Fleets as collections
Create one collection per fleet, region, or customer (fleet-hamburg, fleet-berlin). Queries, geofences, and access tokens all work per collection or name pattern.
Keep every vehicle's live position and status in one place, answer dispatch questions in milliseconds, and let latlng tell your systems when vehicles arrive at or leave a depot, customer site, or service area.
Fleet software has to answer the same questions thousands of times a minute: where is each vehicle, which ones are available, what's closest to this job, and who just left the depot? Relational databases can answer them, but constant position updates create write load and index churn, and nothing tells you when a vehicle crosses a boundary unless you poll and diff.
Most teams end up with a pipeline of cron jobs, caches, and custom geometry code that is hard to keep correct — especially around restarts and failed notifications.
Create one collection per fleet, region, or customer (fleet-hamburg, fleet-berlin). Queries, geofences, and access tokens all work per collection or name pattern.
Each vehicle is an object with a position and fields such as status, speed, type, or capacity. Position reports keep existing fields, and status changes don't need to resend the position.
nearby returns vehicles sorted by distance and filtered by fields — for example, only available vans within 5 km — with the distance on each result.
Register depots, customer sites, and service areas as polygon or radius geofences. latlng emits enter, exit, inside, outside, and cross events as vehicles move.
Geofence events are delivered as webhooks from a durable queue with exponential backoff and dead-lettering, so a brief outage in your backend doesn't lose arrivals.
Send expire_seconds with every position report. When a tracker goes silent, the vehicle expires: it drops out of queries and fires a Del event to hooks that listen for it.
Telematics units or driver apps send positions and status to your ingestion service, which writes them to latlng.
Positions update the in-memory spatial index; every write is checked against the fleet's geofences.
Enter and exit events are delivered to webhooks and live WebSocket channels.
Dispatch, customer ETA pages, and dashboards query nearby and within to show the current state.
One request returns the five closest available vehicles within 5 km, sorted by distance.
curl -s -X POST http://127.0.0.1:7421/collections/fleet-hamburg/search/nearby \
-H 'content-type: application/json' \
-d '{
"lat": 53.5511, "lon": 9.9937, "meters": 5000,
"options": {
"limit": 5,
"where_in_filters": [ { "field": "status", "values": ["available"] } ]
}
}' nearby uses straight-line distance — combine it with a routing engine when drive time matters. Create a fleet, register vehicles with status fields, stream position updates, and find the nearest available vehicle.
Beginner · 15 min Send webhooks when vehicles enter or leave a zoneRegister a polygon geofence, receive enter and exit events over HTTP, and handle retries and duplicate deliveries.
Intermediate · 10 min Stream live geofence events over WebSocketUse channels and the TypeScript SDK to push enter and exit events to a backend service or dashboard in real time.
Intermediate · 10 min Secure latlng with scoped JWTsRequire authentication and give each tracker, dashboard, and operator a token limited to the fleets and actions it needs.
latlng keeps objects in memory with an R-tree index, so capacity depends mainly on available RAM and update rate. It includes a benchmark harness so you can measure throughput for your own fleet size and geofence count.
Usually, yes. Queries and geofences run per collection, and JWT permissions are scoped by collection name patterns, so one collection per fleet, region, or customer keeps queries fast and access control simple.
Send expire_seconds with each position update. Because every update resets the TTL, it works as a heartbeat: if no update arrives in time, the vehicle is deleted by the background expiry sweep, disappears from queries, and fires a Del event to hooks whose commands include Del — so you can alert on it.
latlng keeps the latest state per vehicle. For history, write the same position stream, or latlng's geofence events, into a database built for it, such as PostgreSQL with PostGIS or a time-series store.
Check which delivery zone an address falls into, and notify customers and dispatchers the moment a driver arrives at or leaves a stop.
Ride-hailing and on-demand dispatchMatch riders with the nearest available driver, alert when a driver is close to the pickup, and manage airport and event pickup zones.
Asset tracking and theft alertsKeep track of trailers, containers, and equipment across sites, raise an alert when an asset leaves its yard, and detect trackers that stop reporting.