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:
Patrick Niklaus
2015-12-17 04:14:06 +01:00
parent 7eb2af6cd3
commit 78ac3cffde
16 changed files with 283 additions and 238 deletions
+2 -12
View File
@@ -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