[GRASS-SVN] r29847 - grass/trunk/gui/tcltk/gis.m
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jan 26 13:14:13 EST 2008
Author: cmbarton
Date: 2008-01-26 13:14:13 -0500 (Sat, 26 Jan 2008)
New Revision: 29847
Modified:
grass/trunk/gui/tcltk/gis.m/mapcanvas.tcl
Log:
setting computational region extents now maintains current resolution (whatever it is) accurately.
Modified: grass/trunk/gui/tcltk/gis.m/mapcanvas.tcl
===================================================================
--- grass/trunk/gui/tcltk/gis.m/mapcanvas.tcl 2008-01-26 17:05:35 UTC (rev 29846)
+++ grass/trunk/gui/tcltk/gis.m/mapcanvas.tcl 2008-01-26 18:14:13 UTC (rev 29847)
@@ -1170,17 +1170,45 @@
variable zoom_attrs
global devnull
+ #get current region settings for resolution
+ if {![catch {open [concat "|g.region" "-ugp" $args "2> $devnull"] r} input]} {
+ while {[gets $input line] >= 0} {
+ if { [regexp -nocase {^([a-z]+)=(.*)$} $line trash key value] } {
+ set parts($key) $value
+ }
+ }
+
+ if {[catch {close $input} error]} {
+ GmLib::errmsg $error [G_msg "Error reading current resolution with g.region"]
+ }
+
+ } else {
+ puts $input
+ }
+
+ #set computational region extents while maintaining current resolution
set values [MapCanvas::currentzoom $mon]
set cmd "g.region"
set options {}
+
+ lappend options "-a"
+
foreach attr $zoom_attrs value $values {
if {$attr != "rows" && $attr != "cols" && $attr != "ewres" && $attr!= "nsres"} {
lappend options "$attr=$value"
}
}
+
+ if {$parts(nsres) != ""} {
+ lappend options "nsres=$parts(nsres)"
+ }
+ if {$parts(ewres) != ""} {
+ lappend options "ewres=$parts(ewres)"
+ }
+
if {$overwrite == 1} {
lappend options "--overwrite"
}
More information about the grass-commit
mailing list