[GRASS-SVN] r56259 - in grass/trunk: gui/wxpython/location_wizard lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 15 04:07:02 PDT 2013


Author: hamish
Date: 2013-05-15 04:06:59 -0700 (Wed, 15 May 2013)
New Revision: 56259

Modified:
   grass/trunk/gui/wxpython/location_wizard/wizard.py
   grass/trunk/lib/python/script/core.py
Log:
sync datum transform fixes for proj 4.8.0 from devbr6 (#1849)

Modified: grass/trunk/gui/wxpython/location_wizard/wizard.py
===================================================================
--- grass/trunk/gui/wxpython/location_wizard/wizard.py	2013-05-15 10:55:27 UTC (rev 56258)
+++ grass/trunk/gui/wxpython/location_wizard/wizard.py	2013-05-15 11:06:59 UTC (rev 56259)
@@ -135,7 +135,7 @@
                        wx.ALL, border = 5,
                        pos = (2, 2))
 
-        self.sizer.Add(item = self.MakeLabel("%s:" % _("Optional Location Title"),
+        self.sizer.Add(item = self.MakeLabel("%s:" % _("Location Title"),
                                              tooltip = _("Optional location title, "
                                                          "you can leave this field blank.")),
                        flag = wx.ALIGN_RIGHT |
@@ -891,7 +891,7 @@
     def OnPageChanging(self, event):
         self.proj4params = ''
         proj = self.parent.projpage.p4proj
-                
+        
         if event.GetDirection():
             if self.datum not in self.parent.datums:
                 event.Veto()
@@ -902,7 +902,8 @@
                                  read = True,
                                  proj4 = '%s' % proj,
                                  datum = '%s' % self.datum, 
-                                 datum_trans = '-1')
+                                 datum_trans = '-1',
+                                 flags = 't')
 #                wx.Messagebox('here')
                 if ret != '':
                     dtrans = ''
@@ -1286,9 +1287,12 @@
 
     def OnBrowse(self, event):
         """!Choose file"""
-        dlg = wx.FileDialog(parent = self, message = _("Select WKT or PRJ file"),
-                            defaultDir = os.getcwd(), 
-                            wildcard = "PRJ files (*.prj)|*.prj|Files (*.*)|*.*", style = wx.OPEN)
+        dlg = wx.FileDialog(parent = self,
+                            message = _("Select WKT or PRJ file"),
+                            defaultDir = os.getcwd(),
+                            wildcard = "PRJ files (*.prj)|*.prj|Files (*.*)|*.*",
+                            style = wx.OPEN)
+
         if dlg.ShowModal() == wx.ID_OK:
             path = dlg.GetPath()
             self.tfile.SetValue(path)
@@ -1395,7 +1399,8 @@
                 ret = RunCommand('g.proj',
                                  read = True,
                                  epsg = self.epsgcode,
-                                 datum_trans = '-1')
+                                 datum_trans = '-1',
+                                 flags = 't')
                 
                 if ret != '':
                     dtrans = ''
@@ -1543,11 +1548,19 @@
 
     def OnPageChanging(self, event):
         if event.GetDirection():
