Split offline hiking trails per country, add a picker instead of one big file
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:
1 parent
079ac37787
commit
c6e4a455b6
12 files changed
+300
-184
No files matched your search
@@ -62,7 +62,6 @@ module Maptool
|
||||
|
||||
OFFLINE_PMTILES_PATH = File.join(DATA_DIR, "offline.pmtiles")
|
||||
TERRAIN_PMTILES_PATH = File.join(DATA_DIR, "terrain.pmtiles")
|
||||
HIKING_TRAILS_PATH = PmtilesBuilder.hiking_trails_path(DATA_DIR)
|
||||
GPX_STORE = GpxStore.new(File.join(DATA_DIR, "gpx"))
|
||||
LIVETRACK_STORE = LiveTrackStore.new(File.join(DATA_DIR, "livetrack.json"))
|
||||
|
||||
@@ -361,24 +360,28 @@ module Maptool
|
||||
# PmtilesBuilder.extract_hiking_trails) rather than its own separate
|
||||
# build — it's derived from the exact same per-country .osm.pbf cache
|
||||
# offline.pmtiles itself already downloads, so there's nothing of its
|
||||
# own to trigger or delete; DELETE /api/offline-tiles removes this
|
||||
# file too. No `meta` argument here (unlike offline/terrain above) —
|
||||
# parsing the whole GeoJSON just to report a feature count would cost
|
||||
# real time on every page load's status check for what's a multi-MB
|
||||
# file across several countries; size/mtime alone is enough to know
|
||||
# whether it's there.
|
||||
# own to trigger; DELETE /api/offline-tiles removes it too. One file
|
||||
# per country (not one combined file) so a viewer only ever fetches
|
||||
# the country they actually pick in the Hiking trails overlay's own
|
||||
# checklist (public/js/hiking_trails.js), not every selected country's
|
||||
# trails at once — `countries` lists which ones exist to build that
|
||||
# checklist from.
|
||||
get "/api/hiking-trails" do
|
||||
json pmtiles_file_status(HIKING_TRAILS_PATH, nil)
|
||||
json countries: PmtilesBuilder.hiking_trails_countries(DATA_DIR)
|
||||
end
|
||||
|
||||
# Fetched client-side only when the Hiking trails overlay is actually
|
||||
# toggled on (public/js/hiking_trails.js), not on page load — same
|
||||
# "on demand" story as the online raster tiles it replaces once this
|
||||
# is available.
|
||||
get "/tiles/hiking_trails.geojson" do
|
||||
halt 404 unless File.exist?(HIKING_TRAILS_PATH)
|
||||
# Fetched client-side only for a country the viewer actually ticks in
|
||||
# the Hiking trails checklist, not on page load. :code is constrained
|
||||
# to exactly what hiking_trails_countries can ever return (two
|
||||
# uppercase letters) — otherwise this would accept an arbitrary
|
||||
# ".."-laden path segment.
|
||||
get "/tiles/hiking_trails/:code.geojson" do
|
||||
halt 404 unless params[:code].match?(/\A[A-Z]{2}\z/)
|
||||
|
||||
send_file HIKING_TRAILS_PATH, type: "application/geo+json"
|
||||
path = PmtilesBuilder.hiking_trails_country_path(DATA_DIR, params[:code])
|
||||
halt 404 unless File.exist?(path)
|
||||
|
||||
send_file path, type: "application/geo+json"
|
||||
end
|
||||
|
||||
# Pinged once per page load (public/js/map.js) — url is a same-origin
|
||||
|
||||
Reference in new issue
Block a user