updated turn restriction tests. use correct .osrm.restrictions file during tests. add tests for no-right-turn

This commit is contained in:
Emil Tin 2012-03-02 13:35:30 +01:00
parent 9fdb6eb2c5
commit b0ecb869f2
3 changed files with 230 additions and 58 deletions

View File

@ -1,95 +1,267 @@
@routing @restrictions @routing @restrictions
Feature: Turn restrictions Feature: Turn restrictions
Handle turn restrictions as defined by http://wiki.openstreetmap.org/wiki/Relation:restriction Handle turn restrictions as defined by http://wiki.openstreetmap.org/wiki/Relation:restriction
How this plays with u-turns can be tricky. Note that if u-turns are allowed, turn restrictions can lead to suprising, but correct, routes.
Scenario: No left turn #left side
@restriction_left @no_left_turn @no_turn
Scenario: No left turn, no way to reach destination
Given the nodes Given the nodes
| | t | | | w | j |
| a | j | b | | | s |
And the ways
| nodes |
| sj |
| wj |
And the relations
| from | to | via | restriction |
| sj | wj | j | no_left_turn |
When I route I should get
| from | to | route |
| s | w | |
| w | s | wj,sj |
@restriction_left @no_left_turn @no_turn
Scenario: No left turn, don't use u-turns to reach destination
Given the nodes
| | n | |
| w | j | e |
| | s | | | | s | |
And the ways And the ways
| nodes | | nodes |
| bj | | nj |
| aj | | ej |
| sj | | sj |
| tj | | wj |
And the relations And the relations
| from | to | via | restriction | | from | to | via | restriction |
| sj | aj | j | no_left_turn | | sj | wj | j | no_left_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
| s | a | | | s | w | |
| s | b | sj,jb | | s | n | sj,nj |
| s | t | sj,tj | | s | e | sj,ej |
| a | b | aj,bj | | w | n | wj,nj |
| a | a | aj,sj | | w | e | wj,ej |
| a | t | aj,tj | | w | s | wj,sj |
| b | b | jb,aj | | n | e | nj,ej |
| b | s | bj,sj | | n | s | nj,sj |
| b | t | bj,tj | | n | w | nj,wj |
| e | s | ej,sj |
| e | w | ej,wj |
| e | n | ej,nj |
Scenario: No left turn, go counter-clockwise around the block instead @restriction_left @no_left_turn @no_turn
Scenario: No left turn, go around the block instead
Given the nodes Given the nodes
| x | t | | | y | n | |
| a | j | b | | w | j | e |
| | s | | | | s | |
And the ways And the ways
| nodes | | nodes |
| bj | | nj |
| aj | | ej |
| sj | | sj |
| tj | | wj |
| axt | | wyn |
And the relations And the relations
| from | to | via | restriction | | from | to | via | restriction |
| sj | aj | j | no_left_turn | | sj | wj | j | no_left_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
| s | a | sj,tj,axt | | s | w | sj,nj,wyn |
| s | b | sj,jb | | s | n | sj,nj |
| s | t | sj,tj | | s | e | sj,ej |
| a | b | aj,bj | | w | n | wj,nj |
| a | a | aj,sj | | w | e | wj,ej |
| a | t | aj,tj | | w | s | wj,sj |
| b | b | jb,aj | | n | e | nj,ej |
| b | s | bj,sj | | n | s | nj,sj |
| b | t | bj,tj | | n | w | nj,wj |
| e | s | ej,sj |
| e | w | ej,wj |
| e | n | ej,nj |
Scenario: No left turn, go clockwise around the block instead @restriction_left @only_left_turn @must_turn
Scenario: Only left turn, don't use u-turns to reach destination
Given the nodes Given the nodes
| | | t | | | | n | |
| z | a | j | b | | w | j | e |
| x | | s | | | | s | |
And the ways And the ways
| nodes | | nodes |
| bj | | nj |
| aj | | ej |
| sj | | sj |
| tj | | wj |
| sxza |
And the relations And the relations
| from | to | via | restriction | | from | to | via | restriction |
| sj | aj | j | no_left_turn | | sj | wj | j | only_restriction_left |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
| s | a | sxza | | s | w | sj,wj |
| s | b | sj,jb | | s | n | |
| s | t | sj,tj | | s | e | |
| a | b | aj,bj | | w | n | wj,nj |
| a | a | aj,sj | | w | e | wj,ej |
| a | t | aj,tj | | w | s | wj,sj |
| b | b | jb,aj | | n | e | nj,ej |
| b | s | bj,sj | | n | s | nj,sj |
| b | t | bj,tj | | n | w | nj,wj |
| e | s | ej,sj |
| e | w | ej,wj |
| e | n | ej,nj |
#right side
@restriction_right @no_right_turn @no_turn
Scenario: No right turn, no way to reach destination
Given the nodes
| j | e |
| s | |
And the ways
| nodes |
| ej |
| sj |
And the relations
| from | to | via | restriction |
| sj | ej | j | no_right_turn |
When I route I should get
| from | to | route |
| s | e | |
| e | s | ej,sj |
@restriction_right @no_right_turn @no_turn
Scenario: No right turn, don't use u-turns to reach destination
Given the nodes
| | n | |
| w | j | e |
| | s | |
And the ways
| nodes |
| nj |
| ej |
| sj |
| wj |
And the relations
| from | to | via | restriction |
| sj | ej | j | no_right_turn |
When I route I should get
| from | to | route |
| s | w | sj,wj |
| s | n | sj,nj |
| s | e | |
| w | n | wj,nj |
| w | e | wj,ej |
| w | s | wj,sj |
| n | e | nj,ej |
| n | s | nj,sj |
| n | w | nj,wj |
| e | s | ej,sj |
| e | w | ej,wj |
| e | n | ej,nj |
@restriction_right @no_right_turn @no_turn
Scenario: No right turn, go around the block instead
Given the nodes
| | n | y |
| w | j | e |
| | s | |
And the ways
| nodes |
| nj |
| ej |
| sj |
| wj |
| nye |
And the relations
| from | to | via | restriction |
| sj | ej | j | no_right_turn |
When I route I should get
| from | to | route |
| s | w | sj,wj |
| s | n | sj,nj |
| s | e | sj,nj,nye |
| w | n | wj,nj |
| w | e | wj,ej |
| w | s | wj,sj |
| n | e | nj,ej |
| n | s | nj,sj |
| n | w | nj,wj |
| e | s | ej,sj |
| e | w | ej,wj |
| e | n | ej,nj |
@restriction_right @only_right_turn @must_turn
Scenario: Right turn only, don't use u-turns to reach destination
Given the nodes
| | n | |
| w | j | e |
| | s | |
And the ways
| nodes |
| nj |
| ej |
| sj |
| wj |
And the relations
| from | to | via | restriction |
| sj | ej | j | only_right_turn |
When I route I should get
| from | to | route |
| s | w | |
| s | n | |
| s | e | sj,ej |
| w | n | wj,nj |
| w | e | wj,ej |
| w | s | wj,sj |
| n | e | nj,ej |
| n | s | nj,sj |
| n | w | nj,wj |
| e | s | ej,sj |
| e | w | ej,wj |
| e | n | ej,nj |
@no_u_turn
Scenario: No U-turn
Given the nodes
| | b | |
| | | |
| c | | a |
And the ways
| nodes |
| ab |
| bc |
And the relations
| from | to | via | restriction |
| ab | bc | b | no_u_turn |
When I route I should get
| from | to | route |
| a | c | |
| c | a | bc,ab |

