Browse Source

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á 11 years ago
parent
commit
ccf2e7bc4b
2 changed files with 34 additions and 3 deletions
  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.gselect import Select
 from gui_core.widgets import FloatValidator
 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.data import AnimationData, AnimLayer
 from animation.toolbars import AnimSimpleLmgrToolbar, SIMPLE_LMGR_STDS
 from animation.toolbars import AnimSimpleLmgrToolbar, SIMPLE_LMGR_STDS
 from gui_core.simplelmgr import SimpleLayerManager, \
 from gui_core.simplelmgr import SimpleLayerManager, \
@@ -1390,7 +1390,8 @@ class AddTemporalLayerDialog(wx.Dialog):
                 try:
                 try:
                     maps = getRegisteredMaps(self._name, etype=self._mapType)
                     maps = getRegisteredMaps(self._name, etype=self._mapType)
                     if maps:
                     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:
                 except gcore.ScriptError, e:
                     GError(parent=self, message=str(e), showTraceback=False)
                     GError(parent=self, message=str(e), showTraceback=False)
                     return None
                     return None

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

@@ -119,6 +119,28 @@ def getRegisteredMaps(timeseries, etype):
     return timeseriesMaps
     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):
 def checkSeriesCompatibility(mapSeriesList=None, timeseriesList=None):
     """!Checks whether time series (map series and stds) are compatible,
     """!Checks whether time series (map series and stds) are compatible,
         which means they have equal number of maps ad times (in case of stds).
         which means they have equal number of maps ad times (in case of stds).
@@ -292,7 +314,15 @@ def layerListToCmdsMatrix(layerList):
                     cmd = layer.cmd[:]
                     cmd = layer.cmd[:]
                     cmds = []
                     cmds = []
                     for map_ in layer.maps:
                     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[:])
                         cmds.append(cmd[:])
                     cmdsForComposition.append(cmds)
                     cmdsForComposition.append(cmds)
         else:
         else: