[GRASS-SVN] r56014 - in grass/trunk: lib/python/temporal lib/temporal/SQL temporal/t.topology temporal/t.vect.observe.strds

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 27 09:08:48 PDT 2013


Author: huhabla
Date: 2013-04-27 09:08:47 -0700 (Sat, 27 Apr 2013)
New Revision: 56014

Added:
   grass/trunk/lib/temporal/SQL/raster3d_views.sql
   grass/trunk/lib/temporal/SQL/raster_views.sql
   grass/trunk/lib/temporal/SQL/str3ds_views.sql
   grass/trunk/lib/temporal/SQL/strds_views.sql
   grass/trunk/lib/temporal/SQL/stvds_views.sql
   grass/trunk/lib/temporal/SQL/vector_views.sql
Modified:
   grass/trunk/lib/python/temporal/abstract_dataset.py
   grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
   grass/trunk/lib/python/temporal/core.py
   grass/trunk/lib/python/temporal/pythontemporallib.dox
   grass/trunk/lib/python/temporal/spatial_extent.py
   grass/trunk/lib/python/temporal/spatio_temporal_relationships.py
   grass/trunk/lib/temporal/SQL/raster3d_metadata_table.sql
   grass/trunk/lib/temporal/SQL/raster_metadata_table.sql
   grass/trunk/lib/temporal/SQL/str3ds_metadata_table.sql
   grass/trunk/lib/temporal/SQL/strds_metadata_table.sql
   grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql
   grass/trunk/lib/temporal/SQL/vector_metadata_table.sql
   grass/trunk/temporal/t.topology/t.topology.py
   grass/trunk/temporal/t.topology/test.t.topology.abstime.sh
   grass/trunk/temporal/t.vect.observe.strds/test.t.vect.observe.strds.layer_bug.sh
Log:
Added bottom and top to views and separated them in new files. Support for spatio-temporal topology analysis.


Modified: grass/trunk/lib/python/temporal/abstract_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_dataset.py	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/python/temporal/abstract_dataset.py	2013-04-27 16:08:47 UTC (rev 56014)
@@ -91,7 +91,7 @@
         - finished
        
         To access topological information the spatial, temporal or booth topologies must be build first
-        using the SpatialTopologyBuilder, TemporalTopologyBuilder or SpatioTemporalTopologyBuilder.
+        using the SpatioTemporalTopologyBuilder.
         
         @return the dictionary with relations as keys and number as values or None in case the topology  wasn't build
         """

Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2013-04-27 16:08:47 UTC (rev 56014)
@@ -381,13 +381,16 @@
 
         return gaps
 
-    def print_temporal_relationships(self, maps=None, dbif=None):
+    def print_spatio_temporal_relationships(self, maps=None, spatial=None, dbif=None):
         """!Print the temporal relation matrix of all registered maps to stdout
 
            The temporal relation matrix includes the temporal relations between
            all registered maps. The relations are strings stored in a list of lists.
 
            @param maps a ordered by start_time list of map objects
+           @param spatial This indicates if the spatial topology is created as well:
+                          spatial can be None (no spatial topology), "2D" using west, east, 
+                          south, north or "3D" using west, east, south, north, bottom, top
            @param dbif The database interface to be used
         """
 
@@ -395,7 +398,8 @@
             maps = self.get_registered_maps_as_objects(
                 where=None, order="start_time", dbif=dbif)
 
-        print_temporal_topology_relationships(maps)
+        print_spatio_temporal_topology_relationships(maps1=maps, maps2=maps, 
+                                              spatial=spatial, dbif=dbif)
 
     def count_temporal_relations(self, maps=None, dbif=None):
         """!Count the temporal relations between the registered maps.
@@ -521,8 +525,8 @@
 
            Gaps between maps are identified as unregistered maps with id==None.
 
-           The map objects are initialized with the id and the temporal 
-           extent of the granule (temporal type, start time, end time).
+           The objects are initialized with their id's' and the spatio-temporal extent 
+           (temporal type, start time, end time, west, east, south, north, bottom and top).
            In case more map information are needed, use the select() 
            method for each listed object.
 
@@ -712,7 +716,7 @@
 
     def get_registered_maps_as_objects_by_granularity(self, gran=None, dbif=None):
         """!Return all registered maps as ordered (by start_time) object list with
-           "gap" map objects (id==None) for temporal topological operations 
+           "gap" map objects (id==None) for spatio-temporal topological operations 
            that require the temporal extent only.
            
            Each list entry is a list of map objects
@@ -729,8 +733,8 @@
 
            Gaps between maps are identified as unregistered maps with id==None.
 
-           The objects are initialized with the id and the temporal 
-           extent (temporal type, start time, end time).
+           The objects are initialized with their id's' and the spatio-temporal extent 
+           (temporal type, start time, end time, west, east, south, north, bottom and top).
            In case more map information are needed, use the select() 
            method for each listed object.
 
@@ -899,13 +903,13 @@
     def get_registered_maps_as_objects_with_gaps(self, where=None, dbif=None):
         """!Return all or a subset of the registered maps as 
            ordered (by start_time) object list with
-           "gap" map objects (id==None) for temporal topological operations 
-           that require the temporal extent only.
+           "gap" map objects (id==None) for spatio-temporal topological operations 
+           that require the spatio-temporal extent only.
 
            Gaps between maps are identified as maps with id==None
 
-           The objects are initialized with the id and the 
-           temporal extent (temporal type, start time, end time).
+           The objects are initialized with their id's' and the spatio-temporal extent 
+           (temporal type, start time, end time, west, east, south, north, bottom and top).
            In case more map information are needed, use the select() 
            method for each listed object.
 
@@ -954,10 +958,10 @@
     def get_registered_maps_as_objects_with_temporal_topology(self, where=None, order="start_time", 
                                        dbif=None):
         """!Return all or a subset of the registered maps as ordered object list with 
-           temporal topological relationship informations.
+           spatio-temporal topological relationship informations.
 
-           The objects are initialized with their id's' and the temporal extent 
-           (temporal type, start time, end time) and the temporal topological information.
+           The objects are initialized with their id's' and the spatio-temporal extent 
+           (temporal type, start time, end time, west, east, south, north, bottom and top).
            In case more map information are needed, use the select() 
            method for each listed object.
 
@@ -984,10 +988,10 @@
     def get_registered_maps_as_objects(self, where=None, order="start_time", 
                                        dbif=None):
         """!Return all or a subset of the registered maps as ordered object list for 
-           temporal topological operations that require the temporal extent only
+           spatio-temporal topological operations that require the spatio-temporal extent only
 
-           The objects are initialized with their id's' and the temporal extent 
-           (temporal type, start time, end time).
+           The objects are initialized with their id's' and the spatio-temporal extent 
+           (temporal type, start time, end time, west, east, south, north, bottom and top).
            In case more map information are needed, use the select() 
            method for each listed object.
 
@@ -1004,8 +1008,24 @@
 
         obj_list = []
 
