[GRASS-SVN] r38427 - grass/branches/develbranch_6/gui/tcltk/gis.m

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 15 10:48:18 EDT 2009


Author: marisn
Date: 2009-07-15 10:48:17 -0400 (Wed, 15 Jul 2009)
New Revision: 38427

Modified:
   grass/branches/develbranch_6/gui/tcltk/gis.m/chart.tcl
   grass/branches/develbranch_6/gui/tcltk/gis.m/gmmenu.tcl
   grass/branches/develbranch_6/gui/tcltk/gis.m/thematic.tcl
Log:
Fix gis.m issues if GISBASE or GISDBASE contains spaces

Modified: grass/branches/develbranch_6/gui/tcltk/gis.m/chart.tcl
===================================================================
--- grass/branches/develbranch_6/gui/tcltk/gis.m/chart.tcl	2009-07-15 14:44:40 UTC (rev 38426)
+++ grass/branches/develbranch_6/gui/tcltk/gis.m/chart.tcl	2009-07-15 14:48:17 UTC (rev 38427)
@@ -10,12 +10,12 @@
 ##########################################################################
 
 namespace eval GmChart {
-    variable array opt # chart options
+    variable array opt ;# chart options
     variable count 1
-    variable array lfile # vector
-    variable array lfilemask # vector
+    variable array lfile ;# vector
+    variable array lfilemask ;# vector
     variable optlist
-    variable array dup # vector
+    variable array dup ;# vector
 }
 
 
@@ -121,7 +121,19 @@
 	variable opt
 	global bgcolor
 	set mapname $opt($id,1,map)
+	if {[string length $mapname] == 0} {
+		GmChart::select_map $id
+		set mapname $opt($id,1,map)
+		if {[string length $mapname] == 0} {
+			GmLib::errmsg [G_msg "This action requires map name to be set"]
+			return
+		}
+	}
 	set layernum $opt($id,1,layer)
+	if {[string is integer -strict $layernum] == 0 } {
+		GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+		return
+	}
 	set cmd "v.info -c map=$mapname layer=$layernum"
 	run_panel $cmd
 }
@@ -130,17 +142,29 @@
 	variable opt
 	global bgcolor
 	set mapname $opt($id,1,map)
-	set layer $opt($id,1,layer)
-	if ![catch {open "|v.db.connect map=$mapname layer=$layer -g" r} vdb] {
+	if {[string length $mapname] == 0} {
+		GmChart::select_map $id
+		set mapname $opt($id,1,map)
+		if {[string length $mapname] == 0} {
+			GmLib::errmsg [G_msg "This action requires map name to be set"]
+			return
+		}
+	}
+	set layernum $opt($id,1,layer)
+	if {[string is integer -strict $layernum] == 0 } {
+		GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+		return
+	}
+	if ![catch {open "|v.db.connect map=$mapname layer=$layernum -g" r} vdb] {
 		set vectdb [read $vdb]
 		if {[catch {close $vdb} error]} {
             GmLib::errmsg $error
 		}
 		set vdblist [split $vectdb " "]
-		set tbl [lindex $vdblist 1]
-		set db [lindex $vdblist 3]
-		set drv [lindex $vdblist 4]
-		set cmd "db.select table=$tbl database=$db driver=$drv"
+		set tbl [string trim [lindex $vdblist 1]]
+		set db [file normalize [join [lrange $vdblist 3 end-1]]]
+		set drv [string trim [lindex $vdblist end]]
+		set cmd [list db.select "table=$tbl" "database=$db" "driver=$drv"]
 		run_panel $cmd
 	}
 }

Modified: grass/branches/develbranch_6/gui/tcltk/gis.m/gmmenu.tcl
===================================================================
--- grass/branches/develbranch_6/gui/tcltk/gis.m/gmmenu.tcl	2009-07-15 14:44:40 UTC (rev 38426)
+++ grass/branches/develbranch_6/gui/tcltk/gis.m/gmmenu.tcl	2009-07-15 14:48:17 UTC (rev 38427)
@@ -209,7 +209,7 @@
 		{command {[G_msg "Change region settings"]} {} "g.region: " {} -command {execute g.region }}
 	}}
 	{cascad {[G_msg "GRASS working environment"]} {} "" $tmenu {			
-		{command {[G_msg "Mapset access"]} {} "g.mapsets.tcl: Access other mapsets in current location" {} -command {exec $env(GRASS_WISH) $env(GISBASE)/etc/g.mapsets.tcl --tcltk &}}
+		{command {[G_msg "Mapset access"]} {} "g.mapsets.tcl: Access other mapsets in current location" {} -command {exec "$env(GRASS_WISH)" "$env(GISBASE)/etc/g.mapsets.tcl" --tcltk &}}
 		{command {[G_msg "Change working environment"]} {} "g.mapset: Change current working session to new mapset, location, or GISDBASE" {} -command {execute g.mapset }}
 		{command {[G_msg "User access"]} {} "g.access: Modify access by other users to current mapset" {} -command {execute g.access }}
 		{command {[G_msg "Show settings"]} {} "g.gisenv: Show current GRASS environment settings" {} -command {run_panel g.gisenv }}
@@ -641,8 +641,8 @@
 {[G_msg "&Help"]} all options $tmenu {
 	{command {[G_msg "GRASS help"]} {} "g.manual" {} -command { exec g.manual -i > $devnull & } }
 	{command {[G_msg "GIS Manager &help"]} {} {[G_msg "GIS Manager help"]} {} -command { exec g.manual gis.m > $devnull & } }
-	{command {[G_msg "About &GRASS"]} {} {[G_msg "About GRASS"]} {} -command { source $env(GISBASE)/etc/gm/grassabout.tcl} }
-	{command {[G_msg "About &System"]} {} {[G_msg "About System"]} {} -command { exec $env(GRASS_WISH) $env(GISBASE)/etc/gm/tksys.tcl --tcltk & }}
+	{command {[G_msg "About &GRASS"]} {} {[G_msg "About GRASS"]} {} -command { source "$env(GISBASE)/etc/gm/grassabout.tcl" } }
+	{command {[G_msg "About &System"]} {} {[G_msg "About System"]} {} -command { exec "$env(GRASS_WISH)" "$env(GISBASE)/etc/gm/tksys.tcl" --tcltk & }}
  }
 
 }]

