[GRASS-SVN] r50284 - in grass/trunk/lib/temporal: . SQL src
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jan 18 19:11:22 EST 2012
Author: huhabla
Date: 2012-01-18 16:11:22 -0800 (Wed, 18 Jan 2012)
New Revision: 50284
Added:
grass/trunk/lib/temporal/SQL/
grass/trunk/lib/temporal/SQL/map_stds_register_table_template.sql
grass/trunk/lib/temporal/SQL/map_tables_template.sql
grass/trunk/lib/temporal/SQL/raster3d_metadata_table.sql
grass/trunk/lib/temporal/SQL/raster_metadata_table.sql
grass/trunk/lib/temporal/SQL/sqlite3_delete_trigger.sql
grass/trunk/lib/temporal/SQL/stds_map_register_table_template.sql
grass/trunk/lib/temporal/SQL/stds_raster3d_register_trigger_template.sql
grass/trunk/lib/temporal/SQL/stds_raster_register_trigger_template.sql
grass/trunk/lib/temporal/SQL/stds_tables_template.sql
grass/trunk/lib/temporal/SQL/stds_vector_register_trigger_template.sql
grass/trunk/lib/temporal/SQL/str3ds_metadata_table.sql
grass/trunk/lib/temporal/SQL/strds_metadata_table.sql
grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql
grass/trunk/lib/temporal/SQL/test.temporal.py
grass/trunk/lib/temporal/SQL/update_stds_spatial_temporal_extent_template.sql
grass/trunk/lib/temporal/SQL/update_str3ds_metadata_template.sql
grass/trunk/lib/temporal/SQL/update_strds_metadata_template.sql
grass/trunk/lib/temporal/SQL/update_stvds_metadata_template.sql
grass/trunk/lib/temporal/SQL/vector_metadata_table.sql
grass/trunk/lib/temporal/src/
grass/trunk/lib/temporal/src/Makefile
grass/trunk/lib/temporal/src/connect.c
grass/trunk/lib/temporal/src/default_name.c
Removed:
grass/trunk/lib/temporal/map_stds_register_table_template.sql
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/sqlite3_delete_trigger.sql
grass/trunk/lib/temporal/stds_map_register_table_template.sql
grass/trunk/lib/temporal/stds_raster3d_register_trigger_template.sql
grass/trunk/lib/temporal/stds_raster_register_trigger_template.sql
grass/trunk/lib/temporal/stds_tables_template.sql
grass/trunk/lib/temporal/stds_vector_register_trigger_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/update_stds_spatial_temporal_extent_template.sql
grass/trunk/lib/temporal/update_str3ds_metadata_template.sql
grass/trunk/lib/temporal/update_strds_metadata_template.sql
grass/trunk/lib/temporal/update_stvds_metadata_template.sql
grass/trunk/lib/temporal/vector_metadata_table.sql
Modified:
grass/trunk/lib/temporal/Makefile
Log:
New directory structure. Added temporal C-library with temporal database init functions.
Modified: grass/trunk/lib/temporal/Makefile
===================================================================
--- grass/trunk/lib/temporal/Makefile 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/Makefile 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,17 +1,13 @@
MODULE_TOPDIR = ../..
-include $(MODULE_TOPDIR)/include/Make/Other.make
+include $(MODULE_TOPDIR)/include/Make/Vars.make
-SQLDIR = $(ETC)/sql
+#order is relevant:
+SUBDIRS = \
+ SQL \
+ src
-SQLFILES:= $(wildcard *.sql)
+include $(MODULE_TOPDIR)/include/Make/Dir.make
-DSTFILES := $(patsubst %.sql,$(SQLDIR)/%.sql,$(SQLFILES))
+default: subdirs
-default: $(DSTFILES)
-
-$(SQLDIR):
- $(MKDIR) $@
-
-$(SQLDIR)/%.sql: %.sql | $(SQLDIR)
- $(INSTALL_DATA) $< $@
Copied: grass/trunk/lib/temporal/SQL/map_stds_register_table_template.sql (from rev 50164, grass/trunk/lib/temporal/map_stds_register_table_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/map_stds_register_table_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/map_stds_register_table_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,38 @@
+--#############################################################################
+-- This SQL script generates the table listing all STDS in
+-- which the GRASS_MAP map is registered
+--
+-- This table is map specific and created for each GRASS_MAP map which is registered
+-- in a STDS. TABLE_NAME is a placeholder for the table name which must be unique.
+-- A uuid is used as unique identifier across mapsets.
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+--PRAGMA foreign_keys = ON;
+
+-- TABLE_NAME is a placeholder for specific table name (SQL compliant)
+-- MAP_ID is a placeholder for specific map id: name at mapset
+-- GRASS_MAP is a placeholder for specific map type: raster, raster3d or vector
+-- STDS is a placeholder for specific space-time dataset type: strds, str3ds, stvds
+
+-- This table stores the names of the space-time datasets in which this map is registered
+CREATE TABLE TABLE_NAME_STDS_register (
+ id VARCHAR NOT NULL, -- This column is a primary foreign key storing the STDS names
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES STDS_base (id) ON DELETE CASCADE
+);
+
+--CREATE TRIGGER TABLE_NAME_STDS_register_insert AFTER INSERT ON TABLE_NAME_STDS_register
+-- BEGIN
+-- UPDATE GRASS_MAP_base SET modification_time = datetime("NOW") WHERE GRASS_MAP_base.id = 'MAP_ID';
+-- UPDATE GRASS_MAP_base SET revision = (revision + 1) WHERE GRASS_MAP_base.id = 'MAP_ID';
+-- END;
+
+--CREATE TRIGGER TABLE_NAME_STDS_register_delete AFTER DELETE ON TABLE_NAME_STDS_register
+-- BEGIN
+-- UPDATE GRASS_MAP_base SET modification_time = datetime("NOW") WHERE GRASS_MAP_base.id = 'MAP_ID';
+-- UPDATE GRASS_MAP_base SET revision = (revision + 1) WHERE GRASS_MAP_base.id = 'MAP_ID';
+-- END;
+
+
Copied: grass/trunk/lib/temporal/SQL/map_tables_template.sql (from rev 50164, grass/trunk/lib/temporal/map_tables_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/map_tables_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/map_tables_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,83 @@
+--#############################################################################
+-- This SQL script generates the grass map tables to store time stamps, revision
+-- and spatial extent for SQL queries and temporal GIS support.
+-- Additionally several triggers are created for convenient functions
+-- The grass map metadata is map specific (raster, raster3d and vector maps are
+-- supported)
+--
+-- The placeholder GRASS_MAP will be replaced by raster, raster3d and vector
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- GRASS_MAP is a placeholder for specific map type: raster, raster3d or vector
+
+--PRAGMA foreign_keys = ON;
+
+CREATE TABLE GRASS_MAP_base (
+ id VARCHAR NOT NULL, -- The id (PK) is the unique identifier for all tables, it is based on name and mapset (name at mapset) and is used as primary key
+ name VARCHAR NOT NULL, -- name of the grass map
+ mapset VARCHAR NOT NULL, -- mapset of the grass map
+ creator VARCHAR NOT NULL,
+ temporal_type VARCHAR, -- The temporal type of the grass map "absolute" or "relative" or NULL in case no time stamp is available
+ creation_time TIMESTAMP NOT NULL, -- The time of creation of the grass map
+-- Uncommented due to performance issues
+-- modification_time TIMESTAMP NOT NULL, -- The time of the last modification of the grass map
+-- revision SMALLINT NOT NULL, -- The revision number
+ PRIMARY KEY (id)
+);
+
+-- Relative valid time interval with start and end time
+CREATE TABLE GRASS_MAP_relative_time (
+ 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
+ start_time DOUBLE PRECISION, -- The relative valid start time in [days]
+ end_time DOUBLE PRECISION, -- The relative valid end time in [days]
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES GRASS_MAP_base (id) ON DELETE CASCADE
+);
+
+CREATE TABLE GRASS_MAP_absolute_time (
+ 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
+ start_time TIMESTAMP, -- Start of the valid time, can be NULL if no time information is available
+ end_time TIMESTAMP, -- End of the valid time, can be NULL if no time information is available or valid time is a single point in time
+ timezone SMALLINT, -- The timezone of the valid time
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES GRASS_MAP_base (id) ON DELETE CASCADE
+);
+
+-- The spatial extent of a raster map
+
+CREATE TABLE GRASS_MAP_spatial_extent (
+ 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 foreigen key
+ -- below is the spatial extent of the map
+ north DOUBLE PRECISION NOT NULL,
+ south DOUBLE PRECISION NOT NULL,
+ east DOUBLE PRECISION NOT NULL,
+ west DOUBLE PRECISION NOT NULL,
+ top DOUBLE PRECISION NOT NULL,
+ bottom DOUBLE PRECISION NOT NULL,
+ proj VARCHAR,
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES GRASS_MAP_base (id) ON DELETE CASCADE
+);
+
+-- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
+
+--CREATE TRIGGER update_GRASS_MAP_absolute_time AFTER UPDATE ON GRASS_MAP_absolute_time
+-- BEGIN
+-- UPDATE GRASS_MAP_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE GRASS_MAP_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
+
+--CREATE TRIGGER update_GRASS_MAP_relative_time AFTER UPDATE ON GRASS_MAP_relative_time
+-- BEGIN
+-- UPDATE GRASS_MAP_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE GRASS_MAP_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
+
+
+--CREATE TRIGGER update_GRASS_MAP_spatial_extent AFTER UPDATE ON GRASS_MAP_spatial_extent
+-- BEGIN
+-- UPDATE GRASS_MAP_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE GRASS_MAP_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
Copied: grass/trunk/lib/temporal/SQL/raster3d_metadata_table.sql (from rev 50164, grass/trunk/lib/temporal/raster3d_metadata_table.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/raster3d_metadata_table.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/raster3d_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,74 @@
+--#############################################################################
+-- This SQL script generates the raster3d metadata table to store
+-- and metadata for SQL queries and temporal GIS support. Additionally two views
+-- are created to access all map specific tables
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+--PRAGMA foreign_keys = ON;
+
+-- The metadata table reflects most of the raster3d metadata available in grass
+
+CREATE TABLE raster3d_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
+ str3ds_register VARCHAR, -- The name of the table storing all space-time raster3d datasets in which this map is registered
+ datatype VARCHAR NOT NULL,
+ cols INTEGER NOT NULL,
+ rows INTEGER NOT NULL,
+ depths INTEGER NOT NULL,
+ number_of_cells INTEGER NOT NULL,
+ nsres DOUBLE PRECISION NOT NULL,
+ ewres DOUBLE PRECISION NOT NULL,
+ tbres DOUBLE PRECISION NOT NULL,
+ min DOUBLE PRECISION,
+ max DOUBLE PRECISION,
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES raster3d_base (id) ON DELETE CASCADE
+);
+
+-- Create the views to access all cols for the absolute and relative time
+
+CREATE VIEW raster3d_view_abs_time AS SELECT
+ A1.id, A1.mapset,
+ A1.name, A1.temporal_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time, A2.timezone,
+ 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,
+ A4.str3ds_register,
+ A4.number_of_cells
+ FROM raster3d_base A1, raster3d_absolute_time A2,
+ raster3d_spatial_extent A3, raster3d_metadata A4
+ WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW raster3d_view_rel_time AS SELECT
+ A1.id, A1.mapset,
+ A1.name, A1.temporal_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time,
+ 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,
+ A4.str3ds_register,
+ A4.number_of_cells
+ FROM raster3d_base A1, raster3d_relative_time A2,
+ raster3d_spatial_extent A3, raster3d_metadata A4
+ WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
+
+-- Create a trigger to update the modification time and revision number in case the metadata have been updated
+
+--CREATE TRIGGER update_raster3d_metadata AFTER UPDATE ON raster3d_metadata
+-- BEGIN
+-- UPDATE raster3d_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE raster3d_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
Copied: grass/trunk/lib/temporal/SQL/raster_metadata_table.sql (from rev 50164, grass/trunk/lib/temporal/raster_metadata_table.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/raster_metadata_table.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/raster_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,71 @@
+--#############################################################################
+-- This SQL script generates the raster metadata table to store
+-- and metadata for SQL queries and temporal GIS support. Additionally two views
+-- are created to access all map specific tables
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+--PRAGMA foreign_keys = ON;
+
+-- The metadata table reflects most of the raster metadata available in grass
+
+CREATE TABLE raster_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
+ strds_register VARCHAR, -- The name of the table storing all space-time raster datasets in which this map is registered
+ datatype VARCHAR NOT NULL,
+ cols INTEGER NOT NULL,
+ rows INTEGER NOT NULL,
+ number_of_cells INTEGER NOT NULL,
+ nsres DOUBLE PRECISION NOT NULL,
+ ewres DOUBLE PRECISION NOT NULL,
+ min DOUBLE PRECISION,
+ max DOUBLE PRECISION,
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES raster_base (id) ON DELETE CASCADE
+);
+
+-- Create the views to access all cols for the absolute and relative time
+
+CREATE VIEW raster_view_abs_time AS SELECT
+ A1.id, A1.mapset,
+ A1.name, A1.temporal_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time, A2.timezone,
+ 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,
+ A4.number_of_cells
+ FROM raster_base A1, raster_absolute_time A2,
+ raster_spatial_extent A3, raster_metadata A4
+ WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW raster_view_rel_time AS SELECT
+ A1.id, A1.mapset,
+ A1.name, A1.temporal_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time,
+ 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,
+ A4.number_of_cells
+ FROM raster_base A1, raster_relative_time A2,
+ raster_spatial_extent A3, raster_metadata A4
+ WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
+
+-- Create a trigger to update the modification time and revision number in case the metadata have been updated
+-- Uncommented due to performance issues
+--CREATE TRIGGER update_raster_metadata AFTER UPDATE ON raster_metadata
+-- BEGIN
+-- UPDATE raster_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE raster_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
+
Copied: grass/trunk/lib/temporal/SQL/sqlite3_delete_trigger.sql (from rev 50164, grass/trunk/lib/temporal/sqlite3_delete_trigger.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/sqlite3_delete_trigger.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/sqlite3_delete_trigger.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,51 @@
+
+-- Create trigger for automated deletion of dependent rows, this should normally be done using foreign keys
+
+CREATE TRIGGER delete_strds_base AFTER DELETE ON strds_base
+ BEGIN
+ DELETE FROM strds_absolute_time WHERE id = old.id;
+ DELETE FROM strds_relative_time WHERE id = old.id;
+ DELETE FROM strds_spatial_extent WHERE id = old.id;
+ DELETE FROM strds_metadata WHERE id = old.id;
+ END;
+
+CREATE TRIGGER delete_raster_base AFTER DELETE ON raster_base
+ BEGIN
+ DELETE FROM raster_absolute_time WHERE id = old.id;
+ DELETE FROM raster_relative_time WHERE id = old.id;
+ DELETE FROM raster_spatial_extent WHERE id = old.id;
+ DELETE FROM raster_metadata WHERE id = old.id;
+ END;
+
+CREATE TRIGGER delete_str3ds_base AFTER DELETE ON str3ds_base
+ BEGIN
+ DELETE FROM str3ds_absolute_time WHERE id = old.id;
+ DELETE FROM str3ds_relative_time WHERE id = old.id;
+ DELETE FROM str3ds_spatial_extent WHERE id = old.id;
+ DELETE FROM str3ds_metadata WHERE id = old.id;
+ END;
+
+CREATE TRIGGER delete_raster3d_base AFTER DELETE ON raster3d_base
+ BEGIN
+ DELETE FROM raster3d_absolute_time WHERE id = old.id;
+ DELETE FROM raster3d_relative_time WHERE id = old.id;
+ DELETE FROM raster3d_spatial_extent WHERE id = old.id;
+ DELETE FROM raster3d_metadata WHERE id = old.id;
+ END;
+
+CREATE TRIGGER delete_stvds_base AFTER DELETE ON stvds_base
+ BEGIN
+ DELETE FROM stvds_absolute_time WHERE id = old.id;
+ DELETE FROM stvds_relative_time WHERE id = old.id;
+ DELETE FROM stvds_spatial_extent WHERE id = old.id;
+ DELETE FROM stvds_metadata WHERE id = old.id;
+ END;
+
+CREATE TRIGGER delete_vector_base AFTER DELETE ON vector_base
+ BEGIN
+ DELETE FROM vector_absolute_time WHERE id = old.id;
+ DELETE FROM vector_relative_time WHERE id = old.id;
+ DELETE FROM vector_spatial_extent WHERE id = old.id;
+ DELETE FROM vector_metadata WHERE id = old.id;
+ END;
+
Copied: grass/trunk/lib/temporal/SQL/stds_map_register_table_template.sql (from rev 50164, grass/trunk/lib/temporal/stds_map_register_table_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/stds_map_register_table_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/stds_map_register_table_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,129 @@
+--#############################################################################
+-- This SQL script generates the table in which all registered GRASS_MAP maps
+-- are listed in.
+--
+-- This table will be created for each STDS.
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- 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
+-- GRASS_MAP is a placeholder for specific map type: raster, raster3d or vector
+-- STDS is a placeholder for specific space-time dataset type: strds, str3ds, stvds
+
+--PRAGMA foreign_keys = ON;
+
+-- This table stores the.ids of the GRASS_MAP maps registered in the current spacetime GRASS_MAP table
+CREATE TABLE SPACETIME_NAME_GRASS_MAP_register (
+ id VARCHAR NOT NULL, -- This colum is a primary foreign key storing the registered GRASS_MAP map.ids
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES GRASS_MAP_base (id) ON DELETE CASCADE
+);
+
+-- Triggers are disabled due to huge performance issues
+--CREATE TRIGGER SPACETIME_NAME_GRASS_MAP_register_insert_trigger AFTER INSERT ON SPACETIME_NAME_GRASS_MAP_register
+-- BEGIN
+-- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = 'SPACETIME_ID';
+-- UPDATE STDS_base SET revision = (revision + 1) WHERE id = 'SPACETIME_ID';
+-- -- Number of registered maps
+-- UPDATE STDS_metadata SET number_of_maps =
+-- (SELECT count(id) FROM SPACETIME_NAME_GRASS_MAP_register)
+-- WHERE id = 'SPACETIME_ID';
+-- -- Update the temporal extent
+-- UPDATE STDS_absolute_time SET start_time =
+-- (SELECT min(start_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
+-- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE STDS_absolute_time SET end_time =
+-- (SELECT max(end_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
+-- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+-- ) WHERE id = 'SPACETIME_ID';
+
+-- UPDATE STDS_relative_time SET start_time =
+-- (SELECT min(start_time) FROM GRASS_MAP_relative_time WHERE GRASS_MAP_relative_time.id IN
+-- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE STDS_relative_time SET end_time =
+-- (SELECT max(end_time) FROM GRASS_MAP_relative_time WHERE GRASS_MAP_relative_time.id IN
+-- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- -- Update the spatial extent
+-- UPDATE STDS_spatial_extent SET north =
+-- (SELECT max(north) 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 south =
+-- (SELECT min(south) 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 east =
+-- (SELECT max(east) 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 west =
+-- (SELECT min(west) 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 top =
+-- (SELECT max(top) 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 bottom =
+-- (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
+-- BEGIN
+-- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = 'SPACETIME_ID';
+-- UPDATE STDS_base SET revision = (revision + 1) WHERE id = 'SPACETIME_ID';
+-- -- Number of registered maps
+-- UPDATE STDS_metadata SET number_of_maps =
+-- (SELECT count(id) FROM SPACETIME_NAME_GRASS_MAP_register)
+-- WHERE id = 'SPACETIME_ID';
+-- -- Update the temporal extent
+-- UPDATE STDS_absolute_time SET start_time =
+-- (SELECT min(start_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
+-- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE STDS_absolute_time SET end_time =
+-- (SELECT max(end_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
+-- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- -- Update the spatial extent
+-- UPDATE STDS_spatial_extent SET north =
+-- (SELECT max(north) 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 south =
+-- (SELECT min(south) 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 east =
+-- (SELECT max(east) 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 west =
+-- (SELECT min(west) 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 top =
+-- (SELECT max(top) 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 bottom =
+-- (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;
+--
Copied: grass/trunk/lib/temporal/SQL/stds_raster3d_register_trigger_template.sql (from rev 50164, grass/trunk/lib/temporal/stds_raster3d_register_trigger_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/stds_raster3d_register_trigger_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/stds_raster3d_register_trigger_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,113 @@
+--#############################################################################
+-- This SQL script creates a trigger to update a space-time raster3d dataset
+-- metadata
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- 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
+
+--PRAGMA foreign_keys = ON;
+
+-- Triggers are disabled due to huge performance issues
+--CREATE TRIGGER SPACETIME_NAME_raster3d_metadata_register_insert_trigger AFTER INSERT ON SPACETIME_NAME_raster3d_register
+-- BEGIN
+-- -- Update the min and max values
+-- UPDATE str3ds_metadata SET min_min =
+-- (SELECT min(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET min_max =
+-- (SELECT max(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET max_min =
+-- (SELECT min(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET max_max =
+-- (SELECT max(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- -- Update the resolution
+-- UPDATE str3ds_metadata SET nsres_min =
+-- (SELECT min(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET nsres_max =
+-- (SELECT max(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET ewres_min =
+-- (SELECT min(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET ewres_max =
+-- (SELECT max(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET tbres_min =
+-- (SELECT min(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET tbres_max =
+-- (SELECT max(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- END;
+--
+--CREATE TRIGGER SPACETIME_NAME_raster3d_metadata_register_delete_trigger AFTER DELETE ON SPACETIME_NAME_raster3d_register
+-- BEGIN
+-- -- Update the min and max values
+-- UPDATE str3ds_metadata SET min_min =
+-- (SELECT min(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET min_max =
+-- (SELECT max(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET max_min =
+-- (SELECT min(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET max_max =
+-- (SELECT max(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- -- Update the resolution
+-- UPDATE str3ds_metadata SET nsres_min =
+-- (SELECT min(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET nsres_max =
+-- (SELECT max(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET ewres_min =
+-- (SELECT min(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET ewres_max =
+-- (SELECT max(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET tbres_min =
+-- (SELECT min(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE str3ds_metadata SET tbres_max =
+-- (SELECT max(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster3d_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- END;
+--
+--
+--
+--
+--
+--
+--
+--
+--
Copied: grass/trunk/lib/temporal/SQL/stds_raster_register_trigger_template.sql (from rev 50164, grass/trunk/lib/temporal/stds_raster_register_trigger_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/stds_raster_register_trigger_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/stds_raster_register_trigger_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,113 @@
+--#############################################################################
+-- This SQL script creates a trigger to update a space-time raster dataset
+-- metadata
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- 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
+
+--PRAGMA foreign_keys = ON;
+
+-- Triggers are disabled due to huge performance issues
+--CREATE TRIGGER SPACETIME_NAME_raster_metadata_register_insert_trigger AFTER INSERT ON SPACETIME_NAME_raster_register
+-- BEGIN
+-- -- Update the min and max values
+-- UPDATE strds_metadata SET min_min =
+-- (SELECT min(min) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET min_max =
+-- (SELECT max(min) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET max_min =
+-- (SELECT min(max) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET max_max =
+-- (SELECT max(max) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- -- Update the resolution
+-- UPDATE strds_metadata SET nsres_min =
+-- (SELECT min(nsres) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET nsres_max =
+-- (SELECT max(nsres) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET ewres_min =
+-- (SELECT min(ewres) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET ewres_max =
+-- (SELECT max(ewres) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- END;
+--
+--CREATE TRIGGER SPACETIME_NAME_raster_metadata_register_delete_trigger AFTER DELETE ON SPACETIME_NAME_raster_register
+-- BEGIN
+-- -- Update the min and max values
+-- UPDATE strds_metadata SET min_min =
+-- (SELECT min(min) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET min_max =
+-- (SELECT max(min) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET max_min =
+-- (SELECT min(max) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET max_max =
+-- (SELECT max(max) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- -- Update the resolution
+-- UPDATE strds_metadata SET nsres_min =
+-- (SELECT min(nsres) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET nsres_max =
+-- (SELECT max(nsres) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET ewres_min =
+-- (SELECT min(ewres) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- UPDATE strds_metadata SET ewres_max =
+-- (SELECT max(ewres) FROM raster_metadata WHERE raster_metadata.id IN
+-- (SELECT id FROM SPACETIME_NAME_raster_register)
+-- ) WHERE id = 'SPACETIME_ID';
+-- END;
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
+--
Copied: grass/trunk/lib/temporal/SQL/stds_tables_template.sql (from rev 50164, grass/trunk/lib/temporal/stds_tables_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/stds_tables_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/stds_tables_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,79 @@
+--#############################################################################
+-- This SQL script generates the space time dataset tables to store time
+-- stamps and revision for SQL queries and temporal GIS support.
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- STDS is a placeholder for specific space-time dataset type: strds, str3ds, stvds
+
+--PRAGMA foreign_keys = ON;
+
+CREATE TABLE STDS_base (
+ id VARCHAR NOT NULL, -- Id of the space-time dataset, name at mapset this is the primary key
+ name VARCHAR NOT NULL, -- name of the space-time dataset
+ mapset VARCHAR NOT NULL, -- mapset of the space-time dataset
+ creator VARCHAR NOT NULL, -- Name of the creator
+ temporal_type VARCHAR NOT NULL, -- The temporal type of the dataset "absolute" or "relative"
+ semantic_type VARCHAR NOT NULL, -- The semantic data description used for aggregation/decomposition algorithm selection
+ creation_time TIMESTAMP NOT NULL, -- The time of creation of the space-time dataset
+-- Uncommented due to performance issues
+-- modification_time TIMESTAMP NOT NULL, -- The time of the last modification of the grass map
+-- revision SMALLINT NOT NULL, -- The revision number -- The revision number
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE STDS_relative_time (
+ id VARCHAR NOT NULL, -- Id of the space-time dataset, this is the primary foreign key
+ start_time DOUBLE PRECISION, -- The relative valid start time in [days]
+ end_time DOUBLE PRECISION, -- The relative valid end time in [days]
+ granularity DOUBLE PRECISION, -- The granularity in [days]
+ map_time VARCHAR, -- The temporal type of the registered maps, may be interval, point or mixed
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES STDS_base (id) ON DELETE CASCADE
+);
+
+CREATE TABLE STDS_absolute_time (
+ id VARCHAR NOT NULL, -- Id of the space-time dataset, this is the primary foreign key
+ start_time TIMESTAMP, -- Start of the valid time, can be NULL if no map is registered
+ end_time TIMESTAMP, -- End of the valid time, can be NULL if no map is registered
+ granularity VARCHAR, -- The granularity "NNN seconds, NNN minutes, NNN hours, NNN days, NNN weeks, NNN months, NNN years"
+ timezone SMALLINT, -- The time zone number
+ map_time VARCHAR, -- The temporal type of the registered maps, may be interval, point or mixed
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES STDS_base (id) ON DELETE CASCADE
+);
+
+CREATE TABLE STDS_spatial_extent (
+ id VARCHAR NOT NULL, -- Id of the space-time dataset, this is the primary foreign key
+ north DOUBLE PRECISION, -- The spatial north extent, derived from the registered maps
+ south DOUBLE PRECISION, -- The spatial south extent, derived from the registered maps
+ east DOUBLE PRECISION, -- The spatial east extent, derived from the registered maps
+ 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 VARCHAR, -- The projection of the space time dataset (XY of LL)
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES STDS_base (id) ON DELETE CASCADE
+);
+
+-- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
+-- Uncommented due to performance issues
+--CREATE TRIGGER update_STDS_abs_time AFTER UPDATE ON STDS_absolute_time
+-- BEGIN
+-- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE STDS_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
+
+--CREATE TRIGGER update_STDS_rel_time AFTER UPDATE ON STDS_relative_time
+-- BEGIN
+-- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE STDS_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
+
+--CREATE TRIGGER update_STDS_spatial_extent AFTER UPDATE ON STDS_spatial_extent
+-- BEGIN
+-- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE STDS_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
+
Copied: grass/trunk/lib/temporal/SQL/stds_vector_register_trigger_template.sql (from rev 50164, grass/trunk/lib/temporal/stds_vector_register_trigger_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/stds_vector_register_trigger_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/stds_vector_register_trigger_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,6 @@
+--#############################################################################
+-- This SQL script is for now a placeholder, till the vector metadata
+-- concept is clear
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
\ No newline at end of file
Copied: grass/trunk/lib/temporal/SQL/str3ds_metadata_table.sql (from rev 50164, grass/trunk/lib/temporal/str3ds_metadata_table.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/str3ds_metadata_table.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/str3ds_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,80 @@
+--#############################################################################
+-- This SQL script generates the space time raster3d dataset metadata table,
+-- view and trigger
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+--PRAGMA foreign_keys = ON;
+
+CREATE TABLE str3ds_metadata (
+ id VARCHAR NOT NULL, -- Id of the space-time raster3d dataset, this is the primary foreign key
+ raster3d_register VARCHAR, -- The id of the table in which the raster3d maps are registered for this dataset
+ number_of_maps INTEGER, -- The number of registered raster3d maps
+ max_min DOUBLE PRECISION, -- The minimal maximum of the registered raster3d maps
+ min_min DOUBLE PRECISION, -- The minimal minimum of the registered raster3d maps
+ max_max DOUBLE PRECISION, -- The maximal maximum of the registered raster3d maps
+ min_max DOUBLE PRECISION, -- The maximal minimum of the registered raster3d maps
+ nsres_min DOUBLE PRECISION, -- The lowest north-south resolution of the registered raster3d maps
+ nsres_max DOUBLE PRECISION, -- The highest north-south resolution of the registered raster3d maps
+ ewres_min DOUBLE PRECISION, -- The lowest east-west resolution of the registered raster3d maps
+ ewres_max DOUBLE PRECISION, -- The highest east-west resolution of the registered raster3d maps
+ tbres_min DOUBLE PRECISION, -- The lowest top-bottom resolution of the registered raster3d maps
+ tbres_max DOUBLE PRECISION, -- The highest top-bottom resolution of the registered raster3d maps
+ title VARCHAR, -- Title of the space-time raster3d dataset
+ description VARCHAR, -- Detailed description of the space-time raster3d dataset
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES str3ds_base (id) ON DELETE CASCADE
+);
+-- Create the views to access all cols for absolute or relative time
+
+CREATE VIEW str3ds_view_abs_time AS SELECT
+ A1.id, A1.name, A1.mapset, A1.temporal_type,
+ A1.semantic_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time, A2.timezone, A2.granularity,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
+ A4.raster3d_register,
+ A4.number_of_maps,
+ A4.nsres_min, A4.ewres_min,
+ A4.nsres_max, A4.ewres_max,
+ A4.tbres_min, A4.tbres_max,
+ A4.min_min, A4.min_max,
+ A4.max_min, A4.max_max,
+ A4.title, A4.description
+ FROM str3ds_base A1, str3ds_absolute_time A2,
+ str3ds_spatial_extent A3, str3ds_metadata A4 WHERE A1.id = A2.id AND
+ A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW str3ds_view_rel_time AS SELECT
+ A1.id, A1.name, A1.mapset, A1.temporal_type,
+ A1.semantic_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time, A2.granularity,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
+ A4.raster3d_register,
+ A4.number_of_maps,
+ A4.nsres_min, A4.ewres_min,
+ A4.nsres_max, A4.ewres_max,
+ A4.tbres_min, A4.tbres_max,
+ A4.min_min, A4.min_max,
+ A4.max_min, A4.max_max,
+ A4.title, A4.description
+ FROM str3ds_base A1, str3ds_relative_time A2,
+ str3ds_spatial_extent A3, str3ds_metadata A4 WHERE A1.id = A2.id AND
+ A1.id = A3.id AND A1.id = A4.id;
+
+
+-- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
+-- Uncommented due to performance issues
+--CREATE TRIGGER update_str3ds_metadata AFTER UPDATE ON str3ds_metadata
+-- BEGIN
+-- UPDATE str3ds_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE str3ds_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
Copied: grass/trunk/lib/temporal/SQL/strds_metadata_table.sql (from rev 50164, grass/trunk/lib/temporal/strds_metadata_table.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/strds_metadata_table.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/strds_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,76 @@
+--#############################################################################
+-- This SQL script generates the space time raster dataset metadata table,
+-- view and trigger
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+--PRAGMA foreign_keys = ON;
+
+CREATE TABLE strds_metadata (
+ id VARCHAR NOT NULL, -- Id of the space-time dataset, this is the primary foreign key
+ raster_register VARCHAR, -- The id of the table in which the raster maps are registered for this dataset
+ number_of_maps INTEGER, -- The number of registered raster maps
+ max_min DOUBLE PRECISION, -- The minimal maximum of the registered raster maps
+ min_min DOUBLE PRECISION, -- The minimal minimum of the registered raster maps
+ max_max DOUBLE PRECISION, -- The maximal maximum of the registered raster maps
+ min_max DOUBLE PRECISION, -- The maximal minimum of the registered raster maps
+ nsres_min DOUBLE PRECISION, -- The lowest north-south resolution of the registered raster maps
+ nsres_max DOUBLE PRECISION, -- The highest north-south resolution of the registered raster maps
+ ewres_min DOUBLE PRECISION, -- The lowest east-west resolution of the registered raster maps
+ ewres_max DOUBLE PRECISION, -- The highest east-west resolution of the registered raster maps
+ title VARCHAR, -- Title of the space-time raster dataset
+ description VARCHAR, -- Detailed description of the space-time raster dataset
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES strds_base (id) ON DELETE CASCADE
+);
+-- Create the views to access all cols for absolute or relative time
+
+CREATE VIEW strds_view_abs_time AS SELECT
+ A1.id, A1.name, A1.mapset, A1.temporal_type,
+ A1.semantic_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time, A2.timezone, A2.granularity,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
+ A4.raster_register,
+ A4.number_of_maps,
+ A4.nsres_min, A4.ewres_min,
+ A4.nsres_max, A4.ewres_max,
+ A4.min_min, A4.min_max,
+ A4.max_min, A4.max_max,
+ A4.title, A4.description
+ FROM strds_base A1, strds_absolute_time A2,
+ strds_spatial_extent A3, strds_metadata A4 WHERE A1.id = A2.id AND
+ A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW strds_view_rel_time AS SELECT
+ A1.id, A1.name, A1.mapset, A1.temporal_type,
+ A1.semantic_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time, A2.granularity,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
+ A4.raster_register,
+ A4.number_of_maps,
+ A4.nsres_min, A4.ewres_min,
+ A4.nsres_max, A4.ewres_max,
+ A4.min_min, A4.min_max,
+ A4.max_min, A4.max_max,
+ A4.title, A4.description
+ FROM strds_base A1, strds_relative_time A2,
+ strds_spatial_extent A3, strds_metadata A4 WHERE A1.id = A2.id AND
+ A1.id = A3.id AND A1.id = A4.id;
+
+
+-- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
+-- Uncommented due to performance issues
+--CREATE TRIGGER update_strds_metadata AFTER UPDATE ON strds_metadata
+-- BEGIN
+-- UPDATE strds_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE strds_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
Copied: grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql (from rev 50164, grass/trunk/lib/temporal/stvds_metadata_table.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/stvds_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,61 @@
+--#############################################################################
+-- This SQL script generates the space time vector dataset metadata table,
+-- view and trigger
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+--PRAGMA foreign_keys = ON;
+
+CREATE TABLE stvds_metadata (
+ id VARCHAR NOT NULL, -- Name of the space-time vector dataset, this is the primary foreign key
+ vector_register VARCHAR, -- The id of the table in which the vector maps are registered for this dataset
+ 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
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES stvds_base (id) ON DELETE CASCADE
+);
+-- Create the views to access all columns for absolute or relative time
+
+CREATE VIEW stvds_view_abs_time AS SELECT
+ A1.id, A1.name, A1.mapset, A1.temporal_type,
+ A1.semantic_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time, A2.timezone,
+ A2.granularity,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
+ A4.vector_register,
+ A4.number_of_maps,
+ A4.title, A4.description
+ 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;
+
+CREATE VIEW stvds_view_rel_time AS SELECT
+ A1.id, A1.name, A1.mapset, A1.temporal_type,
+ A1.semantic_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time, A2.granularity,
+ A3.north, A3.south, A3.east, A3.west, A3.proj,
+ A4.vector_register,
+ A4.number_of_maps,
+ A4.title, A4.description
+ 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;
+
+
+-- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
+-- Uncommented due to performance issues
+--CREATE TRIGGER update_stvds_metadata AFTER UPDATE ON stvds_metadata
+-- BEGIN
+-- UPDATE stvds_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE stvds_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
Copied: grass/trunk/lib/temporal/SQL/test.temporal.py (from rev 50164, grass/trunk/lib/temporal/test.temporal.py)
===================================================================
--- grass/trunk/lib/temporal/SQL/test.temporal.py (rev 0)
+++ grass/trunk/lib/temporal/SQL/test.temporal.py 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,836 @@
+import os
+from grass.script.tgis_core import *
+from grass.script.tgis_base import *
+from grass.script.tgis_temporal_extent import *
+from grass.script.tgis_spatial_extent import *
+from grass.script.tgis_metadata import *
+from grass.script.tgis_abstract_datasets import *
+from grass.script.tgis_space_time_datasets import *
+import grass.script as grass
+###############################################################################
+
+def test_dict_sql_serializer():
+ t = dict_sql_serializer()
+ t.test()
+
+def test_dataset_identifer():
+ for i in range(2):
+ base = raster_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", creator="soeren", temporal_type="absolute", revision=1)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_creator("rene")
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = raster3d_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", temporal_type="absolute", creator="soeren")
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_creator("rene")
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = vector_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", temporal_type="absolute", creator="soeren")
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_creator("rene")
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = strds_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", creator="soeren", semantic_type="event", temporal_type="absolute", revision=1)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_creator("rene")
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = str3ds_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", temporal_type="absolute", semantic_type="event", creator="soeren")
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_creator("rene")
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = stvds_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", temporal_type="absolute", semantic_type="event", creator="soeren")
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_creator("rene")
+ base.update()
+ base.select()
+ base.print_self()
+
+def test_absolute_timestamp():
+ for i in range(2):
+ base = raster_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), timezone=1)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_start_time(datetime(2010,01,01))
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = raster3d_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), timezone=1)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_start_time(datetime(2010,01,01))
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = vector_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), timezone=1)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_start_time(datetime(2010,01,01))
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = strds_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), granularity="1 day", timezone=1)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_start_time(datetime(2010,01,01))
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = str3ds_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), granularity="1 day", timezone=1)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_start_time(datetime(2010,01,01))
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = stvds_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), granularity="1 day", timezone=1)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_start_time(datetime(2010,01,01))
+ base.update()
+ base.select()
+ base.print_self()
+
+def test_spatial_extent():
+ for i in range(2):
+ base = raster_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_north(120+i)
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = raster3d_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_north(120+i)
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = vector_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_north(120+i)
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = strds_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_north(120+i)
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = str3ds_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_north(120+i)
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = stvds_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_north(120+i)
+ base.update()
+ base.select()
+ base.print_self()
+
+def test_relative_timestamp():
+ for i in range(2):
+ base = raster_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_interval(i+1)
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = raster3d_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_interval(i+1)
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = vector_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_interval(i+1)
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = strds_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i, granularity=5.5)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_interval(i+1)
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = str3ds_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i, granularity=5.5)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_interval(i+1)
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = stvds_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i, granularity=5.5)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_interval(i+1)
+ base.update()
+ base.select()
+ base.print_self()
+
+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", \
+ cols=500, rows=400, number_of_cells=200000,nsres=1, ewres=1, min=0, max=33)
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_datatype("FCELL")
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ 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()
+ base.print_self()
+ base.clear()
+ base.set_datatype("DCELL")
+ base.update()
+ base.select()
+ base.print_self()
+
+ for i in range(2):
+ base = vector_metadata(ident="soil" + str(i) + "@PERMANENT", stvds_register="PERMANENT_soil_stvds_register")
+ base.insert()
+ base.select()
+ base.print_self()
+ base.clear()
+ base.set_stvds_register("PERMANENT_soil_stvds_register")
+ 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):
+ base = vector_base(ident="water" + str(i) + "@PERMANENT", name="water" + str(i), mapset="PERMANENT", creator="soeren")
+ base.insert()
+ base = raster_base(ident="water" + str(i) + "@PERMANENT", name="water" + str(i), mapset="PERMANENT", creator="soeren")
+ base.insert()
+ base = raster3d_base(ident="water" + str(i) + "@PERMANENT", name="water" + str(i), mapset="PERMANENT", creator="soeren")
+ base.insert()
+
+ for i in range(10):
+ base = vector_base(ident="water" + str(i) + "@PERMANENT")
+ base.set_creator("rene")
+ base.update()
+ base = raster_base(ident="water" + str(i) + "@PERMANENT")
+ base.set_creator("rene")
+ base.update()
+ base = raster3d_base(ident="water" + str(i) + "@PERMANENT")
+ base.set_creator("rene")
+ base.update()
+
+ for i in range(10):
+ base = vector_absolute_time(ident="water" + str(i) + "@PERMANENT", start_time=datetime.now(), end_time=datetime.now(), timezone=1)
+ base.insert()
+ base = raster_absolute_time(ident="water" + str(i) + "@PERMANENT", start_time=datetime.now(), end_time=datetime.now(), timezone=1)
+ base.insert()
+ base = raster3d_absolute_time(ident="water" + str(i) + "@PERMANENT", start_time=datetime.now(), end_time=datetime.now(), timezone=1)
+ base.insert()
+
+ for i in range(10):
+ base = vector_absolute_time(ident="water" + str(i) + "@PERMANENT")
+ base.set_start_time(datetime(2010, 6, 1))
+ base.update()
+ base = raster_absolute_time(ident="water" + str(i) + "@PERMANENT")
+ base.set_start_time(datetime(2010, 6, 1))
+ base.update()
+ base = raster3d_absolute_time(ident="water" + str(i) + "@PERMANENT")
+ base.set_start_time(datetime(2010, 6, 1))
+ base.update()
+
+ for i in range(10):
+ base = vector_spatial_extent(ident="water" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
+ base.insert()
+ base = raster_spatial_extent(ident="water" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=0, bottom=0)
+ base.insert()
+ base = raster3d_spatial_extent(ident="water" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
+ base.insert()
+
+ for i in range(10):
+ base = vector_spatial_extent(ident="water" + str(i) + "@PERMANENT")
+ base.set_north(120 + i)
+ base.set_south(20 + i)
+ base.update()
+ base = raster_spatial_extent(ident="water" + str(i) + "@PERMANENT")
+ base.set_north(120 + i)
+ base.set_south(20 + i)
+ base.update()
+ base = raster3d_spatial_extent(ident="water" + str(i) + "@PERMANENT")
+ base.set_north(120 + i)
+ base.set_south(20 + i)
+ base.update()
+
+ for i in range(10):
+ base = vector_metadata(ident="water" + str(i) + "@PERMANENT", stvds_register="PERMANENT_water_stvds_register")
+ base.insert()
+ base = raster_metadata(ident="water" + str(i) + "@PERMANENT", strds_register="PERMANENT_water_strds-register", datatype="CELL", \
+ cols=500, rows=400, number_of_cells=200000,nsres=1, ewres=1, min=0, max=33)
+ base.insert()
+ base = raster3d_metadata(ident="water" + str(i) + "@PERMANENT", str3ds_register="PERMANENT_water_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()
+
+ for i in range(10):
+ base = vector_metadata(ident="water" + str(i) + "@PERMANENT")
+ base.set_stvds_register("PERMANENT_water_stvds_register")
+ base.update()
+ base = raster_metadata(ident="water" + str(i) + "@PERMANENT")
+ base.set_datatype("DCELL")
+ base.update()
+ base = raster3d_metadata(ident="water" + str(i) + "@PERMANENT")
+ base.set_datatype("DCELL")
+ base.update()
+
+ for i in range(10):
+ base = vector_base(ident="water" + str(i) + "@PERMANENT")
+ base.select()
+ base.print_self()
+ base = raster_base(ident="water" + str(i) + "@PERMANENT")
+ base.select()
+ base.print_self()
+ base = raster3d_base(ident="water" + str(i) + "@PERMANENT")
+ base.select()
+ base.print_self()
+
+ print "Create a raster object"
+
+ rds = raster_dataset("water0 at PERMANENT")
+ rds.select()
+ rds.print_self()
+
+ print rds.temporal_relation(rds)
+
+def test_absolut_time_temporal_relations():
+
+ A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
+ end_time=datetime(year=2001, month=1, day=1), timezone=1)
+ B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2001, month=1, day=1), \
+ end_time=datetime(year=2002, month=1, day=1), timezone=1)
+
+ print "Precedes: ", A.temporal_relation(B)
+ print "Follows: ", B.temporal_relation(A)
+
+ A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
+ end_time=datetime(year=2001, month=1, day=1), timezone=1)
+ B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2001, month=1, day=2), \
+ end_time=datetime(year=2002, month=1, day=1), timezone=1)
+
+ print "Before: ", A.temporal_relation(B)
+ print "After: ", B.temporal_relation(A)
+
+ A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
+ end_time=datetime(year=2001, month=1, day=1), timezone=1)
+ B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
+ end_time=datetime(year=2002, month=1, day=1), timezone=1)
+
+ print "Starts: ", A.temporal_relation(B)
+ print "Started: ", B.temporal_relation(A)
+
+ A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
+ end_time=datetime(year=2001, month=1, day=1), timezone=1)
+ B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2000, month=1, day=2), \
+ end_time=datetime(year=2001, month=1, day=1), timezone=1)
+
+ print "Finished: ", A.temporal_relation(B)
+ print "Finishes: ", B.temporal_relation(A)
+
+ A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
+ end_time=datetime(year=2001, month=1, day=1), timezone=1)
+ B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2000, month=3, day=1), \
+ end_time=datetime(year=2000, month=9, day=1), timezone=1)
+
+ print "Contains: ", A.temporal_relation(B)
+ print "During: ", B.temporal_relation(A)
+
+
+ A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
+ end_time=datetime(year=2000, month=6, day=1), timezone=1)
+ B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2000, month=3, day=1), \
+ end_time=datetime(year=2000, month=9, day=1), timezone=1)
+
+ print "Overlap: ", A.temporal_relation(B)
+ print "Overlapped:", B.temporal_relation(A)
+
+ A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
+ end_time=datetime(year=2000, month=1, day=1), timezone=1)
+ B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
+ end_time=datetime(year=2000, month=1, day=1), timezone=1)
+
+ print "Equivalent:", A.temporal_relation(B)
+ print "Equivalent:", B.temporal_relation(A)
+
+
+def test_raster_dataset():
+
+ # Create a test map
+ grass.raster.mapcalc("test = sin(x()) + cos(y())", overwrite = True)
+
+ name = "test"
+ mapset = grass.gisenv()["MAPSET"]
+
+ 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()
+
+ 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 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()
+
+ 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)
+
+ name = "test"
+ mapset = grass.gisenv()["MAPSET"]
+
+ 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()
+
+ 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.update_from_registered_maps()
+ strds.select()
+ # Print self info
+ strds.print_self()
+ # Delete the dataset
+ strds.delete()
+
+
+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 raster3d map in the mapset
+ r3ds.load()
+
+ print "Is raster3d 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 raster3d dataset
+ str3ds.register_map(r3ds)
+ # Print self info
+ #r3ds.print_self()
+
+ str3ds.update_from_registered_maps()
+ str3ds.select()
+ # Print self info
+ str3ds.print_self()
+ # Delete the dataset
+ str3ds.delete()
+
+
+def test_stvds_dataset():
+
+ name = "stvds_test_1"
+ mapset = grass.gisenv()["MAPSET"]
+
+ print "Create a stvds object"
+
+ # We need to specify the name and the mapset as identifier
+ stvds = space_time_vector_dataset(ident = name + "@" + mapset)
+ # Check if in db
+ print "Is stvds in db: ", stvds.is_in_db()
+ # Create a new entry if not in db
+ if stvds.is_in_db() == False:
+ stvds.set_initial_values(temporal_type = "absolute", granularity="1 day",\
+ semantic_type="event", title="This is a test space time vector dataset", description="A space time vector dataset for testing")
+ stvds.insert()
+
+ # Reread the data from the db
+ stvds.select()
+ # Print self info
+ #stvds.print_self()
+
+ # Create a test maps
+ for i in range(11):
+ name = "test" + str(i)
+ mapset = grass.gisenv()["MAPSET"]
+ ident = name + "@" + mapset
+
+ i = i + 1
+ grass.run_command("v.random", output=name, n=100, zmin=0, zmax=100, column="height" ,flags="z" , overwrite = True)
+
+
+ print "Create a vector object"
+
+ # We need to specify the name and the mapset as identifier
+ vds = vector_dataset(ident)
+
+ # Load data from the raster map in the mapset
+ vds.load()
+
+ print "Is vector in db: ", vds.is_in_db()
+
+ if vds.is_in_db():
+ vds.select()
+ vds.print_self()
+ # Remove the entry if it is in the db
+ vds.delete()
+ vds.reset(ident)
+ vds.load()
+
+ # Set the absolute valid time
+ vds.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
+ vds.insert()
+ # Register the map in the space time raster dataset
+ stvds.register_map(vds)
+ # Print self info
+ #vds.print_self()
+
+ stvds.update_from_registered_maps()
+ stvds.select()
+ # Print self info
+ stvds.print_self()
+ # Delete the dataset
+ stvds.delete()
+
+
+test_dict_sql_serializer()
+create_temporal_database()
+#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_strds_dataset()
+test_str3ds_dataset()
+test_stvds_dataset()
+test_increment_datetime_by_string()
Copied: grass/trunk/lib/temporal/SQL/update_stds_spatial_temporal_extent_template.sql (from rev 50164, grass/trunk/lib/temporal/update_stds_spatial_temporal_extent_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/update_stds_spatial_temporal_extent_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/update_stds_spatial_temporal_extent_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,66 @@
+--#############################################################################
+-- This SQL script is to update the spatial and temporal extent as well as
+-- the modifcation time and revision of a space time dataset. This script
+-- should be called when maps inserted or deleted in a space time dataset.
+--
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- 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
+-- GRASS_MAP is a placeholder for specific map type: raster, raster3d or vector
+-- STDS is a placeholder for specific space-time dataset type: strds, str3ds, stvds
+
+-- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = 'SPACETIME_ID';
+-- UPDATE STDS_base SET revision = (revision + 1) WHERE id = 'SPACETIME_ID';
+-- Number of registered maps
+UPDATE STDS_metadata SET number_of_maps =
+ (SELECT count(id) FROM SPACETIME_NAME_GRASS_MAP_register)
+ WHERE id = 'SPACETIME_ID';
+-- Update the temporal extent
+UPDATE STDS_absolute_time SET start_time =
+ (SELECT min(start_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
+ (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE STDS_absolute_time SET end_time =
+ (SELECT max(end_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
+ (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE STDS_relative_time SET start_time =
+ (SELECT min(start_time) FROM GRASS_MAP_relative_time WHERE GRASS_MAP_relative_time.id IN
+ (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE STDS_relative_time SET end_time =
+ (SELECT max(end_time) FROM GRASS_MAP_relative_time WHERE GRASS_MAP_relative_time.id IN
+ (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
+ ) WHERE id = 'SPACETIME_ID';
+-- Update the spatial extent
+UPDATE STDS_spatial_extent SET north =
+ (SELECT max(north) 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 south =
+ (SELECT min(south) 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 east =
+ (SELECT max(east) 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 west =
+ (SELECT min(west) 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 top =
+ (SELECT max(top) 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 bottom =
+ (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';
Copied: grass/trunk/lib/temporal/SQL/update_str3ds_metadata_template.sql (from rev 50164, grass/trunk/lib/temporal/update_str3ds_metadata_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/update_str3ds_metadata_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/update_str3ds_metadata_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,51 @@
+--#############################################################################
+-- This SQL script is to update a space-time raster3d dataset metadata
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- 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 min and max values
+UPDATE str3ds_metadata SET min_min =
+ (SELECT min(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster3d_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE str3ds_metadata SET min_max =
+ (SELECT max(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster3d_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE str3ds_metadata SET max_min =
+ (SELECT min(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster3d_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE str3ds_metadata SET max_max =
+ (SELECT max(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster3d_register)
+ ) WHERE id = 'SPACETIME_ID';
+-- Update the resolution
+UPDATE str3ds_metadata SET nsres_min =
+ (SELECT min(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster3d_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE str3ds_metadata SET nsres_max =
+ (SELECT max(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster3d_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE str3ds_metadata SET ewres_min =
+ (SELECT min(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster3d_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE str3ds_metadata SET ewres_max =
+ (SELECT max(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster3d_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE str3ds_metadata SET tbres_min =
+ (SELECT min(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster3d_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE str3ds_metadata SET tbres_max =
+ (SELECT max(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster3d_register)
+ ) WHERE id = 'SPACETIME_ID';
Copied: grass/trunk/lib/temporal/SQL/update_strds_metadata_template.sql (from rev 50164, grass/trunk/lib/temporal/update_strds_metadata_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/update_strds_metadata_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/update_strds_metadata_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,43 @@
+--#############################################################################
+-- This SQL is to update a space-time raster dataset metadata
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+-- 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 min and max values
+UPDATE strds_metadata SET min_min =
+ (SELECT min(min) FROM raster_metadata WHERE raster_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE strds_metadata SET min_max =
+ (SELECT max(min) FROM raster_metadata WHERE raster_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE strds_metadata SET max_min =
+ (SELECT min(max) FROM raster_metadata WHERE raster_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE strds_metadata SET max_max =
+ (SELECT max(max) FROM raster_metadata WHERE raster_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster_register)
+ ) WHERE id = 'SPACETIME_ID';
+-- Update the resolution
+UPDATE strds_metadata SET nsres_min =
+ (SELECT min(nsres) FROM raster_metadata WHERE raster_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE strds_metadata SET nsres_max =
+ (SELECT max(nsres) FROM raster_metadata WHERE raster_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE strds_metadata SET ewres_min =
+ (SELECT min(ewres) FROM raster_metadata WHERE raster_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster_register)
+ ) WHERE id = 'SPACETIME_ID';
+UPDATE strds_metadata SET ewres_max =
+ (SELECT max(ewres) FROM raster_metadata WHERE raster_metadata.id IN
+ (SELECT id FROM SPACETIME_NAME_raster_register)
+ ) WHERE id = 'SPACETIME_ID';
Copied: grass/trunk/lib/temporal/SQL/update_stvds_metadata_template.sql (from rev 50164, grass/trunk/lib/temporal/update_stvds_metadata_template.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/update_stvds_metadata_template.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/update_stvds_metadata_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,6 @@
+--#############################################################################
+-- This SQL script is for now a placeholder, till the vector metadata
+-- concept is clear
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
\ No newline at end of file
Copied: grass/trunk/lib/temporal/SQL/vector_metadata_table.sql (from rev 50164, grass/trunk/lib/temporal/vector_metadata_table.sql)
===================================================================
--- grass/trunk/lib/temporal/SQL/vector_metadata_table.sql (rev 0)
+++ grass/trunk/lib/temporal/SQL/vector_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,55 @@
+--#############################################################################
+-- This SQL script generates the vector table to store
+-- metadata for SQL queries and temporal GIS support.
+--
+-- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
+--#############################################################################
+
+--PRAGMA foreign_keys = ON;
+
+-- The metadata table
+
+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
+ PRIMARY KEY (id),
+ FOREIGN KEY (id) REFERENCES vector_base (id) ON DELETE CASCADE
+);
+
+-- Create the views to access all columns for the absolute and relative time
+
+CREATE VIEW vector_view_abs_time AS SELECT
+ A1.id, A1.mapset,
+ A1.name, A1.temporal_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time, A2.timezone,
+ 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
+ WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
+
+CREATE VIEW vector_view_rel_time AS SELECT
+ A1.id, A1.mapset,
+ A1.name, A1.temporal_type,
+ A1.creation_time,
+-- Uncommented due to performance issues
+-- A1.modification_time, A1.revision,
+ A1.creator,
+ A2.start_time, A2.end_time,
+ 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
+ WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
+
+-- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
+-- Uncommented due to performance issues
+--CREATE TRIGGER update_vector_metadata AFTER UPDATE ON vector_metadata
+-- BEGIN
+-- UPDATE vector_base SET modification_time = datetime("NOW") WHERE id = old.id;
+-- UPDATE vector_base SET revision = (revision + 1) WHERE id = old.id;
+-- END;
Deleted: grass/trunk/lib/temporal/map_stds_register_table_template.sql
===================================================================
--- grass/trunk/lib/temporal/map_stds_register_table_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/map_stds_register_table_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,38 +0,0 @@
---#############################################################################
--- This SQL script generates the table listing all STDS in
--- which the GRASS_MAP map is registered
---
--- This table is map specific and created for each GRASS_MAP map which is registered
--- in a STDS. TABLE_NAME is a placeholder for the table name which must be unique.
--- A uuid is used as unique identifier across mapsets.
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
---PRAGMA foreign_keys = ON;
-
--- TABLE_NAME is a placeholder for specific table name (SQL compliant)
--- MAP_ID is a placeholder for specific map id: name at mapset
--- GRASS_MAP is a placeholder for specific map type: raster, raster3d or vector
--- STDS is a placeholder for specific space-time dataset type: strds, str3ds, stvds
-
--- This table stores the names of the space-time datasets in which this map is registered
-CREATE TABLE TABLE_NAME_STDS_register (
- id VARCHAR NOT NULL, -- This column is a primary foreign key storing the STDS names
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES STDS_base (id) ON DELETE CASCADE
-);
-
---CREATE TRIGGER TABLE_NAME_STDS_register_insert AFTER INSERT ON TABLE_NAME_STDS_register
--- BEGIN
--- UPDATE GRASS_MAP_base SET modification_time = datetime("NOW") WHERE GRASS_MAP_base.id = 'MAP_ID';
--- UPDATE GRASS_MAP_base SET revision = (revision + 1) WHERE GRASS_MAP_base.id = 'MAP_ID';
--- END;
-
---CREATE TRIGGER TABLE_NAME_STDS_register_delete AFTER DELETE ON TABLE_NAME_STDS_register
--- BEGIN
--- UPDATE GRASS_MAP_base SET modification_time = datetime("NOW") WHERE GRASS_MAP_base.id = 'MAP_ID';
--- UPDATE GRASS_MAP_base SET revision = (revision + 1) WHERE GRASS_MAP_base.id = 'MAP_ID';
--- END;
-
-
Deleted: grass/trunk/lib/temporal/map_tables_template.sql
===================================================================
--- grass/trunk/lib/temporal/map_tables_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/map_tables_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,83 +0,0 @@
---#############################################################################
--- This SQL script generates the grass map tables to store time stamps, revision
--- and spatial extent for SQL queries and temporal GIS support.
--- Additionally several triggers are created for convenient functions
--- The grass map metadata is map specific (raster, raster3d and vector maps are
--- supported)
---
--- The placeholder GRASS_MAP will be replaced by raster, raster3d and vector
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
--- GRASS_MAP is a placeholder for specific map type: raster, raster3d or vector
-
---PRAGMA foreign_keys = ON;
-
-CREATE TABLE GRASS_MAP_base (
- id VARCHAR NOT NULL, -- The id (PK) is the unique identifier for all tables, it is based on name and mapset (name at mapset) and is used as primary key
- name VARCHAR NOT NULL, -- name of the grass map
- mapset VARCHAR NOT NULL, -- mapset of the grass map
- creator VARCHAR NOT NULL,
- temporal_type VARCHAR, -- The temporal type of the grass map "absolute" or "relative" or NULL in case no time stamp is available
- creation_time TIMESTAMP NOT NULL, -- The time of creation of the grass map
--- Uncommented due to performance issues
--- modification_time TIMESTAMP NOT NULL, -- The time of the last modification of the grass map
--- revision SMALLINT NOT NULL, -- The revision number
- PRIMARY KEY (id)
-);
-
--- Relative valid time interval with start and end time
-CREATE TABLE GRASS_MAP_relative_time (
- 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
- start_time DOUBLE PRECISION, -- The relative valid start time in [days]
- end_time DOUBLE PRECISION, -- The relative valid end time in [days]
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES GRASS_MAP_base (id) ON DELETE CASCADE
-);
-
-CREATE TABLE GRASS_MAP_absolute_time (
- 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
- start_time TIMESTAMP, -- Start of the valid time, can be NULL if no time information is available
- end_time TIMESTAMP, -- End of the valid time, can be NULL if no time information is available or valid time is a single point in time
- timezone SMALLINT, -- The timezone of the valid time
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES GRASS_MAP_base (id) ON DELETE CASCADE
-);
-
--- The spatial extent of a raster map
-
-CREATE TABLE GRASS_MAP_spatial_extent (
- 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 foreigen key
- -- below is the spatial extent of the map
- north DOUBLE PRECISION NOT NULL,
- south DOUBLE PRECISION NOT NULL,
- east DOUBLE PRECISION NOT NULL,
- west DOUBLE PRECISION NOT NULL,
- top DOUBLE PRECISION NOT NULL,
- bottom DOUBLE PRECISION NOT NULL,
- proj VARCHAR,
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES GRASS_MAP_base (id) ON DELETE CASCADE
-);
-
--- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
-
---CREATE TRIGGER update_GRASS_MAP_absolute_time AFTER UPDATE ON GRASS_MAP_absolute_time
--- BEGIN
--- UPDATE GRASS_MAP_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE GRASS_MAP_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
-
---CREATE TRIGGER update_GRASS_MAP_relative_time AFTER UPDATE ON GRASS_MAP_relative_time
--- BEGIN
--- UPDATE GRASS_MAP_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE GRASS_MAP_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
-
-
---CREATE TRIGGER update_GRASS_MAP_spatial_extent AFTER UPDATE ON GRASS_MAP_spatial_extent
--- BEGIN
--- UPDATE GRASS_MAP_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE GRASS_MAP_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
Deleted: grass/trunk/lib/temporal/raster3d_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/raster3d_metadata_table.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/raster3d_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,74 +0,0 @@
---#############################################################################
--- This SQL script generates the raster3d metadata table to store
--- and metadata for SQL queries and temporal GIS support. Additionally two views
--- are created to access all map specific tables
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
---PRAGMA foreign_keys = ON;
-
--- The metadata table reflects most of the raster3d metadata available in grass
-
-CREATE TABLE raster3d_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
- str3ds_register VARCHAR, -- The name of the table storing all space-time raster3d datasets in which this map is registered
- datatype VARCHAR NOT NULL,
- cols INTEGER NOT NULL,
- rows INTEGER NOT NULL,
- depths INTEGER NOT NULL,
- number_of_cells INTEGER NOT NULL,
- nsres DOUBLE PRECISION NOT NULL,
- ewres DOUBLE PRECISION NOT NULL,
- tbres DOUBLE PRECISION NOT NULL,
- min DOUBLE PRECISION,
- max DOUBLE PRECISION,
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES raster3d_base (id) ON DELETE CASCADE
-);
-
--- Create the views to access all cols for the absolute and relative time
-
-CREATE VIEW raster3d_view_abs_time AS SELECT
- A1.id, A1.mapset,
- A1.name, A1.temporal_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time, A2.timezone,
- 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,
- A4.str3ds_register,
- A4.number_of_cells
- FROM raster3d_base A1, raster3d_absolute_time A2,
- raster3d_spatial_extent A3, raster3d_metadata A4
- WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW raster3d_view_rel_time AS SELECT
- A1.id, A1.mapset,
- A1.name, A1.temporal_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time,
- 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,
- A4.str3ds_register,
- A4.number_of_cells
- FROM raster3d_base A1, raster3d_relative_time A2,
- raster3d_spatial_extent A3, raster3d_metadata A4
- WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
--- Create a trigger to update the modification time and revision number in case the metadata have been updated
-
---CREATE TRIGGER update_raster3d_metadata AFTER UPDATE ON raster3d_metadata
--- BEGIN
--- UPDATE raster3d_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE raster3d_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
Deleted: grass/trunk/lib/temporal/raster_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/raster_metadata_table.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/raster_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,71 +0,0 @@
---#############################################################################
--- This SQL script generates the raster metadata table to store
--- and metadata for SQL queries and temporal GIS support. Additionally two views
--- are created to access all map specific tables
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
---PRAGMA foreign_keys = ON;
-
--- The metadata table reflects most of the raster metadata available in grass
-
-CREATE TABLE raster_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
- strds_register VARCHAR, -- The name of the table storing all space-time raster datasets in which this map is registered
- datatype VARCHAR NOT NULL,
- cols INTEGER NOT NULL,
- rows INTEGER NOT NULL,
- number_of_cells INTEGER NOT NULL,
- nsres DOUBLE PRECISION NOT NULL,
- ewres DOUBLE PRECISION NOT NULL,
- min DOUBLE PRECISION,
- max DOUBLE PRECISION,
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES raster_base (id) ON DELETE CASCADE
-);
-
--- Create the views to access all cols for the absolute and relative time
-
-CREATE VIEW raster_view_abs_time AS SELECT
- A1.id, A1.mapset,
- A1.name, A1.temporal_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time, A2.timezone,
- 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,
- A4.number_of_cells
- FROM raster_base A1, raster_absolute_time A2,
- raster_spatial_extent A3, raster_metadata A4
- WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW raster_view_rel_time AS SELECT
- A1.id, A1.mapset,
- A1.name, A1.temporal_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time,
- 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,
- A4.number_of_cells
- FROM raster_base A1, raster_relative_time A2,
- raster_spatial_extent A3, raster_metadata A4
- WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
--- Create a trigger to update the modification time and revision number in case the metadata have been updated
--- Uncommented due to performance issues
---CREATE TRIGGER update_raster_metadata AFTER UPDATE ON raster_metadata
--- BEGIN
--- UPDATE raster_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE raster_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
-
Deleted: grass/trunk/lib/temporal/sqlite3_delete_trigger.sql
===================================================================
--- grass/trunk/lib/temporal/sqlite3_delete_trigger.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/sqlite3_delete_trigger.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,51 +0,0 @@
-
--- Create trigger for automated deletion of dependent rows, this should normally be done using foreign keys
-
-CREATE TRIGGER delete_strds_base AFTER DELETE ON strds_base
- BEGIN
- DELETE FROM strds_absolute_time WHERE id = old.id;
- DELETE FROM strds_relative_time WHERE id = old.id;
- DELETE FROM strds_spatial_extent WHERE id = old.id;
- DELETE FROM strds_metadata WHERE id = old.id;
- END;
-
-CREATE TRIGGER delete_raster_base AFTER DELETE ON raster_base
- BEGIN
- DELETE FROM raster_absolute_time WHERE id = old.id;
- DELETE FROM raster_relative_time WHERE id = old.id;
- DELETE FROM raster_spatial_extent WHERE id = old.id;
- DELETE FROM raster_metadata WHERE id = old.id;
- END;
-
-CREATE TRIGGER delete_str3ds_base AFTER DELETE ON str3ds_base
- BEGIN
- DELETE FROM str3ds_absolute_time WHERE id = old.id;
- DELETE FROM str3ds_relative_time WHERE id = old.id;
- DELETE FROM str3ds_spatial_extent WHERE id = old.id;
- DELETE FROM str3ds_metadata WHERE id = old.id;
- END;
-
-CREATE TRIGGER delete_raster3d_base AFTER DELETE ON raster3d_base
- BEGIN
- DELETE FROM raster3d_absolute_time WHERE id = old.id;
- DELETE FROM raster3d_relative_time WHERE id = old.id;
- DELETE FROM raster3d_spatial_extent WHERE id = old.id;
- DELETE FROM raster3d_metadata WHERE id = old.id;
- END;
-
-CREATE TRIGGER delete_stvds_base AFTER DELETE ON stvds_base
- BEGIN
- DELETE FROM stvds_absolute_time WHERE id = old.id;
- DELETE FROM stvds_relative_time WHERE id = old.id;
- DELETE FROM stvds_spatial_extent WHERE id = old.id;
- DELETE FROM stvds_metadata WHERE id = old.id;
- END;
-
-CREATE TRIGGER delete_vector_base AFTER DELETE ON vector_base
- BEGIN
- DELETE FROM vector_absolute_time WHERE id = old.id;
- DELETE FROM vector_relative_time WHERE id = old.id;
- DELETE FROM vector_spatial_extent WHERE id = old.id;
- DELETE FROM vector_metadata WHERE id = old.id;
- END;
-
Added: grass/trunk/lib/temporal/src/Makefile
===================================================================
--- grass/trunk/lib/temporal/src/Makefile (rev 0)
+++ grass/trunk/lib/temporal/src/Makefile 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,14 @@
+MODULE_TOPDIR = ../../..
+
+EXTRA_LIBS = $(GISLIB) $(DBMILIB) $(DATETIMELIB)
+# needed? $(OMPLIBPATH)
+
+LIB = TEMPORAL
+
+include $(MODULE_TOPDIR)/include/Make/Lib.make
+include $(MODULE_TOPDIR)/include/Make/Doxygen.make
+
+default: lib
+
+#doxygen:
+DOXNAME=temporal
Added: grass/trunk/lib/temporal/src/connect.c
===================================================================
--- grass/trunk/lib/temporal/src/connect.c (rev 0)
+++ grass/trunk/lib/temporal/src/connect.c 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,52 @@
+/*!
+ \file lib/temporal/src/connect.c
+
+ \brief Temporal GIS Library - connect to TGIS DB
+
+ (C) 2012 by the GRASS Development Team
+
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
+
+ \author Soeren Gebbert
+ Code is based on the dbmi library written by
+ Joel Jones (CERL/UIUC) and Radim Blazek
+*/
+#include <grass/temporal.h>
+
+/*!
+ \brief Set default Temporal GIS DB connection settings
+
+ This function sets enviromental variables as TGISDB_DRIVER, TGISDB_DATABASE.
+
+ \param connection pointer to dbConnection with default settings
+
+ \return DB_OK
+ */
+int tgis_set_connection(dbConnection * connection)
+{
+ if (connection->driverName)
+ G_setenv2("TGISDB_DRIVER", connection->driverName, G_VAR_MAPSET);
+
+ if (connection->databaseName)
+ G_setenv2("TGISDB_DATABASE", connection->databaseName, G_VAR_MAPSET);
+
+ return DB_OK;
+}
+
+/*!
+ \brief Get Temporal GIS DB connection settings
+
+ \param[out] connection pointer to dbConnection to be modified
+
+ \return DB_OK
+ */
+int tgis_get_connection(dbConnection * connection)
+{
+ G_zero(connection, sizeof(dbConnection));
+
+ connection->driverName = (char *)G__getenv2("TGISDB_DRIVER", G_VAR_MAPSET);
+ connection->databaseName = (char *)G__getenv2("TGISDB_DATABASE", G_VAR_MAPSET);
+
+ return DB_OK;
+}
Added: grass/trunk/lib/temporal/src/default_name.c
===================================================================
--- grass/trunk/lib/temporal/src/default_name.c (rev 0)
+++ grass/trunk/lib/temporal/src/default_name.c 2012-01-19 00:11:22 UTC (rev 50284)
@@ -0,0 +1,77 @@
+/*!
+ \file lib/db/dbmi_base/default_name.c
+
+ \brief Temporal GIS Library (base) - default settings
+
+ (C) 2012 by the GRASS Development Team
+
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
+
+ \author Soeren Gebbert
+ Code is based on the dbmi library written by
+ Joel Jones (CERL/UIUC) and Radim Blazek
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <grass/gis.h>
+#include <grass/temporal.h>
+#include <grass/glocale.h>
+
+/*!
+ \brief Get default TGIS driver name
+
+ \return pointer to default TGIS driver name
+ \return NULL if not set
+*/
+const char *tgis_get_default_driver_name(void)
+{
+ const char *drv;
+
+ if ((drv = G__getenv2("TGISDB_DRIVER", G_VAR_MAPSET)))
+ return G_store(drv);
+
+ return NULL;
+}
+
+/*!
+ \brief Get default TGIS database name
+
+ \return pointer to default TGIS database name
+ \return NULL if not set
+*/
+const char *tgis_get_default_database_name(void)
+{
+ const char *drv;
+
+ if ((drv = G__getenv2("TGISDB_DATABASE", G_VAR_MAPSET)))
+ return G_store(drv);
+
+ return NULL;
+}
+
+/*!
+ \brief Sets up TGIS database connection settings using GRASS default from temporal.h
+
+ \return returns DB_OK
+*/
+int tgis_set_default_connection(void)
+{
+ dbConnection connection;
+
+ G_debug(1,
+ "Creating new default TGIS DB params with tgis_set_default_connection()");
+
+ if (strcmp(TGISDB_DEFAULT_DRIVER, "sqlite") == 0) {
+
+ connection.driverName = "sqlite";
+ connection.databaseName =
+ "$GISDBASE/$LOCATION_NAME/PERMANENT/tgis.db";
+ tgis_set_connection(&connection);
+ }
+ else
+ G_fatal_error(_("Programmer error"));
+
+ return DB_OK;
+}
Deleted: grass/trunk/lib/temporal/stds_map_register_table_template.sql
===================================================================
--- grass/trunk/lib/temporal/stds_map_register_table_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/stds_map_register_table_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,129 +0,0 @@
---#############################################################################
--- This SQL script generates the table in which all registered GRASS_MAP maps
--- are listed in.
---
--- This table will be created for each STDS.
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
--- 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
--- GRASS_MAP is a placeholder for specific map type: raster, raster3d or vector
--- STDS is a placeholder for specific space-time dataset type: strds, str3ds, stvds
-
---PRAGMA foreign_keys = ON;
-
--- This table stores the.ids of the GRASS_MAP maps registered in the current spacetime GRASS_MAP table
-CREATE TABLE SPACETIME_NAME_GRASS_MAP_register (
- id VARCHAR NOT NULL, -- This colum is a primary foreign key storing the registered GRASS_MAP map.ids
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES GRASS_MAP_base (id) ON DELETE CASCADE
-);
-
--- Triggers are disabled due to huge performance issues
---CREATE TRIGGER SPACETIME_NAME_GRASS_MAP_register_insert_trigger AFTER INSERT ON SPACETIME_NAME_GRASS_MAP_register
--- BEGIN
--- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = 'SPACETIME_ID';
--- UPDATE STDS_base SET revision = (revision + 1) WHERE id = 'SPACETIME_ID';
--- -- Number of registered maps
--- UPDATE STDS_metadata SET number_of_maps =
--- (SELECT count(id) FROM SPACETIME_NAME_GRASS_MAP_register)
--- WHERE id = 'SPACETIME_ID';
--- -- Update the temporal extent
--- UPDATE STDS_absolute_time SET start_time =
--- (SELECT min(start_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
--- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE STDS_absolute_time SET end_time =
--- (SELECT max(end_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
--- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
--- ) WHERE id = 'SPACETIME_ID';
-
--- UPDATE STDS_relative_time SET start_time =
--- (SELECT min(start_time) FROM GRASS_MAP_relative_time WHERE GRASS_MAP_relative_time.id IN
--- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE STDS_relative_time SET end_time =
--- (SELECT max(end_time) FROM GRASS_MAP_relative_time WHERE GRASS_MAP_relative_time.id IN
--- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
--- ) WHERE id = 'SPACETIME_ID';
--- -- Update the spatial extent
--- UPDATE STDS_spatial_extent SET north =
--- (SELECT max(north) 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 south =
--- (SELECT min(south) 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 east =
--- (SELECT max(east) 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 west =
--- (SELECT min(west) 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 top =
--- (SELECT max(top) 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 bottom =
--- (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
--- BEGIN
--- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = 'SPACETIME_ID';
--- UPDATE STDS_base SET revision = (revision + 1) WHERE id = 'SPACETIME_ID';
--- -- Number of registered maps
--- UPDATE STDS_metadata SET number_of_maps =
--- (SELECT count(id) FROM SPACETIME_NAME_GRASS_MAP_register)
--- WHERE id = 'SPACETIME_ID';
--- -- Update the temporal extent
--- UPDATE STDS_absolute_time SET start_time =
--- (SELECT min(start_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
--- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE STDS_absolute_time SET end_time =
--- (SELECT max(end_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
--- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
--- ) WHERE id = 'SPACETIME_ID';
--- -- Update the spatial extent
--- UPDATE STDS_spatial_extent SET north =
--- (SELECT max(north) 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 south =
--- (SELECT min(south) 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 east =
--- (SELECT max(east) 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 west =
--- (SELECT min(west) 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 top =
--- (SELECT max(top) 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 bottom =
--- (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;
---
Deleted: grass/trunk/lib/temporal/stds_raster3d_register_trigger_template.sql
===================================================================
--- grass/trunk/lib/temporal/stds_raster3d_register_trigger_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/stds_raster3d_register_trigger_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,113 +0,0 @@
---#############################################################################
--- This SQL script creates a trigger to update a space-time raster3d dataset
--- metadata
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
--- 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
-
---PRAGMA foreign_keys = ON;
-
--- Triggers are disabled due to huge performance issues
---CREATE TRIGGER SPACETIME_NAME_raster3d_metadata_register_insert_trigger AFTER INSERT ON SPACETIME_NAME_raster3d_register
--- BEGIN
--- -- Update the min and max values
--- UPDATE str3ds_metadata SET min_min =
--- (SELECT min(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET min_max =
--- (SELECT max(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET max_min =
--- (SELECT min(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET max_max =
--- (SELECT max(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- -- Update the resolution
--- UPDATE str3ds_metadata SET nsres_min =
--- (SELECT min(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET nsres_max =
--- (SELECT max(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET ewres_min =
--- (SELECT min(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET ewres_max =
--- (SELECT max(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET tbres_min =
--- (SELECT min(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET tbres_max =
--- (SELECT max(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- END;
---
---CREATE TRIGGER SPACETIME_NAME_raster3d_metadata_register_delete_trigger AFTER DELETE ON SPACETIME_NAME_raster3d_register
--- BEGIN
--- -- Update the min and max values
--- UPDATE str3ds_metadata SET min_min =
--- (SELECT min(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET min_max =
--- (SELECT max(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET max_min =
--- (SELECT min(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET max_max =
--- (SELECT max(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- -- Update the resolution
--- UPDATE str3ds_metadata SET nsres_min =
--- (SELECT min(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET nsres_max =
--- (SELECT max(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET ewres_min =
--- (SELECT min(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET ewres_max =
--- (SELECT max(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET tbres_min =
--- (SELECT min(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE str3ds_metadata SET tbres_max =
--- (SELECT max(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster3d_register)
--- ) WHERE id = 'SPACETIME_ID';
--- END;
---
---
---
---
---
---
---
---
---
Deleted: grass/trunk/lib/temporal/stds_raster_register_trigger_template.sql
===================================================================
--- grass/trunk/lib/temporal/stds_raster_register_trigger_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/stds_raster_register_trigger_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,113 +0,0 @@
---#############################################################################
--- This SQL script creates a trigger to update a space-time raster dataset
--- metadata
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
--- 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
-
---PRAGMA foreign_keys = ON;
-
--- Triggers are disabled due to huge performance issues
---CREATE TRIGGER SPACETIME_NAME_raster_metadata_register_insert_trigger AFTER INSERT ON SPACETIME_NAME_raster_register
--- BEGIN
--- -- Update the min and max values
--- UPDATE strds_metadata SET min_min =
--- (SELECT min(min) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET min_max =
--- (SELECT max(min) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET max_min =
--- (SELECT min(max) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET max_max =
--- (SELECT max(max) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- -- Update the resolution
--- UPDATE strds_metadata SET nsres_min =
--- (SELECT min(nsres) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET nsres_max =
--- (SELECT max(nsres) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET ewres_min =
--- (SELECT min(ewres) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET ewres_max =
--- (SELECT max(ewres) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- END;
---
---CREATE TRIGGER SPACETIME_NAME_raster_metadata_register_delete_trigger AFTER DELETE ON SPACETIME_NAME_raster_register
--- BEGIN
--- -- Update the min and max values
--- UPDATE strds_metadata SET min_min =
--- (SELECT min(min) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET min_max =
--- (SELECT max(min) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET max_min =
--- (SELECT min(max) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET max_max =
--- (SELECT max(max) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- -- Update the resolution
--- UPDATE strds_metadata SET nsres_min =
--- (SELECT min(nsres) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET nsres_max =
--- (SELECT max(nsres) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET ewres_min =
--- (SELECT min(ewres) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- UPDATE strds_metadata SET ewres_max =
--- (SELECT max(ewres) FROM raster_metadata WHERE raster_metadata.id IN
--- (SELECT id FROM SPACETIME_NAME_raster_register)
--- ) WHERE id = 'SPACETIME_ID';
--- END;
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
---
Deleted: grass/trunk/lib/temporal/stds_tables_template.sql
===================================================================
--- grass/trunk/lib/temporal/stds_tables_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/stds_tables_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,79 +0,0 @@
---#############################################################################
--- This SQL script generates the space time dataset tables to store time
--- stamps and revision for SQL queries and temporal GIS support.
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
--- STDS is a placeholder for specific space-time dataset type: strds, str3ds, stvds
-
---PRAGMA foreign_keys = ON;
-
-CREATE TABLE STDS_base (
- id VARCHAR NOT NULL, -- Id of the space-time dataset, name at mapset this is the primary key
- name VARCHAR NOT NULL, -- name of the space-time dataset
- mapset VARCHAR NOT NULL, -- mapset of the space-time dataset
- creator VARCHAR NOT NULL, -- Name of the creator
- temporal_type VARCHAR NOT NULL, -- The temporal type of the dataset "absolute" or "relative"
- semantic_type VARCHAR NOT NULL, -- The semantic data description used for aggregation/decomposition algorithm selection
- creation_time TIMESTAMP NOT NULL, -- The time of creation of the space-time dataset
--- Uncommented due to performance issues
--- modification_time TIMESTAMP NOT NULL, -- The time of the last modification of the grass map
--- revision SMALLINT NOT NULL, -- The revision number -- The revision number
- PRIMARY KEY (id)
-);
-
-CREATE TABLE STDS_relative_time (
- id VARCHAR NOT NULL, -- Id of the space-time dataset, this is the primary foreign key
- start_time DOUBLE PRECISION, -- The relative valid start time in [days]
- end_time DOUBLE PRECISION, -- The relative valid end time in [days]
- granularity DOUBLE PRECISION, -- The granularity in [days]
- map_time VARCHAR, -- The temporal type of the registered maps, may be interval, point or mixed
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES STDS_base (id) ON DELETE CASCADE
-);
-
-CREATE TABLE STDS_absolute_time (
- id VARCHAR NOT NULL, -- Id of the space-time dataset, this is the primary foreign key
- start_time TIMESTAMP, -- Start of the valid time, can be NULL if no map is registered
- end_time TIMESTAMP, -- End of the valid time, can be NULL if no map is registered
- granularity VARCHAR, -- The granularity "NNN seconds, NNN minutes, NNN hours, NNN days, NNN weeks, NNN months, NNN years"
- timezone SMALLINT, -- The time zone number
- map_time VARCHAR, -- The temporal type of the registered maps, may be interval, point or mixed
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES STDS_base (id) ON DELETE CASCADE
-);
-
-CREATE TABLE STDS_spatial_extent (
- id VARCHAR NOT NULL, -- Id of the space-time dataset, this is the primary foreign key
- north DOUBLE PRECISION, -- The spatial north extent, derived from the registered maps
- south DOUBLE PRECISION, -- The spatial south extent, derived from the registered maps
- east DOUBLE PRECISION, -- The spatial east extent, derived from the registered maps
- 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 VARCHAR, -- The projection of the space time dataset (XY of LL)
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES STDS_base (id) ON DELETE CASCADE
-);
-
--- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
--- Uncommented due to performance issues
---CREATE TRIGGER update_STDS_abs_time AFTER UPDATE ON STDS_absolute_time
--- BEGIN
--- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE STDS_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
-
---CREATE TRIGGER update_STDS_rel_time AFTER UPDATE ON STDS_relative_time
--- BEGIN
--- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE STDS_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
-
---CREATE TRIGGER update_STDS_spatial_extent AFTER UPDATE ON STDS_spatial_extent
--- BEGIN
--- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE STDS_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
-
Deleted: grass/trunk/lib/temporal/stds_vector_register_trigger_template.sql
===================================================================
--- grass/trunk/lib/temporal/stds_vector_register_trigger_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/stds_vector_register_trigger_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,6 +0,0 @@
---#############################################################################
--- This SQL script is for now a placeholder, till the vector metadata
--- concept is clear
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
\ No newline at end of file
Deleted: grass/trunk/lib/temporal/str3ds_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/str3ds_metadata_table.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/str3ds_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,80 +0,0 @@
---#############################################################################
--- This SQL script generates the space time raster3d dataset metadata table,
--- view and trigger
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
---PRAGMA foreign_keys = ON;
-
-CREATE TABLE str3ds_metadata (
- id VARCHAR NOT NULL, -- Id of the space-time raster3d dataset, this is the primary foreign key
- raster3d_register VARCHAR, -- The id of the table in which the raster3d maps are registered for this dataset
- number_of_maps INTEGER, -- The number of registered raster3d maps
- max_min DOUBLE PRECISION, -- The minimal maximum of the registered raster3d maps
- min_min DOUBLE PRECISION, -- The minimal minimum of the registered raster3d maps
- max_max DOUBLE PRECISION, -- The maximal maximum of the registered raster3d maps
- min_max DOUBLE PRECISION, -- The maximal minimum of the registered raster3d maps
- nsres_min DOUBLE PRECISION, -- The lowest north-south resolution of the registered raster3d maps
- nsres_max DOUBLE PRECISION, -- The highest north-south resolution of the registered raster3d maps
- ewres_min DOUBLE PRECISION, -- The lowest east-west resolution of the registered raster3d maps
- ewres_max DOUBLE PRECISION, -- The highest east-west resolution of the registered raster3d maps
- tbres_min DOUBLE PRECISION, -- The lowest top-bottom resolution of the registered raster3d maps
- tbres_max DOUBLE PRECISION, -- The highest top-bottom resolution of the registered raster3d maps
- title VARCHAR, -- Title of the space-time raster3d dataset
- description VARCHAR, -- Detailed description of the space-time raster3d dataset
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES str3ds_base (id) ON DELETE CASCADE
-);
--- Create the views to access all cols for absolute or relative time
-
-CREATE VIEW str3ds_view_abs_time AS SELECT
- A1.id, A1.name, A1.mapset, A1.temporal_type,
- A1.semantic_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time, A2.timezone, A2.granularity,
- A3.north, A3.south, A3.east, A3.west, A3.proj,
- A4.raster3d_register,
- A4.number_of_maps,
- A4.nsres_min, A4.ewres_min,
- A4.nsres_max, A4.ewres_max,
- A4.tbres_min, A4.tbres_max,
- A4.min_min, A4.min_max,
- A4.max_min, A4.max_max,
- A4.title, A4.description
- FROM str3ds_base A1, str3ds_absolute_time A2,
- str3ds_spatial_extent A3, str3ds_metadata A4 WHERE A1.id = A2.id AND
- A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW str3ds_view_rel_time AS SELECT
- A1.id, A1.name, A1.mapset, A1.temporal_type,
- A1.semantic_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time, A2.granularity,
- A3.north, A3.south, A3.east, A3.west, A3.proj,
- A4.raster3d_register,
- A4.number_of_maps,
- A4.nsres_min, A4.ewres_min,
- A4.nsres_max, A4.ewres_max,
- A4.tbres_min, A4.tbres_max,
- A4.min_min, A4.min_max,
- A4.max_min, A4.max_max,
- A4.title, A4.description
- FROM str3ds_base A1, str3ds_relative_time A2,
- str3ds_spatial_extent A3, str3ds_metadata A4 WHERE A1.id = A2.id AND
- A1.id = A3.id AND A1.id = A4.id;
-
-
--- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
--- Uncommented due to performance issues
---CREATE TRIGGER update_str3ds_metadata AFTER UPDATE ON str3ds_metadata
--- BEGIN
--- UPDATE str3ds_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE str3ds_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
Deleted: grass/trunk/lib/temporal/strds_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/strds_metadata_table.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/strds_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,76 +0,0 @@
---#############################################################################
--- This SQL script generates the space time raster dataset metadata table,
--- view and trigger
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
---PRAGMA foreign_keys = ON;
-
-CREATE TABLE strds_metadata (
- id VARCHAR NOT NULL, -- Id of the space-time dataset, this is the primary foreign key
- raster_register VARCHAR, -- The id of the table in which the raster maps are registered for this dataset
- number_of_maps INTEGER, -- The number of registered raster maps
- max_min DOUBLE PRECISION, -- The minimal maximum of the registered raster maps
- min_min DOUBLE PRECISION, -- The minimal minimum of the registered raster maps
- max_max DOUBLE PRECISION, -- The maximal maximum of the registered raster maps
- min_max DOUBLE PRECISION, -- The maximal minimum of the registered raster maps
- nsres_min DOUBLE PRECISION, -- The lowest north-south resolution of the registered raster maps
- nsres_max DOUBLE PRECISION, -- The highest north-south resolution of the registered raster maps
- ewres_min DOUBLE PRECISION, -- The lowest east-west resolution of the registered raster maps
- ewres_max DOUBLE PRECISION, -- The highest east-west resolution of the registered raster maps
- title VARCHAR, -- Title of the space-time raster dataset
- description VARCHAR, -- Detailed description of the space-time raster dataset
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES strds_base (id) ON DELETE CASCADE
-);
--- Create the views to access all cols for absolute or relative time
-
-CREATE VIEW strds_view_abs_time AS SELECT
- A1.id, A1.name, A1.mapset, A1.temporal_type,
- A1.semantic_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time, A2.timezone, A2.granularity,
- A3.north, A3.south, A3.east, A3.west, A3.proj,
- A4.raster_register,
- A4.number_of_maps,
- A4.nsres_min, A4.ewres_min,
- A4.nsres_max, A4.ewres_max,
- A4.min_min, A4.min_max,
- A4.max_min, A4.max_max,
- A4.title, A4.description
- FROM strds_base A1, strds_absolute_time A2,
- strds_spatial_extent A3, strds_metadata A4 WHERE A1.id = A2.id AND
- A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW strds_view_rel_time AS SELECT
- A1.id, A1.name, A1.mapset, A1.temporal_type,
- A1.semantic_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time, A2.granularity,
- A3.north, A3.south, A3.east, A3.west, A3.proj,
- A4.raster_register,
- A4.number_of_maps,
- A4.nsres_min, A4.ewres_min,
- A4.nsres_max, A4.ewres_max,
- A4.min_min, A4.min_max,
- A4.max_min, A4.max_max,
- A4.title, A4.description
- FROM strds_base A1, strds_relative_time A2,
- strds_spatial_extent A3, strds_metadata A4 WHERE A1.id = A2.id AND
- A1.id = A3.id AND A1.id = A4.id;
-
-
--- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
--- Uncommented due to performance issues
---CREATE TRIGGER update_strds_metadata AFTER UPDATE ON strds_metadata
--- BEGIN
--- UPDATE strds_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE strds_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
Deleted: grass/trunk/lib/temporal/stvds_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/stvds_metadata_table.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/stvds_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,61 +0,0 @@
---#############################################################################
--- This SQL script generates the space time vector dataset metadata table,
--- view and trigger
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
---PRAGMA foreign_keys = ON;
-
-CREATE TABLE stvds_metadata (
- id VARCHAR NOT NULL, -- Name of the space-time vector dataset, this is the primary foreign key
- vector_register VARCHAR, -- The id of the table in which the vector maps are registered for this dataset
- 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
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES stvds_base (id) ON DELETE CASCADE
-);
--- Create the views to access all columns for absolute or relative time
-
-CREATE VIEW stvds_view_abs_time AS SELECT
- A1.id, A1.name, A1.mapset, A1.temporal_type,
- A1.semantic_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time, A2.timezone,
- A2.granularity,
- A3.north, A3.south, A3.east, A3.west, A3.proj,
- A4.vector_register,
- A4.number_of_maps,
- A4.title, A4.description
- 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;
-
-CREATE VIEW stvds_view_rel_time AS SELECT
- A1.id, A1.name, A1.mapset, A1.temporal_type,
- A1.semantic_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time, A2.granularity,
- A3.north, A3.south, A3.east, A3.west, A3.proj,
- A4.vector_register,
- A4.number_of_maps,
- A4.title, A4.description
- 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;
-
-
--- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
--- Uncommented due to performance issues
---CREATE TRIGGER update_stvds_metadata AFTER UPDATE ON stvds_metadata
--- BEGIN
--- UPDATE stvds_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE stvds_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
Deleted: grass/trunk/lib/temporal/test.temporal.py
===================================================================
--- grass/trunk/lib/temporal/test.temporal.py 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/test.temporal.py 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,836 +0,0 @@
-import os
-from grass.script.tgis_core import *
-from grass.script.tgis_base import *
-from grass.script.tgis_temporal_extent import *
-from grass.script.tgis_spatial_extent import *
-from grass.script.tgis_metadata import *
-from grass.script.tgis_abstract_datasets import *
-from grass.script.tgis_space_time_datasets import *
-import grass.script as grass
-###############################################################################
-
-def test_dict_sql_serializer():
- t = dict_sql_serializer()
- t.test()
-
-def test_dataset_identifer():
- for i in range(2):
- base = raster_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", creator="soeren", temporal_type="absolute", revision=1)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_creator("rene")
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = raster3d_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", temporal_type="absolute", creator="soeren")
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_creator("rene")
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = vector_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", temporal_type="absolute", creator="soeren")
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_creator("rene")
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = strds_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", creator="soeren", semantic_type="event", temporal_type="absolute", revision=1)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_creator("rene")
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = str3ds_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", temporal_type="absolute", semantic_type="event", creator="soeren")
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_creator("rene")
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = stvds_base(ident="soil" + str(i) + "@PERMANENT", name="soil" + str(i), mapset="PERMANENT", temporal_type="absolute", semantic_type="event", creator="soeren")
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_creator("rene")
- base.update()
- base.select()
- base.print_self()
-
-def test_absolute_timestamp():
- for i in range(2):
- base = raster_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), timezone=1)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_start_time(datetime(2010,01,01))
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = raster3d_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), timezone=1)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_start_time(datetime(2010,01,01))
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = vector_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), timezone=1)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_start_time(datetime(2010,01,01))
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = strds_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), granularity="1 day", timezone=1)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_start_time(datetime(2010,01,01))
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = str3ds_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), granularity="1 day", timezone=1)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_start_time(datetime(2010,01,01))
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = stvds_absolute_time(ident="soil" + str(i) + "@PERMANENT", start_time=datetime(2011,01,01), end_time=datetime(2011,07,01), granularity="1 day", timezone=1)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_start_time(datetime(2010,01,01))
- base.update()
- base.select()
- base.print_self()
-
-def test_spatial_extent():
- for i in range(2):
- base = raster_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_north(120+i)
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = raster3d_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_north(120+i)
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = vector_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_north(120+i)
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = strds_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_north(120+i)
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = str3ds_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_north(120+i)
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = stvds_spatial_extent(ident="soil" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_north(120+i)
- base.update()
- base.select()
- base.print_self()
-
-def test_relative_timestamp():
- for i in range(2):
- base = raster_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_interval(i+1)
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = raster3d_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_interval(i+1)
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = vector_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_interval(i+1)
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = strds_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i, granularity=5.5)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_interval(i+1)
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = str3ds_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i, granularity=5.5)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_interval(i+1)
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = stvds_relative_time(ident="soil" + str(i) + "@PERMANENT", interval=i, granularity=5.5)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_interval(i+1)
- base.update()
- base.select()
- base.print_self()
-
-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", \
- cols=500, rows=400, number_of_cells=200000,nsres=1, ewres=1, min=0, max=33)
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_datatype("FCELL")
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- 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()
- base.print_self()
- base.clear()
- base.set_datatype("DCELL")
- base.update()
- base.select()
- base.print_self()
-
- for i in range(2):
- base = vector_metadata(ident="soil" + str(i) + "@PERMANENT", stvds_register="PERMANENT_soil_stvds_register")
- base.insert()
- base.select()
- base.print_self()
- base.clear()
- base.set_stvds_register("PERMANENT_soil_stvds_register")
- 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):
- base = vector_base(ident="water" + str(i) + "@PERMANENT", name="water" + str(i), mapset="PERMANENT", creator="soeren")
- base.insert()
- base = raster_base(ident="water" + str(i) + "@PERMANENT", name="water" + str(i), mapset="PERMANENT", creator="soeren")
- base.insert()
- base = raster3d_base(ident="water" + str(i) + "@PERMANENT", name="water" + str(i), mapset="PERMANENT", creator="soeren")
- base.insert()
-
- for i in range(10):
- base = vector_base(ident="water" + str(i) + "@PERMANENT")
- base.set_creator("rene")
- base.update()
- base = raster_base(ident="water" + str(i) + "@PERMANENT")
- base.set_creator("rene")
- base.update()
- base = raster3d_base(ident="water" + str(i) + "@PERMANENT")
- base.set_creator("rene")
- base.update()
-
- for i in range(10):
- base = vector_absolute_time(ident="water" + str(i) + "@PERMANENT", start_time=datetime.now(), end_time=datetime.now(), timezone=1)
- base.insert()
- base = raster_absolute_time(ident="water" + str(i) + "@PERMANENT", start_time=datetime.now(), end_time=datetime.now(), timezone=1)
- base.insert()
- base = raster3d_absolute_time(ident="water" + str(i) + "@PERMANENT", start_time=datetime.now(), end_time=datetime.now(), timezone=1)
- base.insert()
-
- for i in range(10):
- base = vector_absolute_time(ident="water" + str(i) + "@PERMANENT")
- base.set_start_time(datetime(2010, 6, 1))
- base.update()
- base = raster_absolute_time(ident="water" + str(i) + "@PERMANENT")
- base.set_start_time(datetime(2010, 6, 1))
- base.update()
- base = raster3d_absolute_time(ident="water" + str(i) + "@PERMANENT")
- base.set_start_time(datetime(2010, 6, 1))
- base.update()
-
- for i in range(10):
- base = vector_spatial_extent(ident="water" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
- base.insert()
- base = raster_spatial_extent(ident="water" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=0, bottom=0)
- base.insert()
- base = raster3d_spatial_extent(ident="water" + str(i) + "@PERMANENT", north=100 + i, south=10+i, east=50+i, west=20+i, top=i, bottom=0)
- base.insert()
-
- for i in range(10):
- base = vector_spatial_extent(ident="water" + str(i) + "@PERMANENT")
- base.set_north(120 + i)
- base.set_south(20 + i)
- base.update()
- base = raster_spatial_extent(ident="water" + str(i) + "@PERMANENT")
- base.set_north(120 + i)
- base.set_south(20 + i)
- base.update()
- base = raster3d_spatial_extent(ident="water" + str(i) + "@PERMANENT")
- base.set_north(120 + i)
- base.set_south(20 + i)
- base.update()
-
- for i in range(10):
- base = vector_metadata(ident="water" + str(i) + "@PERMANENT", stvds_register="PERMANENT_water_stvds_register")
- base.insert()
- base = raster_metadata(ident="water" + str(i) + "@PERMANENT", strds_register="PERMANENT_water_strds-register", datatype="CELL", \
- cols=500, rows=400, number_of_cells=200000,nsres=1, ewres=1, min=0, max=33)
- base.insert()
- base = raster3d_metadata(ident="water" + str(i) + "@PERMANENT", str3ds_register="PERMANENT_water_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()
-
- for i in range(10):
- base = vector_metadata(ident="water" + str(i) + "@PERMANENT")
- base.set_stvds_register("PERMANENT_water_stvds_register")
- base.update()
- base = raster_metadata(ident="water" + str(i) + "@PERMANENT")
- base.set_datatype("DCELL")
- base.update()
- base = raster3d_metadata(ident="water" + str(i) + "@PERMANENT")
- base.set_datatype("DCELL")
- base.update()
-
- for i in range(10):
- base = vector_base(ident="water" + str(i) + "@PERMANENT")
- base.select()
- base.print_self()
- base = raster_base(ident="water" + str(i) + "@PERMANENT")
- base.select()
- base.print_self()
- base = raster3d_base(ident="water" + str(i) + "@PERMANENT")
- base.select()
- base.print_self()
-
- print "Create a raster object"
-
- rds = raster_dataset("water0 at PERMANENT")
- rds.select()
- rds.print_self()
-
- print rds.temporal_relation(rds)
-
-def test_absolut_time_temporal_relations():
-
- A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
- end_time=datetime(year=2001, month=1, day=1), timezone=1)
- B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2001, month=1, day=1), \
- end_time=datetime(year=2002, month=1, day=1), timezone=1)
-
- print "Precedes: ", A.temporal_relation(B)
- print "Follows: ", B.temporal_relation(A)
-
- A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
- end_time=datetime(year=2001, month=1, day=1), timezone=1)
- B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2001, month=1, day=2), \
- end_time=datetime(year=2002, month=1, day=1), timezone=1)
-
- print "Before: ", A.temporal_relation(B)
- print "After: ", B.temporal_relation(A)
-
- A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
- end_time=datetime(year=2001, month=1, day=1), timezone=1)
- B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
- end_time=datetime(year=2002, month=1, day=1), timezone=1)
-
- print "Starts: ", A.temporal_relation(B)
- print "Started: ", B.temporal_relation(A)
-
- A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
- end_time=datetime(year=2001, month=1, day=1), timezone=1)
- B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2000, month=1, day=2), \
- end_time=datetime(year=2001, month=1, day=1), timezone=1)
-
- print "Finished: ", A.temporal_relation(B)
- print "Finishes: ", B.temporal_relation(A)
-
- A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
- end_time=datetime(year=2001, month=1, day=1), timezone=1)
- B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2000, month=3, day=1), \
- end_time=datetime(year=2000, month=9, day=1), timezone=1)
-
- print "Contains: ", A.temporal_relation(B)
- print "During: ", B.temporal_relation(A)
-
-
- A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
- end_time=datetime(year=2000, month=6, day=1), timezone=1)
- B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2000, month=3, day=1), \
- end_time=datetime(year=2000, month=9, day=1), timezone=1)
-
- print "Overlap: ", A.temporal_relation(B)
- print "Overlapped:", B.temporal_relation(A)
-
- A = raster_absolute_time(ident="test1 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
- end_time=datetime(year=2000, month=1, day=1), timezone=1)
- B = raster_absolute_time(ident="test2 at PERMANENT", start_time=datetime(year=2000, month=1, day=1), \
- end_time=datetime(year=2000, month=1, day=1), timezone=1)
-
- print "Equivalent:", A.temporal_relation(B)
- print "Equivalent:", B.temporal_relation(A)
-
-
-def test_raster_dataset():
-
- # Create a test map
- grass.raster.mapcalc("test = sin(x()) + cos(y())", overwrite = True)
-
- name = "test"
- mapset = grass.gisenv()["MAPSET"]
-
- 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()
-
- 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 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()
-
- 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)
-
- name = "test"
- mapset = grass.gisenv()["MAPSET"]
-
- 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()
-
- 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.update_from_registered_maps()
- strds.select()
- # Print self info
- strds.print_self()
- # Delete the dataset
- strds.delete()
-
-
-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 raster3d map in the mapset
- r3ds.load()
-
- print "Is raster3d 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 raster3d dataset
- str3ds.register_map(r3ds)
- # Print self info
- #r3ds.print_self()
-
- str3ds.update_from_registered_maps()
- str3ds.select()
- # Print self info
- str3ds.print_self()
- # Delete the dataset
- str3ds.delete()
-
-
-def test_stvds_dataset():
-
- name = "stvds_test_1"
- mapset = grass.gisenv()["MAPSET"]
-
- print "Create a stvds object"
-
- # We need to specify the name and the mapset as identifier
- stvds = space_time_vector_dataset(ident = name + "@" + mapset)
- # Check if in db
- print "Is stvds in db: ", stvds.is_in_db()
- # Create a new entry if not in db
- if stvds.is_in_db() == False:
- stvds.set_initial_values(temporal_type = "absolute", granularity="1 day",\
- semantic_type="event", title="This is a test space time vector dataset", description="A space time vector dataset for testing")
- stvds.insert()
-
- # Reread the data from the db
- stvds.select()
- # Print self info
- #stvds.print_self()
-
- # Create a test maps
- for i in range(11):
- name = "test" + str(i)
- mapset = grass.gisenv()["MAPSET"]
- ident = name + "@" + mapset
-
- i = i + 1
- grass.run_command("v.random", output=name, n=100, zmin=0, zmax=100, column="height" ,flags="z" , overwrite = True)
-
-
- print "Create a vector object"
-
- # We need to specify the name and the mapset as identifier
- vds = vector_dataset(ident)
-
- # Load data from the raster map in the mapset
- vds.load()
-
- print "Is vector in db: ", vds.is_in_db()
-
- if vds.is_in_db():
- vds.select()
- vds.print_self()
- # Remove the entry if it is in the db
- vds.delete()
- vds.reset(ident)
- vds.load()
-
- # Set the absolute valid time
- vds.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
- vds.insert()
- # Register the map in the space time raster dataset
- stvds.register_map(vds)
- # Print self info
- #vds.print_self()
-
- stvds.update_from_registered_maps()
- stvds.select()
- # Print self info
- stvds.print_self()
- # Delete the dataset
- stvds.delete()
-
-
-test_dict_sql_serializer()
-create_temporal_database()
-#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_strds_dataset()
-test_str3ds_dataset()
-test_stvds_dataset()
-test_increment_datetime_by_string()
Deleted: grass/trunk/lib/temporal/update_stds_spatial_temporal_extent_template.sql
===================================================================
--- grass/trunk/lib/temporal/update_stds_spatial_temporal_extent_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/update_stds_spatial_temporal_extent_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,66 +0,0 @@
---#############################################################################
--- This SQL script is to update the spatial and temporal extent as well as
--- the modifcation time and revision of a space time dataset. This script
--- should be called when maps inserted or deleted in a space time dataset.
---
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
--- 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
--- GRASS_MAP is a placeholder for specific map type: raster, raster3d or vector
--- STDS is a placeholder for specific space-time dataset type: strds, str3ds, stvds
-
--- UPDATE STDS_base SET modification_time = datetime("NOW") WHERE id = 'SPACETIME_ID';
--- UPDATE STDS_base SET revision = (revision + 1) WHERE id = 'SPACETIME_ID';
--- Number of registered maps
-UPDATE STDS_metadata SET number_of_maps =
- (SELECT count(id) FROM SPACETIME_NAME_GRASS_MAP_register)
- WHERE id = 'SPACETIME_ID';
--- Update the temporal extent
-UPDATE STDS_absolute_time SET start_time =
- (SELECT min(start_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE STDS_absolute_time SET end_time =
- (SELECT max(end_time) FROM GRASS_MAP_absolute_time WHERE GRASS_MAP_absolute_time.id IN
- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE STDS_relative_time SET start_time =
- (SELECT min(start_time) FROM GRASS_MAP_relative_time WHERE GRASS_MAP_relative_time.id IN
- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE STDS_relative_time SET end_time =
- (SELECT max(end_time) FROM GRASS_MAP_relative_time WHERE GRASS_MAP_relative_time.id IN
- (SELECT id FROM SPACETIME_NAME_GRASS_MAP_register)
- ) WHERE id = 'SPACETIME_ID';
--- Update the spatial extent
-UPDATE STDS_spatial_extent SET north =
- (SELECT max(north) 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 south =
- (SELECT min(south) 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 east =
- (SELECT max(east) 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 west =
- (SELECT min(west) 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 top =
- (SELECT max(top) 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 bottom =
- (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';
Deleted: grass/trunk/lib/temporal/update_str3ds_metadata_template.sql
===================================================================
--- grass/trunk/lib/temporal/update_str3ds_metadata_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/update_str3ds_metadata_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,51 +0,0 @@
---#############################################################################
--- This SQL script is to update a space-time raster3d dataset metadata
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
--- 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 min and max values
-UPDATE str3ds_metadata SET min_min =
- (SELECT min(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster3d_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE str3ds_metadata SET min_max =
- (SELECT max(min) FROM raster3d_metadata WHERE raster3d_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster3d_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE str3ds_metadata SET max_min =
- (SELECT min(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster3d_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE str3ds_metadata SET max_max =
- (SELECT max(max) FROM raster3d_metadata WHERE raster3d_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster3d_register)
- ) WHERE id = 'SPACETIME_ID';
--- Update the resolution
-UPDATE str3ds_metadata SET nsres_min =
- (SELECT min(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster3d_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE str3ds_metadata SET nsres_max =
- (SELECT max(nsres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster3d_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE str3ds_metadata SET ewres_min =
- (SELECT min(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster3d_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE str3ds_metadata SET ewres_max =
- (SELECT max(ewres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster3d_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE str3ds_metadata SET tbres_min =
- (SELECT min(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster3d_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE str3ds_metadata SET tbres_max =
- (SELECT max(tbres) FROM raster3d_metadata WHERE raster3d_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster3d_register)
- ) WHERE id = 'SPACETIME_ID';
Deleted: grass/trunk/lib/temporal/update_strds_metadata_template.sql
===================================================================
--- grass/trunk/lib/temporal/update_strds_metadata_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/update_strds_metadata_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,43 +0,0 @@
---#############################################################################
--- This SQL is to update a space-time raster dataset metadata
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
--- 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 min and max values
-UPDATE strds_metadata SET min_min =
- (SELECT min(min) FROM raster_metadata WHERE raster_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE strds_metadata SET min_max =
- (SELECT max(min) FROM raster_metadata WHERE raster_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE strds_metadata SET max_min =
- (SELECT min(max) FROM raster_metadata WHERE raster_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE strds_metadata SET max_max =
- (SELECT max(max) FROM raster_metadata WHERE raster_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster_register)
- ) WHERE id = 'SPACETIME_ID';
--- Update the resolution
-UPDATE strds_metadata SET nsres_min =
- (SELECT min(nsres) FROM raster_metadata WHERE raster_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE strds_metadata SET nsres_max =
- (SELECT max(nsres) FROM raster_metadata WHERE raster_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE strds_metadata SET ewres_min =
- (SELECT min(ewres) FROM raster_metadata WHERE raster_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster_register)
- ) WHERE id = 'SPACETIME_ID';
-UPDATE strds_metadata SET ewres_max =
- (SELECT max(ewres) FROM raster_metadata WHERE raster_metadata.id IN
- (SELECT id FROM SPACETIME_NAME_raster_register)
- ) WHERE id = 'SPACETIME_ID';
Deleted: grass/trunk/lib/temporal/update_stvds_metadata_template.sql
===================================================================
--- grass/trunk/lib/temporal/update_stvds_metadata_template.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/update_stvds_metadata_template.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,6 +0,0 @@
---#############################################################################
--- This SQL script is for now a placeholder, till the vector metadata
--- concept is clear
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
\ No newline at end of file
Deleted: grass/trunk/lib/temporal/vector_metadata_table.sql
===================================================================
--- grass/trunk/lib/temporal/vector_metadata_table.sql 2012-01-18 22:33:23 UTC (rev 50283)
+++ grass/trunk/lib/temporal/vector_metadata_table.sql 2012-01-19 00:11:22 UTC (rev 50284)
@@ -1,55 +0,0 @@
---#############################################################################
--- This SQL script generates the vector table to store
--- metadata for SQL queries and temporal GIS support.
---
--- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
---#############################################################################
-
---PRAGMA foreign_keys = ON;
-
--- The metadata table
-
-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
- PRIMARY KEY (id),
- FOREIGN KEY (id) REFERENCES vector_base (id) ON DELETE CASCADE
-);
-
--- Create the views to access all columns for the absolute and relative time
-
-CREATE VIEW vector_view_abs_time AS SELECT
- A1.id, A1.mapset,
- A1.name, A1.temporal_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time, A2.timezone,
- 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
- WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
-CREATE VIEW vector_view_rel_time AS SELECT
- A1.id, A1.mapset,
- A1.name, A1.temporal_type,
- A1.creation_time,
--- Uncommented due to performance issues
--- A1.modification_time, A1.revision,
- A1.creator,
- A2.start_time, A2.end_time,
- 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
- WHERE A1.id = A2.id AND A1.id = A3.id AND A1.id = A4.id;
-
--- Create a trigger to update the modification time and revision number in case the metadata or timestanps have been updated
--- Uncommented due to performance issues
---CREATE TRIGGER update_vector_metadata AFTER UPDATE ON vector_metadata
--- BEGIN
--- UPDATE vector_base SET modification_time = datetime("NOW") WHERE id = old.id;
--- UPDATE vector_base SET revision = (revision + 1) WHERE id = old.id;
--- END;
More information about the grass-commit
mailing list