Spatial-first geocoding in one Rust binary.
Sub-25 ms forward, reverse, and batch geocoding over memory-mapped SQLite shards and S2 geometry. 416M rooftops and 18.5M cadastral parcels across 128 global shards — self-host on one NVMe VPS, run inside DuckDB, or embed on iOS and Android with zero Elasticsearch, PostgreSQL, or per-request fees.
Querying live engine...
Spatial-first architecture
Parse-first geocoders (libpostal, Pelias, Nominatim) label tokens into fields before checking geography, so swapped fields or a wrong city misroute queries. texspace intersects S2 spatial footprints first.
query → normalize text, extract sub-premise / PO box, fast-path WGS84 coords & Plus Codes → router.db: RoaringBitmap postings narrow 128 global shards to 1–2 shards (<0.4 ms) → per-shard subsequence mapping + in-RAM S2 CellUnion galloping intersection → 4-tier lookup: parcel polygon → rooftop → building-snapped → street interpolation → compiled depth-3 GBDT ranker + Platt confidence calibration + conflict diagnostics
S2 CellUnion joins
Entities and attributes are indexed as S2 cell coverings in SQLite WITHOUT ROWID tables with Hilbert-ordered keys. Intersecting spans in RAM verifies physical co-location before scoring.
Mmap SQLite + live OSM diffs
Shards are immutable read-only mmap files (core.db, optional buildings.db and parcels.db). --osm-sync minute streams official OSM .osc.gz diffs into a hot-reloading osm_delta.db with tombstone suppression.
Deterministic romanization
Chinese Pinyin, Japanese Hepburn Kana, Korean Hangul, Cyrillic, Greek, Hebrew, Arabic, and Thai are transliterated at build time and focus-scoped query rescue — resolving native-only streets on Latin queries with zero ML models.
Bundled GeoIP & Timezone
Sibling geoip.db (DB-IP City Lite + IPtoASN) and 16 MB tz.db (444 IANA zones with embedded RFC 8536 TZif v2/v3 rules) provide offline IPv4/IPv6 geolocation, DST/local-time evaluation, and focus.ip=auto search biasing.
Benchmarks & resource footprint
Measured on a strictly independent 440-query, 9-country civic holdout sourced exclusively from municipal and national open-data portals (zero Overture, OSM, OpenAddresses, or GeoNames sampling; report & scripts).
| Provider | Top-1 | Top-3 | Median err | ≤10 m | ECE ↓ | p50 latency | vs texspace (McNemar) |
|---|---|---|---|---|---|---|---|
| texspace ($0, offline) | 96.1% | 12.7 m | 0.030 | 28.1 ms | baseline | ||
| ArcGIS ($40–$500/1M) | 96.8% | 12.0 m | 0.040 | 269.2 ms | p = 1.00 (tie) | ||
| Google Maps ($5,000/1M) | 93.9% | 20.9 m | 0.078 | 170.7 ms | +1.2 pp (p = 0.40) | ||
| Mapbox v6 ($750–$5k/1M) | 90.0% | 19.6 m | 0.262 | 206.0 ms | +7.3 pp (p = 9.4e-7) | ||
| Geocode Earth ($500/1M) | 77.0% | 23.4 m | 0.143 | 258.2 ms | +18.2 pp (p = 3.7e-18) | ||
| Photon (OSM) | 66.6% | 27.1 m | — | 813.5 ms | +31.6 pp (p = 6.2e-35) |
eval/.
| Engine | Planet RAM | Planet Disk | Setup | Runtime stack |
|---|---|---|---|---|
| texspace | 4–16 GB (65 MB idle heap) | ~100 GiB NVMe | ~15 min pull | 1 static Rust binary + mmap SQLite |
| Nominatim | 64–128 GB | 900 GB–1 TB | 24–72 hrs | PostgreSQL + PostGIS |
| Pelias | 64–128 GB | 300+ GB | 18–48 hrs | Elasticsearch + Node + libpostal |
| Photon | 32–64 GB | 120–180 GB | 1–3 hrs | JVM + OpenSearch |
Smaller footprints: 1 state/metro shard runs in 256 MB RAM · iOS/Android FFI library is 4.5 MB (~10 MB peak dirty RAM).
Interfaces
One engine across CLI, Pelias-compatible HTTP endpoints (plus /v1/geoip, /v1/timezone, and /openapi.json), Rust crate, Python ctypes / C ABI, native DuckDB SQL extension, Swift, Kotlin, and stdio MCP.
# Forward search, reverse geocode, offline GeoIP, and IANA timezone texspace query --db data/global "10 Downing Street, London, SW1A 2AA" --compact texspace reverse --db data/global --lat 51.5034 --lon -0.1276 --compact texspace geoip --db data/global 8.8.8.8 2606:4700:4700::1111 texspace timezone --db data/global --lat 37.7749 --lon -122.4194 # Parallel bulk CSV geocoding across all CPU cores texspace batch --db data/global --input addresses.csv --output geocoded.csv --threads 0 # Incremental SHA-256 shard update & HTTP API with minutely OSM diff sync texspace update --db data/global --prune-delta texspace serve --db data/global --port 4000 --osm-sync minute
# Forward search (Pelias GeoJSON by default, ?format=compact, optional focus.ip=auto) curl "https://api.texspace.dev/v1/search?text=10+Downing+Street,+London&format=compact" # Reverse geocode, GeoIP (+ auto-enriched IANA timezone), and IANA timezone curl "https://api.texspace.dev/v1/reverse?point.lat=51.5034&point.lon=-0.1276&format=compact" curl "https://api.texspace.dev/v1/geoip?ip=8.8.8.8" curl "https://api.texspace.dev/v1/timezone?location=37.7749,-122.4194" # Parallel batch POST curl -X POST "https://api.texspace.dev/v1/batch" -H "Content-Type: application/json" \ -d '{"queries":["221B Baker St, London","350 5th Ave, NY","Ermou 10, Athens"]}'
-- Vectorized, Rayon-parallel offline SQL geocoding (native DuckDB C-API extension) LOAD 'texspace.duckdb_extension'; SELECT id, addr, g.label, g.lat, g.lon, g.match_level, g.confidence, g.apn FROM ( SELECT id, addr, texspace_geocode('data/global', addr) AS g FROM read_csv('customers.csv') ); -- Also: texspace_reverse(db, lat, lon), texspace_geoip(db, ip), texspace_timezone(db, lat, lon)
use texspace_engine::{QueryOptions, TexspaceEngine}; fn main() -> anyhow::Result<()> { let engine = TexspaceEngine::open("data/global")?; let resp = engine.query("10 Downing Street, London", &QueryOptions::default())?; let ip = engine.geoip("8.8.8.8")?; let tz = engine.timezone(37.7749, -122.4194, None)?; println!("{:?} | {:?} | {}", resp.results.first().map(|r| &r.label), ip.city, tz.tzid); Ok(()) }
from texspace import TexspaceEngine with TexspaceEngine("data/global") as geo: print(geo.search("10 Downing Street, London")) print(geo.reverse(51.5034, -0.1276)) print(geo.geoip("8.8.8.8")) print(geo.timezone(37.7749, -122.4194))
import Texspace let manager = try TexspacePackManager(packsDirectory: packsDir) let (engine, _) = try await manager.ensureEngine( forLat: 37.7749, lon: -122.4194, policy: .init(strategy: .preferCompact, includeWorldBase: true, maxInstalledMetros: 2) ) let hits = try engine.search("4865 Mission St Apt 4B, San Francisco", options: .init(limit: 3))
import dev.texspace.* val manager = TexspacePackManager(File(context.filesDir, "texspace_packs")) val (engine, _) = manager.ensureEngine( lat = location.latitude, lon = location.longitude, policy = SmartDownloadPolicy(strategy = PackSelectionStrategy.PREFER_METRO, maxInstalledMetros = 2) ) engine.use { geo -> geo.search("221B Baker St, London") }
{
"mcpServers": {
"texspace": {
"command": "texspace",
"args": ["mcp", "--db", "/var/lib/texspace"]
}
}
}
// 9 read-only tools: geocode_search, geocode_structured, geocode_reverse, geocode_autocomplete,
// geocode_nearby, geocode_batch, geocode_geoip, geocode_timezone, index_info