|
@@ -278,7 +278,7 @@ def test_relative_timestamp():
|
|
|
|
|
|
def test_map_metadata():
|
|
|
for i in range(2):
|
|
|
- base = raster_metadata(ident="soil" + str(i) + "@PERMANENT", strds_register="PERMANENT_soil_strds-register", datatype="CELL", \
|
|
|
+ base = raster_metadata(ident="soil" + str(i) + "@PERMANENT", strds_register="PERMANENT_soil_strds_register", datatype="CELL", \
|
|
|
cols=500, rows=400, number_of_cells=200000,nsres=1, ewres=1, min=0, max=33)
|
|
|
base.insert()
|
|
|
base.select()
|
|
@@ -290,7 +290,7 @@ def test_map_metadata():
|
|
|
base.print_self()
|
|
|
|
|
|
for i in range(2):
|
|
|
- base = raster3d_metadata(ident="soil" + str(i) + "@PERMANENT", str3ds_register="PERMANENT_soil_str3ds-register", datatype="FCELL", \
|
|
|
+ base = raster3d_metadata(ident="soil" + str(i) + "@PERMANENT", str3ds_register="PERMANENT_soil_str3ds_register", datatype="FCELL", \
|
|
|
cols=500, rows=400, depths=20, number_of_cells=200000,nsres=1, ewres=1, tbres=10, min=0, max=33)
|
|
|
base.insert()
|
|
|
base.select()
|
|
@@ -311,7 +311,43 @@ def test_map_metadata():
|
|
|
base.update()
|
|
|
base.select()
|
|
|
base.print_self()
|
|
|
+
|
|
|
+ for i in range(2):
|
|
|
+ base = strds_metadata(ident="soil" + str(i) + "@PERMANENT", raster_register="PERMANENT_soil_raster_register", \
|
|
|
+ title="Test", description="Test description")
|
|
|
+ base.insert()
|
|
|
+ base.select()
|
|
|
+ base.print_self()
|
|
|
+ base.clear()
|
|
|
+ base.set_title("More tests")
|
|
|
+ base.update()
|
|
|
+ base.select()
|
|
|
+ base.print_self()
|
|
|
|
|
|
+ for i in range(2):
|
|
|
+ base = str3ds_metadata(ident="soil" + str(i) + "@PERMANENT", raster3d_register="PERMANENT_soil_raster3d_register", \
|
|
|
+ title="Test", description="Test description")
|
|
|
+ base.insert()
|
|
|
+ base.select()
|
|
|
+ base.print_self()
|
|
|
+ base.clear()
|
|
|
+ base.set_title("More tests")
|
|
|
+ base.update()
|
|
|
+ base.select()
|
|
|
+ base.print_self()
|
|
|
+
|
|
|
+ for i in range(2):
|
|
|
+ base = stvds_metadata(ident="soil" + str(i) + "@PERMANENT", vector_register="PERMANENT_soil_vector_register", \
|
|
|
+ title="Test", description="Test description")
|
|
|
+ base.insert()
|
|
|
+ base.select()
|
|
|
+ base.print_self()
|
|
|
+ base.clear()
|
|
|
+ base.set_title("More tests")
|
|
|
+ base.update()
|
|
|
+ base.select()
|
|
|
+ base.print_self()
|
|
|
+
|
|
|
def test_base_absolute_time_extent_metadata():
|
|
|
|
|
|
for i in range(10):
|
|
@@ -476,6 +512,7 @@ def test_absolut_time_temporal_relations():
|
|
|
|
|
|
def test_raster_dataset():
|
|
|
|
|
|
+ # Create a test map
|
|
|
grass.raster.mapcalc("test = sin(x()) + cos(y())", overwrite = True)
|
|
|
|
|
|
name = "test"
|
|
@@ -483,54 +520,64 @@ def test_raster_dataset():
|
|
|
|
|
|
print "Create a raster object"
|
|
|
|
|
|
+ # We need to specify the name and the mapset as identifier
|
|
|
rds = raster_dataset(name + "@" + mapset)
|
|
|
|
|
|
+ # Load data from the raster map in the mapset
|
|
|
rds.load()
|
|
|
|
|
|
print "Is in db: ", rds.is_in_db()
|
|
|
|
|
|
- rds.base.set_ttype("absolue")
|
|
|
- rds.absolute_time.set_start_time(datetime(year=2000, month=1, day=1))
|
|
|
- rds.absolute_time.set_end_time(datetime(year=2010, month=1, day=1))
|
|
|
-
|
|
|
- # Remove the entry if it is in the db
|
|
|
- rds.delete()
|
|
|
+ if rds.is_in_db():
|
|
|
+ # Remove the entry if it is in the db
|
|
|
+ rds.delete()
|
|
|
|
|
|
+ # Set the absolute valid time
|
|
|
+ rds.set_absolute_time(start_time= datetime(year=2000, month=1, day=1), \
|
|
|
+ end_time= datetime(year=2010, month=1, day=1))
|
|
|
+ # Insert the map data into the SQL database
|
|
|
rds.insert()
|
|
|
+ # Print self info
|
|
|
rds.print_self()
|
|
|
-
|
|
|
+ # The temporal relation must be equal
|
|
|
print rds.temporal_relation(rds)
|
|
|
|
|
|
def test_raster3d_dataset():
|
|
|
|
|
|
+ # Create a test map
|
|
|
grass.raster3d.mapcalc3d("test = sin(x()) + cos(y()) + sin(z())", overwrite = True)
|
|
|
|
|
|
name = "test"
|
|
|
mapset = grass.gisenv()["MAPSET"]
|
|
|
|
|
|
- print "Create a raster3d object"
|
|
|
+ print "Create a raster object"
|
|
|
|
|
|
+ # We need to specify the name and the mapset as identifier
|
|
|
r3ds = raster3d_dataset(name + "@" + mapset)
|
|
|
|
|
|
+ # Load data from the raster map in the mapset
|
|
|
r3ds.load()
|
|
|
|
|
|
print "Is in db: ", r3ds.is_in_db()
|
|
|
- r3ds.print_self()
|
|
|
-
|
|
|
- r3ds.base.set_ttype("absolue")
|
|
|
- r3ds.absolute_time.set_start_time(datetime(year=2000, month=1, day=1))
|
|
|
- r3ds.absolute_time.set_end_time(datetime(year=2010, month=1, day=1))
|
|
|
|
|
|
- # Remove the entry if it is in the db
|
|
|
- r3ds.delete()
|
|
|
+ if r3ds.is_in_db():
|
|
|
+ # Remove the entry if it is in the db
|
|
|
+ r3ds.delete()
|
|
|
|
|
|
+ # Set the absolute valid time
|
|
|
+ r3ds.set_absolute_time(start_time= datetime(year=2000, month=1, day=1), \
|
|
|
+ end_time= datetime(year=2010, month=1, day=1))
|
|
|
+
|
|
|
+ # Insert the map data into the SQL database
|
|
|
r3ds.insert()
|
|
|
+ # Print self info
|
|
|
r3ds.print_self()
|
|
|
-
|
|
|
+ # The temporal relation must be equal
|
|
|
print r3ds.temporal_relation(r3ds)
|
|
|
|
|
|
def test_vector_dataset():
|
|
|
|
|
|
+ # Create a test map
|
|
|
grass.run_command("v.random", output="test", n=20, column="height", zmin=0, \
|
|
|
zmax=100, flags="z", overwrite = True)
|
|
|
|
|
@@ -539,34 +586,103 @@ def test_vector_dataset():
|
|
|
|
|
|
print "Create a vector object"
|
|
|
|
|
|
+ # We need to specify the name and the mapset as identifier
|
|
|
vds = vector_dataset(name + "@" + mapset)
|
|
|
|
|
|
+ # Load data from the raster map in the mapset
|
|
|
vds.load()
|
|
|
|
|
|
print "Is in db: ", vds.is_in_db()
|
|
|
- vds.print_self()
|
|
|
|
|
|
- vds.base.set_ttype("absolue")
|
|
|
- vds.absolute_time.set_start_time(datetime(year=2000, month=1, day=1))
|
|
|
- vds.absolute_time.set_end_time(datetime(year=2010, month=1, day=1))
|
|
|
-
|
|
|
- # Remove the entry if it is in the db
|
|
|
- vds.delete()
|
|
|
+ if vds.is_in_db():
|
|
|
+ # Remove the entry if it is in the db
|
|
|
+ vds.delete()
|
|
|
|
|
|
+ # Set the absolute valid time
|
|
|
+ vds.set_absolute_time(start_time= datetime(year=2000, month=1, day=1), \
|
|
|
+ end_time= datetime(year=2010, month=1, day=1))
|
|
|
+ # Insert the map data into the SQL database
|
|
|
vds.insert()
|
|
|
+ # Print self info
|
|
|
vds.print_self()
|
|
|
-
|
|
|
+ # The temporal relation must be equal
|
|
|
print vds.temporal_relation(vds)
|
|
|
|
|
|
+
|
|
|
+def test_strds_dataset():
|
|
|
+
|
|
|
+ name = "strds_test_1"
|
|
|
+ mapset = grass.gisenv()["MAPSET"]
|
|
|
+
|
|
|
+ print "Create a strds object"
|
|
|
+
|
|
|
+ # We need to specify the name and the mapset as identifier
|
|
|
+ strds = space_time_raster_dataset(ident = name + "@" + mapset)
|
|
|
+ # Check if in db
|
|
|
+ print "Is strds in db: ", strds.is_in_db()
|
|
|
+ # Create a new entry if not in db
|
|
|
+ if strds.is_in_db() == False:
|
|
|
+ strds.set_initial_values(temporal_type = "absolute", granularity="1 day",\
|
|
|
+ semantic_type="event", title="This is a test space time raster dataset", description="A space time raster dataset for testing")
|
|
|
+ strds.insert()
|
|
|
+
|
|
|
+ # Reread the data from the db
|
|
|
+ strds.select()
|
|
|
+ # Print self info
|
|
|
+ strds.print_self()
|
|
|
+
|
|
|
+ # Create a test maps
|
|
|
+ for i in range(11):
|
|
|
+ i = i + 1
|
|
|
+ grass.raster.mapcalc("test" + str(i) + " = sin(x()) + cos(y())", overwrite = True)
|
|
|
+
|
|
|
+ name = "test" + str(i)
|
|
|
+ mapset = grass.gisenv()["MAPSET"]
|
|
|
+ ident = name + "@" + mapset
|
|
|
+
|
|
|
+ print "Create a raster object"
|
|
|
+
|
|
|
+ # We need to specify the name and the mapset as identifier
|
|
|
+ rds = raster_dataset(ident)
|
|
|
+
|
|
|
+ # Load data from the raster map in the mapset
|
|
|
+ rds.load()
|
|
|
+
|
|
|
+ print "Is raster in db: ", rds.is_in_db()
|
|
|
+
|
|
|
+ if rds.is_in_db():
|
|
|
+ rds.select()
|
|
|
+ rds.print_self()
|
|
|
+ # Remove the entry if it is in the db
|
|
|
+ rds.delete()
|
|
|
+ rds.reset(ident)
|
|
|
+ rds.load()
|
|
|
+
|
|
|
+ # Set the absolute valid time
|
|
|
+ rds.set_absolute_time(start_time= datetime(year=2000, month=i, day=1), \
|
|
|
+ end_time= datetime(year=2000, month=i + 1, day=1))
|
|
|
+ # Insert the map data into the SQL database
|
|
|
+ rds.insert()
|
|
|
+ # Register the map in the space time raster dataset
|
|
|
+ strds.register_map(rds)
|
|
|
+ # Print self info
|
|
|
+ rds.print_self()
|
|
|
+
|
|
|
+ strds.select()
|
|
|
+ # Print self info
|
|
|
+ strds.print_self()
|
|
|
+
|
|
|
#test_dict_sql_serializer()
|
|
|
create_temporal_database()
|
|
|
-test_dataset_identifer()
|
|
|
-test_absolute_timestamp()
|
|
|
-test_relative_timestamp()
|
|
|
-test_spatial_extent()
|
|
|
+#test_dataset_identifer()
|
|
|
+#test_absolute_timestamp()
|
|
|
+#test_relative_timestamp()
|
|
|
+#test_spatial_extent()
|
|
|
#test_map_metadata()
|
|
|
#test_base_absolute_time_extent_metadata()
|
|
|
#test_absolut_time_temporal_relations()
|
|
|
#test_raster_dataset()
|
|
|
#test_raster3d_dataset()
|
|
|
-#test_vector_dataset()
|
|
|
+#test_vector_dataset()
|
|
|
+
|
|
|
+test_strds_dataset()
|