1 class NodeController < ApplicationController
5 before_filter :authorize, :only => [:create, :update, :delete]
6 before_filter :check_write_availability, :only => [:create, :update, :delete]
7 before_filter :check_read_availability, :except => [:create, :update, :delete]
8 after_filter :compress_output
12 node = Node.from_xml(request.raw_post, true)
15 node.user_id = @user.id
17 node.save_with_history!
19 render :text => node.id.to_s, :content_type => "text/plain"
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
44 node = Node.find(params[:id])
47 new_node = Node.from_xml(request.raw_post)
49 if new_node and new_node.id == node.id
50 node.user_id = @user.id
51 node.latitude = new_node.latitude
52 node.longitude = new_node.longitude
53 node.tags = new_node.tags
54 node.save_with_history!
56 render :nothing => true
58 render :nothing => true, :status => :bad_request
61 render :nothing => true, :status => :gone
63 rescue ActiveRecord::RecordNotFound
64 render :nothing => true, :status => :not_found
70 node = Node.find(params[:id])
73 if Segment.find(:first, :conditions => [ "visible = 1 and (node_a = ? or node_b = ?)", node.id, node.id])
74 render :nothing => true, :status => :precondition_failed
76 node.user_id = @user.id
78 node.save_with_history!
80 render :nothing => true
83 render :nothing => true, :status => :gone
85 rescue ActiveRecord::RecordNotFound
86 render :nothing => true, :status => :not_found
91 ids = params['nodes'].split(',').collect { |n| n.to_i }
94 doc = OSM::API.new.get_xml_doc
96 Node.find(ids).each do |node|
97 doc.root << node.to_xml_node
100 render :text => doc.to_s, :content_type => "text/xml"
102 render :nothing => true, :status => :bad_request