-        rows = self.get_registered_maps(
-            "id,start_time,end_time", where, order, dbif)
+        # Older temporal databases have no bottom and top columns
+        # in their views so we need a work around to set the full
+        # spatial extent as well
+        has_bt_columns = True
+        try:
+            rows = self.get_registered_maps(
+                "id,start_time,end_time, west,east,south,north,bottom,top", 
+                where, order, dbif)
+        except:
+            try:
+                rows = self.get_registered_maps(
+                    "id,start_time,end_time", 
+                    where, order, dbif)
+                has_bt_columns = False
+                core.warning(_("Old temporal database format. The top and bottom column"\
+                               " is missing in the views, using a work around."))
+            except:
+                raise
 
         if rows is not None:
             for row in rows:
@@ -1015,6 +1035,15 @@
                 elif self.is_time_relative():
                     map.set_relative_time(row["start_time"], row["end_time"],
                                           self.get_relative_time_unit())
+                # The fast way
+                if has_bt_columns:
+                    map.set_spatial_extent(west=row["west"], east=row["east"],
+                    south=row["south"],north=row["north"], bottom=row["bottom"],
+                    top=row["top"])
+                # The slow work around
+                else:
+                    map.spatial_extent.select(dbif)
+                    
                 obj_list.append(copy.copy(map))
 
         if connected:

Modified: grass/trunk/lib/python/temporal/core.py
===================================================================
--- grass/trunk/lib/python/temporal/core.py	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/python/temporal/core.py	2013-04-27 16:08:47 UTC (rev 56014)
@@ -39,7 +39,7 @@
 import sys
 import grass.script.core as core
 # Import all supported database backends
-# Ignore import errors sicne they are checked later
+# Ignore import errors since they are checked later
 try:
     import sqlite3
 except ImportError:
@@ -56,17 +56,21 @@
 # It can either be "sqlite" or "pg"
 tgis_backed = None
 
+# The version of the temporal framework
+tgis_version="1.0"
 
-# This variable specifies if the ctypes interface to the grass 
-# libraries should be used to read map specific data. If set to False
-# the grass scripting library will be used to get map informations.
-# The advantage of the ctypes inteface is speed, the disadvantage is that
-# the GRASS C functions may call G_fatal_error() which exits the process.
-# That is not catchable in Python.
-use_ctypes_map_access = True
-        
 ###############################################################################
 
+def get_tgis_version():
+    """!Get the verion number of the temporal framework
+       @return The version number of the temporal framework as string
+    """
+    global tgis_version
+    return tgis_version
+
+
+###############################################################################
+
 def get_temporal_dbmi_init_string():
     kv = core.parse_command("t.connect", flags="pg")
     grassenv = core.gisenv()
@@ -93,6 +97,14 @@
 
 ###############################################################################
 
+# This variable specifies if the ctypes interface to the grass 
+# libraries should be used to read map specific data. If set to False
+# the grass scripting library will be used to get map informations.
+# The advantage of the ctypes inteface is speed, the disadvantage is that
+# the GRASS C functions may call G_fatal_error() which exits the process.
+# That is not catchable in Python.
+use_ctypes_map_access = True
+
 def set_use_ctypes_map_access(use_ctype = True):
     """!Define the map access method for the temporal GIS library
     
@@ -242,6 +254,13 @@
         ), "raster3d_metadata_table.sql"), 'r').read()
     vector_metadata_sql = open(os.path.join(
         get_sql_template_path(), "vector_metadata_table.sql"), 'r').read()
+    raster_views_sql = open(os.path.join(
+        get_sql_template_path(), "raster_views.sql"), 'r').read()
+    raster3d_views_sql = open(os.path.join(get_sql_template_path(
+        ), "raster3d_views.sql"), 'r').read()
+    vector_views_sql = open(os.path.join(
+        get_sql_template_path(), "vector_views.sql"), 'r').read()
+
     stds_tables_template_sql = open(os.path.join(
         get_sql_template_path(), "stds_tables_template.sql"), 'r').read()
     strds_metadata_sql = open(os.path.join(
@@ -250,6 +269,12 @@
         get_sql_template_path(), "str3ds_metadata_table.sql"), 'r').read()
     stvds_metadata_sql = open(os.path.join(
         get_sql_template_path(), "stvds_metadata_table.sql"), 'r').read()
+    strds_views_sql = open(os.path.join(
+        get_sql_template_path(), "strds_views.sql"), 'r').read()
+    str3ds_views_sql = open(os.path.join(
+        get_sql_template_path(), "str3ds_views.sql"), 'r').read()
+    stvds_views_sql = open(os.path.join(
+        get_sql_template_path(), "stvds_views.sql"), 'r').read()
 
     # Create the raster, raster3d and vector tables
     raster_tables_sql = map_tables_template_sql.replace("GRASS_MAP", "raster")
@@ -281,17 +306,23 @@
         # Create the global tables for the native grass datatypes
         cursor.executescript(raster_tables_sql)
         cursor.executescript(raster_metadata_sql)
+        cursor.executescript(raster_views_sql)
         cursor.executescript(vector_tables_sql)
         cursor.executescript(vector_metadata_sql)
+        cursor.executescript(vector_views_sql)
         cursor.executescript(raster3d_tables_sql)
         cursor.executescript(raster3d_metadata_sql)
+        cursor.executescript(raster3d_views_sql)
         # Create the tables for the new space-time datatypes
         cursor.executescript(strds_tables_sql)
         cursor.executescript(strds_metadata_sql)
+        cursor.executescript(strds_views_sql)
         cursor.executescript(stvds_tables_sql)
         cursor.executescript(stvds_metadata_sql)
+        cursor.executescript(stvds_views_sql)
         cursor.executescript(str3ds_tables_sql)
         cursor.executescript(str3ds_metadata_sql)
+        cursor.executescript(str3ds_views_sql)
         cursor.executescript(sqlite3_delete_trigger_sql)
     elif tgis_backed == "pg":
         # Connect to database
@@ -301,17 +332,23 @@
         # Create the global tables for the native grass datatypes
         cursor.execute(raster_tables_sql)
         cursor.execute(raster_metadata_sql)
+        cursor.execute(raster_views_sql)
         cursor.execute(vector_tables_sql)
         cursor.execute(vector_metadata_sql)
+        cursor.execute(vector_views_sql)
         cursor.execute(raster3d_tables_sql)
         cursor.execute(raster3d_metadata_sql)
+        cursor.execute(raster3d_views_sql)
         # Create the tables for the new space-time datatypes
         cursor.execute(strds_tables_sql)
         cursor.execute(strds_metadata_sql)
+        cursor.execute(strds_views_sql)
         cursor.execute(stvds_tables_sql)
         cursor.execute(stvds_metadata_sql)
+        cursor.execute(stvds_views_sql)
         cursor.execute(str3ds_tables_sql)
         cursor.execute(str3ds_metadata_sql)
+        cursor.execute(str3ds_views_sql)
 
     connection.commit()
     cursor.close()

Modified: grass/trunk/lib/python/temporal/pythontemporallib.dox
===================================================================
--- grass/trunk/lib/python/temporal/pythontemporallib.dox	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/python/temporal/pythontemporallib.dox	2013-04-27 16:08:47 UTC (rev 56014)
@@ -44,8 +44,9 @@
 of time stamped maps and space time datasets, such as temporal and spatial
 handling and representation:
 
+- python::temporal::spatial_topology_dataset_connector
+- python::temporal::temporal_topology_dataset_connector
 - python::temporal::abstract_dataset
-- python::temporal::abstract_temporal_dataset
 - python::temporal::abstract_map_dataset
 - python::temporal::abstract_space_time_dataset
 
@@ -54,12 +55,12 @@
 
 - python::temporal::space_time_datasets
 
-Helper functions to compute temporal granularity, handling of datetime objects
-and their conversion as well as topology computation are defined in these modules:
+Functions to compute temporal granularity, handling of datetime objects
+and their conversion as well as spatio-temporal topology computation are defined in these modules:
 
 - python::temporal::datetime_math
+- python::temporal::spatio_temporal_relationships
 - python::temporal::temporal_granularity
-- python::temporal::temporal_relationships
 
 Functionality that is shared between different temporal GRASS modules, such as
 map listing, space time dataset creation, map registration and unregistration, 

Modified: grass/trunk/lib/python/temporal/spatial_extent.py
===================================================================
--- grass/trunk/lib/python/temporal/spatial_extent.py	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/python/temporal/spatial_extent.py	2013-04-27 16:08:47 UTC (rev 56014)
@@ -634,13 +634,13 @@
                 eW -= 360.0
 
         # Edges of extent located outside of self are not allowed
-        if E < eW:
+        if E <= eW:
             return False
-        if W > eE:
+        if W >= eE:
             return False
-        if N < eS:
+        if N <= eS:
             return False
-        if S > eN:
+        if S >= eN:
             return False
 
         # First we check that at least one edge of extent meets an edge of self
@@ -1094,23 +1094,42 @@
     def disjoint_2d(self, extent):
         """!Return True if this extent (A) is disjoint with the provided spatial
         extent (B) in three dimensions.
