Skip to content

Commit f393f47

Browse files
committed
Move classes to intersection object and don't emit notifications
1 parent 1e258ed commit f393f47

File tree

10 files changed

+84
-62
lines changed

10 files changed

+84
-62
lines changed

docs/http.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,6 @@ step.
583583
- `destinations`: The destinations of the way. Will be `undefined` if there are no destinations.
584584
- `exits`: The exit numbers or names of the way. Will be `undefined` if there are no exit numbers or names.
585585
- `mode`: A string signifying the mode of transportation.
586-
- `classes`: An array of strings signifying the classes of the road as specified in the profile.
587586
- `maneuver`: A `StepManeuver` object representing the maneuver.
588587
- `intersections`: A list of `Intersection` objects that are passed along the segment, the very first belonging to the StepManeuver
589588
- `rotary_name`: The name for the rotary. Optionally included, if the step is a rotary and a rotary name is available.
@@ -597,7 +596,6 @@ step.
597596
"mode" : "driving",
598597
"duration" : 15.6,
599598
"weight" : 15.6,
600-
"classes": ["toll", "restricted"],
601599
"intersections" : [
602600
{ "bearings" : [ 10, 92, 184, 270 ],
603601
"lanes" : [
@@ -735,6 +733,7 @@ location of the StepManeuver. Further intersections are listed for every cross-w
735733

736734
- `location`: A `[longitude, latitude]` pair describing the location of the turn.
737735
- `bearings`: A list of bearing values (e.g. [0,90,180,270]) that are available at the intersection. The bearings describe all available roads at the intersection. Values are between 0-359 (0=true north)
736+
- `classes`: An array of strings signifying the classes (as specified in the profile) of the road exiting the intersection.
738737
- `entry`: A list of entry flags, corresponding in a 1:1 relationship to the bearings. A value of `true` indicates that the respective road could be entered on a valid route.
739738
`false` indicates that the turn onto the respective road would violate a restriction.
740739
- `in`: index into bearings/entry array. Used to calculate the bearing just before the turn. Namely, the clockwise angle from true north to the
@@ -753,6 +752,7 @@ location of the StepManeuver. Further intersections are listed for every cross-w
753752
"out":2,
754753
"bearings":[60,150,240,330],
755754
"entry":["false","true","true","true"],
755+
"classes": ["toll", "restricted"],
756756
"lanes":{
757757
"indications": ["left", "straight"],
758758
"valid": "false"

features/car/classes.feature

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Feature: Car - Mode flag
1717
| cd | primary | |
1818

1919
When I route I should get
20-
| from | to | route | turns | classes |
21-
| a | d | ab,bc,cd,cd | depart,notification right,notification left,arrive | ,ferry,, |
22-
| d | a | cd,bc,ab,ab | depart,notification right,notification left,arrive | ,ferry,, |
23-
| c | a | bc,ab,ab | depart,notification left,arrive | ferry,, |
24-
| d | b | cd,bc,bc | depart,notification right,arrive | ,ferry,ferry |
25-
| a | c | ab,bc,bc | depart,notification right,arrive | ,ferry,ferry |
26-
| b | d | bc,cd,cd | depart,notification left,arrive | ferry,, |
20+
| from | to | route | turns | classes |
21+
| a | d | ab,bc,cd,cd | depart,notification right,notification left,arrive | [()],[(ferry)],[()],[()] |
22+
| d | a | cd,bc,ab,ab | depart,notification right,notification left,arrive | [()],[(ferry)],[()],[()] |
23+
| c | a | bc,ab,ab | depart,notification left,arrive | [(ferry)],[()],[()] |
24+
| d | b | cd,bc,bc | depart,notification right,arrive | [()],[(ferry)],[()] |
25+
| a | c | ab,bc,bc | depart,notification right,arrive | [()],[(ferry)],[()] |
26+
| b | d | bc,cd,cd | depart,notification left,arrive | [(ferry)],[()],[()] |
2727

2828

2929
Scenario: Car - We tag motorways with a class
@@ -40,10 +40,10 @@ Feature: Car - Mode flag
4040
| cd | primary |
4141

4242
When I route I should get
43-
| from | to | route | turns | classes | # |
44-
| a | d | ab,bc,cd | depart,notification right,arrive | ,motorway, | |
45-
| a | c | ab,bc,bc | depart,notification right,arrive | ,motorway,motorway | |
46-
| b | d | bc,cd | depart,arrive | motorway, | we don't announce when we leave the highway |
43+
| from | to | route | turns | classes |
44+
| a | d | ab,cd | depart,arrive | [(),(motorway),()],[()] |
45+
| a | c | ab,bc | depart,arrive | [(),(motorway)],[()] |
46+
| b | d | bc,cd | depart,arrive | [(motorway),()],[()] |
4747

4848
Scenario: Car - We tag motorway_link with a class
4949
Given the node map
@@ -59,10 +59,10 @@ Feature: Car - Mode flag
5959
| cd | primary |
6060

6161
When I route I should get
62-
| from | to | route | turns | classes | # |
63-
| a | d | ab,bc,cd | depart,on ramp right,arrive | ,motorway, | notification replaced by on-ramp |
64-
| a | c | ab,bc,bc | depart,on ramp right,arrive | ,motorway,motorway | " " |
65-
| b | d | bc,cd | depart,arrive | motorway, | no announcement |
62+
| from | to | route | turns | classes | # |
63+
| a | d | ab,bc,cd | depart,on ramp right,arrive | [()],[(motorway),()],[()] | on-ramp at class change |
64+
| a | c | ab,bc,bc | depart,on ramp right,arrive | [()],[(motorway)],[()] | " " |
65+
| b | d | bc,cd | depart,arrive | [(motorway),()],[()] | no announcement |
6666

6767

6868
Scenario: Car - We tag restricted with a class
@@ -79,8 +79,8 @@ Feature: Car - Mode flag
7979
| cd | primary | |
8080

8181
When I route I should get
82-
| from | to | route | turns | classes |
83-
| a | d | ab,bc,cd | depart,notification right,arrive| restricted,motorway;restricted, |
82+
| from | to | route | turns | classes |
83+
| a | d | ab,cd | depart,arrive| [(restricted),(motorway,restricted),()],[()] |
8484

8585
Scenario: Car - We toll restricted with a class
8686
Given the node map
@@ -96,6 +96,32 @@ Feature: Car - Mode flag
9696
| cd | primary | |
9797

9898
When I route I should get
99-
| from | to | route | turns | classes |
100-
| a | d | ab,bc,cd | depart,notification right,arrive | toll,motorway;toll, |
99+
| from | to | route | turns | classes |
100+
| a | d | ab,cd | depart,arrive | [(toll),(motorway,toll),()],[()] |
101+
102+
Scenario: Car - From roundabout on toll road
103+
Given the node map
104+
"""
105+
c
106+
/ \
107+
a---b d---f
108+
\ /
109+
e
110+
|
111+
g
112+
"""
113+
114+
And the ways
115+
| nodes | oneway | highway | junction | toll |
116+
| ab | yes | primary | | |
117+
| cb | yes | primary | roundabout | |
118+
| dc | yes | primary | roundabout | |
119+
| be | yes | primary | roundabout | |
120+
| ed | yes | motorway| roundabout | |
121+
| eg | yes | primary | | |
122+
| df | yes | motorway| | yes |
123+
124+
When I route I should get
125+
| from | to | route | turns | classes |
126+
| a | f | ab,df,df | depart,roundabout-exit-2,arrive | [()],[(),(motorway),(toll,motorway)],[()] |
101127

features/car/destination.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ Feature: Car - Destination only, no passing through
2323
When I route I should get
2424
| from | to | route |
2525
| a | b | ab,ab |
26-
| a | c | ab,bcd,bcd |
26+
| a | c | ab,bcd |
2727
| a | d | ab,bcd,bcd |
2828
| a | e | axye,axye |
2929
| e | d | de,de |
30-
| e | c | de,bcd,bcd |
30+
| e | c | de,bcd |
3131
| e | b | de,bcd,bcd |
3232
| e | a | axye,axye |
3333

@@ -51,12 +51,12 @@ Feature: Car - Destination only, no passing through
5151
When I route I should get
5252
| from | to | route |
5353
| a | b | ab,ab |
54-
| a | c | ab,bc,bc |
55-
| a | d | ab,bc,cd |
54+
| a | c | ab,bc |
55+
| a | d | ab,cd |
5656
| a | e | axye,axye |
5757
| e | d | de,de |
58-
| e | c | de,cd,cd |
59-
| e | b | de,cd,bc |
58+
| e | c | de,cd |
59+
| e | b | de,bc |
6060
| e | a | axye,axye |
6161

6262
Scenario: Car - Routing inside a destination only area

features/support/route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ module.exports = function () {
261261
};
262262

263263
this.classesList = (instructions) => {
264-
return this.extractInstructionList(instructions, s => s.classes ? s.classes.join(';') : '');
264+
return this.extractInstructionList(instructions, s => '[' + s.intersections.map(i => '(' + (i.classes ? i.classes.join(',') : '') + ')').join(',') + ']');
265265
};
266266

267267
this.timeList = (instructions) => {

include/engine/guidance/assemble_steps.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
6363
: target_node.forward_segment_id.id;
6464
const auto target_name_id = facade.GetNameIndex(target_node_id);
6565
const auto target_mode = facade.GetTravelMode(target_node_id);
66-
auto target_classes = facade.GetClasses(facade.GetClassData(target_node_id));
6766

6867
const auto number_of_segments = leg_geometry.GetNumberOfSegments();
6968

@@ -88,7 +87,8 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
8887
IntermediateIntersection::NO_INDEX,
8988
0,
9089
util::guidance::LaneTuple(),
91-
{}};
90+
{},
91+
source_classes};
9292

9393
if (leg_data.size() > 0)
9494
{
@@ -118,7 +118,8 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
118118
const auto destinations = facade.GetDestinationsForID(step_name_id);
119119
const auto exits = facade.GetExitsForID(step_name_id);
120120
const auto distance = leg_geometry.segment_distances[segment_index];
121-
auto classes = facade.GetClasses(path_point.classes);
121+
// intersections contain the classes of exiting road
122+
intersection.classes = facade.GetClasses(path_point.classes);
122123

123124
steps.push_back(RouteStep{step_name_id,
124125
name.to_string(),
@@ -135,8 +136,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
135136
maneuver,
136137
leg_geometry.FrontIndex(segment_index),
137138
leg_geometry.BackIndex(segment_index) + 1,
138-
{intersection},
139-
std::move(classes)});
139+
{intersection}});
140140

141141
if (leg_data_index + 1 < leg_data.size())
142142
{
@@ -196,6 +196,8 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
196196
const auto distance = leg_geometry.segment_distances[segment_index];
197197
const EdgeWeight duration = segment_duration + target_duration;
198198
const EdgeWeight weight = segment_weight + target_weight;
199+
// intersections contain the classes of exiting road
200+
intersection.classes = facade.GetClasses(facade.GetClassData(target_node_id));
199201
BOOST_ASSERT(duration >= 0);
200202
steps.push_back(RouteStep{step_name_id,
201203
facade.GetNameForID(step_name_id).to_string(),
@@ -212,8 +214,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
212214
maneuver,
213215
leg_geometry.FrontIndex(segment_index),
214216
leg_geometry.BackIndex(segment_index) + 1,
215-
{intersection},
216-
std::move(target_classes)});
217+
{intersection}});
217218
}
218219
// In this case the source + target are on the same edge segment
219220
else
@@ -255,8 +256,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
255256
std::move(maneuver),
256257
leg_geometry.FrontIndex(segment_index),
257258
leg_geometry.BackIndex(segment_index) + 1,
258-
{intersection},
259-
std::move(source_classes)});
259+
{intersection}});
260260
}
261261

