X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e799022131f3e833179e9058060ec5e136ed2edd..932c2d4f8faa0e43f4777089c859d99dfb517d9d:/app/controllers/segment_controller.rb?ds=sidebyside diff --git a/app/controllers/segment_controller.rb b/app/controllers/segment_controller.rb index 9315bce77..58e98bef2 100644 --- a/app/controllers/segment_controller.rb +++ b/app/controllers/segment_controller.rb @@ -2,6 +2,7 @@ class SegmentController < ApplicationController require 'xml/libxml' before_filter :authorize + after_filter :compress_output def create response.headers["Content-Type"] = 'application/xml' @@ -12,11 +13,11 @@ class SegmentController < ApplicationController segment.user_id = @user.id - a = Node.find(segment.node_a.to_i) - b = Node.find(segment.node_b.to_i) + segment.from_node = Node.find(segment.node_a.to_i) + segment.to_node = Node.find(segment.node_b.to_i) - unless a and a.visible and b and b.visible - render :nothing => true, :status => 400 + unless segment.preconditions_ok? # are the nodes visible? + render :nothing => true, :status => 412 end if segment.save_with_history @@ -80,4 +81,19 @@ class SegmentController < ApplicationController end + def segments + response.headers["Content-Type"] = 'application/xml' + ids = params['segments'].split(',').collect {|s| s.to_i } + if ids.length > 0 + segmentlist = Segment.find(ids) + doc = 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 + end