aegis-geo
Geospatial engine for Aegis-DB — named collections of {id, lat, lon, metadata}
features on a uniform grid spatial index, with radius / bounding-box / nearest-k
queries over great-circle (Haversine) distance. The ninth data paradigm in
the Aegis engine.
Features
- Grid spatial index — points bucketed into fixed-size lat/lon cells, so radius and bbox queries only scan the cells overlapping the query region.
- Haversine distance — great-circle distance in metres (spherical Earth).
- Radius query — every feature within
radius_mof a point, nearest first. - Bounding-box query — every feature inside a lat/lon rectangle.
- Nearest-k — exact k-nearest; the search radius expands geometrically until ≥ k points are enclosed, so the true k nearest are guaranteed.
- Metadata filtering — exact-match JSON filter on results.
- Snapshot persistence — a serializable snapshot the server stores and rebuilds the index from on load.
Example
use GeoEngine;
let geo = new;
geo.create_collection?;
geo.upsert?;
geo.upsert?;
// Everything within 2000 km of New York, nearest first.
let hits = geo.within_radius?;
for hit in hits
// The 3 nearest cities to a point near Washington DC.
let near = geo.nearest?;
HTTP API (via aegis-server)
| Method | Path | Description |
|---|---|---|
| GET/POST | /api/v1/geo/collections |
List / create a collection ({name}) |
| GET/DELETE | /api/v1/geo/collections/:name |
Stats / drop |
| POST | /api/v1/geo/collections/:name/features |
Upsert {id, lat, lon, metadata?} |
| GET/DELETE | /api/v1/geo/collections/:name/features/:id |
Get / delete a feature |
| POST | /api/v1/geo/collections/:name/radius |
Radius query {lat, lon, radius_m, filter?} |
| POST | /api/v1/geo/collections/:name/bbox |
Bbox query {min_lat, min_lon, max_lat, max_lon, filter?} |
| POST | /api/v1/geo/collections/:name/nearest |
Nearest-k {lat, lon, k, filter?} |
Tests
Workspace total includes Haversine accuracy vs a known city-pair distance, nearest-k vs brute force, radius + bbox membership, metadata filter, CRUD with in-place moves, and snapshot round-trip.