Skip to content

Implement polygon union (#24)#90

Merged
trasch merged 4 commits into
mainfrom
24_union
Jun 3, 2026
Merged

Implement polygon union (#24)#90
trasch merged 4 commits into
mainfrom
24_union

Conversation

@trasch
Copy link
Copy Markdown
Contributor

@trasch trasch commented May 8, 2026

Summary

Implemented polygon union operations.

Sources/GISTools/Algorithms/Union.swift

  • GeoJson.union(with:) -> GeoJsonGeometry? — union of two polygon geometries
  • FeatureCollection.union() -> Feature? — union of all polygon features
  • Handles Feature auto-unwrapping
  • Merges contained polygons (outer absorbs inner)
  • Returns Polygon for contiguous, MultiPolygon for disjoint result
  • Returns nil for non-polygon inputs

Tests/UnionTests.swift (6 tests)

Test Coverage
unionDisjointPolygons Two non-touching → MultiPolygon
unionContainedPolygon Inner absorbed by outer → Polygon
unionFeatureCollection Batch FC union
unionFeatureWrapping Feature auto-unwrapped
unionNotPolygon Point input → nil
unionEmpty Empty FC → nil

README

Updated union from TODO.

Test results

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


Closes #24

Adds GeoJson.union(with:) for pair-wise polygon union and
FeatureCollection.union() for batch union. Handles contained
and disjoint polygons; returns Polygon or 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 a463a45 into main Jun 3, 2026
1 check passed
@trasch trasch deleted the 24_union branch June 3, 2026 13:36
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-union

1 participant