diff --git a/features/car/access.feature b/features/car/access.feature index 1c1509516..1d94b54d0 100644 --- a/features/car/access.feature +++ b/features/car/access.feature @@ -181,10 +181,10 @@ Feature: Car - Restricted access @hov Scenario: Car - only designated HOV ways are ignored by default Then routability should be - | highway | hov | bothw | - | primary | designated | | - | primary | yes | x | - | primary | no | x | + | highway | hov | bothw | forw_rate | + | primary | designated | x | 52.63 km/h | + | primary | yes | x | | + | primary | no | x | | @hov Scenario: Car - a way with all lanes HOV-designated is inaccessible by default (similar to hov=designated) diff --git a/features/car/bridge.feature b/features/car/bridge.feature index 2b1b87b42..2bee3bba2 100644 --- a/features/car/bridge.feature +++ b/features/car/bridge.feature @@ -29,6 +29,27 @@ Feature: Car - Handle driving | c | f | cde,efg,efg | driving,driving,driving | | c | g | cde,efg,efg | driving,driving,driving | + Scenario: Car - Control test without durations, osrm uses movable bridge speed to calculate duration + Given the node map + """ + a b c + d + e f g + """ + + And the ways + | nodes | highway | bridge | + | abc | primary | | + | cde | | movable | + | efg | primary | | + + When I route I should get + | from | to | route | modes | speed | time | + | a | g | abc,cde,efg,efg | driving,driving,driving,driving | 12 km/h | 173s +-1 | + | b | f | abc,cde,efg,efg | driving,driving,driving,driving | 9 km/h | 162s +-1 | + | c | e | cde,cde | driving,driving | 5 km/h | 146s +-1 | + | e | c | cde,cde | driving,driving | 5 km/h | 149s +-1 | + Scenario: Car - Properly handle durations Given the node map """ @@ -45,7 +66,7 @@ Feature: Car - Handle driving When I route I should get | from | to | route | modes | speed | - | a | g | abc,cde,efg,efg | driving,driving,driving,driving | 6 km/h | - | b | f | abc,cde,efg,efg | driving,driving,driving,driving | 4 km/h | + | a | g | abc,cde,efg,efg | driving,driving,driving,driving | 7 km/h | + | b | f | abc,cde,efg,efg | driving,driving,driving,driving | 5 km/h | | c | e | cde,cde | driving,driving | 2 km/h | | e | c | cde,cde | driving,driving | 2 km/h | diff --git a/features/car/ferry.feature b/features/car/ferry.feature index ae7b0b691..95e95dfa8 100644 --- a/features/car/ferry.feature +++ b/features/car/ferry.feature @@ -29,6 +29,27 @@ Feature: Car - Handle ferry routes | c | f | cde,efg,efg | ferry,driving,driving | | c | g | cde,efg,efg | ferry,driving,driving | + + Scenario: Car - Use default speeds to calculate duration if no duration given + Given the node map + """ + a b c + d + e f g + """ + + And the ways + | nodes | highway | route | + | abc | primary | | + | cde | | ferry | + | efg | primary | | + + When I route I should get + | from | to | route | modes | speed | time | + | a | g | abc,cde,efg,efg | driving,ferry,driving,driving | 12 km/h | 173.4s | + | b | f | abc,cde,efg,efg | driving,ferry,driving,driving | 9 km/h | 162.4s | + | c | e | cde,cde | ferry,ferry | 5 km/h | 151.4s | + | e | c | cde,cde | ferry,ferry | 5 km/h | 151.4s | Scenario: Car - Properly handle simple durations Given the node map """ @@ -44,11 +65,11 @@ Feature: Car - Handle ferry routes | efg | primary | | | When I route I should get - | from | to | route | modes | speed | - | a | g | abc,cde,efg,efg | driving,ferry,driving,driving | 23 km/h | - | b | f | abc,cde,efg,efg | driving,ferry,driving,driving | 18 km/h | - | c | e | cde,cde | ferry,ferry | 11 km/h | - | e | c | cde,cde | ferry,ferry | 11 km/h | + | from | to | route | modes | speed | time | + | a | g | abc,cde,efg,efg | driving,ferry,driving,driving | 24 km/h | 89.4s | + | b | f | abc,cde,efg,efg | driving,ferry,driving,driving | 18 km/h | 78.4s | + | c | e | cde,cde | ferry,ferry | 11 km/h | 67.4s | + | e | c | cde,cde | ferry,ferry | 11 km/h | 67.4s | Scenario: Car - Properly handle ISO 8601 durations Given the node map @@ -65,8 +86,8 @@ Feature: Car - Handle ferry routes | efg | primary | | | When I route I should get - | from | to | route | modes | speed | - | a | g | abc,cde,efg,efg | driving,ferry,driving,driving | 23 km/h | - | b | f | abc,cde,efg,efg | driving,ferry,driving,driving | 18 km/h | - | c | e | cde,cde | ferry,ferry | 11 km/h | - | e | c | cde,cde | ferry,ferry | 11 km/h | + | from | to | route | modes | speed | time | + | a | g | abc,cde,efg,efg | driving,ferry,driving,driving | 24 km/h | 89.4s | + | b | f | abc,cde,efg,efg | driving,ferry,driving,driving | 18 km/h | 78.4s | + | c | e | cde,cde | ferry,ferry | 11 km/h | 67.4s | + | e | c | cde,cde | ferry,ferry | 11 km/h | 67.4s | diff --git a/features/car/maxspeed.feature b/features/car/maxspeed.feature index 4f78046af..db270a44e 100644 --- a/features/car/maxspeed.feature +++ b/features/car/maxspeed.feature @@ -37,26 +37,30 @@ OSRM will use 4/5 of the projected free-flow speed. """ And the ways - | nodes | highway | maxspeed | - | ab | residential | | - | bc | residential | 90 | - | cd | living_street | FR:urban | + | nodes | highway | maxspeed | # | + | ab | residential | | default residential speed is 25 | + | bc | residential | 90 | | + | cd | living_street | FR:urban | | When I route I should get | from | to | route | speed | - | a | b | ab,ab | 20 km/h | + | a | b | ab,ab | 25 km/h | + # default residential speed is 25, don't mess with this | b | c | bc,bc | 72 km/h | + # parsed maxspeeds are scaled by profile's speed_reduction value | c | d | cd,cd | 40 km/h | + # symbolic posted speeds without explicit exceptions are parsed + # from the profile's maxspeed_table_default table - Scenario: Car - Forward/backward maxspeed + Scenario: Car - Forward/backward maxspeed are scaled by profile's speed_reduction if explicitly set Given a grid size of 100 meters Then routability should be | highway | maxspeed | maxspeed:forward | maxspeed:backward | forw | backw | - | primary | | | | 52 km/h | 52 km/h | + | primary | | | | 65 km/h | 65 km/h | | primary | 60 | | | 48 km/h | 48 km/h | - | primary | | 60 | | 48 km/h | 52 km/h | - | primary | | | 60 | 52 km/h | 48 km/h | + | primary | | 60 | | 48 km/h | 65 km/h | + | primary | | | 60 | 65 km/h | 48 km/h | | primary | 15 | 60 | | 48 km/h | 12 km/h | | primary | 15 | | 60 | 12 km/h | 48 km/h | | primary | 15 | 30 | 60 | 24 km/h | 48 km/h | @@ -81,55 +85,55 @@ OSRM will use 4/5 of the projected free-flow speed. Scenario: Car - Too narrow streets should be ignored or incur a penalty Then routability should be - | highway | maxspeed | width | maxspeed:forward | maxspeed:backward | forw | backw | - | primary | | | | | 52 km/h | 52 km/h | - | primary | | 3 | | | 32 km/h | 32 km/h | - | primary | 60 | | | | 47 km/h | 47 km/h | - | primary | 60 | 3 | | | 29 km/h | 29 km/h | - | primary | | | 60 | | 47 km/h | 52 km/h | - | primary | | 3 | 60 | | 29 km/h | 32 km/h | - | primary | | | | 60 | 52 km/h | 47 km/h | - | primary | | 3 | | 60 | 32 km/h | 29 km/h | - | primary | 15 | | 60 | | 47 km/h | 11 km/h | - | primary | 15 | 3 | 60 | | 30 km/h | 7 km/h | - | primary | 15 | | | 60 | 12 km/h | 47 km/h | - | primary | 15 | 3 | | 60 | 7 km/h | 29 km/h | - | primary | 15 | | 30 | 60 | 23 km/h | 47 km/h | - | primary | 15 | 3 | 30 | 60 | 15 km/h | 29 km/h | + | highway | maxspeed | width | maxspeed:forward | maxspeed:backward | forw | backw | forw_rate | backw_rate | + | primary | | | | | 64 km/h | 64 km/h | 65 km/h | 65 km/h | + | primary | | 3 | | | 64 km/h | 64 km/h | 32 km/h | 32 km/h | + | primary | 60 | | | | 47 km/h | 47 km/h | 48 km/h | 48 km/h | + | primary | 60 | 3 | | | 47 km/h | 47 km/h | 24 km/h | 24 km/h | + | primary | | | 60 | | 47 km/h | 64 km/h | 48 km/h | 65 km/h | + | primary | | 3 | 60 | | 47 km/h | 64 km/h | 24 km/h | 32 km/h | + | primary | | | | 60 | 64 km/h | 47 km/h | 65 km/h | 48 km/h | + | primary | | 3 | | 60 | 64 km/h | 47 km/h | 32 km/h | 24 km/h | + | primary | 15 | | 60 | | 47 km/h | 11 km/h | 48 km/h | 12 km/h | + | primary | 15 | 3 | 60 | | 48 km/h | 12 km/h | 24 km/h | 6 km/h | + | primary | 15 | | | 60 | 12 km/h | 47 km/h | 12 km/h | 48 km/h | + | primary | 15 | 3 | | 60 | 12 km/h | 47 km/h | 6 km/h | 24 km/h | + | primary | 15 | | 30 | 60 | 23 km/h | 47 km/h | 24 km/h | 48 km/h | + | primary | 15 | 3 | 30 | 60 | 23 km/h | 47 km/h | 12 km/h | 24 km/h | Scenario: Car - Single lane streets be ignored or incur a penalty Then routability should be - | highway | maxspeed | lanes | maxspeed:forward | maxspeed:backward | forw | backw | - | primary | | | | | 52 km/h | 52 km/h | - | primary | | 1 | | | 32 km/h | 32 km/h | - | primary | 60 | | | | 47 km/h | 47 km/h | - | primary | 60 | 1 | | | 29 km/h | 29 km/h | - | primary | | | 60 | | 47 km/h | 52 km/h | - | primary | | 1 | 60 | | 29 km/h | 32 km/h | - | primary | | | | 60 | 52 km/h | 47 km/h | - | primary | | 1 | | 60 | 32 km/h | 29 km/h | - | primary | 15 | | 60 | | 47 km/h | 11 km/h | - | primary | 15 | 1 | 60 | | 30 km/h | 7 km/h | - | primary | 15 | | | 60 | 12 km/h | 47 km/h | - | primary | 15 | 1 | | 60 | 7 km/h | 29 km/h | - | primary | 15 | | 30 | 60 | 23 km/h | 47 km/h | - | primary | 15 | 1 | 30 | 60 | 15 km/h | 29 km/h | + | highway | maxspeed | lanes | maxspeed:forward | maxspeed:backward | forw | backw | forw_rate | backw_rate | + | primary | | | | | 64 km/h | 64 km/h | 65 km/h | 65 km/h | + | primary | | 1 | | | 64 km/h | 64 km/h | 32 km/h | 32 km/h | + | primary | 60 | | | | 47 km/h | 47 km/h | 48 km/h | 48 km/h | + | primary | 60 | 1 | | | 47 km/h | 47 km/h | 24 km/h | 24 km/h | + | primary | | | 60 | | 47 km/h | 64 km/h | 48 km/h | 65 km/h | + | primary | | 1 | 60 | | 47 km/h | 64 km/h | 24 km/h | 32 km/h | + | primary | | | | 60 | 64 km/h | 47 km/h | 65 km/h | 48 km/h | + | primary | | 1 | | 60 | 64 km/h | 47 km/h | 32 km/h | 24 km/h | + | primary | 15 | | 60 | | 47 km/h | 11 km/h | 48 km/h | 12 km/h | + | primary | 15 | 1 | 60 | | 48 km/h | 12 km/h | 24 km/h | 6 km/h | + | primary | 15 | | | 60 | 12 km/h | 47 km/h | 12 km/h | 48 km/h | + | primary | 15 | 1 | | 60 | 12 km/h | 47 km/h | 6 km/h | 24 km/h | + | primary | 15 | | 30 | 60 | 23 km/h | 47 km/h | 24 km/h | 48 km/h | + | primary | 15 | 1 | 30 | 60 | 23 km/h | 47 km/h | 12 km/h | 24 km/h | - Scenario: Car - Single lane streets only incure a penalty for two-way streets + Scenario: Car - Single lane streets only incur a penalty for two-way streets Then routability should be - | highway | maxspeed | lanes | oneway | forw | backw | - | primary | 30 | 1 | yes | 23 km/h | | - | primary | 30 | 1 | -1 | | 23 km/h | - | primary | 30 | 1 | | 15 km/h | 15 km/h | - | primary | 30 | 2 | | 23 km/h | 23 km/h | + | highway | maxspeed | lanes | oneway | forw | backw | forw_rate | backw_rate | + | primary | 30 | 1 | yes | 23 km/h | | 24 km/h | | + | primary | 30 | 1 | -1 | | 23 km/h | | 24 km/h | + | primary | 30 | 1 | | 23 km/h | 23 km/h | 12 km/h | 12 km/h | + | primary | 30 | 2 | | 23 km/h | 23 km/h | 24 km/h | 24 km/h | - Scenario: Car - Forwward/backward maxspeed on reverse oneways + Scenario: Car - Forward/backward maxspeed on reverse oneways Then routability should be - | highway | maxspeed | maxspeed:forward | maxspeed:backward | oneway | forw | backw | - | primary | | | | -1 | | 52 km/h | - | primary | 30 | | | -1 | | 23 km/h | - | primary | | 30 | | -1 | | 52 km/h | - | primary | | | 30 | -1 | | 23 km/h | - | primary | 20 | 30 | | -1 | | 15 km/h | - | primary | 20 | | 30 | -1 | | 23 km/h | + | highway | maxspeed | maxspeed:forward | maxspeed:backward | oneway | forw | backw | forw_rate | backw_rate | + | primary | | | | -1 | | 64 km/h | | 65 km/h | + | primary | 30 | | | -1 | | 23 km/h | | 24 km/h | + | primary | | 30 | | -1 | | 64 km/h | | 65 km/h | + | primary | | | 30 | -1 | | 23 km/h | | 24 km/h | + | primary | 20 | 30 | | -1 | | 15 km/h | | 16 km/h | + | primary | 20 | | 30 | -1 | | 23 km/h | | 24 km/h | diff --git a/features/car/service.feature b/features/car/service.feature index 9bd65846e..453eedde0 100644 --- a/features/car/service.feature +++ b/features/car/service.feature @@ -4,11 +4,11 @@ Feature: Car - Surfaces Background: Given the profile "car" - Scenario: Car - Surface should reduce speed + Scenario: Car - Ways tagged service should reduce speed Then routability should be - | highway | service | forw | backw | - | service | alley | 5 km/h +-1 | 5 km/h +-1 | - | service | emergency_access | | | - | service | driveway | 5 km/h +-1 | 5 km/h +-1 | - | service | drive-through | 5 km/h +-1 | 5 km/h +-1 | - | service | parking | 5 km/h +-1 | 5 km/h +-1 | + | highway | service | forw | backw | forw_rate | + | service | alley | 15 km/h +-1 | 15 km/h +-1 | 12.05 km/h | + | service | emergency_access | | | | + | service | driveway | 15 km/h +-1 | 15 km/h +-1 | 12.05 km/h | + | service | drive-through | 15 km/h +-1 | 15 km/h +-1 | 12.05 km/h | + | service | parking | 15 km/h +-1 | 15 km/h +-1 | 12.05 km/h | diff --git a/features/car/side_bias.feature b/features/car/side_bias.feature index 65fb5e5f7..708e45c05 100644 --- a/features/car/side_bias.feature +++ b/features/car/side_bias.feature @@ -28,8 +28,8 @@ Feature: Testbot - side bias When I route I should get | from | to | route | time | - | d | a | bd,ab,ab | 29s +-1 | - | d | c | bd,bc,bc | 33s +-1 | + | d | a | bd,ab,ab | 24s +-1 | + | d | c | bd,bc,bc | 27s +-1 | Scenario: Right hand bias Given the profile file "car" extended with @@ -51,8 +51,9 @@ Feature: Testbot - side bias When I route I should get | from | to | route | time | - | d | a | bd,ab,ab | 33s +-1 | - | d | c | bd,bc,bc | 29s +-1 | + | d | a | bd,ab,ab | 27s +-1 | + # should be inverse of left hand bias + | d | c | bd,bc,bc | 24s +-1 | Scenario: Roundabout exit counting for left sided driving And a grid size of 10 meters diff --git a/features/car/speed.feature b/features/car/speed.feature index 5750cbfc3..5855cafd4 100644 --- a/features/car/speed.feature +++ b/features/car/speed.feature @@ -5,42 +5,43 @@ Feature: Car - speeds Given the profile "car" And a grid size of 1000 meters + # should more or less match default speeds in car profile, but may be different due to rounding errors Scenario: Car - speed of various way types Then routability should be | highway | oneway | bothw | - | motorway | no | 71 km/h | - | motorway_link | no | 35 km/h | - | trunk | no | 68 km/h | - | trunk_link | no | 31 km/h | - | primary | no | 52 km/h | - | primary_link | no | 23 km/h | - | secondary | no | 44 km/h | - | secondary_link | no | 19 km/h | - | tertiary | no | 31 km/h | - | tertiary_link | no | 16 km/h | - | unclassified | no | 19 km/h | - | residential | no | 19 km/h | - | living_street | no | 8 km/h | - | service | no | 12 km/h | + | motorway | no | 89 km/h | + | motorway_link | no | 44 km/h | + | trunk | no | 85 km/h | + | trunk_link | no | 39 km/h | + | primary | no | 64 km/h | + | primary_link | no | 29 km/h | + | secondary | no | 55 km/h | + | secondary_link | no | 24 km/h | + | tertiary | no | 39 km/h | + | tertiary_link | no | 20 km/h | + | unclassified | no | 24 km/h | + | residential | no | 24 km/h | + | living_street | no | 9 km/h | + | service | no | 15 km/h | - # Alternating oneways have to take average waiting time into account. + # Alternating oneways scale rates but not speeds Scenario: Car - scaled speeds for oneway=alternating Then routability should be | highway | oneway | junction | forw | backw | # | - | tertiary | | | 31 km/h | 31 km/h | | - | tertiary | alternating | | 12 km/h | 12 km/h | | - | motorway | | | 71 km/h | | implied oneway | - | motorway | alternating | | 28 km/h | | implied oneway | + | tertiary | | | 39 km/h | 39 km/h | | + | tertiary | alternating | | 39 km/h | 39 km/h | | + | motorway | | | 89 km/h | | implied oneway | + | motorway | alternating | | 89 km/h | | implied oneway | | motorway | reversible | | | | unroutable | - | primary | | roundabout | 52 km/h | | implied oneway | - | primary | alternating | roundabout | 20 km/h | | implied oneway | + | primary | | roundabout | 64 km/h | | implied oneway | + | primary | alternating | roundabout | 64 km/h | | implied oneway | | primary | reversible | roundabout | | | unroutable | Scenario: Car - Check roundoff errors Then routability should be | highway | maxspeed | forw | backw | - | primary | | 52 km/h | 52 km/h | + | primary | | 64 km/h | 64 km/h | | primary | 60 | 47 km/h | 47 km/h | | primary | 60 | 47 km/h | 47 km/h | | primary | 60 | 47 km/h | 47 km/h | diff --git a/features/car/surface.feature b/features/car/surface.feature index 6fd26d18e..ef7d6ec42 100644 --- a/features/car/surface.feature +++ b/features/car/surface.feature @@ -64,64 +64,65 @@ Feature: Car - Surfaces Scenario: Car - Surface should reduce speed Then routability should be | highway | oneway | surface | forw | backw | - | motorway | no | | 72 km/h | 72 km/h | - | motorway | no | asphalt | 72 km/h | 72 km/h +-1 | - | motorway | no | concrete | 72 km/h +-1 | 72 km/h +-1 | - | motorway | no | concrete:plates | 72 km/h +-1 | 72 km/h +-1 | - | motorway | no | concrete:lanes | 72 km/h +-1 | 72 km/h +-1 | - | motorway | no | paved | 72 km/h +-1 | 72 km/h +-1 | - | motorway | no | cement | 64 km/h +-1 | 64 km/h +-1 | - | motorway | no | compacted | 64 km/h +-1 | 64 km/h +-1 | - | motorway | no | fine_gravel | 64 km/h +-1 | 64 km/h +-1 | - | motorway | no | paving_stones | 48 km/h +-1 | 48 km/h +-1 | - | motorway | no | metal | 48 km/h +-1 | 48 km/h +-1 | - | motorway | no | bricks | 48 km/h +-1 | 48 km/h +-1 | - | motorway | no | grass | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | wood | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | sett | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | grass_paver | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | gravel | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | unpaved | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | ground | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | dirt | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | pebblestone | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | tartan | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | cobblestone | 24 km/h +-1 | 24 km/h +-1 | - | motorway | no | clay | 24 km/h +-1 | 24 km/h +-1 | - | motorway | no | earth | 16 km/h +-1 | 16 km/h +-1 | - | motorway | no | stone | 16 km/h +-1 | 16 km/h +-1 | - | motorway | no | rocky | 16 km/h +-1 | 16 km/h +-1 | - | motorway | no | sand | 16 km/h +-1 | 16 km/h +-1 | + | motorway | no | | 90 km/h | 90 km/h | + | motorway | no | asphalt | 90 km/h | 90 km/h +-1 | + | motorway | no | concrete | 90 km/h +-1 | 90 km/h +-1 | + | motorway | no | concrete:plates | 90 km/h +-1 | 90 km/h +-1 | + | motorway | no | concrete:lanes | 90 km/h +-1 | 90 km/h +-1 | + | motorway | no | paved | 90 km/h +-1 | 90 km/h +-1 | + | motorway | no | cement | 80 km/h +-1 | 80 km/h +-1 | + | motorway | no | compacted | 80 km/h +-1 | 80 km/h +-1 | + | motorway | no | fine_gravel | 80 km/h +-1 | 80 km/h +-1 | + | motorway | no | paving_stones | 60 km/h +-1 | 60 km/h +-1 | + | motorway | no | metal | 60 km/h +-1 | 60 km/h +-1 | + | motorway | no | bricks | 60 km/h +-1 | 60 km/h +-1 | + | motorway | no | grass | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | wood | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | sett | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | grass_paver | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | gravel | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | unpaved | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | ground | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | dirt | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | pebblestone | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | tartan | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | cobblestone | 30 km/h +-1 | 30 km/h +-1 | + | motorway | no | clay | 30 km/h +-1 | 30 km/h +-1 | + | motorway | no | earth | 20 km/h +-1 | 20 km/h +-1 | + | motorway | no | stone | 20 km/h +-1 | 20 km/h +-1 | + | motorway | no | rocky | 20 km/h +-1 | 20 km/h +-1 | + | motorway | no | sand | 20 km/h +-1 | 20 km/h +-1 | + | motorway | no | mud | 10 km/h +-1 | 10 km/h +-1 | Scenario: Car - Tracktypes should reduce speed Then routability should be | highway | oneway | tracktype | forw | backw | - | motorway | no | | 72 km/h | 72 km/h | - | motorway | no | grade1 | 48 km/h +-1 | 48 km/h +-1 | - | motorway | no | grade2 | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | grade3 | 24 km/h +-1 | 24 km/h +-1 | - | motorway | no | grade4 | 20 km/h +-1 | 20 km/h +-1 | - | motorway | no | grade5 | 16 km/h +-1 | 16 km/h +-1 | + | motorway | no | | 90 km/h | 90 km/h | + | motorway | no | grade1 | 60 km/h +-1 | 60 km/h +-1 | + | motorway | no | grade2 | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | grade3 | 30 km/h +-1 | 30 km/h +-1 | + | motorway | no | grade4 | 25 km/h +-1 | 25 km/h +-1 | + | motorway | no | grade5 | 20 km/h +-1 | 20 km/h +-1 | Scenario: Car - Smoothness should reduce speed Then routability should be | highway | oneway | smoothness | forw | backw | - | motorway | no | | 72 km/h | 72 km/h | - | motorway | no | intermediate | 64 km/h | 64 km/h | - | motorway | no | bad | 32 km/h +-1 | 32 km/h +-1 | - | motorway | no | very_bad | 16 km/h +-1 | 16 km/h +-1 | - | motorway | no | horrible | 8 km/h +-1 | 8 km/h +-1 | - | motorway | no | very_horrible | 4 km/h +-1 | 4 km/h +-1 | + | motorway | no | | 90 km/h | 90 km/h | + | motorway | no | intermediate | 80 km/h | 80 km/h | + | motorway | no | bad | 40 km/h +-1 | 40 km/h +-1 | + | motorway | no | very_bad | 20 km/h +-1 | 20 km/h +-1 | + | motorway | no | horrible | 10 km/h +-1 | 10 km/h +-1 | + | motorway | no | very_horrible | 5 km/h +-1 | 5 km/h +-1 | Scenario: Car - Combination of surface tags should use lowest speed Then routability should be - | highway | oneway | tracktype | surface | smoothness | backw | forw | - | motorway | no | | | | 72 km/h | 72 km/h | - | service | no | grade1 | asphalt | excellent | 12 km/h | 12 km/h | - | motorway | no | grade5 | asphalt | excellent | 16 km/h | 16 km/h | - | motorway | no | grade1 | mud | excellent | 8 km/h | 8 km/h | - | motorway | no | grade1 | asphalt | very_horrible | 4 km/h | 4 km/h | - | service | no | grade5 | mud | very_horrible | 4 km/h | 4 km/h | + | highway | oneway | tracktype | surface | smoothness | bothw | + | motorway | no | | | | 90 km/h | + | service | no | grade1 | asphalt | excellent | 15 km/h | + | motorway | no | grade5 | asphalt | excellent | 20 km/h | + | motorway | no | grade1 | mud | excellent | 10 km/h | + | motorway | no | grade1 | asphalt | very_horrible | 5 km/h | + | service | no | grade5 | mud | very_horrible | 5 km/h | Scenario: Car - Surfaces should not affect oneway direction Then routability should be diff --git a/features/car/traffic_turn_penalties.feature b/features/car/traffic_turn_penalties.feature index eeeda5272..d2a996367 100644 --- a/features/car/traffic_turn_penalties.feature +++ b/features/car/traffic_turn_penalties.feature @@ -89,9 +89,9 @@ Feature: Traffic - turn penalties And the contract extra arguments "--turn-penalty-file {penalties_file}" When I route I should get | from | to | route | speed | time | - | a | h | ad,dhk,dhk | 52 km/h | 14s +-1 | + | a | h | ad,dhk,dhk | 65 km/h | 11s +-1 | # straight - | i | g | fim,fg,fg | 46 km/h | 15s +-1 | + | i | g | fim,fg,fg | 56 km/h | 15s +-1 | # right - ifg penalty | a | e | ad,def,def | 53 km/h | 14s +-1 | # left - faster because of negative ade penalty diff --git a/features/car/weight.feature b/features/car/weight.feature index c092f8018..5d7f4b201 100644 --- a/features/car/weight.feature +++ b/features/car/weight.feature @@ -20,9 +20,9 @@ Feature: Car - weights | cg | tertiary | | bdf | service | When I route I should get - | from | to | route | speed | - | a | e | abc,cg,efg,efg | 23 km/h | - | a | d | abc,bdf,bdf | 14 km/h | + | from | to | route | speed | weight | + | a | e | abc,cg,efg,efg | 28 km/h | 38 +-1 | + | a | d | abc,bdf,bdf | 18 km/h | 21 +-1 | Scenario: Does not jump off the highway to go down service road Given the node map @@ -37,20 +37,27 @@ Feature: Car - weights | d """ + And the nodes + | node | id | + | a | 1 | + | b | 2 | + | c | 3 | + | d | 4 | + | e | 5 | And the ways - | nodes | highway | - | ab | primary | - | bc | primary | - | cd | primary | - | be | service | - | ec | service | + | nodes | highway | oneway | + | ab | primary | yes | + | bc | primary | yes | + | cd | primary | yes | + | be | service | yes | + | ec | service | yes | And the extract extra arguments "--generate-edge-lookup" And the contract extra arguments "--segment-speed-file {speeds_file}" And the speed file """ - 2,4,8 + 2,5,8 """ When I route I should get - | from | to | route | speed | - | a | d | ab,bc,cd,cd | 14 km/h | - | a | e | ab,be,be | 19 km/h | + | from | to | route | speed | weight | + | a | d | ab,bc,cd,cd | 65 km/h | 12 +-1 | + | a | e | ab,be,be | 14 km/h | 104 | diff --git a/features/step_definitions/routability.js b/features/step_definitions/routability.js index fba1ae419..ce3e2c753 100644 --- a/features/step_definitions/routability.js +++ b/features/step_definitions/routability.js @@ -8,8 +8,8 @@ module.exports = function () { var directions = ['forw','backw','bothw'], headers = new Set(Object.keys(table.hashes()[0])); - if (!directions.some(k => !!headers.has(k))) { - throw new Error('*** routability table must contain either "forw", "backw" or "bothw" column'); + if (!['forw','backw','bothw','forw_rate','backw_rate','bothw_rate'].some(k => !!headers.has(k))) { + throw new Error('*** routability table must contain either "forw", "backw", "bothw", "forw_rate" or "backw_rate" column'); } this.reprocessAndLoadData((e) => { @@ -19,6 +19,19 @@ module.exports = function () { testRoutabilityRow(i, (err, result) => { if (err) return cb(err); + directions.filter(d => headers.has(d + '_rate')).forEach((direction) => { + var want = row[direction + '_rate']; + if (/^\d+ km\/h/.test(want)) { + if (result[direction].rate) { + outputRow[direction + '_rate'] = !isNaN(result[direction].rate) ? + result[direction].rate.toString()+' km/h' : + result[direction].rate.toString() || ''; + } else { + outputRow[direction + '_rate'] = ''; + } + } + }); + directions.filter(d => headers.has(d)).forEach((direction) => { var usingShortcut = false, want = row[direction]; @@ -31,6 +44,8 @@ module.exports = function () { usingShortcut = row[direction]; } + // TODO split out accessible/not accessible value from forw/backw headers + // rename forw/backw to forw/backw_speed switch (true) { case '' === want: case 'x' === want: @@ -75,6 +90,10 @@ module.exports = function () { }); }); + // makes simple a-b request using the given cucumber test routability conditions + // result is an object containing the calculated values for 'rate', 'status', + // 'time', 'distance', and 'speed' for forwards and backwards routing, as well as + // a bothw object that diffs forwards/backwards var testRoutabilityRow = (i, cb) => { var result = {}; @@ -98,6 +117,7 @@ module.exports = function () { if (r.route.split(',')[0] === util.format('w%d', i)) { r.time = r.json.routes[0].duration; r.distance = r.json.routes[0].distance; + r.rate = Math.round(r.distance / r.json.routes[0].weight) r.speed = r.time > 0 ? parseInt(3.6 * r.distance / r.time) : null; } else { r.status = null; @@ -133,7 +153,7 @@ module.exports = function () { scb(); }; - ['status', 'time', 'distance', 'speed'].forEach((key) => { + ['rate', 'status', 'time', 'distance', 'speed'].forEach((key) => { sq.defer(parseRes, key); }); diff --git a/features/support/shared_steps.js b/features/support/shared_steps.js index 6a66376b7..2ed49d87d 100644 --- a/features/support/shared_steps.js +++ b/features/support/shared_steps.js @@ -92,7 +92,8 @@ module.exports = function () { } var distance = hasRoute && json.routes[0].distance, - time = hasRoute && json.routes[0].duration; + time = hasRoute && json.routes[0].duration, + weight = hasRoute && json.routes[0].weight; if (headers.has('distance')) { if (row.distance.length) { @@ -104,6 +105,16 @@ module.exports = function () { } } + if (headers.has('weight')) { + if (row.weight.length) { + if (!row.weight.match(/[\d\.]+/)) + return cb(new Error('*** Weight must be specified as a numeric value. (ex: 8)')); + got.weight = instructions ? util.format('%dm', weight) : ''; + } else { + got.weight = ''; + } + } + if (headers.has('time')) { if (!row.time.match(/\d+s/)) return cb(new Error('*** Time must be specied in seconds. (ex: 60s)')); @@ -161,6 +172,7 @@ module.exports = function () { putValue('destinations', destinations); putValue('weight_name', weight_name); putValue('weights', weights); + putValue('weight', weight); } for (var key in row) { diff --git a/profiles/lib/handlers.lua b/profiles/lib/handlers.lua index 69c801c82..ee8bd366b 100644 --- a/profiles/lib/handlers.lua +++ b/profiles/lib/handlers.lua @@ -128,12 +128,15 @@ function Handlers.handle_movables(way,result,data,profile) if bridge_speed and bridge_speed > 0 then local capacity_car = way:get_value_by_key("capacity:car") if capacity_car ~= 0 then + result.forward_mode = profile.default_mode + result.backward_mode = profile.default_mode local duration = way:get_value_by_key("duration") if duration and durationIsValid(duration) then result.duration = math.max( parseDuration(duration), 1 ) + else + result.forward_speed = bridge_speed + result.backward_speed = bridge_speed end - result.forward_speed = bridge_speed - result.backward_speed = bridge_speed end end end @@ -236,7 +239,7 @@ function Handlers.handle_speed(way,result,data,profile) end end - if result.forward_speed == -1 and result.backward_speed == -1 then + if result.forward_speed == -1 and result.backward_speed == -1 and result.duration <= 0 then return false end end @@ -265,7 +268,7 @@ end function Handlers.handle_penalties(way,result,data,profile) -- heavily penalize a way tagged with all HOV lanes -- in order to only route over them if there is no other option - local hov_penalty = 0.1 + local hov_penalty = 1.0 if profile.avoid.hov_lanes then local hov = way:get_value_by_key("hov") local all_lanes_designated = Handlers.has_all_designated_hov_lanes(data.hov_lanes_forward) @@ -317,10 +320,10 @@ function Handlers.handle_penalties(way,result,data,profile) if properties.weight_name == 'routability' then if result.forward_speed > 0 then - result.forward_rate = result.forward_speed * profile.speed_reduction + result.forward_rate = result.forward_speed * penalty end if result.backward_speed > 0 then - result.backward_rate = result.backward_speed * profile.speed_reduction + result.backward_rate = result.backward_speed * penalty end if result.duration > 0 then result.weight = result.duration / penalty @@ -483,6 +486,16 @@ function Handlers.run(handlers,way,result,data,profile) for i,handler in ipairs(handlers) do if Handlers[handler](way,result,data,profile) == false then return false + else + if handler == 'handle_penalties' then +-- io.write('handler: ', handler, '\n') +-- io.write('weight ', result.weight, '\n') +-- io.write('rate ', result.forward_rate, '\n') +-- io.write('duration ', result.duration, '\n') +-- io.write('speed ', result.forward_speed, '\n') + io.write('forward speed ', result.forward_speed) + io.write('forward rate ', result.forward_rate) + end end end end