1 class NodeController < ApplicationController
5 before_filter :authorize, :only => [:create, :update, :delete]
6 before_filter :check_availability, :only => [:create, :update, :delete]
7 after_filter :compress_output
11 node = Node.from_xml(request.raw_post, true)
14 node.user_id = @user.id
16 node.save_with_history!
18 render :text => node.id.to_s, :content_type => "text/plain"
20 render :nothing => true, :status => :bad_request
23 render :nothing => true, :status => :method_not_allowed
29 node = Node.find(params[:id])
32 render :text => node.to_xml.to_s, :content_type => "text/xml"
34 render :nothing => true, :status => :gone
36 rescue ActiveRecord::RecordNotFound
37 render :nothing => true, :status => :not_found
43 node = Node.find(params[:id])
46 new_node = Node.from_xml(request.raw_post)
48 if new_node and new_node.id == node.id
49 node.user_id = @user.id
50 node.latitude = new_node.latitude
51 node.longitude = new_node.longitude
52 node.tags = new_node.tags
53 node.save_with_history!
55 render :nothing => true
57 render :nothing => true, :status => :bad_request
60 render :nothing => true, :status => :gone
62 rescue ActiveRecord::RecordNotFound
63 render :nothing => true, :status => :not_found
69 node = Node.find(params[:id])
72 if Segment.find(:first, :conditions => [ "visible = 1 and (node_a = ? or node_b = ?)", node.id, node.id])
73 render :nothing => true, :status => :precondition_failed
75 node.user_id = @user.id
77 node.save_with_history!
79 render :nothing => true
82 render :nothing => true, :status => :gone
84 rescue ActiveRecord::RecordNotFound
85 render :nothing => true, :status => :not_found
90 ids = params['nodes'].split(',').collect { |n| n.to_i }
93 doc = OSM::API.new.get_xml_doc
95 Node.find(ids).each do |node|
96 doc.root << node.to_xml_node
99 render :text => doc.to_s, :content_type => "text/xml"
101 render :nothing => true, :status => :bad_request