]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/api_controller.rb
Fix the changeset feed to put the description in as raw HTML so we
[rails.git] / app / controllers / api_controller.rb
index ffc5852166f94b8bd8ec1b79cc2bdb0df8fb40f6..564f718993d2642433a7a44bbdfe7f4385f5f9a6 100644 (file)
@@ -1,18 +1,12 @@
 class ApiController < ApplicationController
 
-  session :off
   before_filter :check_api_readable, :except => [:capabilities]
   after_filter :compress_output
+  around_filter :api_call_handle_error, :api_call_timeout
 
   # Help methods for checking boundary sanity and area size
   include MapBoundary
 
-  # The maximum area you're allowed to request, in square degrees
-  MAX_REQUEST_AREA = APP_CONFIG['max_request_area']
-
-  # Number of GPS trace/trackpoints returned per-page
-  TRACEPOINTS_PER_PAGE = APP_CONFIG['tracepoints_per_page']
-
   # 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
@@ -27,7 +21,7 @@ class ApiController < ApplicationController
         return
     end
 
-    offset = page * TRACEPOINTS_PER_PAGE
+    offset = page * APP_CONFIG['tracepoints_per_page']
 
     # Figure out the bbox
     bbox = params['bbox']
@@ -48,7 +42,7 @@ class ApiController < ApplicationController
     end
 
     # get all the points
-    points = Tracepoint.find_by_area(min_lat, min_lon, max_lat, max_lon, :offset => offset, :limit => TRACEPOINTS_PER_PAGE, :order => "timestamp DESC" )
+    points = Tracepoint.find_by_area(min_lat, min_lon, max_lat, max_lon, :offset => offset, :limit => APP_CONFIG['tracepoints_per_page'], :order => "timestamp DESC" )
 
     doc = XML::Document.new
     doc.encoding = XML::Encoding::UTF_8
@@ -188,7 +182,7 @@ class ApiController < ApplicationController
     # this "uniq" may be slightly inefficient; it may be better to first collect and output
     # all node-related relations, then find the *not yet covered* way-related ones etc.
     relations.uniq.each do |relation|
-      doc.root << relation.to_xml_node(changeset_cache, user_display_name_cache)
+      doc.root << relation.to_xml_node(nil, changeset_cache, user_display_name_cache)
     end
 
     response.headers["Content-Disposition"] = "attachment; filename=\"map.osm\""
@@ -257,7 +251,7 @@ class ApiController < ApplicationController
     version['maximum'] = "#{API_VERSION}";
     api << version
     area = XML::Node.new 'area'
-    area['maximum'] = MAX_REQUEST_AREA.to_s;
+    area['maximum'] = APP_CONFIG['max_request_area'].to_s;
     api << area
     tracepoints = XML::Node.new 'tracepoints'
     tracepoints['per_page'] = APP_CONFIG['tracepoints_per_page'].to_s
@@ -268,6 +262,9 @@ class ApiController < ApplicationController
     changesets = XML::Node.new 'changesets'
     changesets['maximum_elements'] = Changeset::MAX_ELEMENTS.to_s
     api << changesets
+    timeout = XML::Node.new 'timeout'
+    timeout['seconds'] = APP_CONFIG['api_timeout'].to_s
+    api << timeout
     
     doc.root << api