latlng is an open-source spatial database in Rust. Index moving points, define geofences as code, stream geofence events as they happen — natively, or directly in the browser via WebAssembly.
50 simulated vehicles
Hamburg districts (geofences)
@latlng/wasm
in a Web Worker
Features
Built for things that move.
Core commands and queries are available over HTTP/JSON and Cap'n Proto, geofence events stream over WebSocket subscriptions, and the browser SDK runs the same Rust core in WebAssembly.
Spatial indexing
R-tree spatial indexing and field indexes for nearby, within, intersects, scan, and text search — backed by a portable Rust core.
Geofencing as code
Define hooks with circles, bounds, GeoJSON areas, or roaming distance. Emit inside, outside, enter, exit, cross, and roam events as objects move.
Webhook eventing
Durable HTTP POST delivery from a SQLite-backed outbox. Per-request timeouts, exponential backoff, dead-letter — at-least-once with stable event IDs.
Three transports
HTTP/JSON with generated OpenAPI, WebSocket subscriptions, and async Cap'n Proto RPC — all backed by the same engine and auth model.
Pluggable storage
Run the server in memory or on an append-only file. The Rust storage layer also includes SQLite for embedded use, plus AOF compaction, verification, backup, and restore.
Single-leader replication
Streaming replication over Cap'n Proto with checksum-based resume. Read-only followers catch up incrementally and serve queries after initial sync.
Auth that fits
Static bearer tokens, HMAC JWTs, asymmetric JWTs from PEM keys or JWKS. Claims-based authz scoped per collection.
Browser-native
The same engine compiles to wasm and runs in a Web Worker. Build local-first map apps with no server in the loop — like the demo above.
Operational from day one
Prometheus metrics, structured logging, HTTP rate limits per principal, runtime config rewrite — built for production, not just demos.
How it works
One engine. Two shapes.
latlng compiles a single Rust core into the form that fits where you run it — a service you deploy or a worker that ships with your web app.
Native server
latlng-server
Run it as a standalone process. HTTP/JSON, WebSocket subscriptions, and async Cap'n Proto RPC, all from the same binary, behind the same auth.
# Start the server binary
latlng-server
# Store a point
curl -sS -X POST http://127.0.0.1:7421/collections/fleet/objects/truck-1 \
-H 'content-type: application/json' \
-d '{"object":{"Point":{"lat":53.55,"lon":9.99,"z":null}}}'
# Query nearby points
curl -sS -X POST http://127.0.0.1:7421/collections/fleet/search/nearby \
-H 'content-type: application/json' \
-d '{"lat":53.55,"lon":9.99,"meters":1000,"options":{}}'
Browser
@latlng/wasm
The same engine, compiled to WebAssembly and pinned inside a Web Worker. Local-first geospatial — no server, no network, no key.