garage44.eu/jeroen/cartopolis

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

.. /docs/adr/023-data-layers.md

raw

ADR-023: Data Layers (Togglable OSM Point-of-Interest Overlays)


Metadata:


Context

Problem: The world renders OSM basemap tiles (ADR-004) and 3D buildings (ADR-022), but carries no thematic point data — transit stops, businesses, amenities. We want an open-ended set of such overlays that the user can switch on and off individually, without each one re-inventing fetching, caching, streaming and disposal.

Requirements:

Decision

Introduce a client-side data-layer registry (systems/data_layers.rs), sourced from the OSM Overpass API. Shipped layers: transit stops and shops.

Approach: A LAYER_DEFS table declares each layer as {key, name, Overpass query with a {bbox} placeholder, categories with marker styles, classify fn}. Shared machinery streams every enabled layer per fixed zoom-14 cell within LAYER_CELL_RADIUS (3) of the camera: disk-cached Overpass fetch → POI classify → one merged marker mesh per cell, all on a worker thread; the main thread only spawns entities. Disabling a layer flips Visibility rather than despawning.

Rationale

Primary Reasoning:

  1. Overpass is already a dependency (ADR-022), so this adds no new vendor, crate, credential, or rate-limit budget to reason about — only new queries. Its data is OpenStreetMap: worldwide, ODbL, redistributable with attribution.
  2. The building far-cell streamer is a proven template for exactly this shape of problem (fetch-once/keep-while-in-range/anchor-to-BigSpace-cell), so the layer streamer reuses its cache layout, throttle, and cell geometry.
  3. Transit stops are the right first layer: dense in Dutch cities, node-only (no geometry assembly), and split into tag-obvious categories that exercise the styling path. Shops followed as a denser, pin-headed second layer.

Alternatives Considered:

AlternativeProsConsRejected Because
NL-only sources (NDOV/OVapi, CBS, BAG)Richer, authoritative, real-time departuresNetherlands-only; each has its own schema, endpoint, and termsLayers must work worldwide; a NL-only first layer would bake NL assumptions into the registry's shape
Wikidata / Wikimedia SPARQLWorldwide, CC0, rich entity linksUneven street-level geo coverage; public SPARQL endpoint is rate-limitedCoverage too thin for the street-level POIs this layer set targets
Overpass, one query per POI typeSimple per-layer queriesN× the requests against a shared free serviceUnion queries fetch a whole layer's categories in one request per cell
Bake POIs into the SQLite world DB server-sideNo client network path; server can enrichRequires an import pipeline and schema before we know what layers we wantPremature; revisit once layer set stabilises (see Consequences)

Consequences

Positive:

Negative:

Related