View File

@ -66,7 +66,7 @@ end
Given /^the relations$/ do |table| Given /^the relations$/ do |table|
table.hashes.each do |row| table.hashes.each do |row|
relation = OSM::Relation.new make_osm_id, OSM_USER, OSM_TIMESTAMP relation = OSM::Relation.new make_osm_id, OSM_USER, OSM_TIMESTAMP
relation << { :type => :restriction, :restriction => 'no_left_turn' } relation << { :type => :restriction, :restriction => row['restriction'] }
from_way = find_way_by_name(row['from']) from_way = find_way_by_name(row['from'])
raise "*** unknown way '#{row['from']}'" unless from_way raise "*** unknown way '#{row['from']}'" unless from_way
to_way = find_way_by_name(row['to']) to_way = find_way_by_name(row['to'])

View File

@ -179,7 +179,7 @@ def reprocess
unless prepared? unless prepared?
log_preprocess_info log_preprocess_info
log "== Preparing #{@osm_file}.osm...", :preprocess log "== Preparing #{@osm_file}.osm...", :preprocess
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}" unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
log "*** Exited with code #{$?.exitstatus}.", :preprocess log "*** Exited with code #{$?.exitstatus}.", :preprocess
raise "*** osrm-prepare exited with code #{$?.exitstatus}. The file preprocess.log might contain more info." raise "*** osrm-prepare exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
end end