Skip to content

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

Open
trasch wants to merge 3 commits into
mainfrom
52_polygon_smooth
Open

Port polygon-smooth from turf (#52)#87
trasch wants to merge 3 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.
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-polygon-smooth

1 participant