Skip to content

Port pole-of-inaccessibility (polylabel) (#21)#89

Open
trasch wants to merge 1 commit into
mainfrom
21_polylabel
Open

Port pole-of-inaccessibility (polylabel) (#21)#89
trasch wants to merge 1 commit into
mainfrom
21_polylabel

Conversation

@trasch
Copy link
Copy Markdown
Contributor

@trasch trasch commented May 8, 2026

Summary

Ported polylabel (Mapbox) algorithm for finding the pole of inaccessibility.

Sources/GISTools/Algorithms/PoleOfInaccessibility.swift

Polygon.poleOfInaccessibility(precision:) -> Point? — finds the most distant internal point from the polygon outline.

  • Uses a priority-queue grid search
  • Starts with the polygon centroid and bounding box center as guesses
  • Subdivides the most promising cells until precision threshold is met
  • Handles holes (all rings are considered for distance)
  • Returns nil for polygons without an outer ring

Tests/PoleOfInaccessibilityTests.swift (5 tests)

Test Coverage
squarePole Square center
trianglePole Triangle interior
poleWithPrecision High and low precision
poleLShaped Concave L-shape
poleNoOuterRing Empty polygon → nil

README

Updated pole-of-inaccessibility from TODO to example with test link.

Test results

271 tests pass across 60 suites (+5 new).


Closes #21

Implements Polygon.poleOfInaccessibility(precision:) using
Mapbox's polylabel grid-search algorithm. Returns the most
distant interior point from the polygon outline.
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 pole-of-inaccessibility

1 participant