sphereql-index
Spatial indexing for the sphereQL project.
Partitions S² into a two-tier index — radial shells × angular sectors — so spatial queries scan only the buckets that overlap the query region instead of the whole point set.
What's here
SectorIndex<T>— angular sector grid (theta_divisions × phi_divisions) for fast in-region lookups (Cone,Cap,Band,Wedge, …) defined insphereql-core.ShellIndex<T>— radial shell partitioning for r-range filtering. Composes withSectorIndexviaSpatialIndex.SpatialIndex<T>— composite of shell + sector. Built throughSpatialIndexBuilder(chained config: shell boundaries, theta / phi divisions, then.build()).CachedIndex<T>— wrapsSpatialIndexwith an LRU cache (IndexMap-backed, O(1) touch and evict) over recent query keys, invalidated by a generation counter on mutation.CachedIndexBuilderexposes.cache_capacity(n).- k-NN — uses precomputed unit Cartesian vectors and
1 − dotas a cosine proxy instead of full Vincenty per pair, so the inner loop is 3 muls + 2 adds per item.
The SpatialItem trait is the integration point: implement it on your
record type to plug into any of the indexes above.
Example
use SphericalPoint;
use ;
let mut idx = builder
.uniform_shells
.theta_divisions
.phi_divisions
.build;
idx.insert;
idx.insert;
let hits = idx.nearest;
assert_eq!;
Versioning
Part of the sphereQL workspace, currently 0.3.0; API may change
before 1.0. IndexError is #[non_exhaustive]. Builder types are
#[must_use] — forgetting .build() warns at the use site.
Documentation
See the workspace architecture.md and performance.md.