X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/91461927d44f68ad2dc10eccaaa2d3b9ce1d6f12..18453600aa5c208276c7d2f329952642924f4a75:/app/controllers/api_controller.rb diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index be00b9f9c..7e8017f4e 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -1,11 +1,8 @@ class ApiController < ApplicationController - before_filter :authorize + session :off after_filter :compress_output - helper :user - model :user - #COUNT is the number of map requests to allow before exiting and starting a new process @@count = COUNT @@ -18,7 +15,6 @@ class ApiController < ApplicationController def trackpoints @@count+=1 - response.headers["Content-Type"] = 'text/xml' #retrieve the page number page = params['page'].to_i unless page @@ -96,12 +92,12 @@ class ApiController < ApplicationController #exit when we have too many requests if @@count > MAX_COUNT - render :text => doc.to_s + render :text => doc.to_s, :content_type => "text/xml" @@count = COUNT exit! end - render :text => doc.to_s + render :text => doc.to_s, :content_type => "text/xml" end @@ -109,7 +105,6 @@ class ApiController < ApplicationController GC.start @@count+=1 - response.headers["Content-Type"] = 'text/xml' # Figure out the bbox bbox = params['bbox'] unless bbox and bbox.count(',') == 3 @@ -152,10 +147,11 @@ class ApiController < ApplicationController if node_ids.length > 50_000 report_error("You requested too many nodes (limit is 50,000). Either request a smaller area, or use planet.osm") + return end if node_ids.length == 0 - render :text => "" + render :text => "", :content_type => "text/xml" return end @@ -240,7 +236,7 @@ class ApiController < ApplicationController doc.root << way.to_xml_node(visible_segments, user_display_name_cache) if way.visible? end - render :text => doc.to_s + render :text => doc.to_s, :content_type => "text/xml" #exit when we have too many requests if @@count > MAX_COUNT @@ -248,6 +244,22 @@ class ApiController < ApplicationController exit! end + end + + def capabilities + doc = OSM::API.new.get_xml_doc + + api = XML::Node.new 'api' + version = XML::Node.new 'version' + version['minimum'] = '0.4'; + version['maximum'] = '0.4'; + api << version + area = XML::Node.new 'area' + area['maximum'] = MAX_REQUEST_AREA.to_s; + api << area + + doc.root << api + render :text => doc.to_s, :content_type => "text/xml" end end