garage44.eu/jeroen/cartopolis

logclone: git clone https://garage44.eu/jeroen/cartopolis.git

.. /docs/notes/atlas.md

raw


topic: atlas triggers: [cartopolis_atlas, crates/atlas, atlas, "terrain tile", "/terrain/", pipeline, "user management", registration, accounts, "ROBUST", OpenSim, "service design"] updated: 2026-10-17

cartopolis_atlas: everything around the world that is not the simulation

Agreed 2026-09-23. A separate crate and binary in this workspace (crates/atlas), an axum/tokio service depending on cartopolis_core and cartopolis_geo. It owns the map data pipelines (ported from a separate TypeScript repository), the terrain tiles that level-of-detail-tile-tree.md needs, and later registration and user management.

Why it exists

The pipelines were TypeScript in a separate repository while their readers (lod22.rs, building_facts.rs, surveyed.rs, osm_buildings.rs, dikes.rs, crops.rs) are Rust here, and nothing checked that the two agreed (where-the-map-data-is-built.md). In one workspace one commit changes both sides and one gate tests them, and the writer and the reader can share one Rust type per format, which would make a mismatch a compile error — the port did not do that yet. It also lets server-side work use cartopolis_geo directly.

Rules, several learned from OpenSimulator's ROBUST

Order

  1. Crate skeleton plus /terrain/{z}/{x}/{y}: AHN height grids per tile, cut from PDOK on first request and kept on disk; 404 outside coverage. Road flattening server-side came later, as a pipeline step rather than on request: the terrain dataset grades every tile it cuts (pipeline/terrain_grade.rs) into terrain-graded-v1/, served with &graded=1, and writes the deck heights it measured to decks/14/x/y.json (level-of-detail-tile-tree.md, "Atlas grades"). It reads the vector tiles from ATLAS_VECTOR_TILES (default tiles.cartopolis.org), the water dataset's own output from the site tree — so run water before terrain — and the surface model for the decks, from AHN6 where it is published and PDOK's AHN4 elsewhere (ahn6.rs, ahn-editions.md). Each deck record is [x, y, height, top, profile] — the profile is DeckProfile::to_wire, trailing so an older client still reads the height. Built (crates/atlas, format cartopolis_geo::terrain_tile): z8–z17, 129² samples, 33 KB a tile. Against live PDOK from the VPS (2026-09-23): a first cut takes 0.2–0.3 s and a repeat is ~1 ms from disk. North Groningen (14/8490/5318) spans −1.0 to +10.6 m NAP. A tile over the Markermeer is a remembered 404, not a flat tile.
  2. Port the TypeScript pipelines. Done 2026-09-23, all at once rather than one at a time, because the goal became retiring that repository altogether. All six datasets (crates/atlas/src/pipeline/), each diffed against the TypeScript output for the same square (where-the-map-data-is-built.md has the results), and the TypeScript server's surface route for route: the one-job runner (jobs.rs), the admin check against the simulator (auth.rs), and coverage (coverage.rs), all under /api/pipeline/* (api.rs). The admin GUI moved into atlas unchanged except for the log cursor (below) and its address, and is now the atlas web UI (crates/atlas/web): static files behind Caddy at the site root of cartopolis.org, published by midas deploy web (atlas-web-ui.md). It is the front page (which atlas served from a string until 2026-09-24), the operator's pages at /admin (they were /console/, which redirects) and the players' pages (/register, /verify, /buildings; /house is an alias), so the simulator's CARTO_PUBLIC_BASE_URL is just https://cartopolis.org. web.cartopolis.org, its old hostname, was dropped rather than redirected — one site, not two.
  3. Move accounts once the token design is agreed. The in-world player actions (block, report, delete my account) stay on the wire, with the simulator passing them on.

The pipeline surface, as ported

Contracts a port must keep

Client code already depends on these shapes, and a port that changes them breaks it silently (reported by the tunnel/bridge work, 2026-09-23):

The LoD2.2 cells are binary as well as JSON

pipeline/lod22.rs writes lod22/14/{x}/{y}.bin beside every cell's JSON, in cartopolis_geo::lod22_cell's encoding — the one format in this tree whose writer and reader share a type and a codec, so a change to it is a compile error on the other side rather than a layer that draws nothing. The module docs have the layout: a 16-byte header, then five varint streams (metadata, latitude deltas, longitude deltas, heights, triangle index codes). It is on the JSON's own grid (10⁻⁷°, 1 cm), so it carries the JSON's numbers, not an approximation of them — the client's tests check both formats give the same meshes.

Measured 2026-09-26 on Groningen's densest cell, 8490/5319 (7,934 buildings, 174,614 vertices, 266,902 triangles), with the client's own print_lod22_cell_cost instrument in a release build (best of five, one core of the VPS):

rawgzip -6parseparse + mesh
JSON8.31 MB1.76 MB57.8 ms445.7 ms
binary1.80 MB0.94 MB23.0 ms394.3 ms

A cold start at 600 m fetches ten such cells, so the win is mostly bytes: the gzipped transfer of the opening ring nearly halves on a phone link, and the decompressed body a client holds and caches is a fifth. The parse saves 35 ms of worker time on the densest cell, but the mesh build around it (~370 ms) is what dominates a cell's CPU cost, and this change does not touch it. atlas's encode is 12 ms a cell.

Three things about serving it:

Rejected