[GRASS-SVN] r48216 - grass/trunk/lib/temporal
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Sep 8 08:51:08 EDT 2011
Author: huhabla
Date: 2011-09-08 05:51:08 -0700 (Thu, 08 Sep 2011)
New Revision: 48216
Modified:
grass/trunk/lib/temporal/map_tables_template.sql
grass/trunk/lib/temporal/raster3d_metadata_table.sql
grass/trunk/lib/temporal/raster_metadata_table.sql
grass/trunk/lib/temporal/stds_map_register_table_template.sql
grass/trunk/lib/temporal/stds_tables_template.sql
grass/trunk/lib/temporal/str3ds_metadata_table.sql
grass/trunk/lib/temporal/strds_metadata_table.sql
grass/trunk/lib/temporal/stvds_metadata_table.sql
grass/trunk/lib/temporal/test.temporal.py
grass/trunk/lib/temporal/vector_metadata_table.sql
Log:
New projection column in spatial extent. Space time raster3d dataset test
Modified: grass/trunk/lib/temporal/map_tables_template.sql
===================================================================
--- grass/trunk/lib/temporal/map_tables_template.sql 2011-09-08 12:50:12 UTC (rev 48215)
+++ grass/trunk/lib/temporal/map_tables_template.sql 2011-09-08 12:51:08 UTC (rev 48216)
@@ -53,6 +53,7 @@
west DOUBLE PRECISION NOT NULL,
top DOUBLE PRECISION NOT NULL,
bottom DOUBLE PRECISION NOT NULL,
+ proj DOUBLE VARCHAR,
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES GRASS_MAP_base (id) ON DELETE CASCADE
);
Modified: grass/trunk/lib/temporal/raster3d_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/raster3d_metadata_table.sql 2011-09-08 12:50:12 UTC (rev 48215)
+++ grass/trunk/lib/temporal/raster3d_metadata_table.sql 2011-09-08 12:51:08 UTC (rev 48216)
@@ -35,7 +35,7 @@
A1.creation_time, A1.modification_time,
A1.revision, A1.creator,
A2.start_time, A2.end_time,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.datatype, A4.cols, A4.rows, A4.depths,
A4.nsres, A4.ewres, A4.tbres,
A4.min, A4.max,
@@ -51,7 +51,7 @@
A1.creation_time, A1.modification_time,
A1.revision, A1.creator,
A2.interval,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.datatype, A4.cols, A4.rows, A4.depths,
A4.nsres, A4.ewres, A4.tbres,
A4.min, A4.max,
Modified: grass/trunk/lib/temporal/raster_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/raster_metadata_table.sql 2011-09-08 12:50:12 UTC (rev 48215)
+++ grass/trunk/lib/temporal/raster_metadata_table.sql 2011-09-08 12:51:08 UTC (rev 48216)
@@ -33,7 +33,7 @@
A1.creation_time, A1.modification_time,
A1.revision, A1.creator,
A2.start_time, A2.end_time,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.datatype, A4.cols, A4.rows,
A4.nsres, A4.ewres, A4.min, A4.max,
A4.strds_register,
@@ -48,7 +48,7 @@
A1.creation_time, A1.modification_time,
A1.revision, A1.creator,
A2.interval,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.datatype, A4.cols, A4.rows,
A4.nsres, A4.ewres, A4.min, A4.max,
A4.strds_register,
Modified: grass/trunk/lib/temporal/stds_map_register_table_template.sql
===================================================================
--- grass/trunk/lib/temporal/stds_map_register_table_template.sql 2011-09-08 12:50:12 UTC (rev 48215)
+++ grass/trunk/lib/temporal/stds_map_register_table_template.sql 2011-09-08 12:51:08 UTC (rev 48216)
@@ -63,6 +63,10 @@
(SELECT min(bottom) FROM GRASS_MAP_spatial_extent WHERE GRASS_MAP_spatial_extent.id IN
(SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
) WHERE id = "SPACETIME_ID";
+ UPDATE STDS_spatial_extent SET proj =
+ (SELECT min(proj) FROM GRASS_MAP_spatial_extent WHERE GRASS_MAP_spatial_extent.id IN
+ (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+ ) WHERE id = "SPACETIME_ID";
END;
CREATE TRIGGER SPACETIME_NAME_GRASS_MAP_register_delete_trigger AFTER DELETE ON SPACETIME_NAME_GRASS_MAP_register
@@ -107,5 +111,9 @@
(SELECT min(bottom) FROM GRASS_MAP_spatial_extent WHERE GRASS_MAP_spatial_extent.id IN
(SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
) WHERE id = "SPACETIME_ID";
+ UPDATE STDS_spatial_extent SET proj =
+ (SELECT min(proj) FROM GRASS_MAP_spatial_extent WHERE GRASS_MAP_spatial_extent.id IN
+ (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+ ) WHERE id = "SPACETIME_ID";
END;
Modified: grass/trunk/lib/temporal/stds_tables_template.sql
===================================================================
--- grass/trunk/lib/temporal/stds_tables_template.sql 2011-09-08 12:50:12 UTC (rev 48215)
+++ grass/trunk/lib/temporal/stds_tables_template.sql 2011-09-08 12:51:08 UTC (rev 48216)
@@ -48,6 +48,7 @@
west DOUBLE PRECISION, -- The spatial west extent, derived from the registered maps
top DOUBLE PRECISION, -- The spatial top extent, derived from the registered maps
bottom DOUBLE PRECISION, -- The spatial bottom extent, derived from the registered maps
+ proj DOUBLE VARCHAR, -- The projection of the space time dataset (XY of LL)
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES STDS_base (id) ON DELETE CASCADE
);
Modified: grass/trunk/lib/temporal/str3ds_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/str3ds_metadata_table.sql 2011-09-08 12:50:12 UTC (rev 48215)
+++ grass/trunk/lib/temporal/str3ds_metadata_table.sql 2011-09-08 12:51:08 UTC (rev 48216)
@@ -34,7 +34,7 @@
A1.creation_time, A1.modification_time,
A1.revision, A2.start_time,
A2.end_time, A2.granularity,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.raster3d_register,
A4.number_of_maps,
A4.nsres_min, A4.ewres_min,
@@ -53,7 +53,7 @@
A1.creation_time, A1.modification_time,
A1.revision,
A2.interval, A2.granularity,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.raster3d_register,
A4.number_of_maps,
A4.nsres_min, A4.ewres_min,
Modified: grass/trunk/lib/temporal/strds_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/strds_metadata_table.sql 2011-09-08 12:50:12 UTC (rev 48215)
+++ grass/trunk/lib/temporal/strds_metadata_table.sql 2011-09-08 12:51:08 UTC (rev 48216)
@@ -32,7 +32,7 @@
A1.creation_time, A1.modification_time,
A1.revision, A2.start_time,
A2.end_time, A2.granularity,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.raster_register,
A4.number_of_maps,
A4.nsres_min, A4.ewres_min,
@@ -50,7 +50,7 @@
A1.creation_time, A1.modification_time,
A1.revision,
A2.interval, A2.granularity,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.raster_register,
A4.number_of_maps,
A4.nsres_min, A4.ewres_min,
Modified: grass/trunk/lib/temporal/stvds_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/stvds_metadata_table.sql 2011-09-08 12:50:12 UTC (rev 48215)
+++ grass/trunk/lib/temporal/stvds_metadata_table.sql 2011-09-08 12:51:08 UTC (rev 48216)
@@ -24,7 +24,7 @@
A1.creation_time, A1.modification_time,
A1.revision, A2.start_time,
A2.end_time, A2.granularity,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.vector_register,
A4.number_of_maps,
A4.title, A4.description
@@ -38,7 +38,7 @@
A1.creation_time, A1.modification_time,
A1.revision,
A2.interval, A2.granularity,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.vector_register,
A4.number_of_maps,
A4.title, A4.description
Modified: grass/trunk/lib/temporal/test.temporal.py
===================================================================
--- grass/trunk/lib/temporal/test.temporal.py 2011-09-08 12:50:12 UTC (rev 48215)
+++ grass/trunk/lib/temporal/test.temporal.py 2011-09-08 12:51:08 UTC (rev 48216)
@@ -672,6 +672,71 @@
# Print self info
strds.print_self()
+
+def test_str3ds_dataset():
+
+ name = "str3ds_test_1"
+ mapset = grass.gisenv()["MAPSET"]
+
+ print "Create a str3ds object"
+
+ # We need to specify the name and the mapset as identifier
+ str3ds = space_time_raster3d_dataset(ident = name + "@" + mapset)
+ # Check if in db
+ print "Is str3ds in db: ", str3ds.is_in_db()
+ # Create a new entry if not in db
+ if str3ds.is_in_db() == False:
+ str3ds.set_initial_values(temporal_type = "absolute", granularity="1 day",\
+ semantic_type="event", title="This is a test space time raster3d dataset", description="A space time raster3d dataset for testing")
+ str3ds.insert()
+
+ # Reread the data from the db
+ str3ds.select()
+ # Print self info
+ str3ds.print_self()
+
+ # Create a test maps
+ for i in range(11):
+ i = i + 1
+ grass.raster3d.mapcalc3d("test" + str(i) + " = sin(x()) + cos(y()) + z()", overwrite = True)
+
+ name = "test" + str(i)
+ mapset = grass.gisenv()["MAPSET"]
+ ident = name + "@" + mapset
+
+ print "Create a raster3d object"
+
+ # We need to specify the name and the mapset as identifier
+ r3ds = raster3d_dataset(ident)
+
+ # Load data from the raster map in the mapset
+ r3ds.load()
+
+ print "Is raster in db: ", r3ds.is_in_db()
+
+ if r3ds.is_in_db():
+ r3ds.select()
+ r3ds.print_self()
+ # Remove the entry if it is in the db
+ r3ds.delete()
+ r3ds.reset(ident)
+ r3ds.load()
+
+ # Set the absolute valid time
+ r3ds.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
+ r3ds.insert()
+ # Register the map in the space time raster dataset
+ str3ds.register_map(r3ds)
+ # Print self info
+ r3ds.print_self()
+
+ str3ds.select()
+ # Print self info
+ str3ds.print_self()
+
+
#test_dict_sql_serializer()
create_temporal_database()
#test_dataset_identifer()
@@ -685,4 +750,5 @@
#test_raster3d_dataset()
#test_vector_dataset()
-test_strds_dataset()
\ No newline at end of file
+#test_strds_dataset()
+test_str3ds_dataset()
\ No newline at end of file
Modified: grass/trunk/lib/temporal/vector_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/vector_metadata_table.sql 2011-09-08 12:50:12 UTC (rev 48215)
+++ grass/trunk/lib/temporal/vector_metadata_table.sql 2011-09-08 12:51:08 UTC (rev 48216)
@@ -24,7 +24,7 @@
A1.creation_time, A1.modification_time,
A1.revision, A1.creator,
A2.start_time, A2.end_time,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.stvds_register
FROM vector_base A1, vector_absolute_time A2,
vector_spatial_extent A3, vector_metadata A4
@@ -36,7 +36,7 @@
A1.creation_time, A1.modification_time,
A1.revision, A1.creator,
A2.interval,
- A3.north, A3.south, A3.east, A3.west,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
A4.stvds_register
FROM vector_base A1, vector_relative_time A2,
vector_spatial_extent A3, vector_metadata A4
More information about the grass-commit
mailing list