[GRASS-SVN] r49008 - in grass-addons/vector: . v.in.ply
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Oct 30 14:20:13 EDT 2011
Author: neteler
Date: 2011-10-30 11:20:13 -0700 (Sun, 30 Oct 2011)
New Revision: 49008
Added:
grass-addons/vector/v.in.ply/
grass-addons/vector/v.in.ply/Makefile
grass-addons/vector/v.in.ply/description.html
grass-addons/vector/v.in.ply/v.in.ply
Log:
new
Added: grass-addons/vector/v.in.ply/Makefile
===================================================================
--- grass-addons/vector/v.in.ply/Makefile (rev 0)
+++ grass-addons/vector/v.in.ply/Makefile 2011-10-30 18:20:13 UTC (rev 49008)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = v.in.ply
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Property changes on: grass-addons/vector/v.in.ply/Makefile
___________________________________________________________________
Added: svn:eol-style
+ native
Added: grass-addons/vector/v.in.ply/description.html
===================================================================
--- grass-addons/vector/v.in.ply/description.html (rev 0)
+++ grass-addons/vector/v.in.ply/description.html 2011-10-30 18:20:13 UTC (rev 49008)
@@ -0,0 +1,25 @@
+<h2>DESCRIPTION</h2>
+
+<em>v.in.ply</em> imports point clouds stored as PLY file
+(<a href="http://en.wikipedia.org/wiki/PLY_%28file_format%29">PLY format</a>)
+as vector points into GRASS.
+<br>
+If color definitions are present for each point, a corresponding
+GRASSRGB (RRR:GGG:BBB, varchar (11)) column is created and populated.
+
+<h2>EXAMPLE</h2>
+
+<div class="code"><pre>
+v.in.ply archaeo_pointcloud.ply
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<em><a href="v.in.ascii.html">v.in.ascii</a></em>
+
+<h2>AUTHOR</h2>
+
+Markus Neteler<br>
+during his visit at <a href="http://www.topoi.org/">TOPOI Excellence Cluster</a>, FU Berlin, Germany
+
+<p><i>Last changed: $Date$</i>
Property changes on: grass-addons/vector/v.in.ply/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.ply/v.in.ply
===================================================================
--- grass-addons/vector/v.in.ply/v.in.ply (rev 0)
+++ grass-addons/vector/v.in.ply/v.in.ply 2011-10-30 18:20:13 UTC (rev 49008)
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+############################################################################
+#
+# MODULE: v.in.ply
+#
+# AUTHOR(S): Markus Neteler
+#
+# PURPOSE: Imports PLY file as a GRASS vector map
+# http://en.wikipedia.org/wiki/PLY_%28file_format%29
+# If RGB colors are present in the PLY file, automatically
+# a GRASSRGB column is created and populated with RRR:GGG:BBB
+#
+# COPYRIGHT: (c) 2011 Markus Neteler, 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 PLY file into a vector map.
+#% keywords: vector, import
+#%End
+#%option
+#% key: file
+#% type: string
+#% description: PLY file
+#% gisprompt: old_file,file,input
+#% required : yes
+#%end
+#%option
+#% key: vect
+#% type: string
+#% gisprompt: new,vector,vector
+#% description: Name for output vector map
+#% required : no
+#%end
+
+if [ -z "$GISBASE" ] ; then
+ echo "You must be in GRASS GIS to run this program." >&2
+ exit 1
+fi
+
+# save command line
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+ CMDLINE=`basename "$0"`
+ for arg in "$@" ; do
+ CMDLINE="$CMDLINE \"$arg\""
+ done
+ export CMDLINE
+ exec g.parser "$0" "$@"
+fi
+
+PROG=`basename "$0"`
+
+#### check if we have awk
+if [ ! -x "`which awk`" ] ; then
+ g.message -e "awk required, please install awk or gawk first"
+ exit 1
+fi
+
+# setting environment, so that awk works properly in all languages
+unset LC_ALL
+LC_NUMERIC=C
+export LC_NUMERIC
+
+cat ${GIS_OPT_FILE} | awk "/ply/,/end_header/" > /dev/null
+DATALINES=`head -n 30 ${GIS_OPT_FILE} | grep 'element vertex' | cut -d' ' -f3`
+
+head -n 30 ${GIS_OPT_FILE} | grep 'char red' > /dev/null 2>/dev/null
+if [ $? == 0 ] ; then
+ echo "Colors found in PLY file, creating GRASSRGB column"
+ COLOR=1
+else
+ COLOR=0
+fi
+
+if [ -n "$GIS_OPT_VECT" ] ; then
+ MAP="$GIS_OPT_VECT"
+else
+ MAP=`basename $GIS_OPT_FILE .ply`
+fi
+
+if [ $COLOR == 0 ] ; then
+ tail -n $DATALINES ${GIS_OPT_FILE} | tr -s ' ' ' ' | sed 's+^ ++g' | cut -d' ' -f1-3 | v.in.ascii -z x=1 y=2 z=3 out=$MAP fs=" "
+ if [ $? -ne 0 ] ; then
+ g.message -e "An error occurred. Halting."
+ exit 1
+ fi
+else
+ tail -n $DATALINES ${GIS_OPT_FILE} | tr -s ' ' ' ' | sed 's+^ ++g' | cut -d' ' -f1-7 | awk -F " " '{printf "%f,%f,%f,%d:%d:%d,%d\n", $1, $2, $3, $4, $5, $6, $7}' | v.in.ascii -z x=1 y=2 z=3 out=$MAP fs="," columns="x double precision,y double precision,z double precision,GRASSRGB varchar(11),alpha integer"
+ if [ $? -ne 0 ] ; then
+ g.message -e "An error occurred. Halting."
+ exit 1
+ fi
+fi
+
+# write cmd history:
+v.support "$MAP" cmdhist="${CMDLINE}"
+
+exit 0
Property changes on: grass-addons/vector/v.in.ply/v.in.ply
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/x-sh
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list