1 class NodeController < ApplicationController
4 before_filter :authorize, :only => [:create, :update, :delete]
5 before_filter :check_availability, :only => [:create, :update, :delete]
6 after_filter :compress_output
10 node = Node.from_xml(request.raw_post, true)
13 node.user_id = @user.id
16 if node.save_with_history
17 render :text => node.id.to_s, :content_type => "text/plain"
19 render :nothing => true, :status => :internal_server_error
22 render :nothing => true, :status => :bad_request
25 render :nothing => true, :status => :method_not_allowed
31 node = Node.find(params[:id])
34 render :text => node.to_xml.to_s, :content_type => "text/xml"
36 render :nothing => true, :status => :gone
38 rescue ActiveRecord::RecordNotFound
39 render :nothing => true, :status => :not_found
41 render :nothing => true, :status => :internal_server_error
47 node = Node.find(params[:id])
50 new_node = Node.from_xml(request.raw_post)
52 if new_node and new_node.id == node.id
53 node.user_id = @user.id
54 node.latitude = new_node.latitude
55 node.longitude = new_node.longitude
56 node.tags = new_node.tags
58 if node.save_with_history
59 render :nothing => true
61 render :nothing => true, :status => :internal_server_error
64 render :nothing => true, :status => :bad_request
67 render :nothing => true, :status => :gone
69 rescue ActiveRecord::RecordNotFound
70 render :nothing => true, :status => :not_found
72 render :nothing => true, :status => :internal_server_error
78 node = Node.find(params[:id])
81 if Segment.find(:first, :conditions => [ "visible = 1 and (node_a = ? or node_b = ?)", node.id, node.id])
82 render :nothing => true, :status => :precondition_failed
84 node.user_id = @user.id
86 node.save_with_history
87 render :nothing => true
90 render :nothing => true, :status => :gone
92 rescue ActiveRecord::RecordNotFound
93 render :nothing => true, :status => :not_found
95 render :nothing => true, :status => :internal_server_error
100 ids = params['nodes'].split(',').collect { |n| n.to_i }
103 doc = OSM::API.new.get_xml_doc
105 Node.find(ids).each do |node|
106 doc.root << node.to_xml_node
109 render :text => doc.to_s, :content_type => "text/xml"
111 render :nothing => true, :status => :bad_request