]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5925'
authorTom Hughes <tom@compton.nu>
Sun, 13 Apr 2025 10:12:14 +0000 (11:12 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 13 Apr 2025 10:12:14 +0000 (11:12 +0100)
app/assets/javascripts/leaflet.key.js
app/assets/javascripts/osm.js.erb
config/key.yml
config/locales/en.yml
lib/map_layers.rb
test/system/history_test.rb
test/system/search_test.rb
test/system/site_test.rb

index a5d7acb430507b98e4ef7c96608bc69f0f835abf..b432bcf8fce059381fe875ddb49f0045f285e0e2 100644 (file)
@@ -27,7 +27,7 @@ L.OSM.key = function (options) {
     }
 
     function updateButton() {
-      const disabled = OSM.LAYERS_WITH_MAP_KEY.indexOf(map.getMapBaseLayerId()) === -1;
+      const disabled = !map.getMapBaseLayer().options.hasLegend;
       button
         .toggleClass("disabled", disabled)
         .attr("data-bs-original-title",
index d73d1c16302d5c9b64017a885b4e07a04f2d90b9..31f92da84a846644e9e99fe2c653dc18bc983a9b 100644 (file)
@@ -27,8 +27,7 @@ OSM = {
 
   DEFAULT_LOCALE: <%= I18n.default_locale.to_json %>,
 
-  LAYER_DEFINITIONS: <%= MapLayers::full_definitions("config/layers.yml").to_json %>,
-  LAYERS_WITH_MAP_KEY: <%= YAML.load_file(Rails.root.join("config/key.yml")).keys.to_json %>,
+  LAYER_DEFINITIONS: <%= MapLayers::full_definitions("config/layers.yml", :legends => "config/key.yml").to_json %>,
 
   MARKER_BLUE: <%= image_path("marker-blue.png").to_json %>,
   MARKER_GREEN: <%= image_path("marker-green.png").to_json %>,
index 798d9ca546db80f0b82960bb79f0db13078615f0..775cdf461d7b2afeab0c693a49ee1a968073f83a 100644 (file)
@@ -104,6 +104,44 @@ mapnik:
   - { min_zoom: 15, name: private, image: private.png }
   - { min_zoom: 15, name: destination, image: destination.png }
   - { min_zoom: 12, name: construction, image: construction.png }
+cyclosm:
+  # bicycle routes: roads.mss, road-colors.mss
+  - { min_zoom:  2, name: international_bike_route, width: 50, height:  1, fill: "#ff00ff", opacity: 0.75 }
+  - { min_zoom:  8, name: international_bike_route, width: 50, height:  1, fill: "#ff00ff", opacity: 0.6 }
+  - { min_zoom:  9, name: international_bike_route, width: 50, height:  2, fill: "#ff00ff", opacity: 0.6 }
+  - { min_zoom: 11, name: international_bike_route, width: 50, height:  3, fill: "#ff00ff", opacity: 0.25 }
+  - { min_zoom: 12, name: international_bike_route, width: 50, height:  4, fill: "#ff00ff", opacity: 0.25 }
+  - { min_zoom: 14, name: international_bike_route, width: 50, height:  5, fill: "#ff00ff", opacity: 0.25 }
+  - { min_zoom: 15, name: international_bike_route, width: 50, height:  6, fill: "#ff00ff", opacity: 0.25 }
+  - { min_zoom: 16, name: international_bike_route, width: 50, height:  7, fill: "#ff00ff", opacity: 0.25 }
+  - { min_zoom: 17, name: international_bike_route, width: 50, height: 10, fill: "#ff00ff", opacity: 0.25 }
+  - { min_zoom: 18, name: international_bike_route, width: 50, height: 14, fill: "#ff00ff", opacity: 0.25 }
+  - { min_zoom:  5, name: national_bike_route,      width: 50, height:  1, fill: "#aa00ff", opacity: 0.75 }
+  - { min_zoom:  8, name: national_bike_route,      width: 50, height:  1, fill: "#aa00ff", opacity: 0.6 }
+  - { min_zoom:  9, name: national_bike_route,      width: 50, height:  2, fill: "#aa00ff", opacity: 0.6 }
+  - { min_zoom: 11, name: national_bike_route,      width: 50, height:  3, fill: "#aa00ff", opacity: 0.25 }
+  - { min_zoom: 12, name: national_bike_route,      width: 50, height:  4, fill: "#aa00ff", opacity: 0.25 }
+  - { min_zoom: 14, name: national_bike_route,      width: 50, height:  5, fill: "#aa00ff", opacity: 0.25 }
+  - { min_zoom: 15, name: national_bike_route,      width: 50, height:  6, fill: "#aa00ff", opacity: 0.25 }
+  - { min_zoom: 16, name: national_bike_route,      width: 50, height:  7, fill: "#aa00ff", opacity: 0.25 }
+  - { min_zoom: 17, name: national_bike_route,      width: 50, height: 10, fill: "#aa00ff", opacity: 0.25 }
+  - { min_zoom: 18, name: national_bike_route,      width: 50, height: 14, fill: "#aa00ff", opacity: 0.25 }
+  - { min_zoom:  8, name: regional_bike_route,      width: 50, height:  1, fill: "#5500ff", opacity: 0.6 }
+  - { min_zoom:  9, name: regional_bike_route,      width: 50, height:  2, fill: "#5500ff", opacity: 0.6 }
+  - { min_zoom: 11, name: regional_bike_route,      width: 50, height:  3, fill: "#5500ff", opacity: 0.25 }
+  - { min_zoom: 12, name: regional_bike_route,      width: 50, height:  4, fill: "#5500ff", opacity: 0.25 }
+  - { min_zoom: 14, name: regional_bike_route,      width: 50, height:  5, fill: "#5500ff", opacity: 0.25 }
+  - { min_zoom: 15, name: regional_bike_route,      width: 50, height:  6, fill: "#5500ff", opacity: 0.25 }
+  - { min_zoom: 16, name: regional_bike_route,      width: 50, height:  7, fill: "#5500ff", opacity: 0.25 }
+  - { min_zoom: 17, name: regional_bike_route,      width: 50, height: 10, fill: "#5500ff", opacity: 0.25 }
+  - { min_zoom: 18, name: regional_bike_route,      width: 50, height: 14, fill: "#5500ff", opacity: 0.25 }
+  - { min_zoom: 11, name: local_bike_route,         width: 50, height:  3, fill: "#0000ff", opacity: 0.25 }
+  - { min_zoom: 12, name: local_bike_route,         width: 50, height:  4, fill: "#0000ff", opacity: 0.25 }
+  - { min_zoom: 14, name: local_bike_route,         width: 50, height:  5, fill: "#0000ff", opacity: 0.25 }
+  - { min_zoom: 15, name: local_bike_route,         width: 50, height:  6, fill: "#0000ff", opacity: 0.25 }
+  - { min_zoom: 16, name: local_bike_route,         width: 50, height:  7, fill: "#0000ff", opacity: 0.25 }
+  - { min_zoom: 17, name: local_bike_route,         width: 50, height: 10, fill: "#0000ff", opacity: 0.25 }
+  - { min_zoom: 18, name: local_bike_route,         width: 50, height: 14, fill: "#0000ff", opacity: 0.25 }
 cyclemap:
   - { min_zoom:  5, name: motorway, width: 50, height: 2, fill: "#9a9ab1" }
   - { min_zoom:  9, name: motorway, width: 50, height: 3, fill: "#9a9ab1" }
@@ -124,17 +162,17 @@ cyclemap:
   - { min_zoom: 17, name: track, width: 50, height: 5, fill: white, casing: "#999", casing-dasharray: "5 3", casing-dashoffset: 1 }
   - { min_zoom: 13, name: bridleway, width: 52, height: 3, line: green, line-width: 1.5, line-dasharray: "4 2" }
   - { min_zoom:  8, name: cycleway, width: 50, height: 3, line: "#0100fe", line-width: 1.5, line-dasharray: "6 2" }
-  - { min_zoom:  5, name: cycleway_national, width: 50, height:  2, fill: "#fe0000" }
-  - { min_zoom: 12, name: cycleway_national, width: 50, height:  3, fill: "#fe0000" }
-  - { min_zoom: 13, name: cycleway_national, width: 50, height: 12, fill: "#ffb3b3" }
-  - { min_zoom:  7, name: cycleway_regional, width: 50, height:  2, fill: "#b638fb" }
-  - { min_zoom: 12, name: cycleway_regional, width: 50, height:  3, fill: "#b638fb" }
-  - { min_zoom: 13, name: cycleway_regional, width: 50, height: 10, fill: "#ddb5d9" }
-  - { min_zoom:  8, name: cycleway_local, width: 50, height: 2, fill: "#0100fe" }
-  - { min_zoom: 12, name: cycleway_local, width: 50, height: 3, fill: "#0100fe" }
-  - { min_zoom: 13, name: cycleway_local, width: 50, height: 8, fill: "#b2b2ff" }
-  - { min_zoom: 10, name: cycleway_mtb, width: 50, height: 2, fill: "#ff7b1c" }
-  - { min_zoom: 13, name: cycleway_mtb, width: 50, height: 6, fill: "#fbcaa3" }
+  - { min_zoom:  5, name: national_bike_route, width: 50, height:  2, fill: "#fe0000" }
+  - { min_zoom: 12, name: national_bike_route, width: 50, height:  3, fill: "#fe0000" }
+  - { min_zoom: 13, name: national_bike_route, width: 50, height: 12, fill: "#ffb3b3" }
+  - { min_zoom:  7, name: regional_bike_route, width: 50, height:  2, fill: "#b638fb" }
+  - { min_zoom: 12, name: regional_bike_route, width: 50, height:  3, fill: "#b638fb" }
+  - { min_zoom: 13, name: regional_bike_route, width: 50, height: 10, fill: "#ddb5d9" }
+  - { min_zoom:  8, name: local_bike_route, width: 50, height: 2, fill: "#0100fe" }
+  - { min_zoom: 12, name: local_bike_route, width: 50, height: 3, fill: "#0100fe" }
+  - { min_zoom: 13, name: local_bike_route, width: 50, height: 8, fill: "#b2b2ff" }
+  - { min_zoom: 10, name: mountain_bike_route, width: 50, height: 2, fill: "#ff7b1c" }
+  - { min_zoom: 13, name: mountain_bike_route, width: 50, height: 6, fill: "#fbcaa3" }
   - { min_zoom: 13, name: footway, width: 50, height: 3, line: "#bd6d6e", line-width: 1.5, line-dasharray: "6 2" }
   - { min_zoom:  7, name: rail, width: 50, height: 3, line: "#999999", line-width: 1.5 }
   - { min_zoom: 14, name: rail, width: 50, height: 4, fill: "#999999", line: white, line-dasharray: 4, line-width: 2 }
index c4c53f05906f8fa93b80234717e8cf62e3da70ff..35ba0650bc2f6475d528e3ec37a3f50458e2c533 100644 (file)
@@ -2529,10 +2529,11 @@ en:
         track: "Track"
         bridleway: "Bridleway"
         cycleway: "Cycleway"
-        cycleway_national: "National cycleway"
-        cycleway_regional: "Regional cycleway"
-        cycleway_local: "Local cycleway"
-        cycleway_mtb: "Mountain bike route"
+        international_bike_route: "International bike route"
+        national_bike_route: "National bike route"
+        regional_bike_route: "Regional bike route"
+        local_bike_route: "Local bike route"
+        mountain_bike_route: "Mountain bike route"
         footway: "Footway"
         rail: "Railway"
         train: "Train"
index 8a1bdea79789a02f23545f6d15ea42a999aaef55..f0727ed927bf528b843a4bc77c0bb4e1a7bf96f4 100644 (file)
@@ -1,5 +1,6 @@
 module MapLayers
-  def self.full_definitions(layers_filename)
+  def self.full_definitions(layers_filename, legends: nil)
+    legended_layers = YAML.load_file(Rails.root.join(legends)).keys if legends
     YAML.load_file(Rails.root.join(layers_filename))
         .reject { |layer| layer["apiKeyId"] && !Settings[layer["apiKeyId"]] }
         .map do |layer|
@@ -7,6 +8,7 @@ module MapLayers
             layer["apikey"] = Settings[layer["apiKeyId"]]
             layer.delete "apiKeyId"
           end
+          layer["hasLegend"] = true if legended_layers&.include?(layer["layerId"])
           layer
         end
   end
index cb36473541757a33a86bd5c0898ac1da6a4d1d0d..01652b6b08cda11fd0b15a0ac7d04b9cd1a10549 100644 (file)
@@ -176,6 +176,16 @@ class HistoryTest < ApplicationSystemTestCase
     end
   end
 
+  test "changeset bbox is shown on the map and clickable" do
+    user = create(:user)
+    changeset = create(:changeset, :user => user, :num_changes => 1, :bbox => [50, 50, 51, 51])
+
+    visit "#{user_path(user)}/history"
+    find_by_id("map").click
+
+    assert_current_path changeset_path(changeset)
+  end
+
   private
 
   def create_visible_changeset(user, comment)
index bf05f92122a2e098093148370edd50545b5ae60a..0292e67f0f3389c25333ab0c0dce97f20a49723e 100644 (file)
@@ -1,7 +1,13 @@
 require "application_system_test_case"
 
 class SearchTest < ApplicationSystemTestCase
-  test "click on 'where is this' sets search input value and makes reverse geocoding request with zoom" do
+  def setup
+    stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/search\?})
+      .to_return(:status => 404)
+
+    stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?})
+      .to_return(:status => 404)
+
     stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?.*zoom=$})
       .to_return(:status => 400, :body => <<-BODY)
         <?xml version="1.0" encoding="UTF-8"?>
