Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/korp-map

korp-map

The map half of korp, in its own repository: region cuts from the OpenStreetMap planet, the map registry, the packed-cut read, and korp-map-server, which serves the cuts over the map wire (HTTP Arrow IPC and Arrow Flight on one port).

korp links crates/korp-map as its map module, as a sibling path dependency with a version pin. korp-map knows no korp home: the host hands it its paths (korp_map::paths), and korp-map-server takes them as flags.

crate what it is
crates/korp-map the library (region clip, planet download and cache, map registry, provisioning, the packed-cut read) and the korp-map-server binary (feature server)
crates/korp-map-wire the map wire contract: MapSource, the HTTP and Flight doors, the client side (feature client), and the korp-map-1xx wire error codes
crates/korp-map-wire-roundtrip the contract read back through facett-osm's native decoder, as a reply is read like a file
crates/korp-map-build-thing the build recipe; .nornir/build-variants.toml is emitted from it

korp-map-wire and korp-map-wire-roundtrip are self-rooting workspaces with their own locks, as they were in korp.

The map wire, contract v1.2 (summary)

One producer (MapSource), two doors on one port:

Error codes

korp-map's codes keep the names they had in korp (korp-map-*, korp-landmass-*, korp-clip-*, korp-roadgraph-*, korp-address-*, korp-s3-*). The table is append-only. The map, roadgraph and s3 subsystems are shared with korp's table, and the two tables are numbered as one: HELD_BY_KORP lists korp's numbers, and the tests on both sides check that the numbering stays dense. korp's generated catalog (.nornir/korp-error-codes.md in korp) lists both tables.

Running

You need the sibling checkouts next to this one: edda, facett, korp-collectors, znippy-zoomies, Skidbladnir and draupnir (the build recipe's [build.toolchain] siblings, held by crates/korp-map-build-thing/tests/siblings.rs).

cargo build --release -p korp-map --features server --bin korp-map-server
./target/release/korp-map-server --home /srv/korp-map --listen 127.0.0.1:8765

Paths:

Other flags:

HTTPS

The public server is https://karta.gunnar.rs (its landing page: https://karta.gunnar.rs/v1/). It runs behind a reverse proxy that holds the certificate and routes /v1/ and /openapi.json here, so it needs none of the flags below; they are for a server that answers HTTPS itself.

HTTPS is the cargo feature tls (rustls on ring), off by default: the plain --features server build links no TLS, and a TLS flag stops its start with korp-map-120. Build with --features tls for the flags below.

cargo build --release -p korp-map --features tls --bin korp-map-server

--listen-tls <addr:port> adds an HTTPS listener beside the plain --listen one. Both serve the same routes (HTTP and Flight; ALPN offers h2 and http/1.1) with the same CORS headers. TLS is rustls on the ring provider; nothing links aws-lc or OpenSSL.

The certificate comes from PEM files, from Let's Encrypt, or both:

Let's Encrypt checks the challenge by connecting to port 443 of the domain, so:

  1. The domain must resolve to the server's public IP. Without a DNS name of your own, a-b-c-d.sslip.io resolves to the IP a.b.c.d.
  2. Public port 443 must reach the HTTPS listener (on a router: forward TCP 443 to the host's --listen-tls port).
korp-map-server --home /srv/korp-map --listen 0.0.0.0:8765 \
  --listen-tls 0.0.0.0:8443 --tls-acme <D> --tls-acme-cache /srv/korp-map/acme

Try it with --tls-acme-staging first: staging certificates are not trusted by browsers, but its rate limits are generous. While an order cannot complete (port 443 not forwarded yet, DNS not pointing here), the server keeps serving HTTP, and HTTPS with a cached or PEM certificate; the failure is printed as korp-map-123 with Let's Encrypt's reason, and the order is tried again after 5 minutes, doubling to at most an hour (Let's Encrypt allows 5 failed validations per name and hour). A restart tries at once.

TLS setup failures stop the start with a code: korp-map-117 (certificate file), korp-map-118 (key file), korp-map-119 (certificate and key do not match), korp-map-120 (the TLS flags do not make one setup; exit code 2), korp-map-121 (the ACME cache directory) and korp-map-122 (the HTTPS address cannot be bound).

The client side of the wire talks https with korp-map-wire's feature client-tls (HttpMapClient::new("https://…"), or HttpMapClient::with_tls and FlightMapClient::with_tls_roots for a self-signed server).

Files

--files <region>[:<set>]=<dir> (repeatable) serves every *.parquet file in <dir> for download and remote querying, under /v1/files/<region>/<set>/<file>. Without :<set> the set is named by the files' format: native (GeoParquet 1.1 native encodings), geoparquet2 (GeoParquet 2.0) or parquet.

korp-map-server … --files sweden=<cut>/sweden --files sweden=<cut>/sweden-gp2

DuckDB reads only the footer and the row groups a query needs:

INSTALL httpfs; LOAD httpfs;
SELECT count(*)
FROM 'https://karta.gunnar.rs/v1/files/sweden/geoparquet2/areas.parquet'
WHERE bbox.xmin <= 18.1 AND bbox.xmax >= 18.0 AND bbox.ymin <= 59.35 AND bbox.ymax >= 59.3;

Python

The korp-map-client package (python/) reads the map as pyarrow tables or GeoDataFrames: pip install "korp-map-client[geo]", then korp_map_client.Client("https://karta.gunnar.rs").map("lines", bbox=(17.9, 59.2, 18.2, 59.4), lod=14).table.

Tests

cargo test -p korp-map                      # the library
cargo test -p korp-map --features server    # and the server (plain HTTP)
cargo test -p korp-map --features tls       # and its HTTPS
(cd crates/korp-map-wire && cargo test --features client)           # contract, Flight, client
(cd crates/korp-map-wire && cargo test --features acme,client-tls)  # and HTTPS, ACME setup
KORP_MAP_PYTHON=<python with duckdb> cargo test --test files -- --ignored  # DuckDB over HTTP
(cd crates/korp-map-wire-roundtrip && cargo test)                   # facett reads the reply
cargo test -p korp-map-build-thing          # the recipe and the build gate

License

Licensed under either of

at your option. Copyright (c) 2026 Ignalina ApS (Rickard Ernst Björn Lundin).

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Data keeps its own license: crates/korp-map/assets/sweden.poly (compiled into the library) is cut from OpenStreetMap, relation 52822, under ODbL 1.0, "© OpenStreetMap contributors" (see crates/korp-map/assets/sweden.poly.provenance.md). So are the region cuts, networks and tables korp-map builds from an OSM planet at run time.

Files

Newest commits