Kaynağa Gözat

New directory structure. Added temporal C-library with temporal database init functions.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@50284 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 13 yıl önce
ebeveyn
işleme
f894432db8

+ 7 - 11
lib/temporal/Makefile

@@ -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) $< $@

lib/temporal/map_stds_register_table_template.sql → lib/temporal/SQL/map_stds_register_table_template.sql


lib/temporal/map_tables_template.sql → lib/temporal/SQL/map_tables_template.sql


lib/temporal/raster3d_metadata_table.sql → lib/temporal/SQL/raster3d_metadata_table.sql


lib/temporal/raster_metadata_table.sql → lib/temporal/SQL/raster_metadata_table.sql


lib/temporal/sqlite3_delete_trigger.sql → lib/temporal/SQL/sqlite3_delete_trigger.sql


lib/temporal/stds_map_register_table_template.sql → lib/temporal/SQL/stds_map_register_table_template.sql


lib/temporal/stds_raster3d_register_trigger_template.sql → lib/temporal/SQL/stds_raster3d_register_trigger_template.sql


lib/temporal/stds_raster_register_trigger_template.sql → lib/temporal/SQL/stds_raster_register_trigger_template.sql


lib/temporal/stds_tables_template.sql → lib/temporal/SQL/stds_tables_template.sql


lib/temporal/stds_vector_register_trigger_template.sql → lib/temporal/SQL/stds_vector_register_trigger_template.sql


lib/temporal/str3ds_metadata_table.sql → lib/temporal/SQL/str3ds_metadata_table.sql


lib/temporal/strds_metadata_table.sql → lib/temporal/SQL/strds_metadata_table.sql


lib/temporal/stvds_metadata_table.sql → lib/temporal/SQL/stvds_metadata_table.sql


lib/temporal/test.temporal.py → lib/temporal/SQL/test.temporal.py


lib/temporal/update_stds_spatial_temporal_extent_template.sql → lib/temporal/SQL/update_stds_spatial_temporal_extent_template.sql


lib/temporal/update_str3ds_metadata_template.sql → lib/temporal/SQL/update_str3ds_metadata_template.sql


lib/temporal/update_strds_metadata_template.sql → lib/temporal/SQL/update_strds_metadata_template.sql


lib/temporal/update_stvds_metadata_template.sql → lib/temporal/SQL/update_stvds_metadata_template.sql


lib/temporal/vector_metadata_table.sql → lib/temporal/SQL/vector_metadata_table.sql


+ 14 - 0
lib/temporal/src/Makefile

@@ -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

+ 52 - 0
lib/temporal/src/connect.c

@@ -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;
+}

+ 77 - 0
lib/temporal/src/default_name.c

@@ -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;
+}