-        
+
         @verbatim
-          _____ 
+          _____
          |  A  |
-         |_____|       
-         _______ 
+         |_____|
+         _______
         |   B   |
         |_______|
-                     
+
          @endverbatim
-         
+
         @param extent The spatial extent
         @return True or False
         """
 
-        if self.overlapping_2d(extent) or self.meet_2d(extent):
+        if self.is_in_2d(extent):
             return False
+
+        if self.contain_2d(extent):
+            return False
+
+        if self.cover_2d(extent):
+            return False
+
+        if self.covered_2d(extent):
+            return False
+
+        if self.equivalent_2d(extent):
+            return False
+
+        if self.overlapping_2d(extent):
+            return False
+
+        if  self.meet_2d(extent):
+            return False
+
         return True
 
     def disjoint(self, extent):
@@ -1121,8 +1140,27 @@
         @return True or False
         """
 
-        if self.overlapping(extent) or self.meet(extent):
+        if self.is_in(extent):
             return False
+
+        if self.contain(extent):
+            return False
+
+        if self.cover(extent):
+            return False
+
+        if self.covered(extent):
+            return False
+
+        if self.equivalent(extent):
+            return False
+
+        if self.overlapping(extent):
+            return False
+
+        if  self.meet(extent):
+            return False
+            
         return True
 
     def spatial_relation_2d(self, extent):
@@ -1331,6 +1369,14 @@
         >>> B = SpatialExtent(north=70, south=30, east=50, west=10, bottom=0, top=50)
         >>> A.spatial_relation(B)
         'meet'
+        >>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
+        >>> B = SpatialExtent(north=90, south=81, east=60, west=10, bottom=-50, top=50)
+        >>> A.spatial_relation(B)
+        'disjoint'
+        >>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
+        >>> B = SpatialExtent(north=90, south=80, east=60, west=10, bottom=-50, top=50)
+        >>> A.spatial_relation(B)
+        'meet'
         
         @endcode
         """

Modified: grass/trunk/lib/python/temporal/spatio_temporal_relationships.py
===================================================================
--- grass/trunk/lib/python/temporal/spatio_temporal_relationships.py	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/python/temporal/spatio_temporal_relationships.py	2013-04-27 16:08:47 UTC (rev 56014)
@@ -31,7 +31,7 @@
 class SpatioTemporalTopologyBuilder(object):
     """!This class is designed to build the spatio-temporal topology 
        of spatio-temporally related abstract dataset objects.
-       
+
        The abstract dataset objects must be provided as a single list, or in two lists.
 
         Example:
@@ -41,13 +41,13 @@
         maps = strds.get_registered_maps_as_objects()
 
         # Now lets build the temporal topology of the maps in the list
-        
+
         tb = SpatioTemporalTopologyBuilder()
-        
+
         tb.build(maps)
 
         dbif, connected = init_dbif(None)
-            
+
         for _map in tb:
             _map.select(dbif)
             _map.print_info()
@@ -97,7 +97,7 @@
         """
         return self._first
 
-    def _build_internal_iteratable(self, maps):
+    def _build_internal_iteratable(self, maps, spatial):
         """!Build an iteratable temporal topology structure for all maps in 
            the list and store the maps internally
 
@@ -109,7 +109,7 @@
            @param maps A sorted (by start_time)list of abstract_dataset 
                         objects with initiated temporal extent
         """
-        self._build_iteratable(maps)
+        self._build_iteratable(maps, spatial)
 
         for _map in maps:
             self._insert(_map)
@@ -117,7 +117,7 @@
         # Detect the first map
         self._detect_first()
 
-    def _build_iteratable(self, maps):
+    def _build_iteratable(self, maps, spatial):
         """!Build an iteratable temporal topology structure for 
            all maps in the list
 
@@ -141,7 +141,7 @@
         # First we need to order the map list chronologically 
         sorted_maps = sorted(
             maps, key=AbstractDatasetComparisonKeyStartTime)
-            
+
         for i in xrange(len(sorted_maps) - 1):
             sorted_maps[i].set_next(sorted_maps[i + 1])
 
@@ -150,26 +150,27 @@
             if next_:
                 next_.set_prev(map_)
             map_.set_temporal_topology_build_true()
-        
+            if spatial is not None:
+                map_.set_spatial_topology_build_true()
+
     def _map_to_rect(self, tree, map_, spatial=None):
         """Use the temporal extent of a map to create and return a RTree rectange
-        
-        
+
            @param spatial This indicates if the spatial topology is created as well:
                           spatial can be None (no spatial topology), "2D" using west, east, 
                           #south, north or "3D" using west, east, south, north, bottom, top
         """
         rect = vector.RTreeAllocRect(tree)
-        
+
         start, end = map_.get_valid_time()
-        
+
         if not end:
             end = start
