diff --git a/features/testbot/penalty.feature b/features/testbot/penalty.feature index bcb4d7a8b6d..8e4a081e596 100644 --- a/features/testbot/penalty.feature +++ b/features/testbot/penalty.feature @@ -5,26 +5,60 @@ Feature: Penalties Background: Given the profile "testbot" + # one OSM way through the obstacle (test graph compressor) Scenario: Traffic signals should incur a delay, without changing distance Given the node map """ a b c d e f + g h i """ And the nodes | node | highway | | e | traffic_signals | + | h | crossing | And the ways | nodes | | abc | | def | + | ghi | When I route I should get | from | to | route | time | distance | | a | c | abc,abc | 20s +-1 | 200m +-1 | | d | f | def,def | 27s +-1 | 200m +-1 | + | g | i | ghi,ghi | 20s +-1 | 200m +-1 | + + # two OSM ways connected at the obstacle + Scenario: Traffic signals should incur a delay, without changing distance + Given the node map + """ + a b c + d e f + g h i + """ + + And the nodes + | node | highway | + | e | traffic_signals | + | h | crossing | + + And the ways + | nodes | + | ab | + | bc | + | de | + | ef | + | gh | + | hi | + + When I route I should get + | from | to | route | time | distance | + | a | c | ab,bc | 20s +-1 | 200m +-1 | + | d | f | de,ef | 27s +-1 | 200m +-1 | + | g | i | gh,hi | 20s +-1 | 200m +-1 | # Penalties not on the phantom nodes Scenario: Traffic signals should incur a delay, without changing distance diff --git a/include/extractor/extraction_turn.hpp b/include/extractor/extraction_turn.hpp index a779c920ed0..dd0673ca27b 100644 --- a/include/extractor/extraction_turn.hpp +++ b/include/extractor/extraction_turn.hpp @@ -147,11 +147,12 @@ struct ExtractionTurn const ExtractionTurnLeg::EdgeData &source_edge, const ExtractionTurnLeg::EdgeData &target_edge, const std::vector &roads_on_the_right, - const std::vector &roads_on_the_left) + const std::vector &roads_on_the_left, + const bool has_traffic_light) : ExtractionTurn{0, 2, false, - true, + has_traffic_light, false, // source false, diff --git a/src/extractor/graph_compressor.cpp b/src/extractor/graph_compressor.cpp index b410b4ab3e2..ab6c7d8621e 100644 --- a/src/extractor/graph_compressor.cpp +++ b/src/extractor/graph_compressor.cpp @@ -265,8 +265,15 @@ void GraphCompressor::Compress(ScriptingEnvironment &scripting_environment, EdgePenalties &penalties) { // generate an artificial turn for the turn penalty generation - ExtractionTurn fake_turn{ - from, via, to, from_edge, to_edge, no_other_roads, no_other_roads}; + ExtractionTurn fake_turn{from, + via, + to, + from_edge, + to_edge, + no_other_roads, + no_other_roads, + scripting_environment.m_obstacle_map.any( + from, via, Obstacle::Type::TrafficSignals)}; scripting_environment.ProcessTurn(fake_turn); penalties.duration += to_alias(fake_turn.duration * SECOND_TO_DECISECOND);