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
+1
-1
@@ -307,7 +307,7 @@ class AppTest < Minitest::Test
|
||||
)
|
||||
assert_equal 200, response.status
|
||||
body = json_body(response)
|
||||
assert_equal "test-plugin.geojson", body["path"]
|
||||
assert_match(/\Atest-plugin_48\.05_17\.05_\d{6}_\d{4}\.geojson\z/, body["path"])
|
||||
|
||||
saved = json_body(request.get("/api/gpx/file/#{body["path"]}"))
|
||||
assert_equal "Test POI", saved["features"][0]["properties"]["name"]
|
||||
|
||||
@@ -22,6 +22,44 @@ class OverpassPoisTest < Minitest::Test
|
||||
water = geojson["features"].find { |f| f["properties"]["category"] == "Drinking water" }
|
||||
assert_equal [17.2, 48.1], water["geometry"]["coordinates"]
|
||||
assert_equal "Drinking water", water["properties"]["name"], "falls back to the category when the node has no name tag"
|
||||
assert_equal "amenity_drinking_water", water["properties"]["icon"]
|
||||
assert_equal "#2e86de", water["properties"]["color"]
|
||||
end
|
||||
|
||||
def test_to_geojson_assigns_icons_to_shop_categories
|
||||
response = {
|
||||
"elements" => [
|
||||
{ "type" => "node", "lat" => 1, "lon" => 1, "tags" => { "shop" => "supermarket" } },
|
||||
{ "type" => "node", "lat" => 2, "lon" => 2, "tags" => { "shop" => "convenience" } },
|
||||
],
|
||||
}
|
||||
|
||||
icons = Maptool::OverpassPois.to_geojson(response)["features"].map { |f| f["properties"]["icon"] }
|
||||
|
||||
assert_equal %w[shop_supermarket shop_convenience], icons
|
||||
end
|
||||
|
||||
def test_to_geojson_builds_a_description_from_recognized_tags
|
||||
response = {
|
||||
"elements" => [
|
||||
{
|
||||
"type" => "node",
|
||||
"lat" => 48.1,
|
||||
"lon" => 17.2,
|
||||
"tags" => { "amenity" => "toilets", "opening_hours" => "24/7", "operator" => "Town Council", "website" => "https://example.com" },
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
description = Maptool::OverpassPois.to_geojson(response)["features"].first["properties"]["description"]
|
||||
|
||||
assert_equal "Opening hours: 24/7\nOperator: Town Council\nhttps://example.com", description
|
||||
end
|
||||
|
||||
def test_to_geojson_omits_description_when_no_recognized_tags_are_present
|
||||
response = { "elements" => [{ "type" => "node", "lat" => 48.1, "lon" => 17.2, "tags" => { "amenity" => "toilets" } }] }
|
||||
|
||||
refute Maptool::OverpassPois.to_geojson(response)["features"].first["properties"].key?("description")
|
||||
end
|
||||
|
||||
def test_to_geojson_uses_the_node_name_when_present
|
||||
|
||||
Reference in new issue
Block a user