SQLiteGIS
PostGIS-style spatial functions for SQLite in pure Rust. Ships as a SQLite loadable extension (native and WebAssembly) and as a Diesel ORM integration. Geometries travel as EWKB BLOBs, matching the PostGIS wire format so queries port between SQLite and PostGIS without rewriting.
SQLite extension
SELECT load_extension('./target/release/libsqlitegis');
SELECT ST_AsText(ST_Buffer(ST_Point(0, 0), 1.0));
SELECT ST_Distance(ST_GeomFromText('POINT(0 0)'), ST_GeomFromText('POINT(3 4)'));
Pure-Rust geometry
use st_point;
use st_distance;
let a = st_point.unwrap;
let b = st_point.unwrap;
assert!;
Diesel integration
#
#
CreateSpatialIndex and DropSpatialIndex are DDL helpers without typed wrappers, called through diesel::sql_query. R-tree-backed queries run 50 to 60x faster than the non-indexed equivalents (see Benchmarks).
Notes
Geodesic functions (ST_DistanceSphere, ST_DistanceSpheroid, ST_LengthSphere, ST_Azimuth, ST_Project, ST_DWithinSphere, ST_DWithinSpheroid) require SRID=4326 non-empty Point inputs and reject anything else. ST_GeomFromGeoJSON defaults to SRID=4326. ST_DWithin* predicates require a finite, non-negative distance.
Benchmarks
Criterion central estimates on the included R-tree workloads:
| Scenario | Indexed | Non-indexed | Speedup |
|---|---|---|---|
intersects_window |
178 us |
9.81 ms |
~55x |
knn |
89 us |
5.66 ms |
~64x |
Contributing
See CONTRIBUTING.md.
License
MIT OR Apache-2.0