[GRASS-SVN] r69242 - in grass/branches/releasebranch_7_0: gui/wxpython/gui_core gui/wxpython/mapdisp gui/wxpython/mapswipe lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 23 07:49:21 PDT 2016


Author: lucadelu
Date: 2016-08-23 07:49:21 -0700 (Tue, 23 Aug 2016)
New Revision: 69242

Modified:
   grass/branches/releasebranch_7_0/gui/wxpython/gui_core/query.py
   grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/frame.py
   grass/branches/releasebranch_7_0/gui/wxpython/mapswipe/frame.py
   grass/branches/releasebranch_7_0/lib/python/script/raster.py
Log:
python script: backported raster_what function to work with or without localized labels fixed #2912

Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/query.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/query.py	2016-08-23 14:43:28 UTC (rev 69241)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/query.py	2016-08-23 14:49:21 UTC (rev 69242)
@@ -249,7 +249,8 @@
     from grass.script import vector as gvect
     from grass.script import raster as grast
     testdata1 = grast.raster_what(map = ('elevation_shade at PERMANENT','landclass96'),
-                                  coord = [(638509.051416,224742.348346)])
+                                  coord = [(638509.051416,224742.348346)],
+                                  localized=True)
 
     testdata2 = gvect.vector_what(map=('firestations','bridges'),
                                   coord=(633177.897487,221352.921257), distance=10)

Modified: grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/frame.py	2016-08-23 14:43:28 UTC (rev 69241)
+++ grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/frame.py	2016-08-23 14:49:21 UTC (rev 69242)
@@ -867,7 +867,8 @@
         rastQuery = []
         vectQuery = []
         if rast:
-            rastQuery = grass.raster_what(map=rast, coord=(east, north))
+            rastQuery = grass.raster_what(map=rast, coord=(east, north),
+                                          localized=True)
         if vect:
             encoding = UserSettings.Get(group='atm', key='encoding', subkey='value')
             try:

Modified: grass/branches/releasebranch_7_0/gui/wxpython/mapswipe/frame.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/mapswipe/frame.py	2016-08-23 14:43:28 UTC (rev 69241)
+++ grass/branches/releasebranch_7_0/gui/wxpython/mapswipe/frame.py	2016-08-23 14:49:21 UTC (rev 69242)
@@ -645,11 +645,13 @@
 
         result = []
         if rasters[0]:
-            result.extend(grass.raster_what(map=rasters[0], coord=(east, north)))
+            result.extend(grass.raster_what(map=rasters[0], coord=(east, north),
+                                            localized=True))
         if vectors[0]:
             result.extend(grass.vector_what(map=vectors[0], coord=(east, north), distance=qdist))
         if rasters[1]:
-            result.extend(grass.raster_what(map=rasters[1], coord=(east, north)))
+            result.extend(grass.raster_what(map=rasters[1], coord=(east, north),
+                                            localized=True))
         if vectors[1]:
             result.extend(grass.vector_what(map=vectors[1], coord=(east, north), distance=qdist))
 

Modified: grass/branches/releasebranch_7_0/lib/python/script/raster.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/script/raster.py	2016-08-23 14:43:28 UTC (rev 69241)
+++ grass/branches/releasebranch_7_0/lib/python/script/raster.py	2016-08-23 14:49:21 UTC (rev 69242)
@@ -149,7 +149,7 @@
     return p
 
 
-def raster_what(map, coord, env=None):
+def raster_what(map, coord, env=None, localized=False):
     """Interface to r.what
 
     >>> raster_what('elevation', [[640000, 228000]])
@@ -187,7 +187,10 @@
     if not ret:
         return data
 
-    labels = (_("value"), _("label"), _("color"))
+    if localized:
+        labels = (_("value"), _("label"), _("color"))
+    else:
+        labels = ('value', 'label', 'color')
     for item in ret.splitlines():
         line = item.split(sep)[3:]
         for i, map_name in enumerate(map_list):



More information about the grass-commit mailing list