Modified: grass/branches/develbranch_6/gui/tcltk/gis.m/thematic.tcl
===================================================================
--- grass/branches/develbranch_6/gui/tcltk/gis.m/thematic.tcl	2009-07-15 14:44:40 UTC (rev 38426)
+++ grass/branches/develbranch_6/gui/tcltk/gis.m/thematic.tcl	2009-07-15 14:48:17 UTC (rev 38427)
@@ -10,14 +10,14 @@
 ##########################################################################
 
 namespace eval GmThematic {
-    variable array opt # thematic current options
-	variable array tlegend # mon id
-	variable array tlegcan # mon id
+    variable array opt ;# thematic current options
+	variable array tlegend ;# mon id
+	variable array tlegcan ;# mon id
     variable count 1
-    variable array lfile # raster
-    variable array lfilemask # raster
+    variable array lfile ;# raster
+    variable array lfilemask ;# raster
     variable optlist
-    variable array dup # vector
+    variable array dup ;# vector
 }
 
 
@@ -162,7 +162,19 @@
 	variable opt
 	global bgcolor
 	set mapname $opt($id,1,map)
+	if {[string length $mapname] == 0} {
+		GmThematic::select_map $id
+		set mapname $opt($id,1,map)
+		if {[string length $mapname] == 0} {
+			GmLib::errmsg [G_msg "This action requires map name to be set"]
+			return
+		}
+	}
 	set layernum $opt($id,1,layer)
+	if {[string is integer -strict $layernum] == 0 } {
+		GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+		return
+	}
 	set cmd "v.info -c map=$mapname layer=$layernum"
 	run_panel $cmd
 }
@@ -171,17 +183,29 @@
 	variable opt
 	global bgcolor
 	set mapname $opt($id,1,map)
-	set layer $opt($id,1,layer)
-	if {![catch {open "|v.db.connect map=$mapname layer=$layer -g" r} vdb]} {
+	if {[string length $mapname] == 0} {
+		GmVector::select_map $id
+		set mapname $opt($id,1,map)
+		if {[string length $mapname] == 0} {
+			GmLib::errmsg [G_msg "This action requires map name to be set"]
+			return
+		}
+	}
+	set layernum $opt($id,1,layer)
+	if {[string is integer -strict $layernum] == 0 } {
+		GmLib::errmsg [G_msg "You must provide valid vector layer number"]
+		return
+	}
+	if {![catch {open "|v.db.connect map=$mapname layer=$layernum -g" r} vdb]} {
 		set vectdb [read $vdb]
 		if {[catch {close $vdb} error]} {
 			GmLib::errmsg $error
 		}
 		set vdblist [split $vectdb " "]
-		set tbl [lindex $vdblist 1]
-		set db [lindex $vdblist 3]
-		set drv [lindex $vdblist 4]
-		set cmd "db.select table=$tbl database=$db driver=$drv"
+		set tbl [string trim [lindex $vdblist 1]]
+		set db [file normalize [join [lrange $vdblist 3 end-1]]]
+		set drv [string trim [lindex $vdblist end]]
+		set cmd [list db.select "table=$tbl" "database=$db" "driver=$drv"]
 		run_panel $cmd
 	}
 }
@@ -680,7 +704,7 @@
 		GmLib::errmsg $error [G_msg "Error creating tempfile"]
 	}
 
-	set legfile "$tmpdir/gismlegend.txt"
+	set legfile [file join "$tmpdir" "gismlegend.txt"]
 	if {![file exists $legfile]} {return}
 	catch {set ltxt [open $legfile r]}
 	set x1 30



More information about the grass-commit mailing list