Prototype: extract offline hiking trails from the Geofabrik PBF we already have
No custom Planetiler profile needed after all — Maptool::HikingTrails runs osmium tags-filter r/route=hiking against the same .osm.pbf PmtilesBuilder already downloads per country for offline.pmtiles, then osmium cat -f opl (locations_on_ways=true) to get member-way geometry back as plain text, no separate node-id lookup table to build. No general OSM tool stitches a route relation into one line (routes are a semantic grouping, not a geometry type) — parse_opl does that walk itself, same as the Overpass-based click handler already does client-side. Kept pure/testable apart from the two osmium subprocess calls, mirroring OverpassPois.fetch vs .to_geojson. rake hiking:trails[pbf,out] to try it by hand against a real cached extract. Not wired into the actual offline build or rendering yet — still just a prototype, per TODO.adoc.
This commit is contained in:
1 parent
cc3d8ca5f3
commit
714795d52b
4 files changed
+281
-1
No files matched your search
@@ -24,6 +24,22 @@ namespace :overpass do
|
||||
end
|
||||
end
|
||||
|
||||
namespace :hiking do
|
||||
desc "Extract route=hiking relations (name/colour/network/operator, full geometry) from a local " \
|
||||
".osm.pbf (e.g. one of PmtilesBuilder's own data/geofabrik_cache/*.osm.pbf) and write GeoJSON. " \
|
||||
"Prototype — see lib/maptool/hiking_trails.rb. Usage: rake hiking:trails[input.osm.pbf,out.geojson]"
|
||||
task :trails, %i[pbf out] do |_t, args|
|
||||
%i[pbf out].each { |key| abort("usage: rake hiking:trails[input.osm.pbf,out.geojson]") unless args[key] }
|
||||
|
||||
require_relative "lib/maptool/hiking_trails"
|
||||
|
||||
puts "Extracting hiking routes from #{args[:pbf]}..."
|
||||
geojson = Maptool::HikingTrails.extract(args[:pbf])
|
||||
File.write(args[:out], JSON.generate(geojson))
|
||||
puts "Wrote #{geojson["features"].size} route(s) to #{args[:out]}"
|
||||
end
|
||||
end
|
||||
|
||||
namespace :gpx do
|
||||
desc "Backfill properties.id on Note-category features saved before edit/delete (and its id targeting) existed"
|
||||
task :backfill_note_ids do
|
||||
|
||||
Reference in new issue
Block a user