1 class WayController < ApplicationController
5 before_filter :authorize, :only => [:create, :update, :delete]
6 before_filter :check_availability, :only => [:create, :update, :delete]
7 after_filter :compress_output
11 way = Way.from_xml(request.raw_post, true)
14 if !way.preconditions_ok?
15 render :nothing => true, :status => :precondition_failed
17 way.user_id = @user.id
19 if way.save_with_history
20 render :text => way.id.to_s, :content_type => "text/plain"
22 render :nothing => true, :status => :internal_server_error
26 render :nothing => true, :status => :bad_request
29 render :nothing => true, :status => :method_not_allowed
35 way = Way.find(params[:id])
38 render :text => way.to_xml.to_s, :content_type => "text/xml"
40 render :nothing => true, :status => :gone
42 rescue ActiveRecord::RecordNotFound
43 render :nothing => true, :status => :not_found
45 render :nothing => true, :status => :internal_server_error
51 way = Way.find(params[:id])
54 new_way = Way.from_xml(request.raw_post)
56 if new_way and new_way.id == way.id
57 if !new_way.preconditions_ok?
58 render :nothing => true, :status => :precondition_failed
60 way.user_id = @user.id
61 way.tags = new_way.tags
65 if way.save_with_history
66 render :nothing => true
68 render :nothing => true, :status => :internal_server_error
72 render :nothing => true, :status => :bad_request
75 render :nothing => true, :status => :gone
77 rescue ActiveRecord::RecordNotFound
78 render :nothing => true, :status => :not_found
80 render :nothing => true, :status => :internal_server_error
86 way = Way.find(params[:id])
89 if RelationMember.find(:first, :joins => "INNER JOIN current_relations ON current_relations.id=current_relation_members.id", :conditions => [ "visible = 1 AND member_type='way' and member_id=?", params[:id]])
90 render :nothing => true, :status => :precondition_failed
92 way.user_id = @user.id
97 if way.save_with_history
98 render :nothing => true
100 render :nothing => true, :status => :internal_server_error
104 render :nothing => true, :status => :gone
106 rescue ActiveRecord::RecordNotFound
107 render :nothing => true, :status => :not_found
109 render :nothing => true, :status => :internal_server_error
115 way = Way.find(params[:id])
118 nd_ids = way.nds + [-1]
119 nodes = Node.find(:all, :conditions => "visible = 1 AND id IN (#{nd_ids.join(',')})")
122 doc = OSM::API.new.get_xml_doc
124 doc.root << node.to_xml_node()
126 doc.root << way.to_xml_node()
128 render :text => doc.to_s, :content_type => "text/xml"
130 render :nothing => true, :status => :gone
132 rescue ActiveRecord::RecordNotFound
133 render :nothing => true, :status => :not_found
135 render :nothing => true, :status => :internal_server_error
141 ids = params['ways'].split(',').collect { |w| w.to_i }
147 doc = OSM::API.new.get_xml_doc
149 Way.find(ids).each do |way|
150 doc.root << way.to_xml_node
153 render :text => doc.to_s, :content_type => "text/xml"
155 render :nothing => true, :status => :bad_request
160 wayids = WayNode.find(:all, :conditions => ['node_id = ?', params[:id]]).collect { |ws| ws.id }.uniq
163 doc = OSM::API.new.get_xml_doc
165 Way.find(wayids).each do |way|
166 doc.root << way.to_xml_node
169 render :text => doc.to_s, :content_type => "text/xml"
171 render :nothing => true, :status => :bad_request