Skip to content

Commit

Permalink
v.in.ogr: fix OGR extents
Browse files Browse the repository at this point in the history
  • Loading branch information
metzm committed May 22, 2019
1 parent 15f53e8 commit ee6de70
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions vector/v.in.ogr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit ee6de70

Please sign in to comment.