[GRASS-SVN] r51407 - in grass/trunk: lib/python/temporal lib/temporal/SQL temporal temporal/t.info temporal/t.rast.export temporal/t.rast.import temporal/t.rast.mapcalc temporal/t.rast.series temporal/t.rast.to.rast3 temporal/t.register temporal/t.sample temporal/t.support temporal/t.vect.extract temporal/t.vect.list temporal/t.vect.what.strds

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Apr 13 07:13:35 EDT 2012


Author: huhabla
Date: 2012-04-13 04:13:35 -0700 (Fri, 13 Apr 2012)
New Revision: 51407

Added:
   grass/trunk/temporal/run_all_tests.sh
   grass/trunk/temporal/t.vect.extract/
   grass/trunk/temporal/t.vect.extract/Makefile
   grass/trunk/temporal/t.vect.extract/t.vect.extract.html
   grass/trunk/temporal/t.vect.extract/t.vect.extract.py
   grass/trunk/temporal/t.vect.extract/test.t.vect.extract.sh
Modified:
   grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
   grass/trunk/lib/python/temporal/aggregation.py
   grass/trunk/lib/python/temporal/extract.py
   grass/trunk/lib/python/temporal/mapcalc.py
   grass/trunk/lib/python/temporal/metadata.py
   grass/trunk/lib/python/temporal/space_time_datasets.py
   grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql
   grass/trunk/lib/temporal/SQL/update_stvds_metadata_template.sql
   grass/trunk/lib/temporal/SQL/vector_metadata_table.sql
   grass/trunk/temporal/Makefile
   grass/trunk/temporal/t.info/t.info.py
   grass/trunk/temporal/t.rast.export/test.t.rast.export.sh
   grass/trunk/temporal/t.rast.import/test.t.rast.import.sh
   grass/trunk/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh
   grass/trunk/temporal/t.rast.series/t.rast.series.py
   grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
   grass/trunk/temporal/t.register/test.t.register.raster.file.reltime.sh
   grass/trunk/temporal/t.register/test.t.register.raster.file.sh
   grass/trunk/temporal/t.register/test.t.register.raster.sh
   grass/trunk/temporal/t.register/test.t.register.raster3d.sh
   grass/trunk/temporal/t.sample/test.t.sample.sh
   grass/trunk/temporal/t.support/t.support.py
   grass/trunk/temporal/t.vect.list/t.vect.list.py
   grass/trunk/temporal/t.vect.list/test.t.vect.list.sh
   grass/trunk/temporal/t.vect.what.strds/test.t.vect.what.strds.layer.sh
Log:
* Added vector metadata support in temporal database -> API and database layout changes
* New module t.vect.extract to perform spatio-temporal and value based queries on vector maps
* Test update and bugfixing
* API use bugfixing


Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -1018,26 +1018,27 @@
 	    core.verbose(_("Unregister %s map <%s>") % (map.get_type(), map.get_map_id()))
 
         # Check if the map is registered in the space time raster dataset
-	if dbmi.paramstyle == "qmark":
-	    sql = "SELECT id FROM " + map_register_table + " WHERE id = ?"
-	else:
-	    sql = "SELECT id FROM " + map_register_table + " WHERE id = %s"
-        try:
-            dbif.cursor.execute(sql, (self.base.get_id(),))
-            row = dbif.cursor.fetchone()
-        except:
-            row = None
-
-        # Break if the map is not registered
-        if row == None:
-	    if map.get_layer():
-		core.warning(_("Map <%s> with layer %s is not registered in space time dataset <%s>") %(map.get_map_id(), map.get_layer(), self.base.get_id()))
+        if map_register_table != None:
+	    if dbmi.paramstyle == "qmark":
+		sql = "SELECT id FROM " + map_register_table + " WHERE id = ?"
 	    else:
-		core.warning(_("Map <%s> is not registered in space time dataset <%s>") %(map.get_map_id(), self.base.get_id()))
-            if connect == True:
-                dbif.close()
-            return ""
+		sql = "SELECT id FROM " + map_register_table + " WHERE id = %s"
+	    try:
+		dbif.cursor.execute(sql, (self.base.get_id(),))
+		row = dbif.cursor.fetchone()
+	    except:
+		row = None
 
+	    # Break if the map is not registered
+	    if row == None:
+		if map.get_layer():
+		    core.warning(_("Map <%s> with layer %s is not registered in space time dataset <%s>") %(map.get_map_id(), map.get_layer(), self.base.get_id()))
+		else:
+		    core.warning(_("Map <%s> is not registered in space time dataset <%s>") %(map.get_map_id(), self.base.get_id()))
+		if connect == True:
+		    dbif.close()
+		return ""
+
         # Remove the space time raster dataset from the raster dataset register
         if map_register_table != None:
             if dbmi.paramstyle == "qmark":

Modified: grass/trunk/lib/python/temporal/aggregation.py
===================================================================
--- grass/trunk/lib/python/temporal/aggregation.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/lib/python/temporal/aggregation.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -143,10 +143,8 @@
     # Set the time stamp and write it to the raster map
     if dataset.is_time_absolute():
         new_map.set_absolute_time(start, end, None)
-    	new_map.write_absolute_time_to_file()
     else:
         new_map.set_relative_time(start, end, orig_ds.get_relative_time_unit())
-    	new_map.write_relative_time_to_file()
 
     # Insert map in temporal database
     new_map.insert(dbif)

Modified: grass/trunk/lib/python/temporal/extract.py
===================================================================
--- grass/trunk/lib/python/temporal/extract.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/lib/python/temporal/extract.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -23,20 +23,22 @@
 
 ############################################################################
 
-def extract_dataset(input, output, type, where, expression, base, nprocs, register_null=False):
-    """!Extract a subset of a space time raster or raster3d dataset
+def extract_dataset(input, output, type, where, expression, base, nprocs=1, register_null=False, layer=1, vtype="point,line,boundary,centroid,area,face"):
+    """!Extract a subset of a space time raster, raster3d or vector dataset
     
        A mapcalc expression can be provided to process the temporal extracted maps.
        Mapcalc expressions are supported for raster and raster3d maps.
        
        @param input The name of the input space time raster/raster3d dataset 
        @param output The name of the extracted new space time raster/raster3d dataset
-       @param type The type of the dataset: "raster" or "raster3d"
-       @param where The SQL WHERE statement for subset extraction
-       @param expression The r(3).mapcalc expression
+       @param type The type of the dataset: "raster", "raster3d" or vector
+       @param where The temporal SQL WHERE statement for subset extraction
+       @param expression The r(3).mapcalc expression or the v.extract where statement
        @param base The base name of the new created maps in case a mapclac expression is provided 
        @param nprocs The number of parallel processes to be used for mapcalc processing
