garage44.eu/jeroen/cartopolis

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

.. /docs/adr/006-world-coordinate-and-osm-anchor.md

raw

ADR-006: World Coordinate Model and OSM Anchor


Metadata:


Superseded. The absolute-f32 sim-unit region frame here proved too imprecise at planet scale (ADR-019) and too coupled (map vs sim, ADR-020). Only the Web-Mercator tile math survives, implemented in cartopolis_core::world (lat_lng_to_tile, tile_key_from_lat_lng, REGION_ZOOM_LEVEL = 17). The region model itself is being retired — see ADR-021 and the capacity-bounded asset direction. Kept for history.

Context

Problem: Regions, avatar movement, OSM tile fetching, and a future server must share one authoritative idea of where things are. Today rendering and SQLite use implicit assumptions; without a documented contract, client and server will drift (tile keys, AOI, handoff).

Requirements:

Decision

Define and document one canonical coordinate contract in shared types (library code as implemented): region origin in sim units, optional lat/lon metadata for tooling, and a deterministic function from that origin to default TileKey set at a chosen zoom level.

Approach:

Rust ecosystem (implement in cartopolis_core, ADR-015):

Rationale

Primary Reasoning:

  1. OSM as differentiator: The server and interest logic (ADR-012) must agree on which tiles matter without re-deriving ad hoc.
  2. Future replication: Avatar and static world updates reference the same frame as tiles (ADR-010, ADR-011).
  3. Prevents silent bugs: “Approximate” vs “authoritative” is written down once.

Alternatives Considered:

AlternativeProsConsRejected Because
Client-only lat/lonSimple nowServer cannot validate AOIMulti-user needs shared model
Full proj pipeline everywhereAccurateHeavy dependency for v0Defer until needed
Separate tile space from simFlexibleTwo sources of truthHarder to keep aligned

Consequences

Positive:

Negative:

Related