Add a country-based region picker for offline data
Replaces "regenerate for the current viewport" with what Locus/OsmAnd- style apps give you: tick which countries you want offline (a Natural Earth-derived checklist, public domain, vendored), Apply rebuilds offline.pmtiles/terrain.pmtiles to cover the whole selection at once. Multiple regions can be offline simultaneously (e.g. Slovakia + Austria for a trip that crosses the border) — the selection itself is the source of truth (data/offline_regions.json), not a set of per-country files, so "remove a country" and "refresh a country" are both just "change the selection, then Apply." Confirmed against go-pmtiles' own source (not just its docs) before committing to this shape: `extract --region=<geojson>` treats a FeatureCollection's features as their union already (no dissolve/union math needed on our side — pmtiles/region.go's UnmarshalRegion just concatenates every feature's rings), and `merge` hard-errors on any overlapping tile id between inputs (merge.go's prepareInputs). That second fact rules out "extract each country separately, merge them all" — adjacent countries' region-extracts would share border tiles, since extraction copies whole tiles rather than clipping vector content to the polygon. The actual fix: extract per *source archive* (the Protomaps build, each intersecting Mapterhorn chunk), each call covering the whole current selection via one --region= file — the terrain pipeline already extracted-then-merged per source this way, it just needed a multi-country region instead of a single bbox.
This commit is contained in:
1 parent
f89dea5805
commit
53c9a82af2
10 files changed
+442
-170
No files matched your search
+37
-15
@@ -85,25 +85,47 @@ size rather than assuming one, so this isn't a problem either way.
|
||||
|
||||
A logged-in user can also generate both files above from the app
|
||||
itself, no local tooling needed — the sidebar's "Offline data" icon
|
||||
(Offline hub group) shows each file's status (size, last updated) and
|
||||
a "Regenerate for current view" button. The region is always the
|
||||
current map viewport, same "no area-picker, the visible area is the
|
||||
area" convention the Overpass POI plugin already uses below. This
|
||||
wraps exactly the manual `go-pmtiles` workflows documented above
|
||||
(Offline hub group) shows a checklist of European countries
|
||||
(`lib/maptool/data/europe_countries.geojson`, Natural Earth 110m
|
||||
admin-0, public domain) plus each file's status (size, last updated).
|
||||
Ticking countries and clicking "Apply changes" saves the selection
|
||||
(`data/offline_regions.json`, an array of ISO A2 codes) and rebuilds
|
||||
both files to cover it.
|
||||
|
||||
There's no standalone per-country file to individually delete —
|
||||
`offline.pmtiles`/`terrain.pmtiles` are always one combined extract for
|
||||
the *whole current selection*. "Remove a country" and "refresh a
|
||||
country" are both just "change the selection, then Apply" (unticking a
|
||||
country and applying rebuilds without it; nothing to separately
|
||||
delete). Every Apply re-extracts the entire selection from scratch, not
|
||||
just what changed — fine given extraction is fast (byte-range requests
|
||||
against remote archives, not per-tile fetches), but worth revisiting if
|
||||
someone selects half of Europe at once and finds it slow.
|
||||
|
||||
This wraps exactly the manual `go-pmtiles` workflows documented above
|
||||
(`lib/maptool/pmtiles_builder.rb`) — the server needs the
|
||||
https://github.com/protomaps/go-pmtiles[go-pmtiles] CLI installed and
|
||||
on `PATH` (override with the `PMTILES_BIN` env var if it lives
|
||||
somewhere else). Fetches Mapterhorn's own small JSON manifest to work
|
||||
out which regional chunk(s), if any, intersect the bbox, `extract`s
|
||||
each (plus `planet.pmtiles`, always), then `merge`s them if there was
|
||||
more than one — typically seconds, not the tens of minutes an earlier
|
||||
version of this (fetching every individual Terrarium tile itself) used
|
||||
to take for a real-sized region.
|
||||
somewhere else), using `--region=<geojson>` (a `FeatureCollection` of
|
||||
the selected countries — go-pmtiles treats multiple features as their
|
||||
union already, no union/dissolve math needed on this side) rather than
|
||||
`--bbox=` for precise, per-country extraction. terrain.pmtiles extracts
|
||||
`planet.pmtiles` (always) plus whichever Mapterhorn regional chunks
|
||||
intersect the selection, `merge`s them if there was more than one —
|
||||
always safe regardless of how many/which countries are selected, since
|
||||
each chunk is Mapterhorn's own pre-partitioned, non-overlapping source
|
||||
file (extracting the *same* source once per country and merging those,
|
||||
by contrast, would fail — adjacent countries' region-extracts share
|
||||
border tiles, since extraction copies whole tiles rather than clipping
|
||||
vector content to the polygon, and `pmtiles merge` refuses any
|
||||
overlapping tile id between inputs).
|
||||
|
||||
A build runs in the background (`POST /api/offline-tiles/build` /
|
||||
`/api/terrain-tiles/build`, polled via the matching `*/build-status`
|
||||
route) — only one of each kind at a time; starting a second while one's
|
||||
running gets a 409.
|
||||
A build runs in the background (`GET /api/offline-regions` to list/see
|
||||
the current selection, `POST` to change it, then `POST
|
||||
/api/offline-tiles/build` / `/api/terrain-tiles/build`, polled via the
|
||||
matching `*/build-status` route) — only one of each kind at a time;
|
||||
starting a second while one's running gets a 409, as does starting
|
||||
either with nothing selected yet.
|
||||
|
||||
== Camper-relevant POIs (Overpass)
|
||||
|
||||
|
||||
Reference in new issue
Block a user