]> git.openstreetmap.org Git - rails.git/commitdiff
Merge branch 'p' of https://github.com/jfirebaugh/openstreetmap-website into jfirebaugh-p
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 22 Nov 2017 10:47:18 +0000 (10:47 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 22 Nov 2017 10:47:18 +0000 (10:47 +0000)
Refs #139

app/controllers/api_controller.rb
app/controllers/relation_controller.rb
app/controllers/search_controller.rb
app/models/relation.rb

index 9324a8ed56a4c4eb2351123a0c7d677ce56fd894..c6cc3ba5f46cbaf71412b7e414e3f48a0363e2b8 100644 (file)
@@ -193,7 +193,7 @@ class ApiController < ApplicationController
     # this "uniq" may be slightly inefficient; it may be better to first collect and output
     # all node-related relations, then find the *not yet covered* way-related ones etc.
     relations.uniq.each do |relation|
-      doc.root << relation.to_xml_node(nil, changeset_cache, user_display_name_cache)
+      doc.root << relation.to_xml_node(changeset_cache, user_display_name_cache)
     end
 
     response.headers["Content-Disposition"] = "attachment; filename=\"map.osm\""
index 80fd519978fec4a74b0e17f35a1b0dcdedf886f4..25532a95c72c0dc965f0ddeb1757099a7755773f 100644 (file)
@@ -91,7 +91,6 @@ class RelationController < ApplicationController
       # create XML.
       doc = OSM::API.new.get_xml_doc
       visible_nodes = {}
-      visible_members = { "Node" => {}, "Way" => {}, "Relation" => {} }
       changeset_cache = {}
       user_display_name_cache = {}
 
@@ -100,25 +99,22 @@ class RelationController < ApplicationController
 
         doc.root << node.to_xml_node(changeset_cache, user_display_name_cache)
         visible_nodes[node.id] = node
-        visible_members["Node"][node.id] = true
       end
 
       ways.each do |way|
         next unless way.visible? # should be unnecessary if data is consistent.
 
         doc.root << way.to_xml_node(visible_nodes, changeset_cache, user_display_name_cache)
-        visible_members["Way"][way.id] = true
       end
 
       relations.each do |rel|
         next unless rel.visible? # should be unnecessary if data is consistent.
 
-        doc.root << rel.to_xml_node(nil, changeset_cache, user_display_name_cache)
-        visible_members["Relation"][rel.id] = true
+        doc.root << rel.to_xml_node(changeset_cache, user_display_name_cache)
       end
 
       # finally add self and output
-      doc.root << relation.to_xml_node(visible_members, changeset_cache, user_display_name_cache)
+      doc.root << relation.to_xml_node(changeset_cache, user_display_name_cache)
       render :xml => doc.to_s
 
     else
index 4b8b2f402509655cb8efd5ed046fa54bc50ba324..0d40b6691ab4e69e6fac431004d61a9327522e64 100644 (file)
@@ -91,7 +91,7 @@ class SearchController < ApplicationController
     end
 
     relations.each do |rel|
-      doc.root << rel.to_xml_node(nil, changeset_cache, user_display_name_cache)
+      doc.root << rel.to_xml_node(changeset_cache, user_display_name_cache)
     end
 
     render :xml => doc.to_s
index 275cafec24d29090b9e859aabaf2e94de22cd7ca..157794cd69cee7424771a248b0331b569f6d32d8 100644 (file)
@@ -122,25 +122,13 @@ class Relation < ActiveRecord::Base
     doc
   end
 
-  def to_xml_node(visible_members = nil, changeset_cache = {}, user_display_name_cache = {})
+  def to_xml_node(changeset_cache = {}, user_display_name_cache = {})
     el = XML::Node.new "relation"
     el["id"] = id.to_s
 
     add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache)
 
     relation_members.each do |member|
-      p = 0
-
-      if visible_members
-        # if there is a list of visible members then use that to weed out deleted segments
-        p = 1 if visible_members[member.member_type][member.member_id]
-      else
-        # otherwise, manually go to the db to check things
-        p = 1 if member.member.visible?
-      end
-
-      next unless p
-
       member_el = XML::Node.new "member"
       member_el["type"] = member.member_type.downcase
       member_el["ref"] = member.member_id.to_s