Skip to content

feat(c): C API over the Arrow C Data Interface - #1473

Closed
willcohen wants to merge 38 commits into
geoarrow:mainfrom
willcohen:c-api
Closed

feat(c): C API over the Arrow C Data Interface#1473
willcohen wants to merge 38 commits into
geoarrow:mainfrom
willcohen:c-api

Conversation

@willcohen

Copy link
Copy Markdown
Contributor

This is a draft PR, dependent on #1462, #1466, #1467, #1471, and #1472.

The only new commit here is the single final commit on top. It adds a c/ crate that exports a public C API for geoarrow-rs, as discussed in #526.

Arrays use the Arrow C Data Interface, covering all geoarrow-expr-geo operations (allowing both js + c to use the same kernels), plus geoparquet. The type vocabulary lines up with geoarrow-c. Functions return errno-compatible codes.

Like the js bindings, macros cover the functions, so extending these bindings over additional kernels should be straightforward. TThe committed geoarrow_rs.h is the build input, and cbindgen regenerates it on demand (this is noted in README). Another addition to keep these aligned is that tests/header_parity.rs fails when the header, the sources, or the js operation surface drift apart.

Unlike #1472, where wasm isn't in the workspace, this c/ crate is a workspace member, so I think CI should cover this.

Four public fns intersection/union/difference/xor, each delegating to one
private _boolean_op over _boolean_op_impl (mirrors area.rs's shared-impl
style; binary two-array dispatch via downcast_geoarrow_array_two_args! like
intersects.rs). Element-wise left[i] op right[i]; errors on length mismatch.

geo::BooleanOps is areal-only, so per element a non-Polygon/MultiPolygon
input pushes null (documented); null in either side -> null out. Output is a
concrete 2D MultiPolygonArray; Z/M dropped as in buffer. xor follows geo's
method name (symmetric difference).

Tests: two overlapping unit squares -> intersection/union/difference/xor
areas; null + non-areal propagation; length-mismatch error.
The transform reads x and y only, thus Z and M pass through and an array with a
builder of its own keeps its geometry type.

dim_geom gains the point, multipoint and collection types, an owned DimGeometry
of any type, and map_ordinates, which rebuilds a geometry with a function
applied to each of its coordinates.
@willcohen
willcohen marked this pull request as draft August 21, 2026 17:43
@github-actions github-actions Bot added the feat label Aug 21, 2026
@kylebarron

Copy link
Copy Markdown
Member

This is a draft PR, dependent on #1462, #1466, #1467, #1471, and #1472.

For one, in general you might want to try using github's new stacked PR support (I haven't used it yet).

But also, I barely have any time to maintain geoarrow-rs. I don't want to add C API support to this repo. In an external repo, yes I fully support that. But here, the repo is already very complex as it is

@willcohen

Copy link
Copy Markdown
Contributor Author

Gotcha. Will close. I can do this in a different repo.

@willcohen willcohen closed this Aug 21, 2026
@willcohen

Copy link
Copy Markdown
Contributor Author

(Additionally -- sorry about the stacked commits. It only works intra-repo -- I unfortunately can't do it from a fork!)

@kylebarron

Copy link
Copy Markdown
Member

(Additionally -- sorry about the stacked commits. It only works intra-repo -- I unfortunately can't do it from a fork!)

oh ok good to know!

@willcohen

Copy link
Copy Markdown
Contributor Author

Initial empty repo for building up a C api at https://github.com/willcohen/geoarrow-ffi/. Will work on wrapping existing things before trying to cover stuff covered by the kernel and geoparquet PRs.

@kylebarron

Copy link
Copy Markdown
Member

Awesome, fully supportive of that effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants