[GRASS-SVN] r46715 - grass-addons/raster/r.colors.out_vtk
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jun 15 05:55:32 EDT 2011
Author: hamish
Date: 2011-06-15 02:55:32 -0700 (Wed, 15 Jun 2011)
New Revision: 46715
Modified:
grass-addons/raster/r.colors.out_vtk/r.colors.out_vtk
Log:
test if input map exists
Modified: grass-addons/raster/r.colors.out_vtk/r.colors.out_vtk
===================================================================
--- grass-addons/raster/r.colors.out_vtk/r.colors.out_vtk 2011-06-15 09:49:52 UTC (rev 46714)
+++ grass-addons/raster/r.colors.out_vtk/r.colors.out_vtk 2011-06-15 09:55:32 UTC (rev 46715)
@@ -81,7 +81,7 @@
fi
-# --overwrite test
+#### --overwrite test
if [ -e "$GIS_OPT_OUTPUT" ] ; then
if [ -z "$GRASS_OVERWRITE" ] || [ "$GRASS_OVERWRITE" -ne 1 ] ; then
g.message -e "File <$GIS_OPT_OUTPUT> already exists"
@@ -89,14 +89,18 @@
fi
fi
-#
-# test here if input map actually exists?
-#
+#### test if map exists
+eval `g.findfile element=cell file="$GIS_OPT_MAP"`
+if [ -z "$fullname" ] ; then
+ g.message -e "Raster map <$GIS_OPT_MAP> not found"
+ exit 1
+fi
+
+#### start writing it
echo "<ColorMap name=\"$GIS_OPT_MAP\" space=\"RGB\">" > "$GIS_OPT_OUTPUT"
-
if [ $GIS_FLAG_N -eq 1 ] ; then
r.colors.out -p map="$GIS_OPT_MAP" rules=- | grep '^[0-9]' | tr ':' ' ' | \
awk -v MIN="$min" -v MAX="$max" \
@@ -104,17 +108,14 @@
$1/100., $1/100., $2/255., $3/255., $4/255.)}' \
>> "$GIS_OPT_OUTPUT"
- RCO_EXITCODE=$?
else
r.colors.out map="$GIS_OPT_MAP" rules=- | grep '^[0-9]' | tr ':' ' ' | \
awk '{printf(" <Point x=\"%.15g\" o=\"1\" r=\"%.3f\" g=\"%.3f\" b=\"%.3f\" />\n", \
$1, $2/255., $3/255., $4/255.)}' >> "$GIS_OPT_OUTPUT"
- RCO_EXITCODE=$?
fi
echo "</ColorMap>" >> "$GIS_OPT_OUTPUT"
-#done!
-exit $RCO_EXITCODE
+#### done!
More information about the grass-commit
mailing list