[GRASS-SVN] r65677 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 20 01:34:53 PDT 2015


Author: martinl
Date: 2015-07-20 01:34:53 -0700 (Mon, 20 Jul 2015)
New Revision: 65677

Modified:
   grass/trunk/lib/vector/Vlib/close.c
   grass/trunk/lib/vector/Vlib/close_nat.c
   grass/trunk/lib/vector/Vlib/local_proto.h
   grass/trunk/lib/vector/Vlib/open.c
Log:
vlib: fix GRASS_VECTOR_TEMPORARY when creating temporary maps using Vect_open_new_tmp()


Modified: grass/trunk/lib/vector/Vlib/close.c
===================================================================
--- grass/trunk/lib/vector/Vlib/close.c	2015-07-20 08:02:19 UTC (rev 65676)
+++ grass/trunk/lib/vector/Vlib/close.c	2015-07-20 08:34:53 UTC (rev 65677)
@@ -5,7 +5,7 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2009, 2011-2012 by the GRASS Development Team
+   (C) 2001-2015 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.

Modified: grass/trunk/lib/vector/Vlib/close_nat.c
===================================================================
--- grass/trunk/lib/vector/Vlib/close_nat.c	2015-07-20 08:02:19 UTC (rev 65676)
+++ grass/trunk/lib/vector/Vlib/close_nat.c	2015-07-20 08:34:53 UTC (rev 65677)
@@ -59,7 +59,7 @@
         char *env = getenv("GRASS_VECTOR_TEMPORARY");
 
         delete = TRUE;
-        if (env) {
+        if (Map->temporary == TEMPORARY_MAP_ENV && env) {
             if (G_strcasecmp(env, "move") == 0) {
                 /* copy temporary vector map to the current mapset */
                 char path_tmp[GPATH_MAX], path_map[GPATH_MAX];
@@ -82,6 +82,7 @@
 
 #ifdef TEMPORARY_MAP_DB
                 int i, ndblinks;
+                int tmp;
                 
                 struct field_info *fi;
                 dbConnection connection;
@@ -109,9 +110,10 @@
                 }
                 G_free(Map->dblnk);
                 Map->dblnk = dblinks;
-                Map->temporary = FALSE;
+                tmp = Map->temporary;
+                Map->temporary = TEMPORARY_MAP_DISABLED;
                 Vect_write_dblinks(Map);
-                Map->temporary = TRUE;
+                Map->temporary = tmp;
 #endif
             }
             else if (G_strcasecmp(env, "delete") == 0) {
@@ -125,7 +127,11 @@
                 delete = FALSE;
             }
         }
-
+        else if (Map->temporary == TEMPORARY_MAP) {
+            G_debug(1, "V1_close_nat(): temporary map <%s> TO BE DELETED", Map->name);
+            delete = TRUE;
+        }
+        
         if (delete) {
             char path_tmp[GPATH_MAX];
 

Modified: grass/trunk/lib/vector/Vlib/local_proto.h
===================================================================
--- grass/trunk/lib/vector/Vlib/local_proto.h	2015-07-20 08:02:19 UTC (rev 65676)
+++ grass/trunk/lib/vector/Vlib/local_proto.h	2015-07-20 08:34:53 UTC (rev 65677)
@@ -10,6 +10,11 @@
 /*! Attributes of temporary maps */
 /* #define TEMPORARY_MAP_DB */
 
+/*! Temporary mode */
+#define TEMPORARY_MAP_DISABLED 0
+#define TEMPORARY_MAP_ENV      1
+#define TEMPORARY_MAP          2
+
 /* Internal vector library subroutines which are not part of public
    API*/
 

Modified: grass/trunk/lib/vector/Vlib/open.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open.c	2015-07-20 08:02:19 UTC (rev 65676)
+++ grass/trunk/lib/vector/Vlib/open.c	2015-07-20 08:34:53 UTC (rev 65677)
@@ -6,7 +6,7 @@
   
   Higher level functions for reading/writing/manipulating vectors.
   
-  (C) 2001-2009, 2012-2013 by the GRASS Development Team
+  (C) 2001-2015 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.
@@ -154,7 +154,7 @@
  \param update non-zero to open for update otherwise read-only mode
  \param head_only read only header info from 'head', 'dbln', 'topo',
  'cidx' is not opened. The header may be opened on level 2 only.
- \param is_tmp TRUE for temporary maps
+ \param is_tmp non-zero code for temporary maps
 
  \return level of openness (1, 2)
  \return -1 in error
@@ -175,7 +175,7 @@
             is_tmp);
     
     if (update && !is_tmp) {
-        is_tmp = getenv("GRASS_VECTOR_TEMPORARY") ? TRUE : FALSE;
+        is_tmp = getenv("GRASS_VECTOR_TEMPORARY") ? TEMPORARY_MAP_ENV : TEMPORARY_MAP_DISABLED;
         G_debug(1, "Vect__open_old(): is_tmp = %d (check GRASS_VECTOR_TEMPORARY)", is_tmp);
     }
 
@@ -912,7 +912,7 @@
 {
     int is_tmp;
     
-    is_tmp = getenv("GRASS_VECTOR_TEMPORARY") ? TRUE : FALSE;
+    is_tmp = getenv("GRASS_VECTOR_TEMPORARY") ? TEMPORARY_MAP_ENV : TEMPORARY_MAP_DISABLED;
     G_debug(1, "Vect_open_new(): is_tmp = %d", is_tmp);
     
     return open_new(Map, name, with_z, is_tmp);
@@ -950,7 +950,7 @@
     }
     G_debug(1, "Vect_open_tmp_new(): name = '%s' with_z = %d", name, with_z);
 
-    return open_new(Map, tmp_name, with_z, TRUE); /* temporary map */
+    return open_new(Map, tmp_name, with_z, TEMPORARY_MAP); /* temporary map */
 }
 
 /*!
@@ -1300,7 +1300,7 @@
              * in the native format and when closing the map
              * transferred to output OGR layer */
             format = GV_FORMAT_NATIVE;
-            Map->temporary = TRUE;
+            Map->temporary = TEMPORARY_MAP;
         }
         fp = G_fopen_old("", "OGR", G_mapset());
         if (!fp) {
@@ -1417,7 +1417,7 @@
                  * in the native format and when closing the map
                  * transferred to output PostGIS layer */
                 format = GV_FORMAT_NATIVE;
-                Map->temporary = TRUE;
+                Map->temporary = TEMPORARY_MAP;
             }
         }
     }



More information about the grass-commit mailing list