From f09b16cade5447158606e37ebd6c9cd86fc8b50b Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sat, 24 Nov 2007 14:47:50 +0000 Subject: [PATCH] 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). --- app/controllers/relation_controller.rb | 14 +++++--------- app/controllers/way_controller.rb | 14 +++++--------- 2 files changed, 10 insertions(+), 18 deletions(-) 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 -- 2.43.2