1 class NodeController < ApplicationController
4 before_filter :authorize, :only => [:create, :update, :delete]
5 after_filter :compress_output
9 node = Node.from_xml(request.raw_post, true)
12 node.user_id = @user.id
15 if node.save_with_history
16 render :text => node.id.to_s, :content_type => "text/plain"
18 render :nothing => true, :status => :internal_server_error
21 render :nothing => true, :status => :bad_request
24 render :nothing => true, :status => :method_not_allowed
30 node = Node.find(params[:id])
33 render :text => node.to_xml.to_s, :content_type => "text/xml"
35 render :nothing => true, :status => :gone
37 rescue ActiveRecord::RecordNotFound
38 render :nothing => true, :status => :not_found
40 render :nothing => true, :status => :internal_server_error
46 node = Node.find(params[:id])
49 new_node = Node.from_xml(request.raw_post)
51 if new_node and new_node.id == node.id
52 node.user_id = @user.id
53 node.latitude = new_node.latitude
54 node.longitude = new_node.longitude
55 node.tags = new_node.tags
57 if node.save_with_history
58 render :nothing => true
60 render :nothing => true, :status => :internal_server_error
63 render :nothing => true, :status => :bad_request
66 render :nothing => true, :status => :gone
68 rescue ActiveRecord::RecordNotFound
69 render :nothing => true, :status => :not_found
71 render :nothing => true, :status => :internal_server_error
77 node = Node.find(params[:id])
80 if Segment.find(:first, :conditions => [ "visible = 1 and (node_a = ? or node_b = ?)", node.id, node.id])
81 render :nothing => true, :status => :precondition_failed
83 node.user_id = @user.id
85 node.save_with_history
86 render :nothing => true
89 render :nothing => true, :status => :gone
91 rescue ActiveRecord::RecordNotFound
92 render :nothing => true, :status => :not_found
94 render :nothing => true, :status => :internal_server_error
99 ids = params['nodes'].split(',').collect { |n| n.to_i }
102 doc = OSM::API.new.get_xml_doc
104 Node.find(ids).each do |node|
105 doc.root << node.to_xml_node
108 render :text => doc.to_s, :content_type => "text/xml"
110 render :nothing => true, :status => :bad_request