Skip to content

fix(great-circle): fix antimeridian splitting by upgrading arc to v1.0.0#3048

Open
thomas-hervey wants to merge 1 commit intoTurfjs:masterfrom
thomas-hervey:fix/great-circle-antimeridian
Open

fix(great-circle): fix antimeridian splitting by upgrading arc to v1.0.0#3048
thomas-hervey wants to merge 1 commit intoTurfjs:masterfrom
thomas-hervey:fix/great-circle-antimeridian

Conversation

@thomas-hervey
Copy link
Copy Markdown
Contributor

@thomas-hervey thomas-hervey commented Apr 13, 2026

Summary

Fixes #3030

Details

Routes crossing the international dateline (e.g. Tokyo-LAX, Auckland-LAX, Shanghai-SFO) were returning a malformed MultiLineString with a gap at the +/-180 boundary. This was caused by a bug in the GDAL-ported linear heuristic in arc.js v0.1.x/v0.2.x.

Fix

arc v1.0.0 replaces the heuristic with analytical bisection, producing exact +/-180 boundary coordinates and a correctly closed MultiLineString.

Changes:

  • Bump arc dependency from ^0.2.0 to ^1.0.0
  • Remove offset from Arc() call. Antimeridian splitting is now automatic
  • Mark options.offset as deprecated in JSDoc (kept for backward compat)
  • Remove unused offset destructuring

Test

  • Add three antimeridian test fixtures: Tokyo-LAX, Auckland-LAX, Shanghai-SFO
  • Add tape tests asserting MultiLineString output and exact +/-180 boundary coords
  • Fix fixture-dependent tests to use named getFixture() lookup instead of fixtures[0]
  • Regenerate basic.geojson snapshot (arc@1.0.0 defaults to 100 points)

When testing locally, arc@0.2.0 fails, but passes at arc@1.0.0

=== arc@0.2.0 ===
FAIL  Tokyo -> LAX: expected MultiLineString, got LineString
FAIL  Auckland -> LAX: gap at split -- last=[174.7900,-36.8500] first=[-176.0046,-29.7388]
FAIL  Shanghai -> SFO: expected MultiLineString, got LineString

found 0 vulnerabilities
=== arc@1.0.0 ===
PASS  Tokyo -> LAX: split at antimeridian, lat=47.3643
PASS  Auckland -> LAX: split at antimeridian, lat=-33.0522
PASS  Shanghai -> SFO: split at antimeridian, lat=52.3090
[rerun: b3]

... and the visual results were verified in geojson.io (see screenshot below)
Screenshot 2026-04-13 at 14 47 36


Please provide the following when creating a PR:

  • Meaningful title, including the name of the package being modified.
  • Summary of the changes.
  • Heads up if this is a breaking change. NO Breaking change
  • Any issues this resolves.
  • Inclusion of your details in the contributors field of package.json - you've earned it! 👏
  • Confirmation you've read the steps for preparing a pull request.

Fixes Turfjs#3030

Routes crossing the international dateline (e.g. Tokyo-LAX, Auckland-LAX,
Shanghai-SFO) were returning a malformed MultiLineString with a gap at the
+/-180 boundary. This was caused by a bug in the GDAL-ported linear heuristic
in arc.js v0.1.x/v0.2.x.

arc v1.0.0 replaces the heuristic with analytical bisection, producing
exact +/-180 boundary coordinates and a correctly closed MultiLineString.

Changes:
- Bump arc dependency from ^0.2.0 to ^1.0.0
- Remove offset from Arc() call - antimeridian splitting is now automatic
- Mark options.offset as deprecated in JSDoc (kept for backward compat)
- Remove unused offset destructuring
- Add three antimeridian test fixtures: Tokyo-LAX, Auckland-LAX, Shanghai-SFO
- Add tape tests asserting MultiLineString output and exact +/-180 boundary coords
- Fix fixture-dependent tests to use named getFixture() lookup instead of fixtures[0]
- Regenerate basic.geojson snapshot (arc@1.0.0 defaults to 100 points)
@thomas-hervey
Copy link
Copy Markdown
Contributor Author

thomas-hervey commented Apr 13, 2026

@smallsaucepan @rowanwins I see that you've contributed more recently and was wondering if I could get your review on this PR. In short, it's a bump of the arc package to resolve an antimeridian splitting issue #3030 .

Thanks!

@smallsaucepan
Copy link
Copy Markdown
Member

Thanks for this. While checking to see if this might fix the sourcemap issue #2721 as well noticed that arc as of 1.0.0 is ESM only?

@bijay-karki bijay-karki mentioned this pull request Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

greatCircle broken for routes crossing the antimeridian in v7.3.2+

2 participants