Skip to content

feat(wkb): add MultiPolygon support to WKB parser#44

Open
wietzesuijker wants to merge 6 commits into
geoarrow:mainfrom
wietzesuijker:feat/multipolygon-wkb
Open

feat(wkb): add MultiPolygon support to WKB parser#44
wietzesuijker wants to merge 6 commits into
geoarrow:mainfrom
wietzesuijker:feat/multipolygon-wkb

Conversation

@wietzesuijker

@wietzesuijker wietzesuijker commented Mar 30, 2026

Copy link
Copy Markdown

Adds WKBType.MultiPolygon case to parseWkb(). Based on the WKB parser from the kyle/wkb branch, adding one more nesting level for geom-to-polygon offsets using polygonIndices from loaders.gl's BinaryPolygonGeometry.

MultiPolygon is a core OGC Simple Features type. The types (MultiPolygonData, WKBType.MultiPolygon) and type guards already exist in this library, only the parseWkb() case was missing.

Changes

File Change
src/io/wkb.ts repackMultiPolygons() + inferMultiPolygonCapacity()
src/io/wkb.test.ts 4 tests: two-polygon, single-polygon, with-hole, multi-feature batch
src/type.ts, src/data.ts LargeWKB / LargeWKBData type aliases

Tests verify offset arrays at every nesting level and spot-check coordinate values. WKB hex generated via Shapely. All 8 tests pass (4 new + 4 existing).

Note

Based on kyle/wkb. stac-map depends on smohiudd/geoarrow-js (a fork of that branch) because it was never merged upstream.

AI (Claude) supported my development of this PR.

@wietzesuijker wietzesuijker force-pushed the feat/multipolygon-wkb branch from 56b3c02 to 0149696 Compare March 30, 2026 18:28
@wietzesuijker wietzesuijker marked this pull request as ready for review March 30, 2026 18:29
@wietzesuijker wietzesuijker force-pushed the feat/multipolygon-wkb branch 2 times, most recently from a0a7f2b to 30c751d Compare March 30, 2026 19:18
@wietzesuijker

Copy link
Copy Markdown
Author

pushed 30c751d to make the linter happy

@wietzesuijker wietzesuijker force-pushed the feat/multipolygon-wkb branch from 30c751d to da33f57 Compare March 30, 2026 23:06

@kylebarron kylebarron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the WKB parser really needs a wholesale re-design. Or, perhaps the design is fine, but there are a lot of considerations

Perhaps you'd be able to point Claude at this folder in geoarrow-rs and enough test cases and it would be able to create a WKB -> GeoArrow parser.. but I'm skeptical that a claude-created version would be possible to maintain without a lot of additional input effort.

I do think the Rust implementation there is quite stable and cleanly-designed, but it's reasonably verbose. You can read, say, the wkb parsing/encoding from cast.

I think you'd need something like https://github.com/developmentseed/geotiff-test-data: a considerable corpus of test data for WKB - GeoArrow interop to have confidence in the code.

That said I don't really have the time to review big changes here at the moment.

Comment thread package.json
Comment on lines +51 to +52
"@loaders.gl/schema": "*",
"@loaders.gl/wkt": "*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely wouldn't want to depend on loaders.gl from geoarrow-js.

Comment thread src/type.ts
| MultiPoint
| MultiLineString
| MultiPolygon;
export type WKB = Binary;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd want a type for LargeWKB too

@wietzesuijker

Copy link
Copy Markdown
Author

Thanks @kylebarron. Agreed on the bigger picture. This PR is just adding the missing MultiPolygon case to the existing parser (one function + tests), because I want to use that elsewhere. Happy to convert to draft if you'd rather revisit the whole thing at once.

This was referenced Mar 31, 2026
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.

4 participants