[GRASS-SVN] r58874 - grass/branches/develbranch_6/raster/r.li/r.li.setup

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Feb 3 16:21:00 PST 2014


Author: hamish
Date: 2014-02-03 16:20:53 -0800 (Mon, 03 Feb 2014)
New Revision: 58874

Modified:
   grass/branches/develbranch_6/raster/r.li/r.li.setup/square_mouse_selection.sh
Log:
script cleanups, more to come for this file

Modified: grass/branches/develbranch_6/raster/r.li/r.li.setup/square_mouse_selection.sh
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.setup/square_mouse_selection.sh	2014-02-03 22:34:15 UTC (rev 58873)
+++ grass/branches/develbranch_6/raster/r.li/r.li.setup/square_mouse_selection.sh	2014-02-04 00:20:53 UTC (rev 58874)
@@ -1,90 +1,94 @@
-#! /bin/sh 
-
+#!/bin/sh 
+#
+# This script selects a square area using the mouse
+#
 # This program is free software under the GPL (>=v2)
 # Read the COPYING file that comes with GRASS for details.
+#
 
-#this script select a square area using mouse
-
 #%Module 
 #% description: Select a rectangular area
 #%End
 #%option
 #% key: raster
 #% type: string
-#% description: raster map to to analyse
+#% gisprompt: old,cell,raster
+#% description: Raster map to to analyse
 #% required: yes
 #%end
 #%option
 #% key: vector
 #% type: string
-#% description: vector to overlay
+#% gisprompt: old,vector,vector
+#% description: Vector map to overlay
 #% required: no
 #%end
 #%option
 #% key: site
 #% type: string
-#% description: site to overlay
+#% description: Vector points map to overlay
 #% required: no
 #%end
 #%option
 #% key: conf
 #% type: string
-#% description: name of configuration file where insert areas
+#% gisprompt: new,file,file
+#% description: Name of configuration file where inserted areas will be stored
 #% required: yes
 #%end
 #%option
 #% key: north
 #% type: string
-#% description: nothern edge (use only with f flag)
+#% description: Northern edge (use only with the 'f' flag)
 #% required: no
 #%end
 #%option
 #% key: south
 #% type: string
-#% description:south edge (use only with f flag)
+#% description: Southern edge (use only with the 'f' flag)
 #% required: no
 #%end
 #%option
 #% key: east
 #% type: string
-#% description: east edge(use only with f flag)
+#% description: Eastern edge (use only with the 'f' flag)
 #% required: no
 #%end
 #%option
 #% key: west 
 #% type: string
-#% description: west edge(use only with f flag)
+#% description: Western edge (use only with the 'f' flag)
 #% required: no
 #%end
 #%flag
 #% key: f
-#% description: sample frame yet selected 
+#% description: Sample frame selected by module options
 #%end
 
 f_path="$GISBASE/etc/r.li.setup"
 
-# Check if we have grass
+# Check if we are in a GRASS session
 if test "$GISBASE" = ""; then
- echo "You must be in GRASS GIS to run this program." >&2
- exit 1
+   echo "You must be in GRASS GIS to run this program." >&2
+   exit 1
 fi
+
 if [ "$1" != "@ARGS_PARSED@" ] ; then
-  exec g.parser "$0" "$@"
+   exec g.parser "$0" "$@"
 fi
 
 
-
-# open x1 monitor
+# open x1 Xmonitor
 d.mon stop=x1
 d.mon start=x1
 
 
 g.region rast=$GIS_OPT_raster
 
-#### set temporary files
+#### create temporary file
 TMP="`g.tempfile pid=$$`"
 if [ $? -ne 0 ] || [ -z "$TMP" ] ; then
-    echo "ERROR: unable to create temporary files" 1>&2
+    echo "ERROR: unable to create temporary file" 1>&2
     exit 1
 fi
 
@@ -104,27 +108,33 @@
 echo "START $s_n|$s_s|$s_e|$s_w|$s_nsres|$s_ewres" >> $GIS_OPT_conf
 
 # show the sampling frame
-if [ $GIS_FLAG_f -eq 1 ] ; then
-    g.region n=$GIS_OPT_north s=$GIS_OPT_south e=$GIS_OPT_east w=$GIS_OPT_west
+if [ "$GIS_FLAG_f" -eq 1 ] ; then
+    g.region n="$GIS_OPT_north" s="$GIS_OPT_south" \
+	     e="$GIS_OPT_east" w="$GIS_OPT_west"
 fi
 
-d.rast -o map=$GIS_OPT_raster
+d.rast -o map="$GIS_OPT_raster"
+
 if [ -n "$GIS_OPT_vector" ] ; then
-    d.vect  map=$GIS_OPT_vector
+    d.vect map="$GIS_OPT_vector"
 fi
 if [ -n "$GIS_OPT_site" ] ; then 
-    d.vect  map=$GIS_OPT_site
+    d.vect map="$GIS_OPT_site" color=red fcolor=red size=5 icon=basic/circle
 fi
 
-#let draw area
+# let draw area
 d.zoom
 
-#ask if the selected area is right
-export name=$TMP #where write the answer
-$GRASS_WISH $f_path/square_query
-read ok < $TMP.var
-if [ $ok -eq 0 ] ; then
-    echo "NO" >> $GIS_OPT_conf
+# ask if the selected area is right
+name="$TMP"  # file where write the answer
+export name
+
+"$GRASS_WISH" "$f_path/square_query"
+
+read ok < "$TMP.var"
+
+if [ "$ok" -eq 0 ] ; then
+    echo "NO" >> "$GIS_OPT_conf"
 fi
 
 if [ $ok -eq 1 ] ; then
@@ -144,11 +154,9 @@
     echo "SQUAREAREA $n|$s|$e|$w|$nsres|$ewres" >> $GIS_OPT_conf
 fi
 
-#close monitor
+# close the Xmonitor
 d.mon stop=x1
+
 # clean tmp files
 rm -f $TMP*
 
-
-
-



More information about the grass-commit mailing list