2012-09-30 08:40:59 -04:00
|
|
|
@routing @car @restrictions
|
2012-10-01 07:27:08 -04:00
|
|
|
Feature: Car - Turn restrictions
|
2014-03-27 16:46:53 -04:00
|
|
|
# Handle turn restrictions as defined by http://wiki.openstreetmap.org/wiki/Relation:restriction
|
|
|
|
# Note that if u-turns are allowed, turn restrictions can lead to suprising, but correct, routes.
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
Background: Use car routing
|
|
|
|
Given the profile "car"
|
2016-05-30 11:42:28 -04:00
|
|
|
Given a grid size of 200 meters
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
@no_turning
|
|
|
|
Scenario: Car - No left turn
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | sj | wj | j | no_left_turn |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | w | |
|
|
|
|
| s | n | sj,nj,nj |
|
|
|
|
| s | e | sj,ej,ej |
|
2013-08-29 13:29:13 -04:00
|
|
|
|
2014-05-19 06:53:27 -04:00
|
|
|
@no_turning
|
|
|
|
Scenario: Car - No straight on
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
a b j d e
|
|
|
|
v z
|
|
|
|
w x y
|
|
|
|
"""
|
2014-05-19 06:53:27 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| ab | no |
|
|
|
|
| bj | no |
|
|
|
|
| jd | no |
|
|
|
|
| de | no |
|
|
|
|
| av | yes |
|
|
|
|
| vw | yes |
|
|
|
|
| wx | yes |
|
|
|
|
| xy | yes |
|
|
|
|
| yz | yes |
|
|
|
|
| ze | yes |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | bj | jd | j | no_straight_on |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| a | e | av,vw,wx,xy,yz,ze,ze |
|
2014-05-19 06:53:27 -04:00
|
|
|
|
2013-08-29 13:29:13 -04:00
|
|
|
@no_turning
|
|
|
|
Scenario: Car - No right turn
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | sj | ej | j | no_right_turn |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | w | sj,wj,wj |
|
|
|
|
| s | n | sj,nj,nj |
|
|
|
|
| s | e | |
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
@no_turning
|
|
|
|
Scenario: Car - No u-turn
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | sj | wj | j | no_u_turn |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | w | |
|
|
|
|
| s | n | sj,nj,nj |
|
|
|
|
| s | e | sj,ej,ej |
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
@no_turning
|
|
|
|
Scenario: Car - Handle any no_* relation
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | sj | wj | j | no_weird_zigzags |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | w | |
|
|
|
|
| s | n | sj,nj,nj |
|
|
|
|
| s | e | sj,ej,ej |
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
@only_turning
|
|
|
|
Scenario: Car - Only left turn
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | sj | wj | j | only_left_turn |
|
|
|
|
|
2016-08-31 09:22:36 -04:00
|
|
|
Scenario: Car - Only right turn, invalid
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e r
|
|
|
|
s
|
|
|
|
"""
|
2016-08-31 09:22:36 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
| re | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | sj | er | j | only_right_on |
|
|
|
|
|
2013-08-29 13:29:13 -04:00
|
|
|
When I route I should get
|
2016-08-31 09:22:36 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | r | sj,ej,re,re |
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
@only_turning
|
|
|
|
Scenario: Car - Only right turn
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | sj | ej | j | only_right_turn |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | w | |
|
|
|
|
| s | n | |
|
|
|
|
| s | e | sj,ej,ej |
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
@only_turning
|
|
|
|
Scenario: Car - Only straight on
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | sj | nj | j | only_straight_on |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | w | |
|
|
|
|
| s | n | sj,nj,nj |
|
|
|
|
| s | e | |
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
@no_turning
|
|
|
|
Scenario: Car - Handle any only_* restriction
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | sj | nj | j | only_weird_zigzags |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | w | |
|
|
|
|
| s | n | sj,nj,nj |
|
|
|
|
| s | e | |
|
2013-08-29 13:29:13 -04:00
|
|
|
|
2015-09-10 00:53:41 -04:00
|
|
|
@specific
|
|
|
|
Scenario: Car - :hgv-qualified on a standard turn restriction
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2015-09-10 00:53:41 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction:hgv |
|
|
|
|
| restriction | sj | nj | j | no_straight_on |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | w | sj,wj,wj |
|
|
|
|
| s | n | sj,nj,nj |
|
|
|
|
| s | e | sj,ej,ej |
|
2015-09-10 00:53:41 -04:00
|
|
|
|
|
|
|
@specific
|
|
|
|
Scenario: Car - :motorcar-qualified on a standard turn restriction
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2015-09-10 00:53:41 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction:motorcar |
|
|
|
|
| restriction | sj | nj | j | no_straight_on |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | w | sj,wj,wj |
|
|
|
|
| s | n | |
|
|
|
|
| s | e | sj,ej,ej |
|
2015-09-10 00:53:41 -04:00
|
|
|
|
2013-08-29 13:29:13 -04:00
|
|
|
@except
|
|
|
|
Scenario: Car - Except tag and on no_ restrictions
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
b x c
|
|
|
|
a j d
|
|
|
|
s
|
|
|
|
"""
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | no |
|
|
|
|
| xj | -1 |
|
|
|
|
| aj | -1 |
|
|
|
|
| bj | no |
|
|
|
|
| cj | no |
|
|
|
|
| dj | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction | except |
|
|
|
|
| restriction | sj | aj | j | no_left_turn | motorcar |
|
|
|
|
| restriction | sj | bj | j | no_left_turn | |
|
|
|
|
| restriction | sj | cj | j | no_right_turn | |
|
|
|
|
| restriction | sj | dj | j | no_right_turn | motorcar |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | a | sj,aj,aj |
|
|
|
|
| s | b | |
|
|
|
|
| s | c | |
|
|
|
|
| s | d | sj,dj,dj |
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
@except
|
|
|
|
Scenario: Car - Except tag and on only_ restrictions
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
a b
|
|
|
|
j
|
|
|
|
s
|
|
|
|
"""
|
2013-08-29 13:29:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| aj | no |
|
|
|
|
| bj | no |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction | except |
|
|
|
|
| restriction | sj | aj | j | only_straight_on | motorcar |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| s | a | sj,aj,aj |
|
|
|
|
| s | b | sj,bj,bj |
|
2014-06-10 11:23:24 -04:00
|
|
|
|
|
|
|
@except
|
|
|
|
Scenario: Car - Several only_ restrictions at the same segment
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
y
|
|
|
|
i j f b x a e g h
|
|
|
|
|
|
|
|
c d
|
|
|
|
"""
|
2014-06-10 11:23:24 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| fb | no |
|
|
|
|
| bx | -1 |
|
|
|
|
| xa | no |
|
|
|
|
| ae | no |
|
|
|
|
| cb | no |
|
|
|
|
| dc | -1 |
|
|
|
|
| da | no |
|
|
|
|
| fj | no |
|
|
|
|
| jf | no |
|
|
|
|
| ge | no |
|
|
|
|
| hg | no |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | ae | xa | a | only_straight_on |
|
|
|
|
| restriction | xb | fb | b | only_straight_on |
|
|
|
|
| restriction | cb | bx | b | only_right_turn |
|
|
|
|
| restriction | da | ae | a | only_right_turn |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| e | f | ae,xa,bx,fb,fb |
|
|
|
|
| c | f | dc,da,ae,ge,hg,hg,ge,ae,xa,bx,fb,fb |
|
|
|
|
| d | f | da,ae,ge,hg,hg,ge,ae,xa,bx,fb,fb |
|
2014-07-15 09:10:13 -04:00
|
|
|
|
|
|
|
@except
|
|
|
|
Scenario: Car - two only_ restrictions share same to-way
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
e f
|
|
|
|
a
|
|
|
|
|
|
|
|
c x d
|
|
|
|
y
|
|
|
|
|
|
|
|
b
|
|
|
|
"""
|
2014-07-15 09:10:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| ef | no |
|
|
|
|
| ce | no |
|
|
|
|
| fd | no |
|
|
|
|
| ca | no |
|
|
|
|
| ad | no |
|
|
|
|
| ax | no |
|
|
|
|
| xy | no |
|
|
|
|
| yb | no |
|
|
|
|
| cb | no |
|
|
|
|
| db | no |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | ax | xy | x | only_straight_on |
|
|
|
|
| restriction | by | xy | y | only_straight_on |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| a | b | ax,xy,yb,yb |
|
|
|
|
| b | a | yb,xy,ax,ax |
|
2014-07-15 09:10:13 -04:00
|
|
|
|
|
|
|
@except
|
|
|
|
Scenario: Car - two only_ restrictions share same from-way
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
e f
|
|
|
|
a
|
|
|
|
|
|
|
|
c x d
|
|
|
|
y
|
|
|
|
|
|
|
|
b
|
|
|
|
"""
|
2014-07-15 09:10:13 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| ef | no |
|
|
|
|
| ce | no |
|
|
|
|
| fd | no |
|
|
|
|
| ca | no |
|
|
|
|
| ad | no |
|
|
|
|
| ax | no |
|
|
|
|
| xy | no |
|
|
|
|
| yb | no |
|
|
|
|
| cb | no |
|
|
|
|
| db | no |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | xy | xa | x | only_straight_on |
|
|
|
|
| restriction | xy | yb | y | only_straight_on |
|
|
|
|
|
|
|
|
When I route I should get
|
2016-03-31 19:39:31 -04:00
|
|
|
| from | to | route |
|
|
|
|
| a | b | ax,xy,yb,yb |
|
|
|
|
| b | a | yb,xy,ax,ax |
|
2014-07-15 09:10:13 -04:00
|
|
|
|
2016-08-31 09:52:05 -04:00
|
|
|
@specific
|
|
|
|
Scenario: Car - Ignore unrecognized restriction
|
|
|
|
Given the node map
|
2016-09-30 03:33:08 -04:00
|
|
|
"""
|
|
|
|
n
|
|
|
|
w j e
|
|
|
|
s
|
|
|
|
"""
|
2016-08-31 09:52:05 -04:00
|
|
|
|
|
|
|
And the ways
|
|
|
|
| nodes | oneway |
|
|
|
|
| sj | yes |
|
|
|
|
| nj | -1 |
|
|
|
|
| wj | -1 |
|
|
|
|
| ej | -1 |
|
|
|
|
|
|
|
|
And the relations
|
|
|
|
| type | way:from | way:to | node:via | restriction |
|
|
|
|
| restriction | sj | wj | j | yield |
|
|
|
|
|
|
|
|
When I route I should get
|
|
|
|
| from | to | route |
|
|
|
|
| s | w | sj,wj,wj |
|
|
|
|
| s | n | sj,nj,nj |
|
|
|
|
| s | e | sj,ej,ej |
|
|
|
|
|