[GRASS-SVN] r61983 - in grass/trunk: include lib/temporal/lib

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 15 15:29:55 PDT 2014


Author: huhabla
Date: 2014-09-15 15:29:55 -0700 (Mon, 15 Sep 2014)
New Revision: 61983

Modified:
   grass/trunk/include/temporal.h
   grass/trunk/lib/temporal/lib/connect.c
   grass/trunk/lib/temporal/lib/default_name.c
Log:
temporal library: Default temporal database path is now mapset specific. Correct handling of environment switch for mapset specific metadata reading. 

Modified: grass/trunk/include/temporal.h
===================================================================
--- grass/trunk/include/temporal.h	2014-09-15 18:51:01 UTC (rev 61982)
+++ grass/trunk/include/temporal.h	2014-09-15 22:29:55 UTC (rev 61983)
@@ -7,7 +7,8 @@
 
 
 #define TGISDB_DEFAULT_DRIVER "sqlite"
-#define TGISDB_DEFAULT_SQLITE_PATH "PERMANENT/tgis/sqlite.db"
+/* Default path in the current location */
+#define TGISDB_DEFAULT_SQLITE_PATH "tgis/sqlite.db"
 
 
 int tgis_set_connection(dbConnection * connection);

Modified: grass/trunk/lib/temporal/lib/connect.c
===================================================================
--- grass/trunk/lib/temporal/lib/connect.c	2014-09-15 18:51:01 UTC (rev 61982)
+++ grass/trunk/lib/temporal/lib/connect.c	2014-09-15 22:29:55 UTC (rev 61983)
@@ -91,26 +91,28 @@
 {
     const char *val = NULL;
     char *ret_val = NULL;
-    const char *orig_mapset;
     int ret;
 
-    orig_mapset = G__getenv("MAPSET");
-
-    ret = G__mapset_permissions2(G__getenv("GISDBASE"), G__getenv("LOCATION_NAME"), mapset);
+    ret = G__mapset_permissions2(G__getenv("GISDBASE"), 
+                                 G__getenv("LOCATION_NAME"), mapset);
     switch (ret) {
     case 0:
-        G_fatal_error(_("You don't have permission to access the mapset <%s>"),
+        G_warning(_("You don't have permission to access the mapset <%s>"),
                       mapset);
         break;
     case -1:
-        G_fatal_error(_("Mapset <%s> does not exist."),
+        G_warning(_("Mapset <%s> does not exist."),
 	              mapset);
         break;
     default:
         break;
     }    
 
-    G_setenv("MAPSET", mapset);
+    G_create_alt_env();
+    G__setenv("GISDBASE", G_gisdbase());
+    G__setenv("LOCATION_NAME", G_location());
+    G__setenv("MAPSET", mapset);
+    G__read_mapset_env();
  
     if(contype == DATABASE_NAME) {
         if ((val = G__getenv2("TGISDB_DATABASE", G_VAR_MAPSET)))
@@ -120,7 +122,7 @@
             ret_val = G_store(val);
     }
 
-    G_setenv("MAPSET", orig_mapset);
+    G_switch_env();
     
     return ret_val;
 }
@@ -129,8 +131,8 @@
 /*!
  * \brief Get TGIS driver name from a specific mapset
  *
- * This function will call G_fatal_error() in case the mapset does not exists
- * or it is not allowed to access the mapset.
+ * This function give a warning in case the mapset does not exists
+ * or it is not allowed to access the mapset. NULL is returned in this case.
  * 
  * \param mapset The name of the mapset to receive the driver name from
  *
@@ -145,8 +147,8 @@
 /*!
  * \brief Get TGIS database name
  * 
- * This function will call G_fatal_error() in case the mapset does not exists
- * or it is not allowed to access the mapset.
+ * This function give a warning in case the mapset does not exists
+ * or it is not allowed to access the mapset. NULL is returned in this case..
  * 
  * \param mapset The name of the mapset to receive the driver name from
  

Modified: grass/trunk/lib/temporal/lib/default_name.c
===================================================================
--- grass/trunk/lib/temporal/lib/default_name.c	2014-09-15 18:51:01 UTC (rev 61982)
+++ grass/trunk/lib/temporal/lib/default_name.c	2014-09-15 22:29:55 UTC (rev 61983)
@@ -39,27 +39,10 @@
 char *tgis_get_default_database_name(void)
 {
     char default_connection[2048];
-    char use_current_mapset = 0;
 
-    /* Check GRASS environmental variable if mapset specific
-     * temporal databases should be created 
-     * */
+    G_snprintf(default_connection, 2048, "%s/%s/%s/%s", G_gisdbase(), G_location(),
+               G_mapset(), TGISDB_DEFAULT_SQLITE_PATH);
 
-    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