ORIX Maps — architecture
ORIX Maps is a native iOS / iPadOS map application that works without any Apple or Google map service and without a
network once a region is installed. This document describes how it is built. Decisions and their reasons are in
docs/adr/; formats are specified in docs/ORIXMAP_FORMAT.md, docs/CATALOG_API.md and
Packages/ORIXRouting/docs/ORIXGRAPH_FORMAT.md; what works today is in STATUS.md.
The three parts
Build node (macOS) Web node Device
─────────────────── ───────── ──────
OSM extract (Geofabrik) www.orixlab.dev/maps/v1/ ORIX Maps app
│ osmium extract catalog.json │ CatalogClient ── HTTPS, no identifier
├─ Planetiler + Protomaps ─ map.pmtiles regions/<id>.json │ DownloadManager ─ Range resume
├─ orix-geocoder-build ─ search.sqlite regions/<id>/versions.json │ PackageVerifier ─ Ed25519 + SHA-256
├─ orix-routing-build ─ routing.orixgraph files/<id>/<ver>/….orixmap │ RegionStore ──── atomic install
└─ orix-package build ─ <id>-<ver>.orixmap (static files, Range, ETag) ▼
signed with the node's private key map.pmtiles → MapLibre Native (Metal)
orix-package publish / catalog → rsync search.sqlite → SearchEngine (FTS5)
routing.orixgraph → Router (A*)Nothing flows from the device to a server except plain GET requests for the catalog and for the package the user
chose. Search text, routes, positions and saved places never leave the device.
Repository layout
| Path | Content |
|---|---|
Apps/ORIXMaps/ |
The application: XcodeGen project, SwiftUI sources, resources (world base map, world labels, glyphs, privacy manifest) |
Packages/ |
One SwiftPM package per module (below); each builds and tests alone on macOS with swift test |
Infrastructure/ |
Build-time tools, macOS only: ingestion/ORIXOSM (PBF reader), tile-builder, geocoder-builder, routing-builder, package-builder, distribution/, build-region.sh, regions.json |
docs/ |
ADRs, format and API specifications, data source register, testing, release |
scripts/ |
build.sh (generate / build / run / test), asc.py, make-icon.swift, inspect-pmtiles.py, localization |
data/ |
Local geodata and development keys, git-ignored |
Modules
Dependencies point downwards only; ORIXGeoCore depends on nothing.
Apps/ORIXMaps (SwiftUI, composition root: AppModel)
┌──────────┬───────────┬───────────┬─────────────┬───────────┬──────────┬───────────┬──────────┐
ORIXMap- ORIXMap- ORIXSearch ORIXNavigation ORIXPlaces ORIXTracks ORIXLocation ORIXDesign-
Renderer Package │ │ │ │ │ System
│ │ │ ORIXRouting ORIXGeoExchange ┘ │ ORIXPrivacy
ORIXMapStyle │ │ │ │ │ ORIXTerrain
└───────────┴───────────┴────────────┴──── ORIXGeoCore ───────────────────┘ ORIXTileStore
ORIXAtlas (prototype)| Module | Responsibility | Notes |
|---|---|---|
ORIXGeoCore |
Coordinates, bounding boxes (antimeridian-aware), Web Mercator and tile math, spherical geodesy, polyline projection and simplification, coordinate text (decimal, DMS, DDM, UTM), encoded polylines | Pure Swift |
ORIXMapStyle |
MapTheme (39 colour roles + weights and visibility rules), the eight ORIX themes, theme file import/export with validation, StyleBuilder (MapLibre style documents for the tile schema, base map + regions + world labels + application overlays), RegionRenderPlanner, point-of-interest groups |
No rendering code |
ORIXMapRenderer |
Engine-neutral MapController (camera, style, overlays, events, frame statistics) and MapBackend protocol; MapLibreBackend / MapCanvas is the only code importing MapLibre |
ADR 0002 |
ORIXTileStore |
PMTiles v3 reader, Mapbox Vector Tile decoder, LRU cache, TileStore actor |
Used by tools and by the Atlas prototype; MapLibre reads archives itself |
ORIXAtlas |
Specification and prototype of the proprietary Metal engine | Not linked in the app; docs/ATLAS_ENGINE.md |
ORIXMapPackage |
.orixmap container reader/writer, manifest, Ed25519 trust store, streaming verifier, RegionStore (atomic install, update, rollback, delete, space checks, crash recovery), CatalogClient, DownloadManager |
The only module with network code |
ORIXSearch |
Search index schema, writer and engine: FTS5 full text, grid spatial index, address resolution, categories (64, bilingual), typo correction, reverse geocoding, multi-region | System SQLite |
ORIXRouting |
.orixgraph format (memory-mapped), writer, A* / Dijkstra on directed-edge states with turn restrictions, car / bicycle / pedestrian profiles, alternatives, waypoints, maneuvers, English and French instructions |
ADR 0004 |
ORIXNavigation |
NavigationSession: map matching, progress and ETA, announcement scheduling, off-route detection with hysteresis, reroute requests, stops and arrival; VoiceGuide (AVSpeechSynthesizer) |
Value-type state machine, no clock, no I/O |
ORIXLocation |
LocationService (progressive permission, usage-based accuracy and background rule), CoreLocationProvider, SimulatedLocationProvider |
|
ORIXGeoExchange |
GPX 1.1, GeoJSON, KML 2.2 codecs with limits and hostile-input tests | Shared by places and tracks |
ORIXPlaces |
Collections, saved places with notes, local history, export/import, backup (SQLite) | |
ORIXTracks |
TrackRecorder (filtering, segments), statistics, profiles, TripReplay, TrackStore with crash-safe in-progress recording |
|
ORIXTerrain |
Elevation sources (HGT tiles, mosaic) and ElevationProfile |
No elevation data is distributed yet: inactive in the app |
ORIXPrivacy |
Log redaction, PrivacyLog, NetworkPolicy (what a request may contain) |
Enforced on every request by PolicedTransport in the app |
ORIXDesignSystem |
Tokens, floating map controls, chips, buttons, empty states, notices, unit-aware formatter |
Application
AppModel is the composition root: it creates the stores and services once and injects them through the SwiftUI
environment. There are no singletons.
| Object | Role |
|---|---|
MapController + StyleCoordinator |
The map view state; the style document is rebuilt when the theme, label language or set of regions changes. Overlays (route, position, pins, selection, track, measure, user layers, search results) are GeoJSON sources declared in every style, so a theme change never loses them. |
RegionsModel |
Installed regions, catalog, downloads; publishes MapRegion values to the map, search and routing layers |
SearchModel |
Opens one index per installed region; debounced suggestions, full search, categories, reverse geocoding for dropped pins |
DirectionsModel |
Opens one graph per region; planning (stops, modes, avoid options, alternatives), guidance with NavigationSession, simulated drives, rerouting, voice |
LibraryModel, TracksModel, UserLayersModel, ThemeStore |
Saved places and history, tracks and recording, imported layers, themes |
LocationService |
The single source of position for the map arrow, guidance and recording |
The interface is one screen: the map, floating controls, and a panel (a native sheet with detents on iPhone, a side
column on iPad) whose content follows AppModel.route — home/search, place card, directions, guidance, measure, track
recording or replay. Secondary screens (maps, collections, tracks, Explorer, planner, compass, Map Studio, settings,
about) are sheets.
Rendering stack
backgroundin the water colour.- For the base map then each drawn region: land, land cover / land use, water, tunnels, buildings (flat, then extruded when tilted), roads by class (casing then fill), railways, boundaries, bridges.
- Application line overlays (user layers, measure, track, alternative routes, route, travelled part).
- Labels of every source (water, roads, references, one-way arrows, house numbers, places of interest by group, places), then the bundled world labels (Natural Earth), which yield to region labels from zoom 7.
- Application symbols: maneuver points, pins, selection, position.
The base map (zoom 0–6) draws fills at every zoom, overzoomed outside regions; regions take over fills and labels from zoom 7, and draw their road network at every zoom. A region whose bounds lie inside another installed region with the same data is not drawn twice.
Region lifecycle on the device
catalog.json → the user taps Download → free-space check → DownloadManager streams to a partial file (Range +
If-Range resume, strong ETag = SHA-256) → size and SHA-256 check → PackageVerifier (header, manifest limits, Ed25519
signature against the compiled-in trust store, canonical layout, streaming SHA-256 of every component) → extraction into
a staging directory → fsync → rename → the previous version is kept for rollback → RegionStore publishes the change →
style rebuilt, search index and routing graph opened. A file imported from Files takes the same path from the verifier
on. Leftover staging state is cleaned at the next launch.
Concurrency
Swift 6 language mode everywhere. Stores and engines shared across tasks are actors (RegionStore, DownloadManager,
CatalogClient, SearchEngine, PlacesStore, TrackStore, TileStore); the routing graph is immutable and
memory-mapped, and Router is a value type, so route computations run on detached tasks. Interface models are
main-actor @Observable classes. Pure state machines (NavigationSession, TrackRecorder) are value types tested
without a clock.
Security and privacy by construction
- The only network code is in
ORIXMapPackage, behindHTTPTransport; the app wraps it inPolicedTransport, which refuses any request that is not HTTPS to the catalog host, carries a query string, a body, a cookie or a non-allow-listed header. - Packages are trusted by signature, not by where they came from. Installed file names come from a fixed table, never from the package. Every parser of external bytes (packages, PBF, PMTiles, vector tiles, graphs, search indexes, GPX / GeoJSON / KML, themes, backups) is bounds-checked and has corrupted-input tests.
- Logs go through
PrivacyLog, which scrubs coordinates and long numbers. - Position is requested only when a feature that needs it is used; background updates are on only while guidance or a recording runs.
- See
docs/PRIVACY.mdfor the behaviour as shipped anddocs/SECURITY.mdfor the threat model.