262262
BOOST_ASSERT(segment_index == number_of_segments - 1);
@@ -269,6 +269,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
269269
0,
270270
IntermediateIntersection::NO_INDEX,
271271
util::guidance::LaneTuple(),
272+
{},
272273
{}};
273274

274275
// This step has length zero, the only reason we need it is the target location
@@ -295,8 +296,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
295296
std::move(maneuver),
296297
leg_geometry.locations.size() - 1,
297298
leg_geometry.locations.size(),
298-
{intersection},
299-
std::move(target_classes)});
299+
{intersection}});
300300

301301
BOOST_ASSERT(steps.front().intersections.size() == 1);
302302
BOOST_ASSERT(steps.front().intersections.front().bearings.size() == 1);

include/engine/guidance/route_step.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct IntermediateIntersection
4242
// turn lane information
4343
util::guidance::LaneTuple lanes;
4444
extractor::guidance::TurnLaneDescription lane_description;
45+
std::vector<std::string> classes;
4546
};
4647

4748
inline IntermediateIntersection getInvalidIntersection()
@@ -52,6 +53,7 @@ inline IntermediateIntersection getInvalidIntersection()
5253
IntermediateIntersection::NO_INDEX,
5354
IntermediateIntersection::NO_INDEX,
5455
util::guidance::LaneTuple(),
56+
{},
5557
{}};
5658
}
5759

