[GRASS-SVN] r74138 - grass/branches/releasebranch_7_6/vector/v.in.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Feb 28 01:20:10 PST 2019


Author: mmetz
Date: 2019-02-28 01:20:10 -0800 (Thu, 28 Feb 2019)
New Revision: 74138

Modified:
   grass/branches/releasebranch_7_6/vector/v.in.ogr/main.c
Log:
v.in.ogr: set spatial filter to correct geometry field if geometry option is given (backport trunk r74137)

Modified: grass/branches/releasebranch_7_6/vector/v.in.ogr/main.c
===================================================================
--- grass/branches/releasebranch_7_6/vector/v.in.ogr/main.c	2019-02-28 09:02:06 UTC (rev 74137)
+++ grass/branches/releasebranch_7_6/vector/v.in.ogr/main.c	2019-02-28 09:20:10 UTC (rev 74138)
@@ -768,7 +768,22 @@
 
 	for (layer = 0; layer < nlayers; layer++) {
 	    Ogr_layer = ds_getlayerbyindex(Ogr_ds, layers[layer]);
+#if GDAL_VERSION_NUM >= 1110000
+	    if (param.geom->answer) {
+		Ogr_featuredefn = OGR_L_GetLayerDefn(Ogr_layer);
+		igeom = OGR_FD_GetGeomFieldIndex(Ogr_featuredefn, param.geom->answer);
+		if (igeom < 0)
+		    G_fatal_error(_("Geometry column <%s> not found in input layer <%s>"),
+				  param.geom->answer, OGR_L_GetName(Ogr_layer));
+
+		OGR_L_SetSpatialFilterEx(Ogr_layer, igeom, poSpatialFilter[layer]);
+	    }
+	    else {
+		OGR_L_SetSpatialFilter(Ogr_layer, poSpatialFilter[layer]);
+	    }
+#else
 	    OGR_L_SetSpatialFilter(Ogr_layer, poSpatialFilter[layer]);
+#endif
 	    if (OGR_L_SetAttributeFilter(Ogr_layer, attr_filter) != OGRERR_NONE)
 		G_fatal_error(_("Error setting attribute filter '%s'"),
 			      attr_filter);
@@ -2179,6 +2194,8 @@
 
 	    /* use OGR extents if possible, needed to skip corrupted data
 	     * in OGR dsn/layer */
+	    /* BUT: OGR extents are unreliable, 
+	     * sometimes excluding valid features */
 	    have_ogr_extent[layer] = 1;
 	}
 	/* OGR_L_GetExtent(): 
@@ -2236,7 +2253,10 @@
     for (layer = 0; layer < nlayers; layer++) {
 	int have_filter = 0;
 
-	if (have_ogr_extent[layer]) {
+	/* OGR extents are unreliable, 
+	 * sometimes excluding valid features:
+	 * disabled */
+	if (0 && have_ogr_extent[layer]) {
 	    if (*xmin <= *xmax && *ymin <= *ymax) {
 		/* check for any overlap */
 		if (xminl[layer] > *xmax || xmaxl[layer] < *xmin ||



More information about the grass-commit mailing list