[GRASS-SVN] r61157 - in grass/trunk/lib: python/temporal temporal/lib
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jul 4 09:44:59 PDT 2014
Author: huhabla
Date: 2014-07-04 09:44:59 -0700 (Fri, 04 Jul 2014)
New Revision: 61157
Modified:
grass/trunk/lib/python/temporal/unittests_register.py
grass/trunk/lib/temporal/lib/default_name.c
Log:
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.
Modified: grass/trunk/lib/python/temporal/unittests_register.py
===================================================================
--- grass/trunk/lib/python/temporal/unittests_register.py 2014-07-04 14:01:41 UTC (rev 61156)
+++ grass/trunk/lib/python/temporal/unittests_register.py 2014-07-04 16:44:59 UTC (rev 61157)
@@ -20,6 +20,8 @@
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 @@
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 @@
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 @@
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 @@
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
"""
Modified: grass/trunk/lib/temporal/lib/default_name.c
===================================================================
--- grass/trunk/lib/temporal/lib/default_name.c 2014-07-04 14:01:41 UTC (rev 61156)
+++ grass/trunk/lib/temporal/lib/default_name.c 2014-07-04 16:44:59 UTC (rev 61157)
@@ -39,10 +39,27 @@
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);
}
More information about the grass-commit
mailing list