Repository navigation
Conversation
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.
geo::distance now returns the WGS84 geodesic distance instead of the haversine on a sphere. For each pair it uses the cheapest method that is accurate enough:
1° table's interpolation error), but fails where meridians converge
(poles) and grows with distance beyond (0.008% at 50 km and 75-80°);
its own result picks the next tier
~10 m and degrades towards the antipode; its own result picks the next
Compared with the haversine:
Compared with the
approx_*functions:approx_*uses the same sphere and a flat earth, with the longitude scale taken at the query point. It is off by up to 0.56% below 5 km, and the error grows with distance: 0.9% at 30 km, 2% at 100 km.distance()stays within 0.004%.approx_*stays faster per pair: 3.6 ns instead of 6.8 ns, once the scale has been computed for the query (one haversine, ~23 ns). It remains the better choice for testing many candidates against one point.The
approx_*functions could switch to local radii without changing how they are used (scale computed once per query, two multiplications per pair). This is not part of this PR:approx_*today)The cost per pair stays the same, the scale gets 10× cheaper and the sphere error disappears. The remaining error comes from using the query point's scale for a point at another latitude.
The spherical distance stays available as
haversine_distance, and theapprox_*functions are unchanged.box::extendnow assumes 110,500 m per degree of latitude (WGS84 has 110,574 m at the equator). Otherwisepoint_rtree::in_radiuswould miss points at the edge of the radius.