[GRASS-SVN] r61910 - in grass/branches/releasebranch_7_0: . gui/wxpython/wxplot

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 13 12:42:06 PDT 2014


Author: annakrat
Date: 2014-09-13 12:42:06 -0700 (Sat, 13 Sep 2014)
New Revision: 61910

Modified:
   grass/branches/releasebranch_7_0/
   grass/branches/releasebranch_7_0/gui/wxpython/wxplot/profile.py
Log:
wxGUI/profile: fix #1787 - wxplot now converts distance from meters to the current units (merge from trunk, r61269)


Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
   - /grass/trunk:60289,60696,61380,61420,61422,61480,61500,61764,61891,61905,61907
   + /grass/trunk:60289,60696,61269,61380,61420,61422,61480,61500,61764,61891,61905,61907

Modified: grass/branches/releasebranch_7_0/gui/wxpython/wxplot/profile.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/wxplot/profile.py	2014-09-13 19:07:26 UTC (rev 61909)
+++ grass/branches/releasebranch_7_0/gui/wxpython/wxplot/profile.py	2014-09-13 19:42:06 UTC (rev 61910)
@@ -43,6 +43,22 @@
 from wxplot.dialogs    import ProfileRasterDialog, PlotStatsFrame
 from core.gcmd         import RunCommand, GWarning, GError, GMessage
 
+
+def get_unit_conversion():
+    """Get conversion factor to convert output from r.profile to current units.
+    Module r.profile always outputs distance in meters.
+
+    .. todo:: create a wrapper for g.proj in grass.core    
+    """
+    proj = RunCommand(prog='g.proj', read=True, flags='g').strip()
+    if not proj:
+        # TODO put some warning here
+        return 1.
+
+    proj = grass.parse_key_val(proj, sep='=')
+    return 1 / float(proj.get('meters', 1))
+
+
 class ProfileFrame(BasePlotFrame):
     """!Mainframe for displaying profile of one or more raster maps. Uses wx.lib.plot.
     """
@@ -59,6 +75,7 @@
             self.SetToolBar(self.toolbar)
         self.SetTitle(_("GRASS Profile Analysis Tool"))
         self._units = units
+        self._conversion = get_unit_conversion()
 
         #
         # Init variables
@@ -258,7 +275,8 @@
             if dist == None or dist == '' or dist == 'nan' or \
                 elev == None or elev == '' or elev == 'nan':
                 continue
-            dist = float(dist)
+            # remove conversion if one day r.profile starts to output distance in projection units!
+            dist = self._conversion * float(dist)
             elev = float(elev)
             datalist.append((dist,elev))
 



More information about the grass-commit mailing list