Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions features/testbot/penalty.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions include/extractor/extraction_turn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ struct ExtractionTurn
const ExtractionTurnLeg::EdgeData &source_edge,
const ExtractionTurnLeg::EdgeData &target_edge,
const std::vector<ExtractionTurnLeg> &roads_on_the_right,
const std::vector<ExtractionTurnLeg> &roads_on_the_left)
const std::vector<ExtractionTurnLeg> &roads_on_the_left,
const bool has_traffic_light)
: ExtractionTurn{0,
2,
false,
true,
has_traffic_light,
false,
// source
false,
Expand Down
11 changes: 9 additions & 2 deletions src/extractor/graph_compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<EdgeDuration>(fake_turn.duration * SECOND_TO_DECISECOND);
Expand Down
Loading