Add rake overpass:pois to fetch camper POIs from Overpass
lib/maptool/overpass_pois.rb: queries Overpass for drinking water, dump stations, LPG refill, toilets, laundromats, supermarkets/ convenience stores, and springs within a bbox, writes GeoJSON. A dev-time tool (like the offline.pmtiles/terrain.pmtiles generation steps already documented) — not called by the running app, drop the output into data/gpx/ or upload it through the Tracks panel like any other .geojson layer. Verified against the real Overpass API (88 POIs for central Bratislava) in addition to the new unit tests (pure to_geojson/ build_query logic, no network in the suite itself). Full suite: 103 runs, 0 failures.
This commit is contained in:
1 parent
aa2b96ac70
commit
f53c74e06f
5 files changed
+180
-1
No files matched your search
@@ -6,3 +6,20 @@ Rake::TestTask.new(:test) do |t|
|
||||
end
|
||||
|
||||
task default: :test
|
||||
|
||||
namespace :overpass do
|
||||
desc "Fetch camper-relevant POIs (water, dump stations, LPG, toilets, laundry, shops, springs) " \
|
||||
"for a bbox from Overpass and write GeoJSON. Usage: rake overpass:pois[south,west,north,east,out.geojson]"
|
||||
task :pois, [:south, :west, :north, :east, :out] do |_t, args|
|
||||
%i[south west north east out].each { |key| abort("usage: rake overpass:pois[south,west,north,east,out.geojson]") unless args[key] }
|
||||
|
||||
require_relative "lib/maptool/overpass_pois"
|
||||
bbox = [args[:south], args[:west], args[:north], args[:east]].map(&:to_f)
|
||||
|
||||
puts "Querying Overpass for #{bbox.join(",")}..."
|
||||
response = Maptool::OverpassPois.fetch(bbox)
|
||||
geojson = Maptool::OverpassPois.to_geojson(response)
|
||||
File.write(args[:out], JSON.generate(geojson))
|
||||
puts "Wrote #{geojson["features"].size} POIs to #{args[:out]}"
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user