- doc = XML::Document.new
- doc.encoding = 'UTF-8'
- root = XML::Node.new 'osm'
- root['version'] = '0.4'
- root['generator'] = 'OpenStreetMap server'
- doc.root = root
-
- segment.old_segments.each do |old_segment|
- el1 = XML::Node.new 'segment'
- el1['id'] = old_segment.id.to_s
- el1['from'] = old_segment.node_a.to_s
- el1['to'] = old_segment.node_b.to_s
- Segment.split_tags(el1, old_segment.tags)
- el1['visible'] = old_segment.visible.to_s
- el1['timestamp'] = old_segment.timestamp.xmlschema
- root << el1
+ 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
+ render :text => doc.to_s
+ else
+ render :nothing => true, :status => 400