Selaa lähdekoodia

python script: backported raster_what function to work with or without localized labels fixed https://trac.osgeo.org/grass/ticket/2912

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@69242 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 8 vuotta sitten
vanhempi
commit
518ed3f264

+ 2 - 1
gui/wxpython/gui_core/query.py

@@ -249,7 +249,8 @@ def test():
     from grass.script import vector as gvect
     from grass.script import raster as grast
     testdata1 = grast.raster_what(map = ('elevation_shade@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)

+ 2 - 1
gui/wxpython/mapdisp/frame.py

@@ -867,7 +867,8 @@ class MapFrame(SingleMapFrame):
         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:

+ 4 - 2
gui/wxpython/mapswipe/frame.py

@@ -645,11 +645,13 @@ class SwipeMapFrame(DoubleMapFrame):
 
         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))
 

+ 5 - 2
lib/python/script/raster.py

@@ -149,7 +149,7 @@ def mapcalc_start(exp, quiet=False, verbose=False, overwrite=False,
     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 @@ def raster_what(map, coord, env=None):
     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):