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.
26 lines
1012 B
Ruby
26 lines
1012 B
Ruby
require "rake/testtask"
|
|
|
|
Rake::TestTask.new(:test) do |t|
|
|
t.libs << "test" << "lib"
|
|
t.test_files = FileList["test/test_*.rb"]
|
|
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
|