Skip to content

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

Merged
trasch merged 5 commits into
mainfrom
50_great_circle
Jun 3, 2026
Merged

Port great-circle from turf (#50)#85
trasch merged 5 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 5 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).
@trasch trasch self-assigned this Jun 3, 2026
@trasch trasch added the enhancement New feature or request label Jun 3, 2026
@trasch trasch merged commit 2f4b7a4 into main Jun 3, 2026
1 check passed
@trasch trasch deleted the 50_great_circle branch June 3, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port turf-great-circle

1 participant