Add adaptiverMeterDist() - #15
Draft
patrickbr wants to merge 4 commits into
Draft
Conversation
…(exact iterative method) and `andoyerLambert()` (refinement of haversine to correct for sphere approximation) and add `adaptiveMeterDist()` methods which try to select haversine, andoyerLambert and then vincenty (ordered here in computation cost) based on a given tolerance factor in meters (0.5 per default) AND ALSO use haversine for points which are nearly antipodal (all the spheriod methods fail catatrophically then)
patrickbr
marked this pull request as draft
August 21, 2026 13:40
Member
Author
|
Tests not updated and thus fail because they assume the old earth radius. |
Member
Author
|
Some preliminary local (laptop) performance tests on meter dist, haversine vs. adaptive: malta self-join within distance 50m: 61.1s vs 118s (2x)
Performance may be improved by a bounded version (if the bound is >> haversine, haversine (or even euclidean distance) can be used directly) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
For the meter distance calc, this PR adds methods
vincenty()(exact iterative method) andandoyerLambert()(refinement of haversine to correct for sphere approximation).It also adds an
adaptiveMeterDist()methods which tries to select haversine, andoyerLambert and then vincenty based on a given tolerance factor in meters (0.5 per default). The idea is to use haversine for short distances (up to around 100 meters), andoyerLambert for distance to up to around 100 km, and vincenty for everything else to guarantee a max error of 50cmNo performance test yet.
Also use the mean earth radius in haversine, not the equiatorial radius.