[GRASS-SVN] r30557 - grass/trunk/lib/init
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 14 05:36:49 EDT 2008
Author: pkelly
Date: 2008-03-14 05:36:49 -0400 (Fri, 14 Mar 2008)
New Revision: 30557
Modified:
grass/trunk/lib/init/epsg_option.tcl
grass/trunk/lib/init/file_option.tcl
Log:
Add improved interaction with g.proj to file_option.tcl (copy and paste
from epsg_option.tcl). Use eq and ne for comparing strings.
Modified: grass/trunk/lib/init/epsg_option.tcl
===================================================================
--- grass/trunk/lib/init/epsg_option.tcl 2008-03-14 07:25:49 UTC (rev 30556)
+++ grass/trunk/lib/init/epsg_option.tcl 2008-03-14 09:36:49 UTC (rev 30557)
@@ -236,11 +236,11 @@
DialogGen .wrnDlg [G_msg "Error creating location!"] error \
[format [G_msg "g.proj returned the following message:\n%s"] $errMsg] \
0 OK
- } elseif {$dtrans == ""} {
+ } elseif {$dtrans eq ""} {
# if nothing written to stdout, there was no choice of
# datum parameters and we need not do anything more
- if {$errMsg != ""} {
+ if {$errMsg ne ""} {
DialogGen .wrnDlg [G_msg "Informational output from g.proj"] info \
[format [G_msg "g.proj returned the following informational message:\n%s"] $errMsg] \
0 OK
@@ -264,7 +264,7 @@
[format [G_msg "g.proj returned the following message:\n%s"] $errMsg] \
0 OK
} else {
- if {$errMsg != ""} {
+ if {$errMsg ne ""} {
DialogGen .wrnDlg [G_msg "Informational output from g.proj"] info \
[format [G_msg "g.proj returned the following informational message:\n%s"] $errMsg] \
0 OK
Modified: grass/trunk/lib/init/file_option.tcl
===================================================================
--- grass/trunk/lib/init/file_option.tcl 2008-03-14 07:25:49 UTC (rev 30556)
+++ grass/trunk/lib/init/file_option.tcl 2008-03-14 09:36:49 UTC (rev 30557)
@@ -178,19 +178,97 @@
global location
global mapset
- # create new location from georeferenced file
- catch {exec g.proj -c georef=$filepath location=$fileLocation} errMsg
+ set dtrans ""
+ catch {set dtrans [exec g.proj --q -c location=$fileLocation georef=$filepath datumtrans=-1]} errMsg
+
if {[lindex $::errorCode 0] eq "CHILDSTATUS"} {
- DialogGen .wrnDlg [G_msg "WARNING: Error creating new location"] warning \
- [format [G_msg "Error creating new location from georeferenced file. \
- g.proj returned following message:\n\n%s"] $errMsg] \
- 0 OK
- } else {
+ DialogGen .wrnDlg [G_msg "Error creating location!"] error \
+ [format [G_msg "g.proj returned the following message:\n%s"] $errMsg] \
+ 0 OK
+ } elseif {$dtrans eq ""} {
+ # if nothing written to stdout, there was no choice of
+ # datum parameters and we need not do anything more
+
+ if {$errMsg ne ""} {
+ DialogGen .wrnDlg [G_msg "Informational output from g.proj"] info \
+ [format [G_msg "g.proj returned the following informational message:\n%s"] $errMsg] \
+ 0 OK
+ }
set location $fileLocation
set mapset "PERMANENT"
+ } else {
+ # user selects datum transform
+ #create dialog that lists datum transforms, asks user to enter a number and press OK
+ set paramset [fileOpt::sel_dtrans $dtrans]
+
+ # operation canceled
+ if {$paramset == -9} {return}
+
+ # create new location from georeferenced file
+ catch {exec g.proj --q -c georef=$filepath location=$fileLocation datumtrans=$paramset} errMsg
+
+ #catch any other errors
+ if {[lindex $::errorCode 0] eq "CHILDSTATUS"} {
+ DialogGen .wrnDlg [G_msg "Error creating location!"] warning \
+ [format [G_msg "g.proj returned the following message:\n%s"] $errMsg] \
+ 0 OK
+ } else {
+ if {$errMsg ne ""} {
+ DialogGen .wrnDlg [G_msg "Informational output from g.proj"] info \
+ [format [G_msg "g.proj returned the following informational message:\n%s"] $errMsg] \
+ 0 OK
+ }
+ set location $fileLocation
+ set mapset "PERMANENT"
+ }
}
-
return
}
+
+proc fileOpt::sel_dtrans {dtrans} {
+
+# Dialog for selecting optional datum transform parameters
+# Argument is stdout from g.proj
+
+ # default is not to specify datum transformation
+ set fileOpt::dtnum 0
+
+ # Create a popup search dialog
+ toplevel .dtrans_sel
+ wm title .dtrans_sel [G_msg "Select datum transformation parameters:"]
+ set row1 [frame .dtrans_sel.frame1]
+ set row3 [frame .dtrans_sel.frame3]
+
+ radiobutton $row1.0 -value 0 -variable fileOpt::dtnum -wraplength 640 -justify left -text [G_msg "Continue without specifying parameters - if used when creating a location, other GRASS modules will use the \"default\" (likely non-optimum) parameters for this datum if necessary in the future."]
+ pack $row1.0 -anchor w
+
+ set dtrans [split $dtrans "\n"]
+ for {set i 0} { $i < [llength $dtrans] } {incr i} {
+ set thisnum [lindex $dtrans $i]
+ if {$thisnum == "---"} {
+ continue
+ }
+ set thisdesc $thisnum.
+ while { [incr i] < [llength $dtrans] && [lindex $dtrans $i] != "---"} {
+ set thisdesc ${thisdesc}\n[lindex $dtrans $i]
+ }
+ radiobutton $row1.$thisnum -variable fileOpt::dtnum -value $thisnum -wraplength 640 -justify left -text $thisdesc
+ pack $row1.$thisnum -anchor w
+ }
+
+ pack $row1
+
+ Button $row3.ok -text [G_msg "OK"] -padx 10 -bd 1 \
+ -command "destroy .dtrans_sel"
+ pack $row3.ok -side left -padx 3
+ button $row3.cancel -text [G_msg "Cancel"] -padx 10 -bd 1 \
+ -command "set fileOpt::dtnum -9; destroy .dtrans_sel"
+ pack $row3.cancel -side left -padx 3
+ pack $row3 -anchor center -pady 3
+
+ tkwait window .dtrans_sel
+ return $fileOpt::dtnum
+
+}
More information about the grass-commit
mailing list