Skip to content

Port polygon-smooth from turf (#52)#87

Merged
trasch merged 4 commits into
mainfrom
52_polygon_smooth
Jun 3, 2026
Merged

Port polygon-smooth from turf (#52)#87
trasch merged 4 commits into
mainfrom
52_polygon_smooth

Conversation

@trasch
Copy link
Copy Markdown
Contributor

@trasch trasch commented May 8, 2026

Summary

Ported turf-polygon-smooth from Turf.js using Chaikin's algorithm.

Sources/GISTools/Algorithms/PolygonSmooth.swift

  • Polygon.smooth(iterations:) -> Polygon — smooths outer ring and hole rings
  • MultiPolygon.smooth(iterations:) -> MultiPolygon — smooths all sub-polygons
  • Each iteration doubles the number of points on each ring
  • Ring closure (first == last) is preserved

Tests/PolygonSmoothTests.swift (6 tests)

Test Coverage
smoothSquare 4→8 points, ring closure
smoothMultipleIterations 2 passes: 4→8→16
smoothTriangle 3→6 points
smoothWithHole Outer + hole both smoothed
smoothMultiPolygon All sub-polygons smoothed
smoothIdempotency Subsequent smoothing still grows points

Test results

272 tests pass across 60 suites (+6 new).


Closes #52

trasch added 3 commits May 8, 2026 18:57
Implements Chaikin's algorithm for Polygon.smooth(iterations:)
and MultiPolygon.smooth(iterations:). Each iteration doubles
the number of points, preserving ring closure and holes.
@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 8ec01b4 into main Jun 3, 2026
1 check passed
@trasch trasch deleted the 52_polygon_smooth branch June 3, 2026 10:35
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-polygon-smooth

1 participant