OGR Layer Intersection: Add support for GEOS rectangle intersections
Expected behaviour and actual behaviour.
GEOS 3.5 added support for faster intersection calculations when using rectangles (see https://trac.osgeo.org/geos/ticket/699 ). It would be useful if this were added to the OGR Layer Intersection method as an option, e.g. via USE_RECTANGLE_INTERSECTION=yes.
Some quick and dirty benchmarking with my own data shows a substantial speed up when the GEOS library is built with rectangle support (one large and complex polygon intersected with a fishnet of smaller square polygons went from 768s down to 130s). Implementing the rectangle methods in OGR should show similar improvements.
Transparent support for rectangle intersections is disabled in GEOS due to issues with invalid polygons, but the OGR layer intersection documentation already raises such a caveat so in that sense it does not change the expected validity of any results.
I am not sure what minimum version of GEOS is supported by OGR, so a version guard might also be needed.
Steps to reproduce the problem.
Nil - not currently implemented.
Operating system
All
GDAL version and provenance
Feature request, not currently implemented.
@shawnlaffan How did you test this? Could you possibly share some code?
@rouault Some years ago @ajolma added the USE_PREPARED_GEOMETRIES and PRETEST_CONTAINMENT options to OGR Layer Intersection. Any chance that this might also be added quickly in the sense of implementation? Or is this more complex.
If @shawnlaffan benchmarking would scale well, this would speed up my processing significantly.
@kmuehlbauer - For testing, I recompiled GEOS with USE_RECTANGLE_INTERSECTION defined (I edited the header file) and re-ran my existing code.
(one large and complex polygon intersected with a fishnet of smaller square polygons went from 768s down to 130s).
This special case can benefit from more optimization than is possible with repeated calls to GEOSClipByRect: see https://github.com/libgeos/geos/issues/967