@@ -74,7 +76,6 @@ struct RouteStep
7476
std::size_t geometry_begin;
7577
std::size_t geometry_end;
7678
std::vector<IntermediateIntersection> intersections;
77-
std::vector<std::string> classes;
7879

7980
// remove all information from the route step, marking it as invalid (used to indicate empty
8081
// steps to be removed).
@@ -128,7 +129,6 @@ inline void RouteStep::Invalidate()
128129
geometry_end = 0;
129130
intersections.clear();
130131
intersections.push_back(getInvalidIntersection());
131-
classes.clear();
132132
}
133133

134134
// Elongate by another step in front

src/engine/api/json_factory.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,18 @@ util::json::Object makeIntersection(const guidance::IntermediateIntersection &in
234234
if (detail::hasValidLanes(intersection))
235235
result.values["lanes"] = detail::lanesFromIntersection(intersection);
236236

237+
if (!intersection.classes.empty())
238+
{
239+
util::json::Array classes;
240+
classes.values.reserve(intersection.classes.size());
241+
std::transform(
242+
intersection.classes.begin(),
243+
intersection.classes.end(),
244+
std::back_inserter(classes.values),
245+
[](const std::string &class_name) { return util::json::String{class_name}; });
246+
result.values["classes"] = std::move(classes);
247+
}
248+
237249
return result;
238250
}
239251

