Skip to content

Port great-circle from turf (#50)#85

Open
trasch wants to merge 2 commits into
mainfrom
50_great_circle
Open

Port great-circle from turf (#50)#85
trasch wants to merge 2 commits into
mainfrom
50_great_circle

Conversation

@trasch
Copy link
Copy Markdown
Contributor

@trasch trasch commented May 8, 2026

Summary

Ported turf-great-circle from Turf.js.

New file: Sources/GISTools/Algorithms/GreatCircle.swift

GISTool.greatCircle(from:to:npoints:offset:) computes points along the great circle arc between two coordinates using spherical linear interpolation (slerp).

  • If start == end, returns a LineString with npoints copies of the coordinate
  • If the arc crosses the anti-meridian, returns a MultiLineString split at ±180°
  • Otherwise returns a LineString with npoints coordinates
  • Default: 100 points, offset 10

Tests: GreatCircleTests.swift (7 tests)

Test Coverage
greatCircleSameHemisphere Seattle → DC (100 points)
greatCircleCrossingAntimeridian 170°E → 170°W returns MultiLineString
greatCircleSamePoint Same start/end, 5 points
greatCircleCustomNpoints Custom 10 points
greatCircleEquator 0°→180° along equator
greatCircleNorthSouth North pole to south pole along meridian
greatCircleMinPoints npoints=1 fallback

Test results

273 tests pass across 60 suites (+7 new).


Closes #50

trasch added 2 commits May 8, 2026 18:48
Adds GISTool.greatCircle(from:to:npoints:offset:) computing
great circle arcs between two coordinates. Returns LineString
or MultiLineString (split at antimeridian when crossing).
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.

Port turf-great-circle

1 participant