-        
+
         if map_.is_time_absolute():
             start = time_delta_to_relative_time(start - self._timeref)
             end = time_delta_to_relative_time(end - self._timeref)
-        
+
         if spatial is None:
             vector.RTreeSetRect1D(rect, tree, float(start), float(end))
         elif spatial == "2D":
@@ -180,13 +181,13 @@
             north, south, east, west, top, bottom = map_.get_spatial_extent()
             vector.RTreeSetRect4D(rect, tree, west, east, south, north, 
                                   bottom, top, float(start), float(end))
-        
+
         return rect
-        
+
     def _build_rtree(self, maps, spatial=None):
         """Build and return the 1-4 dimensional R*-Tree
-        
-        
+
+
            @param spatial This indicates if the spatial topology is created as well:
                           spatial can be None (no spatial topology), "2D" using west, east, 
                           south, north or "3D" using west, east, south, north, bottom, top
@@ -196,13 +197,14 @@
             dim = 3
         if spatial == "3D":
             dim = 4
+
         tree = vector.RTreeCreateTree(-1, 0, dim)
 
         for i in xrange(len(maps)):
-            
+
             rect = self._map_to_rect(tree, maps[i], spatial)
             vector.RTreeInsertRect(rect, i + 1, tree)
-            
+
         return tree
 
     def build(self, mapsA, mapsB=None, spatial=None):
@@ -220,42 +222,33 @@
            the chronological iteration over the mapsA.
 
            @param mapsA A list of abstract_dataset 
-                         objects with initiated temporal extent
+                         objects with initiated spatio-temporal extent
            @param mapsB An optional list of abstract_dataset 
-                         objects with initiated temporal extent
+                         objects with initiated spatio-temporal extent
            @param spatial This indicates if the spatial topology is created as well:
                           spatial can be None (no spatial topology), "2D" using west, east, 
                           south, north or "3D" using west, east, south, north, bottom, top
         """
-        
-        if spatial is not None:
-            dbif, connected = init_dbif(None)
 
         identical = False
         if mapsA == mapsB:
             identical = True
-            
+
         if mapsB == None:
             mapsB = mapsA
             idetnical = True
 
         for map_ in mapsA:
             map_.reset_topology()
-            # Spatial extent from the database
-            if spatial is not None:
-                map_.select(dbif)
 
         if not identical:
             for map_ in mapsB:
                 map_.reset_topology()
-                # Spatial extent from the database
-                if spatial is not None:
-                    map_.select(dbif)
 
         tree = self. _build_rtree(mapsA, spatial)
-            
-        for j in xrange(len(mapsB)):            
-        
+
+        for j in xrange(len(mapsB)):
+
             list_ = gis.ilist()
             rect = self._map_to_rect(tree, mapsB[j], spatial)
             num = vector.RTreeSearch2(tree, rect, byref(list_))
@@ -266,24 +259,20 @@
 
                 # Get the temporal relationship
                 relation = mapsB[j].temporal_relation(mapsA[i])
-                
+
                 A = mapsA[i]
                 B = mapsB[j]
                 set_temoral_relationship(A, B, relation)
-                
+
                 if spatial is not None:
                     relation = mapsB[j].spatial_relation(mapsA[i])
                     set_spatial_relationship(A, B, relation)
 
-        self._build_internal_iteratable(mapsA)
+        self._build_internal_iteratable(mapsA, spatial)
         if not identical and mapsB != None:
-            self._build_iteratable(mapsB)
-        
+            self._build_iteratable(mapsB, spatial)
+
         vector.RTreeDestroyTree(tree)
-        
-        if spatial is not None:
-            if connected:
-                dbif.close()
 
     def __iter__(self):
         start_ = self._first
@@ -407,8 +396,9 @@
             A.append_overlaps(B)
 
 ###############################################################################
-       
+
 def set_spatial_relationship(A, B, relation):
+
     if relation == "equivalent":
         if B != A:
             if not B.get_equivalent() or \
@@ -486,24 +476,54 @@
                       objects with initiated temporal extent
         @param dbif The database interface to be used
     """
-                    
+
     tb = SpatioTemporalTopologyBuilder()
 
     tb.build(maps1, maps2)
 
     dbif, connected = init_dbif(dbif)
-        
+
     for _map in tb:
         _map.select(dbif)
         _map.print_info()
-        
+
     if connected:
         dbif.close()
-        
+
     return
 
 ###############################################################################
 
+def print_spatio_temporal_topology_relationships(maps1, maps2=None, spatial="2D", dbif=None):
+    """!Print the temporal relationships of the 
+       map lists maps1 and maps2 to stdout.
+
+        @param maps1 A list of abstract_dataset 
+                      objects with initiated temporal extent
+        @param maps2 An optional list of abstract_dataset 
+                      objects with initiated temporal extent
+        @param spatial The dimension of the spatial extent to be used: "2D" using west, east, 
+                        south, north or "3D" using west, east, south, north, bottom, top
+        @param dbif The database interface to be used
+    """
+
+    tb = SpatioTemporalTopologyBuilder()
+
+    tb.build(maps1, maps2, spatial)
+
+    dbif, connected = init_dbif(dbif)
+
+    for _map in tb:
+        _map.select(dbif)
+        _map.print_info()
+
+    if connected:
+        dbif.close()
+
+    return
+
+###############################################################################
+
 def count_temporal_topology_relationships(maps1, maps2=None, dbif=None):
     """!Count the temporal relations of a single list of maps or between two lists of maps
 
@@ -516,14 +536,14 @@
         @return A dictionary with counted temporal relationships
     """
 
-    
+
     tb = SpatioTemporalTopologyBuilder()
     tb.build(maps1, maps2)
 
     dbif, connected = init_dbif(dbif)
-    
+
     relations = None
-        
+
     for _map in tb:
         if relations != None:
             r = _map.get_number_of_relations()
@@ -534,7 +554,7 @@
 
     if connected:
         dbif.close()
-        
+
     return relations
 
 ###############################################################################
@@ -599,9 +619,9 @@
                          @endverbatim
 
         Usage:
-        
+
         @code
-        
+
         >>> # Relative time
         >>> start = 1
         >>> end = 2
@@ -667,7 +687,7 @@
         ... use_start=True, use_during=True, use_overlap=True, use_contain=True,
         ... use_equal=True, use_follows=True, use_precedes=True)
         "((start_time >= '2001-01-01 12:30:00' and start_time < '2001-03-31 14:30:00')  OR ((start_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time >= '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time > '2001-01-01 12:30:00' and end_time <= '2001-03-31 14:30:00')) OR ((start_time < '2001-01-01 12:30:00' and end_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time < '2001-03-31 14:30:00' and start_time > '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00')) OR ((start_time < '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time <= '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time < '2001-01-01 12:30:00' and end_time >= '2001-03-31 14:30:00')) OR (start_time = '2001-01-01 12:30:00' and end_time = '2001-03-31 14:30:00') OR (start_time = '2001-03-31 14:30:00') OR (end_time = '2001-01-01 12:30:00'))"
-        
+
         @endcode
         """
 