-        # check for datum tranforms            
+            self.custom_dtrans_string = ''
+
+            if self.customstring.find('+datum=') < 0:
+                self.GetNext().SetPrev(self)
+                return
+
+            # check for datum tranforms
+            # FIXME: -t flag is a hack-around for trac bug #1849
             ret, out, err = RunCommand('g.proj',
                                        read = True, getErrorMsg = True,
                                        proj4 = self.customstring, 
-                                       datum_trans = '-1')
+                                       datum_trans = '-1',
+                                       flags = 't')
             if ret != 0:
                 wx.MessageBox(parent = self,
                               message = err,
@@ -1573,7 +1586,20 @@
                     return _('Datum transform is required.')
                 
                 self.parent.datum_trans = dtrans
-        
+
+                # prepare +nadgrids or +towgs84 terms for Summary page. first convert them:
+                ret, projlabel, err = RunCommand('g.proj',
+                                                 flags = 'jft',
+                                                 proj4 = self.customstring,
+                                                 datum_trans = dtrans,
+                                                 getErrorMsg = True,
+                                                 read = True)
+                # splitting on space alone would break for grid files with space in pathname
+                for projterm in projlabel.split(' +'):
+                    if projterm.find("towgs84=") != -1 or projterm.find("nadgrids=") != -1:
+                        self.custom_dtrans_string = ' +%s' % projterm
+                        break
+
         self.GetNext().SetPrev(self)
             
     def GetProjstring(self, event):
@@ -1686,7 +1712,7 @@
                 addl_opts = {}
                 if len(datum) > 0:
                     addl_opts['datum'] = '%s' % datum
-                    addl_opts['datumtrans'] = dtrans
+                    addl_opts['datum_trans'] = dtrans
 
                 ret, projlabel, err = RunCommand('g.proj',
                                                  flags = 'jf',
@@ -1697,7 +1723,7 @@
                                                  **addl_opts)
             elif coordsys == 'epsg':
                 ret, projlabel, err = RunCommand('g.proj',
-                                                 flags = 'jf',
+                                                 flags = 'jft',
                                                  epsg = epsgcode,
                                                  datum_trans = dtrans,
                                                  location = location,
@@ -1707,8 +1733,8 @@
             finishButton = wx.FindWindowById(wx.ID_FORWARD)
             if ret == 0:
                 if datum != '':
-                    projlabel = projlabel + ' ' + 'datum=%s' % datum
-                self.lproj4string.SetLabel(projlabel.replace(' ', os.linesep))
+                    projlabel = projlabel + '+datum=%s' % datum
+                self.lproj4string.SetLabel(projlabel.replace(' +', os.linesep + '+'))
                 finishButton.Enable(True)
             else:
                 GError(err, parent = self)
@@ -1739,7 +1765,8 @@
             self.lproj4string.SetLabel("")
         elif coordsys == 'custom':
             label = _("custom")
-            self.lproj4string.SetLabel(('%s' % self.parent.custompage.customstring.replace(' ', os.linesep)))
+            combo_str = self.parent.custompage.customstring + self.parent.custompage.custom_dtrans_string
+            self.lproj4string.SetLabel(('%s' % combo_str.replace(' +', os.linesep + '+')))
         self.lprojection.SetLabel(label)
         
     def OnFinish(self, event):
@@ -2055,10 +2082,15 @@
                                       datum_trans = self.datum_trans,
                                       desc = self.startpage.locTitle)
             elif coordsys == 'custom':
+                addl_opts = {}
+                if self.datum_trans is not None:
+                    addl_opts['datum_trans'] = self.datum_trans
+
                 grass.create_location(dbase = self.startpage.grassdatabase,
                                       location = self.startpage.location,
                                       proj4 = self.custompage.customstring,
-                                      desc = self.startpage.locTitle)
+                                      desc = self.startpage.locTitle,
+                                      **addl_opts)
             elif coordsys == "epsg":
                 if not self.epsgpage.epsgcode:
                     return _('EPSG code missing.')
@@ -2109,12 +2141,12 @@
         ellipse = self.ellipsepage.ellipse
         ellipsedesc = self.ellipsepage.ellipsedesc
         ellipseparams = self.ellipsepage.ellipseparams
-                
+        
         #
         # creating PROJ.4 string
         #
         proj4string = '%s %s' % (proj, proj4params)
-                            
+        
         # set ellipsoid parameters
         if ellipse != '':
             proj4string = '%s +ellps=%s' % (proj4string, ellipse)
@@ -2124,7 +2156,7 @@
             else:
                 item = ' +' + item
             proj4string = '%s %s' % (proj4string, item)
-            
+        
         # set datum transform parameters if relevant
         if datumparams:
             for item in datumparams:

Modified: grass/trunk/lib/python/script/core.py
===================================================================
--- grass/trunk/lib/python/script/core.py	2013-05-15 10:55:27 UTC (rev 56258)
+++ grass/trunk/lib/python/script/core.py	2013-05-15 11:06:59 UTC (rev 56259)
@@ -1257,6 +1257,7 @@
     """
     gisdbase = None
     if epsg or proj4 or filename or wkt:
+        # FIXME: changing GISDBASE mid-session is not background-job safe
         gisdbase = gisenv()['GISDBASE']
         run_command('g.gisenv',
                     set = 'GISDBASE=%s' % dbase)
@@ -1272,6 +1273,7 @@
     if epsg:
         ps = pipe_command('g.proj',
                           quiet = True,
+                          flags = 't',
                           epsg = epsg,
                           location = location,
                           stderr = PIPE,
@@ -1279,6 +1281,7 @@
     elif proj4:
         ps = pipe_command('g.proj',
                           quiet = True,
+                          flags = 't',
                           proj4 = proj4,
                           location = location,
                           stderr = PIPE,



More information about the grass-commit mailing list