Closed apendleton closed 9 months ago
The matching turf behaviour makes sense as HaversineDestination
is inspired by the turf function: https://github.com/georust/geo/pull/124.
I'm in favour of modifying the method to match HaversineIntermediate
. Anyone else have thoughts?
During a recent refactor, we switched some logic that had previously used
HaversineIntermediate
to useHaversineDestination
instead, in a way that should have been equivalent (calculating great-circle intermediate values between two points). The results do seem in general to be equivalent, but HaversineDestination sometimes produces result values that are outside[-180,180]
longitude even when the inputs are in-bounds, which I found somewhat surprising.Looking at the docs, it doesn't seem like
geo
actually commits to any particular longitude representation ([-180,180]
vs[0,360]
in particular), so maybe this is left undefined on purpose and applications should just normalize? But notably, the equivalentHaversineIntermediate
operation does seem to wrap longitudes correctly as I'd expect. Seems like there's some value in consistency, or at least in documenting expected behavior.Minimal
rust-script
reproduction that compares in-theory-equivalentHaversineDestination
andHaversineIntermediate
operations calculating points along an AM-crossing line:prints:
Happy to help out with a PR or whatever if there's some consensus about what, if anything, ought to be done here, but just wanted to flag since it caught me off-guard.
Also FWIW, I compared the behavior to
turf.destination
in turf.js, and again somewhat to my surprise, it exhibits the same past-180 wrapping behavior, so maybe this is normal?