feat(c): C API over the Arrow C Data Interface - #1473
Conversation
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.
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 |
|
Gotcha. Will close. I can do this in a different repo. |
|
(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! |
|
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. |
|
Awesome, fully supportive of that effort! |
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.