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).
This commit is contained in:
Tom Hughes 2007-11-24 14:47:50 +00:00
parent 300c3b4ed4
commit f09b16cade
2 changed files with 10 additions and 18 deletions

View file

@ -201,16 +201,12 @@ class RelationController < ApplicationController
def relations_for_object(objtype) def relations_for_object(objtype)
relationids = RelationMember.find(:all, :conditions => ['member_type=? and member_id=?', objtype, params[:id]]).collect { |ws| ws.id }.uniq 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
doc = OSM::API.new.get_xml_doc
Relation.find(relationids).each do |relation| Relation.find(relationids).each do |relation|
doc.root << relation.to_xml_node doc.root << relation.to_xml_node
end
render :text => doc.to_s, :content_type => "text/xml"
else
render :nothing => true, :status => :not_found
end end
render :text => doc.to_s, :content_type => "text/xml"
end end
end end

View file

@ -140,16 +140,12 @@ class WayController < ApplicationController
def ways_for_node def ways_for_node
wayids = WayNode.find(:all, :conditions => ['node_id = ?', params[:id]]).collect { |ws| ws.id }.uniq 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
doc = OSM::API.new.get_xml_doc
Way.find(wayids).each do |way| Way.find(wayids).each do |way|
doc.root << way.to_xml_node doc.root << way.to_xml_node
end
render :text => doc.to_s, :content_type => "text/xml"
else
render :nothing => true, :status => :bad_request
end end
render :text => doc.to_s, :content_type => "text/xml"
end end
end end