]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/api_controller.rb
Finish removing old request counting logic.
[rails.git] / app / controllers / api_controller.rb
index 0724a3712651cfd23e05fcd81c0fc38f24182be3..1af14845585ee6b39e387cf6a5ab7071c509625e 100644 (file)
@@ -1,15 +1,12 @@
 class ApiController < ApplicationController
 
   session :off
-  before_filter :check_read_availability, :except => [:capabilities]
+  before_filter :check_api_readable, :except => [:capabilities]
   after_filter :compress_output
 
   # Help methods for checking boundary sanity and area size
   include MapBoundary
 
-  #COUNT is the number of map requests to allow before exiting and starting a new process
-  @@count = COUNT
-
   # The maximum area you're allowed to request, in square degrees
   MAX_REQUEST_AREA = APP_CONFIG['max_request_area']
 
@@ -19,7 +16,6 @@ class ApiController < ApplicationController
   # Get an XML response containing a list of tracepoints that have been uploaded
   # within the specified bounding box, and in the specified page.
   def trackpoints
-    @@count+=1
     #retrieve the page number
     page = params['page'].to_i
     unless page
@@ -55,7 +51,7 @@ class ApiController < ApplicationController
     points = Tracepoint.find_by_area(min_lat, min_lon, max_lat, max_lon, :offset => offset, :limit => TRACEPOINTS_PER_PAGE, :order => "timestamp DESC" )
 
     doc = XML::Document.new
-    doc.encoding = 'UTF-8'
+    doc.encoding = XML::Encoding::UTF_8
     root = XML::Node.new 'gpx'
     root['version'] = '1.0'
     root['creator'] = 'OpenStreetMap.org'
@@ -73,13 +69,6 @@ class ApiController < ApplicationController
       trkseg << point.to_xml_node()
     end
 
-    #exit when we have too many requests
-    if @@count > MAX_COUNT
-      render :text => doc.to_s, :content_type => "text/xml"
-      @@count = COUNT
-      exit!
-    end
-
     response.headers["Content-Disposition"] = "attachment; filename=\"map.osm\""
 
     render :text => doc.to_s, :content_type => "text/xml"
@@ -95,8 +84,6 @@ class ApiController < ApplicationController
   # fetched. All the nodes and ways that are referenced by those ways are then 
   # fetched. Finally all the xml is returned.
   def map
-    GC.start
-    @@count+=1
     # Figure out the bbox
     bbox = params['bbox']
 
@@ -206,13 +193,6 @@ class ApiController < ApplicationController
     response.headers["Content-Disposition"] = "attachment; filename=\"map.osm\""
 
     render :text => doc.to_s, :content_type => "text/xml"
-    
-    #exit when we have too many requests
-    if @@count > MAX_COUNT
-      @@count = COUNT
-      
-      exit!
-    end
   end
 
   # Get a list of the tiles that have changed within a specified time
@@ -225,7 +205,7 @@ class ApiController < ApplicationController
       endtime = Time.parse(params[:end])
     else
       hours = (params[:hours] || '1').to_i.hours
-      endtime = Time.now
+      endtime = Time.now.getutc
       starttime = endtime - hours
     end
 
@@ -284,6 +264,9 @@ class ApiController < ApplicationController
     waynodes = XML::Node.new 'waynodes'
     waynodes['maximum'] = APP_CONFIG['max_number_of_way_nodes'].to_s
     api << waynodes
+    changesets = XML::Node.new 'changesets'
+    changesets['maximum_elements'] = Changeset::MAX_ELEMENTS.to_s
+    api << changesets
     
     doc.root << api