Sovereign Mapping: Engineering a Full-Stack Geospatial Infrastructure for Tanzania
Why build a sovereign stack
After the GST Geo-Scientific prototype, it was clear Tanzania needed a mapping stack that was local, fast, and under our control. Reliance on global APIs added latency and limited how we could tailor data for Tanzanian use-cases. api.maps.locations.co.tz was my answer: a fully self-hosted pipeline from OSM extract to production API, tuned for local performance and sovereignty.
The stack at a glance
- Data core: PostgreSQL 15 + PostGIS for spatial queries and enrichment.
- Geocoding: Nominatim to resolve place names with Tanzanian context.
- Routing: GraphHopper configured for car profiles, optimized for our road attributes.
- Tiles: Planetiler builds Tanzania basemaps from OSM extracts; TileServer GL serves vector tiles.
- API layer: A Go service acts as a thin, concurrent proxy that enriches responses and unifies endpoints.
Moving from TypeScript to Go
High-concurrency spatial endpoints demanded lower overhead. I rewrote the API layer in Go to gain tighter control over goroutine pools, connection reuse, and memory. The result: predictable latency even when multiple geocode, tiles, and routing calls land at once.
Automation & reproducibility
- Terraform provisions compute, networking, and storage.
- Ansible installs PostGIS, Nominatim, GraphHopper, TileServer GL, and supervises services.
- Shell toolkits orchestrate Planetiler builds and warm caches.
With this pipeline, a full rebuild of the stack is deterministic, critical for disaster recovery and regional replication.
From raw OSM to production
- Pull fresh Tanzania OSM extracts.
- Planetiler builds vector tiles; Nominatim ingests for geocoding.
- GraphHopper imports for routing profiles.
- Ansible deploys updated services behind the Go proxy.
- Synthetic checks validate geocode accuracy, tile integrity, and routing parity before traffic switches.
API interaction examples
Geocoding (Find coordinates for Dar es Salaam)
curl "https://api.maps.locations.co.tz/v1/geocode?q=Dar+es+Salaam&format=json"
# or
http GET https://api.maps.locations.co.tz/v1/geocode q=="Dar es Salaam" format==json
Nearby Places (POI Search with lat/lon enrichment)
curl "https://api.maps.locations.co.tz/v1/places/nearby?lat=-6.8&lon=39.2&limit=1"
# or
http GET https://api.maps.locations.co.tz/v1/places/nearby lat==-6.8 lon==39.2 limit==1
Routing (A to B car navigation)
curl "https://api.maps.locations.co.tz/v1/route?point=-6.8,39.2&point=-6.82,39.25"
# or
http GET https://api.maps.locations.co.tz/v1/route point==-6.8,39.2 point==-6.82,39.25
Results and what’s next
The platform now serves Tanzanian geocode, tiles, and routing with local latency and zero external dependencies. Next on the roadmap: bicycle and pedestrian profiles, SLA-backed uptime targets, and regional mirrors so other East African teams can adopt the same sovereign blueprint.
