Added a spatial index to the overlayng polygonbuilder #1379
+12
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR ports this JTS PR to GEOS. It adds a spatial index to the polygonbuilder in overlayNG.
The proposed implementation differs from the JTS implementation, since the latter uses an HPR-tree (Hilbert-packed R-tree) as the spatial filter. The implementation of the HPR-tree has not yet been ported to GEOS, so I'm using an STR-tree here instead. Following the discussion at the JTS PR, the adverse consequences should be insignificant.
The performance improvements are substantial. Similar to this GEOS PR, I benchmarked the code using a difference operation between two MultiPolygons. To simulate real-world data, I used datasets taken from OSM. Specifically, I took the landmass of a region, and subtracted all its rivers and lakes. The resulting runtimes are listed in the table below.
All timings have been obtained by taking the average runtime of 5 independent runs. The improvement becomes pretty significant for large objects (~20x improvement for USA), signifying that this PR removes a considerable bottleneck in the old implementation. I also verified that the two implementations produce the same results by comparing the areas of the resulting objects.