I have to build a grid of points and remove the points that falls inside a polygon. Polygons are defined in a ESRI shapefile, points are in a list.
This is how I make the test:
OGRLayer *layer = mShapefile->GetLayer(lr);
layer->ResetReading();
layer->SetSpatialFilter(&point); //getting only the feature intercepting the point
OGRFeature *ftr;
while (( ftr = layer->GetNextFeature()) != 0) {
if (point.Within(ftr->GetGeometryRef())) {
n.good = false;
break;
}
}
This code works perfectly on Linux (Ubuntu 14.10, GDAL 1.11).
I had to recompile the library under MinGW64, first I forgot to compile with GEOS and the Within() call always returned false (as defined in the API).
If I compile with GEOS, the result is apparently a random response - some point outside the polygon set is filtered out, other inside are accepted.
Is there any known issue, or workaround, or maybe did I forget some other required library for gdal to work properly?
In a previous version I was only testing for results of GetNextFeature(), and it worked perfectly under linux. Under MinGW I found the same strange result.