[GRASS-SVN] r40350 - in grass/branches/develbranch_6/scripts: . v.in.lines

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jan 9 08:24:00 EST 2010


Author: hamish
Date: 2010-01-09 08:23:59 -0500 (Sat, 09 Jan 2010)
New Revision: 40350

Added:
   grass/branches/develbranch_6/scripts/v.in.lines/
Removed:
   grass/branches/develbranch_6/scripts/v.in.lines/v.in.lines.py
Modified:
   grass/branches/develbranch_6/scripts/Makefile
Log:
module to import vector lines from a stream of x,y data (move from addons)

Modified: grass/branches/develbranch_6/scripts/Makefile
===================================================================
--- grass/branches/develbranch_6/scripts/Makefile	2010-01-09 13:23:31 UTC (rev 40349)
+++ grass/branches/develbranch_6/scripts/Makefile	2010-01-09 13:23:59 UTC (rev 40350)
@@ -73,6 +73,7 @@
 	v.in.geonames \
 	v.in.gns \
 	v.in.gpsbabel \
+	v.in.lines \
 	v.in.mapgen \
 	v.in.sites.all \
 	v.in.wfs \

Deleted: grass/branches/develbranch_6/scripts/v.in.lines/v.in.lines.py
===================================================================
--- grass-addons/vector/v.in.lines/v.in.lines.py	2010-01-09 13:17:25 UTC (rev 40348)
+++ grass/branches/develbranch_6/scripts/v.in.lines/v.in.lines.py	2010-01-09 13:23:59 UTC (rev 40350)
@@ -1,150 +0,0 @@
-#!/usr/bin/env python
-#
-############################################################################
-#
-# MODULE:       v.in.lines
-#
-# AUTHOR(S):    Hamish Bowman
-#
-# PURPOSE:      Import point data as lines ('v.in.mapgen -f' wrapper script)
-#
-# COPYRIGHT:    (c) 2009-2010 The GRASS Development Team
-#
-#               This program is free software under the GNU General Public
-#               License (>=v2). Read the file COPYING that comes with GRASS
-#               for details.
-#
-#############################################################################
-#%Module
-#% description: Import ASCII x,y[,z] coordinates as a series of lines.
-#% keywords: vector, import
-#%End
-#%flag
-#% key: z
-#% description: Create a 3D line from 3 column data 
-#%end
-#%option
-#% key: input
-#% type: string
-#% gisprompt: old_file,file,input
-#% description: Name of input file (or "-" to read from stdin)
-#% required : yes
-#%end
-#%option
-#% key: output
-#% type: string
-#% gisprompt: new,vector,vector
-#% description: Name for output vector map
-#% required : yes
-#%end
-#%option
-#% key: fs
-#% type: string
-#% key_desc: character
-#% description: Field separator
-#% answer: |
-#% required: no
-#%end
-
-import sys
-import os
-import atexit
-import string
-from grass.script import core as grass
-
-def cleanup():
-    grass.try_remove(tmp)
-
-def main():
-    global tmp
-
-    infile_opt = options['input']
-    output = options['output']
-    fs = options['fs']
-    threeD = flags['z']
-
-    prog = 'v.in.lines'
-
-    opts = ""
-
-    if threeD:
-        do3D = 'z'
-    else:
-        do3D = ''
-
-
-    tmp = grass.tempfile()
-
-
-    #### parse field separator
-    if fs in ('space', 'tab'):
-        fs = ' '
-    elif fs == 'comma':
-        fs = ','
-    else:
-        if len(fs) > 1:
-            grass.warning(_("Invalid field separator, using '%s'") % fs[0])
-        try:
-            fs = fs[0]
-        except IndexError:
-            grass.fatal(_("Invalid field separator '%s'") % fs)
-
-    #### set up input file
-    if infile_opt == '-':
-        infile = None
-        inf = sys.stdin
-    else:
-        infile = infile_opt
-        if not os.path.exists(infile):
-            grass.fatal(_("Unable to read input file <%s>") % infile)
-        grass.debug("input file=[%s]" % infile)
-
-
-    if not infile:
-        # read from stdin and write to tmpfile (v.in.mapgen wants a real file)
-        outf = file(tmp, 'w')
-        for line in inf:
-            if len(line.lstrip()) == 0 or line[0] == '#':
-                continue
-            outf.write(line.replace(fs, ' '))
-
-        outf.close()
-        runfile = tmp
-    else:
-        # read from a real file
-        if fs == ' ':
-            runfile = infile
-        else:
-            inf = file(infile)
-            outf = file(tmp, 'w')
-
-            for line in inf:
-                if len(line.lstrip()) == 0 or line[0] == '#':
-                    continue
-                outf.write(line.replace(fs, ' '))
-
-            inf.close()
-            outf.close()
-            runfile = tmp
-
-
-    ##### check that there are at least two columns (three if -z is given)
-    inf = file(runfile)
-    for line in inf:
-        if len(line.lstrip()) == 0 or line[0] == '#':
-            continue
-        numcols = len(line.split())
-        break
-    if (do3D and numcols < 3) or (not do3D and numcols < 2):
-        grass.fatal(_("Not enough data columns. (incorrect fs setting?)"))
-    inf.close()
-
-
-    grass.run_command('v.in.mapgen', flags = 'f' + do3D,
-                      input = runfile, output = output)
-
-
-if __name__ == "__main__":
-    options, flags = grass.parser()
-    atexit.register(cleanup)
-    main()



More information about the grass-commit mailing list