@@ -682,7 +702,7 @@
     if use_during:
         if use_start:
             where += " OR "
-            
+
         if isinstance(start, datetime):
             where += "((start_time > '%s' and end_time < '%s') OR " % (start, end)
             where += "(start_time >= '%s' and end_time < '%s') OR " % (start, end)
@@ -751,7 +771,6 @@
         where = None
 
     return where
-    
 
 ###############################################################################
 

Modified: grass/trunk/lib/temporal/SQL/raster3d_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/raster3d_metadata_table.sql	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/temporal/SQL/raster3d_metadata_table.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -1,7 +1,6 @@
 --#############################################################################
 -- This SQL script generates the raster3d metadata table to store 
--- and metadata for SQL queries and temporal GIS support. Additionally two views
--- are created to access all map specific tables
+-- and metadata for SQL queries and temporal GIS support.
 --
 -- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
 --#############################################################################
@@ -27,44 +26,6 @@
   FOREIGN KEY (id) REFERENCES  raster3d_base (id) ON DELETE CASCADE
 );
 
--- Create the views to access all cols for the absolute and relative time
-
-CREATE VIEW raster3d_view_abs_time AS SELECT 
-            A1.id, A1.mapset,
-            A1.name, A1.temporal_type,
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator,
-	    A2.start_time, A2.end_time, A2.timezone,
-            A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.datatype, A4.cols, A4.rows, A4.depths,
-            A4.nsres, A4.ewres, A4.tbres,
-            A4.min, A4.max,
-	    A4.str3ds_register,
-            A4.number_of_cells
-	    FROM raster3d_base A1, raster3d_absolute_time A2, 
-            raster3d_spatial_extent A3, raster3d_metadata A4 
-	    WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW raster3d_view_rel_time AS SELECT 
-            A1.id, A1.mapset,
-            A1.name, A1.temporal_type,
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator,
-	    A2.start_time, A2.end_time,
-            A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.datatype, A4.cols, A4.rows, A4.depths,
-            A4.nsres, A4.ewres, A4.tbres,
-            A4.min, A4.max,
-	    A4.str3ds_register,
-            A4.number_of_cells
-	    FROM raster3d_base A1, raster3d_relative_time A2, 
-            raster3d_spatial_extent A3, raster3d_metadata A4 
-	    WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
 -- Create a trigger to update the modification time and revision number in case the metadata have been updated 
 
 --CREATE TRIGGER update_raster3d_metadata AFTER UPDATE ON raster3d_metadata 

Added: grass/trunk/lib/temporal/SQL/raster3d_views.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/raster3d_views.sql	                        (rev 0)
+++ grass/trunk/lib/temporal/SQL/raster3d_views.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -0,0 +1,44 @@
+--#############################################################################
+-- This SQL script generates two views to access all map specific tables.
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+
+-- Create the views to access all cols for the absolute and relative time
+
+CREATE VIEW raster3d_view_abs_time AS SELECT 
+            A1.id, A1.mapset,
+            A1.name, A1.temporal_type,
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator,
+            A2.start_time, A2.end_time, A2.timezone,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.datatype, A4.cols, A4.rows, A4.depths,
+            A4.nsres, A4.ewres, A4.tbres,
+            A4.min, A4.max,
+            A4.str3ds_register,
+            A4.number_of_cells
+            FROM raster3d_base A1, raster3d_absolute_time A2, 
+            raster3d_spatial_extent A3, raster3d_metadata A4 
+            WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW raster3d_view_rel_time AS SELECT 
+            A1.id, A1.mapset,
+            A1.name, A1.temporal_type,
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator,
+            A2.start_time, A2.end_time,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.datatype, A4.cols, A4.rows, A4.depths,
+            A4.nsres, A4.ewres, A4.tbres,
+            A4.min, A4.max,
+            A4.str3ds_register,
+            A4.number_of_cells
+            FROM raster3d_base A1, raster3d_relative_time A2, 
+            raster3d_spatial_extent A3, raster3d_metadata A4 
+            WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
\ No newline at end of file

Modified: grass/trunk/lib/temporal/SQL/raster_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/raster_metadata_table.sql	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/temporal/SQL/raster_metadata_table.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -1,7 +1,6 @@
 --#############################################################################
 -- This SQL script generates the raster metadata table to store 
--- and metadata for SQL queries and temporal GIS support. Additionally two views
--- are created to access all map specific tables
+-- and metadata for SQL queries and temporal GIS support. 
 --
 -- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
 --#############################################################################
@@ -25,42 +24,6 @@
   FOREIGN KEY (id) REFERENCES  raster_base (id) ON DELETE CASCADE
 );
 
--- Create the views to access all cols for the absolute and relative time
-
-CREATE VIEW raster_view_abs_time AS SELECT 
-            A1.id, A1.mapset,
-            A1.name, A1.temporal_type,
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator, 
-	    A2.start_time, A2.end_time, A2.timezone,
-            A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.datatype, A4.cols, A4.rows,
-            A4.nsres, A4.ewres, A4.min, A4.max,
-	    A4.strds_register,
-            A4.number_of_cells
-	    FROM raster_base A1, raster_absolute_time A2, 
-            raster_spatial_extent A3, raster_metadata A4 
-	    WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW raster_view_rel_time AS SELECT 
-            A1.id, A1.mapset,
-            A1.name, A1.temporal_type,
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator, 
-	    A2.start_time, A2.end_time,
-            A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.datatype, A4.cols, A4.rows,
-            A4.nsres, A4.ewres, A4.min, A4.max,
-	    A4.strds_register,
-            A4.number_of_cells
-	    FROM raster_base A1, raster_relative_time A2, 
-            raster_spatial_extent A3, raster_metadata A4 
-	    WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
 -- Create a trigger to update the modification time and revision number in case the metadata have been updated 
 -- Uncommented due to performance issues
 --CREATE TRIGGER update_raster_metadata AFTER UPDATE ON raster_metadata 

Added: grass/trunk/lib/temporal/SQL/raster_views.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/raster_views.sql	                        (rev 0)
+++ grass/trunk/lib/temporal/SQL/raster_views.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -0,0 +1,42 @@
+--#############################################################################
+-- This SQL script generates two views to access all map specific tables.
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+
+-- Create the views to access all cols for the absolute and relative time
+
+CREATE VIEW raster_view_abs_time AS SELECT 
+            A1.id, A1.mapset,
+            A1.name, A1.temporal_type,
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator, 
+            A2.start_time, A2.end_time, A2.timezone,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.datatype, A4.cols, A4.rows,
+            A4.nsres, A4.ewres, A4.min, A4.max,
+            A4.strds_register,
+            A4.number_of_cells
+            FROM raster_base A1, raster_absolute_time A2, 
+            raster_spatial_extent A3, raster_metadata A4 
+            WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW raster_view_rel_time AS SELECT 
+            A1.id, A1.mapset,
+            A1.name, A1.temporal_type,
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator, 
+            A2.start_time, A2.end_time,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.datatype, A4.cols, A4.rows,
+            A4.nsres, A4.ewres, A4.min, A4.max,
+            A4.strds_register,
+            A4.number_of_cells
+            FROM raster_base A1, raster_relative_time A2, 
+            raster_spatial_extent A3, raster_metadata A4 
+            WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;

