Fix adding traffic signal penalties during compression (#6419)
Weight and duration penalties are flipped in the lambda function that applies penalties from traffic signals. Duration is in deciseconds, whilst weight is multipled by 10^weight_precision, with weight_precision being 1 by default. Therefore, for default routability profile, the penalties end up being the same, hence why no tests picked this up. If distance weight is used however, it will incorrectly apply an additional penalty to the weight, and not add the traffic signal delay to the duration in the routing graph. To confuse things further, in some API responses the values are correct because they use geometry data instead, but it's still possible that a sub-optimal route was selected. However, given the distance weight is in meters, and the additional penalty per traffic light would be 20, it's unlikely this would have changed the routing results. In any case, we correct the function to apply the arguments correctly.
This commit is contained in:
@@ -66,15 +66,50 @@ Feature: Car - Handle traffic lights
|
||||
| k | traffic_signals | backward |
|
||||
|
||||
When I route I should get
|
||||
| from | to | time | # |
|
||||
| 1 | 2 | 11.1s | no turn with no traffic light |
|
||||
| 2 | 1 | 11.1s | no turn with no traffic light |
|
||||
| 3 | 4 | 13.1s | no turn with traffic light |
|
||||
| 4 | 3 | 13.1s | no turn with traffic light |
|
||||
| 5 | 6 | 13.1s | no turn with traffic light |
|
||||
| 6 | 5 | 11.1s | no turn with no traffic light |
|
||||
| 7 | 8 | 11.1s | no turn with no traffic light |
|
||||
| 8 | 7 | 13.1s | no turn with traffic light |
|
||||
| from | to | time | weight | # |
|
||||
| 1 | 2 | 11.1s | 11.1 | no turn with no traffic light |
|
||||
| 2 | 1 | 11.1s | 11.1 | no turn with no traffic light |
|
||||
| 3 | 4 | 13.1s | 13.1 | no turn with traffic light |
|
||||
| 4 | 3 | 13.1s | 13.1 | no turn with traffic light |
|
||||
| 5 | 6 | 13.1s | 13.1 | no turn with traffic light |
|
||||
| 6 | 5 | 11.1s | 11.1 | no turn with no traffic light |
|
||||
| 7 | 8 | 11.1s | 11.1 | no turn with no traffic light |
|
||||
| 8 | 7 | 13.1s | 13.1 | no turn with traffic light |
|
||||
|
||||
|
||||
Scenario: Car - Traffic signal direction with distance weight
|
||||
Given the profile file "car" initialized with
|
||||
"""
|
||||
profile.properties.weight_name = 'distance'
|
||||
profile.properties.traffic_light_penalty = 100000
|
||||
"""
|
||||
|
||||
Given the node map
|
||||
"""
|
||||
a---b---c
|
||||
1 2
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
d-------f
|
||||
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abc | primary |
|
||||
| adfc | primary |
|
||||
|
||||
And the nodes
|
||||
| node | highway |
|
||||
| b | traffic_signals |
|
||||
|
||||
When I route I should get
|
||||
| from | to | time | distances | weight | # |
|
||||
| 1 | 2 | 100033.2s | 599.9m,0m | 599.8 | goes via the expensive traffic signal |
|
||||
|
||||
|
||||
|
||||
Scenario: Car - Encounters a traffic light
|
||||
|
||||
Reference in New Issue
Block a user