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])
32 response.headers['Last-Modified'] = node.timestamp.rfc822
33 render :text => node.to_xml.to_s, :content_type => "text/xml"
35 render :text => "", :status => :gone
37 rescue ActiveRecord::RecordNotFound
38 render :nothing => true, :status => :not_found
44 node = Node.find(params[:id])
45 new_node = Node.from_xml(request.raw_post)
47 if new_node and new_node.id == node.id
48 node.user_id = @user.id
49 node.latitude = new_node.latitude
50 node.longitude = new_node.longitude
51 node.tags = new_node.tags
53 node.save_with_history!
55 render :nothing => true
57 render :nothing => true, :status => :bad_request
59 rescue ActiveRecord::RecordNotFound
60 render :nothing => true, :status => :not_found
66 node = Node.find(params[:id])
69 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 ])
70 render :text => "", :status => :precondition_failed
71 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]])
72 render :text => "", :status => :precondition_failed
74 node.user_id = @user.id
76 node.save_with_history!
78 render :nothing => true
81 render :text => "", :status => :gone
83 rescue ActiveRecord::RecordNotFound
84 render :nothing => true, :status => :not_found
89 ids = params['nodes'].split(',').collect { |n| n.to_i }
92 doc = OSM::API.new.get_xml_doc
94 Node.find(ids).each do |node|
95 doc.root << node.to_xml_node
98 render :text => doc.to_s, :content_type => "text/xml"
100 render :nothing => true, :status => :bad_request