Modified: grass/trunk/lib/temporal/SQL/str3ds_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/str3ds_metadata_table.sql	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/temporal/SQL/str3ds_metadata_table.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -1,6 +1,5 @@
 --#############################################################################
--- This SQL script generates the space time 3D raster dataset metadata table,
--- view and trigger
+-- This SQL script generates the space time 3D raster dataset metadata table.
 --
 -- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
 --#############################################################################
@@ -27,51 +26,7 @@
   PRIMARY KEY (id),  
   FOREIGN KEY (id) REFERENCES  str3ds_base (id) ON DELETE CASCADE
 );
--- Create the views to access all cols for absolute or relative time
 
-CREATE VIEW str3ds_view_abs_time AS SELECT 
-            A1.id, A1.name, A1.mapset, A1.temporal_type,
-            A1.semantic_type, 
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator, 
-	    A2.start_time, A2.end_time, A2.timezone, A2.granularity,
-	    A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.raster3d_register,
-	    A4.number_of_maps, 
-            A4.nsres_min, A4.ewres_min, 
-            A4.nsres_max, A4.ewres_max, 
-            A4.tbres_min, A4.tbres_max, 
-	    A4.min_min, A4.min_max,
-	    A4.max_min, A4.max_max,
-            A4.title, A4.description, A4.command
-	    FROM str3ds_base A1, str3ds_absolute_time A2,  
-            str3ds_spatial_extent A3, str3ds_metadata A4 WHERE A1.id = A2.id AND 
-	    A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW str3ds_view_rel_time AS SELECT 
-            A1.id, A1.name, A1.mapset, A1.temporal_type,
-            A1.semantic_type, 
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator, 
-	    A2.start_time, A2.end_time, A2.granularity,
-	    A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.raster3d_register,
-	    A4.number_of_maps, 
-            A4.nsres_min, A4.ewres_min, 
-            A4.nsres_max, A4.ewres_max, 
-            A4.tbres_min, A4.tbres_max, 
-	    A4.min_min, A4.min_max,
-	    A4.max_min, A4.max_max,
-            A4.title, A4.description, A4.command
-	    FROM str3ds_base A1, str3ds_relative_time A2,  
-            str3ds_spatial_extent A3, str3ds_metadata A4 WHERE A1.id = A2.id AND 
-	    A1.id = A3.id AND A1.id = A4.id;
-
-
 -- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated 
 -- Uncommented due to performance issues
 --CREATE TRIGGER update_str3ds_metadata AFTER UPDATE ON str3ds_metadata 

Added: grass/trunk/lib/temporal/SQL/str3ds_views.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/str3ds_views.sql	                        (rev 0)
+++ grass/trunk/lib/temporal/SQL/str3ds_views.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -0,0 +1,49 @@
+--#############################################################################
+-- This SQL script generates the space time 3D raster dataset views.
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- Create the views to access all cols for absolute or relative time
+
+CREATE VIEW str3ds_view_abs_time AS SELECT 
+            A1.id, A1.name, A1.mapset, A1.temporal_type,
+            A1.semantic_type, 
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator, 
+            A2.start_time, A2.end_time, A2.timezone, A2.granularity,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.raster3d_register,
+            A4.number_of_maps, 
+            A4.nsres_min, A4.ewres_min, 
+            A4.nsres_max, A4.ewres_max, 
+            A4.tbres_min, A4.tbres_max, 
+            A4.min_min, A4.min_max,
+            A4.max_min, A4.max_max,
+            A4.title, A4.description, A4.command
+            FROM str3ds_base A1, str3ds_absolute_time A2,  
+            str3ds_spatial_extent A3, str3ds_metadata A4 WHERE A1.id = A2.id AND 
+	    A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW str3ds_view_rel_time AS SELECT 
+            A1.id, A1.name, A1.mapset, A1.temporal_type,
+            A1.semantic_type, 
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator, 
+            A2.start_time, A2.end_time, A2.granularity,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.raster3d_register,
+            A4.number_of_maps, 
+            A4.nsres_min, A4.ewres_min, 
+            A4.nsres_max, A4.ewres_max, 
+            A4.tbres_min, A4.tbres_max, 
+            A4.min_min, A4.min_max,
+            A4.max_min, A4.max_max,
+            A4.title, A4.description, A4.command
+            FROM str3ds_base A1, str3ds_relative_time A2,  
+            str3ds_spatial_extent A3, str3ds_metadata A4 WHERE A1.id = A2.id AND 
+            A1.id = A3.id AND A1.id = A4.id;

Modified: grass/trunk/lib/temporal/SQL/strds_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/strds_metadata_table.sql	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/temporal/SQL/strds_metadata_table.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -1,6 +1,5 @@
 --#############################################################################
--- This SQL script generates the space time raster dataset metadata table,
--- view and trigger
+-- This SQL script generates the space time raster dataset metadata table.
 --
 -- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
 --#############################################################################
@@ -25,49 +24,7 @@
   PRIMARY KEY (id),  
   FOREIGN KEY (id) REFERENCES  strds_base (id) ON DELETE CASCADE
 );
--- Create the views to access all cols for absolute or relative time
 
-CREATE VIEW strds_view_abs_time AS SELECT 
-            A1.id, A1.name, A1.mapset, A1.temporal_type,
-            A1.semantic_type, 
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator, 
-	    A2.start_time, A2.end_time, A2.timezone, A2.granularity,
-	    A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.raster_register,
-	    A4.number_of_maps, 
-            A4.nsres_min, A4.ewres_min, 
-            A4.nsres_max, A4.ewres_max, 
-	    A4.min_min, A4.min_max,
-	    A4.max_min, A4.max_max,
-            A4.title, A4.description, A4.command	
-	    FROM strds_base A1, strds_absolute_time A2,  
-            strds_spatial_extent A3, strds_metadata A4 WHERE A1.id = A2.id AND 
-	    A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW strds_view_rel_time AS SELECT 
-            A1.id, A1.name, A1.mapset, A1.temporal_type,
-            A1.semantic_type, 
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator, 
-	    A2.start_time, A2.end_time, A2.granularity,
-	    A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.raster_register,
-	    A4.number_of_maps, 
-            A4.nsres_min, A4.ewres_min, 
-            A4.nsres_max, A4.ewres_max, 
-	    A4.min_min, A4.min_max,
-	    A4.max_min, A4.max_max,
-            A4.title, A4.description, A4.command
-	    FROM strds_base A1, strds_relative_time A2,  
-            strds_spatial_extent A3, strds_metadata A4 WHERE A1.id = A2.id AND 
-	    A1.id = A3.id AND A1.id = A4.id;
-
-
 -- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated 
 -- Uncommented due to performance issues
 --CREATE TRIGGER update_strds_metadata AFTER UPDATE ON strds_metadata 

