[GRASS-SVN] r34877 - in grass/branches/develbranch_6/scripts: .
v.to.3d
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 14 14:25:23 EST 2008
Author: martinl
Date: 2008-12-14 14:25:22 -0500 (Sun, 14 Dec 2008)
New Revision: 34877
Added:
grass/branches/develbranch_6/scripts/v.to.3d/
grass/branches/develbranch_6/scripts/v.to.3d/Makefile
grass/branches/develbranch_6/scripts/v.to.3d/description.html
grass/branches/develbranch_6/scripts/v.to.3d/v.to.3d
Modified:
grass/branches/develbranch_6/scripts/Makefile
Log:
very initial version of v.to.3d module (trac #82)
Modified: grass/branches/develbranch_6/scripts/Makefile
===================================================================
--- grass/branches/develbranch_6/scripts/Makefile 2008-12-14 16:48:33 UTC (rev 34876)
+++ grass/branches/develbranch_6/scripts/Makefile 2008-12-14 19:25:22 UTC (rev 34877)
@@ -78,8 +78,9 @@
v.out.gpsbabel \
v.rast.stats \
v.report \
+ v.to.3d \
v.univar.sh \
- v.what.vect
+ v.what.vect \
include $(MODULE_TOPDIR)/include/Make/Dir.make
Added: grass/branches/develbranch_6/scripts/v.to.3d/Makefile
===================================================================
--- grass/branches/develbranch_6/scripts/v.to.3d/Makefile (rev 0)
+++ grass/branches/develbranch_6/scripts/v.to.3d/Makefile 2008-12-14 19:25:22 UTC (rev 34877)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = v.to.3d
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Added: grass/branches/develbranch_6/scripts/v.to.3d/description.html
===================================================================
--- grass/branches/develbranch_6/scripts/v.to.3d/description.html (rev 0)
+++ grass/branches/develbranch_6/scripts/v.to.3d/description.html 2008-12-14 19:25:22 UTC (rev 34877)
@@ -0,0 +1,29 @@
+<h2>DESCRIPTION</h2>
+
+The <em>v.to.3d</em> module is used to transform 2D vector features
+to 3D. Height (z-coordinate) of 3D vector features can be specified
+by <b>height</b> parameter as fixed value or by <b>column</b>
+parameter.
+
+<h2>TODO</h2>
+
+<ul>
+ <li>Check if input vector map is already 3D</li>
+ <li>Implement reverse transformation</li>
+ <li>Some examples</li>
+</ul>
+
+<h2>SEE ALSO</h2>
+
+<em>
+<a href="v.transform.html">v.transform</a>,
+<a href="v.extrude.html">v.extrude</a>,
+<a href="v.drape.html">v.drape</a>
+</em>
+
+<h2>AUTHORS</h2>
+
+Martin Landa, CTU in Prague, Czech Republic
+
+<p>
+<i>Last changed: $Date: 2008-11-12 02:39:48 +0100 (Wed, 12 Nov 2008) $</i>
Added: grass/branches/develbranch_6/scripts/v.to.3d/v.to.3d
===================================================================
--- grass/branches/develbranch_6/scripts/v.to.3d/v.to.3d (rev 0)
+++ grass/branches/develbranch_6/scripts/v.to.3d/v.to.3d 2008-12-14 19:25:22 UTC (rev 34877)
@@ -0,0 +1,110 @@
+#!/bin/sh
+############################################################################
+#
+# MODULE: v.to.3d
+#
+# AUTHOR: Martin Landa, CTU in Prague, Czech Republic
+#
+# PURPOSE: Transform 2D vectors to 3D vectors
+# (frontend to v.transform)
+#
+# COPYRIGHT: (c) 2008 Martin Landa, 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: Performs transformation of 2D vector features to 3D.
+#% keywords: vector, transformation, 3D
+#%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: yes
+#% multiple: no
+#% key_desc: name
+#% description: Name for output vector map
+#% gisprompt: new,vector,vector
+#%End
+
+#%Option
+#% key: height
+#% type: double
+#% required: no
+#% multiple: no
+#% description: Fixed height for 3D vector features
+#%End
+
+#%Option
+#% key: layer
+#% type: integer
+#% required: no
+#% multiple: no
+#% label: Layer number
+#% description: A single vector map can be connected to multiple database tables. This number determines which table to use.
+#% answer: 1
+#% gisprompt: old_layer,layer,layer
+#%End
+
+#%Option
+#% key: column
+#% type: string
+#% required: no
+#% multiple: no
+#% key_desc: name
+#% description: Name of attribute column used for height
+#% gisprompt: old_dbcolumn,dbcolumn,dbcolumn
+#%End
+
+if [ -z "$GISBASE" ] ; then
+ echo "You must be in GRASS GIS to run this program." 1>&2
+ exit 1
+fi
+
+# save command line
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+ exec g.parser "$0" "$@"
+fi
+
+if [ -n "$GIS_OPT_HEIGHT" ] ; then
+ if [ -n "$GIS_OPT_COLUMN" ] ; then
+ g.message -e "Either 'height' or 'column' parameter have to be used"
+ exit 1
+ fi
+ # fixed height
+ v.transform input="$GIS_OPT_INPUT" output="$GIS_OPT_OUTPUT" zshift="$GIS_OPT_HEIGHT"
+else
+ if [ -z "$GIS_OPT_COLUMN" ] ; then
+ g.message -e "Either 'height' or 'column' parameter have to be used"
+ exit 1
+ fi
+
+ # attribute height, check column type
+ coltype=`v.info -c map="$GIS_OPT_INPUT" layer="$GIS_OPT_LAYER" --quiet | grep -w "$GIS_OPT_COLUMN" | cut -d'|' -f1`
+ if [ "$coltype" = "INTEGER" -o "$coltype" = "DOUBLE PRECISION" ] ; then
+ table=`v.db.connect map="$GIS_OPT_INPUT" -g fs=',' | grep ^"$GIS_OPT_LAYER" | cut -d',' -f2`
+ v.transform input="$GIS_OPT_INPUT" output="$GIS_OPT_OUTPUT" layer="$GIS_OPT_LAYER" columns="zshift:${GIS_OPT_COLUMN}" table="$table"
+ else
+ if [ -z "$coltype" ] ; then
+ g.message -e "Column <$GIS_OPT_COLUMN> not found"
+ else
+ g.message -e "Column type must be numeric"
+ fi
+ exit 1
+ fi
+fi
+
+exit 0
More information about the grass-commit
mailing list