Skip to main content

Crate waratah_geo

Crate waratah_geo 

Source
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§

CovererConfig
Live coverer configuration of this process.
GeoEncodePlugin
Encode/decode hook: datatype map + lexical materialization.
GeoExecutorPlugin
GeoSPARQL executor hook.
GeoPlannerPlugin
GeoSPARQL planner hook.
GeoScanPayload
Typed payload of the geo_scan CustomOp (downcast by the executor).
GeoWritePlugin
GeoSPARQL write hook.
RebuildReport
Report totals one shell accumulates over a rebuild/upgrade run.
WindowQueryShape
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§

UpgradeOutcome
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_scan op id on the CustomOp node.
GEO_WKB_LITERAL
geo:wkbLiteral datatype IRI.
GEO_WKT_LITERAL
geo:wktLiteral datatype 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.0 remains 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 via register + one waratah_compute::PluginHost::install_process_wide instead — a second plugin’s self-install would otherwise be a silent no-op. The ordering constraint is unchanged: BEFORE any QueryEngine is constructed (the engine installs the plain builtins on first use, which would leave geof:* unregistered — the safe-but-unhelpful Unsupported error).
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 on host (the composition point every plugin crate shares; the binary then installs the composed host exactly once, BEFORE any QueryEngine is 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.