Added: grass/trunk/lib/temporal/SQL/strds_views.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/strds_views.sql	                        (rev 0)
+++ grass/trunk/lib/temporal/SQL/strds_views.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -0,0 +1,47 @@
+--#############################################################################
+-- This SQL script generates the space time raster dataset view.
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- Create the views to access all cols for absolute or relative time
+
+CREATE VIEW strds_view_abs_time AS SELECT 
+            A1.id, A1.name, A1.mapset, A1.temporal_type,
+            A1.semantic_type, 
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator, 
+            A2.start_time, A2.end_time, A2.timezone, A2.granularity,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.raster_register,
+            A4.number_of_maps, 
+            A4.nsres_min, A4.ewres_min, 
+            A4.nsres_max, A4.ewres_max, 
+            A4.min_min, A4.min_max,
+            A4.max_min, A4.max_max,
+            A4.title, A4.description, A4.command	
+            FROM strds_base A1, strds_absolute_time A2,  
+            strds_spatial_extent A3, strds_metadata A4 WHERE A1.id = A2.id AND 
+            A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW strds_view_rel_time AS SELECT 
+            A1.id, A1.name, A1.mapset, A1.temporal_type,
+            A1.semantic_type, 
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator, 
+            A2.start_time, A2.end_time, A2.granularity,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.raster_register,
+            A4.number_of_maps, 
+            A4.nsres_min, A4.ewres_min, 
+            A4.nsres_max, A4.ewres_max, 
+            A4.min_min, A4.min_max,
+            A4.max_min, A4.max_max,
+            A4.title, A4.description, A4.command
+            FROM strds_base A1, strds_relative_time A2,  
+            strds_spatial_extent A3, strds_metadata A4 WHERE A1.id = A2.id AND 
+            A1.id = A3.id AND A1.id = A4.id;

Modified: grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -1,6 +1,5 @@
 --#############################################################################
--- This SQL script generates the space time vector dataset metadata table,
--- view and trigger
+-- This SQL script generates the space time vector dataset metadata table.
 --
 -- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
 --#############################################################################
@@ -29,48 +28,7 @@
   PRIMARY KEY (id),  
   FOREIGN KEY (id) REFERENCES  stvds_base (id) ON DELETE CASCADE
 );
--- Create the views to access all columns for absolute or relative time
 
-CREATE VIEW stvds_view_abs_time AS SELECT 
-            A1.id, A1.name, A1.mapset, A1.temporal_type,
-            A1.semantic_type, 
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator, 
-	    A2.start_time, A2.end_time, A2.timezone,
-            A2.granularity,
-	    A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.vector_register,
-	    A4.number_of_maps, 
-            A4.title, A4.description, A4.command, A4.points, A4.lines,
-            A4.boundaries, A4.centroids, A4.faces, A4.kernels,
-            A4.primitives, A4.nodes, A4.areas, A4.islands,
-            A4.holes, A4.volumes
-	    FROM stvds_base A1, stvds_absolute_time A2,  
-            stvds_spatial_extent A3, stvds_metadata A4 WHERE A1.id = A2.id AND 
-	    A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW stvds_view_rel_time AS SELECT 
-            A1.id, A1.name, A1.mapset, A1.temporal_type,
-            A1.semantic_type, 
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator, 
-	    A2.start_time, A2.end_time, A2.granularity,
-	    A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.vector_register,
-	    A4.number_of_maps, 
-            A4.title, A4.description, A4.command, A4.points, A4.lines,
-            A4.boundaries, A4.centroids, A4.faces, A4.kernels,
-            A4.primitives, A4.nodes, A4.areas, A4.islands,
-            A4.holes, A4.volumes
-	    FROM stvds_base A1, stvds_relative_time A2,  
-            stvds_spatial_extent A3, stvds_metadata A4 WHERE A1.id = A2.id AND 
-	    A1.id = A3.id AND A1.id = A4.id;
-
-
 -- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated 
 -- Uncommented due to performance issues
 --CREATE TRIGGER update_stvds_metadata AFTER UPDATE ON stvds_metadata 

Added: grass/trunk/lib/temporal/SQL/stvds_views.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/stvds_views.sql	                        (rev 0)
+++ grass/trunk/lib/temporal/SQL/stvds_views.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -0,0 +1,46 @@
+--#############################################################################
+-- This SQL script generates the space time vector dataset view.
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- Create the views to access all columns for absolute or relative time
+
+CREATE VIEW stvds_view_abs_time AS SELECT 
+            A1.id, A1.name, A1.mapset, A1.temporal_type,
+            A1.semantic_type, 
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator, 
+            A2.start_time, A2.end_time, A2.timezone,
+            A2.granularity,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.vector_register,
+            A4.number_of_maps, 
+            A4.title, A4.description, A4.command, A4.points, A4.lines,
+            A4.boundaries, A4.centroids, A4.faces, A4.kernels,
+            A4.primitives, A4.nodes, A4.areas, A4.islands,
+            A4.holes, A4.volumes
+            FROM stvds_base A1, stvds_absolute_time A2,  
+            stvds_spatial_extent A3, stvds_metadata A4 WHERE A1.id = A2.id AND 
+            A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW stvds_view_rel_time AS SELECT 
+            A1.id, A1.name, A1.mapset, A1.temporal_type,
+            A1.semantic_type, 
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator, 
+            A2.start_time, A2.end_time, A2.granularity,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.vector_register,
+            A4.number_of_maps, 
+            A4.title, A4.description, A4.command, A4.points, A4.lines,
+            A4.boundaries, A4.centroids, A4.faces, A4.kernels,
+            A4.primitives, A4.nodes, A4.areas, A4.islands,
+            A4.holes, A4.volumes
+            FROM stvds_base A1, stvds_relative_time A2,  
+            stvds_spatial_extent A3, stvds_metadata A4 WHERE A1.id = A2.id AND 
+            A1.id = A3.id AND A1.id = A4.id;

Modified: grass/trunk/lib/temporal/SQL/vector_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/vector_metadata_table.sql	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/lib/temporal/SQL/vector_metadata_table.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -29,42 +29,6 @@
   FOREIGN KEY (id) REFERENCES  vector_base (id) ON DELETE CASCADE
 );
 
