Skip to main content

Crate kenro

Crate kenro 

Source
Expand description

§kenro

SpatiaLite-style spatial SQL for SQLite in pure Rust — PostGIS-compatible ST_ functions that work with rusqlite, as a loadable extension, and in WASM.

kenro is a spatial SQL engine for SQLite in pure Rust, with zero C dependencies: WKB/WKT/GeoPackage-blob I/O, the DE-9IM predicate family, pure-Rust overlay/repair/buffer, SQL aggregates (ST_Union, ST_AsMVT), and the helper functions the GeoPackage spatial index triggers require — so a plain SQLite build can maintain a GeoPackage spatial index correctly.

Function names and signatures follow PostGIS (SQL/MM ST_ prefix); PostGIS is the declared reference for semantics. Where kenro differs, it errs loudly — never silently.

let conn = rusqlite::Connection::open("parks.gpkg")?;
kenro::register(&conn)?;
let wkt: String = conn.query_row(
    "SELECT ST_AsText(ST_GeomFromGPB(geom)) FROM parks LIMIT 1",
    [],
    |r| r.get(0),
)?;

All functions are pure (no I/O, no clock, no randomness): identical input always produces identical output.

Re-exports§

pub use error::Error;
pub use error::Result;
pub use geom::Geom;

Modules§

coords
Coordinate rewriting at the encoding level.
crs
Coordinate reference systems: a built-in EPSG → proj4-string table and the proj4rs-backed geometry transform.
error
functions
Pure counterparts of the SQL functions. No SQLite types appear anywhere in this module tree: every function takes &[u8] / &str / scalars and returns Result — the binding layers (rusqlite, and later the loadable extension and WASM) are thin value-mapping shims over these.
geom
The internal geometry hub: everything decodes into Geom, all algorithms run on it, all encoders consume it.
gpb
GeoPackage geometry blob (GPB) header codec.
mvt
Hand-rolled Mapbox Vector Tile encoder (spec 2.1, layer version 2).