[GRASS-SVN] r40160 - in grass-addons/vector: . v.in.lines
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Dec 28 20:53:28 EST 2009
Author: hamish
Date: 2009-12-28 20:53:27 -0500 (Mon, 28 Dec 2009)
New Revision: 40160
Added:
grass-addons/vector/v.in.lines/
grass-addons/vector/v.in.lines/Makefile
grass-addons/vector/v.in.lines/description.html
grass-addons/vector/v.in.lines/v.in.lines
Log:
new module: imports x,y[,z] ASCII coodinates as a series of vector lines. after testing & porting to python it should be moved into the main archive.
Added: grass-addons/vector/v.in.lines/Makefile
===================================================================
--- grass-addons/vector/v.in.lines/Makefile (rev 0)
+++ grass-addons/vector/v.in.lines/Makefile 2009-12-29 01:53:27 UTC (rev 40160)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = v.in.lines
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Property changes on: grass-addons/vector/v.in.lines/Makefile
___________________________________________________________________
Added: svn:mime-type
+ text/x-makefile
Added: svn:eol-style
+ native
Added: grass-addons/vector/v.in.lines/description.html
===================================================================
--- grass-addons/vector/v.in.lines/description.html (rev 0)
+++ grass-addons/vector/v.in.lines/description.html 2009-12-29 01:53:27 UTC (rev 40160)
@@ -0,0 +1,33 @@
+<H2>DESCRIPTION</H2>
+
+Imports a stream of ASCII x,y[,z] coordinates as a line or series of lines.
+
+
+<H2>NOTES</H2>
+
+Input ASCII coordinates are simply a series of "x y" data points.
+Lines are separated by a row containing "<tt>NaN NaN</tt>". Line
+categories start at 1 and increase sequentially.
+<P>
+You can import 3D lines by providing 3 columns of data in the input
+stream and using the <B>-z</B> flag.
+<P>
+This script is a simple wrapper around the <em>v.in.mapgen</em> module.
+
+
+<H2>SEE ALSO</H2>
+<em>
+<A HREF="v.in.ascii.html">v.in.ascii</A><br>
+<A HREF="v.in.mapgen.html">v.in.mapgen</A><br>
+<A HREF="v.out.ascii.html">v.out.ascii</A><br>
+<A HREF="r.in.poly.html">r.in.poly</A>
+</em>
+
+
+<H2>AUTHOR</H2>
+
+Hamish Bowman<BR>
+Dunedin, New Zealand
+
+<p>
+<i>Last changed: $Date$</i>
Property changes on: grass-addons/vector/v.in.lines/description.html
___________________________________________________________________
Added: svn:mime-type
+ text/html
Added: svn:keywords
+ Author Date Id
Added: svn:eol-style
+ native
Added: grass-addons/vector/v.in.lines/v.in.lines
===================================================================
--- grass-addons/vector/v.in.lines/v.in.lines (rev 0)
+++ grass-addons/vector/v.in.lines/v.in.lines 2009-12-29 01:53:27 UTC (rev 40160)
@@ -0,0 +1,133 @@
+#!/bin/sh
+#
+############################################################################
+#
+# MODULE: v.in.lines
+#
+# AUTHOR(S): Hamish Bowman
+#
+# PURPOSE: Import point data as lines ('v.in.mapgen -f' wrapper script)
+#
+# COPYRIGHT: (c) 2009 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
+
+
+if [ -z "$GISBASE" ] ; then
+ echo "You must be in GRASS GIS to run this program." >&2
+ exit 1
+fi
+
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+ exec g.parser "$0" "$@"
+fi
+
+
+#### setup temporary file
+TMP="`g.tempfile pid=$$`"
+if [ $? -ne 0 ] || [ -z "$TMP" ] ; then
+ g.message -e "unable to create temporary files"
+ exit 1
+fi
+
+#### trap ctrl-c so that we can clean up tmp
+trap 'rm -f "$TMP"' 2 3 15
+
+#### parse field separator
+if [ "$GIS_OPT_FS" = "space" ] || [ "$GIS_OPT_FS" = "tab" ] ; then
+ fs=" "
+else
+ fs="`echo "$GIS_OPT_FS" | cut -c1`"
+fi
+
+
+if [ "$GIS_OPT_INPUT" = "-" ] ; then
+ # read from stdin to temp file (code borrowed from m.proj)
+ EXITCODE=0
+ while [ $EXITCODE -eq 0 ] ; do
+ unset REPLY
+ read REPLY
+ EXITCODE=$?
+ if [ -n "$REPLY" ] ; then
+ echo "$REPLY" >> "$TMP.raw"
+ fi
+ done
+
+ if [ "$fs" = " " ] ; then
+ \mv -f "$TMP.raw" "$TMP"
+ else
+ tr "$fs" ' ' < "$TMP.raw" > "$TMP"
+ \rm -f "$TMP.raw"
+ fi
+
+ # make sure we have at least one line of data
+ if [ "`wc -l "$TMP" | cut -f1 -d' '`" -eq 0 ] ; then
+ g.message -e "Problem reading data from stdin"
+ exit 1
+ fi
+
+ INFILE="$TMP"
+else
+ if [ "$fs" = " " ] ; then
+ INFILE="$GIS_OPT_INPUT"
+ else
+ tr "$fs" ' ' < "$GIS_OPT_INPUT" > "$TMP"
+ INFILE="$TMP"
+ fi
+fi
+
+
+if [ "$GIS_FLAG_Z" -eq 1 ] ; then
+ ZFLAG="-z"
+else
+ ZFLAG=""
+fi
+
+if [ -z "`head -n 1 "$INFILE" | sed -e 's/[^ \t]*$//'`" ] ; then
+ g.message -e "Not enough data columns. (incorrect fs setting?)"
+ rm -f "$TMP"
+ exit 1
+fi
+
+v.in.mapgen -f $ZFLAG in="$INFILE" out="$GIS_OPT_OUTPUT"
+EXITCODE=$?
+
+#cleanup
+rm -f "$TMP"
+
+
+exit $EXITCODE
Property changes on: grass-addons/vector/v.in.lines/v.in.lines
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/x-sh
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list