@@ -265,18 +277,6 @@ util::json::Object makeRouteStep(guidance::RouteStep step, util::json::Value geo
265277
route_step.values["maneuver"] = makeStepManeuver(std::move(step.maneuver));
266278
route_step.values["geometry"] = std::move(geometry);
267279

268-
if (!step.classes.empty())
269-
{
270-
util::json::Array classes;
271-
classes.values.reserve(step.classes.size());
272-
std::transform(
273-
step.classes.begin(),
274-
step.classes.end(),
275-
std::back_inserter(classes.values),
276-
[](const std::string &class_name) { return util::json::String{class_name}; });
277-
route_step.values["classes"] = std::move(classes);
278-
}
279-
280280
util::json::Array intersections;
281281
intersections.values.reserve(step.intersections.size());
282282
std::transform(step.intersections.begin(),

src/engine/guidance/post_processing.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,6 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
486486
auto &new_next_to_last = *(steps.end() - 2);
487487
next_to_last_step.AdaptStepSignage(new_next_to_last);
488488
next_to_last_step.mode = new_next_to_last.mode;
489-
next_to_last_step.classes = new_next_to_last.classes;
490489
// the geometry indices of the last step are already correct;
491490
}
492491
else if (util::coordinate_calculation::haversineDistance(

src/extractor/guidance/intersection_handler.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t
8888
// handle travel modes:
8989
const auto in_mode = node_based_graph.GetEdgeData(via_edge).travel_mode;
9090
const auto out_mode = node_based_graph.GetEdgeData(road.eid).travel_mode;
91-
const auto in_classes = node_based_graph.GetEdgeData(via_edge).classes;
92-
const auto out_classes = node_based_graph.GetEdgeData(road.eid).classes;
93-
// if we just lose class flags we don't want to notify
94-
const auto needs_notification = in_mode != out_mode || !isSubset(out_classes, in_classes);
91+
const auto needs_notification = in_mode != out_mode;
9592

9693
if (type == TurnType::Turn)
9794
{

0 commit comments

Comments
 (0)