]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/way_controller.rb
Add support for segment/:id/ways and node/:id/segments API calls. Fixes #452.
[rails.git] / app / controllers / way_controller.rb
index 34f1ab5e7d3818f582df5664e6d3b3728f9ab189..e7eead52fe770d223e3a5cb1cc795db0745d6871 100644 (file)
@@ -135,4 +135,19 @@ class WayController < ApplicationController
     end
   end
 
     end
   end
 
+  def ways_for_segment
+    response.headers["Content-Type"] = 'text/xml'
+    wayids = WaySegment.find(:all, :conditions => ['segment_id = ?', params[:id]]).collect { |ws| ws.id }.uniq
+    if wayids.length > 0
+      waylist = Way.find(wayids)
+      doc = OSM::API.new.get_xml_doc
+      waylist.each do |way|
+        doc.root << way.to_xml_node
+      end
+      render :text => doc.to_s
+    else
+      render :nothing => true, :status => 400
+    end
+  end
+
 end
 end