@@ -27,7 +33,9 @@ class SearchTest < ApplicationSystemTestCase
           </addressparts>
         </reversegeocode>
       BODY
+  end
 
+  test "click on 'where is this' sets search input value and makes reverse geocoding request with zoom" do
     visit "/#map=15/51.76320/-0.00760"
 
     assert_field "Search", :with => ""
@@ -37,28 +45,28 @@ class SearchTest < ApplicationSystemTestCase
     assert_link "Broxbourne, Hertfordshire, East of England, England, United Kingdom"
   end
 
-  test "query search link sets search input value" do
-    stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?})
-      .to_return(:status => 404)
+  test "'Show address' from context menu makes reverse geocoding request with zoom" do
+    visit "/#map=15/51.76320/-0.00760"
+
+    find_by_id("map").right_click
+    click_on "Show address"
 
+    assert_link "Broxbourne, Hertfordshire, East of England, England, United Kingdom"
+  end
+
+  test "query search link sets search input value" do
     visit search_path(:query => "2.341, 7.896")
 
     assert_field "Search", :with => "2.341, 7.896"
   end
 
   test "latlon search link sets search input value" do
-    stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?})
-      .to_return(:status => 404)
-
     visit search_path(:lat => "4.321", :lon => "9.876")
 
     assert_field "Search", :with => "4.321, 9.876"
   end
 
   test "search adds viewbox param to Nominatim link" do
-    stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/search\?})
-      .to_return(:status => 404)
-
     visit "/"
 
     fill_in "query", :with => "paris"
@@ -68,9 +76,6 @@ class SearchTest < ApplicationSystemTestCase
   end
 
   test "search adds zoom param to reverse Nominatim link" do
-    stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?})
-      .to_return(:status => 404)
-
     visit "/#map=7/1.234/6.789"
 
     fill_in "query", :with => "60 30"
index d7b9f279e9d3d874ca3240d604749efa9e25173f..df7682fe9eceb65240da47ad7314c4f1b4051a4d 100644 (file)
@@ -28,7 +28,7 @@ class SiteTest < ApplicationSystemTestCase
   end
 
   test "tooltip shows for Map Key button on a layer without a key provided" do
-    visit "/#layers=Y" # assumes that CyclOSM layer has no map key
+    visit "/#layers=H" # assumes that HOT layer has no map key
 
     assert_no_selector ".tooltip"
     button = find ".control-key .control-button"