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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 10 03:40:46 PDT 2012


Author: huhabla
Date: 2012-09-10 03:40:45 -0700 (Mon, 10 Sep 2012)
New Revision: 53151

Modified:
   grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
   grass/trunk/lib/python/temporal/space_time_datasets_tools.py
Log:
Fixed bug in map granularity handling in case of gaps


Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2012-09-10 10:27:55 UTC (rev 53150)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2012-09-10 10:40:45 UTC (rev 53151)
@@ -650,7 +650,7 @@
 
             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 @@
 
                 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 @@
                     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:

Modified: grass/trunk/lib/python/temporal/space_time_datasets_tools.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets_tools.py	2012-09-10 10:27:55 UTC (rev 53150)
+++ grass/trunk/lib/python/temporal/space_time_datasets_tools.py	2012-09-10 10:40:45 UTC (rev 53151)
@@ -197,7 +197,6 @@
 
         # 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 @@
         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 @@
             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 @@
                     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
 



More information about the grass-commit mailing list