[GRASS-SVN] r37259 - grass/branches/releasebranch_6_4/gui/tcltk/gis.m

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 18 07:26:15 EDT 2009


Author: hamish
Date: 2009-05-18 07:26:12 -0400 (Mon, 18 May 2009)
New Revision: 37259

Modified:
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapcanvas.tcl
Log:
backport some lat/lon fixes. still rather broken, e.g. zoom out, switch modes, check lat coords in status bar, ...

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapcanvas.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapcanvas.tcl	2009-05-18 11:22:28 UTC (rev 37258)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapcanvas.tcl	2009-05-18 11:26:12 UTC (rev 37259)
@@ -113,6 +113,9 @@
 	variable zoom_attrs
 	set zoom_attrs {n s e w nsres ewres rows cols}
 
+	# ll_proj is 1 for a Lat/Lon projection, 0 othervise
+	variable ll_proj
+
 	# string with region information to show in status bar
 	variable regionstr
 
@@ -417,6 +420,7 @@
 
 
 proc MapCanvas::get_mapunits {} {
+	variable ll_proj
 	# get map units from PROJ_UNITS
 	if {![catch {open "|g.proj -p" r} input]} {
 	    set key ""
@@ -424,6 +428,7 @@
 	    while {[gets $input line] >= 0} {
 	    	if { [string equal "XY location (unprojected)" "$line"] } {
 	    	    set mapunits "map units"
+		    set ll_proj 0
 	    	    break
 	    	}
 	    	regexp -nocase {^(.*):(.*)$} $line trash key value
@@ -441,8 +446,14 @@
 	# May already be set above if locn was XY.
 	if { ! [ info exist mapunits ] } {
 	    set mapunits $prj(units)
+
+	    if { [string eq "Lat/Lon" "$prj(name)"] } {
+		set ll_proj 1
+	    } else {
+		set ll_proj 0
+	    }
 	}
-	
+
 	return $mapunits
 }
 
@@ -1029,6 +1040,7 @@
 	variable msg
 	variable canvas_w
 	variable canvas_h
+	variable ll_proj
 
 	set mapunits [MapCanvas::get_mapunits]
 
@@ -1044,8 +1056,13 @@
 	if {$exploremode($mon)} {
 		# Set the region extents to the smallest region no smaller than the canvas
 		set canvas_ar [expr {1.0 * $canvas_w($mon) / $canvas_h($mon)}]
-		set expanded_region [MapCanvas::shrinkwrap 1 [lrange $region 0 3] $canvas_ar]
-		foreach {n s e w} $expanded_region {break}
+		foreach {n s e w} [MapCanvas::shrinkwrap 1 [lrange $region 0 3] $canvas_ar] {break}
+		# In Lat/Lon N and S can not be larger than 90!
+		if { $ll_proj } {
+			if { $n >  90 } { set n  90 }
+			if { $s < -90 } { set s -90 }
+		}
+		set expanded_region "$n $s $e $w"
 		# Calculate the resolutions proportional to the map size
 		set explore_nsres [expr {1.0 * ($n - $s) / $canvas_h($mon)}]
 		set explore_ewres [expr {1.0 * ($e - $w) / $canvas_w($mon)}]



More information about the grass-commit mailing list