mapbox / mapbox-java

The Mapbox Java SDK – Java wrappers around Mapbox APIs and other location data
https://docs.mapbox.com/android/java/overview/
MIT License
424 stars 120 forks source link

Turf distance measurement doesn't match TurfJS #1167

Open ac87 opened 4 years ago

ac87 commented 4 years ago

I am trying to port transformRotate from Turf.JS as I need it for a project.

In the method comments there are some examples with the expected result, my port didn't match. In trying to debug this I've noticed that the distance tests don't match between JS and the Java port.

The standard test points [-75.343,39.984][-75.534, 39.123] used the km distance in TurfJS is 97.12922118967835

Those same points are tested in the port but the expected result is different: 97.15957803131901

This third party suggests TurfJS is correct.

I've noticed Earth radius is different between the implementations so I guess this is the why

6371008.8

6378137

I see JS nearly changed to the same value for earth's radius but got reverted.

Is there a reason the port doesn't produce the same result as the original?

1ec5 commented 4 years ago

Related: mapbox/turf-swift#26.