Files
maptool/plugins/overpass-pois/run.rb
T
randy 72ffd0ef18
CI / check (push) Successful in 40s
CI / deploy (push) Successful in 13s
Add an import plugin system, with the Overpass POI query as its first plugin
A plugin is a directory under plugins/ with a plugin.json manifest
({"label": "...", "command": "./run.sh"}) plus a script that reads
--south/--west/--north/--east and prints a GeoJSON FeatureCollection
to stdout (lib/maptool/plugins.rb) — that's the entire interface a
plugin needs to know about this app. The sidebar's new import icon
(logged in only, GET /api/plugins + POST /api/plugins/:name/run) lists
whatever's found and runs one for the current map viewport, saving its
output as a new .geojson file the same way an upload would be.

The point: a scraper for a site whose ToS forbids that (Park4Night,
iOverlander, Freecampsites) doesn't need to live in this public repo
to work here — its own directory just goes under plugins/ locally and
is never git add'ed, no special-casing needed anywhere.

plugins/overpass-pois wraps the existing rake overpass:pois query as
the first, in-repo, reference example of the contract.

Also fills in four modules (auth.js, locate.js, measure.js, notes.js)
missing from layout.erb's cache-busting importmap alongside adding
plugins.js's own entry — a pre-existing gap that meant they could keep
serving a stale cached copy across a deploy despite the importmap
existing specifically to prevent that.
2026-09-09 16:23:31 +02:00

17 lines
709 B
Ruby
Executable File

#!/usr/bin/env ruby
# frozen_string_literal: true
# The reference example of the plugin contract (see lib/maptool/plugins.rb):
# read --south/--west/--north/--east, print a GeoJSON FeatureCollection to
# stdout. Thin wrapper around lib/maptool/overpass_pois.rb, which already
# did all the real work for the "rake overpass:pois" dev-time task this
# plugin now sits alongside as a second way to run the same query.
require_relative "../../lib/maptool/overpass_pois"
args = ARGV.to_h { |arg| arg.sub(/\A--/, "").split("=", 2) }
bbox = %w[south west north east].map { |key| Float(args.fetch(key)) }
response = Maptool::OverpassPois.fetch(bbox)
puts JSON.generate(Maptool::OverpassPois.to_geojson(response))