-       @param register_null Set this number True to register empty maps
+       @param register_null Set this number True to register empty maps (only raster and raster3d maps)
+       @param layer The vector layer number to be used when no timestamped layer is present, default is 1
+       @param vtype The feature type to be extracted for vector maps, default is point,line,boundary,centroid,area and face
     """
     
     mapset =  core.gisenv()["MAPSET"]
@@ -48,10 +50,13 @@
 
     if type == "raster":
 	sp = space_time_raster_dataset(id)
-    else:
+    elif type == "raster3d":
 	sp = space_time_raster3d_dataset(id)
+    elif type == "vector":
+	sp = space_time_vector_dataset(id)
 	
-    
+    dummy = sp.get_new_map_instance(None)
+	
     dbif = sql_database_interface_connection()
     dbif.connect()
     
@@ -77,8 +82,10 @@
         if core.overwrite() == False:
 	    dbif.close()
             core.fatal(_("Space time %s dataset <%s> is already in database, use overwrite flag to overwrite") % (type, out_id))
-            
-    rows = sp.get_registered_maps("id", where, "start_time", dbif)
+    if type == "vector":
+	rows = sp.get_registered_maps("id,layer", where, "start_time", dbif)
+    else:
+	rows = sp.get_registered_maps("id", where, "start_time", dbif)
 
     new_maps = {}
     if rows:
@@ -91,19 +98,25 @@
 	    count = 0
 	    proc_count = 0
 	    proc_list = []
+	    
 	    for row in rows:
 		count += 1
 		
 		core.percent(count, num_rows, 1)
 		
 		map_name = "%s_%i" % (base, count)
-
-		expr = "%s = %s" % (map_name, expression)
 		
-		expr = expr.replace(sp.base.get_map_id(), row["id"])
-		expr = expr.replace(sp.base.get_name(), row["id"])
+		# We need to modify the r(3).mapcalc expression
+		if type != "vector":
+		    expr = "%s = %s" % (map_name, expression)
 		    
-		map_id = map_name + "@" + mapset
+		    expr = expr.replace(sp.base.get_map_id(), row["id"])
+		    expr = expr.replace(sp.base.get_name(), row["id"])
+		    
+		    # We need to build the id
+		    map_id = dummy.build_id(map_name, mapset)
+		else:
+		    map_id = dummy.build_id(map_name, mapset, row["layer"])
 
 		new_map = sp.get_new_map_instance(map_id)
 
@@ -116,17 +129,27 @@
 		    else:
 			core.error(_("Map <%s> is already in temporal database, use overwrite flag to overwrite")%(new_map.get_map_id()))
 			continue
-
-		core.verbose(_("Apply mapcalc expression: \"%s\"") % expr)
 		
+		# Add process to the process list
 		if type == "raster":
+		    core.verbose(_("Apply r.mapcalc expression: \"%s\"") % expr)
 		    proc_list.append(Process(target=run_mapcalc2d, args=(expr,)))
-		else:
+		elif type == "raster3d":
+		    core.verbose(_("Apply r3.mapcalc expression: \"%s\"") % expr)
 		    proc_list.append(Process(target=run_mapcalc3d, args=(expr,)))
+		elif type == "vector":
+		    core.verbose(_("Apply v.extract where statement: \"%s\"") % expression)
+		    if row["layer"]:
+			proc_list.append(Process(target=run_vector_extraction, args=(row["id"], map_name, row["layer"], vtype, expression)))
+		    else:
+			proc_list.append(Process(target=run_vector_extraction, args=(row["id"], map_name, layer, vtype, expression)))
+		
 		proc_list[proc_count].start()
 		proc_count += 1
 		
-		if proc_count == nprocs:
+		# Join processes if the maximum number of processes are reached or the end of the
+		# loop is reached
+		if proc_count == nprocs or proc_count == num_rows:
 		    proc_count = 0
 		    exitcodes = 0
 		    for proc in proc_list:
@@ -135,9 +158,9 @@
 			
 		    if exitcodes != 0:
 			dbif.close()
-			core.fatal(_("Error while mapcalc computation"))
+			core.fatal(_("Error while computation"))
 			
-		    # Empty proc list
+		    # Empty process list
 		    proc_list = []
 		    
 		# Store the new maps
@@ -155,6 +178,9 @@
 	new_sp.set_initial_values(temporal_type, semantic_type, title, description)
 	new_sp.insert(dbif)
 	
+	# collect empty maps to remove them
+	empty_maps = []
+	
 	# Register the maps in the database
         count = 0
         for row in rows:
@@ -173,10 +199,17 @@
 		    # Read the raster map data
 		    new_map.load()
 		    
-		    # In case of a null map continue, do not register null maps
-		    if new_map.metadata.get_min() == None and new_map.metadata.get_max() == None:
-			if not register_null:
-			    continue
+		    # In case of a empty map continue, do not register empty maps
+		    if type == "raster" or type == "raster3d":
+			if new_map.metadata.get_min() == None and new_map.metadata.get_max() == None:
+			    if not register_null:
+				empty_maps.append(new_map)
+				continue
+		    elif type == "vector":
+			if new_map.metadata.get_primitives() == 0 or new_map.metadata.get_primitives() == None:
+			    if not register_null:
+				empty_maps.append(new_map)
+				continue
 
 		    # Set the time stamp
 		    if old_map.is_time_absolute():
@@ -197,6 +230,23 @@
         new_sp.update_from_registered_maps(dbif)
 	
 	core.percent(num_rows, num_rows, 1)
+	
+	# Remove empty maps
+	if len(empty_maps) > 0:
+	    names = ""
+	    count = 0
+	    for map in empty_maps:
+		if count == 0:
+		    names += "%s"%(map.get_name())
+		else:
+		    names += ",%s"%(map.get_name())
+		count += 1
+	    if type == "raster":
+		core.run_command("g.remove", rast=names, quiet=True)
+	    elif type == "raster3d":
+		core.run_command("g.remove", rast3d=names, quiet=True)
+	    elif type == "vector":
+		core.run_command("g.remove", vect=names, quiet=True)
         
     dbif.close()
 
@@ -209,4 +259,10 @@
 
 def run_mapcalc3d(expr):
     """Helper function to run r3.mapcalc in parallel"""
-    return core.run_command("r3.mapcalc", expression=expr, overwrite=core.overwrite(), quiet=True)
\ No newline at end of file
+    return core.run_command("r3.mapcalc", expression=expr, overwrite=core.overwrite(), quiet=True)
+    
+
+def run_vector_extraction(input, output, layer, type, where):
+    """Helper function to run r.mapcalc in parallel"""
+    return core.run_command("v.extract", input=input, output=output, layer=layer, type=type, where=where, overwrite=core.overwrite(), quiet=True)
+

Modified: grass/trunk/lib/python/temporal/mapcalc.py
===================================================================
--- grass/trunk/lib/python/temporal/mapcalc.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/lib/python/temporal/mapcalc.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -176,7 +176,6 @@
 	
 	# Attach the map names
 	map_matrix.append(copy.copy(map_name_list))
-    
    
     # Needed for map registration
     map_list = []
@@ -283,6 +282,9 @@
     
 	count = 0
 	
+	# collect empty maps to remove them
+	empty_maps = []
+	
 	# Insert maps in the temporal database and in the new space time dataset
 	for new_map in map_list:
 
@@ -295,6 +297,7 @@
 	    # In case of a null map continue, do not register null maps
 	    if new_map.metadata.get_min() == None and new_map.metadata.get_max() == None:
 		if not register_null:
+		    empty_maps.append(new_map)
 		    continue
 
 	    # Insert map in temporal database
@@ -304,8 +307,23 @@
 
         # Update the spatio-temporal extent and the metadata table entries
         new_sp.update_from_registered_maps(dbif)
-	
+		
 	core.percent(1, 1, 1)
+
+	# Remove empty maps
+	if len(empty_maps) > 0:
+	    names = ""
+	    count = 0
+	    for map in empty_maps:
+		if count == 0:
+		    names += "%s"%(map.get_name())
+		else:
+		    names += ",%s"%(map.get_name())
+		count += 1
+	    if type == "raster":
+		core.run_command("g.remove", rast=names, quiet=True)
+	    elif type == "raster3d":
+		core.run_command("g.remove", rast3d=names, quiet=True)
         
     dbif.close()
 

Modified: grass/trunk/lib/python/temporal/metadata.py
===================================================================
--- grass/trunk/lib/python/temporal/metadata.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/lib/python/temporal/metadata.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -276,12 +276,27 @@
 
 class vector_metadata(sql_database_interface):
     """!This is the vector metadata class"""
-    def __init__(self, ident=None, stvds_register=None):
+    def __init__(self, ident=None, stvds_register=None, is_3d=False, points=None, lines=None, boundaries=None,\
+                 centroids=None, faces=None, kernels=None, primitives=None, nodes=None, areas=None, \
+                 islands=None, holes=None, volumes=None):
 
 	sql_database_interface.__init__(self, "vector_metadata", ident)
 
 	self.set_id(ident)
 	self.set_stvds_register(stvds_register)
+	self.set_3d_info(is_3d)
+	self.set_points(points)
+	self.set_lines(lines)
+	self.set_boundaries(boundaries)
+	self.set_centroids(centroids)
+	self.set_faces(faces)
+	self.set_kernels(kernels)
+	self.set_primitives(primitives)
+	self.set_nodes(nodes)
+	self.set_areas(areas)
+	self.set_islands(islands)
+	self.set_holes(holes)
+	self.set_volumes(volumes)
 
     def set_id(self, ident):
 	"""!Convenient method to set the unique identifier (primary key)"""
@@ -292,6 +307,58 @@
 	"""!Set the space time vector dataset register table name"""
 	self.D["stvds_register"] = stvds_register
 
+    def set_3d_info(self, is_3d):
+	"""!Set True if the vector map is three dimensional"""
+	self.D["is_3d"] = is_3d
+
+    def set_points(self, points):
+	"""!Set the number of points of the vector map"""
+	self.D["points"] = points
+
+    def set_lines(self, lines):
+	"""!Set the number of lines of the vector map"""
+	self.D["lines"] = lines
+
+    def set_boundaries(self, boundaries):
+	"""!Set the number of boundaries of the vector map"""
+	self.D["boundaries"] = boundaries
+
+    def set_centroids(self, centroids):
+	"""!Set the number of centroids of the vector map"""
+	self.D["centroids"] = centroids
+
+    def set_faces(self, faces):
+	"""!Set the number of faces of the vector map"""
+	self.D["faces"] = faces
+
+    def set_kernels(self, kernels):
+	"""!Set the number of kernels of the vector map"""
+	self.D["kernels"] = kernels
+
+    def set_primitives(self, primitives):
+	"""!Set the number of primitives of the vector map"""
+	self.D["primitives"] = primitives
+
+    def set_nodes(self, nodes):
+	"""!Set the number of nodes of the vector map"""
+	self.D["nodes"] = nodes
+
+    def set_areas(self, areas):
+	"""!Set the number of areas of the vector map"""
+	self.D["areas"] = areas
+	
+    def set_islands(self, islands):
+	"""!Set the number of islands of the vector map"""
+	self.D["islands"] = islands
+	
+    def set_holes(self, holes):
+	"""!Set the number of holes of the vector map"""
+	self.D["holes"] = holes
+	
+    def set_volumes(self, volumes):
+	"""!Set the number of volumes of the vector map"""
+	self.D["volumes"] = volumes
+
     def get_id(self):
 	"""!Convenient method to get the unique identifier (primary key)
 	   @return None if not found
