Browse Source

temporal framework: Fixed wrong granularity computation and name check befor deletion in register function.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@62625 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 10 years ago
parent
commit
d821a0ab9b
2 changed files with 16 additions and 4 deletions
  1. 3 2
      lib/python/temporal/register.py
  2. 13 2
      lib/python/temporal/temporal_granularity.py

+ 3 - 2
lib/python/temporal/register.py

@@ -488,8 +488,9 @@ def register_map_object_list(type,  map_list, output_stds,
             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()

+ 13 - 2
lib/python/temporal/temporal_granularity.py

@@ -197,16 +197,27 @@ def compute_relative_time_granularity(maps):
             >>> tgis.compute_relative_time_granularity(maps)
             2
 
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((0,21),)
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i@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))