Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize prepared polygon distance #693

Merged
merged 2 commits into from
Sep 28, 2022

Conversation

dbaston
Copy link
Member

@dbaston dbaston commented Sep 27, 2022

The implementation of PreparedPolygonDistance begins with a call to PreparedPolygonIntersects to cover the case where a containment relationship exists between the target and test geometries. However, the segment intersection test performed by PreparedPolygonIntersects is unnecessary. If any segment intersect, they will be found by IndexedFacetDistance.

This PR improves the performance of PreparedPolygonDistance by performing the PIP containment tests directly within PreparedPolygonDistance and avoiding the call to PreparedPolygonIntersects. In the following performance test, which relies heavily on PreparedPolygonDistance, runtime is reduced by 45%.

bin/geosop clusterWithin 1e-3 -t -q -a ~/data/world.wkt

This should bring additional performance improvements to #692.

@dbaston
Copy link
Member Author

dbaston commented Sep 27, 2022

This also brings performance of prepared zero-distance check ahead of prepared intersection testing. I think this essentially means IndexedFacetDistance is outperforming MCIndexSegmentSetMutualIntersector for this dataset.

@pramsey
Copy link
Member

pramsey commented Sep 27, 2022

Good get!

@dbaston dbaston force-pushed the prepared-polygon-distance-opt branch from bd250da to a260d10 Compare September 28, 2022 12:46
@dbaston dbaston merged commit a260d10 into libgeos:main Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants