瀏覽代碼

wxGUI: force map name to be fully qualified, trac https://trac.osgeo.org/grass/ticket/236

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32307 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 年之前
父節點
當前提交
93272d5919
共有 2 個文件被更改,包括 29 次插入25 次删除
  1. 28 24
      gui/wxpython/gui_modules/utils.py
  2. 1 1
      gui/wxpython/gui_modules/wxgui_utils.py

+ 28 - 24
gui/wxpython/gui_modules/utils.py

@@ -19,6 +19,7 @@ import sys
 
 import globalvar
 import gcmd
+import grassenv
 try:
     import subprocess
 except:
@@ -56,38 +57,41 @@ def GetTempfile(pref=None):
     except:
         return None
 
-def GetLayerNameFromCmd(dcmd):
-    """Get layer name from GRASS command
+def GetLayerNameFromCmd(dcmd, fullyQualified=False):
+    """Get map name from GRASS command
 
     @param dcmd GRASS command (given as list)
+    @param fullyQualified change map name to be fully qualified
 
     @return map name
     @return '' if no map name found in command
     """
     mapname = ''
-    for item in dcmd:
-        if 'map=' in item:
-            mapname = item.split('=')[1]
-        elif 'input=' in item:
-            mapname = item.split('=')[1]
-        elif 'red=' in item:
-            mapname = item.split('=')[1]
-        elif 'h_map=' in item:
-            mapname = item.split('=')[1]
-        elif 'reliefmap' in item:
-            mapname = item.split('=')[1]
-        elif 'd.grid' in item:
-            mapname = 'grid'
-        elif 'd.geodesic' in item:
-            mapname = 'geodesic'
-        elif 'd.rhumbline' in item:
-            mapname = 'rhumb'
-        elif 'labels=' in item:
-            mapname = item.split('=')[1]+' labels'
+
+    if 'd.grid' == dcmd[0]:
+        mapname = 'grid'
+    elif 'd.geodesic' in dcmd[0]:
+        mapname = 'geodesic'
+    elif 'd.rhumbline' in dcmd[0]:
+        mapname = 'rhumb'
+    elif 'labels=' in dcmd[0]:
+        mapname = dcmd[idx].split('=')[1]+' labels'
+    else:
+        for idx in range(len(dcmd)):
+            if 'map=' in dcmd[idx] or \
+                    'input=' in dcmd[idx] or \
+                    'red=' in dcmd[idx] or \
+                    'h_map=' in dcmd[idx] or \
+                    'reliefmap' in dcmd[idx]:
+                break
             
-        if mapname != '':
-            break
-        
+        if idx < len(dcmd):
+            mapname = dcmd[idx].split('=')[1]
+            if fullyQualified and '@' not in mapname:
+                dcmd[idx] = dcmd[idx].split('=')[0] + '=' + \
+                    mapname +  '@' + grassenv.GetGRASSVariable('MAPSET')
+                mapname = dcmd[idx].split('=')[1]
+                        
     return mapname
 
 def ListOfCatsToRange(cats):

+ 1 - 1
gui/wxpython/gui_modules/wxgui_utils.py

@@ -1134,7 +1134,7 @@ class LayerTree(CT.CustomTreeCtrl):
 
         # set layer text to map name
         if dcmd:
-            mapname = utils.GetLayerNameFromCmd(dcmd)
+            mapname = utils.GetLayerNameFromCmd(dcmd, fullyQualified=True)
             self.SetItemText(layer, mapname)
 
         # update layer data