Browse Source

remove disabled v.in.gps and related v.out.gps (will be moved to addons)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@64698 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 years ago
parent
commit
41470deda0

+ 0 - 11
scripts/v.in.gps/Makefile

@@ -1,11 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = v.in.gps
-
-include $(MODULE_TOPDIR)/include/Make/Script.make
-
-default: script
-	$(MAKE) $(ETC)/grass_write_ascii.style
-
-$(ETC)/%: %
-	$(INSTALL_DATA) $< $@

+ 0 - 31
scripts/v.in.gps/grass_write_ascii.style

@@ -1,31 +0,0 @@
-# gpsbabel XCSV style file
-#
-# http://www.gpsbabel.org/htmldoc-development/styles_intro.html
-# http://www.gpsbabel.org/htmldoc-development/Styles.html
-# http://www.gpsbabel.org/htmldoc-development/style_intro2.html
-#
-# Format: GRASS ASCII Vector style
-# Author: Spano Lucio Davide & Claudio Porta
-#   Date: 31 May 2005
-#
-
-DESCRIPTION		GRASS ASCII Vector style
-EXTENSION		csv
-
-#
-# FILE LAYOUT DEFINITIONS:
-#   field_delim could be set to "PIPE", but older versions of gpsbabel
-#   (i.e. 1.2.4) don't know about that so we need to use "|" here.
-#
-FIELD_DELIMITER		|
-RECORD_DELIMITER	NEWLINE
-
-#
-# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:
-#
-IFIELD LON_DECIMAL,"","%.8f"
-IFIELD LAT_DECIMAL,"","%.8f"
-IFIELD ALT_METERS,"","%f"
-IFIELD GMT_TIME,"","%m/%d/%Y+%H:%M:%S %p"
-IFIELD	DESCRIPTION, "" , "%s"
-

+ 0 - 98
scripts/v.in.gps/v.in.gps.html

@@ -1,98 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>v.in.gps</em> allows the user to import waypoint, route, and track
-data from a locally connected GPS receiver or a text file containing 
-GPS data of many common formats. Translation is done via the 
-<em><a href="http://www.gpsbabel.org">GPSBabel</a></em> program. 
-
-<p>This software is not intended as a primary means of navigation.
-
-<h2>NOTES</h2>
-
-<em>v.in.gps</em> automatically reprojects data using the 
-projection settings of the current location.
-
-The default input data projection is lat/lon WGS84. If your GPS outputs data
-using another projection or map datum, you may include the 
-<em><a href="http://trac.osgeo.org/proj/">PROJ.4</a></em>
-parameters defining your projection in the <b>proj</b> option and 
-<em>v.in.gps</em> will reproject your data accordingly.
-Great care must be taken to get these parameters correct!
-
-The automatic transform may be skipped by using the <b>-k</b> flag in which 
-case the data will be imported unprojected, as it appears in the <b>input</b>.
-
-<p>Route and Track data may be uploaded as a series of points by using the <b>-p</b> 
-flag, otherwise they will be imported as lines. You can run <em>v.in.gps</em>
-multiple times and merge the line and point vectors with the <em>v.patch</em>
-command if you want, but take care when merging dissimilar attribute tables.
-
-<h2>EXAMPLES</h2>
-
-<h3>GPS device connected via USB adapter</h3>
-
-Import waypoints, tracks, routes from /dev/ttyUSB0 and save
-to a GRASS vector map:
-<div class="code"><pre>
-v.in.gps -w input=/dev/ttyUSB0 format=garmin output=waypoints
-v.in.gps -t input=/dev/ttyUSB0 format=garmin output=tracks
-v.in.gps -r input=/dev/ttyUSB0 format=garmin output=routes
-</pre></div>
-
-<h3>GPS device connected via serial adapter</h3>
-
-Import waypoint data from a Garmin GPS connected at /dev/ttyS0 and save
-to a GRASS vector map named <i>waypoints</i>:
-<div class="code"><pre>
-v.in.gps -w input=/dev/ttyS0 format=garmin output=waypoints
-</pre></div>
-
-<h3>Import track data from a GPX</h3>
-
-Import track data from a GPX text file and save to a GRASS vector map 
-named <i>tracks</i>.
-<!-- (currently buggy) The gpxlogger program distributed with 
-<a href="http://gpsd.berlios.de/">GPSd</a> >2.30 is a good program for 
-creating these logs. -->
-<div class="code"><pre>
-v.in.gps -t input=gpslog.gpx format=gpx output=tracks
-</pre></div>
-
-<h3>Import route data from GPS connected at /dev/gps</h3>
-
-Import route data as a series of points from a Garmin GPS connected at 
-/dev/gps and save to a GRASS vector map named <i>routePoints</i>:
-<div class="code"><pre>
-v.in.gps -r -p file=/dev/gps format=garmin output=routePoints
-</pre></div>
-
-
-<h2>SEE ALSO</h2>
-<em>
-<a href="db.execute.html">db.execute</a>,
-<a href="v.in.ascii.html">v.in.ascii</a>,
-<a href="v.in.garmin.html">v.in.garmin</a>,
-<a href="v.db.connect.html">v.db.connect</a>,
-<a href="v.patch.html">v.patch</a>
-</em>
-
-<a href="http://www.gpsbabel.org">gpsbabel</a> from gpsbabel.org<br>
-cs2cs from <a href="http://trac.osgeo.org/proj/">PROJ.4</a>
-
-<h2>AUTHORS</h2>
-Claudio Porta and Lucio Davide Spano, students of Computer Science at
-University of Pisa (Italy).<br>
-Commission from Faunalia Pontedera (PI)<br><br>
-Based on <em>v.in.garmin</em> for GRASS 6.0 by Hamish Bowman<br>
-and <em>v.in.garmin.sh</em> for GRASS 5 by Andreas Lange
-<br>
-
-<!--
-When we tested the script with a Garmin GPS we noticed that importing waypoints 
-the <i>time</i> field is not correctly set. The data reported is 
-a default system time, while with a gpx text file this thing did not 
-happen. We believe that is a <i>gpsbabel</i> trouble in translating 
-from <i>garmin</i> to <i>xcsv</i> ... 
--->
-
-<p><i>Last changed: $Date$</i>

+ 0 - 244
scripts/v.in.gps/v.in.gps.py

