Wire offline hiking trails into the real build, API, and renderer
data/hiking_trails.geojson now generates automatically as the last step of every offline.pmtiles build (PmtilesBuilder.extract_hiking_trails, best-effort — a failure here doesn't fail the whole build), merged across all selected countries with cross-border dedup by OSM relation id (HikingTrails.extract_merged). Served at GET /tiles/hiking_trails.geojson and GET /api/hiking-trails, fetched client-side only once the overlay is actually toggled on. hiking_trails.js now prefers this local file whenever it exists, regardless of which base map (online/offline) is active — same "prefer local when available" story as HillshadeControl already uses for terrain. Offline click hit-tests the real vector layer directly (queryRenderedFeatures) instead of querying Overpass — instant, no network. Coordinates are rounded to 5dp to keep the combined file smaller; colour tag values are normalized against a known-safe set before ever reaching a style paint property. Verified extract_merged (new: combines multiple countries' extracts, dedupes overlapping relations) against two real cached country PBFs on brick directly, not just fixtures.
This commit is contained in:
1 parent
b35ace9734
commit
079ac37787
11 files changed
+370
-25
No files matched your search
@@ -62,6 +62,7 @@ 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"))
|
||||
|
||||
@@ -356,6 +357,30 @@ module Maptool
|
||||
json ok: true
|
||||
end
|
||||
|
||||
# Generated as a step inside POST /api/offline-tiles/build (see
|
||||
# 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.
|
||||
get "/api/hiking-trails" do
|
||||
json pmtiles_file_status(HIKING_TRAILS_PATH, nil)
|
||||
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)
|
||||
|
||||
send_file HIKING_TRAILS_PATH, type: "application/geo+json"
|
||||
end
|
||||
|
||||
# Pinged once per page load (public/js/map.js) — url is a same-origin
|
||||
# path (not kiwix-serve's own address, which the browser can't reach
|
||||
# directly behind the reverse proxy in front of this app), proxied by
|
||||
|
||||
Reference in new issue
Block a user