Explorar el Código

Fixed bug in map granularity handling in case of gaps

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53151 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert hace 12 años
padre
commit
91e74712dd

+ 16 - 2
lib/python/temporal/abstract_space_time_dataset.py

@@ -650,7 +650,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
 
             rows = self.get_registered_maps("id", where, "start_time", dbif)
 
-            if rows is not None:
+            if rows is not None and len(rows) != 0:
                 if len(rows) > 1:
                     core.warning(_("More than one map found in a granule. "
                                    "Temporal granularity seems to be invalid or"
@@ -660,7 +660,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
 
                 maplist = []
                 for row in rows:
-                   # Take the first map
+                    # Take the first map
                     map = self.get_new_map_instance(rows[0]["id"])
 
                     if self.is_time_absolute():
@@ -672,7 +672,21 @@ class AbstractSpaceTimeDataset(AbstractDataset):
                     maplist.append(copy.copy(map))
 
                 obj_list.append(copy.copy(maplist))
+	    else:
+		# Found a gap
+                map = self.get_new_map_instance(None)
+
+                if self.is_time_absolute():
+                    map.set_absolute_time(start, next)
+                elif self.is_time_relative():
+                    map.set_relative_time(start, next, 
+                                         self.get_relative_time_unit())
 
+                maplist = []
+                maplist.append(copy.copy(map))
+
+                obj_list.append(copy.copy(maplist))
+	
             start = next
 
         if connect:

+ 2 - 4
lib/python/temporal/space_time_datasets_tools.py

@@ -197,7 +197,6 @@ def register_maps_in_space_time_dataset(
 
         # Put the map into the database
         if not map.is_in_db(dbif):
-            print "Map not in db"
             is_in_db = False
             # Break in case no valid time is provided
             if start == "" or start is None:
@@ -496,8 +495,6 @@ def list_maps_of_stds(type, input, columns, order, where, separator, method, hea
         elif method == "gran":
             maps = sp.get_registered_maps_as_objects_by_granularity(None)
             
-        print "The maps object:", maps
-
         if header:
             string = ""
             string += "%s%s" % ("id", separator)
@@ -509,6 +506,7 @@ def list_maps_of_stds(type, input, columns, order, where, separator, method, hea
             string += "%s%s" % ("end_time", separator)
             string += "%s%s" % ("interval_length", separator)
             string += "%s" % ("distance_from_begin")
+            print string
 
         if maps and len(maps) > 0:
 
@@ -527,7 +525,7 @@ def list_maps_of_stds(type, input, columns, order, where, separator, method, hea
                     if len(mymap) > 0:
                         map = mymap[0]
                     else:
-                        core.error(_("Empty entry in map list, continue to next entry"))
+                        core.fatal(_("Empty entry in map list, this should not happen."))
                 else:
                     map = mymap