h3 icon indicating copy to clipboard operation
h3 copied to clipboard

Question: haversine distance algorithm

Open jamescooper-blis opened this issue 5 years ago • 1 comments

Hi,

Looking at the code, it seems the haversine algorithm used in [0] is faster (On My Machine) than the offical algorithm used in [1]. Is there reason it's not the official algorithm? Are there accuracy issues?

[0] https://github.com/uber/h3/blob/6c3c806ffbec16d32013bfa80ceec43b4c7513be/examples/distance.c#L39 [1] https://github.com/uber/h3/blob/6c3c806ffbec16d32013bfa80ceec43b4c7513be/src/h3lib/lib/geoCoord.c#L151

Thanks!

jamescooper-blis avatar Nov 17 '20 23:11 jamescooper-blis

Interesting! I removed [0] because I couldn't find any references for the formula.

I tested two alternatives described here: https://www.movable-type.co.uk/scripts/latlong.html We ended up with the "Haversine" formula [1] on that page.

I recall doing some benchmarking, but not seeing any speed difference between the two, at least on my mac.

How are you doing your benchmarking?

ajfriend avatar Nov 20 '20 00:11 ajfriend