Merge completed

This commit is contained in:
DennisOSRM 2013-02-04 13:05:05 +01:00
commit 91baa9dfd7
9 changed files with 76 additions and 58 deletions

View File

@ -3,31 +3,36 @@ Feature: Bike - Max speed restrictions
Background: Use specific speeds
Given the profile "bicycle"
Scenario: Bike - Respect maxspeeds when lower that way type speed
Given the node map
| a | b | c |
And the ways
| nodes | highway | maxspeed |
| ab | residential | |
| bc | residential | 10 |
Scenario: Bicycle - Respect maxspeeds when lower that way type speed
Then routability should be
| highway | maxspeed | bothw |
| residential | | 40s ~10% |
| residential | 10 | 72s ~10% |
When I route I should get
| from | to | route | time |
| a | b | ab | 20s ~5% |
| b | c | bc | 36s ~5% |
Scenario: Bicycle - Ignore maxspeed when higher than way speed
Then routability should be
| highway | maxspeed | bothw |
| 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
Given the node map
| a | b | c |
And the ways
| nodes | highway | maxspeed |
| ab | residential | |
| bc | residential | 80 |
When I route I should get
| from | to | route | time |
| a | b | ab | 20s ~5% |
| b | c | bc | 20s ~5% |
@todo
Scenario: Bicycle - Maxspeed special tags
Then routability should be
| highway | maxspeed | bothw |
| residential | | 40s ~10% |
| residential | none | 40s ~10% |
| residential | signals | 40s ~10% |

View 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% |

View File

@ -6,6 +6,12 @@ Given /^a grid size of (\d+) meters$/ do |meters|
set_grid_size meters
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|
table.raw.each_with_index do |row,ri|
row.each_with_index do |name,ci|

View File

@ -16,18 +16,21 @@ Then /^routability should be$/ do |table|
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}")
end
want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts
got[direction] = route_status response
json = JSON.parse(response.body)
if got[direction].empty? == false
route = way_list json['route_instructions']
if route != "w#{i}"
got[direction] = "testing w#{i}, but got #{route}!?"
elsif row[direction] =~ /\d+s/
elsif want =~ /^\d+s/
time = json['route_summary']['total_time']
got[direction] = "#{time}s"
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 }
end
end

View File

@ -50,30 +50,10 @@ When /^I route I should get$/ do |table|
ok = true
row.keys.each do |key|
if row[key].match /(.*)\s+~(.+)%$/ #percentage range: 100 ~5%
margin = 1 - $2.to_f*0.01
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
if FuzzyMatch.match got[key], row[key]
got[key] = row[key]
else
ok = row[key] == got[key]
ok = false
end
end

View File

@ -71,8 +71,14 @@ def build_ways_from_table table
way << node5
tags = row.dup
tags.delete 'forw'
tags.delete 'backw'
#remove tags that describe expected test result
tags.reject! do |k,v|
k =~ /^forw\b/ ||
k =~ /^backw\b/ ||
k =~ /^bothw\b/
end
#remove empty tags
tags.reject! { |k,v| v=='' }
# sort tag keys in the form of 'node/....'

View File

@ -28,5 +28,3 @@ class FuzzyMatch
end

View File

@ -0,0 +1,3 @@
def shortcuts_hash
@shortcuts_hash ||= {}
end

View File

@ -152,10 +152,7 @@ function way_function (way, numberOfNodesInWay)
-- 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 (0 < maxspeed and not take_minimum_of_speeds) or (maxspeed == 0) then
maxspeed = math.huge
end
way.speed = math.min(speed_profile[highway], maxspeed)
way.speed = speed_profile[highway]
end
-- Set the avg speed on ways that are marked accessible