Skip to content

Port kinks from turf (#48)#88

Merged
trasch merged 4 commits into
mainfrom
48_kinks
Jun 3, 2026
Merged

Port kinks from turf (#48)#88
trasch merged 4 commits into
mainfrom
48_kinks

Conversation

@trasch
Copy link
Copy Markdown
Contributor

@trasch trasch commented May 8, 2026

Summary

Ported turf-kinks from Turf.js.

GeoJson.kinks() -> FeatureCollection finds all self-intersection points in lines and polygons.

  • Supports LineString, MultiLineString, Polygon, MultiPolygon
  • Skips adjacent segments and closed-ring start/end (not real kinks)
  • Uses existing LineSegment.intersection(_:) for segment intersection
  • Returns a FeatureCollection of Point features at each intersection

Tests (7 tests)

Test Coverage
lineStringNoKinks Simple line
polygonNoKinks Simple square
polygonWithKinks Bow-tie self-intersecting polygon
lineStringWithKinks Self-intersecting line
multiLineStringWithKinks Two crossing lines
featureKinks Feature wrapper
unsupportedGeometryKinks Point → empty

Test results

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


Closes #48

trasch added 2 commits May 8, 2026 19:01
Implements GeoJson.kinks() returning self-intersection points
as a FeatureCollection of Point features. Supports LineString,
MultiLineString, Polygon, and MultiPolygon.
@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 13c5f45 into main Jun 3, 2026
1 check passed
@trasch trasch deleted the 48_kinks branch June 3, 2026 10:48
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-kinks

1 participant