garage44.eu/jeroen/cartopolis

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

.. /docs/adr/022-osm-building-import.md

raw

ADR-022: OSM 3D Building Import (Overpass → Extruded Footprints)


Metadata:


Context

Problem: The map tier (ADR-020) should show OSM 3D buildings, not just flat tiles. OSM stores buildings as 2D footprints plus tags (height, building:levels, roof shape) under the Simple 3D Buildings schema — no ready-made meshes. We fetch that data and build geometry client-side.

Requirements:

Decision

Fetch buildings from the Overpass API, parse the JSON, and extrude each footprint client-side into a placed mesh.

Approach (systems/osm_buildings.rs):

New dependency: earcutr — small, pure Rust, no native build step.

Rationale

  1. Overpass is the standard query path for selective OSM data by bbox + tag (sibling to the tile fetch, ADR-004), reusing the existing ureq client.
  2. Client-side extrusion keeps the prototype additive — no wire/sim changes; buildings are map-tier content.
  3. earcutr is the minimal way to triangulate non-convex footprints; alternatives (geo + heavier triangulation, or hand-rolled) add weight or bugs.
  4. Validated on real data — Groningen buildings render aligned to the streets.

Alternatives Considered:

AlternativeProsConsRejected Because
Cesium OSM Buildings / 3D TilesPrebuilt global LOD tilesetsHeavy spec; less control; external dependencyRevisit for planet-scale streaming, overkill now
Convex-only / fan triangulationNo dependencyWrong for L-shaped/non-convex footprintsMost buildings are non-convex
Server-side extrusionThin clientPremature; needs protocol/sim workPrototype is client-only

Consequences

Positive:

Negative:

Related