- 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
-
- # 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
- #retrieve the page number
- page = params['page'].to_i
- unless page
- page = 0;
- end
-
- unless page >= 0
- report_error("Page number must be greater than or equal to 0")
- return
- end
-
- offset = page * APP_CONFIG['tracepoints_per_page']
-
- # Figure out the bbox
- bbox = params['bbox']
- unless bbox and bbox.count(',') == 3
- report_error("The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat")
- return
- end
-
- bbox = bbox.split(',')
- min_lon, min_lat, max_lon, max_lat = sanitise_boundaries(bbox)
- # check boundary is sane and area within defined
- # see /config/application.yml
- begin
- check_boundaries(min_lon, min_lat, max_lon, max_lat)
- rescue Exception => err
- report_error(err.message)
- return
- end
-
- # get all the points
- 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
- root = XML::Node.new 'gpx'
- root['version'] = '1.0'
- root['creator'] = 'OpenStreetMap.org'
- root['xmlns'] = "http://www.topografix.com/GPX/1/0/"
-
- doc.root = root
-
- track = XML::Node.new 'trk'
- doc.root << track
-
- trkseg = XML::Node.new 'trkseg'
- track << trkseg
-
- points.each do |point|
- trkseg << point.to_xml_node()