[GRASS-SVN] r70246 - in grass/branches/releasebranch_7_2: lib/vector/Vlib vector/v.external

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jan 4 06:38:51 PST 2017


Author: martinl
Date: 2017-01-04 06:38:51 -0800 (Wed, 04 Jan 2017)
New Revision: 70246

Modified:
   grass/branches/releasebranch_7_2/lib/vector/Vlib/build_ogr.c
   grass/branches/releasebranch_7_2/vector/v.external/main.c
Log:
v.external: fix check_projection() when input is PG datasource (and native GRASS PostGIS reader is used)
vlib/ogr: be quiet when trying to commit transaction (probably there is no active)
          (relbr72: merge r70244, r70245 from trunk)


Modified: grass/branches/releasebranch_7_2/lib/vector/Vlib/build_ogr.c
===================================================================
--- grass/branches/releasebranch_7_2/lib/vector/Vlib/build_ogr.c	2017-01-04 14:34:23 UTC (rev 70245)
+++ grass/branches/releasebranch_7_2/lib/vector/Vlib/build_ogr.c	2017-01-04 14:38:51 UTC (rev 70246)
@@ -25,6 +25,7 @@
 
 #ifdef HAVE_OGR
 #include <ogr_api.h>
+#include <cpl_error.h>
 #endif
 
 #include "local_proto.h"
@@ -72,8 +73,12 @@
 	return 0;
     }
     
-    if (OGR_L_TestCapability(ogr_info->layer, OLCTransactions))
-	OGR_L_CommitTransaction(ogr_info->layer);
+    if (OGR_L_TestCapability(ogr_info->layer, OLCTransactions)) {
+        CPLPushErrorHandler(CPLQuietErrorHandler); 
+	if (OGR_L_CommitTransaction(ogr_info->layer) != OGRERR_NONE)
+            G_debug(1, "Unable to commit transation");
+        CPLPushErrorHandler(CPLDefaultErrorHandler); 
+    }
 
     /* test layer capabilities */
     if (!OGR_L_TestCapability(ogr_info->layer, OLCRandomRead)) {

Modified: grass/branches/releasebranch_7_2/vector/v.external/main.c
===================================================================
--- grass/branches/releasebranch_7_2/vector/v.external/main.c	2017-01-04 14:34:23 UTC (rev 70245)
+++ grass/branches/releasebranch_7_2/vector/v.external/main.c	2017-01-04 14:38:51 UTC (rev 70246)
@@ -85,8 +85,9 @@
     }
     
 #ifdef HAVE_OGR
-    if (use_ogr)
-        OGRRegisterAll();
+    /* GDAL drivers must be registered since check_projection()
+     * depends on it (even use_ogr is false)*/
+    OGRRegisterAll();
 #endif
 
     if (flags.format->answer) {
@@ -135,7 +136,9 @@
 
     /* check projection match */
     if (!flags.override->answer) {
-        check_projection(dsn, ilayer);
+        /* here must be used original dsn since check_projection() is
+         * using GDAL library */
+        check_projection(options.dsn->answer, ilayer);
     }
     
     /* create new vector map */



More information about the grass-commit mailing list