Expand description
GeoSPARQL geometry support: a WKT (Well-Known Text) literal parser and the
real geometry predicates the SPARQL extension functions dispatch to
(geof:distance, geof:sfContains, sfWithin, sfIntersects, sfTouches).
This replaces the “Simplified” placeholders in sparql_extensions.rs (which
returned hardcoded true/false or an arbitrary threshold) with genuine
computation over parsed geometry. Distances use the haversine great-circle
formula (lon/lat degrees, WGS-84 mean radius); topological predicates use
planar tests (ray-casting point-in-polygon, segment intersection).
Scope: POINT, LINESTRING, POLYGON (with holes), and their MULTI
variants — the WKT subset GeoSPARQL data uses in practice. Z/M coordinates
are parsed and ignored (2D predicates). An optional SRID/<uri> prefix
(geo:wktLiteral values sometimes carry <crs> POINT(...)) is skipped.
Structs§
- Coord
- A 2-D coordinate
(x, y).
Enums§
- GeoFn
- The GeoSPARQL extension functions this engine implements.
- GeoValue
- Result of a GeoSPARQL predicate: a boolean (sf* topology) or a metric.
- Geometry
- A parsed WKT geometry. Coordinates are
(x, y)=(longitude, latitude)for geographic data.
Constants§
- GEO_
FUNCTION_ IRIS - Canonical function IRIs, keyed by
GeoFn. Parser and evaluator agree on these so ageof:<local>call hashes to the sameFunction::Customid both sides compute.
Functions§
- contains
geof:sfContains— doesacontainb? Implemented for the common case of a polygon containing a point / all points of another geometry.- distance_
metres - Great-circle distance in metres between two geometries’ representative
points (haversine). For non-point geometries the centroid of the coordinate
set is used — a documented approximation adequate for
geof:distance. - eval_
geo_ fn - Evaluate a
GeoFnover two already-parsed geometries. - geo_
fn_ for_ hash - Map a function-IRI hash back to a
GeoFn(used by the evaluator to dispatch aFunction::Custom(hash)). - geo_
function_ iri - Canonical IRI for a
geof:<local>function name, if recognised. Lets the parser expand ageof:call to the standard IRI even when the query did not declare the prefix. - intersects
geof:sfIntersects— doaandbshare any point? Covers point-in-polygon, shared vertices, and segment crossings between line/polygon boundaries.- parse_
wkt - Parse a WKT literal into a
Geometry. Accepts an optional leading CRS URI (<http://…/CRS84> POINT(…)) which is skipped. Case-insensitive keywords. - touches
geof:sfTouches— geometries share a boundary point but no interior. A pragmatic test: they intersect, but neither contains an interior point of the other (approximated as: they intersect and no vertex of one is strictly inside a polygon of the other).- within
geof:sfWithin—awithinb≡bcontainsa.