[GRASS-SVN] r68480 - in grass-addons/grass7/vector: . v.delaunay3d v.explode

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 21 13:24:32 PDT 2016


Author: amuriy
Date: 2016-05-21 13:24:32 -0700 (Sat, 21 May 2016)
New Revision: 68480

Added:
   grass-addons/grass7/vector/v.explode/
   grass-addons/grass7/vector/v.explode/Makefile
   grass-addons/grass7/vector/v.explode/v.explode.html
   grass-addons/grass7/vector/v.explode/v.explode.py
Modified:
   grass-addons/grass7/vector/v.delaunay3d/Makefile
Log:
<v.explode> script added

Modified: grass-addons/grass7/vector/v.delaunay3d/Makefile
===================================================================
--- grass-addons/grass7/vector/v.delaunay3d/Makefile	2016-05-20 21:01:30 UTC (rev 68479)
+++ grass-addons/grass7/vector/v.delaunay3d/Makefile	2016-05-21 20:24:32 UTC (rev 68480)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = /usr/lib/grass70
 
 PGM = v.delaunay3d
 

Added: grass-addons/grass7/vector/v.explode/Makefile
===================================================================
--- grass-addons/grass7/vector/v.explode/Makefile	                        (rev 0)
+++ grass-addons/grass7/vector/v.explode/Makefile	2016-05-21 20:24:32 UTC (rev 68480)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = v.explode
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script

Added: grass-addons/grass7/vector/v.explode/v.explode.html
===================================================================
--- grass-addons/grass7/vector/v.explode/v.explode.html	                        (rev 0)
+++ grass-addons/grass7/vector/v.explode/v.explode.html	2016-05-21 20:24:32 UTC (rev 68480)
@@ -0,0 +1,24 @@
+<h2>DESCRIPTION</h2>
+
+<em>v.explode</em> "explode" polylines, splitting them to separate lines
+
+<h2>NOTES</h2>
+
+Module is a simple wrapper to <v.split> + <v.category>.
+
+<h2>EXAMPLES</h2>
+
+<div class="code"><pre>
+    v.explode input=polylines output=lines
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<em>
+  <a href="v.split.html">v.split</a>
+  <a href="v.category.html">v.category</a>
+</em>
+
+<h2>AUTHOR</h2>
+
+Alexander Muriy (IEG RAS, Moscow)

Added: grass-addons/grass7/vector/v.explode/v.explode.py
===================================================================
--- grass-addons/grass7/vector/v.explode/v.explode.py	                        (rev 0)
+++ grass-addons/grass7/vector/v.explode/v.explode.py	2016-05-21 20:24:32 UTC (rev 68480)
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE:       v.explode
+# AUTHOR(S):    Alexander Muriy
+#               (Institute of Environmental Geoscience, Moscow, Russia)  
+#               e-mail: amuriy AT gmail DOT com 
+#
+# PURPOSE:      "Explode" polylines, splitting them to separate lines
+#
+# COPYRIGHT:    (C) 2016 Alexander Muriy / GRASS Development Team
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+############################################################################
+#%Module 
+#%  description: "Explode" polylines, splitting them to separate lines (uses v.split + v.category)
+#%  keywords: display, graphics, vector, symbology
+#%End
+#%Option
+#%  key: input
+#%  type: string
+#%  required: yes
+#%  multiple: no
+#%  key_desc: name
+#%  description: Name of input vector map
+#%  gisprompt: old,vector,vector
+#%End
+#%Option
+#%  key: output
+#%  type: string
+#%  required: no
+#%  multiple: no
+#%  key_desc: name
+#%  description: Name of output vector map 
+#%  gisprompt: new,vector,vector
+#%End
+############################################################################
+
+import os
+import atexit
+
+try:
+    import grass.script as grass
+except:
+    try:
+        from grass.script import core as grass
+    except:
+        if not os.environ.has_key("GISBASE"):
+            print "You must be in GRASS GIS to run this program."
+            sys.exit(1)
+        
+
+def cleanup():
+    nuldev = file(os.devnull, 'w')
+    grass.run_command('g.remove', type_ = 'vect', pattern = 'v_explode*', flags = 'f',
+                      quiet = True, stderr = nuldev)
+
+def main():
+    inmap = options['input']
+    outmap = options['output']
+
+    global nuldev
+    nuldev = None
+
+    # check if input file exists
+    if not grass.find_file(inmap, element = 'vector')['file']:
+        grass.fatal(_("<%s> does not exist.") % inmap)
+
+    
+    out_split = 'v_explode' + '_' + 'split'
+    grass.run_command('v.split', input_ = inmap, vertices = 2, 
+                          out = out_split, quiet = True, stderr = nuldev)
+    out_catdel = 'v_explode' + '_' + 'catdel'
+    grass.run_command('v.category', input_ = out_split, opt = 'del', 
+                      output = out_catdel, quiet = True, stderr = nuldev)
+    grass.run_command('v.category', input_ = out_catdel, opt = 'add', 
+                      output = outmap, quiet = True, stderr = nuldev)
+    
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    atexit.register(cleanup)
+    main()


Property changes on: grass-addons/grass7/vector/v.explode/v.explode.py
___________________________________________________________________
Added: svn:executable
   + *



More information about the grass-commit mailing list