Explorar o código

wxGUI/animation: support also registered vector layers, not just registered vector maps, in 2D

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@60115 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová %!s(int64=11) %!d(string=hai) anos
pai
achega
ccf2e7bc4b
Modificáronse 2 ficheiros con 34 adicións e 3 borrados
  1. 3 2
      gui/wxpython/animation/dialogs.py
  2. 31 1
      gui/wxpython/animation/utils.py

+ 3 - 2
gui/wxpython/animation/dialogs.py

@@ -37,7 +37,7 @@ from core.utils import _
 from gui_core.gselect import Select
 from gui_core.widgets import FloatValidator
 
-from animation.utils import TemporalMode, getRegisteredMaps
+from animation.utils import TemporalMode, getRegisteredMaps, getNameAndLayer
 from animation.data import AnimationData, AnimLayer
 from animation.toolbars import AnimSimpleLmgrToolbar, SIMPLE_LMGR_STDS
 from gui_core.simplelmgr import SimpleLayerManager, \
@@ -1390,7 +1390,8 @@ class AddTemporalLayerDialog(wx.Dialog):
                 try:
                     maps = getRegisteredMaps(self._name, etype=self._mapType)
                     if maps:
-                        cmd.append('map={name}'.format(name=maps[0]))
+                        mapName, mapLayer = getNameAndLayer(maps[0])
+                        cmd.append('map={name}'.format(name=mapName))
                 except gcore.ScriptError, e:
                     GError(parent=self, message=str(e), showTraceback=False)
                     return None

+ 31 - 1
gui/wxpython/animation/utils.py

@@ -119,6 +119,28 @@ def getRegisteredMaps(timeseries, etype):
     return timeseriesMaps
 
 
+def getNameAndLayer(name):
+    """!Checks whether map name contains layer
+    and returns map name with mapset (when there was mapset)
+    and layer (can be None).
+
+    >>> getNameAndLayer('name:2@mapset')
+    ('name@mapset', '2')
+    >>> getNameAndLayer('name@mapset')
+    ('name@mapset', None)
+    >>> getNameAndLayer('name:2')
+    ('name', '2')
+    """
+    mapset = layer = None
+    if '@' in name:
+        name, mapset = name.split('@')
+    if ':' in name:
+        name, layer = name.split(':')
+    if mapset:
+        name = name + '@' + mapset
+    return name, layer
+
+
 def checkSeriesCompatibility(mapSeriesList=None, timeseriesList=None):
     """!Checks whether time series (map series and stds) are compatible,
         which means they have equal number of maps ad times (in case of stds).
@@ -292,7 +314,15 @@ def layerListToCmdsMatrix(layerList):
                     cmd = layer.cmd[:]
                     cmds = []
                     for map_ in layer.maps:
-                        cmd[i] = 'map={name}'.format(name=map_)
+                        # check if dataset uses layers instead of maps
+                        mapName, mapLayer = getNameAndLayer(map_)
+                        cmd[i] = 'map={name}'.format(name=mapName)
+                        if mapLayer:
+                            try:
+                                idx = cmd.index('layer')
+                                cmd[idx] = 'layer={layer}'.format(layer=mapLayer)
+                            except ValueError:
+                                cmd.append('layer={layer}'.format(layer=mapLayer))
                         cmds.append(cmd[:])
                     cmdsForComposition.append(cmds)
         else: