feat(train): a route's map kept offline on request (ADR 0030, D45)

A saved route's page has Keep the map offline: the tiles within 2 km of
its way at zooms 10 to 16 (never above the source's own), shared between
routes, kept again as the route changes and let go with it. The style,
its sprites and the instance's map source are kept as last read, and
every map reads a kept tile before the network, so a map draws with no
network at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-29 10:28:36 +01:00
commit a2997e87af
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -923,6 +923,27 @@ Strava. What was found, 27 Oct:
so that a swipe goes back to the figures, north up by default and the heading up
(of the last 5 m or more) as tapped. A saved workout doesn't keep which route it
followed yet.
Built: maps offline (9d's first half). A saved route's page has *Keep the map
offline*; on, `OfflineMaps` (in the person's folder, `offline_maps/`, never synced)
asks the source for every tile within 2 km of the way (`corridorTiles`: the tiles
under a square of 2 km each way around a point every 250 m, a band at least 2 km
either side) at zooms 10 to 16, but never above the zoom the source has (OpenFreeMap
has 14, the map overzooms from there), four at a time, a tile shared by two routes
kept once and deleted only once neither keeps it; the page counts them as they come
and then says how much the device holds, and the list marks the route. The style,
its sources' TileJSON and its sprites are kept each time they are read, and the
instance's map source too (`map_source.json`), so that a map draws with no network
at all; the map reads a kept tile from the device before the network
(`keptVectorTiles`), which is why the app now builds vector_map_tiles' style itself
(with vector_tile_renderer's readers): its `StyleReader` reads only from the
network. A tile that didn't come is counted and asked for again the next time the
app opens online, and one the source has none of (204, 404: the sea) is nothing
missing. A kept route that changes, here or on another device, or whose map source
changes, is kept again along its new way, the old way's tiles deleted; one deleted
is let go; one that doesn't open on this device stays. Only a saved route can be
kept, since it is the saved way that is kept. Not done: a size limit or a warning
before a long route's download (a 200 km ride at OpenFreeMap's zooms is some 700
tiles, a few tens of MB), and keeping a map only on Wi-Fi.
- **D46 Train's server on the instance** (recommended, the developer's; 28 Oct): it
joins learn.halkyon.eu's server, as BRouter needs a server of Train's to ask it
(D11, D22), at **train.halkyon.eu** (over a path on learn.halkyon.eu, which would