Skip to content

fix: ignore empty polygon parts in MultiPolygon - #195

Open
spokodev wants to merge 1 commit into
mapbox:mainfrom
spokodev:fix/multipolygon-empty-part
Open

fix: ignore empty polygon parts in MultiPolygon#195
spokodev wants to merge 1 commit into
mapbox:mainfrom
spokodev:fix/multipolygon-empty-part

Conversation

@spokodev

@spokodev spokodev commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

A MultiPolygon whose coordinates contain an empty polygon part (for example [[], [ring]]) throws TypeError: Cannot read properties of undefined (reading 'length') while building the feature bounding box, because createFeature reads polygon[0] on the empty part. A single such part in an otherwise valid FeatureCollection aborts the whole index build, so no tiles are produced.

This skips empty polygon parts during conversion, matching the if (newPolygon.length) guard already used in clip.js, so the valid parts still get tiled. Adds a test that fails on main with the TypeError and passes with the fix.

A MultiPolygon whose coordinates contain an empty polygon (for example
[[], [ring]]) threw a TypeError while building the feature bounding box,
because createFeature reads polygon[0] on the empty part. A single such
part in an otherwise valid FeatureCollection aborted the whole tiling.

Skip empty polygon parts during conversion, matching the guard already
present in clip.js, so the valid parts still get tiled.
@spokodev
spokodev requested a review from a team as a code owner July 8, 2026 14:35
@mourner

mourner commented Jul 8, 2026

Copy link
Copy Markdown
Member

geojson-vt is in the middle of a big rewrite (see #191), so I'll hold on merging any fixes to the project until the overhaul is merged. This will likely need to be applied from scratch to the new code if still relevant.

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.

2 participants