Forráskód Böngészése

v.in.ogr: fix OGR extents

Markus Metz 6 éve
szülő
commit
2292e30cf2
1 módosított fájl, 20 hozzáadás és 2 törlés
  1. 20 2
      vector/v.in.ogr/main.c

+ 20 - 2
vector/v.in.ogr/main.c

@@ -2192,10 +2192,28 @@ int create_spatial_filter(ds_t Ogr_ds, OGRGeometryH *poSpatialFilter,
 	    yminl[layer] = oExt.MinY;
 	    ymaxl[layer] = oExt.MaxY;
 
+	    /* OGR extents are unreliable,
+	     * sometimes excluding valid features
+	     * reason: converting double to float or %.6g and back
+	     * -> expand a bit */
+	    G_debug(2, "xmin old: %.15g", xminl[layer]);
+	    xminl[layer] = xminl[layer] - fabs(xminl[layer] * 2.0e-6);
+	    G_debug(2, "xmin new: %.15g", xminl[layer]);
+
+	    G_debug(2, "xmax old: %.15g", xmaxl[layer]);
+	    xmaxl[layer] = xmaxl[layer] + fabs(xmaxl[layer] * 2.0e-6);
+	    G_debug(2, "xmax new: %.15g", xmaxl[layer]);
+
+	    G_debug(2, "ymin old: %.15g", yminl[layer]);
+	    yminl[layer] = yminl[layer] - fabs(yminl[layer] * 2.0e-6);
+	    G_debug(2, "ymin new: %.15g", yminl[layer]);
+
+	    G_debug(2, "ymax old: %.15g", ymaxl[layer]);
+	    ymaxl[layer] = ymaxl[layer] + fabs(ymaxl[layer] * 2.0e-6);
+	    G_debug(2, "ymax new: %.15g", ymaxl[layer]);
+
 	    /* 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():