2 class WaysController < ApiController
3 before_action :check_api_writable, :only => [:create, :update, :destroy]
4 before_action :authorize, :only => [:create, :update, :destroy]
8 before_action :require_public_data, :only => [:create, :update, :destroy]
9 before_action :set_request_formats, :except => [:create, :update, :destroy]
10 before_action :check_rate_limit, :only => [:create, :update, :destroy]
13 raise OSM::APIBadUserInput, "The parameter ways is required, and must be of the form ways=id[,id[,id...]]" unless params["ways"]
15 ids = params["ways"].split(",").collect(&:to_i)
17 raise OSM::APIBadUserInput, "No ways were given to search for" if ids.empty?
19 @ways = Way.includes(:nodes, :element_tags).find(ids)
22 respond_to do |format|
30 @way = @way.includes(:nodes, :element_tags)
31 @way = @way.includes(:nodes => :element_tags) if params[:full]
32 @way = @way.find(params[:id])
34 response.last_modified = @way.timestamp unless params[:full]
40 @way.nodes.uniq.each do |node|
41 @nodes << node if node.visible
45 respond_to do |format|
55 way = Way.from_xml(request.raw_post, :create => true)
57 # Assume that Way.from_xml has thrown an exception if there is an error parsing the xml
58 way.create_with_history current_user
59 render :plain => way.id.to_s
63 way = Way.find(params[:id])
64 new_way = Way.from_xml(request.raw_post)
66 raise OSM::APIBadUserInput, "The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})" unless new_way && new_way.id == way.id
68 way.update_from(new_way, current_user)
69 render :plain => way.version.to_s
72 # This is the API call to delete a way
74 way = Way.find(params[:id])
75 new_way = Way.from_xml(request.raw_post)
77 if new_way && new_way.id == way.id
78 way.delete_with_history!(new_way, current_user)
79 render :plain => way.version.to_s