Skip to content

Skip empty rings in flatten - #214

Merged
mourner merged 1 commit into
mapbox:mainfrom
EpicDima:epicdima/flatten-empty-rings
Oct 8, 2026
Merged

mourner merged 1 commit into
mapbox:mainfrom
EpicDima:epicdima/flatten-empty-rings

Conversation

@EpicDima

@EpicDima EpicDima commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #213.

flatten adds a hole index even for an empty ring. For an empty last ring this index equals the number of vertices,
and earcut throws a TypeError. This PR makes flatten skip empty rings, so the result is the same as without them.
earcut.hpp already ignores empty holes the same way.

rings (vertex counts) main this PR
4, 3, 0 holes [4, 7] → TypeError holes [4], as for 4, 3
4, 0 holes [4] → TypeError holes [], as for 4

@EpicDima
EpicDima requested a review from a team as a code owner October 7, 2026 17:26
@EpicDima
EpicDima requested review from Xdudu and removed request for a team October 7, 2026 17:26
@mourner
mourner merged commit 20a6fae into mapbox:main Oct 8, 2026
2 checks passed
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.

flatten with an empty last ring makes earcut throw

2 participants