@@ -1,244 +0,0 @@
-#!/usr/bin/env python
-#
-############################################################################
-#
-# MODULE:	v.in.gps
-#
-# PURPOSE:	Import GPS data from a GPS receiver or file into a GRASS
-#	       vector map using gpsbabel
-#
-# COPYRIGHT:	(c) 2011 Hamish Bowman, and 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.
-#
-# AUTHOR:	Hamish Bowman, Dunedin, New Zealand
-#		Python version based on v.out.gps.py by Glynn Clements
-#		Work-alike of the v.in.gpsbabel shell script from GRASS 6
-#
-#############################################################################
-#
-# REQUIREMENTS:
-#      -  GPSBabel from 	http://gpsbabel.sourceforge.net
-#      -  cs2cs from PROJ.4 (for m.proj)	http://proj.osgeo.org
-#
-#      - report supported GPSBabel formats:
-#	 gpsbabel -^2 | tr '\t' ';' | sort -t';' -k3
-#
-#############################################################################
-#
-# How to do it
-#   http://www.gdal.org/ogr/drv_gpx.html
-#   gpsbabel [options] -i INTYPE -f INFILE -o OUTTYPE -F OUTFILE
-#
-#############################################################################
-
-#%Module
-#% description: Import waypoints, routes, and tracks from a GPS receiver or GPS download file into a vector map.
-#% keyword: vector
-#% keyword: import
-#% keyword: GPS
-#%End
-#%flag
-#% key: w
-#% description: Import as waypoints
-#%end
-#%flag
-#% key: r
-#% description: Import as routes
-#%end
-#%flag
-#% key: t
-#% description: Import as tracks
-#%end
-#%flag
-#% key: p
-#% description: Force vertices of track or route data as points
-#%end
-#%flag
-#% key: k
-#% description: Do not attempt projection transform from WGS84
-#%end
-#%option G_OPT_F_INPUT
-#% description: Device or file used to import data
-#%end
-#%option G_OPT_V_OUTPUT
-#%end
-#%option
-#% key: format
-#% type: string
-#% description: GPSBabel supported output format
-#% answer: gpx
-#%end
-#%option
-#% key: proj
-#% type: string
-#% description: Projection of input data (PROJ.4 style), if not set Lat/Lon WGS84 is assumed
-#% required: no
-#%end
-
-
-
-import sys
-import os
-import atexit
-import string
-import re
-
-import grass.script as grass
-from grass.exceptions import CalledModuleError
-
-
-#.... todo ....
-
-def main():
-    format = options['format']
-    input = options['input']
-    output = options['output']
-    proj_terms = options['proj']
-    wpt = flags['w']
-    rte = flags['r']
-    trk = flags['t']
-    points_mode = flags['p']
-    no_reproj = flags['k']
-
-    nflags = len(filter(None, [wpt, rte, trk]))
-    if nflags > 1:
-	grass.fatal(_("One feature at a time please."))
-    if nflags < 1:
-	grass.fatal(_("No features requested for import."))
-
-
-    #### check for gpsbabel
-    ### FIXME: may need --help or similar?
-    if not grass.find_program("gpsbabel"):
-	grass.fatal(_("The gpsbabel program was not found, please install it first.\n") +
-		    "http://gpsbabel.sourceforge.net")
-
-    #### check for cs2cs
-    if not grass.find_program("cs2cs"):
-	grass.fatal(_("The cs2cs program was not found, please install it first.\n") +
-		    "http://proj.osgeo.org")
-
-#todo
-#    # check if we will overwrite data
-#    if grass.findfile(output) and not grass.overwrite():
-#	grass.fatal(_("Output file already exists."))
-
-    #### set temporary files
-    tmp = grass.tempfile()
-
-    # import as GPX using v.in.ogr
-#     if trk:
-# 	linetype = "FORCE_GPX_TRACK=YES"
-#     elif rte:
-# 	linetype = "FORCE_GPX_TRACK=YES"
-#     else:
-# 	linetype = None
-
-    if format == 'gpx':
-	# short circuit, we have what we came for.
-#todo
-#	grass.try_remove(output)
-#	os.rename(tmp_gpx, output)
-	grass.verbose("Fast exit.")
-	sys.exit()
-
-    # run gpsbabel
-    if wpt:
-	gtype = '-w'
-    elif trk:
-	gtype = '-t'
-    elif rte:
-	gtype = '-r'
-    else:
-	gtype = ''
-
-    grass.verbose("Running GPSBabel ...")
-
-    ret = grass.call(['gpsbabel',
-		      gtype,
-		      '-i', format,
-		      '-f', output,
-		      '-o', 'gpx',
-		      '-F', tmp + '.gpx')
-
-    if ret != 0:
-	grass.fatal(_("Error running GPSBabel"))
-
-
-    grass.verbose("Importing data ...")
-
-    tmp_gpx = tmp + ".gpx"
-    try:
-        grass.run_command('v.in.ogr', input=tmp_gpx, output=output,
-                          type=type, format='GPX', lco=linetype,
-                          dsco="GPX_USE_EXTENSIONS=YES", quiet=True)
-    except CalledModuleError:
-        grass.fatal(_("Error importing data"))
-
-    #### set up projection info
-    # TODO: check if we are already in ll/WGS84.  If so skip m.proj step.
-
-    # TODO: multi layer will probably fail badly due to sed 's/^ 1   /'
-    #   output as old GRASS 4 vector ascii and fight with dig_ascii/?
-    #   Change to s/^ \([0-9]   .*\)    /# \1/' ??? mmph.
-
-#todo (taken from Glynn's v.out.gps)
-    # reproject to lat/lon WGS84
-#     grass.verbose("Reprojecting data ...")
-# 
-#     re1 = re.compile(r'^\([PLBCFKA]\)')
-#     re2 = re.compile(r'^ 1     ')
-# 
-#     re3 = re.compile(r'\t\([-\.0-9]*\) .*')
-#     re4 = re.compile(r'^\([-\.0-9]\)')
-#     re5 = re.compile(r'^#')
-# 
-#     tmp_proj = tmp + ".proj"
-#     tf = open(tmp_proj, 'w')
-#     p1 = grass.pipe_command('v.out.ascii', input = inmap, format = 'standard')
-#     p2 = grass.feed_command('m.proj', input = '-', flags = 'od', quiet = True, stdout = tf)
-#     tf.close()
-# 
-#     lineno = 0
-#     for line in p1.stdout:
-# 	lineno += 1
-# 	if lineno < 11:
-# 	    continue
-# 	line = re1.sub(r'#\1', line)
-# 	line = re2.sub(r'# 1  ', line)
-# 	p2.stdin.write(line)
-# 
-#     p2.stdin.close()
-#     p1.wait()
-#     p2.wait()
-# 
-#     if p1.returncode != 0 or p2.returncode != 0:
-# 	grass.fatal(_("Error reprojecting data"))
-# 
-#     tmp_vogb = "tmp_vogb_epsg4326_%d" % os.getpid()
-#     p3 = grass.feed_command('v.in.ascii', out = tmp_vogb, format = 'standard', flags = 'n', quiet = True)
-#     tf = open(tmp_proj, 'r')
-# 
-#     for line in tf:
-# 	line = re3.sub(r' \1', line)
-# 	line = re4.sub(r' \1', line)
-# 	line = re5.sub('', line)
-# 	p3.stdin.write(line)
-# 
-#     p3.stdin.close()
-#     tf.close()
-#     p3.wait()
-# 
-#     if p3.returncode != 0:
-# 	grass.fatal(_("Error reprojecting data"))
-
-
-
-    grass.verbose("Done.")
-
-if __name__ == "__main__":
-    options, flags = grass.parser()
-    atexit.register(cleanup)
-    main()

+ 0 - 719
scripts/v.in.gps/v.in.gpsbabel

@@ -1,719 +0,0 @@
-#!/bin/sh
-# 
-############################################################################
-#
-# MODULE:      v.in.gpsbabel
-#
-# PURPOSE:     Import GPS data from a GPS receiver or file into a GRASS
-#	       vector map using gpsbabel
-#
-# COPYRIGHT:   (c) 2000-2007 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.
-#
-# AUTHORS:     Claudio Porta & Lucio Davide Spano, students of Computer 
-#		  Science, University of Pisa (Italy).
-#		Commission from Faunalia Pontedera (PI)
-#
-#               With updates by Markus Neteler and Hamish Bowman
-#
-#		Based on v.in.garmin for GRASS 6 by Hamish Bowman
-#		and v.in.garmin.sh for GRASS 5 by Andreas Lange
-#
-#############################################################################
-#
-# REQUIREMENTS:
-#      -  gpsbabel from:
-#	     http://gpsbabel.sourceforge.net
-#      -  unix tools: grep, cat, cut, paste, awk/nawk/gawk, sed
-#      -  cs2cs from PROJ.4    http://proj.maptools.org/
-#
-#      - report supported formats:
-#	 gpsbabel -^2 | tr '\t' ';' | sort -t';' -k3
-#
-#############################################################################
-
-#%Module
-#%  description: Import waypoints, routes, and tracks from a GPS receiver or GPS download file into a vector map.
-#%  keywords: vector, import, GPS
-#%End
-#%flag
-#%  key: v
-#%  description: Verbose mode
-#%end
-#%flag
-#%  key: w
-#%  description: Import waypoints
-#%end
-#%flag
-#%  key: r
-#%  description: Import routes
-#%end
-#%flag
-#%  key: t
-#%  description: Import track
-#%end
-#%flag
-#%  key: p
-#%  description: Force vertices of track or route data as points
-#%end
-#%flag
-#%  key: k
-#%  description: Do not attempt projection transform from WGS84
-#%end
-#%option
-#% key: input
-#% type: string
-#% description: Device or file used to import data
-#% gisprompt: old_file,file,file
-#% answer: /dev/gps
-#%end
-#%option
-#% key: output
-#% type: string
-#% gisprompt: new,vector,vector
-#% description: Name for output vector map (omit for display to stdout)
-#% required : no
-#%end
-#%option
-#% key: format
-#% type: string
-#% description: Format of GPS input data (use gpsbabel supported formats)
-#% answer: garmin
-#%end
-#%option
-#% key: proj
-#% type: string
-#% description: Projection of input data (PROJ.4 style), if not set Lat/Lon WGS84 is assumed
-#% required: no
-#%end
-
-if [ -z "$GISBASE" ] ; then
-    echo "You must be in GRASS GIS to run this program." 1>&2
-    exit 1
-fi
-
-if [ "$1" != "@ARGS_PARSED@" ] ; then
-    # save command line
-    CMDLINE=`basename "$0"`
-    for arg in "$@" ; do
-	CMDLINE="$CMDLINE \"$arg\""
-    done
-    export CMDLINE
-    exec g.parser "$0" "$@"
-fi
-
-# set environment so that awk works properly in all languages
-unset LC_ALL
-LC_NUMERIC=C
-export LC_NUMERIC
-
-eval `g.gisenv`
-: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
-LOCATION="$GISDBASE"/"$LOCATION_NAME"/"$MAPSET"
-
-PROG=`basename "$0"`
-
-#### check for gpsbabel 
- if [ ! -x "`which gpsbabel`" ] ; then
-    g.message -e "The gpsbabel program was not found, please install it first.
-                  http://gpsbabel.sourceforge.net"
-    exit 1
-fi
-
-#### check for cs2cs
-if [ ! -x "`which cs2cs`" ] ; then
-    g.message -e "The cs2cs program was not found, please install it first.
-                   http://proj.maptools.org"
-    exit 1
-fi
-
-#### check if we have awk
-if [ ! -x "`which awk`" ] ; then
-    g.message -e "awk is required, please install awk or gawk first."
-    exit 1
-fi
-
-if [ `ogr2ogr --formats | grep -cw GPX` -eq 1 ] ; then
-    g.message -v "OGR is GPX capable."
-    OGR_GPX=1
-else
-    OGR_GPX=0
-fi
-
-#### set temporary files
-TEMPFILE="`g.tempfile pid=$$`"
-if [ $? -ne 0 ] || [ -z "$TEMPFILE" ] ; 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 "${TEMPFILE}."*' 2 3 15
-
-
-#### process command line arguments 
-WPT=1 ; RTE=0 ; TRK=0 ; KEEP_WGS84=0; VERBOSE=0
-
-
-if [ $GIS_FLAG_V -eq 1 ] ; then
-    VERBOSE=1
-    PROGVERBOSE="-D 1"
-fi
-
-if [ -n "$GIS_OPT_OUTPUT" ] ; then
-    NAME="$GIS_OPT_OUTPUT"
-    if [ $VERBOSE -eq 1 ] ; then
-	g.message message="output=$NAME" 
-    fi
-fi
-if [ -n "$GIS_OPT_INPUT" ] ; then
-    GPSdevice="$GIS_OPT_INPUT"
-    if [ $VERBOSE -eq 1 ] ; then
-	g.message message="file=$GIS_OPT_INPUT"
-    fi
-fi
-
-
-if [ $GIS_FLAG_W -eq 1 ] && ([ $GIS_FLAG_R -eq 1 ] || [ $GIS_FLAG_T -eq 1 ]) ; then
-    g.message -e "One feature at a time please. Use v.patch if you need to combine them."
-    rm -f "${TEMPFILE}"
-    exit 1
-fi
-# logic eludes me at pressent..  [combine with above]
-if [ $GIS_FLAG_R -eq 1 ] && [ $GIS_FLAG_T -eq 1 ] ; then
-    g.message -e "One feature at a time please. Use v.patch if you need to combine them."
-    rm -f "${TEMPFILE}"
-    exit 1
-fi
-
-CREATE_POINTS=0
-
-if [ $GIS_FLAG_W -eq 1 ] ; then
-    WPT=1
-    CREATE_POINTS=1
-elif [ $GIS_FLAG_R -eq 1 ] ; then
-    WPT=0
-    RTE=1
-    CREATE_POINTS=0
-elif [ $GIS_FLAG_T -eq 1 ] ; then
-    WPT=0
-    TRK=1
-    CREATE_POINTS=0
-fi
-
-if [ $GIS_FLAG_P -eq 1 ] ; then
-    CREATE_POINTS=1
-fi
-if [ $GIS_FLAG_K -eq 1 ] ; then
-    KEEP_WGS84=1
-fi
-
-if [ $GIS_FLAG_W -eq 0 ] && [ $GIS_FLAG_R -eq 0 ] && [ $GIS_FLAG_T -eq 0 ] ; then
-    g.message -w "No features requested for download. Assuming waypoints."
-    WPT=1
-    CREATE_POINTS=1
-fi
-
-
-#### set up projection info
-if [ -n "$GIS_OPT_PROJ" ] ; then
-    IN_PROJ="$GIS_OPT_PROJ"
-else
-    IN_PROJ="+proj=longlat +datum=WGS84"
-fi
-
-OUT_PROJ=`g.proj -j | (
-    OUT_PROJ=
-    while read line ; do
-	OUT_PROJ="$OUT_PROJ '$line'"
-    done
-    echo "$OUT_PROJ"
-)`
-
-PROJ_TYPE=`g.region -p | grep 'projection' | cut -f2 -d" "`
-
-if [ $PROJ_TYPE -eq 0 ] && [ $KEEP_WGS84 -ne 1 ] ; then
-    g.message -e "Cannot project to a XY location."
-    rm -f "${TEMPFILE}"
-    exit 1
-fi
-
-STYLE="$GISBASE/etc/grass_write_ascii.style"
-
-# How to do it
-#
-# gpsbabel [options] -i INTYPE -f INFILE -o OUTTYPE -F OUTFILE
-# gpsbabel [options] -i INTYPE -o OUTTYPE INFILE [OUTFILE]
-#
-#(GPX file example):
-# gpsbabel -w -i gpx -o xcsv,style=grass_write_ascii.style outfile.csv
-
-#### receive data...
-
-if [ $CREATE_POINTS -eq 1 ] ; then
-    if [ $WPT -eq 1 ] ; then
-	g.message "Loading Waypoints from <$GIS_OPT_INPUT>..." 
-	TYPE="-w"
-    elif [ $RTE -eq 1 ] ; then
-	g.message "Loading Routes as points from <$GIS_OPT_INPUT>..." 
-	TYPE="-r"
-    elif [ $TRK -eq 1 ] ; then
-	g.message "Loading Tracks as points from <$GIS_OPT_INPUT>..." 
-	TYPE="-t"
-    fi
-
-    gpsbabel $TYPE -i $GIS_OPT_FORMAT -f "$GPSdevice" $PROGVERBOSE \
-	-o xcsv,style="$STYLE" -F "$TEMPFILE".xcsv
-    EXITCODE=$?
-
-    if [ "`wc -l < "${TEMPFILE}.xcsv"`" -eq 0 ] ; then
-	g.message -w 'No data! Exiting.'
-	rm -f "${TEMPFILE}."*
-	exit 0
-    fi
-
-else
-    if [ $RTE -eq 1 ] ; then
-	g.message "Loading Routes from <$GIS_OPT_INPUT>..." 
-	TYPE="-r"
-    elif [ $TRK -eq 1 ] ; then
-	g.message "Loading Tracks from <$GIS_OPT_INPUT>..." 
-	TYPE="-t"
-    fi
-    gpsbabel $TYPE -i $GIS_OPT_FORMAT -f "$GPSdevice" $PROGVERBOSE \
-	-o gpx -F "$TEMPFILE".gpx
-    EXITCODE=$?
-
-    if [ $EXITCODE -eq 0 ] && \
-       [ "`grep -c '<rte>' "${TEMPFILE}.gpx"`" -eq 0 ] && \
-       [ "`grep -c '<trk>' "${TEMPFILE}.gpx"`" -eq 0 ] ; then
-	g.message -e 'No data! Exiting.'
-	rm -f "${TEMPFILE}."*
-	exit 0
-    fi
-fi
-
-#### check success/failure
-if [ $EXITCODE -ne 0 ] ; then
-    g.message -e "Error loading data from gpsbabel"
-    rm -f "${TEMPFILE}."*
-    exit 1
-fi
-
-
-###################################
-if [ $CREATE_POINTS -eq 1 ] ; then
-###################################
-
-    cat "${TEMPFILE}.xcsv" | cut -f 1,2 -d '|'| tr '|' ' '  > "$TEMPFILE".base
-# FIXME: if last field (comments) is empty it causes a not-enough fields error in v.in.ascii
-# FIXME: if altitude column is empty (1st attr) v.in.ascii complains as the column type is defined as 'double'
-    cat "${TEMPFILE}.xcsv" | tr '+' '|' | cut -f3,4,5,6 -d '|' | \
-	sed -e 's/-99999999.000000//' -e 's/|$/|_/' \
-	    -e 's/01\/01\/1970|00:00:00 AM/|/' \
-	    -e 's/^|/-9999|/'> "$TEMPFILE".attributes
-
-
-    #### reproject if needed
-    if [ "$IN_PROJ" = "$OUT_PROJ" ] || [ $KEEP_WGS84 -eq 1 ] ; then
-	g.message "No projection transformation performed" 
-	cp "${TEMPFILE}.base" "${TEMPFILE}.P_base"
-    else
-	g.message "Attempting waypoint projection transform with cs2cs" 
-
-	eval cs2cs -f %.9f `echo $IN_PROJ` +to `echo $OUT_PROJ` \
-	  < "${TEMPFILE}.base" > "${TEMPFILE}.P_base"
-
-	EXITCODE=$?
-
-	# check if transform REALLY worked (e.g. when the grid file is not found)
-	BAD_PTS="`grep -c "^\*" "${TEMPFILE}.P_base"`"
-	if [ "$BAD_PTS" -gt 0 ] ; then
-	    g.message message=""
-	    g.message -w "$BAD_PTS point(s) failed reprojection."
-	    EXITCODE=1
-	fi
-	if [ $EXITCODE -ne 0 ] ; then
-	    g.message -w "Projection transform failed, retaining WGS84"
-	    g.message message=""
-	    cp -f "${TEMPFILE}.base" "${TEMPFILE}.P_base"
-	fi
-    fi
-
-    cat "${TEMPFILE}.P_base" | awk '{print $1 "|" $2}' > "${TEMPFILE}.vertices"
-
-    #### and put back together
-    # wpt list:   x|y|<attr1>|...|<attr n>
-    paste -d"|" "$TEMPFILE".vertices "$TEMPFILE".attributes > "$TEMPFILE".asc
-
-    #### output or import
-    if [ -z "$NAME" ] ; then
-	g.message "ASCII file redirected to stdout" 
-	cat "${TEMPFILE}.asc" 2> /dev/null
-    else
-	#### import into new points file
-	if [ $WPT -eq 1 ] ; then
-	    g.message "Importing Waypoints..."
-	elif [ $RTE -eq 1 ] ; then
-	    g.message "Importing Routes as points..."
-	elif [ $TRK -eq 1 ] ; then
-	    g.message "Importing Tracks as points..."
-	fi
-
-	v.in.ascii in="${TEMPFILE}.asc" output="$NAME" cat=0 \
-	  columns='x double precision, y double precision, altitude double precision, gmt_date varchar(10), gmt_time varchar(11), comments varchar(40)'
-	EXITCODE=$?
-
-	# EXITCODE also used at pgm termination below!
-	if [ $EXITCODE -ne 0 ] ; then
-	    g.message -e "While Importing data with v.in.ascii"
-	    rm -f "${TEMPFILE}"*
-	    exit 1
-	fi
-    fi
-
-
-#####################
-else # CREATE_LINES
-#####################
-
-    #### prepare line components
-    if [ $RTE -eq 1 ] ; then
-
-	if [ $ORG_GPX -eq 1 ] ; then
-	    # http://www.gdal.org/ogr/drv_gpx.html
-	    # make it really easy ; but need to reproject from WGS84/LL.
-	    #   use '-c location=', then v.proj it in, then rm -rf the temp locn?
-	    #? GPX_USE_EXTENSIONS=YES
-	    #? export GPX_USE_EXTENSIONS
-	    #v.in.ogr input="$TEMPFILE.gpx" output=$map_name
-	    echo
-	fi
-
-
-	# this part is quite difficult using gpx... I'll explain all I've done
-	# if someone has any suggest please mail!!!!
-
-	# list of bytes where routes finish
-	cat "$TEMPFILE.gpx" | grep -n "</rte>" > "$TEMPFILE.bytes"
-	# number of routes
-	cat "$TEMPFILE.bytes" | grep -c "</rte>" > "$TEMPFILE.var"
-	ROUTE_NUMBER=0 
-	read ROUTE_NUMBER < "$TEMPFILE.var" # route number to process
-	READ_BYTES=0 # offset of bytes already read
-	cp "$TEMPFILE.gpx" "$TEMPFILE.gpx2" # file to be "eaten" by head commands in while 
-	ROUTE_ID=0 # route identifier
-
-	while [ "$ROUTE_NUMBER" -gt 0 ] ; do
-	    head -n 1 "$TEMPFILE.bytes" | cut -f 1 -d ':'> "$TEMPFILE.var"
-	    END_BYTE=0
-	    read END_BYTE < "$TEMPFILE.var" # this route ends at END_BYTE in $TEMPFILE.gpx file
-
-	    TO_READ=0
-	    TO_READ="`expr $END_BYTE - $READ_BYTES`"    # bytes to read from $TEMPFILE.gpx2 file 
-	    READ_BYTES="`expr $READ_BYTES + $TO_READ`"  # update readed bytes
-
-	    # list of points in route
-	    head -n $TO_READ "$TEMPFILE.gpx2" | grep "<rtept" > "$TEMPFILE.points" 
-	    POINTS=0 # number of points in route
-	    cat "$TEMPFILE.points" | grep -c "<rtept" > "$TEMPFILE.var"
-	    read POINTS < "$TEMPFILE.var"
-	    echo "L $POINTS 1" >> "$TEMPFILE.base"
-	    # read lat lon data
-	    cat "$TEMPFILE.points" | cut -f2 -d'<' | cut -f2,3 -d ' ' | cut -f2,4 -d '"' | tr '"' '\t' > "$TEMPFILE.latlon"
-	    cat "$TEMPFILE.latlon" | tr ',' '.' | awk '{printf(" %s %s\n", $2, $1) }' >> "$TEMPFILE.base"
-	    # create attribute line
-	    head -n $TO_READ "$TEMPFILE.gpx2" | grep -n "<rtept" | head -n 1 | cut -f1 -d ':' > "$TEMPFILE.var"
-	    OFFSET=0
-	    read OFFSET < "$TEMPFILE.var"
-	    head -n $OFFSET "$TEMPFILE.gpx2" > "$TEMPFILE.rte_attr"
-	    # read needed attributes
-	    ROUTE_ID="`expr $ROUTE_ID + 1`"
-	    cat "$TEMPFILE.rte_attr"| grep "<number" | tail -n 1 | cut -f2 -d'<' | cut -f2 -d'>' > "$TEMPFILE.var"
-	    NUMBER=0
-	    read NUMBER < "$TEMPFILE.var" # read the route number
-	    cat "$TEMPFILE.rte_attr"| grep "<name" | tail -n 1 | cut -f2 -d'<' | cut -f2 -d'>' > "$TEMPFILE.var"
-	    R_NAME=""
-	    read R_NAME < "$TEMPFILE.var" # read the route name
-
-	    OFFSET="`expr $TO_READ - $OFFSET`"
-	    head -n $TO_READ "$TEMPFILE.gpx2" | tail -n $OFFSET | grep "<name" | head -n 1 | cut -f2 -d'<' | cut -f2 -d'>' > "$TEMPFILE.var"
-	    START_PNT=""
-	    read START_PNT < "$TEMPFILE.var" # read the name of start point
-
-	    # check that numberic values don't try and pass an empty string
-### variable names don't line up with column names ?!
-	    if [ -z "$ROUTE_ID" ] ; then
-		ROUTE_ID="NULL"
-        	g.message -w "Route $ROUTE_NUMBER: category number was empty. Bug?"
-	    fi
-	    if [ -z "$NUMBER" ] ; then
-		NUMBER="NULL"
-		g.message -w "Route $ROUTE_NUMBER: route ID was empty. Bug?"
-	    fi
-
-	    echo "$ROUTE_ID|$NUMBER|$R_NAME|$START_PNT" >> "$TEMPFILE.route_atts"
-
-	    ROUTE_NUMBER="`expr $ROUTE_NUMBER - 1`"
-
-	    # eat files
-	    tail -n $ROUTE_NUMBER "$TEMPFILE.bytes" > "$TEMPFILE.bytes2"
-	    mv "$TEMPFILE.bytes2" "$TEMPFILE.bytes"
-	    head -n $TO_READ "$TEMPFILE.gpx2" > "$TEMPFILE.points"
-	    B_GPX=0
-	    wc -c < "$TEMPFILE.gpx2" > "$TEMPFILE.var"
-	    read B_GPX < "$TEMPFILE.var"
-	    B_PNT=0
-	    wc -c < "$TEMPFILE.points" > "$TEMPFILE.var"
-	    read B_PNT < "$TEMPFILE.var"
-	    TO_READ="`expr $B_GPX - $B_PNT`"
-	    tail -c $TO_READ "$TEMPFILE.gpx2" > "$TEMPFILE.points"
-	    mv "$TEMPFILE.points" "$TEMPFILE.gpx2"
-	done
-	# create attr table: cat(int), id number(int 0-19), name varchar(16+), starting_wpt(varchar 10)
-	ATTR_FILE="${TEMPFILE}.route_atts"
-	ATTR_COLS='cat int, route_id int, name varchar(40), start_wpt varchar(40)'
-    fi
-
-    if [ $TRK -eq 1 ] ; then
-
-	# list of bytes where tracks finish
-	cat "$TEMPFILE.gpx" | grep -n "</trkseg>" > "$TEMPFILE.bytes"
-	# number of tracks
-	cat "$TEMPFILE.bytes" | grep -c "</trkseg>" > "$TEMPFILE.var"
-	TRACK_NUMBER=0 
-	read TRACK_NUMBER < "$TEMPFILE.var" # route number to process
-	READ_BYTES=0 # offset of bytes already read
-	cp "$TEMPFILE.gpx" "$TEMPFILE.gpx2" # file to be "eaten" by head commands in while 
-	TRACK_ID=0 # track identifier
-	while [ "$TRACK_NUMBER" -gt 0 ] ; do
-	    head -n 1 "$TEMPFILE.bytes" | cut -f 1 -d ':'> "$TEMPFILE.var"
-	    END_BYTE=0
-	    read END_BYTE < "$TEMPFILE.var" # this route ends at END_BYTE in $TEMPFILE.gpx file
-	    TO_READ=0
-
-	    TO_READ="`expr $END_BYTE - $READ_BYTES`"    # bytes to read from $TEMPFILE.gpx2 file 
-	    READ_BYTES="`expr $READ_BYTES + $TO_READ`"  # update readed bytes
-
-	    # list of points in route
-	    head -n $TO_READ "$TEMPFILE.gpx2" | grep "<trkpt" > "$TEMPFILE.points" 
-	    POINTS=0 # number of points in track 
-	    cat "$TEMPFILE.points" | grep -c "<trkpt" > "$TEMPFILE.var"
-	    read POINTS < "$TEMPFILE.var"
-	    echo "L $POINTS 1" >> "$TEMPFILE.base"
-	    # read lat lon data
-	    cat "$TEMPFILE.points" | cut -f2 -d'<' | cut -f2,3 -d ' ' | cut -f2,4 -d '"' | tr '"' '\t' > "$TEMPFILE.latlon"
-	    cat "$TEMPFILE.latlon" | tr ',' '.' | awk '{printf(" %s %s\n", $2, $1) }' >> "$TEMPFILE.base"
-	    # create attribute line
-	    head -n $TO_READ "$TEMPFILE.gpx2" | grep -n "<trk" | head -n 1 | cut -f1 -d ':' > "$TEMPFILE.var"
-	    OFFSET=0
-	    read OFFSET < "$TEMPFILE.var"
-	    S_LAT=""
-	    head -n 1 "$TEMPFILE.latlon" | cut -f1 > "$TEMPFILE.var"
-	    read S_LAT < "$TEMPFILE.var"
-	    S_LON=""
-	    head -n 1 "$TEMPFILE.latlon" | cut -f2 > "$TEMPFILE.var"
-	    read S_LON < "$TEMPFILE.var"
-	    E_LAT=""
-	    tail -n 1 "$TEMPFILE.latlon" | cut -f1 > "$TEMPFILE.var"
-	    read E_LAT < "$TEMPFILE.var"
-	    E_LON=""
-	    tail -n 1 "$TEMPFILE.latlon" | cut -f2 > "$TEMPFILE.var"
-	    read E_LON < "$TEMPFILE.var"
-
-	    OFFSET="`expr $TO_READ - $OFFSET`"
-
-	    head -n $TO_READ "$TEMPFILE.gpx2" | tail -n $OFFSET | grep "<time" > "$TEMPFILE.time"
-	    S_TIME=""
-	    head -n 1 "$TEMPFILE.time" | cut -f 2 -d'>' | cut -f1 -d'<' > "$TEMPFILE.var"
-	    read S_TIME < "$TEMPFILE.var"
-	    E_TIME=""
-	    tail -n 1 "$TEMPFILE.time" | cut -f 2 -d'>' | cut -f1 -d'<' > "$TEMPFILE.var"
-	    read E_TIME < "$TEMPFILE.var"
-
-	    TRACK_ID="`expr $TRACK_ID + 1`"
-
-	    # check that numberic values don't try and pass an empty string
-	    if [ -z "$TRACK_ID" ] ; then
-		TRACK_ID="NULL"
-		g.message -w "Track $TRACK_NUMBER: category number was empty. Bug?"
-	    fi
-	    if [ -z "$S_LAT" ] ; then
-		S_LAT="NULL"
-		g.message -w "Track $TRACK_NUMBER:  starting lat was empty. Bug?"
-	    fi
-	    if [ -z "$S_LON" ] ; then
-		S_LON="NULL"
-		g.message -w "Track $TRACK_NUMBER:  starting lon was empty. Bug?"
-	    fi
-	    if [ -z "$E_LAT" ] ; then
-		E_LAT="NULL"
-		g.message -w "Track $TRACK_NUMBER:  ending lat was empty. Bug?"
-	    fi
-	    if [ -z "$E_LON" ] ; then
-		E_LON="NULL"
-		g.message -w "Track $TRACK_NUMBER:  ending lon was empty. Bug?"
-	    fi
-
-	    echo "$TRACK_ID|$S_TIME|$S_LAT|$S_LON|$E_TIME|$E_LAT|$E_LON" >> "$TEMPFILE.track_atts"
-
-	    TRACK_NUMBER="`expr $TRACK_NUMBER - 1`"
-
-	    # eat files
-	    tail -n $TRACK_NUMBER "$TEMPFILE.bytes" > "$TEMPFILE.bytes2"
-	    mv "$TEMPFILE.bytes2" "$TEMPFILE.bytes"
-	    head -n $TO_READ "$TEMPFILE.gpx2" > "$TEMPFILE.points"
-	    B_GPX=0
-	    wc -c < "$TEMPFILE.gpx2" > "$TEMPFILE.var"
-	    read B_GPX < "$TEMPFILE.var"
-	    B_PNT=0
-	    wc -c < "$TEMPFILE.points" > "$TEMPFILE.var"
-	    read B_PNT < "$TEMPFILE.var"
-
-	    TO_READ="`expr $B_GPX - $B_PNT`"
-	    
-	    tail -c $TO_READ "$TEMPFILE.gpx2" > "$TEMPFILE.points"
-	    mv "$TEMPFILE.points" "$TEMPFILE.gpx2"
-	done
-
-	# create attr table: cat(int), start_time varchar(40), start_lat(double precision), start_lon(double precision), \
-	#			end_time varchar(40), end_lat(double precision), end_lon(double precision)
-	
-	ATTR_FILE="${TEMPFILE}.track_atts"
-	ATTR_COLS='cat int, start_time varchar(40), start_lat double precision, start_lon double precision, end_time varchar(40), end_lat double precision, end_lon double precision'
-    fi
-
-
-    #### reproject if needed
-    if [ "$IN_PROJ" = "$OUT_PROJ" ] || [ $KEEP_WGS84 -eq 1 ] ; then
-	g.message "No projection transformation performed" 
-	cat "${TEMPFILE}.base" | awk 'BEGIN {;} $1=="L" { print } ; \
-	    $1!="L" { printf(" %s %s\n", $1, $2) } END {;}' > "${TEMPFILE}.P_base"
-    else
-	g.message "Attempting waypoint projection transform with cs2cs" 
-
-	eval cs2cs -tL -f %.9f `echo $IN_PROJ` +to `echo $OUT_PROJ` \
-	   < "${TEMPFILE}.base" > "${TEMPFILE}.P_mid"
-
-	EXITCODE=$?
-
-	# check if transform REALLY worked (e.g. grid file not found)
-	BAD_PTS="`grep -c "^\*" "${TEMPFILE}.P_mid"`"
-	if [ "$BAD_PTS" -gt 0 ] ; then
-	    g.message message=""
-	    g.message -w "$BAD_PTS vertices failed reprojection."
-	    EXITCODE=1
-	fi
-	if [ $EXITCODE -ne 0 ] ; then
-	    g.message "Projection transform failed, retaining WGS84" 
-	    g.message message=""
-	    cat "${TEMPFILE}.base" | awk 'BEGIN {;} $1=="L" { print } ; \
-		$1!="L" { printf(" %s %s\n", $1, $2) } END {;}' > "${TEMPFILE}.P_base"
-	else
-	    cat "${TEMPFILE}.P_mid" | awk 'BEGIN {;} $1=="L" { print } ; \
-		$1!="L" { printf(" %s %s\n", $1, $2) } END {;}' > "${TEMPFILE}.P_base"
-	fi
-    fi
-
-    # add category numbers
-    cat "${TEMPFILE}.P_base" | awk 'BEGIN { FS=" " ; R=0 } \
-	$1=="L" { printf(" 1 %d\nL %d 1\n", R, $2) ; ++R } ; \
-	$1!="L" { print } END { printf(" 1 %d\n", R) }' | sed -e '1d' > "${TEMPFILE}.P_baseC"
-
-
-    #### create digit header
-    cat << EOF > "${TEMPFILE}.dig"
-ORGANIZATION: GRASSroots organization
-DIGIT DATE:   `date "+%Y/%m/%d"`
-DIGIT NAME:   $PROG
-MAP NAME:     $NAME
-MAP DATE:     `date +%Y`
-MAP SCALE:    1
-OTHER INFO:   Imported by `echo $USER@$HOSTNAME`
-ZONE:	 0
-MAP THRESH:   0
-VERTI:
-EOF
-
-    #### merge in vertices
-#HB#?? locale test fixed this
-    cat "${TEMPFILE}.P_baseC" | tr ',' '.' >> "${TEMPFILE}.dig"
-
-    #### if no name for vector file given, cat to stdout
-    if [ -z "$NAME" ] ; then
-	g.message "ASCII file redirected to stdout" 
-	cat "${TEMPFILE}.dig" 2> /dev/null
-    else
-	#### import to binary vector file 
-	g.message "Importing with v.in.ascii" 
-	v.in.ascii format=standard output="$NAME" input="${TEMPFILE}.dig"
-
-	#### check success/failure
-	if [ $? -eq 0 ] ; then
-	    g.message message="Line vector <$NAME> successfully created."
-	else
-	    g.message -e message='An error occurred on creating <$NAME>, please check!'
-	    exit 1
-	fi
-
-	## create db links if they don't exist
-	db.connect -c
-	DRIVER="`db.connect -p | grep '^driver:' | cut -f2 -d:`"
-	if [ "$DRIVER" = "dbf" ] && [ ! -d "$LOCATION/dbf/" ] ; then
-	    mkdir "$LOCATION/dbf/"
-	fi
-
-	g.message "Creating new table.."
-	echo "CREATE TABLE $NAME ($ATTR_COLS)" | db.execute
-
-	g.message "Populating table with attributes.."
-	# echo "COPY $NAME FROM '$ATTR_FILE'" | db.execute
-
-	# "COPY table FROM 'filename.txt'" does not work for DBF and there is no
-	#   db.in.ascii yet, so we use a hack...
-
-### <hack>
-	if [ $RTE -eq 1 ] ; then
-	    # =>  echo "INSERT INTO $NAME VALUES (2, 1, 'AB', 'B')" | db.execute
-	    cat "$ATTR_FILE" | \
-	      awk -F'|' '{
-		printf("echo \"INSERT INTO $NAME VALUES (%d, %d, ^%s^, ^%s^)\" | db.execute\n", $1, $2, $3, $4) }' \
-		    | tr '^' \' > "$ATTR_FILE"_exe
-	fi
-	if [ $TRK -eq 1 ] ; then
-	    # =>  echo "INSERT INTO $NAME VALUES ()" | db.execute
-	    cat "$ATTR_FILE" | \
-	      awk -F'|' '{
-		printf("echo \"INSERT INTO $NAME VALUES (%d, ^%s^, %s, %s, ^%s^, %s, %s)\" | db.execute\n", $1, $2, $3, $4, $5, $6, $7) }' \
-		    | tr '^' \' > "$ATTR_FILE"_exe
-	fi
-
-	. "$ATTR_FILE"_exe
-### </hack>
-
-	g.message "Connecting attribute table to vector file..."
-	v.db.connect map="$NAME" table="$NAME"
-	EXITCODE=$?
-    fi
-
-fi  # if CREATE_POINTS or CREATE_LINES
-
-
-# list column names
-if [ $VERBOSE -eq 1 ] && [ -n "$NAME" ] ; then
-    g.message message="<$NAME> columns:"
-    db.columns "$NAME"
-fi
-
-# write cmd history:
-v.support map="$NAME" cmdhist="${CMDLINE}"
-
-#### clean up the mess
-rm -f "${TEMPFILE}."* "${TEMPFILE}"
-
-#### end
-g.message "Done." 
-
-exit $EXITCODE

