[GRASS-SVN] r48795 - in grass/trunk/temporal: t.create t.info
t.list t.remove t.support t.topology tr.register tr3.register
tr3.unregister tv.register tv.unregister
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Oct 14 11:22:13 EDT 2011
Author: huhabla
Date: 2011-10-14 08:22:13 -0700 (Fri, 14 Oct 2011)
New Revision: 48795
Modified:
grass/trunk/temporal/t.create/t.create.py
grass/trunk/temporal/t.info/t.info.py
grass/trunk/temporal/t.list/t.list.py
grass/trunk/temporal/t.remove/t.remove.py
grass/trunk/temporal/t.support/t.support.py
grass/trunk/temporal/t.topology/t.topology.py
grass/trunk/temporal/tr.register/tr.register.py
grass/trunk/temporal/tr3.register/tr3.register.py
grass/trunk/temporal/tr3.unregister/tr3.unregister.py
grass/trunk/temporal/tv.register/tv.register.py
grass/trunk/temporal/tv.unregister/tv.unregister.py
Log:
Use dataset object factory. New temporal topology functions.
Modified: grass/trunk/temporal/t.create/t.create.py
===================================================================
--- grass/trunk/temporal/t.create/t.create.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/t.create/t.create.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -105,12 +105,7 @@
mapset = grass.gisenv()["MAPSET"]
id = name + "@" + mapset
- if type == "strds":
- sp = tgis.space_time_raster_dataset(id)
- if type == "str3ds":
- sp = tgis.space_time_raster3d_dataset(id)
- if type == "stvds":
- sp = tgis.space_time_vector_dataset(id)
+ sp = tgis.dataset_factory(type, id)
dbif = tgis.sql_database_interface()
dbif.connect()
Modified: grass/trunk/temporal/t.info/t.info.py
===================================================================
--- grass/trunk/temporal/t.info/t.info.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/t.info/t.info.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -55,7 +55,6 @@
def main():
- # Get the options
name = options["input"]
type = options["type"]
shellstyle = flags['g']
@@ -64,8 +63,6 @@
# Make sure the temporal database exists
tgis.create_temporal_database()
- #Get the current mapset to create the id of the space time dataset
-
if system:
# 0123456789012345678901234567890
print " +------------------- Temporal DBMI backend information ----------------------+"
@@ -84,26 +81,11 @@
mapset = grass.gisenv()["MAPSET"]
id = name + "@" + mapset
- if type == "strds":
- sp = tgis.space_time_raster_dataset(id)
- if type == "str3ds":
- sp = tgis.space_time_raster3d_dataset(id)
- if type == "stvds":
- sp = tgis.space_time_vector_dataset(id)
- if type == "rast":
- sp = tgis.raster_dataset(id)
- tmatrix = False
- if type == "rast3d":
- sp = tgis.raster3d_dataset(id)
- tmatrix = False
- if type == "vect":
- sp = tgis.vector_dataset(id)
- tmatrix = False
+ sp = tgis.dataset_factory(type, id)
if sp.is_in_db() == False:
- grass.fatal("Dataset <" + name + "> not found in temporal database")
+ grass.fatal(_("Dataset <%s> not found in temporal database") % name)
- # Insert content from db
sp.select()
if shellstyle == True:
Modified: grass/trunk/temporal/t.list/t.list.py
===================================================================
--- grass/trunk/temporal/t.list/t.list.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/t.list/t.list.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -26,7 +26,7 @@
#% type: string
#% description: Type of the space time dataset, default is strds
#% required: no
-#% options: strds, str3ds, stvds, raster, raster3d, vector
+#% options: strds, str3ds, stvds, rast, rast3d, vect
#% answer: strds
#%end
@@ -99,20 +99,8 @@
tgis.create_temporal_database()
id = None
+ sp = tgis.dataset_factory(type, id)
- if type == "strds":
- sp = tgis.space_time_raster_dataset(id)
- if type == "str3ds":
- sp = tgis.space_time_raster3d_dataset(id)
- if type == "stvds":
- sp = tgis.space_time_vector_dataset(id)
- if type == "rast":
- sp = tgis.raster_dataset(id)
- if type == "rast3d":
- sp = tgis.raster3d_dataset(id)
- if type == "vect":
- sp = tgis.vector_dataset(id)
-
dbif = tgis.sql_database_interface()
dbif.connect()
Modified: grass/trunk/temporal/t.remove/t.remove.py
===================================================================
--- grass/trunk/temporal/t.remove/t.remove.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/t.remove/t.remove.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -100,25 +100,13 @@
else:
id = name
- if type == "strds":
- ds = tgis.space_time_raster_dataset(id)
- if type == "str3ds":
- ds = tgis.space_time_raster3d_dataset(id)
- if type == "stvds":
- ds = tgis.space_time_vector_dataset(id)
- if type == "rast":
- ds = tgis.raster_dataset(id)
- if type == "rast3d":
- ds = tgis.raster3d_dataset(id)
- if type == "vect":
- ds = tgis.vector_dataset(id)
+ sp = tgis.dataset_factory(type, id)
- if ds.is_in_db(dbif) == False:
+ if sp.is_in_db(dbif) == False:
dbif.close()
- grass.fatal(_("%s dataset <%s> not found in temporal database") % (ds.get_type(), name))
+ grass.fatal(_("%s dataset <%s> not found in temporal database") % (sp.get_type(), name))
- # We need to read some data from the temporal database
- ds.delete(dbif)
+ sp.delete(dbif)
dbif.close()
Modified: grass/trunk/temporal/t.support/t.support.py
===================================================================
--- grass/trunk/temporal/t.support/t.support.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/t.support/t.support.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -100,12 +100,7 @@
mapset = grass.gisenv()["MAPSET"]
id = name + "@" + mapset
- if type == "strds":
- sp = tgis.space_time_raster_dataset(id)
- if type == "str3ds":
- sp = tgis.space_time_raster3d_dataset(id)
- if type == "stvds":
- sp = tgis.space_time_vector_dataset(id)
+ sp = tgis.dataset_factory(type, id)
if sp.is_in_db() == False:
grass.fatal(_("%s dataset <%s> not found in temporal database") % (ds.get_type(), name))
Modified: grass/trunk/temporal/t.topology/t.topology.py
===================================================================
--- grass/trunk/temporal/t.topology/t.topology.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/t.topology/t.topology.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -38,6 +38,12 @@
#%end
#%flag
+#% key: c
+#% description: Check temporal topology
+#%end
+
+
+#%flag
#% key: t
#% description: Print temporal relation matrix and exit
#%end
@@ -65,6 +71,7 @@
tmatrix = flags['t']
relation = flags['r']
map_types = flags['m']
+ check_topo = flags['c']
# Make sure the temporal database exists
tgis.create_temporal_database()
@@ -76,12 +83,7 @@
mapset = grass.gisenv()["MAPSET"]
id = name + "@" + mapset
- if type == "strds":
- sp = tgis.space_time_raster_dataset(id)
- if type == "str3ds":
- sp = tgis.space_time_raster3d_dataset(id)
- if type == "stvds":
- sp = tgis.space_time_vector_dataset(id)
+ sp = tgis.dataset_factory(type, id)
if sp.is_in_db() == False:
grass.fatal("Dataset <" + name + "> not found in temporal database")
@@ -91,28 +93,33 @@
maps = sp.get_registered_maps_as_objects()
+ if check_topo:
+ check = sp.check_temporal_topology(maps)
+ if check:
+ print "Temporal topology is valid"
+ else:
+ print "Temporal topology is invalid"
+
if tmatrix:
- matrix = sp.get_temporal_relation_matrix(maps)
+ matrix = sp.print_temporal_relation_matrix(maps)
- for row in matrix:
- for col in row:
- print col,
- print " "
- print " "
- return
-
if relation:
- dict = sp.get_temporal_relations_count(maps)
+ dict = sp.count_temporal_relations(maps)
for key in dict.keys():
print key, dict[key]
if map_types:
- dict = sp.get_temporal_map_type_count(maps)
+ dict = sp.count_temporal_types(maps)
for key in dict.keys():
print key, dict[key]
+ if dict["interval"] > 0 and dict["point"] == 0 and dict["invalid"] == 0:
+ print "Gaps", sp.count_gaps(maps, True)
+ else:
+ print "Gaps", sp.count_gaps(maps, False)
+
if __name__ == "__main__":
options, flags = grass.parser()
main()
Modified: grass/trunk/temporal/tr.register/tr.register.py
===================================================================
--- grass/trunk/temporal/tr.register/tr.register.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/tr.register/tr.register.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -101,7 +101,7 @@
# Make sure the temporal database exists
tgis.create_temporal_database()
# Register maps
- tgis.register_maps_in_space_time_dataset(type="rast", name=name, maps=maps, file=file, start=start, end=end, \
+ tgis.register_maps_in_space_time_dataset(type="strds", name=name, maps=maps, file=file, start=start, end=end, \
increment=increment, dbif=None, interval=interval, fs=fs)
if __name__ == "__main__":
Modified: grass/trunk/temporal/tr3.register/tr3.register.py
===================================================================
--- grass/trunk/temporal/tr3.register/tr3.register.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/tr3.register/tr3.register.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -101,7 +101,7 @@
# Make sure the temporal database exists
tgis.create_temporal_database()
# Register maps
- tgis.register_maps_in_space_time_dataset(type="rast3d", name=name, maps=maps, file=file, start=start, end=end, \
+ tgis.register_maps_in_space_time_dataset(type="str3ds", name=name, maps=maps, file=file, start=start, end=end, \
increment=increment, dbif=None, interval=interval, fs=fs)
if __name__ == "__main__":
Modified: grass/trunk/temporal/tr3.unregister/tr3.unregister.py
===================================================================
--- grass/trunk/temporal/tr3.unregister/tr3.unregister.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/tr3.unregister/tr3.unregister.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -59,7 +59,7 @@
# Make sure the temporal database exists
tgis.create_temporal_database()
# Unregister maps
- tgis.unregister_maps_from_space_time_datasets(type="rast3d", name=name, maps=maps, file=file, dbif=None)
+ tgis.unregister_maps_from_space_time_datasets(type="str3ds", name=name, maps=maps, file=file, dbif=None)
if __name__ == "__main__":
options, flags = grass.parser()
Modified: grass/trunk/temporal/tv.register/tv.register.py
===================================================================
--- grass/trunk/temporal/tv.register/tv.register.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/tv.register/tv.register.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -101,7 +101,7 @@
# Make sure the temporal database exists
tgis.create_temporal_database()
# Register maps
- tgis.register_maps_in_space_time_dataset(type="vect", name=name, maps=maps, file=file, start=start, end=end, \
+ tgis.register_maps_in_space_time_dataset(type="stvds", name=name, maps=maps, file=file, start=start, end=end, \
increment=increment, dbif=None, interval=interval, fs=fs)
if __name__ == "__main__":
Modified: grass/trunk/temporal/tv.unregister/tv.unregister.py
===================================================================
--- grass/trunk/temporal/tv.unregister/tv.unregister.py 2011-10-14 14:22:03 UTC (rev 48794)
+++ grass/trunk/temporal/tv.unregister/tv.unregister.py 2011-10-14 15:22:13 UTC (rev 48795)
@@ -59,7 +59,7 @@
# Make sure the temporal database exists
tgis.create_temporal_database()
# Unregister maps
- tgis.unregister_maps_from_space_time_datasets(type="vect", name=name, maps=maps, file=file, dbif=None)
+ tgis.unregister_maps_from_space_time_datasets(type="stvds", name=name, maps=maps, file=file, dbif=None)
if __name__ == "__main__":
options, flags = grass.parser()
More information about the grass-commit
mailing list