[GRASS-SVN] r58921 - grass/branches/develbranch_6/raster/r.li/r.li.setup
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Feb 6 22:00:48 PST 2014
Author: hamish
Date: 2014-02-06 22:00:47 -0800 (Thu, 06 Feb 2014)
New Revision: 58921
Modified:
grass/branches/develbranch_6/raster/r.li/r.li.setup/area_query
grass/branches/develbranch_6/raster/r.li/r.li.setup/r.li.setup.main
grass/branches/develbranch_6/raster/r.li/r.li.setup/sample_area_vector.sh
Log:
sample_area_vector.sh usability improvements,
show cat list status in xmon,
add emergency exit button,
explain that sampling area name becomes a raster map,
make sampling area raster map names special.
Modified: grass/branches/develbranch_6/raster/r.li/r.li.setup/area_query
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.setup/area_query 2014-02-07 05:06:36 UTC (rev 58920)
+++ grass/branches/develbranch_6/raster/r.li/r.li.setup/area_query 2014-02-07 06:00:47 UTC (rev 58921)
@@ -4,11 +4,12 @@
# Simply ask if the selected area is ok or not and save the
-# answer in the environment variable "env(name)"
+# answer in the filename given by the environment variable "env(name)"
wm title . "Select this area"
wm minsize . 250 100
- label .label -text "Is this area ok?"
+
+ label .label -text "\nIs this area ok?"
pack .label
frame .buttons
pack .buttons
@@ -18,7 +19,7 @@
pack .name
frame .name.e
pack .name.e
- label .name.e.n -text "Insert area name"
+ label .name.e.n -text "Enter area name\n(raster map mask name)"
entry .name.e.val -textvariable val -width 20
grid .name.e.n .name.e.val
frame .name.buttons
@@ -27,7 +28,7 @@
if {$val != ""} then {
exec echo 1 $val > $env(name)
destroy .
- }
+ }
}
pack .name.buttons.b
}
@@ -35,4 +36,11 @@
exec echo 0 > $env(name)
destroy .
}
- grid .buttons.ok .buttons.no
+ # what to call it: "stop"? "abort"? "quit"?
+ button .buttons.abort -text "Done" -command {
+ exec echo -1 > $env(name)
+ destroy .
+ }
+
+ grid .buttons.ok .buttons.no .buttons.abort -padx 2 -pady 2
+
Modified: grass/branches/develbranch_6/raster/r.li/r.li.setup/r.li.setup.main
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.setup/r.li.setup.main 2014-02-07 05:06:36 UTC (rev 58920)
+++ grass/branches/develbranch_6/raster/r.li/r.li.setup/r.li.setup.main 2014-02-07 06:00:47 UTC (rev 58921)
@@ -378,7 +378,7 @@
button .removeconf.buttons.y -text "Yes" -width 8 -command {
if { [ catch { exec rm $env(HOME)/.r.li/history/$selection } ] } then {
tk_messageBox -message "'$selection' Not deleted" -type ok -icon error} else {
- tk_messageBox -message "$selection deleted" -type ok
+ tk_messageBox -message "'$selection' deleted." -type ok
openDir .files "~/.r.li/history"
destroy .removeconf}
}
Modified: grass/branches/develbranch_6/raster/r.li/r.li.setup/sample_area_vector.sh
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.setup/sample_area_vector.sh 2014-02-07 05:06:36 UTC (rev 58920)
+++ grass/branches/develbranch_6/raster/r.li/r.li.setup/sample_area_vector.sh 2014-02-07 06:00:47 UTC (rev 58921)
@@ -88,10 +88,11 @@
fi
done
-# open Xmonitor
-d.mon stop="$XMON"
-d.mon start="$XMON"
+#d.mon stop="$XMON" --quiet
+d.mon start="$XMON" --quiet
+# TODO: pause to offer a "resize xmon now" window since it will
+# be locked during the interactive selection.
f_path="$GISBASE/etc/r.li.setup"
@@ -100,38 +101,55 @@
# convert to raster and save the bounds to configuration file
##############################################################
-# using v.category instead of v.build with cdump
-v.category input="$GIS_OPT_vector" option=print | \
+# using v.category instead of v.build with cdump because v.build
+# needs fully qualified map name and is harder to parse.
+
+v.category input="$GIS_OPT_vector" type=centroid option=print | \
sort -n | uniq > "$TMP.cat"
+NUM_CATS=`wc -l < "$TMP.cat"`
+
+if [ "$NUM_CATS" -gt 30 ] ; then
+ g.message -w "<$GIS_OPT_vector> contains $NUM_CATS areas. Manual selection may be time consuming."
+ # TODO: d.menu [Continue][Abort] on screen display
+elif [ "$NUM_CATS" -gt 0 ] ; then
+ g.message -w "<$GIS_OPT_vector> doesn't contain any areas. Aborting selection."
+ # TODO: d.menu [Ok] on screen display
+fi
+
# crop away @mapset part, if present
input_vector=`echo "$GIS_OPT_vector" | cut -d'@' -f 1`
# process each feature in the vector that has a cat
+i=0
while read CAT ; do
- # skip blank lines..
+ # skip blank lines.. (shouldn't be any)
if [ -z "$CAT" ] ; then
continue
fi
+ i=`expr $i + 1`
+
# Temporary vector map to store an individual feature from the input vector
# It will be removed at the end of the iteration.
EXTRACT="tmp_$$_${input_vector}_${CAT}"
v.extract input="$GIS_OPT_vector" output="$EXTRACT" \
- type=point,line,centroid,area \
- new=-1 -d list="$CAT" # where="CAT = $CAT"
+ type=area new=-1 -d list="$CAT" --quiet
# set region with raster resolution
g.region vect="$EXTRACT" align="$GIS_OPT_raster"
d.erase
- d.rast -o "$GIS_OPT_raster"
+ d.rast -o "$GIS_OPT_raster" --quiet
# render extracted vector map (prehaps fcolor=none for areas?)
- d.vect "$EXTRACT"
+ d.vect "$EXTRACT" type=boundary width=2
+ echo " Area $i of $NUM_CATS (category $CAT)" | \
+ d.text color=black size=2.5
+
# ask the user to analyse this vector and a name for raster in a Tcl GUI
name="$TMP.val" # where find the answer
export name
@@ -143,15 +161,20 @@
r_name=`cat "$name" | cut -f2 -d' '`
# debug or needed?
- echo "$r_name"
+ g.message -d message="area_query map name (exit code 1) or exit code: $r_name"
if [ "$ok" -eq 1 ] ; then
#area selected, create mask
- v.to.rast input="$EXTRACT" output="$r_name" use=cat
+ mask_name="rli_${input_vector}_${CAT}_${r_name}"
+ v.to.rast input="$EXTRACT" output="$mask_name" use=cat --quiet
# save the region settings into the configuration file
eval `g.region -g`
- echo "MASKEDOVERLAYAREA $r_name|$n|$s|$e|$w" >> "$GIS_OPT_conf"
+ echo "MASKEDOVERLAYAREA $mask_name|$n|$s|$e|$w" >> "$GIS_OPT_conf"
+
+ elif [ "$ok" -eq -1 ] ; then
+ g.remove vect="$EXTRACT" --quiet
+ break
fi
#remove temporary vector map created from v.extract
@@ -160,7 +183,7 @@
done < "$TMP.cat"
-d.mon stop="$XMON"
+d.mon stop="$XMON" --quiet
# clean tmp files and restore region
More information about the grass-commit
mailing list