[GRASS-SVN] r40161 - in grass-addons/vector: . v.in.mbsys_fnv
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Dec 29 00:05:40 EST 2009
Author: hamish
Date: 2009-12-29 00:05:39 -0500 (Tue, 29 Dec 2009)
New Revision: 40161
Added:
grass-addons/vector/v.in.mbsys_fnv/
grass-addons/vector/v.in.mbsys_fnv/Makefile
grass-addons/vector/v.in.mbsys_fnv/description.html
grass-addons/vector/v.in.mbsys_fnv/v.in.mbsys_fnv
Log:
new module to load MB-Systems navigation data in 7 different ways (work in progress)
Added: grass-addons/vector/v.in.mbsys_fnv/Makefile
===================================================================
--- grass-addons/vector/v.in.mbsys_fnv/Makefile (rev 0)
+++ grass-addons/vector/v.in.mbsys_fnv/Makefile 2009-12-29 05:05:39 UTC (rev 40161)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = v.in.mbsys_fnv
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Property changes on: grass-addons/vector/v.in.mbsys_fnv/Makefile
___________________________________________________________________
Added: svn:mime-type
+ text/x-makefile
Added: svn:eol-style
+ native
Added: grass-addons/vector/v.in.mbsys_fnv/description.html
===================================================================
--- grass-addons/vector/v.in.mbsys_fnv/description.html (rev 0)
+++ grass-addons/vector/v.in.mbsys_fnv/description.html 2009-12-29 05:05:39 UTC (rev 40161)
@@ -0,0 +1,23 @@
+<H2>DESCRIPTION</H2>
+
+
+
+<H2>NOTES</H2>
+
+
+
+<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="r.in.xyz.html">r.in.xyz</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.mbsys_fnv/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.mbsys_fnv/v.in.mbsys_fnv
===================================================================
--- grass-addons/vector/v.in.mbsys_fnv/v.in.mbsys_fnv (rev 0)
+++ grass-addons/vector/v.in.mbsys_fnv/v.in.mbsys_fnv 2009-12-29 05:05:39 UTC (rev 40161)
@@ -0,0 +1,231 @@
+#!/bin/sh
+#
+############################################################################
+#
+# MODULE: v.in.mbsys_fnv
+#
+# AUTHOR(S): Hamish Bowman
+#
+# PURPOSE: Import MB-System .fnv nav data into GRASS vector points/lines/areas
+#
+# COPYRIGHT: (c) 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.
+#
+#############################################################################
+#%Module
+#% description: Imports MB-System naviagation data from a fnv-file.
+#% keywords: vector, import
+#%End
+#%option
+#% key: input
+#% type: string
+#% gisprompt: old_file,file,input
+#% description: Name of input file
+#% required : yes
+#%end
+#%option
+#% key: output
+#% type: string
+#% gisprompt: new,vector,vector
+#% description: Name for output vector map
+#% required : yes
+#%end
+#%option
+#% key: type
+#% type: string
+#% options: track,port_trk,stbd_trk,scanlines,swath,track_pts,all_pts
+#% descriptions: track;ship's track;port_trk;port-side outward track;stbd_trk;starboard-side outward track;scanlines;lines perpendicular to direction of travel;swath;coverage area;track_pts;ship's track as points;all_pts;ship's track, port, and stbd track points
+#% answer: track
+#% description: Type of feature to import as
+#% required : yes
+#%end
+#%option
+#% key: cat
+#% type: integer
+#% options: 1-99999999
+#% answer: 1
+#% description: Category value to use for lines and areas
+#% 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
+ exec g.parser "$0" "$@"
+fi
+
+#
+#### import .fnv nav data
+#
+# they are created with:
+# mblist -F %d -I %s -O tMXYHScRPr=X=Y+X+Y
+#
+# t for a time string (yyyy mm dd hh mm ss)
+# M for unix (epoch) time in decimal seconds since 1/1/70 00:00:00
+# X for longitude (decimal degrees)
+# Y for latitude (decimal degrees)
+# H for heading (degrees)
+# S for speed (km/hr)
+# c for sonar tranducer depth (m)
+# R for roll in degrees
+# P for pitch in degrees
+# r for heave in meters
+# = special character: this causes the value indicated by the next
+# character to derive from the port-most non-null beam or pixel.
+# This applies only to numeric values associated with beams or
+# pixels such as depth, longitude, or latitude.
+# X for longitude (decimal degrees)
+# = special character
+# Y for latitude (decimal degrees)
+# + special character: this causes the value indicated by the next
+# character to derive from the starboard-most non-null beam or pixel.
+# This applies only to numeric values associated with beams or pixels
+# such as depth, longitude, or latitude.
+# X for longitude (decimal degrees)
+# + special character
+# Y for latitude (decimal degrees)
+#
+# for example:
+# 2003 01 17 00 57 25.466000 1042765045.466000 169.094199 -46.740662 260.10 10.94 0.078 2.834 -0.75 0.08 169.094547 -46.741980
+#
+####
+#
+
+COLUMN_DEF='timestamp varchar(21), unix_time double precision, center_lon double precision, center_lat double precision, headng_deg double precision, velo_km_hr double precision, trn_dept_m double precision, roll_degr double precision, pitch_degr double precision, heave_m double precision, port_lon double precision, port_lat double precision, stbd_lon double precision, stbd_latdouble precision'
+
+if [ ! -e "$GIS_OPT_INPUT" ] ; then
+ g.message -e "File <$GIS_OPT_INPUT> does not exist."
+ exit 1
+fi
+
+
+#### check if in lat/long location
+#are we in LatLong location?
+g.proj -p | grep -i name | grep -i Lon > /dev/null
+if [ $? -eq 1 ] ; then
+ g.message -e "This module only operates in LatLong/WGS84 locations"
+ exit 1
+fi
+
+#### set temporary files
+TMP="`g.tempfile pid=$$`"
+if [ $? -ne 0 ] || [ -z "$TMP" ] ; then
+ g.message -e "Unable to create temporary files"
+ exit 1
+fi
+cleanup()
+{
+ g.message -v "Cleaning up ..."
+ \rm -f "$TMP" "$TMP".*.trk "${TMP}"_*
+
+ #if [ "$GIS_OPT_TYPE" = "swath" ] ; then
+ # g.mremove -f vect="tmp_v_in_fnv_$$_[1-4]"
+ #fi
+}
+
+#### trap ctrl-c so that we can clean up tmp
+trap 'cleanup' 2 3 15
+
+
+cat "$GIS_OPT_INPUT" | cut -f3-4 > "$TMP.trk"
+cat "$GIS_OPT_INPUT" | cut -f12,14 > "$TMP.port.trk"
+cat "$GIS_OPT_INPUT" | cut -f16,18 > "$TMP.stbd.trk"
+
+
+# import vector coordinates
+case "$GIS_OPT_TYPE" in
+ track)
+ v.in.mapgen -f in="$TMP.trk" out="$GIS_OPT_OUTPUT"
+ ;;
+ port_trk)
+ v.in.mapgen -f in="$TMP.port.trk" out="$GIS_OPT_OUTPUT"
+ ;;
+ stbd_trk)
+ v.in.mapgen -f in="$TMP.stbd.trk" out="$GIS_OPT_OUTPUT"
+ ;;
+ scanlines)
+ awk 'BEGIN { R=0 }
+ { R++;
+ print "L 3 1\n " $16 " " $17 "\n " $8 " " $9 "\n " $18 " " $19 "\n 1 " R}' \
+ "$GIS_OPT_INPUT" > "${TMP}_scanlines.vasc"
+ v.in.ascii -n in="${TMP}_scanlines.vasc" out="$GIS_OPT_OUTPUT" format=standard
+ ;;
+ swath)
+ #swath area
+ NPTS=`cat "$TMP.trk" | wc -l`
+ NPTS_DOUBLED=`expr $NPTS \* 2 + 1`
+ NTPS_MIDDLE=`expr $NPTS / 2`
+ cat=1
+
+ echo "B $NPTS_DOUBLED" > "${TMP}_swath.vasc"
+ cat "$TMP.port.trk" >> "${TMP}_swath.vasc"
+ tac "$TMP.stbd.trk" >> "${TMP}_swath.vasc"
+ head -n 1 "$TMP.port.trk" >> "${TMP}_swath.vasc"
+ echo "C 1 1" >> "${TMP}_swath.vasc"
+ head -n $NTPS_MIDDLE "$TMP.trk" | tail -n 1 >> "${TMP}_swath.vasc"
+ echo " 1 $GIS_OPT_CAT" >> "${TMP}_swath.vasc"
+
+ v.in.ascii -n format=standard in="${TMP}_swath.vasc" out="$GIS_OPT_OUTPUT" #out="tmp_v_in_fnv_$$_1"
+
+ # TODO: cleanup spaghetti
+ #v.clean in="tmp_v_in_fnv_$$_1" out="tmp_v_in_fnv_$$_2" tool=break
+ #v.centroids in="tmp_v_in_fnv_$$_2" out="tmp_v_in_fnv_$$_3" cat="$GIS_OPT_CAT" step=0
+ #v.dissolve in="tmp_v_in_fnv_$$_3" out="tmp_v_in_fnv_$$_4"
+ # and yet... something's wrong.
+ ;;
+ track_pts)
+ v.in.ascii in="$GIS_OPT_INPUT" out="$GIS_OPT_OUTPUT" x=3 y=4 fs=tab \
+ columns="$COLUMN_DEF"
+ ;;
+ all_pts)
+ awk 'BEGIN { R=0 }
+ {R++; print R "\tcenter\t" $8 "\t" $9 "\n" R "\tport\t" $16 "\t" $17 "\n" R "\tstbd\t" $18 "\t" $19 }' \
+ "$GIS_OPT_INPUT" > "${TMP}_all.pts"
+
+ v.in.ascii in="${TMP}_all.pts" out="$GIS_OPT_OUTPUT" x=3 y=4 fs=tab \
+ columns='scanline integer, side varchar(6), lon double precision, lat double precision'
+ ;;
+esac
+
+
+#### attach attributes
+
+#### TODO
+
+# see v.in.garmin for example
+
+# attributes:
+# $COLUMN_DEF
+# `basename filename`
+# $GIS_OPT_CAT for 3 lines + swath area
+
+# area:
+# max time/mintime
+# ?bbox
+# v.to.db area?
+
+
+cleanup
+exit
+
+
+
+#d.varea Coastline
+
+#d.vect fnv_track_port_test col=red
+#d.vect fnv_track_stbd_test col=green
+#d.vect fnv_track_test col=grey
+
+#d.vect fnv_swath fcol=200:220:250 color=none type=area
+
+#d.vect all_pts col=grey where="side = 'center'"
+#d.vect all_pts col=green where="side = 'stbd'"
+#d.vect all_pts col=red where="side = 'port'"
+
Property changes on: grass-addons/vector/v.in.mbsys_fnv/v.in.mbsys_fnv
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/x-sh
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list