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

Improve LineStringSnapper performance by using squared distance #1111

Merged
merged 3 commits into from
Jan 23, 2025

Conversation

micycle1
Copy link
Contributor

@micycle1 micycle1 commented Jan 11, 2025

Prompted by #1110.

commit 1 - we get a ~10% increase by removing assignments to the seg object and working with coordinates directly.
commit 2 - a further ~15% increase vs sqrt-based distance. Does add to the public API (because different package access required) which might not be desirable
(Also, I'm sure there are a lot of other code areas that could benefit from the same approach -- working with squared distances and avoiding sqrt()).

remove empty seg object

Signed-off-by: Michael Carleton <micycle1@hotmail.co.uk>
@micycle1 micycle1 changed the title linesnapper - free small speedup LineStringSnapper Performance Improvement Jan 11, 2025
@dr-jts
Copy link
Contributor

dr-jts commented Jan 23, 2025

Looks good, thanks.

I might do a bit of renaming/refactoring as a followup to this PR.

@dr-jts dr-jts merged commit ac7a165 into locationtech:master Jan 23, 2025
1 check passed
@dr-jts dr-jts changed the title LineStringSnapper Performance Improvement Improve LineStringSnapper performance by using squared distance Jan 23, 2025
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.

2 participants