+ 0 - 7
scripts/v.out.gps/Makefile

@@ -1,7 +0,0 @@
-MODULE_TOPDIR = ../..
-
-PGM = v.out.gps
-
-include $(MODULE_TOPDIR)/include/Make/Script.make
-
-default: script

+ 0 - 96
scripts/v.out.gps/v.out.gps.html

@@ -1,96 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>v.out.gps</em> allows the user to export waypoint, route, and track
-data from a vector map into a locally connected GPS receiver or as a file in
-many common GPS data formats. Translation is done via the 
-<em><a href="http://www.gpsbabel.org">GPSBabel</a></em> program. 
-
-<p>Do not use as a primary means of navigation.
-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 (GPL) for more details.
-
-<h2>NOTES</h2>
-
-<em>v.out.gps</em> automatically reprojects data from the 
-projection settings of the current location to Lat/Lon WGS84.
-<p>GPX format is used for data interchange between GRASS and GpsBabel.
-If the requested output is GPX, then <tt>gpsbabel</tt> is never run.
-<p>OGR's GPX driver knows a number of standard field names. If an attribute
-column matches the name it will be used in that field. Otherwise the
-attribute will be placed within the <tt>&lt;extensions&gt;</tt> metadata
-section of the record. Not all fields names are used with all feature
-types (e.g. DOP fix error is not meaningful for route lines). You can
-use the <em>v.db.renamecolumn</em> module to rename columns.
-<p>These are the standard GPX data fields known to OGR:
-<div class="code"><pre>
-ageofdgpsdata
-cmt:	 Comment
-course
-desc
-dgpsid:	 DGPS station type
-ele:	 Elevation
-fix
-geoidheight
-hdop:	 Horizontal dillution of precision (estimated fix error)
-magvar:	 Magnetic variation
-name
-number
-pdop:	 Positional dillution of precision (estimated fix error)
-route_fid
-route_point_id
-sat
-speed
-src
-sym
-time
-track_fid
-track_seg_id
-track_seg_point_id
-type
-url
-urlname
-vdop:	 Vertical dillution of precision (estimated fix error)
-</pre></div>
-
-
-<h2>EXAMPLES</h2>
-
-<h3>GPX Export</h3>
-
-Export a vector lines map to a GPX track file:
-<div class="code"><pre>
-v.out.gps -t input=trail output=trail.gpx
-</pre></div>
-
-
-<h3>GPS device connected via USB adapter</h3>
-
-Export vector maps named <i>waypoints, tracks, routes</i> to a Garmin GPS
-connected to /dev/ttyUSB0:
-<div class="code"><pre>
-v.out.gps -w input=waypoints format=garmin output=/dev/ttyUSB0
-v.out.gps -t input=tracks format=garmin output=/dev/ttyUSB0
-v.out.gps -r input=routes format=garmin output=/dev/ttyUSB0
-</pre></div>
-
-
-<h2>SEE ALSO</h2>
-<em>
-<a href="m.proj.html">m.proj</a>,
-<a href="v.in.ascii.html">v.in.ascii</a>,
-<a href="v.out.ascii.html">v.out.ascii</a>,
-<a href="v.db.renamecolumn.html">v.db.renamecolumn</a>,
-<a href="v.extract.html">v.extract</a>
-</em>
-<p>
-<a href="http://www.gpsbabel.org">GpsBabel.org</a><br>
-The <a href="http://www.gdal.org/ogr/drv_gpx.html">GDAL/OGR GPX format page</a><br>
-cs2cs from <a href="http://proj.osgeo.org">PROJ.4</a><br>
-
-
-<h2>AUTHOR</h2>
-Hamish Bowman, Dunedin New Zealand
-
-<p><i>Last changed: $Date$</i>

+ 0 - 324
scripts/v.out.gps/v.out.gps.py

@@ -1,324 +0,0 @@
-#!/usr/bin/env python
-#
-############################################################################
-#
-# MODULE:	v.out.gps
-#
-# PURPOSE:	Exports a GRASS vector map to a GPS receiver
-#		or data file using GPSBabel
-#
-# COPYRIGHT:	(c) 2008-2009 Hamish Bowman, and 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.
-#
-# AUTHOR:	Hamish Bowman, Dunedin, New Zealand
-#		Converted to Python by Glynn Clements
-#
-#############################################################################
-#
-# REQUIREMENTS:
-#      -  GPSBabel from 	http://gpsbabel.sourceforge.net
-#      -  cs2cs from PROJ.4 (for m.proj)	http://proj.osgeo.org
-#
-#      - report supported GPSBabel formats:
-#	 gpsbabel -^2 | tr '\t' ';' | sort -t';' -k3
-#
-#############################################################################
-#
-# How to do it
-#   http://www.gdal.org/ogr/drv_gpx.html
-#   gpsbabel [options] -i INTYPE -f INFILE -o OUTTYPE -F OUTFILE
-#
-#############################################################################
-
-#%Module
-#% description: Exports a vector map to a GPS receiver or file format supported by GPSBabel.
-#% keyword: vector
-#% keyword: export
-#% keyword: GPS
-#%End
-#%flag
-#% key: w
-#% description: Export as waypoints
-#%end
-#%flag
-#% key: r
-#% description: Export as routes
-#%end
-#%flag
-#% key: t
-#% description: Export as tracks
-#%end
-############ TODO:
-##%flag
-##% key: z
-##% description: Export altitude from 3D vector's z-coordinate
-##%end
-############
-#%option G_OPT_V_INPUT
-#%end
-#%option G_OPT_V_TYPE
-#% options: point,centroid,line,boundary
-#% answer: point,centroid,line,boundary
-#%end
-#%option G_OPT_F_OUTPUT
-#% description: Name for output file or GPS device
-#%end
-#%option
-#% key: format
-#% type: string
-#% description: GPSBabel supported output format
-#% answer: gpx
-#%end
-#%option G_OPT_V_FIELD
-#% required: no
-#% guisection: Subset
-#%end
-#%option G_OPT_DB_WHERE
-#% guisection: Subset
-#%end
-
-import sys
-import os
-import atexit
-import re
-
-import grass.script as grass
-from grass.exceptions import CalledModuleError
-
-
-def cleanup():
-    grass.verbose("Cleaning up ...")
-    if tmp:
-	grass.try_remove(tmp)
-    if tmp_proj:
-	grass.try_remove(tmp_proj)
-    if tmp_gpx:
-	grass.try_remove(tmp_gpx)
-
-    # only try to remove map if it exists to avoid ugly warnings
-    if tmp_vogb:
-	if grass.find_file(tmp_vogb, element = 'vector')['name']:
-	    grass.run_command('g.remove', flags = 'f', type = 'vector',
-                          name = tmp_vogb, quiet = True)
-    if tmp_extr:
-	if grass.find_file(tmp_extr, element = 'vector')['name']:
-	    grass.run_command('g.remove', flags = 'f', type = 'vector',
-                          name = tmp_vogb, quiet = True)
-
-tmp = None
-tmp_proj = None
-tmp_gpx = None
-tmp_extr = None
-tmp_vogb = None
-
-def main():
-    global tmp, tmp_proj, tmp_gpx, tmp_extr, tmp_vogb
-
-    format = options['format']
-    input = options['input']
-    layer = options['layer']
-    output = options['output']
-    type = options['type']
-    where = options['where']
-    wpt = flags['w']
-    rte = flags['r']
-    trk = flags['t']
-
-    nflags = len(filter(None, [wpt, rte, trk]))
-    if nflags > 1:
-	grass.fatal(_("One feature at a time please."))
-    if nflags < 1:
-	grass.fatal(_("No features requested for export."))
-
-    # set some reasonable defaults
-    if not type:
-	if wpt:
-	    type = 'point'
-	else:
-	    type = 'line'
-
-    #### check for gpsbabel
-    ### FIXME: may need --help or similar?
-    if not grass.find_program("gpsbabel"):
-	grass.fatal(_("The gpsbabel program was not found, please install it first.\n") +
-		    "http://gpsbabel.sourceforge.net")
-
-    #### check for cs2cs
-    if not grass.find_program("cs2cs"):
-	grass.fatal(_("The cs2cs program was not found, please install it first.\n") +
-		    "http://proj.osgeo.org")
-
-    # check if we will overwrite data
-    if os.path.exists(output) and not grass.overwrite():
-	grass.fatal(_("Output file already exists."))
-
-    #### set temporary files
-    tmp = grass.tempfile()
-
-    # SQL extract if needed
-    if where:
-	grass.verbose("Extracting data ...")
-	tmp_extr = "tmp_vogb_extr_%d" % os.getpid()
-        try:
-            grass.run_command('v.extract', input="$GIS_OPT_INPUT",
-                              output=tmp_extr, type=type, layer=layer,
-                              where=where, quiet=True)
-        except CalledModuleError:
-            grass.fatal(_("Error executing SQL query"))
-
-	kv = grass.vector_info_topo(tmp_extr)
-	if kv['primitives'] == 0:
-	    grass.fatal(_("SQL query returned an empty map (no %s features?)") % type)
-
-	inmap = tmp_extr
-    else:
-	#   g.copy vector="$GIS_OPT_INPUT,tmp_vogb_extr_$$"   # to get a copy of DB into local mapset
-	#   INMAP="tmp_vogb_extr_$$"
-	inmap = input
-
-    #### set up projection info
-    # TODO: check if we are already in ll/WGS84.  If so skip m.proj step.
-
-    # TODO: multi layer will probably fail badly due to sed 's/^ 1   /'
-    #   output as old GRASS 4 vector ascii and fight with dig_ascii/?
-    #   Change to s/^ \([0-9]   .*\)    /# \1/' ??? mmph.
-
-    # reproject to lat/lon WGS84
-    grass.verbose("Reprojecting data ...")
-
-    re1 = re.compile(r'^\([PLBCFKA]\)')
-    re2 = re.compile(r'^ 1     ')
-
-    re3 = re.compile(r'\t\([-\.0-9]*\) .*')
-    re4 = re.compile(r'^\([-\.0-9]\)')
-    re5 = re.compile(r'^#')
-
-    tmp_proj = tmp + ".proj"
-    tf = open(tmp_proj, 'w')
-    p1 = grass.pipe_command('v.out.ascii', input = inmap, format = 'standard')
-    p2 = grass.feed_command('m.proj', input = '-', flags = 'od', quiet = True, stdout = tf)
-    tf.close()
-
-    lineno = 0
-    for line in p1.stdout:
-	lineno += 1
-	if lineno < 11:
-	    continue
-	line = re1.sub(r'#\1', line)
-	line = re2.sub(r'# 1  ', line)
-	p2.stdin.write(line)
-
-    p2.stdin.close()
-    p1.wait()
-    p2.wait()
-
-    if p1.returncode != 0 or p2.returncode != 0:
-	grass.fatal(_("Error reprojecting data"))
-
-    tmp_vogb = "tmp_vogb_epsg4326_%d" % os.getpid()
-    p3 = grass.feed_command('v.in.ascii', out = tmp_vogb, format = 'standard', flags = 'n', quiet = True)
-    tf = open(tmp_proj, 'r')
-
-    for line in tf:
-	line = re3.sub(r' \1', line)
-	line = re4.sub(r' \1', line)
-	line = re5.sub('', line)
-	p3.stdin.write(line)
-
-    p3.stdin.close()
-    tf.close()
-    p3.wait()
-
-    if p3.returncode != 0:
-	grass.fatal(_("Error reprojecting data"))
-
-    # don't v.db.connect directly as source table will be removed with
-    # temporary map in that case. So we make a temp copy of it to work with.
-    kv = vector_db(inmap)
-    if layer in kv:
-	db_params = kv[layer]
-
-	db_table = db_params['table']
-	db_key = db_params['key']
-	db_database = db_params['database']
-	db_driver = db_params['driver']
-
-        try:
-            grass.run_command('db.copy',
-                              from_driver=db_driver,
-                              from_database=db_database,
-                              from_table=db_table,
-                              to_table=tmp_vogb)
-        except CalledModuleError:
-            grass.fatal(_("Error copying temporary DB"))
-
-        try:
-            grass.run_command('v.db.connect',
-                              map=tmp_vogb, table=tmp_vogb, quiet=True)
-        except CalledModuleError:
-            grass.fatal(_("Error reconnecting temporary DB"))
-
-    # export as GPX using v.out.ogr
-    if trk:
-	linetype = "FORCE_GPX_TRACK=YES"
-    elif rte:
-	linetype = "FORCE_GPX_TRACK=YES"
-    else:
-	linetype = None
-
-    # BUG: cat is being reported as evelation and attribute output is skipped.
-    #   (v.out.ogr DB reading or ->OGR GPX driver bug<-
-    #     resolved: see new Create opts at http://www.gdal.org/ogr/drv_gpx.html)
-    #   v.out.ogr -> shapefile -> GPX works, but we try to avoid that as it's
-    #     lossy. Also that would allow ogr2ogr -a_srs $IN_PROJ -t_srs EPSG:4326
-    #     so skip m.proj pains.. if that is done ogr2ogr -s_srs MUST HAVE +wktext
-    #     with PROJ.4 terms or else the +nadgrids will be ignored! best to feed
-    #     it  IN_PROJ="`g.proj -jf` +wktext"  in that case.
-
-    grass.verbose("Exporting data ...")
-
-    tmp_gpx = tmp + ".gpx"
-    try:
-        grass.run_command('v.out.ogr', input=tmp_vogb, output=tmp_gpx,
-                          type=type, format='GPX', lco=linetype,
-                          dsco="GPX_USE_EXTENSIONS=YES", quiet=True)
-    except CalledModuleError:
-        grass.fatal(_("Error exporting data"))
-
-    if format == 'gpx':
-	# short circuit, we have what we came for.
-	grass.try_remove(output)
-	os.rename(tmp_gpx, output)
-	grass.verbose("Fast exit.")
-	sys.exit()
-
-    # run gpsbabel
-    if wpt:
-	gtype = '-w'
-    elif trk:
-	gtype = '-t'
-    elif rte:
-	gtype = '-r'
-    else:
-	gtype = ''
-
-    grass.verbose("Running GPSBabel ...")
-
-    ret = grass.call(['gpsbabel',
-		      gtype,
-		      '-i', 'gpx',
-		      '-f', tmp + '.gpx',
-		      '-o', format,
-		      '-F', output])
-
-    if ret != 0:
-	grass.fatal(_("Error running GPSBabel"))
-
-    grass.verbose("Done.")
-
-if __name__ == "__main__":
-    options, flags = grass.parser()
-    atexit.register(cleanup)
-    main()