Prechádzať zdrojové kódy

Enable default mapset specific temporal database creation using g.gisenv set="TGIS_USE_CURRENT_MAPSET=1". This variable can be located in gisrc or in the mapset settings.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@61157 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 11 rokov pred
rodič
commit
63b661231b

+ 2 - 8
lib/python/temporal/unittests_register.py

@@ -20,6 +20,8 @@ class TestRegisterFunctions(unittest.TestCase):
     def setUpClass(cls):
         """!Initiate the temporal GIS and set the region
         """
+        # Use always the current mapset as temporal database
+        ret = grass.run_command("g.gisenv",  set="TGIS_USE_CURRENT_MAPSET=1")
         tgis.init()
         grass.overwrite = True
         grass.use_temp_region()
@@ -67,8 +69,6 @@ class TestRegisterFunctions(unittest.TestCase):
         self.assertEqual(start, datetime.datetime(2001, 1, 1))
         self.assertEqual(end, datetime.datetime(2001, 1, 3))
 
-        self.strds_abs.print_info()
-
     def test_absolute_time_strds_2(self):
         """!Test the registration of maps with absolute time in a
            space time raster dataset.
@@ -100,8 +100,6 @@ class TestRegisterFunctions(unittest.TestCase):
         self.assertEqual(start, datetime.datetime(2001, 1, 1))
         self.assertEqual(end, datetime.datetime(2001, 1, 3))
 
-        self.strds_abs.print_info()
-
     def test_absolute_time_1(self):
         """!Test the registration of maps with absolute time
         """
@@ -189,8 +187,6 @@ class TestRegisterFunctions(unittest.TestCase):
         self.assertEqual(start, 0)
         self.assertEqual(end, 2)
         self.assertEqual(unit, "day")
-        
-        self.strds_rel.print_info()
 
     def test_relative_time_strds_2(self):
         """!Test the registration of maps with relative time in a
@@ -224,8 +220,6 @@ class TestRegisterFunctions(unittest.TestCase):
         self.assertEqual(end, 2000000)
         self.assertEqual(unit, "seconds")
         
-        self.strds_rel.print_info()
-        
     def test_relative_time_1(self):
         """!Test the registration of maps with relative time
         """

+ 19 - 2
lib/temporal/lib/default_name.c

@@ -39,9 +39,26 @@ const char *tgis_get_default_driver_name(void)
 char *tgis_get_default_database_name(void)
 {
     char default_connection[2048];
+    char use_current_mapset = 0;
 
-    G_snprintf(default_connection, 2048, "%s/%s/%s", G_gisdbase(), G_location(),
-               TGISDB_DEFAULT_SQLITE_PATH);
+    /* Check GRASS environmental variable if mapset specific
+     * temporal databases should be created 
+     * */
+
+    if(G__getenv2("TGIS_USE_CURRENT_MAPSET", G_VAR_MAPSET)) {
+        use_current_mapset = 1;
+    } else {
+        if(G__getenv2("TGIS_USE_CURRENT_MAPSET", G_VAR_GISRC))
+            use_current_mapset = 1;
+    }
+
+    if(!use_current_mapset) {
+        G_snprintf(default_connection, 2048, "%s/%s/%s", G_gisdbase(), G_location(),
+                   TGISDB_DEFAULT_SQLITE_PATH);
+    } else {
+        G_snprintf(default_connection, 2048, "%s/%s/%s/tgis/sqlite.db", G_gisdbase(), G_location(),
+                   G_mapset());
+    }
 
     return G_store(default_connection);
 }