Apply traffic light penalty also for non-turns

This commit is contained in:
Patrick Niklaus 2017-04-19 14:47:35 +00:00 committed by Patrick Niklaus
parent c81baae1b9
commit 9974b8b1da
2 changed files with 45 additions and 6 deletions

View File

@ -0,0 +1,39 @@
@routing @car @traffic_light
Feature: Car - Handle traffic lights
Background:
Given the profile "car"
Scenario: Car - Encounters a traffic light
Given the node map
"""
a-1-b-2-c
d-3-e-4-f
g-h-i k-l-m
| |
j n
"""
And the ways
| nodes | highway |
| abc | primary |
| def | primary |
| ghi | primary |
| klm | primary |
| hj | primary |
| ln | primary |
And the nodes
| node | highway |
| e | traffic_signals |
| l | traffic_signals |
When I route I should get
| from | to | time | # |
| 1 | 2 | 11.1s | no turn with no traffic light |
| 3 | 4 | 13.1s | no turn with traffic light |
| g | j | 18.7s | turn with no traffic light |
| k | n | 20.7s | turn with traffic light |

View File

@ -392,21 +392,21 @@ function turn_function (turn)
local turn_penalty = profile.turn_penalty local turn_penalty = profile.turn_penalty
local turn_bias = profile.turn_bias local turn_bias = profile.turn_bias
if turn.has_traffic_light then
turn.duration = profile.traffic_light_penalty
end
if turn.turn_type ~= turn_type.no_turn then if turn.turn_type ~= turn_type.no_turn then
if turn.angle >= 0 then if turn.angle >= 0 then
turn.duration = turn_penalty / (1 + math.exp( -((13 / turn_bias) * turn.angle/180 - 6.5*turn_bias))) turn.duration = turn.duration + turn_penalty / (1 + math.exp( -((13 / turn_bias) * turn.angle/180 - 6.5*turn_bias)))
else else
turn.duration = turn_penalty / (1 + math.exp( -((13 * turn_bias) * -turn.angle/180 - 6.5/turn_bias))) turn.duration = turn.duration + turn_penalty / (1 + math.exp( -((13 * turn_bias) * -turn.angle/180 - 6.5/turn_bias)))
end end
if turn.direction_modifier == direction_modifier.u_turn then if turn.direction_modifier == direction_modifier.u_turn then
turn.duration = turn.duration + profile.u_turn_penalty turn.duration = turn.duration + profile.u_turn_penalty
end end
if turn.has_traffic_light then
turn.duration = turn.duration + profile.traffic_light_penalty
end
-- for distance based routing we don't want to have penalties based on turn angle -- for distance based routing we don't want to have penalties based on turn angle
if properties.weight_name == 'distance' then if properties.weight_name == 'distance' then
turn.weight = 0 turn.weight = 0