[GRASS-SVN] r31172 - grass-addons/display/d.region.box

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Apr 29 09:43:08 EDT 2008


Author: hamish
Date: 2008-04-29 09:43:08 -0400 (Tue, 29 Apr 2008)
New Revision: 31172

Modified:
   grass-addons/display/d.region.box/d.region.box
Log:
add color, width, and named region options

Modified: grass-addons/display/d.region.box/d.region.box
===================================================================
--- grass-addons/display/d.region.box/d.region.box	2008-04-29 06:28:20 UTC (rev 31171)
+++ grass-addons/display/d.region.box/d.region.box	2008-04-29 13:43:08 UTC (rev 31172)
@@ -16,10 +16,33 @@
 #% keywords: display
 #%end
 
+#% option
+#%  key: region
+#%  description: Saved region to draw a box around instead of the current
+#%  required: no
+#%  type: string
+#% end
+#% option
+#%  key: color
+#%  type: string
+#%  required: no
+#%  key_desc: name
+#%  label: Border color
+#%  description: Either a standard color name or R:G:B triplet
+#%  answer: black
+#%  gisprompt: color,grass,color
+#% end
+#% option
+#%  key: width
+#%  type: integer
+#%  required: no
+#%  description: Border width
+#%  answer: 0
+#% end
 #% flag
-#% key: f
-#% description: Non-persistant box (doesn't survive redraw or zoom)
-#%end
+#%  key: f
+#%  description: Non-persistant box (doesn't survive redraw or zoom)
+#% end
 
 if  [ -z "$GISBASE" ] ; then
     echo "You must be in GRASS GIS to run this program." 1>&2
@@ -33,8 +56,28 @@
   fi
 else
   GIS_FLAG_F=0
+  GIS_OPT_COLOR=black
+  GIS_OPT_WIDTH=0
 fi
 
+
+if [ -n "$GIS_OPT_REGION" ] ; then
+   eval `g.findfile elem=windows file="$GIS_OPT_REGION"`
+   if [ -z "$file" ] ; then
+      echo "ERROR: Unable to find region '$GIS_OPT_REGION'" 1>&2
+      exit 1
+   fi
+
+   eval `grep '^north:\|^south:\|^east:\|^west:' $file | sed -e 's/: */=/'`
+   
+   n="$north"
+   s="$south"
+   e="$east"
+   w="$west"
+else
+   eval `g.region -g`
+fi
+
 TMP="`g.tempfile pid=$$`"
 if [ $? -ne 0 ] || [ -z "$TMP" ] ; then
     echo "ERROR: unable to create temporary files" 1>&2
@@ -43,11 +86,14 @@
 
 # another method to try: "d.grid -ng 400"
 
-eval `g.region -g`
+# create d.graph command file
 
-# create d.graph command file
-cat << EOF > "$TMP"
-color black
+if [ "$GIS_OPT_WIDTH" -ne 0 ] ; then
+   echo "width $GIS_OPT_WIDTH" > "$TMP"
+fi
+
+cat << EOF >> "$TMP"
+color $GIS_OPT_COLOR
 polyline 
   $e $s
   $e $n



More information about the grass-commit mailing list