[GRASS-SVN] r50787 - in grass/trunk/temporal: . t.register
t.support t.topology t.unregister
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Feb 13 08:23:10 EST 2012
Author: huhabla
Date: 2012-02-13 05:23:10 -0800 (Mon, 13 Feb 2012)
New Revision: 50787
Added:
grass/trunk/temporal/t.register/test.t.register.vector.file.layer.sh
grass/trunk/temporal/t.unregister/
grass/trunk/temporal/t.unregister/Makefile
grass/trunk/temporal/t.unregister/t.unregister.html
grass/trunk/temporal/t.unregister/t.unregister.py
Modified:
grass/trunk/temporal/Makefile
grass/trunk/temporal/t.register/t.register.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.register/test.t.register.vector.sh
grass/trunk/temporal/t.support/t.support.py
grass/trunk/temporal/t.topology/test.t.topology.abstime.sh
Log:
Added t.unregister as replacement for tr.unregister, tv.unregister
and tr3.unregister to reduce the complexity of the temporal GIS framework
and to avoid redundant functionality.
Modified: grass/trunk/temporal/Makefile
===================================================================
--- grass/trunk/temporal/Makefile 2012-02-13 13:19:32 UTC (rev 50786)
+++ grass/trunk/temporal/Makefile 2012-02-13 13:23:10 UTC (rev 50787)
@@ -8,28 +8,23 @@
t.info \
t.remove \
t.sample \
- t.time.abs \
- t.time.rel \
+ t.register \
+ t.unregister \
tr.aggregate \
tr.aggregate.ds \
- tr.register \
tr.to.rast3 \
tr.univar \
tr.list \
- tv.list \
- tr3.list \
tr.series \
tr.export \
tr.out.vtk \
tr.import \
tr.extract \
+ tr3.list \
tr3.extract \
- tr3.register \
- tv.register \
- tr.unregister \
- tr3.unregister \
- tv.unregister \
- tv.what.rast
+ tv.list \
+ tv.what.rast \
+ tv.oberve.rast
PGM = tgisintro
Modified: grass/trunk/temporal/t.register/t.register.py
===================================================================
--- grass/trunk/temporal/t.register/t.register.py 2012-02-13 13:19:32 UTC (rev 50786)
+++ grass/trunk/temporal/t.register/t.register.py 2012-02-13 13:23:10 UTC (rev 50787)
@@ -41,10 +41,10 @@
#%option
#% key: type
#% type: string
-#% description: Input space time dataset type
+#% description: Type of the input map(s)
#% required: no
-#% options: strds, stvds, str3ds
-#% answer: strds
+#% options: rast, vect, rast3d
+#% answer: rast
#%end
#%option
@@ -139,7 +139,7 @@
It takes care of the correct update of the space time datasets from all
registered maps.
- @param type: The type of the maps raster, raster3d or vector
+ @param type: The type of the maps rast, rast3d or vect
@param name: The name of the space time dataset
@param maps: A comma separated list of map names
@param file: Input file one map with start and optional end time, one per line
@@ -175,7 +175,12 @@
else:
id = name
- sp = tgis.dataset_factory(type, id)
+ if type == "rast":
+ sp = tgis.dataset_factory("strds", id)
+ if type == "rast3d":
+ sp = tgis.dataset_factory("str3ds", id)
+ if type == "vect":
+ sp = tgis.dataset_factory("stvds", id)
connect = False
@@ -316,106 +321,6 @@
###############################################################################
-def unregister_maps_from_space_time_datasets(type, name, maps, file=None, dbif=None):
- """Unregister maps from a single space time dataset or, in case no dataset name is provided,
- unregister from all datasets within the maps are registered.
-
- @param type: The type of the maps raster, vector or raster3d
- @param name: Name of an existing space time raster dataset. If no name is provided the raster map(s) are unregistered from all space time datasets in which they are registered.
- @param maps: A comma separated list of map names
- @param file: Input file one map per line
- @param dbif: The database interface to be used
- """
-
- if maps and file:
- grass.fatal(_("%s= and %s= are mutually exclusive") % ("input","file"))
-
- mapset = grass.gisenv()["MAPSET"]
-
- if dbif == None:
- dbif = sql_database_interface()
- dbif.connect()
- connect = True
-
- # In case a space time dataset is specified
- if name:
- # Check if the dataset name contains the mapset as well
- if name.find("@") < 0:
- id = name + "@" + mapset
- else:
- id = name
-
- if type == "rast":
- sp = dataset_factory("strds", id)
- if type == "rast3d":
- sp = dataset_factory("str3ds", id)
- if type == "vect":
- sp = dataset_factory("stvds", id)
-
- if sp.is_in_db(dbif) == False:
- dbif.close()
- grass.fatal("Space time " + sp.get_new_map_instance(None).get_type() + " dataset <" + name + "> not found")
-
- maplist = []
-
- dummy = raster_dataset(None)
-
- # Map names as comma separated string
- if maps != None:
- if maps.find(",") == -1:
- maplist = [maps,]
- else:
- maplist = maps.split(",")
-
- # Build the maplist
- for count in range(len(maplist)):
- mapname = maplist[count]
- mapid = dummy.build_id(mapname, mapset)
- maplist[count] = mapid
-
- # Read the map list from file
- if file:
- fd = open(file, "r")
-
- line = True
- while True:
- line = fd.readline()
- if not line:
- break
-
- line_list = line.split(fs)
- mapname = line_list[0].strip()
- mapid = dummy.build_id(mapname, mapset)
- maplist.append(mapid)
-
- num_maps = len(maplist)
- count = 0
- for mapid in maplist:
- grass.percent(count, num_maps, 1)
-
- print mapid
- map = dataset_factory(type, mapid)
-
- # Unregister map if in database
- if map.is_in_db(dbif) == True:
- if name:
- sp.select(dbif)
- sp.unregister_map(map, dbif)
- else:
- map.select(dbif)
- map.unregister(dbif)
-
- count += 1
-
- if name:
- sp.update_from_registered_maps(dbif)
-
- if connect == True:
- dbif.close()
-
- grass.percent(num_maps, num_maps, 1)
-
-
if __name__ == "__main__":
options, flags = grass.parser()
main()
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-02-13 13:19:32 UTC (rev 50786)
+++ grass/trunk/temporal/t.register/test.t.register.raster.file.reltime.sh 2012-02-13 13:23:10 UTC (rev 50787)
@@ -61,33 +61,33 @@
t.info type=strds input=precip_abs8
tr.list input=precip_abs8
# File 1
-t.remove --v type=rast file="${n1}"
+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
# File 2
-t.remove --v type=rast file="${n1}"
+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
# File 2 ERROR ERROR -- Increment computation needs to be fixed
-t.remove --v type=rast file="${n1}"
+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
# File 2 ERROR ERROR -- Increment computation needs to be fixed
-t.remove --v type=rast file="${n1}"
+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
# File 3
-t.remove --v type=rast file="${n1}"
+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.remove --v type=rast file="${n1}"
+t.unregister --v type=rast file="${n1}"
# @test of correct @failure handling
t.register -i input=precip_abs8 maps=preac_1,prec_2 file="${n3}" # Maps and file set
Modified: grass/trunk/temporal/t.register/test.t.register.raster.file.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.raster.file.sh 2012-02-13 13:19:32 UTC (rev 50786)
+++ grass/trunk/temporal/t.register/test.t.register.raster.file.sh 2012-02-13 13:23:10 UTC (rev 50787)
@@ -78,4 +78,4 @@
tr.list input=precip_abs8
t.remove --v type=strds input=precip_abs8
-t.remove --v type=rast file="${n1}"
+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-02-13 13:19:32 UTC (rev 50786)
+++ grass/trunk/temporal/t.register/test.t.register.raster.sh 2012-02-13 13:23:10 UTC (rev 50787)
@@ -90,7 +90,7 @@
tr.list input=precip_abs7
t.topology input=precip_abs7
-t.remove type=rast input=prec_1,prec_2,prec_3
+t.unregister type=rast maps=prec_1,prec_2,prec_3
t.remove type=strds input=precip_abs1,precip_abs2,precip_abs3,precip_abs4,precip_abs5,precip_abs6,precip_abs7
-t.remove type=rast input=prec_4,prec_5,prec_6
+t.unregister type=rast maps=prec_4,prec_5,prec_6
r.info map=prec_1
Modified: grass/trunk/temporal/t.register/test.t.register.raster3d.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.raster3d.sh 2012-02-13 13:19:32 UTC (rev 50786)
+++ grass/trunk/temporal/t.register/test.t.register.raster3d.sh 2012-02-13 13:23:10 UTC (rev 50787)
@@ -28,12 +28,12 @@
t.create --v --o type=str3ds temporaltype=absolute output=volume_abs6 title="A test" descr="A test"
t.create --v --o type=str3ds temporaltype=absolute output=volume_abs7 title="A test" descr="A test"
-t.register type=str3ds --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.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.info type=str3ds input=volume_abs1
-t.register type=str3ds --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"
+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"
t.info type=str3ds input=volume_abs2
r3.info volume_1
r3.info volume_2
@@ -42,29 +42,28 @@
r3.info volume_5
r3.info volume_6
-t.register type=str3ds --v -i input=volume_abs3 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="8 hours"
+t.register type=rast3d --v -i input=volume_abs3 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="8 hours"
t.info type=str3ds input=volume_abs3
-tr3.unregister --v maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6
+t.unregister --v type=rast3d maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6
t.info type=str3ds input=volume_abs3
-t.register type=str3ds input=volume_abs4 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="3 days"
+t.register type=rast3d input=volume_abs4 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="3 days"
t.info type=str3ds input=volume_abs4
-t.register type=str3ds input=volume_abs5 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="4 weeks"
+t.register type=rast3d input=volume_abs5 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="4 weeks"
t.info type=str3ds input=volume_abs5
-t.register type=str3ds input=volume_abs6 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-08-01" increment="2 months"
+t.register type=rast3d input=volume_abs6 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-08-01" increment="2 months"
t.info type=str3ds input=volume_abs6
-t.register type=str3ds input=volume_abs7 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="20 years, 3 months, 1 days, 4 hours"
+t.register type=rast3d input=volume_abs7 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="20 years, 3 months, 1 days, 4 hours"
t.info type=str3ds input=volume_abs7
# Register with different valid time again
-t.register type=str3ds input=volume_abs7 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
+t.register type=rast3d input=volume_abs7 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
t.info type=str3ds input=volume_abs7
# Register with different valid time again creating intervals
-t.register type=str3ds -i input=volume_abs7 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
+t.register type=rast3d -i input=volume_abs7 maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
t.info type=str3ds input=volume_abs7
-t.remove --v type=rast3d input=volume_1,volume_2,volume_3
+t.unregister --v type=rast3d maps=volume_1,volume_2,volume_3,volume_4,volume_5,volume_6
t.remove --v type=str3ds input=volume_abs1,volume_abs2,volume_abs3,volume_abs4,volume_abs5,volume_abs6,volume_abs7
-t.remove --v type=rast3d input=volume_4,volume_5,volume_6
Added: grass/trunk/temporal/t.register/test.t.register.vector.file.layer.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.vector.file.layer.sh (rev 0)
+++ grass/trunk/temporal/t.register/test.t.register.vector.file.layer.sh 2012-02-13 13:23:10 UTC (rev 50787)
@@ -0,0 +1,70 @@
+# This is a test to absolute time for vector maps with layer support
+# We need to set a specific region in the
+# @preprocess step of this test. We generate
+# vector with v.random.
+# The region setting should work for UTM and LL test locations
+g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
+
+v.random --o -z output=lidar_abs_1 n=5 zmin=0 zmax=100
+
+n1=`g.tempfile pid=4 -d` # Only map names and layer
+n2=`g.tempfile pid=5 -d` # Map names, layer and start time
+n3=`g.tempfile pid=6 -d` # Map names, layer, start time and increment
+# The vector map
+v.random --o -z seed=1 output=lidar_abs_orig n=100 zmin=0 zmax=100 column=sand
+# Adding new layer with categories
+v.category input=lidar_abs_orig out=lidar_abs_1 option=transfer layer=1,2,3,4,5,6 --o
+
+cat > "${n1}" << EOF
+lidar_abs_1:1
+lidar_abs_1:2
+lidar_abs_1:3
+lidar_abs_1:4
+lidar_abs_1:5
+lidar_abs_1:6
+EOF
+cat "${n1}"
+
+cat > "${n2}" << EOF
+lidar_abs_1:1|2001-01-01
+lidar_abs_1:2|2001-02-01
+lidar_abs_1:3|2001-03-01
+lidar_abs_1:4|2001-04-01
+lidar_abs_1:5|2001-05-01
+lidar_abs_1:6|2001-06-01
+EOF
+cat "${n2}"
+
+cat > "${n3}" << EOF
+lidar_abs_1:1|2001-01-01|2001-04-01
+lidar_abs_1:2|2001-04-01|2001-07-01
+lidar_abs_1:3|2001-07-01|2001-10-01
+lidar_abs_1:4|2001-10-01|2002-01-01
+lidar_abs_1:5|2002-01-01|2002-04-01
+lidar_abs_1:6|2002-04-01|2002-07-01
+EOF
+cat "${n3}"
+
+t.create --v --o type=stvds temporaltype=absolute output=lidar_abs_ds1 title="A test" descr="A test"
+
+# The first @test
+# Test with input files
+# File 1
+t.register --v type=vect input=lidar_abs_ds1 file="${n1}" start="2001-01-01" increment="1 months"
+t.list type=vect columns=id,name,start_time,end_time where='name = "lidar_abs_1"'
+# File 1
+t.register --v type=vect input=lidar_abs_ds1 file="${n1}" start="2001-01-01"
+t.list type=vect columns=id,name,start_time,end_time where='name = "lidar_abs_1"'
+# File 2
+t.register --v type=vect input=lidar_abs_ds1 file="${n2}"
+t.list type=vect columns=id,name,start_time,end_time where='name = "lidar_abs_1"'
+# File 2
+t.register --v type=vect input=lidar_abs_ds1 -i file="${n2}" start=file increment="1 months"
+t.list type=vect columns=id,name,start_time,end_time where='name = "lidar_abs_1"'
+# File 3
+t.register --v type=vect input=lidar_abs_ds1 file="${n3}" start=file
+t.list type=vect columns=id,name,start_time,end_time where='name = "lidar_abs_1"'
+
+t.unregister --v type=vect maps=lidar_abs_1:1,lidar_abs_1:2,lidar_abs_1:3,lidar_abs_1:4,lidar_abs_1:5,lidar_abs_1:6
+t.remove type=stvds input=lidar_abs_ds1
+g.remove vect=lidar_abs_1,lidar_abs_orig
Modified: grass/trunk/temporal/t.register/test.t.register.vector.sh
===================================================================
--- grass/trunk/temporal/t.register/test.t.register.vector.sh 2012-02-13 13:19:32 UTC (rev 50786)
+++ grass/trunk/temporal/t.register/test.t.register.vector.sh 2012-02-13 13:23:10 UTC (rev 50787)
@@ -28,37 +28,37 @@
t.create --v --o type=stvds temporaltype=absolute output=lidar_abs_ds6 title="A test" descr="A test"
t.create --v --o type=stvds temporaltype=absolute output=lidar_abs_ds7 title="A test" descr="A test"
-t.register type=stvds --v -i input=lidar_abs_ds1 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="1 seconds"
+t.register type=vect --v -i input=lidar_abs_ds1 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="1 seconds"
t.info type=stvds input=lidar_abs_ds1
-tv.unregister --v input=lidar_abs_ds1 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6
+t.unregister --v type=vect input=lidar_abs_ds1 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6
t.info type=stvds input=lidar_abs_ds1
-t.register type=stvds --v -i input=lidar_abs_ds2 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="20 seconds, 5 minutes"
+t.register type=vect --v -i input=lidar_abs_ds2 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="20 seconds, 5 minutes"
t.info type=stvds input=lidar_abs_ds2
-t.register type=stvds --v -i input=lidar_abs_ds3 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="8 hours"
+t.register type=vect --v -i input=lidar_abs_ds3 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="8 hours"
t.info type=stvds input=lidar_abs_ds3
-tv.unregister --v maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6
+t.unregister --v type=vect maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6
t.info type=stvds input=lidar_abs_ds3
-t.register type=stvds input=lidar_abs_ds4 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="3 days"
+t.register type=vect input=lidar_abs_ds4 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="3 days"
t.info type=stvds input=lidar_abs_ds4
-t.register type=stvds input=lidar_abs_ds5 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="4 weeks"
+t.register type=vect input=lidar_abs_ds5 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="4 weeks"
t.info type=stvds input=lidar_abs_ds5
-t.register type=stvds input=lidar_abs_ds6 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-08-01" increment="2 months"
+t.register type=vect input=lidar_abs_ds6 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-08-01" increment="2 months"
t.info type=stvds input=lidar_abs_ds6
-t.register type=stvds input=lidar_abs_ds7 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="20 years, 3 months, 1 days, 4 hours"
+t.register type=vect input=lidar_abs_ds7 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="20 years, 3 months, 1 days, 4 hours"
t.info type=stvds input=lidar_abs_ds7
# Register with different valid time again
-t.register type=stvds input=lidar_abs_ds7 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
+t.register type=vect input=lidar_abs_ds7 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
t.info type=stvds input=lidar_abs_ds7
# Register with different valid time again creating an interval
-t.register type=stvds -i input=lidar_abs_ds7 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
+t.register type=vect -i input=lidar_abs_ds7 maps=lidar_abs_1,lidar_abs_2,lidar_abs_3,lidar_abs_4,lidar_abs_5,lidar_abs_6 start="2001-01-01" increment="99 years, 9 months, 9 days, 9 hours"
t.info type=stvds input=lidar_abs_ds7
-t.remove --v type=vect input=lidar_abs_1,lidar_abs_2,lidar_abs_3
+t.unregister --v type=vect maps=lidar_abs_1,lidar_abs_2,lidar_abs_3
t.remove --v type=stvds input=lidar_abs_ds1,lidar_abs_ds2,lidar_abs_ds3,lidar_abs_ds4,lidar_abs_ds5,lidar_abs_ds6,lidar_abs_ds7
-t.remove --v type=vect input=lidar_abs_4,lidar_abs_5,lidar_abs_6
+t.unregister --v type=vect maps=lidar_abs_4,lidar_abs_5,lidar_abs_6
Modified: grass/trunk/temporal/t.support/t.support.py
===================================================================
--- grass/trunk/temporal/t.support/t.support.py 2012-02-13 13:19:32 UTC (rev 50786)
+++ grass/trunk/temporal/t.support/t.support.py 2012-02-13 13:23:10 UTC (rev 50787)
@@ -35,8 +35,8 @@
#% description: The semantic type of the space time dataset
#% required: no
#% multiple: no
-#% options: event, const, continuous
-#% answer: event
+#% options: min,max,sum,mean
+#% answer: mean
#%end
#%option
Modified: grass/trunk/temporal/t.topology/test.t.topology.abstime.sh
===================================================================
--- grass/trunk/temporal/t.topology/test.t.topology.abstime.sh 2012-02-13 13:19:32 UTC (rev 50786)
+++ grass/trunk/temporal/t.topology/test.t.topology.abstime.sh 2012-02-13 13:23:10 UTC (rev 50787)
@@ -16,12 +16,17 @@
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)"
+r.mapcalc --o expr="A = 1"
+r.mapcalc --o expr="B = 2"
+r.mapcalc --o expr="C = 3"
+r.mapcalc --o expr="D = 3"
n1=`g.tempfile pid=1 -d`
n2=`g.tempfile pid=2 -d`
n3=`g.tempfile pid=3 -d`
n4=`g.tempfile pid=4 -d`
n5=`g.tempfile pid=5 -d`
+n6=`g.tempfile pid=6 -d`
cat > "${n1}" << EOF
prec_1
@@ -68,10 +73,19 @@
prec_6|2001-06-01|2001-07-01
EOF
+cat > "${n6}" << EOF
+A|1990-06-01|1990-06-05
+B|1990-06-05|1990-06-18
+C|1990-06-10|1990-06-13
+D|1990-06-16|1990-06-20
+EOF
+
+
# The first @test
# We create the space time raster inputs and register the raster maps with absolute time interval
t.create --o type=strds temporaltype=absolute output=precip_abs title="A test with input files" descr="A test with input files"
+t.create --o type=strds temporaltype=absolute output=maps title="A test with maps in input files" descr="A test with maps in input files"
tr.register -i input=precip_abs file="${n1}" start="2001-01-01" increment="1 months"
cat "${n1}"
@@ -98,5 +112,11 @@
t.topology input=precip_abs
t.topology -m input=precip_abs
-t.remove type=strds input=precip_abs
+tr.register -i input=maps file="${n6}" start=file end=file
+cat "${n6}"
+t.topology input=maps
+t.topology -m input=maps
+
+t.remove type=strds input=precip_abs,maps
t.remove type=rast file="${n1}"
+t.remove type=rast input=A,B,C,D
Added: grass/trunk/temporal/t.unregister/Makefile
===================================================================
--- grass/trunk/temporal/t.unregister/Makefile (rev 0)
+++ grass/trunk/temporal/t.unregister/Makefile 2012-02-13 13:23:10 UTC (rev 50787)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../
+
+PGM = t.unregister
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script $(TEST_DST)
Added: grass/trunk/temporal/t.unregister/t.unregister.html
===================================================================
Added: grass/trunk/temporal/t.unregister/t.unregister.py
===================================================================
--- grass/trunk/temporal/t.unregister/t.unregister.py (rev 0)
+++ grass/trunk/temporal/t.unregister/t.unregister.py 2012-02-13 13:23:10 UTC (rev 50787)
@@ -0,0 +1,212 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE: t.unregister
+# AUTHOR(S): Soeren Gebbert
+#
+# PURPOSE: Unregister raster, vector and raster3d maps from the temporal database or a specific space time 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: Unregister raster, vector and raster3d maps from the temporal database or a specific space time dataset
+#% keywords: temporal
+#% keywords: raster
+#% keywords: vector
+#% keywords: raster3d
+#% keywords: strds
+#% keywords: stvds
+#% keywords: str3ds
+#%end
+
+#%option
+#% key: input
+#% type: string
+#% description: Name of an existing space time raster dataset. If no name is provided the raster map(s) are unregistered from all space time datasets in which they are registered.
+#% required: no
+#% multiple: no
+#%end
+
+#%option
+#% key: file
+#% type: string
+#% description: Input file with map names, one per line
+#% required: no
+#% multiple: no
+#%end
+
+#%option
+#% key: type
+#% type: string
+#% description: Type of the input map(s)
+#% required: no
+#% options: rast, vect, rast3d
+#% answer: rast
+#%end
+
+
+#%option
+#% key: maps
+#% type: string
+#% description: Name(s) of existing raster, vector or raster3d map(s) to unregister
+#% required: no
+#% multiple: yes
+#%end
+
+import grass.script as grass
+import grass.temporal as tgis
+
+############################################################################
+
+def main():
+
+ # Get the options
+ file = options["file"]
+ name = options["input"]
+ maps = options["maps"]
+ type = options["type"]
+
+ # Make sure the temporal database exists
+ tgis.create_temporal_database()
+ # Unregister maps
+ unregister_maps_from_space_time_datasets(type=type, name=name, maps=maps, file=file, dbif=None)
+
+############################################################################
+
+def unregister_maps_from_space_time_datasets(type, name, maps, file=None, dbif=None):
+ """Unregister maps from a single space time dataset or, in case no dataset name is provided,
+ unregister from all datasets within the maps are registered.
+
+ @param type: The type of the maps raster, vector or raster3d
+ @param name: Name of an existing space time raster dataset. If no name is provided the raster map(s) are unregistered from all space time datasets in which they are registered.
+ @param maps: A comma separated list of map names
+ @param file: Input file one map per line
+ @param dbif: The database interface to be used
+ """
+
+ if maps and file:
+ grass.fatal(_("%s= and %s= are mutually exclusive") % ("input","file"))
+
+ if not maps and not file:
+ grass.fatal(_("%s= or %s= must be specified") % ("input","file"))
+
+
+ mapset = grass.gisenv()["MAPSET"]
+
+ if dbif == None:
+ dbif = tgis.sql_database_interface()
+ dbif.connect()
+ connect = True
+
+ # In case a space time dataset is specified
+ if name:
+ # Check if the dataset name contains the mapset as well
+ if name.find("@") < 0:
+ id = name + "@" + mapset
+ else:
+ id = name
+
+ if type == "rast":
+ sp = tgis.dataset_factory("strds", id)
+ if type == "rast3d":
+ sp = tgis.dataset_factory("str3ds", id)
+ if type == "vect":
+ sp = tgis.dataset_factory("stvds", id)
+
+ if sp.is_in_db(dbif) == False:
+ dbif.close()
+ grass.fatal("Space time " + sp.get_new_map_instance(None).get_type() + " dataset <" + name + "> not found")
+
+ maplist = []
+
+ dummy = tgis.raster_dataset(None)
+
+ # Map names as comma separated string
+ if maps != None:
+ if maps.find(",") == -1:
+ maplist = [maps,]
+ else:
+ maplist = maps.split(",")
+
+ # Build the maplist
+ for count in range(len(maplist)):
+ mapname = maplist[count]
+ mapid = dummy.build_id(mapname, mapset)
+ maplist[count] = mapid
+
+ # Read the map list from file
+ if file:
+ fd = open(file, "r")
+
+ line = True
+ while True:
+ line = fd.readline()
+ if not line:
+ break
+
+ mapname = line.strip()
+ mapid = dummy.build_id(mapname, mapset)
+ maplist.append(mapid)
+
+ num_maps = len(maplist)
+ update_dict = {}
+ count = 0
+ for mapid in maplist:
+ grass.percent(count, num_maps, 1)
+
+ print mapid
+ map = tgis.dataset_factory(type, mapid)
+
+ # Unregister map if in database
+ if map.is_in_db(dbif) == True:
+ # Unregister from a single dataset
+ if name:
+ sp.select(dbif)
+ sp.unregister_map(map, dbif)
+ # Unregister from temporal database
+ else:
+ # We need to update all datasets after the removement of maps
+ map.select(dbif)
+ datasets = map.get_registered_datasets(dbif)
+ # Store all unique dataset ids in a dictionary
+ if datasets:
+ for dataset in datasets:
+ update_dict[dataset["id"]] = dataset["id"]
+ map.delete(dbif, update=False)
+
+ count += 1
+
+ # Update space time datasets
+ if name:
+ sp.update_from_registered_maps(dbif)
+ elif len(update_dict) > 0:
+ for key in update_dict.keys():
+ id = update_dict[key]
+ if type == "rast":
+ sp = tgis.dataset_factory("strds", id)
+ elif type == "rast3d":
+ sp = tgis.dataset_factory("str3ds", id)
+ elif type == "vect":
+ sp = tgis.dataset_factory("stvds", id)
+ else:
+ break
+
+ sp.select(dbif)
+ sp.update_from_registered_maps(dbif)
+
+ if connect == True:
+ dbif.close()
+
+ grass.percent(num_maps, num_maps, 1)
+
+###############################################################################
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ main()
Property changes on: grass/trunk/temporal/t.unregister/t.unregister.py
___________________________________________________________________
Added: svn:executable
+ *
More information about the grass-commit
mailing list