@@ -308,17 +375,145 @@
 	    return self.D["stvds_register"]
         else:
 	    return None
+    
+    def get_3d_info(self):
+	"""!Return True if the map is three dimensional, False if not and None if not info was found"""
+	if self.D.has_key("is_3d"):
+	    return self.D["is_3d"]
+        else:
+	    return None
 
+    def get_points(self):
+	"""!Get the number of points of the vector map
+	   @return None if not found"""
+	if self.D.has_key("points"):
+	    return self.D["points"]
+        else:
+	    return None
+	    
+    def get_lines(self):
+	"""!Get the number of lines of the vector map
+	   @return None if not found"""
+	if self.D.has_key("lines"):
+	    return self.D["lines"]
+        else:
+	    return None
+	    
+    def get_boundaries(self):
+	"""!Get the number of boundaries of the vector map
+	   @return None if not found"""
+	if self.D.has_key("boundaries"):
+	    return self.D["boundaries"]
+        else:
+	    return None
+	    
+    def get_centroids(self):
+	"""!Get the number of centroids of the vector map
+	   @return None if not found"""
+	if self.D.has_key("centroids"):
+	    return self.D["centroids"]
+        else:
+	    return None
+	    
+    def get_faces(self):
+	"""!Get the number of faces of the vector map
+	   @return None if not found"""
+	if self.D.has_key("faces"):
+	    return self.D["faces"]
+        else:
+	    return None
+	    
+    def get_kernels(self):
+	"""!Get the number of kernels of the vector map
+	   @return None if not found"""
+	if self.D.has_key("kernels"):
+	    return self.D["kernels"]
+        else:
+	    return None
+	    
+    def get_primitives(self):
+	"""!Get the number of primitives of the vector map
+	   @return None if not found"""
+	if self.D.has_key("primitives"):
+	    return self.D["primitives"]
+        else:
+	    return None
+	    
+    def get_nodes(self):
+	"""!Get the number of nodes of the vector map
+	   @return None if not found"""
+	if self.D.has_key("nodes"):
+	    return self.D["nodes"]
+        else:
+	    return None
+	    
+    def get_areas(self):
+	"""!Get the number of areas of the vector map
+	   @return None if not found"""
+	if self.D.has_key("areas"):
+	    return self.D["areas"]
+        else:
+	    return None
+	    
+    def get_islands(self):
+	"""!Get the number of islands of the vector map
+	   @return None if not found"""
+	if self.D.has_key("islands"):
+	    return self.D["islands"]
+        else:
+	    return None
+	    
+    def get_holes(self):
+	"""!Get the number of holes of the vector map
+	   @return None if not found"""
+	if self.D.has_key("holes"):
+	    return self.D["holes"]
+        else:
+	    return None
+	    
+    def get_volumes(self):
+	"""!Get the number of volumes of the vector map
+	   @return None if not found"""
+	if self.D.has_key("volumes"):
+	    return self.D["volumes"]
+        else:
+	    return None
 
     def print_info(self):
         """!Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         print " +-------------------- Metadata information ----------------------------------+"
         print " | STVDS register table ....... " + str(self.get_stvds_register())
+        print " | Is map 3d .................. " + str(self.get_3d_info())
+        print " | Number of points ........... " + str(self.get_points())
+        print " | Number of lines ............ " + str(self.get_lines())
+        print " | Number of boundaries ....... " + str(self.get_boundaries())
+        print " | Number of centroids ........ " + str(self.get_centroids())
+        print " | Number of faces ............ " + str(self.get_faces())
+        print " | Number of kernels .......... " + str(self.get_kernels())
+        print " | Number of primitives ....... " + str(self.get_primitives())
+        print " | Number of nodes ............ " + str(self.get_nodes())
+        print " | Number of areas ............ " + str(self.get_areas())
+        print " | Number of islands .......... " + str(self.get_islands())
+        print " | Number of holes ............ " + str(self.get_holes())
+        print " | Number of volumes .......... " + str(self.get_volumes())
 
     def print_shell_info(self):
         """!Print information about this class in shell style"""
         print "stvds_register=" + str(self.get_stvds_register())
+        print "is_3d=" + str(self.get_3d_info())
+        print "points=" + str(self.get_points())
+        print "lines=" + str(self.get_lines())
+        print "boundaries=" + str(self.get_boundaries())
+        print "centroids=" + str(self.get_centroids())
+        print "faces=" + str(self.get_faces())
+        print "kernels=" + str(self.get_kernels())
+        print "primitives=" + str(self.get_primitives())
+        print "nodes=" + str(self.get_nodes())
+        print "areas=" + str(self.get_areas())
+        print "islands=" + str(self.get_islands())
+        print "holes=" + str(self.get_holes())
+        print "volumes=" + str(self.get_volumes())
 
 ###############################################################################
 
@@ -614,16 +809,79 @@
 
 class stvds_metadata(stds_metadata_base):
     """!This is the raster metadata class"""
-    def __init__(self, ident=None, vector_register=None,  title=None, description=None):
+    def __init__(self, ident=None, vector_register=None,  title=None, description=None, \
+                 points=None, lines=None, boundaries=None,\
+                 centroids=None, faces=None, kernels=None, primitives=None, nodes=None, areas=None, \
+                 islands=None, holes=None, volumes=None):
 
 	stds_metadata_base.__init__(self, "stvds_metadata", ident, title, description)
 
 	self.set_vector_register(vector_register)
+	self.set_points(points)
+	self.set_lines(lines)
+	self.set_boundaries(boundaries)
+	self.set_centroids(centroids)
+	self.set_faces(faces)
+	self.set_kernels(kernels)
+	self.set_primitives(primitives)
+	self.set_nodes(nodes)
+	self.set_areas(areas)
+	self.set_islands(islands)
+	self.set_holes(holes)
+	self.set_volumes(volumes)
 
     def set_vector_register(self, vector_register):
 	"""!Set the vector map register table name"""
 	self.D["vector_register"] = vector_register
 
+    def set_points(self, points):
+	"""!Set the number of points of the vector map"""
+	self.D["points"] = points
+
+    def set_lines(self, lines):
+	"""!Set the number of lines of the vector map"""
+	self.D["lines"] = lines
+
+    def set_boundaries(self, boundaries):
+	"""!Set the number of boundaries of the vector map"""
+	self.D["boundaries"] = boundaries
+
+    def set_centroids(self, centroids):
+	"""!Set the number of centroids of the vector map"""
+	self.D["centroids"] = centroids
+
+    def set_faces(self, faces):
+	"""!Set the number of faces of the vector map"""
+	self.D["faces"] = faces
+
+    def set_kernels(self, kernels):
+	"""!Set the number of kernels of the vector map"""
+	self.D["kernels"] = kernels
+
+    def set_primitives(self, primitives):
+	"""!Set the number of primitives of the vector map"""
+	self.D["primitives"] = primitives
+
+    def set_nodes(self, nodes):
+	"""!Set the number of nodes of the vector map"""
+	self.D["nodes"] = nodes
+
+    def set_areas(self, areas):
+	"""!Set the number of areas of the vector map"""
+	self.D["areas"] = areas
+	
+    def set_islands(self, islands):
+	"""!Set the number of islands of the vector map"""
+	self.D["islands"] = islands
+	
+    def set_holes(self, holes):
+	"""!Set the number of holes of the vector map"""
+	self.D["holes"] = holes
+	
+    def set_volumes(self, volumes):
+	"""!Set the number of volumes of the vector map"""
+	self.D["volumes"] = volumes
+
     def get_vector_register(self):
 	"""!Get the vector map register table name
 	   @return None if not found"""
@@ -632,16 +890,136 @@
         else:
 	    return None
 
+    def get_points(self):
+	"""!Get the number of points of the vector map
+	   @return None if not found"""
+	if self.D.has_key("points"):
+	    return self.D["points"]
+        else:
+	    return None
+	    
+    def get_lines(self):
+	"""!Get the number of lines of the vector map
+	   @return None if not found"""
+	if self.D.has_key("lines"):
+	    return self.D["lines"]
+        else:
+	    return None
+	    
+    def get_boundaries(self):
+	"""!Get the number of boundaries of the vector map
+	   @return None if not found"""
+	if self.D.has_key("boundaries"):
+	    return self.D["boundaries"]
+        else:
+	    return None
+	    
+    def get_centroids(self):
+	"""!Get the number of centroids of the vector map
+	   @return None if not found"""
+	if self.D.has_key("centroids"):
+	    return self.D["centroids"]
+        else:
+	    return None
+	    
+    def get_faces(self):
+	"""!Get the number of faces of the vector map
+	   @return None if not found"""
+	if self.D.has_key("faces"):
+	    return self.D["faces"]
+        else:
+	    return None
+	    
+    def get_kernels(self):
+	"""!Get the number of kernels of the vector map
+	   @return None if not found"""
+	if self.D.has_key("kernels"):
+	    return self.D["kernels"]
+        else:
+	    return None
+	    
+    def get_primitives(self):
+	"""!Get the number of primitives of the vector map
+	   @return None if not found"""
+	if self.D.has_key("primitives"):
+	    return self.D["primitives"]
+        else:
+	    return None
+	    
+    def get_nodes(self):
+	"""!Get the number of nodes of the vector map
+	   @return None if not found"""
+	if self.D.has_key("nodes"):
+	    return self.D["nodes"]
+        else:
+	    return None
+	    
+    def get_areas(self):
+	"""!Get the number of areas of the vector map
+	   @return None if not found"""
+	if self.D.has_key("areas"):
+	    return self.D["areas"]
+        else:
+	    return None
+	    
+    def get_islands(self):
+	"""!Get the number of islands of the vector map
+	   @return None if not found"""
+	if self.D.has_key("islands"):
+	    return self.D["islands"]
+        else:
+	    return None
+	    
+    def get_holes(self):
+	"""!Get the number of holes of the vector map
+	   @return None if not found"""
+	if self.D.has_key("holes"):
+	    return self.D["holes"]
+        else:
+	    return None
+	    
+    def get_volumes(self):
+	"""!Get the number of volumes of the vector map
+	   @return None if not found"""
+	if self.D.has_key("volumes"):
+	    return self.D["volumes"]
+        else:
+	    return None
+
     def print_info(self):
         """!Print information about this class in human readable style"""
         print " +-------------------- Metadata information ----------------------------------+"
         #      0123456789012345678901234567890
         stds_metadata_base.print_info(self)
         print " | Vector register table:...... " + str(self.get_vector_register())
-
+        print " | Number of points ........... " + str(self.get_points())
+        print " | Number of lines ............ " + str(self.get_lines())
+        print " | Number of boundaries ....... " + str(self.get_boundaries())
+        print " | Number of centroids ........ " + str(self.get_centroids())
+        print " | Number of faces ............ " + str(self.get_faces())
+        print " | Number of kernels .......... " + str(self.get_kernels())
+        print " | Number of primitives ....... " + str(self.get_primitives())
+        print " | Number of nodes ............ " + str(self.get_nodes())
+        print " | Number of areas ............ " + str(self.get_areas())
+        print " | Number of islands .......... " + str(self.get_islands())
+        print " | Number of holes ............ " + str(self.get_holes())
+        print " | Number of volumes .......... " + str(self.get_volumes())
+        
     def print_shell_info(self):
         """!Print information about this class in shell style"""
         stds_metadata_base.print_shell_info(self)
         print "vector_register=" + str(self.get_vector_register())
+        print "points=" + str(self.get_points())
+        print "lines=" + str(self.get_lines())
+        print "boundaries=" + str(self.get_boundaries())
+        print "centroids=" + str(self.get_centroids())
+        print "faces=" + str(self.get_faces())
+        print "kernels=" + str(self.get_kernels())
+        print "primitives=" + str(self.get_primitives())
+        print "nodes=" + str(self.get_nodes())
+        print "areas=" + str(self.get_areas())
+        print "islands=" + str(self.get_islands())
+        print "holes=" + str(self.get_holes())
+        print "volumes=" + str(self.get_volumes())
 
 

Modified: grass/trunk/lib/python/temporal/space_time_datasets.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/lib/python/temporal/space_time_datasets.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -22,13 +22,11 @@
 @author Soeren Gebbert
 """
 import getpass