--- Create the views to access all columns for the absolute and relative time
-
-CREATE VIEW vector_view_abs_time AS SELECT 
-            A1.id, A1.mapset,
-            A1.name, A1.layer, A1.temporal_type,
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator, 
-	    A2.start_time, A2.end_time, A2.timezone,
-            A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.stvds_register, A4.is_3d, A4.points, A4.lines,
-            A4.boundaries, A4.centroids, A4.faces, A4.kernels,
-            A4.primitives, A4.nodes, A4.areas, A4.islands,
-            A4.holes, A4.volumes
-	    FROM vector_base A1, vector_absolute_time A2, 
-            vector_spatial_extent A3, vector_metadata A4 
-	    WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW vector_view_rel_time AS SELECT 
-            A1.id, A1.mapset,
-            A1.name, A1.layer, A1.temporal_type,
-            A1.creation_time, 
--- Uncommented due to performance issues
---            A1.modification_time, A1.revision, 
-            A1.creator, 
-	    A2.start_time, A2.end_time,
-            A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.stvds_register, A4.is_3d, A4.points, A4.lines,
-            A4.boundaries, A4.centroids, A4.faces, A4.kernels,
-            A4.primitives, A4.nodes, A4.areas, A4.islands,
-            A4.holes, A4.volumes
-	    FROM vector_base A1, vector_relative_time A2, 
-            vector_spatial_extent A3, vector_metadata A4 
-	    WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
 -- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated 
 -- Uncommented due to performance issues
 --CREATE TRIGGER update_vector_metadata AFTER UPDATE ON vector_metadata 

Added: grass/trunk/lib/temporal/SQL/vector_views.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/vector_views.sql	                        (rev 0)
+++ grass/trunk/lib/temporal/SQL/vector_views.sql	2013-04-27 16:08:47 UTC (rev 56014)
@@ -0,0 +1,41 @@
+--#############################################################################
+-- This SQL script generates two views to access all map specific tables.
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- Create the views to access all columns for the absolute and relative time
+
+CREATE VIEW vector_view_abs_time AS SELECT 
+            A1.id, A1.mapset,
+            A1.name, A1.layer, A1.temporal_type,
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator, 
+            A2.start_time, A2.end_time, A2.timezone,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.stvds_register, A4.is_3d, A4.points, A4.lines,
+            A4.boundaries, A4.centroids, A4.faces, A4.kernels,
+            A4.primitives, A4.nodes, A4.areas, A4.islands,
+            A4.holes, A4.volumes
+            FROM vector_base A1, vector_absolute_time A2, 
+            vector_spatial_extent A3, vector_metadata A4 
+            WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW vector_view_rel_time AS SELECT 
+            A1.id, A1.mapset,
+            A1.name, A1.layer, A1.temporal_type,
+            A1.creation_time, 
+-- Uncommented due to performance issues
+--            A1.modification_time, A1.revision, 
+            A1.creator, 
+            A2.start_time, A2.end_time,
+            A3.north, A3.south, A3.east, A3.west, A3.bottom, A3.top, A3.proj,
+            A4.stvds_register, A4.is_3d, A4.points, A4.lines,
+            A4.boundaries, A4.centroids, A4.faces, A4.kernels,
+            A4.primitives, A4.nodes, A4.areas, A4.islands,
+            A4.holes, A4.volumes
+            FROM vector_base A1, vector_relative_time A2, 
+            vector_spatial_extent A3, vector_metadata A4 
+            WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;

Modified: grass/trunk/temporal/t.topology/t.topology.py
===================================================================
--- grass/trunk/temporal/t.topology/t.topology.py	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/temporal/t.topology/t.topology.py	2013-04-27 16:08:47 UTC (rev 56014)
@@ -36,6 +36,11 @@
 #% description: Print temporal relationships and exit
 #%end
 
+#%flag
+#% key: s
+#% description: Print spatio-temporal relationships and exit
+#%end
+
 import grass.script as grass
 import grass.temporal as tgis
 
@@ -48,7 +53,8 @@
     name = options["input"]
     type = options["type"]
     where = options["where"]
-    tmatrix = flags['m']
+    temporal_relations = flags['m']
+    spatio_temporal_relations = flags['s']
 
     # Make sure the temporal database exists
     tgis.init()
@@ -72,9 +78,17 @@
     # Get ordered map list
     maps = sp.get_registered_maps_as_objects(
         where=where, order="start_time", dbif=None)
+    
+    spatial = None
+    
+    if spatio_temporal_relations:
+        if sp.get_type() == "strds":
+            spatial = "2D"
+        else:
+            spatial = "3D"
 
-    if tmatrix:
-        sp.print_temporal_relationships(maps)
+    if temporal_relations or spatio_temporal_relations:
+        sp.print_spatio_temporal_relationships(maps=maps, spatial=spatial)
         return
 
     sp.base.print_info()

Modified: grass/trunk/temporal/t.topology/test.t.topology.abstime.sh
===================================================================
--- grass/trunk/temporal/t.topology/test.t.topology.abstime.sh	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/temporal/t.topology/test.t.topology.abstime.sh	2013-04-27 16:08:47 UTC (rev 56014)
@@ -12,9 +12,14 @@
 r.mapcalc --o expr="prec_4 = rand(0, 510)"
 r.mapcalc --o expr="prec_5 = rand(0, 300)"
 r.mapcalc --o expr="prec_6 = rand(0, 650)"
+
+# Different spatial extents
 r.mapcalc --o expr="A = 1"
+g.region s=20 n=70 w=10 e=110 b=10 t=40 res=10 res3=10 -p3 # in A, covered by C
 r.mapcalc --o expr="B = 2"
+g.region s=20 n=80 w=10 e=130 b=10 t=50 res=10 res3=10 -p3 # cover B
 r.mapcalc --o expr="C = 3"
+g.region s=70 n=90 w=10 e=130 b=10 t=50 res=10 res3=10 -p3 # overlap B
 r.mapcalc --o expr="D = 3"
 
 n1=`g.tempfile pid=1 -d` 
@@ -111,7 +116,7 @@
 t.register --o type=rast -i input=maps file="${n6}"
 cat "${n6}"
 t.topology    input=maps
-t.topology -m input=maps
+t.topology -ms input=maps
 
 t.remove type=strds input=precip_abs,maps
 t.unregister type=rast file="${n1}"

Modified: grass/trunk/temporal/t.vect.observe.strds/test.t.vect.observe.strds.layer_bug.sh
===================================================================
--- grass/trunk/temporal/t.vect.observe.strds/test.t.vect.observe.strds.layer_bug.sh	2013-04-27 11:24:23 UTC (rev 56013)
+++ grass/trunk/temporal/t.vect.observe.strds/test.t.vect.observe.strds.layer_bug.sh	2013-04-27 16:08:47 UTC (rev 56014)
@@ -12,7 +12,7 @@
 rm ${MAP_LIST}
 
 count=1
-while [ $count -lt 500 ]; do
+while [ $count -lt 270 ]; do
     name="test_prec_${count}"
     r.mapcalc --o expr="${name} = ${count}"
     echo ${name} >> ${MAP_LIST}
@@ -36,5 +36,5 @@
 t.remove type=strds input=precip_abs1
 t.remove type=stvds input=prec_observer
 
-g.remove vect=prec_observer
+#g.remove vect=prec_observer
 g.mremove -f rast=test_prec_*



More information about the grass-commit mailing list