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
17 if node.save_with_history
18 render :text => node.id.to_s, :content_type => "text/plain"
20 render :nothing => true, :status => :internal_server_error
23 render :nothing => true, :status => :bad_request
26 render :nothing => true, :status => :method_not_allowed
32 node = Node.find(params[:id])
35 render :text => node.to_xml.to_s, :content_type => "text/xml"
37 render :nothing => true, :status => :gone
39 rescue ActiveRecord::RecordNotFound
40 render :nothing => true, :status => :not_found
42 render :nothing => true, :status => :internal_server_error
48 node = Node.find(params[:id])
51 new_node = Node.from_xml(request.raw_post)
53 if new_node and new_node.id == node.id
54 node.user_id = @user.id
55 node.latitude = new_node.latitude
56 node.longitude = new_node.longitude
57 node.tags = new_node.tags
59 if node.save_with_history
60 render :nothing => true
62 render :nothing => true, :status => :internal_server_error
65 render :nothing => true, :status => :bad_request
68 render :nothing => true, :status => :gone
70 rescue ActiveRecord::RecordNotFound
71 render :nothing => true, :status => :not_found
73 render :nothing => true, :status => :internal_server_error
79 node = Node.find(params[:id])
82 if WayNode.find(:first, :joins => "INNER JOIN current_ways ON current_ways.id = current_way_nodes.id", :conditions => [ "current_ways.visible = 1 AND current_way_nodes.node_id = ?", node.id ])
83 render :nothing => true, :status => :precondition_failed
84 elsif RelationMember.find(:first, :joins => "INNER JOIN current_relations ON current_relations.id=current_relation_members.id", :conditions => [ "visible = 1 AND member_type='node' and member_id=?", params[:id]])
85 render :nothing => true, :status => :precondition_failed
87 node.user_id = @user.id
89 node.save_with_history
90 render :nothing => true
93 render :nothing => true, :status => :gone
95 rescue ActiveRecord::RecordNotFound
96 render :nothing => true, :status => :not_found
98 render :nothing => true, :status => :internal_server_error
103 ids = params['nodes'].split(',').collect { |n| n.to_i }
106 doc = OSM::API.new.get_xml_doc
108 Node.find(ids).each do |node|
109 doc.root << node.to_xml_node
112 render :text => doc.to_s, :content_type => "text/xml"
114 render :nothing => true, :status => :bad_request