Browse Source

Bugfixing

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51181 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 13 years ago
parent
commit
b246301fdf

+ 5 - 0
lib/python/temporal/abstract_dataset.py

@@ -52,6 +52,11 @@ class abstract_dataset(object):
 
         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")

+ 7 - 3
lib/python/temporal/abstract_space_time_dataset.py

@@ -438,7 +438,7 @@ class abstract_space_time_dataset(abstract_dataset):
 
            In case nothing found None is returned
         """
-
+        
         use_start = False
         use_during = False
         use_overlap = False
@@ -498,7 +498,7 @@ class abstract_space_time_dataset(abstract_dataset):
 
             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 @@ class abstract_space_time_dataset(abstract_dataset):
                 sql += " AND %s" % (where)
             if order:
                 sql += " ORDER BY %s" % (order)
-
+                
             try:
                 dbif.cursor.execute(sql)
                 rows = dbif.cursor.fetchall()
@@ -1370,6 +1370,10 @@ def create_temporal_relation_sql_where_statement(start, end, use_start=True, use
         where += "(start_time = '%s' and end_time = '%s')" % (start, end)
 
     where += ")"
+    
+    # Catch empty where statement
+    if where == "()":
+	where = None
 
     return where
 

+ 47 - 10
lib/python/temporal/space_time_datasets.py

@@ -67,8 +67,13 @@ class raster_dataset(abstract_map_dataset):
     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 @@ class raster3d_dataset(abstract_map_dataset):
         """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,7 +257,13 @@ class vector_dataset(abstract_map_dataset):
     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"""
@@ -309,8 +328,13 @@ class space_time_raster_dataset(abstract_space_time_dataset):
     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 @@ class space_time_raster3d_dataset(abstract_space_time_dataset):
     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,7 +442,12 @@ class space_time_vector_dataset(abstract_space_time_dataset):
     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):
 

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

@@ -166,7 +166,7 @@ def register_maps_in_space_time_dataset(type, name, maps=None, file=None, start=
     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 @@ def register_maps_in_space_time_dataset(type, name, maps=None, file=None, start=
             # 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 @@ 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:
 
@@ -545,7 +543,6 @@ def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header, se
             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()
 

+ 4 - 4
lib/python/temporal/spatial_extent.py

@@ -61,16 +61,16 @@ class spatial_extent(sql_database_interface):
                 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