Skip to content

Add adaptiverMeterDist() - #15

Draft
patrickbr wants to merge 4 commits into
masterfrom
adaptive-meter
Draft

Add adaptiverMeterDist()#15
patrickbr wants to merge 4 commits into
masterfrom
adaptive-meter

Conversation

@patrickbr

@patrickbr patrickbr commented Aug 21, 2026

Copy link
Copy Markdown
Member

For the meter distance calc, this PR adds methods vincenty() (exact iterative method) and andoyerLambert() (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 50cm

No performance test yet.

Also use the mean earth radius in haversine, not the equiatorial radius.

…(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
patrickbr marked this pull request as draft August 21, 2026 13:40
@patrickbr

Copy link
Copy Markdown
Member Author

Tests not updated and thus fail because they assume the old earth radius.

@patrickbr

patrickbr commented Aug 21, 2026

Copy link
Copy Markdown
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)
distance single polygon Germany vs single polygon Spain: 12s vs 50s (4x)

POINT(0, 1) vs POINT(0, 0) now returns ~110574 meters as expected in ad-freiburg/qlever#2989

Performance may be improved by a bounded version (if the bound is >> haversine, haversine (or even euclidean distance) can be used directly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant