Split offline hiking trails per country, add a picker instead of one big file
CI / check (push) Successful in 21s
CI / deploy (push) Successful in 11s

data/hiking_trails.geojson is now data/hiking_trails/<CODE>.geojson —
one file per country instead of a merge, generated per-source
(PmtilesBuilder.extract_hiking_trails), cached the same way
geofabrik_cache is (skipped once a country's own extract is already
newer than its source .osm.pbf, so growing the selection by one
country only re-extracts that one). GET /api/hiking-trails now lists
available country codes instead of a single file's status.

The Overlays panel's "Hiking trails" item becomes an expandable
per-country checklist once any offline extract exists (same shape as
Radar's own expand), replacing the plain on/off checkbox — nobody
covering a dozen countries' worth of offline map data needs all of
their hiking trails loaded and parsed at once, so each ticked country
fetches its own GeoJSON independently instead.

HikingTrails.extract_merged (server-side multi-country merge, no
longer needed now that the client picks per country) removed again.
Verified the new extract_hiking_trails + caching skip live on brick
against a real cached country PBF.
This commit is contained in:
randy committed 2026-09-13 11:17:05 +02:00
1 parent 079ac37787
commit c6e4a455b6
12 files changed
+300 -184

No files matched your search

+29 -18
View File
@@ -106,11 +106,12 @@ size rather than assuming one, so this isn't a problem either way.
The sidebar's "Hiking trails" overlay works online out of the box
(waymarkedtrails.org raster tiles, `public/js/hiking_trails.js`) —
clicking a trail fires a one-off Overpass query for its name/colour/
network/distance. For it to work offline too, `data/hiking_trails.geojson`
is generated automatically as the last step of every `offline.pmtiles`
build (`Maptool::HikingTrails`, `lib/maptool/hiking_trails.rb`), straight
from the *same* per-country `.osm.pbf` files already downloaded for
`offline.pmtiles` itself — no separate download, no third-party service:
network/distance. For it to work offline too, one `data/hiking_trails/
<CODE>.geojson` per country is generated automatically as the last step
of every `offline.pmtiles` build (`Maptool::HikingTrails`,
`lib/maptool/hiking_trails.rb`), straight from the *same* per-country
`.osm.pbf` files already downloaded for `offline.pmtiles` itself — no
separate download, no third-party service:
[source,shell]
----
@@ -130,20 +131,30 @@ tool stitches a route relation's member ways into one line for you
waymarkedtrails.org and this app's own online Overpass click handler
already do.
Best-effort: a hiking-trails extraction problem on one country's PBF
logs a warning and is skipped rather than failing the whole
`offline.pmtiles` build over what's a bonus overlay, not the core map
(`PmtilesBuilder.extract_hiking_trails`). Coordinates are rounded to 5
decimal places (~1m, plenty for a rendered line) to keep the combined
file smaller — for a many-country selection it can still be a sizeable
GeoJSON (Slovakia alone: ~3000 routes, ~30MB unrounded), fetched
client-side only once the overlay is actually toggled on, not on page
load. `rake hiking:trails[pbf,out]` runs the extraction by hand against
one `.osm.pbf` for testing.
Best-effort per country: an extraction problem on one country's PBF logs
a warning and is skipped rather than failing the whole `offline.pmtiles`
build, or even the other countries in the same selection, over what's a
bonus overlay, not the core map (`PmtilesBuilder.extract_hiking_trails`).
Cached the same way `geofabrik_cache` is (skipped once a country's own
extract is already newer than its source `.osm.pbf`), so growing the
region selection by one country only extracts that one. Coordinates are
rounded to 5 decimal places (~1m, plenty for a rendered line) — Slovakia
alone is ~3000 routes, ~30MB unrounded.
`DELETE /api/offline-tiles` removes this file along with `offline.pmtiles`
and the Geofabrik cache — there's no separate delete/rebuild route for it,
since it's not an independent build.
One file per country rather than one combined file: `GET /api/hiking-trails`
lists which country codes have an extract (`countries: [...]`), and the
Overlays panel's "Hiking trails" item turns that into a checklist —
each ticked country fetches its own `GET /tiles/hiking_trails/<CODE>.geojson`
only then, not on page load and not for countries never ticked. Offline
click hit-tests the loaded vector layer(s) directly
(`queryRenderedFeatures`) instead of querying Overpass, so it resolves
instantly with no network at all. `rake hiking:trails[pbf,out]` runs the
extraction by hand against one `.osm.pbf` for testing.
`DELETE /api/offline-tiles` removes the whole `data/hiking_trails/`
directory along with `offline.pmtiles` and the Geofabrik cache — there's
no separate delete/rebuild route for it, since it's not an independent
build.
== In-app regeneration