Add support for segment/:id/ways and node/:id/segments API calls. Fixes #452.

This commit is contained in:
Tom Hughes 2007-06-21 22:52:40 +00:00
parent 6020e0519e
commit 2c98558c86
3 changed files with 33 additions and 1 deletions

View file

@ -106,7 +106,22 @@ class SegmentController < ApplicationController
ids = params['segments'].split(',').collect {|s| s.to_i }
if ids.length > 0
segmentlist = Segment.find(ids)
doc = OSM::API.get_xml_doc
doc = OSM::API.new.get_xml_doc
segmentlist.each do |segment|
doc.root << segment.to_xml_node
end
render :text => doc.to_s
else
render :nothing => true, :status => 400
end
end
def segments_for_node
response.headers["Content-Type"] = 'text/xml'
segmentids = Segment.find(:all, :conditions => ['node_a = ? OR node_b = ?', params[:id], params[:id]]).collect { |s| s.id }.uniq
if segmentids.length > 0
segmentlist = Segment.find(segmentids)
doc = OSM::API.new.get_xml_doc
segmentlist.each do |segment|
doc.root << segment.to_xml_node
end