cheap-ruler icon indicating copy to clipboard operation
cheap-ruler copied to clipboard

Better way to handle poles?

Open HansBrende opened this issue 4 years ago • 3 comments

Calculating the distance over a pole, e.g., between [0, 89.99] and [180, 89.99] (with 89.99 as the latitude passed into the cheap ruler constructor) gives me a 57% error relative to the Vincenty calculation. (For reference, I used https://github.com/chrisveness/geodesy which seems to be better maintained than the derivative https://github.com/TankofVines/node-vincenty)

I know that this is already documented as a shortcoming, but food for thought: if you can calculate the maximum error that your shortcut formula would give you in advance (which seems likely, given that you have a % error chart in the readme), could you not simply fall back to the Vincenty (or even haversine) formula if the error is too large? That would fix the pole issue... (for comparison, the haversine formula gives only a 0.4% error for those same two coordinates -- and could probably be improved upon by tweaking the earth radius).

HansBrende avatar Apr 26 '21 15:04 HansBrende

The Flat-surface formula used by cheap-ruler has singularity at the poles.

Use other non-singular distance formulas such as Gauss mid-latitude method instead.

The following shows the accuracy test including Gauss mid-latitude method:

288974202-78b6e997-78f8-4d50-adb8-861e079a7a7e

kkdd avatar Jan 21 '24 07:01 kkdd