tracepoints = XML::Node.new 'tracepoints'
tracepoints['per_page'] = APP_CONFIG['tracepoints_per_page'].to_s
api << tracepoints
+ waynodes = XML::Node.new 'waynodes'
+ waynodes['maximum'] = APP_CONFIG['max_number_of_way_nodes'].to_s
+ api << waynodes
doc.root << api
def preconditions_ok?
return false if self.nds.empty?
+ if self.nds.length > APP_CONFIG['max_number_of_way_nodes']
+ raise OSM::APITooManyWayNodesError.new(self.nds.count, APP_CONFIG['max_number_of_way_nodes'])
+ end
self.nds.each do |n|
node = Node.find(:first, :conditions => ["id = ?", n])
unless node and node.visible
max_request_area: 0.25
# Number of GPS trace/trackpoints returned per-page
tracepoints_per_page: 5000
- # Maximum number of nodes
+ # Maximum number of nodes that will be returned by the api in a map request
max_number_of_nodes: 50000
+ # Maximum number of nodes that can be in a way (checked on save)
+ max_number_of_way_nodes: 2000
development:
<<: *standard_settings
:status => :bad_request }
end
end
+
+ # Raised when a way has more than the configured number of way nodes.
+ # This prevents ways from being to long and difficult to work with
+ class APITooManyWayNodesError < APIError
+ def initialize(provided, max)
+ @provided, @max = provided, max
+ end
+
+ attr_reader :provided, :max
+
+ def render_opts
+ { :text => "You tried to add #{provided} nodes to the way, however only #{max} are allowed",
+ :status => :bad_request }
+ end
+ end
# Helper methods for going to/from mercator and lat/lng.
class Mercator