-import grass.script.raster as raster
-import grass.script.vector as vector
-import grass.script.raster3d as raster3d
-
 from ctypes import *
 import grass.lib.gis as libgis
 import grass.lib.raster as libraster
+import grass.lib.vector as libvector
+import grass.lib.raster3d as libraster3d
 
 from datetime_math import *
 from abstract_map_dataset import *
@@ -176,21 +174,33 @@
 	if libraster.Rast_map_is_fp(name, mapset):
 	    range = libraster.FPRange()
 	    libraster.Rast_init_fp_range (byref(range))
-	    libraster.Rast_read_fp_range(name, mapset, byref(range))
-	    min = libgis.DCELL()
-	    max = libgis.DCELL()
-	    libraster.Rast_get_fp_range_min_max(byref(range), byref(min), byref(max))
-	    kvp["min"] = float(min.value)
-	    kvp["max"] = float(max.value)
+	    ret = libraster.Rast_read_fp_range(name, mapset, byref(range))
+	    if ret < 0:
+		core.fatal(_("Unable to read range file"))
+	    if ret == 2:
+		kvp["min"] = None
+		kvp["max"] = None
+	    else:
+		min = libgis.DCELL()
+		max = libgis.DCELL()
+		libraster.Rast_get_fp_range_min_max(byref(range), byref(min), byref(max))
+		kvp["min"] = min.value
+		kvp["max"] = max.value
 	else:
 	    range = libraster.Range()
 	    libraster.Rast_init_range (byref(range))
-	    libraster.Rast_read_range(name, mapset, byref(range))
-	    min = libgis.CELL()
-	    max = libgis.CELL()
-	    libraster.Rast_get_fp_range_min_max(byref(range), byref(min), byref(max))
-	    kvp["min"] = int(min.value)
-	    kvp["max"] = int(max.value)
+	    ret = libraster.Rast_read_range(name, mapset, byref(range))
+	    if ret < 0:
+		core.fatal(_("Unable to read range file"))
+	    if ret == 2:
+		kvp["min"] = None
+		kvp["max"] = None
+	    else:
+		min = libgis.CELL()
+		max = libgis.CELL()
+		libraster.Rast_get_range_min_max(byref(range), byref(min), byref(max))
+		kvp["min"] = min.value
+		kvp["max"] = max.value
 	
 	return kvp
 
@@ -268,7 +278,7 @@
             return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """Return the two or three dimensional spatial relation"""
