Expand description
Waratah GeoSPARQL v1 plugin: native geo terms, S2 candidate index, and
geof:sfContains / sfWithin / sfIntersects FILTER rewrite.
One crate implements all four waratah_compute::plugin hooks — write
(GeoWritePlugin), encode (GeoEncodePlugin), plan
(GeoPlannerPlugin), and execute (GeoExecutorPlugin) — because
ingest and query constants share one parse/transform/validation path and
the planner/executor own the same payload types.
Register at compute startup via register: the binary composes every
plugin crate (geo + temporal) onto ONE
waratah_compute::PluginHost and installs the composed set exactly
once (PluginHost::install_process_wide) — the three geof:* custom
functions (residual cache-aware retry plus the ground fallback) land on the
same process custom-function map before any query is lowered, so an
unregistered geof:* FILTER errors in split_filter (Unsupported), never plans
wrong. install remains only as a single-plugin test shim: two
self-installs would silently drop the second plugin (both registries are
first-install-wins).
v1 boundaries: stored puts require a native indexed form. Other CRS,
EMPTY, ill-formed WKT/WKB, and validation failures outside the narrow
MultiPolygon contact tolerances are hard errors; query-authored constants
may use the ordinary typed-literal fallback because they create no index
entry. Z/M takes the native blob route (see encode’s module docs);
GML/GeoJSON are unparsed; planar geo Relate on CRS84 lon/lat is a
documented limitation near the antimeridian and poles.
Structs§
- Coverer
Config - Live coverer configuration of this process.
- GeoEncode
Plugin - Encode/decode hook: datatype map + lexical materialization.
- GeoExecutor
Plugin - GeoSPARQL executor hook.
- GeoPlanner
Plugin - GeoSPARQL planner hook.
- GeoScan
Payload - Typed payload of the
geo_scanCustomOp (downcast by the executor). - GeoWrite
Plugin - GeoSPARQL write hook.
- Rebuild
Report - Report totals one shell accumulates over a rebuild/upgrade run.
- Window
Query Shape - The query-side window derivation the geo planner performs for one
constant-argument
geof:*conjunct, exposed for diagnostics (waratah geo census --window): the WKT parses through the SAME ingest encode path as a query literal (CRS84-normalized, validity-checked, native forms only), the covering computes under the process coverer config, and both consumer views derive from it — the drain’s cell-id intervals and the estimator’s merged L11 ranges.
Enums§
- Upgrade
Outcome - The outcome of planning one orphaned typed literal’s upgrade.
Constants§
- DEFAULT_
DENSIFY_ STEP_ DEG - The default densification step (0.1°): ~11 km segments, worst-case geodesic-vs-planar chord deviation ~5 m (measured; the deviation scales with the square of the step) — three orders of magnitude inside the near-edge depths that motivated the contract.
- DENSIFICATION_
FIXTURE_ HEXAGON_ WKT - The densification-contract fixture hexagon as WKT: a continental-scale hexagon ~24° wide, centered near 132°W 58°N, whose SE/SW edges bow up to ~0.67° into the interior under geodesic interpretation. The canonical spelling shared by the covering unit tests and the end-to-end contract tests, so the suites cannot drift onto different shapes.
- GEO_
SCAN_ OP_ ID geo_scanop id on the CustomOp node.- GEO_
WKB_ LITERAL geo:wkbLiteraldatatype IRI.- GEO_
WKT_ LITERAL geo:wktLiteraldatatype IRI.- MIN_
DENSIFY_ STEP_ DEG - The smallest configurable densification step (0.0001° ≈ 11 m segments).
Steps below the covering’s own cell resolution buy no accuracy — the cell
budget is what bounds the output — they only inflate the intermediate
vertex list toward an unbounded loop.
0.0remains the documented disable sentinel. - PLUGIN_
ID - Stable plugin id carried by every CustomOp the geo plugin mints.
Functions§
- blob_
id_ of_ ewkb - Blob-id helper for tests and the rebuild path: content-address of EWKB.
- coverer_
config - Current process configuration (ingest and query covering both use it).
- covering_
estimate_ rows - Area-based cardinality estimate for a geo scan covering: sum the exact
cell areas (steradians), convert to square degrees, and multiply by the
[
ASSUMED_ROWS_PER_SQ_DEG] placeholder density. Clamped to ≥ 1 so any covering (including a single point leaf) estimates at least one row. - encode_
literal - Encode a geo literal for the datatype map: native term on success, the
same hashed typed literal storage
From<&Literal>would produce on any failure (ingest and query constants cannot diverge — one path). - eval_
geof_ function - Evaluate one unindexed
geof:*call over RESOLVED terms (ground fallback). Native geo terms normally use the cache-aware encoded evaluator; this path still handles typed literals and any cache miss. Both arguments parse + transform to CRS84 here. Stored geometries arrive with their materialized lexical pre-seeded: the eval prefetch windows (residual FILTER, aggregates, Extend) fetch blob-backed payloads and decode through the plugin before the ground pass, and points materialize from their inline coords — so a type-error on a stored geometry is the missed-prefetch case (or an ill-formed literal), not an unreachable blob. The “correct, slow” v1 bar for shapes the rewrite did not take. - geof_
custom_ functions - Register the three
geof:*custom functions. The cache-aware encoded path avoids repeated parse/validate/reduce work for native geo terms; a miss escalates to the existing residual ground implementation. - geometry_
covering - Covering of a CRS84 polygon (or any area geometry) under the live config.
- geometry_
envelope - CRS84 envelope of a geometry (min/max over every coordinate). TODO(v1):
no lon wrap — WKT lons past ±180 produce a raw min/max box that may
compare disjoint from an overlapping antimeridian query (see
aabb_skip_for_lon_wrap, which covers the span ≥ 180° case only). - geometry_
from_ crs84_ ewkb - Decode a canonical CRS84 EWKB payload back to a geometry (rebuild and
executor candidate path). Z/M canonical blobs degrade to their 2D
projection here — the reader dialect dispatch lives in
[
crate::relate::candidate_from_ewkb], which this delegates to. - install
- Test convenience: install ONLY the geo plugin +
geof:*custom functions on the process registries (first install wins; one guarded host install per process, so repeat calls are no-ops). Production composes every plugin crate viaregister+ onewaratah_compute::PluginHost::install_process_wideinstead — a second plugin’s self-install would otherwise be a silent no-op. The ordering constraint is unchanged: BEFORE anyQueryEngineis constructed (the engine installs the plain builtins on first use, which would leavegeof:*unregistered — the safe-but-unhelpfulUnsupportederror). - intervals_
for_ covering - Merge a covering into the GeoCandidateScan interval list: each covering
cell contributes its
[range_min, range_max]descendant range plus the exact ids of every proper ancestor (which catch indexed POINTS whose leaf cell is an ancestor of the query polygon’s cells). Deduped and sorted by cell id. - materialize_
lexical - Render the lexical form of a native geo term.
- point_
leaf_ cell - Covering of a 2D point: exactly the level-30 leaf cell.
- postings_
for_ geo_ term - Derive the index postings for one NATIVE geo term at
commit_ts. - register
- Register the geo plugin bundle + the three
geof:*custom functions onhost(the composition point every plugin crate shares; the binary then installs the composed host exactly once, BEFORE anyQueryEngineis constructed). Datatype-IRI claim conflicts and duplicate function IRIs propagate to the caller — a conflicting plugin set is a deployment error and must fail at the composition site, not silently no-op at install. - set_
coverer_ config - Override the process coverer config (CLI / compute config / tests).
- should_
store_ envelope - Whether the posting
(cell, geometry)stores the envelope value. - upgrade_
outcome - Plan the upgrade of one orphaned typed literal.
- window_
query_ shape - Derive a window’s query shape from WKT text. Fails the same way the planner’s conjunct match fails (parse / CRS / validity / non-native form), so the census window report prices exactly what a query over this WKT would price.