]> git.openstreetmap.org Git - rails.git/commitdiff
When asked for ways which use a node, or relations which use some given
authorTom Hughes <tom@compton.nu>
Sat, 24 Nov 2007 14:47:50 +0000 (14:47 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 24 Nov 2007 14:47:50 +0000 (14:47 +0000)
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
app/controllers/way_controller.rb

index 4f2b12cf5d4cec51e1d1ac54f65898bc4858ad24..3f185254b4cb3ae6c5e56fdab1cdce7357607126 100644 (file)
@@ -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
 
   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
     end
+
+    render :text => doc.to_s, :content_type => "text/xml"
   end
 end
   end
 end
index acba12def6a7f9f625b8fb78c2745d3eedc06143..413c65d1cd55f9f812670a09d302bc9c0a61e59f 100644 (file)
@@ -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
 
   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
     end
+
+    render :text => doc.to_s, :content_type => "text/xml"
   end
 end
   end
 end