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 9324a8e..c6cc3ba 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 80fd519..25532a9 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 4b8b2f4..0d40b66 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 275cafe..157794c 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