+        """!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)
@@ -334,26 +344,95 @@
 	
 	return True
         
+    def read_info(self):
+        """!Read the raster3d map info from the file system and store the content 
+           into a dictionary
+           
+           This method uses the ctypes interface to the gis and raster3d libraries
+           to read the map metadata information
+        """
+        
+        kvp = {}
+        
+        name = self.get_name()
+        mapset = self.get_mapset()
+        
+        if not self.map_exists():
+	  core.fatal(_("Raster3d map <%s> not found" % name))
+        
+        # Read the region information
+        region = libraster3d.RASTER3D_Region()
+	libraster3d.Rast3d_read_region_map(name, mapset, byref(region))
+	
+	kvp["north"] = region.north
+	kvp["south"] = region.south
+	kvp["east"] = region.east
+	kvp["west"] = region.west
+	kvp["nsres"] = region.ns_res
+	kvp["ewres"] = region.ew_res
+	kvp["tbres"] = region.tb_res
+	kvp["rows"] = region.cols
+	kvp["cols"] = region.rows
+	kvp["depths"] = region.depths
+	kvp["top"] = region.top
+	kvp["bottom"] = region.bottom
+	
+	# We need to open the map, this function returns a void pointer
+	# but we may need the correct type which is RASTER3D_Map, hence the casting
+	g3map = cast(libraster3d.Rast3d_open_cell_old(name, mapset, \
+	        libraster3d.RASTER3D_DEFAULT_WINDOW, libraster3d.RASTER3D_TILE_SAME_AS_FILE, \
+	        libraster3d.RASTER3D_NO_CACHE), POINTER(libraster3d.RASTER3D_Map))
+	        
+	if not g3map:
+	    core.fatal(_("Unable to open 3D raster map <%s>"%(name)));
+
+	maptype = libraster3d.Rast3d_file_type_map(g3map)
+  
+	if maptype == libraster.DCELL_TYPE:
+	    kvp["datatype"] = "DCELL"
+        elif maptype == libraster.FCELL_TYPE:
+	    kvp["datatype"] = "FCELL"
+	
+	# Read range
+	min = libgis.DCELL()
+	max = libgis.DCELL()
+	ret = libraster3d.Rast3d_range_load(g3map)
+	if not ret:
+	    core.fatal(_("Unable to load range of 3D raster map <%s>"%(name)));
+	libraster3d.Rast3d_range_min_max(g3map, byref(min), byref(max))
+	
+	if min.value != min.value:
+	    kvp["min"] = None
+	else:
+	    kvp["min"] = float(min.value)
+	if max.value != max.value:
+	    kvp["max"] = None
+	else:
+	    kvp["max"] = float(max.value)
+	
+	if not libraster3d.Rast3d_close(g3map):
+	    G_fatal_error(_("Unable to close 3D raster map <%s>"%(name)))
+	
+	return kvp
+        
     def load(self):
         """!Load all info from an existing raster3d map into the internal structure"""
 
-        # Get the data from an existing raster map
-        kvp = raster3d.raster3d_info(self.get_map_id())
-
         # Fill base information
-
         self.base.set_name(self.ident.split("@")[0])
         self.base.set_mapset(self.ident.split("@")[1])
         self.base.set_creator(str(getpass.getuser()))
 
         # Fill spatial extent
 
+        # Get the data from an existing raster map
+        kvp = self.read_info()
+        
         self.set_spatial_extent(north=kvp["north"], south=kvp["south"], \
                                 east=kvp["east"],   west=kvp["west"],\
                                 top=kvp["top"], bottom=kvp["bottom"])
 
         # Fill metadata
-
         self.metadata.set_nsres(kvp["nsres"])
         self.metadata.set_ewres(kvp["ewres"])
         self.metadata.set_tbres(kvp["tbres"])
@@ -361,10 +440,12 @@
         self.metadata.set_min(kvp["min"])
         self.metadata.set_max(kvp["max"])
 
-        rows = int((kvp["north"] - kvp["south"])/kvp["nsres"] + 0.5)
-        cols = int((kvp["east"] - kvp["west"])/kvp["ewres"] + 0.5)
-        depths = int((kvp["top"] - kvp["bottom"])/kvp["tbres"] + 0.5)
+        rows = kvp["rows"]
+        cols = kvp["cols"]
+        depths = kvp["depths"]
 
+        ncells = cols * rows
+
         ncells = cols * rows * depths
 
         self.metadata.set_cols(cols)
@@ -412,7 +493,7 @@
         return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """Return the two dimensional spatial relation"""
+        """!Return the two dimensional spatial relation"""
         
         return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
 	
@@ -475,11 +556,86 @@
 	
 	return True
         
+    def read_info(self):
+        """!Read the vector map info from the file system and store the content 
+           into a dictionary
+           
+           This method uses the ctypes interface to the vector libraries
+           to read the map metadata information
+        """
+        
+        kvp = {}
+        
+        name = self.get_name()
+        mapset = self.get_mapset()
+        
+        if not self.map_exists():
+	  core.fatal(_("Vector map <%s> not found" % name))
+	
+	# The vector map structure
+	Map = libvector.Map_info()
+	
+        # We open the maps always in topology mode first
+        libvector.Vect_set_open_level(2)
+        with_topo = True
+        
+        # Code lend from v.info main.c
+        if libvector.Vect_open_old_head2(byref(Map), name, mapset, "1") < 2:
+	    # force level 1, open fully
+	    # NOTE: number of points, lines, boundaries, centroids, faces, kernels is still available
+	    libvector.Vect_close(byref(Map))
+	    libvector.Vect_set_open_level(1) # no topology
+	    with_topo = False
+	    if libvector.Vect_open_old2(byref(Map), name, mapset, "1") < 1:
+		core.fatal(_("Unable to open vector map <%s>"%(libvector.Vect_get_full_name(byref(Map)))))
+
+        # Read the extent information
+        bbox = libvector.bound_box()
+        libvector.Vect_get_map_box(byref(Map), byref(bbox));
+	
+	kvp["north"] = bbox.N
+	kvp["south"] = bbox.S
+	kvp["east"] = bbox.E
+	kvp["west"] = bbox.W
+	kvp["top"] = bbox.T
+	kvp["bottom"] = bbox.B
+	
+	kvp["is_3d"] = bool(libvector.Vect_is_3d(byref(Map)))
+	
+	# Read number of features
+	kvp["points"] = libvector.Vect_get_num_primitives(byref(Map), libvector.GV_POINT)
+	kvp["lines"] = libvector.Vect_get_num_primitives(byref(Map), libvector.GV_LINE)
+	kvp["boundaries"] = libvector.Vect_get_num_primitives(byref(Map), libvector.GV_BOUNDARY)
+	kvp["centroids"] = libvector.Vect_get_num_primitives(byref(Map), libvector.GV_CENTROID)
+	kvp["faces"] = libvector.Vect_get_num_primitives(byref(Map), libvector.GV_FACE)
+	kvp["kernels"] = libvector.Vect_get_num_primitives(byref(Map), libvector.GV_KERNEL)
+	
+	# Summarize the primitives
+	kvp["primitives"] = kvp["points"] + kvp["lines"] + kvp["boundaries"] + kvp["centroids"]
+	if kvp["is_3d"]:
+	    kvp["primitives"] += kvp["faces"] + kvp["kernels"]
+	
+	# Read topology information
+	if with_topo:
+	    kvp["nodes"] = libvector.Vect_get_num_nodes(byref(Map))
+	    kvp["areas"] = libvector.Vect_get_num_areas(byref(Map))
+	    kvp["islands"] = libvector.Vect_get_num_islands(byref(Map))
+	    kvp["holes"] = libvector.Vect_get_num_holes(byref(Map))
+	    kvp["volumes"] = libvector.Vect_get_num_primitives(byref(Map), libvector.GV_VOLUME)
+	else:
+	    kvp["nodes"] = None
+	    kvp["areas"] = None
+	    kvp["islands"] = None
+	    kvp["holes"] = None
+	    kvp["volumes"] = None
+	
+	libvector.Vect_close(byref(Map))
+	
+	return kvp
+	
     def load(self):
         """!Load all info from an existing vector map into the internal structure"""
 
-        # Get the data from an existing raster map
-        kvp = vector.vector_info(self.get_map_id())
 
         # Fill base information
 	if self.ident.find(":") >= 0:
@@ -490,13 +646,28 @@
         self.base.set_mapset(self.ident.split("@")[1])
         self.base.set_creator(str(getpass.getuser()))
 
+        # Get the data from an existing raster map
+        kvp = self.read_info()
+        
         # Fill spatial extent
-
         self.set_spatial_extent(north=kvp["north"], south=kvp["south"], \
                                 east=kvp["east"],   west=kvp["west"],\
                                 top=kvp["top"], bottom=kvp["bottom"])
 
-        # Fill metadata .. no metadata yet
+	# Fill metadata
+	self.metadata.set_3d_info(kvp["is_3d"])
+        self.metadata.set_points(kvp["points"])
+        self.metadata.set_lines(kvp["lines"])
+        self.metadata.set_boundaries(kvp["boundaries"])
+        self.metadata.set_centroids(kvp["centroids"])
+        self.metadata.set_faces(kvp["faces"])
+        self.metadata.set_kernels(kvp["kernels"])
+        self.metadata.set_primitives(kvp["primitives"])
+        self.metadata.set_nodes(kvp["nodes"])
+        self.metadata.set_areas(kvp["areas"])
+        self.metadata.set_islands(kvp["islands"])
+        self.metadata.set_holes(kvp["holes"])
+        self.metadata.set_volumes(kvp["volumes"])
 
 ###############################################################################
 
@@ -531,7 +702,7 @@
         return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """Return the two dimensional spatial relation"""
+        """!Return the two dimensional spatial relation"""
         
         return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
 	
@@ -588,7 +759,7 @@
             return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """Return the two or three dimensional spatial relation"""
+        """!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)
@@ -645,7 +816,7 @@
         return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """Return the two dimensional spatial relation"""
+        """!Return the two dimensional spatial relation"""
         
         return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
 

Modified: grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql	2012-04-13 11:13:35 UTC (rev 51407)
@@ -13,6 +13,18 @@
   number_of_maps INTEGER,          -- The number of registered vector maps
   title VARCHAR,                              -- Title of the space-time vector dataset
   description VARCHAR,                        -- Detailed description of the space-time vector dataset
+  points INTEGER,         -- The number of points accumulated from all registered maps
+  lines INTEGER,          -- The number of lines accumulated from all registered maps
+  boundaries INTEGER,     -- The number of boundaries accumulated from all registered maps
+  centroids INTEGER,      -- The number of centroids accumulated from all registered maps
+  faces INTEGER,          -- The number of faces accumulated from all registered maps
+  kernels INTEGER,        -- The number of kernels accumulated from all registered maps
+  primitives INTEGER,     -- All primitives accumulated (points, lines,boundaries,centroids,faces,kernels)
+  nodes INTEGER,          -- Number of nodes accumulated from all registered maps (topological information) 
+  areas INTEGER,          -- The number of areas accumulated from all registered maps (topological information)
+  islands INTEGER,        -- The number of islands accumulated from all registered maps (topological information)
+  holes INTEGER,          -- The number of holes accumulated from all registered maps (topological information)
+  volumes INTEGER,        -- The number of volumes accumulated from all registered maps (topological information)
   PRIMARY KEY (id),  
   FOREIGN KEY (id) REFERENCES  stvds_base (id) ON DELETE CASCADE
 );
