Turfjs / Turfjs/turf

centerOfMass is incorrectly calculated across the antemeridian

Open
#1,905 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

@turf/center-of-mass antimeridian
Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

Description

If you have points spanning the antemeridian it calculates the centre of mass as close to the meridian.

For example

centerOfMass(featureCollection([point([179, 0]), point([-177, 0])]));

Should return [-179,0] but actually returns [1,0] (ironically in this case the furthest possible point from the true CoM)

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 at the centerOfMass implementation and reproduce the reported featureCollection with points [179, 0] and [-177, 0]. The fix is done when this antimeridian-spanning example returns [-179, 0] rather than [1, 0], with equivalent behavior preserved for ordinary points.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.