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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Mar 29 09:56:24 EDT 2012


Author: huhabla
Date: 2012-03-29 06:56:23 -0700 (Thu, 29 Mar 2012)
New Revision: 51181

Modified:
   grass/trunk/lib/python/temporal/abstract_dataset.py
   grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
   grass/trunk/lib/python/temporal/space_time_datasets.py
   grass/trunk/lib/python/temporal/space_time_datasets_tools.py
   grass/trunk/lib/python/temporal/spatial_extent.py
Log:
Bugfixing


Modified: grass/trunk/lib/python/temporal/abstract_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_dataset.py	2012-03-29 08:34:35 UTC (rev 51180)
+++ grass/trunk/lib/python/temporal/abstract_dataset.py	2012-03-29 13:56:23 UTC (rev 51181)
@@ -52,6 +52,11 @@
 
         raise IOError("This method must be implemented in the subclasses")
 
+    def spatial_relation(self, dataset):
+        """Return the spatial relationship between self and dataset"""
+
+        raise IOError("This method must be implemented in the subclasses")
+    
     def print_info(self):
         """Print information about this class in human readable style"""
 	raise IOError("This method must be implemented in the subclasses")

Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2012-03-29 08:34:35 UTC (rev 51180)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2012-03-29 13:56:23 UTC (rev 51181)
@@ -438,7 +438,7 @@
 
            In case nothing found None is returned
         """
-
+        
         use_start = False
         use_during = False
         use_overlap = False
@@ -498,7 +498,7 @@
 
             where = create_temporal_relation_sql_where_statement(start, end, use_start, \
                     use_during, use_overlap, use_contain, use_equal)  
-
+                    
             maps = self.get_registered_maps_as_objects(where, "start_time", dbif)
 
             result = {}
@@ -743,7 +743,7 @@
                 sql += " AND %s" % (where)
             if order:
                 sql += " ORDER BY %s" % (order)
-
+                
             try:
                 dbif.cursor.execute(sql)
                 rows = dbif.cursor.fetchall()
@@ -1370,6 +1370,10 @@
         where += "(start_time = '%s' and end_time = '%s')" % (start, end)
 
     where += ")"
+    
+    # Catch empty where statement
+    if where == "()":
+	where = None
 
     return where
 

Modified: grass/trunk/lib/python/temporal/space_time_datasets.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets.py	2012-03-29 08:34:35 UTC (rev 51180)
+++ grass/trunk/lib/python/temporal/space_time_datasets.py	2012-03-29 13:56:23 UTC (rev 51181)
@@ -67,8 +67,13 @@
     def spatial_overlapping(self, dataset):
         """Return True if the spatial extents 2d overlap"""
         
-        return self.spatial_extent.overlap_2d(dataset.spatial_extent)
+        return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
+    def spatial_relation(self, dataset):
+        """Return the two dimensional spatial relation"""
+        
+        return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
+	
     def reset(self, ident):
 	"""Reset the internal structure and set the identifier"""
 	self.ident = ident
@@ -151,10 +156,18 @@
         """Return True if the spatial extents overlap"""
         
         if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds":
-            return self.spatial_extent.overlap(dataset.spatial_extent)
+            return self.spatial_extent.overlapping(dataset.spatial_extent)
         else:
-            return self.spatial_extent.overlap_2d(dataset.spatial_extent)
+            return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
+    def spatial_relation(self, dataset):
+        """Return the two or three dimensional spatial relation"""
+        
+        if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds":
+            return self.spatial_extent.spatial_relation(dataset.spatial_extent)
+        else:
+            return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
+        
     def reset(self, ident):
 	"""Reset the internal structure and set the identifier"""
 	self.ident = ident
@@ -244,8 +257,14 @@
     def spatial_overlapping(self, dataset):
         """Return True if the spatial extents 2d overlap"""
         
-        return self.spatial_extent.overlap_2d(dataset.spatial_extent)
+        return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
+    def spatial_relation(self, dataset):
+        """Return the two dimensional spatial relation"""
+        
+        return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
+	
+
     def reset(self, ident):
 	"""Reset the internal structure and set the identifier"""
 	self.ident = ident
@@ -309,8 +328,13 @@
     def spatial_overlapping(self, dataset):
         """Return True if the spatial extents 2d overlap"""
         
-        return self.spatial_extent.overlap_2d(dataset.spatial_extent)
- 
+        return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
+
+    def spatial_relation(self, dataset):
+        """Return the two dimensional spatial relation"""
+        
+        return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
+	
     def reset(self, ident):
 
 	"""Reset the internal structure and set the identifier"""
@@ -358,11 +382,19 @@
     def spatial_overlapping(self, dataset):
         """Return True if the spatial extents overlap"""
         
-        if self.get_type() == dataset.get_type() or dataset.get_type() == "rast3d":
-            return self.spatial_extent.overlap(dataset.spatial_extent)
+        if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds":
+            return self.spatial_extent.overlapping(dataset.spatial_extent)
         else:
-            return self.spatial_extent.overlap_2d(dataset.spatial_extent)
+            return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
+    def spatial_relation(self, dataset):
+        """Return the two or three dimensional spatial relation"""
+        
+        if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds":
+            return self.spatial_extent.spatial_relation(dataset.spatial_extent)
+        else:
+            return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
+        
     def reset(self, ident):
 
 	"""Reset the internal structure and set the identifier"""
@@ -410,8 +442,13 @@
     def spatial_overlapping(self, dataset):
         """Return True if the spatial extents 2d overlap"""
         
-        return self.spatial_extent.overlap_2d(dataset.spatial_extent)
+        return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
+    def spatial_relation(self, dataset):
+        """Return the two dimensional spatial relation"""
+        
+        return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
+
     def reset(self, ident):
 
 	"""Reset the internal structure and set the identifier"""

Modified: grass/trunk/lib/python/temporal/space_time_datasets_tools.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets_tools.py	2012-03-29 08:34:35 UTC (rev 51180)
+++ grass/trunk/lib/python/temporal/space_time_datasets_tools.py	2012-03-29 13:56:23 UTC (rev 51181)
@@ -166,7 +166,7 @@
     for count in range(len(maplist)):
 	core.percent(count, num_maps, 1)
 
-        # Get a new instance of the space time dataset map type
+        # Get a new instance of the map type
         map = dataset_factory(type, maplist[count]["id"])
 
         # Use the time data from file
@@ -189,7 +189,6 @@
             # Load the data from the grass file database
             map.load()
 	    
-	    # We need to check the temporal type based on the time stamp
 	    if unit:
                 map.set_time_to_relative()
             else:
@@ -384,7 +383,6 @@
             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:
 
@@ -545,7 +543,6 @@
             string += "%s%s" % ("end_time", separator)
             string += "%s%s" % ("interval_length", separator)
             string += "%s"   % ("distance_from_begin")
-            print string
 
         first_time, dummy = mapmatrizes[0][0]["granule"].get_valid_time()
 

Modified: grass/trunk/lib/python/temporal/spatial_extent.py
===================================================================
--- grass/trunk/lib/python/temporal/spatial_extent.py	2012-03-29 08:34:35 UTC (rev 51180)
+++ grass/trunk/lib/python/temporal/spatial_extent.py	2012-03-29 13:56:23 UTC (rev 51181)
@@ -61,16 +61,16 @@
                 E -= 360.0
                 W -= 360.0
                 
-        if(self.get_north() <= S):
+        if(self.get_north() < S):
             return False
         
-        if(self.get_south() >= N):
+        if(self.get_south() > N):
             return False
             
-        if self.get_east() <= W:
+        if self.get_east() < W:
             return False
         
-        if self.get_west() >= E:
+        if self.get_west() > E:
             return False
         
         return True



More information about the grass-commit mailing list