@@ -30,7 +42,10 @@
 	    A3.north, A3.south, A3.east, A3.west, A3.proj,
 	    A4.vector_register,
 	    A4.number_of_maps, 
-            A4.title, A4.description	
+            A4.title, A4.description, 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;
@@ -46,7 +61,10 @@
 	    A3.north, A3.south, A3.east, A3.west, A3.proj,
 	    A4.vector_register,
 	    A4.number_of_maps, 
-            A4.title, A4.description	
+            A4.title, A4.description, 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/update_stvds_metadata_template.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/update_stvds_metadata_template.sql	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/lib/temporal/SQL/update_stvds_metadata_template.sql	2012-04-13 11:13:35 UTC (rev 51407)
@@ -3,4 +3,57 @@
 -- concept is clear
 --
 -- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
\ No newline at end of file
+--#############################################################################
+
+-- SPACETIME_NAME is a placeholder for specific stds name (SQL compliant): name_mapset
+-- SPACETIME_ID is a placeholder for specific stds id: name at mapset
+
+-- Update the vector features and topology 
+UPDATE stvds_metadata SET points = 
+       (SELECT sum(points) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET lines = 
+       (SELECT sum(lines) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET boundaries = 
+       (SELECT sum(boundaries) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET centroids = 
+       (SELECT sum(centroids) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET faces = 
+       (SELECT sum(faces) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET kernels = 
+       (SELECT sum(kernels) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET primitives = 
+       (SELECT sum(primitives) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET nodes = 
+       (SELECT sum(nodes) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET areas = 
+       (SELECT sum(areas) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET islands = 
+       (SELECT sum(islands) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET holes = 
+       (SELECT sum(holes) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
+UPDATE stvds_metadata SET volumes = 
+       (SELECT sum(volumes) FROM vector_metadata WHERE vector_metadata.id IN 
+    		(SELECT id FROM SPACETIME_NAME_vector_register)
+       ) WHERE id = 'SPACETIME_ID';
\ No newline at end of file

Modified: grass/trunk/lib/temporal/SQL/vector_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/SQL/vector_metadata_table.sql	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/lib/temporal/SQL/vector_metadata_table.sql	2012-04-13 11:13:35 UTC (rev 51407)
@@ -12,6 +12,19 @@
 CREATE TABLE  vector_metadata (
   id VARCHAR NOT NULL,    -- The id (PFK) is the unique identifier for all tables, it is based on name and mapset (name at mapset) and is used as primary foreign key
   stvds_register VARCHAR, -- The name of the table storing all space-time vector datasets in which this map is registered
+  is_3d INTEGER,          -- This is 1 if the vector map is 3d and 0 otherwise 
+  points INTEGER,         -- The number of points
+  lines INTEGER,          -- The number of lines
+  boundaries INTEGER,     -- The number of boundaries
+  centroids INTEGER,      -- The number of centroids
+  faces INTEGER,          -- The number of faces
+  kernels INTEGER,        -- The number of kernels
+  primitives INTEGER,     -- All primitives accumulated (points, lines,boundaries,centroids,faces,kernels)
+  nodes INTEGER,          -- Number of nodes (topological information)
+  areas INTEGER,          -- The number of areas (topological information)
+  islands INTEGER,        -- The number of islands (topological information)
+  holes INTEGER,          -- The number of holes (topological information)
+  volumes INTEGER,        -- The number of volumes (topological information)
   PRIMARY KEY (id),
   FOREIGN KEY (id) REFERENCES  vector_base (id) ON DELETE CASCADE
 );
@@ -27,7 +40,10 @@
             A1.creator, 
 	    A2.start_time, A2.end_time, A2.timezone,
             A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.stvds_register
+	    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;
@@ -41,7 +57,10 @@
             A1.creator, 
 	    A2.start_time, A2.end_time,
             A3.north, A3.south, A3.east, A3.west, A3.proj,
-	    A4.stvds_register
+	    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/Makefile
===================================================================
--- grass/trunk/temporal/Makefile	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/Makefile	2012-04-13 11:13:35 UTC (rev 51407)
@@ -25,6 +25,7 @@
 	t.rast3d.extract \
 	t.rast3d.mapcalc \
 	t.vect.list \
+	t.vect.extract \
 	t.vect.what.strds \
 	t.vect.observe.strds
 

Added: grass/trunk/temporal/run_all_tests.sh
===================================================================
--- grass/trunk/temporal/run_all_tests.sh	                        (rev 0)
+++ grass/trunk/temporal/run_all_tests.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+# This scripts runs all tests available in the temporal module directory
+# Logs a written to "run.log" 
+
+LOG_FILE="/tmp/run.log"
+echo "Logfile\n\n" > $LOG_FILE
+
+# For each directory
+for dir in `ls -d t*` ; do
+    if [ -d $dir ] ; then
+        echo $dir
+        cd $dir
+        for file in `ls test.* | grep -v '~'` ; do
+            bash $file >> $LOG_FILE 2>&1
+        done
+        cd -
+    fi
+done
+cp $LOG_FILE .


Property changes on: grass/trunk/temporal/run_all_tests.sh
___________________________________________________________________
Added: svn:executable
   + *

Modified: grass/trunk/temporal/t.info/t.info.py
===================================================================
--- grass/trunk/temporal/t.info/t.info.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.info/t.info.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -81,17 +81,17 @@
         mapset =  grass.gisenv()["MAPSET"]
         id = name + "@" + mapset
 
-    sp = tgis.dataset_factory(type, id)
+    ds = tgis.dataset_factory(type, id)
 
-    if sp.is_in_db() == False:
-        grass.fatal(_("Space time %s dataset <%s> not found") % (sp.get_new_map_instance(None).get_type(), id))
+    if ds.is_in_db() == False:
+        grass.fatal(_("Dataset <%s> not found") % (id))
         
-    sp.select()
+    ds.select()
 
     if shellstyle == True:
-        sp.print_shell_info()
+        ds.print_shell_info()
     else:
-        sp.print_info()
+        ds.print_info()
 
 if __name__ == "__main__":
     options, flags = grass.parser()

Modified: grass/trunk/temporal/t.rast.export/test.t.rast.export.sh
===================================================================
--- grass/trunk/temporal/t.rast.export/test.t.rast.export.sh	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.rast.export/test.t.rast.export.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -32,3 +32,4 @@
 
 t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
 t.remove type=strds input=precip_abs1
+rm strds_export.tar.bz2

Modified: grass/trunk/temporal/t.rast.import/test.t.rast.import.sh
===================================================================
--- grass/trunk/temporal/t.rast.import/test.t.rast.import.sh	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.rast.import/test.t.rast.import.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -44,3 +44,5 @@
 t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
 t.remove type=strds input=precip_abs1
 g.remove rast=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
+rm -rf test
+rm strds_export.tar.bz2
\ No newline at end of file

Modified: grass/trunk/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh
===================================================================
--- grass/trunk/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.rast.mapcalc/test.t.rast.mapcalc.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -24,14 +24,25 @@
 # The first @test
 t.rast.mapcalc --o --v -n inputs=precip_abs1,precip_abs2 output=precip_abs3 \
            expression=" precip_abs1 + precip_abs2" base=new_prec \
-           method=equal nprocs=6
+           method=equal nprocs=5
 t.info type=strds input=precip_abs3
 
 t.rast.mapcalc --o --v -s inputs=precip_abs1,precip_abs2,precip_abs3 output=precip_abs4 \
            expression=" (precip_abs1 + precip_abs2) / precip_abs3 at PERMANENT " base=new_prec \
-           method=equal nprocs=6
+           method=equal nprocs=5
 t.info type=strds input=precip_abs4
 
+t.rast.mapcalc --o --v -s inputs=precip_abs1,precip_abs2 output=precip_abs4 \
+           expression=" (precip_abs1 + precip_abs2) * null() " base=new_prec \
+           method=equal nprocs=5
+t.info type=strds input=precip_abs4
+
+t.rast.mapcalc --o --v -sn inputs=precip_abs1,precip_abs2 output=precip_abs4 \
+           expression=" (precip_abs1 + precip_abs2) * null() " base=new_prec \
+           method=equal nprocs=5
+t.info type=strds input=precip_abs4
+
+# @postprocess
 t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
 t.unregister type=rast maps=new_prec_1,new_prec_2,new_prec_3,new_prec_4,new_prec_5,new_prec_6
 t.remove type=strds input=precip_abs1,precip_abs2,precip_abs3,precip_abs4

Modified: grass/trunk/temporal/t.rast.series/t.rast.series.py
===================================================================
--- grass/trunk/temporal/t.rast.series/t.rast.series.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.rast.series/t.rast.series.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -118,10 +118,8 @@
 
             if sp.is_time_absolute():
                 map.set_absolute_time(start_time, end_time, tz)
-                map.write_absolute_time_to_file()
             else:
                 map.set_relative_time(start_time, end_time)
-                map.write_relative_time_to_file()
 
             # Register the map in the temporal database
             if map.is_in_db():

Modified: grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
===================================================================
--- grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -128,10 +128,8 @@
 
     if sp.is_time_absolute():
         r3ds.set_absolute_time(start, end)
-        r3ds.write_absolute_time_to_file()
     else:
         r3ds.set_relative_time(start, end, sp.get_relative_time_unit())
-        r3ds.write_relative_time_to_file()
 
     r3ds.insert()
 

Modified: grass/trunk/temporal/t.register/test.t.register.raster.file.reltime.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.raster.file.reltime.sh	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.register/test.t.register.raster.file.reltime.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -66,33 +66,33 @@
 # File 1
 t.register -i input=precip_abs8 file="${n1}" start=0 increment=7 unit=days
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 # File 1
 t.unregister --v type=rast file="${n1}"
 t.register input=precip_abs8 file="${n1}" start=20 unit=years
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 # File 2
 t.unregister --v type=rast file="${n1}"
 t.register input=precip_abs8 file="${n2}" unit=minutes
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 # File 2 ERROR ERROR -- Increment computation needs to be fixed
 t.unregister --v type=rast file="${n1}"
 t.register input=precip_abs8 file="${n2}" increment=14 unit=days
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 # File 2 ERROR ERROR -- Increment computation needs to be fixed
 t.unregister --v type=rast file="${n1}"
 t.register -i input=precip_abs8 file="${n2}" increment=14 unit=days
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 
 # File 3
 t.unregister --v type=rast file="${n1}"
 t.register -i input=precip_abs8 file="${n3}" unit=seconds
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 
 t.unregister --v type=rast file="${n1}"
 

Modified: grass/trunk/temporal/t.register/test.t.register.raster.file.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.raster.file.sh	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.register/test.t.register.raster.file.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -59,23 +59,23 @@
 # File 1
 t.register -i input=precip_abs8 file="${n1}" start="2001-01-01" increment="1 months"
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 # File 1
 t.register input=precip_abs8 file="${n1}" start="2001-01-01" 
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 # File 2
 t.register input=precip_abs8 file="${n2}"
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 # File 2
 t.register input=precip_abs8 file="${n2}" increment="1 months"
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 # File 3
 t.register -i input=precip_abs8 file="${n3}"
 t.info type=strds input=precip_abs8
-tr.list input=precip_abs8
+t.rast.list input=precip_abs8
 
 t.remove --v type=strds input=precip_abs8
 t.unregister --v type=rast file="${n1}"

Modified: grass/trunk/temporal/t.register/test.t.register.raster.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.raster.sh	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.register/test.t.register.raster.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -32,62 +32,62 @@
 t.info type=strds input=precip_abs1
 t.info -g type=strds input=precip_abs1
 r.info map=prec_1
-tr.list input=precip_abs1
+t.rast.list input=precip_abs1
 t.topology input=precip_abs1
 
 t.register -i input=precip_abs2 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="20 seconds, 5 minutes"
 t.info type=strds input=precip_abs2
 t.info -g type=strds input=precip_abs2
 r.info map=prec_1
-tr.list input=precip_abs2
+t.rast.list input=precip_abs2
 t.topology input=precip_abs2
 
 t.register -i input=precip_abs3 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="8 hours"
 t.info -g type=strds input=precip_abs3
 r.info map=prec_1
-tr.list input=precip_abs3
+t.rast.list input=precip_abs3
 t.topology input=precip_abs3
 
 t.register input=precip_abs4 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="3 days"
 t.info -g type=strds input=precip_abs4
 r.info map=prec_1
-tr.list input=precip_abs4
+t.rast.list input=precip_abs4
 t.topology input=precip_abs4
 
 t.register input=precip_abs5 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="4 weeks"
 t.info -g type=strds input=precip_abs5
 r.info map=prec_1
-tr.list input=precip_abs5
+t.rast.list input=precip_abs5
 t.topology input=precip_abs5
 
 t.register input=precip_abs6 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-08-01" increment="2 months"
 t.info -g type=strds input=precip_abs6
 r.info map=prec_1
-tr.list input=precip_abs6
+t.rast.list input=precip_abs6
 t.topology input=precip_abs6
 
 t.register input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="20 years, 3 months, 1 days, 4 hours"
 t.info -g type=strds input=precip_abs7
 r.info map=prec_1
-tr.list input=precip_abs7
+t.rast.list input=precip_abs7
 t.topology input=precip_abs7
 # Register with different valid time again
 t.register input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
 t.info -g type=strds input=precip_abs7
 r.info map=prec_1
-tr.list input=precip_abs7
+t.rast.list input=precip_abs7
 t.topology input=precip_abs7
 # Register with different valid time again creating an interval
 t.register -i input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
 t.info -g type=strds input=precip_abs7
 r.info map=prec_1
-tr.list input=precip_abs7
+t.rast.list input=precip_abs7
 t.topology input=precip_abs7
 
 t.register input=precip_abs7 maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6 start="2001-01-01" end="2002-01-01"
 t.info -g type=strds input=precip_abs7
 r.info map=prec_1
-tr.list input=precip_abs7
+t.rast.list input=precip_abs7
 t.topology input=precip_abs7
 
 t.unregister type=rast maps=prec_1,prec_2,prec_3

Modified: grass/trunk/temporal/t.register/test.t.register.raster3d.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.raster3d.sh	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.register/test.t.register.raster3d.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -30,7 +30,7 @@
 
 t.register type=rast3d --v -i input=volume_abs1 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="1 seconds"
 t.info type=str3ds input=volume_abs1
-tr3.unregister --v input=volume_abs1 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6
+t.unregister --v type=rast3d input=volume_abs1 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6
 t.info type=str3ds input=volume_abs1
 
 t.register type=rast3d --v -i input=volume_abs2 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="20 seconds, 5 minutes"

Modified: grass/trunk/temporal/t.sample/test.t.sample.sh
===================================================================
--- grass/trunk/temporal/t.sample/test.t.sample.sh	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.sample/test.t.sample.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -56,11 +56,11 @@
 t.create --o type=stvds temporaltype=absolute output=pnts_abs1 title="A test with vector input files" descr="A test with vector input files"
 
 t.register type=rast -i input=precip_abs0 file="${n1}" start="2001-01-01" increment="1 months"
-tr.list precip_abs0 -h
+t.rast.list precip_abs0 -h
 t.register type=vect    input=pnts_abs0 file="${n2}" start=file end=file
-tv.list pnts_abs0 -h
+t.vect.list pnts_abs0 -h
 t.register type=vect    input=pnts_abs1 file="${n3}" start=file end=file
-tv.list pnts_abs1 -h
+t.vect.list pnts_abs1 -h
 
 # The @test
 t.sample method=equal   input=precip_abs0,precip_abs0,precip_abs0,precip_abs0 samtype=stvds sample=pnts_abs0 -cs
@@ -72,10 +72,13 @@
 
 # Test with temporal point data
 t.register type=rast    input=precip_abs0 file="${n1}" start="2001-01-01" increment="1 months"
-tr.list precip_abs0 -h
+t.rast.list precip_abs0 -h
 t.sample input=precip_abs0 samtype=stvds sample=pnts_abs0 -cs
 t.sample input=precip_abs0 samtype=stvds sample=pnts_abs1 -cs
 
 t.unregister type=rast maps=prec_1,prec_2,prec_3,prec_4,prec_5,prec_6
+t.unregister type=vect maps=pnts1,pnts2,pnts3,pnts4,pnts5,pnts6,pnts7,pnts8
 t.remove type=strds input=precip_abs0
 t.remove type=stvds input=pnts_abs0,pnts_abs1
+g.remove rast=prec_1,prec_2,prec_3,,prec_4,prec_5,prec_6
+g.remove vect=pnts1,pnts2,pnts3,pnts4,pnts5,pnts6,pnts7,pnts8

Modified: grass/trunk/temporal/t.support/t.support.py
===================================================================
--- grass/trunk/temporal/t.support/t.support.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.support/t.support.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -119,7 +119,7 @@
 	    count += 1
 
         # Execute the collected SQL statenents
-        tgis.execute_transaction(statement, dbif)
+        dbif.execute_transaction(statement)
 
     if map_update or update:
         sp.update_from_registered_maps(dbif=dbif)

Added: grass/trunk/temporal/t.vect.extract/Makefile
===================================================================
--- grass/trunk/temporal/t.vect.extract/Makefile	                        (rev 0)
+++ grass/trunk/temporal/t.vect.extract/Makefile	2012-04-13 11:13:35 UTC (rev 51407)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../
+
+PGM = t.vect.extract
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script $(TEST_DST)

Added: grass/trunk/temporal/t.vect.extract/t.vect.extract.html
===================================================================
Added: grass/trunk/temporal/t.vect.extract/t.vect.extract.py
===================================================================
--- grass/trunk/temporal/t.vect.extract/t.vect.extract.py	                        (rev 0)
+++ grass/trunk/temporal/t.vect.extract/t.vect.extract.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE:	t.vect.extract
+# AUTHOR(S):	Soeren Gebbert
+#
+# PURPOSE:	Extract a subset of a space time vector dataset
+# COPYRIGHT:	(C) 2011 by the GRASS Development Team
+#
+#		This program is free software under the GNU General Public
+#		License (version 2). Read the file COPYING that comes with GRASS
+#		for details.
+#
+#############################################################################
+
+#%module
+#% description: Extract a subset of a space time raster dataset
+#% keywords: temporal
+#% keywords: extract
+#%end
+
+#%option G_OPT_STVDS_INPUT
+#%end
+
+#%option G_OPT_T_WHERE
+#%end
+
+#%option G_OPT_DB_WHERE
+#% key: expression
+#%end
+
+#%option G_OPT_STVDS_OUTPUT
+#%end
+
+#%option G_OPT_V_FIELD
+#%end
+
+#%option G_OPT_V_TYPE
+#%end
+
+#%option
+#% key: base
+#% type: string
+#% description: Base name of the new created vector maps
+#% required: no
+#% multiple: no
+#%end
+
+#%option
+#% key: nprocs
+#% type: integer
+#% description: The number of v.extract processes to run in parallel. Use only if you have a database backend which supports concurrent writing.
+#% required: no
+#% multiple: no
+#% answer: 1
+#%end
+
+#%flag
+#% key: n
+#% description: Register empty maps
+#%end
+
+import grass.script as grass
+import grass.temporal as tgis
+from multiprocessing import Process
+
+############################################################################
+
+def main():
+
+    # Get the options
+    input = options["input"]
+    output = options["output"]
+    where = options["where"]
+    expression = options["expression"]
+    layer = options["layer"]
+    type = options["type"]
+    base = options["base"]
+    nprocs = int(options["nprocs"])
+    register_null = flags["n"]
+
+    # Make sure the temporal database exists
+    tgis.create_temporal_database()
+    
+    tgis.extract_dataset(input, output, "vector", where, expression, base, nprocs, register_null, layer, type)
+    
+###############################################################################
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()
+


Property changes on: grass/trunk/temporal/t.vect.extract/t.vect.extract.py
___________________________________________________________________
Added: svn:executable
   + *

Added: grass/trunk/temporal/t.vect.extract/test.t.vect.extract.sh
===================================================================
--- grass/trunk/temporal/t.vect.extract/test.t.vect.extract.sh	                        (rev 0)
+++ grass/trunk/temporal/t.vect.extract/test.t.vect.extract.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -0,0 +1,47 @@
+# Test the extraction of a subset of a space time raster input
+
+# We need to set a specific region in the
+# @preprocess step of this test. We generate
+
+v.random --o -z output=soil_1 n=100 zmin=0 zmax=100 column=height  seed=1
+v.random --o -z output=soil_2 n=100 zmin=0 zmax=100 column=height seed=2
+v.random --o -z output=soil_3 n=100 zmin=0 zmax=100 column=height seed=3
+v.random --o -z output=soil_4 n=100 zmin=0 zmax=100 column=height seed=4
+v.random --o -z output=soil_5 n=100 zmin=0 zmax=100 column=height seed=5
+v.random --o -z output=soil_6 n=100 zmin=0 zmax=100 column=height seed=6
+v.random --o -z output=soil_7 n=100 zmin=0 zmax=100 column=height seed=7
+v.random --o -z output=soil_8 n=100 zmin=0 zmax=100 column=height seed=8
+
+n1=`g.tempfile pid=1 -d` 
+
+cat > "${n1}" << EOF
+soil_1
+soil_2
+soil_3
+soil_4
+soil_5
+soil_6
+soil_7
+soil_8
+EOF
+
+t.create --o type=stvds temporaltype=absolute output=soil_abs1 title="A test" descr="A test"
+t.register -i type=vect input=soil_abs1 file="${n1}" start='2001-01-01' increment="1 months"
+t.info type=stvds input=soil_abs1
+t.vect.list input=soil_abs1
+
+# The @test
+t.vect.extract --v input=soil_abs1 output=soil_abs2 where="start_time > '2001-03-01 00:00:01'"
+t.info type=stvds input=soil_abs2
+t.vect.list input=soil_abs2
+
+t.vect.extract --v --o input=soil_abs1 output=soil_abs3 where="start_time >= '2001-01-01'" \
+               base=new_vect expr=" height > 50" nprocs=1
+t.info type=stvds input=soil_abs3
+t.vect.list input=soil_abs3 columns=name,start_time,end_time,primitives
+
+# @postprocess
+t.unregister type=vect maps=soil_1,soil_2,soil_3,soil_4,soil_5,soil_6,soil_7,soil_8
+t.remove type=stvds input=soil_abs1,soil_abs2,soil_abs3
+g.remove vect=soil_1,soil_2,soil_3,soil_4,soil_5,soil_6,soil_7,soil_8
+g.remove vect=new_vect_1,new_vect_2,new_vect_3,new_vect_4,new_vect_5,new_vect_6


Property changes on: grass/trunk/temporal/t.vect.extract/test.t.vect.extract.sh
___________________________________________________________________
Added: svn:executable
   + *

Modified: grass/trunk/temporal/t.vect.list/t.vect.list.py
===================================================================
--- grass/trunk/temporal/t.vect.list/t.vect.list.py	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.vect.list/t.vect.list.py	2012-04-13 11:13:35 UTC (rev 51407)
@@ -29,7 +29,7 @@
 #% description: Order the space time dataset by category. 
 #% required: no
 #% multiple: yes
-#% options: id,name,layer,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east
+#% options: id,name,layer,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,points,lines,boundaries,centroids,faces,kernels,primitives,nodes,areas,islands,holes,volumes
 #% answer: start_time
 #%end
 
@@ -39,7 +39,7 @@
 #% description: Select columns to be printed to stdout 
 #% required: no
 #% multiple: yes
-#% options: id,name,layer,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east
+#% options: id,name,layer,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,points,lines,boundaries,centroids,faces,kernels,primitives,nodes,areas,islands,holes,volumes
 #% answer: id,name,layer,mapset,start_time,end_time
 #%end
 

Modified: grass/trunk/temporal/t.vect.list/test.t.vect.list.sh
===================================================================
--- grass/trunk/temporal/t.vect.list/test.t.vect.list.sh	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.vect.list/test.t.vect.list.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -103,3 +103,4 @@
 
 t.unregister type=vect maps=lidar_1,lidar_2,lidar_3,lidar_4,lidar_5,lidar_6
 t.remove type=stvds input=lidar_abs1,lidar_abs2,lidar_abs3,lidar_abs4,lidar_abs5
+g.remove vect=lidar_1,lidar_2,lidar_3,lidar_4,lidar_5,lidar_6
\ No newline at end of file

Modified: grass/trunk/temporal/t.vect.what.strds/test.t.vect.what.strds.layer.sh
===================================================================
--- grass/trunk/temporal/t.vect.what.strds/test.t.vect.what.strds.layer.sh	2012-04-13 10:49:02 UTC (rev 51406)
+++ grass/trunk/temporal/t.vect.what.strds/test.t.vect.what.strds.layer.sh	2012-04-13 11:13:35 UTC (rev 51407)
@@ -45,12 +45,12 @@
 
 t.create --o type=strds temporaltype=absolute output=sand_frac_abs_1 title="A test" descr="A test"
 t.register -i type=rast input=sand_frac_abs_1 maps=sand_frac start="2001-01-01 00:00:00" increment="12 months"
-tr.list input=sand_frac_abs_1 columns=name,start_time,end_time
+t.rast.list input=sand_frac_abs_1 columns=name,start_time,end_time
 
 t.create --o type=strds temporaltype=absolute output=sand_frac_abs_2 title="A test" descr="A test"
 t.register -i type=rast input=sand_frac_abs_2 maps=sand_frac_1,sand_frac_2,sand_frac_3,sand_frac_4,sand_frac_5,sand_frac_6 \
             start="2001-03-01 00:00:00" increment="1 months"
-tr.list input=sand_frac_abs_2 columns=name,start_time,end_time
+t.rast.list input=sand_frac_abs_2 columns=name,start_time,end_time
 
 # Start the @test
 t.vect.what.strds --v input=soil_abs strds=sand_frac_abs_1 sampling=overlap,during,contain column=sand_frac



More information about the grass-commit mailing list