From: Tom Hughes Date: Sat, 24 Nov 2007 14:47:50 +0000 (+0000) Subject: When asked for ways which use a node, or relations which use some given X-Git-Tag: live~8031 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/f09b16cade5447158606e37ebd6c9cd86fc8b50b?hp=300c3b4ed40d80a483ea9e52b1591e2c38ef7209 When asked for ways which use a node, or relations which use some given object, return 200 OK with an empty document if not matches are found rather than 400 Bad Request (for ways) or 404 Not Found (for relations). --- diff --git a/app/controllers/relation_controller.rb b/app/controllers/relation_controller.rb index 4f2b12cf5..3f185254b 100644 --- a/app/controllers/relation_controller.rb +++ b/app/controllers/relation_controller.rb @@ -201,16 +201,12 @@ class RelationController < ApplicationController def relations_for_object(objtype) relationids = RelationMember.find(:all, :conditions => ['member_type=? and member_id=?', objtype, params[:id]]).collect { |ws| ws.id }.uniq - if relationids.length > 0 - doc = OSM::API.new.get_xml_doc - - Relation.find(relationids).each do |relation| - doc.root << relation.to_xml_node - end + doc = OSM::API.new.get_xml_doc - render :text => doc.to_s, :content_type => "text/xml" - else - render :nothing => true, :status => :not_found + Relation.find(relationids).each do |relation| + doc.root << relation.to_xml_node end + + render :text => doc.to_s, :content_type => "text/xml" end end diff --git a/app/controllers/way_controller.rb b/app/controllers/way_controller.rb index acba12def..413c65d1c 100644 --- a/app/controllers/way_controller.rb +++ b/app/controllers/way_controller.rb @@ -140,16 +140,12 @@ class WayController < ApplicationController def ways_for_node wayids = WayNode.find(:all, :conditions => ['node_id = ?', params[:id]]).collect { |ws| ws.id }.uniq - if wayids.length > 0 - doc = OSM::API.new.get_xml_doc - - Way.find(wayids).each do |way| - doc.root << way.to_xml_node - end + doc = OSM::API.new.get_xml_doc - render :text => doc.to_s, :content_type => "text/xml" - else - render :nothing => true, :status => :bad_request + Way.find(wayids).each do |way| + doc.root << way.to_xml_node end + + render :text => doc.to_s, :content_type => "text/xml" end end