Skip to content

Commit b69d940

Browse files
Fix issue 7296 (#7300)
* Initial commit * add tests --------- Co-authored-by: Patrick Niklaus <patrick.niklaus@gopuff.com>
1 parent e28e439 commit b69d940

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

features/testbot/penalty.feature

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,60 @@ Feature: Penalties
55
Background:
66
Given the profile "testbot"
77

8+
# one OSM way through the obstacle (test graph compressor)
89
Scenario: Traffic signals should incur a delay, without changing distance
910
Given the node map
1011
"""
1112
a b c
1213
d e f
14+
g h i
1315
"""
1416

1517
And the nodes
1618
| node | highway |
1719
| e | traffic_signals |
20+
| h | crossing |
1821

1922
And the ways
2023
| nodes |
2124
| abc |
2225
| def |
26+
| ghi |
2327

2428
When I route I should get
2529
| from | to | route | time | distance |
2630
| a | c | abc,abc | 20s +-1 | 200m +-1 |
2731
| d | f | def,def | 27s +-1 | 200m +-1 |
32+
| g | i | ghi,ghi | 20s +-1 | 200m +-1 |
33+
34+
# two OSM ways connected at the obstacle
35+
Scenario: Traffic signals should incur a delay, without changing distance
36+
Given the node map
37+
"""
38+
a b c
39+
d e f
40+
g h i
41+
"""
42+
43+
And the nodes
44+
| node | highway |
45+
| e | traffic_signals |
46+
| h | crossing |
47+
48+
And the ways
49+
| nodes |
50+
| ab |
51+
| bc |
52+
| de |
53+
| ef |
54+
| gh |
55+
| hi |
56+
57+
When I route I should get
58+
| from | to | route | time | distance |
59+
| a | c | ab,bc | 20s +-1 | 200m +-1 |
60+
| d | f | de,ef | 27s +-1 | 200m +-1 |
61+
| g | i | gh,hi | 20s +-1 | 200m +-1 |
2862

2963
# Penalties not on the phantom nodes
3064
Scenario: Traffic signals should incur a delay, without changing distance

include/extractor/extraction_turn.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,12 @@ struct ExtractionTurn
147147
const ExtractionTurnLeg::EdgeData &source_edge,
148148
const ExtractionTurnLeg::EdgeData &target_edge,
149149
const std::vector<ExtractionTurnLeg> &roads_on_the_right,
150-
const std::vector<ExtractionTurnLeg> &roads_on_the_left)
150+
const std::vector<ExtractionTurnLeg> &roads_on_the_left,
151+
const bool has_traffic_light)
151152
: ExtractionTurn{0,
152153
2,
153154
false,
154-
true,
155+
has_traffic_light,
155156
false,
156157
// source
157158
false,

src/extractor/graph_compressor.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,15 @@ void GraphCompressor::Compress(ScriptingEnvironment &scripting_environment,
265265
EdgePenalties &penalties)
266266
{
267267
// generate an artificial turn for the turn penalty generation
268-
ExtractionTurn fake_turn{
269-
from, via, to, from_edge, to_edge, no_other_roads, no_other_roads};
268+
ExtractionTurn fake_turn{from,
269+
via,
270+
to,
271+
from_edge,
272+
to_edge,
273+
no_other_roads,
274+
no_other_roads,
275+
scripting_environment.m_obstacle_map.any(
276+
from, via, Obstacle::Type::TrafficSignals)};
270277
scripting_environment.ProcessTurn(fake_turn);
271278
penalties.duration +=
272279
to_alias<EdgeDuration>(fake_turn.duration * SECOND_TO_DECISECOND);

0 commit comments

Comments
 (0)