Add max values for viaroute and trip and reorganize return code handling
"status" is now always: - 200 if the request was successful - 207 if the result is empty (no path found) - 400 if the request is invalid viaroute and trip now have a maximum of 500 and 100 locations respectively. Override with the --max-viaroute-size and --max-trip-size parameters.
This commit is contained in:
@@ -25,9 +25,11 @@ Feature: osrm-routed command line options: help
|
||||
And stdout should contain "--port"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--shared-memory"
|
||||
And stdout should contain "--max-viaroute-size"
|
||||
And stdout should contain "--max-trip-size"
|
||||
And stdout should contain "--max-table-size"
|
||||
And stdout should contain "--max-matching-size"
|
||||
And stdout should contain 27 lines
|
||||
And stdout should contain 30 lines
|
||||
And it should exit with code 0
|
||||
|
||||
Scenario: osrm-routed - Help, short
|
||||
@@ -51,9 +53,11 @@ Feature: osrm-routed command line options: help
|
||||
And stdout should contain "--port"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--shared-memory"
|
||||
And stdout should contain "--max-viaroute-size"
|
||||
And stdout should contain "--max-trip-size"
|
||||
And stdout should contain "--max-table-size"
|
||||
And stdout should contain "--max-matching-size"
|
||||
And stdout should contain 27 lines
|
||||
And stdout should contain 30 lines
|
||||
And it should exit with code 0
|
||||
|
||||
Scenario: osrm-routed - Help, long
|
||||
@@ -77,7 +81,9 @@ Feature: osrm-routed command line options: help
|
||||
And stdout should contain "--port"
|
||||
And stdout should contain "--threads"
|
||||
And stdout should contain "--shared-memory"
|
||||
And stdout should contain "--max-trip-size"
|
||||
And stdout should contain "--max-table-size"
|
||||
And stdout should contain "--max-table-size"
|
||||
And stdout should contain "--max-matching-size"
|
||||
And stdout should contain 27 lines
|
||||
And stdout should contain 30 lines
|
||||
And it should exit with code 0
|
||||
|
||||
@@ -12,7 +12,7 @@ When /^I request nearest I should get$/ do |table|
|
||||
response = request_nearest in_node, @query_params
|
||||
if response.code == "200" && response.body.empty? == false
|
||||
json = JSON.parse response.body
|
||||
if json['status'] == 0
|
||||
if json['status'] == 200
|
||||
coord = json['mapped_coordinate']
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,8 +8,8 @@ def test_routability_row i
|
||||
r[:query] = @query
|
||||
r[:json] = JSON.parse(r[:response].body)
|
||||
|
||||
r[:status] = route_status r[:response]
|
||||
if r[:status].empty? == false
|
||||
r[:status] = (route_status r[:response]) == 200 ? 'x' : nil
|
||||
if r[:status] then
|
||||
r[:route] = way_list r[:json]['route_instructions']
|
||||
|
||||
if r[:route]=="w#{i}"
|
||||
|
||||
@@ -56,7 +56,7 @@ When /^I route I should get$/ do |table|
|
||||
end
|
||||
|
||||
if response.body.empty? == false
|
||||
if json['status'] == 0
|
||||
if json['status'] == 200
|
||||
instructions = way_list json['route_instructions']
|
||||
bearings = bearing_list json['route_instructions']
|
||||
compasses = compass_list json['route_instructions']
|
||||
@@ -77,66 +77,64 @@ When /^I route I should get$/ do |table|
|
||||
got['#'] = row['#'] # copy value so it always match
|
||||
end
|
||||
|
||||
if response.code == "200"
|
||||
if table.headers.include? 'start'
|
||||
got['start'] = instructions ? json['route_summary']['start_point'] : nil
|
||||
end
|
||||
if table.headers.include? 'end'
|
||||
got['end'] = instructions ? json['route_summary']['end_point'] : nil
|
||||
end
|
||||
if table.headers.include? 'geometry'
|
||||
got['geometry'] = json['route_geometry']
|
||||
end
|
||||
if table.headers.include? 'route'
|
||||
got['route'] = (instructions || '').strip
|
||||
if table.headers.include?('alternative')
|
||||
got['alternative'] =
|
||||
if json['found_alternative']
|
||||
way_list json['alternative_instructions'].first
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
if table.headers.include?('distance')
|
||||
if row['distance']!=''
|
||||
raise "*** Distance must be specied in meters. (ex: 250m)" unless row['distance'] =~ /\d+m/
|
||||
end
|
||||
got['distance'] = instructions ? "#{json['route_summary']['total_distance'].to_s}m" : ''
|
||||
end
|
||||
if table.headers.include?('time')
|
||||
raise "*** Time must be specied in seconds. (ex: 60s)" unless row['time'] =~ /\d+s/
|
||||
got['time'] = instructions ? "#{json['route_summary']['total_time'].to_s}s" : ''
|
||||
end
|
||||
if table.headers.include?('speed')
|
||||
if row['speed'] != '' && instructions
|
||||
raise "*** Speed must be specied in km/h. (ex: 50 km/h)" unless row['speed'] =~ /\d+ km\/h/
|
||||
time = json['route_summary']['total_time']
|
||||
distance = json['route_summary']['total_distance']
|
||||
speed = time>0 ? (3.6*distance/time).round : nil
|
||||
got['speed'] = "#{speed} km/h"
|
||||
if table.headers.include? 'start'
|
||||
got['start'] = instructions ? json['route_summary']['start_point'] : nil
|
||||
end
|
||||
if table.headers.include? 'end'
|
||||
got['end'] = instructions ? json['route_summary']['end_point'] : nil
|
||||
end
|
||||
if table.headers.include? 'geometry'
|
||||
got['geometry'] = json['route_geometry']
|
||||
end
|
||||
if table.headers.include? 'route'
|
||||
got['route'] = (instructions || '').strip
|
||||
if table.headers.include?('alternative')
|
||||
got['alternative'] =
|
||||
if json['found_alternative']
|
||||
way_list json['alternative_instructions'].first
|
||||
else
|
||||
got['speed'] = ''
|
||||
""
|
||||
end
|
||||
end
|
||||
if table.headers.include?('distance')
|
||||
if row['distance']!=''
|
||||
raise "*** Distance must be specied in meters. (ex: 250m)" unless row['distance'] =~ /\d+m/
|
||||
end
|
||||
if table.headers.include? 'bearing'
|
||||
got['bearing'] = instructions ? bearings : ''
|
||||
end
|
||||
if table.headers.include? 'compass'
|
||||
got['compass'] = instructions ? compasses : ''
|
||||
end
|
||||
if table.headers.include? 'turns'
|
||||
got['turns'] = instructions ? turns : ''
|
||||
end
|
||||
if table.headers.include? 'modes'
|
||||
got['modes'] = instructions ? modes : ''
|
||||
end
|
||||
if table.headers.include? 'times'
|
||||
got['times'] = instructions ? times : ''
|
||||
end
|
||||
if table.headers.include? 'distances'
|
||||
got['distances'] = instructions ? distances : ''
|
||||
got['distance'] = instructions ? "#{json['route_summary']['total_distance'].to_s}m" : ''
|
||||
end
|
||||
if table.headers.include?('time')
|
||||
raise "*** Time must be specied in seconds. (ex: 60s)" unless row['time'] =~ /\d+s/
|
||||
got['time'] = instructions ? "#{json['route_summary']['total_time'].to_s}s" : ''
|
||||
end
|
||||
if table.headers.include?('speed')
|
||||
if row['speed'] != '' && instructions
|
||||
raise "*** Speed must be specied in km/h. (ex: 50 km/h)" unless row['speed'] =~ /\d+ km\/h/
|
||||
time = json['route_summary']['total_time']
|
||||
distance = json['route_summary']['total_distance']
|
||||
speed = time>0 ? (3.6*distance/time).round : nil
|
||||
got['speed'] = "#{speed} km/h"
|
||||
else
|
||||
got['speed'] = ''
|
||||
end
|
||||
end
|
||||
if table.headers.include? 'bearing'
|
||||
got['bearing'] = instructions ? bearings : ''
|
||||
end
|
||||
if table.headers.include? 'compass'
|
||||
got['compass'] = instructions ? compasses : ''
|
||||
end
|
||||
if table.headers.include? 'turns'
|
||||
got['turns'] = instructions ? turns : ''
|
||||
end
|
||||
if table.headers.include? 'modes'
|
||||
got['modes'] = instructions ? modes : ''
|
||||
end
|
||||
if table.headers.include? 'times'
|
||||
got['times'] = instructions ? times : ''
|
||||
end
|
||||
if table.headers.include? 'distances'
|
||||
got['distances'] = instructions ? distances : ''
|
||||
end
|
||||
end
|
||||
|
||||
ok = true
|
||||
|
||||
@@ -99,7 +99,7 @@ end
|
||||
def got_route? response
|
||||
if response.code == "200" && !response.body.empty?
|
||||
json = JSON.parse response.body
|
||||
if json['status'] == 0
|
||||
if json['status'] == 200
|
||||
return way_list( json['route_instructions']).empty? == false
|
||||
end
|
||||
end
|
||||
@@ -109,17 +109,7 @@ end
|
||||
def route_status response
|
||||
if response.code == "200" && !response.body.empty?
|
||||
json = JSON.parse response.body
|
||||
if json['status'] == 0
|
||||
if way_list(json['route_instructions']).empty?
|
||||
return 'Empty route'
|
||||
else
|
||||
return 'x'
|
||||
end
|
||||
elsif json['status'] == 207
|
||||
''
|
||||
else
|
||||
"Status #{json['status']}"
|
||||
end
|
||||
return json['status']
|
||||
else
|
||||
"HTTP #{response.code}"
|
||||
end
|
||||
|
||||
@@ -14,8 +14,8 @@ Feature: Status messages
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | status | message |
|
||||
| a | b | ab | 0 | Found route between points |
|
||||
| b | a | ab | 0 | Found route between points |
|
||||
| a | b | ab | 200 | Found route between points |
|
||||
| b | a | ab | 200 | Found route between points |
|
||||
|
||||
Scenario: No route found
|
||||
Given the node map
|
||||
@@ -30,8 +30,8 @@ Feature: Status messages
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | status | message |
|
||||
| a | b | ab | 0 | Found route between points |
|
||||
| c | d | cd | 0 | Found route between points |
|
||||
| a | b | ab | 200 | Found route between points |
|
||||
| c | d | cd | 200 | Found route between points |
|
||||
| a | c | | 207 | Impossible route between points. |
|
||||
| b | d | | 207 | Impossible route between points. |
|
||||
|
||||
@@ -46,22 +46,22 @@ Feature: Status messages
|
||||
| ab |
|
||||
|
||||
When I route I should get
|
||||
| request | status | message |
|
||||
| viaroute?loc=1,1&loc=1.01,1 | 0 | Found route between points |
|
||||
| nonsense | 400 | Bad Request |
|
||||
| nonsense?loc=1,1&loc=1.01,1 | 400 | Bad Request |
|
||||
| | 400 | Query string malformed close to position 0 |
|
||||
| / | 400 | Query string malformed close to position 0 |
|
||||
| ? | 400 | Query string malformed close to position 0 |
|
||||
| viaroute/loc= | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=1 | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=1,1 | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=1,1,1 | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=x | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=x,y | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=1,1&loc= | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=1,1&loc=1 | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=1,1&loc=1,1 | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=1,1&loc=1,1,1 | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=1,1&loc=x | 400 | Query string malformed close to position 9 |
|
||||
| viaroute/loc=1,1&loc=x,y | 400 | Query string malformed close to position 9 |
|
||||
| request | status | message |
|
||||
| viaroute?loc=1,1&loc=1.01,1 | 200 | Found route between points |
|
||||
| nonsense | 400 | Service not found |
|
||||
| nonsense?loc=1,1&loc=1.01,1 | 400 | Service not found |
|
||||
| | 400 | Query string malformed close to position 0 |
|
||||
| / | 400 | Query string malformed close to position 0 |
|
||||
| ? | 400 | Query string malformed close to position 0 |
|
||||
| viaroute?loc= | 400 | Query string malformed close to position 9 |
|
||||
| viaroute?loc=1 | 400 | Query string malformed close to position 9 |
|
||||
| viaroute?loc=1,1 | 400 | Invalid coordinates. |
|
||||
| viaroute?loc=1,1,1 | 400 | Query string malformed close to position 17 |
|
||||
| viaroute?loc=x | 400 | Query string malformed close to position 9 |
|
||||
| viaroute?loc=x,y | 400 | Query string malformed close to position 9 |
|
||||
| viaroute?loc=1,1&loc= | 400 | Query string malformed close to position 17 |
|
||||
| viaroute?loc=1,1&loc=1 | 400 | Query string malformed close to position 17 |
|
||||
| viaroute?loc=1,1&loc=1,1 | 200 | Found route between points |
|
||||
| viaroute?loc=1,1&loc=1,1,1 | 400 | Query string malformed close to position 25 |
|
||||
| viaroute?loc=1,1&loc=x | 400 | Query string malformed close to position 17 |
|
||||
| viaroute?loc=1,1&loc=x,y | 400 | Query string malformed close to position 17 |
|
||||
|
||||
Reference in New Issue
Block a user