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.

$ cargo install texspace && texspace pull gb
GET /v1/search?text=10+Downing+Street%2C+London&format=compact&size=2 ready
Querying live engine...
Click map to reverse-geocode & inspect timezone Full demo ↗
51.503396, -0.127640 · Europe/London
01

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
01.1

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.

01.2

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.

01.3

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.

01.4

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.

02

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).

ACCURACY & CALIBRATION — 440 THIRD-PARTY CIVIC ADDRESSES (US, UK, CA, AU, FR, NL, ES, BR, TW)
Provider Top-1 Top-3 Median err ≤10 m ECE ↓ p50 latency vs texspace (McNemar)
texspace ($0, offline)
94.8%
96.1% 12.7 m
46.8%
0.030 28.1 ms baseline
ArcGIS ($40–$500/1M)
95.0%
96.8% 12.0 m
47.7%
0.040 269.2 ms p = 1.00 (tie)
Google Maps ($5,000/1M)
93.6%
93.9% 20.9 m
30.0%
0.078 170.7 ms +1.2 pp (p = 0.40)
Mapbox v6 ($750–$5k/1M)
87.5%
90.0% 19.6 m
37.5%
0.262 206.0 ms +7.3 pp (p = 9.4e-7)
Geocode Earth ($500/1M)
76.6%
77.0% 23.4 m
35.0%
0.143 258.2 ms +18.2 pp (p = 3.7e-18)
Photon (OSM)
63.2%
66.6% 27.1 m
22.5%
— 813.5 ms +31.6 pp (p = 6.2e-35)
Tradeoffs: Commercial APIs retain deeper long-tail business/POI catalogs, and rooftop density tracks upstream open address and OSM coverage per country. All evaluation queries and scoring scripts live in eval/.
SELF-HOSTED PLANET FOOTPRINT — 8-VCPU AMD HETZNER CPX42 (16 GB RAM, NVMe)
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
Single-node timings (128 shards): /v1/geoip ~0.05 ms · /v1/timezone ~0.07 ms · /v1/reverse 1.9 ms · /v1/autocomplete 4.9 ms · /v1/search 23 ms · /v1/batch ~111 QPS.
Smaller footprints: 1 state/metro shard runs in 256 MB RAM · iOS/Android FFI library is 4.5 MB (~10 MB peak dirty RAM).
03

Pre-built shards & offline mobile packs

Stream SHA-256 verified zstd SQLite shards directly from Cloudflare R2 — pull a single metro, a country, or the full 128-shard planet. Click any preset or region on the map.

Equal Earth · click any shard polygon
$ texspace pull planet --with-buildings --out ./texspace-data
128 shards · 74.0M entities · ~35.2 GB zstd

Offline mobile packs (iOS Swift & Android Kotlin)

51 pre-built city/metro SQLite packs (3.5–57 MB zstd) plus a 31.7 MB world_base.db gazetteer. Native XCFramework and Android JNI libraries include pure-Rust zstd unpacking and GPS-based pack selection with no on-device router rebuild.

$ texspace pull --mobile --near 37.7749,-122.4194 -o ./mobile
04

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