[GRASS-SVN] r60116 - grass/branches/releasebranch_7_0/gui/wxpython/animation

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 5 10:32:48 PDT 2014


Author: annakrat
Date: 2014-05-05 10:32:48 -0700 (Mon, 05 May 2014)
New Revision: 60116

Modified:
   grass/branches/releasebranch_7_0/gui/wxpython/animation/dialogs.py
   grass/branches/releasebranch_7_0/gui/wxpython/animation/utils.py
Log:
wxGUI/animation: support also registered vector layers, not just registered vector maps, in 2D (merge from trunk, r60115)

Modified: grass/branches/releasebranch_7_0/gui/wxpython/animation/dialogs.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/animation/dialogs.py	2014-05-05 17:27:14 UTC (rev 60115)
+++ grass/branches/releasebranch_7_0/gui/wxpython/animation/dialogs.py	2014-05-05 17:32:48 UTC (rev 60116)
@@ -41,7 +41,7 @@
 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, \
@@ -1394,7 +1394,8 @@
                 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

Modified: grass/branches/releasebranch_7_0/gui/wxpython/animation/utils.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/animation/utils.py	2014-05-05 17:27:14 UTC (rev 60115)
+++ grass/branches/releasebranch_7_0/gui/wxpython/animation/utils.py	2014-05-05 17:32:48 UTC (rev 60116)
@@ -117,6 +117,28 @@
     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 at mapset')
+    ('name at mapset', '2')
+    >>> getNameAndLayer('name at mapset')
+    ('name at 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).
@@ -290,7 +312,15 @@
                     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:



More information about the grass-commit mailing list