Give Overpass POI downloads icons/descriptions and unique filenames
Overpass categories now carry the same icon+color styling a p4n2gpx waypoint gets, instead of falling back to gpx.js's plain red marker, plus a popup description built from opening_hours/operator/website tags. Supermarket/convenience store reuse NPS's generic store glyph, the only honest match in that icon set. Each plugin run's saved filename now bakes in the area's center and a timestamp, so repeated downloads for different areas land as separate, identifiable files instead of overpass-pois.geojson/-1/-2/...
This commit is contained in:
1 parent
72ffd0ef18
commit
1733fc7c1b
5 files changed
+119
-20
No files matched your search
@@ -356,13 +356,24 @@ module Maptool
|
||||
bbox = %w[south west north east].map { |key| params[key].to_s }
|
||||
halt 400, json(error: "south, west, north, east are required") if bbox.any?(&:empty?)
|
||||
|
||||
south, west, north, east = bbox.map(&:to_f)
|
||||
begin
|
||||
geojson = Plugins.run(PLUGINS_DIR, params[:name], bbox.map(&:to_f))
|
||||
geojson = Plugins.run(PLUGINS_DIR, params[:name], [south, west, north, east])
|
||||
rescue Plugins::RunError => e
|
||||
halt 502, json(error: e.message)
|
||||
end
|
||||
|
||||
path = GPX_STORE.save(folder: "", filename: "#{params[:name]}.geojson", io: StringIO.new(JSON.generate(geojson)))
|
||||
# Filename carries the area's center and the run's timestamp (same
|
||||
# idea as a p4n2gpx export's own "p4n_area_<lat>_<lon>_<date>_<time>"
|
||||
# naming) — without it, running this again for a different area just
|
||||
# overwrote/renamed-with-a-counter the same "overpass-pois.geojson",
|
||||
# with nothing in the file tree to tell one run's POIs from another's.
|
||||
center_lat = format("%.2f", (south + north) / 2)
|
||||
center_lon = format("%.2f", (west + east) / 2)
|
||||
timestamp = Time.now.strftime("%y%m%d_%H%M")
|
||||
filename = "#{params[:name]}_#{center_lat}_#{center_lon}_#{timestamp}.geojson"
|
||||
|
||||
path = GPX_STORE.save(folder: "", filename: filename, io: StringIO.new(JSON.generate(geojson)))
|
||||
json path: path, tree: GPX_STORE.tree
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user