]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5585'
authorTom Hughes <tom@compton.nu>
Sun, 2 Feb 2025 10:16:43 +0000 (10:16 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 2 Feb 2025 10:16:43 +0000 (10:16 +0000)
app/controllers/api/maps_controller.rb

index 2aa25fdd74611ecb2e3323af46ede63b8f72e5fe..9ba95c2551b650cfaccf0aa3c91f171a98e84238 100644 (file)
@@ -57,26 +57,12 @@ module Api
 
       nodes += Node.includes(:node_tags).find(nodes_to_fetch) unless nodes_to_fetch.empty?
 
-      visible_nodes = {}
-      @nodes = []
-      nodes.each do |node|
-        if node.visible?
-          visible_nodes[node.id] = node
-          @nodes << node
-        end
-      end
+      @nodes = nodes.filter(&:visible?)
 
-      @ways = []
-      way_ids = []
-      ways.each do |way|
-        if way.visible?
-          way_ids << way.id
-          @ways << way
-        end
-      end
+      @ways = ways.filter(&:visible?)
 
-      @relations = Relation.nodes(visible_nodes.keys).visible +
-                   Relation.ways(way_ids).visible
+      @relations = Relation.nodes(@nodes).visible +
+                   Relation.ways(@ways).visible
 
       # we do not normally return the "other" partners referenced by an relation,
       # e.g. if we return a way A that is referenced by relation X, and there's