mapbox / mapbox/mapbox-java

Turf distance measurement doesn't match TurfJS

Open
#1,167 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question Turf
Dominant language
Java
Stars
438
Forks
117
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with services-turf/src/main/java/com/mapbox/turf/TurfMeasurement.java and compare its distance calculation with TurfJS, then inspect services-turf/src/test/java/com/mapbox/turf/TurfMeasurementTest.java. Determine why the implementations produce different values and update the implementation or expectations so the distance test reflects the intended TurfJS behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, javascript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.