Merge completed
This commit is contained in:
commit
91baa9dfd7
@ -3,31 +3,36 @@ Feature: Bike - Max speed restrictions
|
|||||||
|
|
||||||
Background: Use specific speeds
|
Background: Use specific speeds
|
||||||
Given the profile "bicycle"
|
Given the profile "bicycle"
|
||||||
|
|
||||||
Scenario: Bike - Respect maxspeeds when lower that way type speed
|
|
||||||
Given the node map
|
|
||||||
| a | b | c |
|
|
||||||
|
|
||||||
And the ways
|
Scenario: Bicycle - Respect maxspeeds when lower that way type speed
|
||||||
| nodes | highway | maxspeed |
|
Then routability should be
|
||||||
| ab | residential | |
|
| highway | maxspeed | bothw |
|
||||||
| bc | residential | 10 |
|
| residential | | 40s ~10% |
|
||||||
|
| residential | 10 | 72s ~10% |
|
||||||
|
|
||||||
When I route I should get
|
Scenario: Bicycle - Ignore maxspeed when higher than way speed
|
||||||
| from | to | route | time |
|
Then routability should be
|
||||||
| a | b | ab | 20s ~5% |
|
| highway | maxspeed | bothw |
|
||||||
| b | c | bc | 36s ~5% |
|
| residential | | 40s ~10% |
|
||||||
|
| residential | 80 | 40s ~10% |
|
||||||
|
|
||||||
|
@todo
|
||||||
|
Scenario: Bicycle - Maxspeed formats
|
||||||
|
Then routability should be
|
||||||
|
| highway | maxspeed | bothw |
|
||||||
|
| residential | | 40s ~10% |
|
||||||
|
| residential | 5 | 144s ~10% |
|
||||||
|
| residential | 5mph | 90s ~10% |
|
||||||
|
| residential | 5 mph | 90s ~10% |
|
||||||
|
| residential | 5MPH | 90s ~10% |
|
||||||
|
| residential | 5 MPH | 90s ~10% |
|
||||||
|
| trunk | 5unknown | 40s ~10% |
|
||||||
|
| trunk | 5 unknown | 40s ~10% |
|
||||||
|
|
||||||
Scenario: Bike - Do not use maxspeed when higher that way type speed
|
@todo
|
||||||
Given the node map
|
Scenario: Bicycle - Maxspeed special tags
|
||||||
| a | b | c |
|
Then routability should be
|
||||||
|
| highway | maxspeed | bothw |
|
||||||
And the ways
|
| residential | | 40s ~10% |
|
||||||
| nodes | highway | maxspeed |
|
| residential | none | 40s ~10% |
|
||||||
| ab | residential | |
|
| residential | signals | 40s ~10% |
|
||||||
| bc | residential | 80 |
|
|
||||||
|
|
||||||
When I route I should get
|
|
||||||
| from | to | route | time |
|
|
||||||
| a | b | ab | 20s ~5% |
|
|
||||||
| b | c | bc | 20s ~5% |
|
|
||||||
|
20
features/foot/maxspeed.feature
Normal file
20
features/foot/maxspeed.feature
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
@routing @maxspeed @foot
|
||||||
|
Feature: Foot - Ignore max speed restrictions
|
||||||
|
|
||||||
|
Background: Use specific speeds
|
||||||
|
Given the profile "foot"
|
||||||
|
|
||||||
|
@todo
|
||||||
|
Scenario: Foot - Ignore maxspeed
|
||||||
|
Then routability should be
|
||||||
|
| highway | maxspeed | bothw |
|
||||||
|
| residential | | 145s ~10% |
|
||||||
|
| residential | 1 | 145s ~10% |
|
||||||
|
| residential | 100 | 145s ~10% |
|
||||||
|
| residential | 1 | 145s ~10% |
|
||||||
|
| residential | 1mph | 145s ~10% |
|
||||||
|
| residential | 1 mph | 145s ~10% |
|
||||||
|
| residential | 1unknown | 145s ~10% |
|
||||||
|
| residential | 1 unknown | 145s ~10% |
|
||||||
|
| residential | none | 145s ~10% |
|
||||||
|
| residential | signals | 145s ~10% |
|
@ -6,6 +6,12 @@ Given /^a grid size of (\d+) meters$/ do |meters|
|
|||||||
set_grid_size meters
|
set_grid_size meters
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Given /^the shortcuts$/ do |table|
|
||||||
|
table.hashes.each do |row|
|
||||||
|
shortcuts_hash[ row['key'] ] = row['value']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Given /^the node map$/ do |table|
|
Given /^the node map$/ do |table|
|
||||||
table.raw.each_with_index do |row,ri|
|
table.raw.each_with_index do |row,ri|
|
||||||
row.each_with_index do |name,ci|
|
row.each_with_index do |name,ci|
|
||||||
|
@ -16,18 +16,21 @@ Then /^routability should be$/ do |table|
|
|||||||
elsif direction == 'backw' || direction == 'bothw'
|
elsif direction == 'backw' || direction == 'bothw'
|
||||||
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}")
|
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}")
|
||||||
end
|
end
|
||||||
|
want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts
|
||||||
got[direction] = route_status response
|
got[direction] = route_status response
|
||||||
json = JSON.parse(response.body)
|
json = JSON.parse(response.body)
|
||||||
if got[direction].empty? == false
|
if got[direction].empty? == false
|
||||||
route = way_list json['route_instructions']
|
route = way_list json['route_instructions']
|
||||||
if route != "w#{i}"
|
if route != "w#{i}"
|
||||||
got[direction] = "testing w#{i}, but got #{route}!?"
|
got[direction] = "testing w#{i}, but got #{route}!?"
|
||||||
elsif row[direction] =~ /\d+s/
|
elsif want =~ /^\d+s/
|
||||||
time = json['route_summary']['total_time']
|
time = json['route_summary']['total_time']
|
||||||
got[direction] = "#{time}s"
|
got[direction] = "#{time}s"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if got[direction] != row[direction]
|
if FuzzyMatch.match got[direction], want
|
||||||
|
got[direction] = row[direction]
|
||||||
|
else
|
||||||
attempts << { :attempt => direction, :query => @query, :response => response }
|
attempts << { :attempt => direction, :query => @query, :response => response }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -50,30 +50,10 @@ When /^I route I should get$/ do |table|
|
|||||||
|
|
||||||
ok = true
|
ok = true
|
||||||
row.keys.each do |key|
|
row.keys.each do |key|
|
||||||
if row[key].match /(.*)\s+~(.+)%$/ #percentage range: 100 ~5%
|
if FuzzyMatch.match got[key], row[key]
|
||||||
margin = 1 - $2.to_f*0.01
|
got[key] = row[key]
|
||||||
from = $1.to_f*margin
|
|
||||||
to = $1.to_f/margin
|
|
||||||
if got[key].to_f >= from && got[key].to_f <= to
|
|
||||||
got[key] = row[key]
|
|
||||||
else
|
|
||||||
ok = false
|
|
||||||
end
|
|
||||||
elsif row[key].match /(.*)\s+\+\-(.+)$/ #absolute range: 100 +-5
|
|
||||||
margin = $2.to_f
|
|
||||||
from = $1.to_f-margin
|
|
||||||
to = $1.to_f+margin
|
|
||||||
if got[key].to_f >= from && got[key].to_f <= to
|
|
||||||
got[key] = row[key]
|
|
||||||
else
|
|
||||||
ok = false
|
|
||||||
end
|
|
||||||
elsif row[key] =~ /^\/(.*)\/$/ #regex: /a,b,.*/
|
|
||||||
if got[key] =~ /#{$1}/
|
|
||||||
got[key] = row[key]
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
ok = row[key] == got[key]
|
ok = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,8 +71,14 @@ def build_ways_from_table table
|
|||||||
way << node5
|
way << node5
|
||||||
|
|
||||||
tags = row.dup
|
tags = row.dup
|
||||||
tags.delete 'forw'
|
#remove tags that describe expected test result
|
||||||
tags.delete 'backw'
|
tags.reject! do |k,v|
|
||||||
|
k =~ /^forw\b/ ||
|
||||||
|
k =~ /^backw\b/ ||
|
||||||
|
k =~ /^bothw\b/
|
||||||
|
end
|
||||||
|
|
||||||
|
#remove empty tags
|
||||||
tags.reject! { |k,v| v=='' }
|
tags.reject! { |k,v| v=='' }
|
||||||
|
|
||||||
# sort tag keys in the form of 'node/....'
|
# sort tag keys in the form of 'node/....'
|
||||||
|
@ -28,5 +28,3 @@ class FuzzyMatch
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
3
features/support/shortcuts.rb
Normal file
3
features/support/shortcuts.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
def shortcuts_hash
|
||||||
|
@shortcuts_hash ||= {}
|
||||||
|
end
|
@ -152,10 +152,7 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
|
|
||||||
-- Set the avg speed on the way if it is accessible by road class
|
-- Set the avg speed on the way if it is accessible by road class
|
||||||
if (speed_profile[highway] ~= nil and way.speed == -1 ) then
|
if (speed_profile[highway] ~= nil and way.speed == -1 ) then
|
||||||
if (0 < maxspeed and not take_minimum_of_speeds) or (maxspeed == 0) then
|
way.speed = speed_profile[highway]
|
||||||
maxspeed = math.huge
|
|
||||||
end
|
|
||||||
way.speed = math.min(speed_profile[highway], maxspeed)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set the avg speed on ways that are marked accessible
|
-- Set the avg speed on ways that are marked accessible
|
||||||
|
Loading…
Reference in New Issue
Block a user