[GRASS-SVN] r62625 - grass/trunk/lib/python/temporal

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 5 12:29:17 PST 2014


Author: huhabla
Date: 2014-11-05 12:29:17 -0800 (Wed, 05 Nov 2014)
New Revision: 62625

Modified:
   grass/trunk/lib/python/temporal/register.py
   grass/trunk/lib/python/temporal/temporal_granularity.py
Log:
temporal framework: Fixed wrong granularity computation and name check befor deletion in register function.

Modified: grass/trunk/lib/python/temporal/register.py
===================================================================
--- grass/trunk/lib/python/temporal/register.py	2014-11-05 20:28:35 UTC (rev 62624)
+++ grass/trunk/lib/python/temporal/register.py	2014-11-05 20:29:17 UTC (rev 62625)
@@ -488,8 +488,9 @@
             if map.is_in_db(dbif):
                 map.delete(dbif)
             mod = copy.deepcopy(g_remove)
-            mod(type='rast', name=map.get_name())
-            mod.run()
+            if map.get_name():
+                mod(type='rast', name=map.get_name())
+                mod.run()
 
     if connected:
         dbif.close()

Modified: grass/trunk/lib/python/temporal/temporal_granularity.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_granularity.py	2014-11-05 20:28:35 UTC (rev 62624)
+++ grass/trunk/lib/python/temporal/temporal_granularity.py	2014-11-05 20:29:17 UTC (rev 62625)
@@ -197,16 +197,27 @@
             >>> tgis.compute_relative_time_granularity(maps)
             2
 
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((0,21),)
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_relative_time(t[0],t[1],"hours")
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_relative_time_granularity(maps)
+            21
+
     """
 
     # The interval time must be scaled to days resolution
     granularity = None
-
     delta = []
     # First we compute the timedelta of the intervals
     for map in maps:
         start, end = map.get_temporal_extent_as_tuple()
-        if start and end:
+        if (start == 0 or start) and end:
             t = abs(end - start)
             delta.append(int(t))
 



More information about the grass-commit mailing list