~valhalla-routing/+junk/valhalla_2.1.9-0ubuntu1

« back to all changes in this revision

Viewing changes to libvalhalla/test/maneuversbuilder.cc

  • Committer: valhalla
  • Date: 2017-04-24 20:20:53 UTC
  • Revision ID: valhalla@mapzen.com-20170424202053-7o69b9nwx9ee0tw3
PackagingĀ forĀ 2.1.9-0ubuntu1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <string>
 
2
 
 
3
#include "midgard/util.h"
 
4
#include "midgard/logging.h"
 
5
 
 
6
#include "proto/directions_options.pb.h"
 
7
#include "odin/maneuver.h"
 
8
#include "odin/maneuversbuilder.h"
 
9
 
 
10
#include "test.h"
 
11
 
 
12
using namespace std;
 
13
using namespace valhalla::odin;
 
14
using namespace valhalla::midgard;
 
15
 
 
16
namespace {
 
17
 
 
18
// Sub class to test protected methods
 
19
class ManeuversBuilderTest : public ManeuversBuilder {
 
20
 public:
 
21
  ManeuversBuilderTest()
 
22
      : ManeuversBuilder(DirectionsOptions(), nullptr) {
 
23
  }
 
24
 
 
25
  ManeuversBuilderTest(const DirectionsOptions& directions_options,
 
26
                       EnhancedTripPath* etp)
 
27
      : ManeuversBuilder(directions_options, etp) {
 
28
  }
 
29
 
 
30
  void Combine(std::list<Maneuver>& maneuvers) {
 
31
    ManeuversBuilder::Combine(maneuvers);
 
32
  }
 
33
 
 
34
  void CountAndSortExitSigns(std::list<Maneuver>& maneuvers) {
 
35
    ManeuversBuilder::CountAndSortExitSigns(maneuvers);
 
36
  }
 
37
 
 
38
  void SetSimpleDirectionalManeuverType(Maneuver& maneuver) {
 
39
    ManeuversBuilder::SetSimpleDirectionalManeuverType(maneuver, nullptr, nullptr);
 
40
  }
 
41
 
 
42
  TripDirections_Maneuver_CardinalDirection DetermineCardinalDirection(
 
43
      uint32_t heading) {
 
44
    return ManeuversBuilder::DetermineCardinalDirection(heading);
 
45
  }
 
46
 
 
47
  void DetermineRelativeDirection(Maneuver& maneuver) {
 
48
    return ManeuversBuilder::DetermineRelativeDirection(maneuver);
 
49
  }
 
50
 
 
51
  static Maneuver::RelativeDirection DetermineRelativeDirection(
 
52
      uint32_t turn_degree) {
 
53
    return ManeuversBuilder::DetermineRelativeDirection(turn_degree);
 
54
  }
 
55
 
 
56
  bool IsIntersectingForwardEdge(int node_index,
 
57
                                 EnhancedTripPath_Edge* prev_edge,
 
58
                                 EnhancedTripPath_Edge* curr_edge) {
 
59
    return ManeuversBuilder::IsIntersectingForwardEdge(node_index, prev_edge,
 
60
                                                       curr_edge);
 
61
  }
 
62
 
 
63
  EnhancedTripPath* trip_path() {
 
64
    return trip_path_;
 
65
  }
 
66
 
 
67
};
 
68
 
 
69
void TrySetSimpleDirectionalManeuverType(
 
70
    uint32_t turn_degree, TripDirections_Maneuver_Type expected) {
 
71
  DirectionsOptions directions_options;
 
72
  TripPath path;
 
73
  TripPath_Node* node;
 
74
 
 
75
  // node:0
 
76
  node = path.add_node();
 
77
 
 
78
  // node:1
 
79
  node = path.add_node();
 
80
  node->mutable_edge()->set_drive_on_right(true);
 
81
 
 
82
  // node:2 dummy last node
 
83
  node = path.add_node();
 
84
 
 
85
  ManeuversBuilderTest mbTest(directions_options,
 
86
                              static_cast<EnhancedTripPath*>(&path));
 
87
  Maneuver maneuver;
 
88
  maneuver.set_begin_node_index(1);
 
89
  maneuver.set_turn_degree(turn_degree);
 
90
  mbTest.SetSimpleDirectionalManeuverType(maneuver);
 
91
  if (maneuver.type() != expected) {
 
92
    throw std::runtime_error(
 
93
        "Incorrect maneuver type for turn degree="
 
94
            + std::to_string(turn_degree));
 
95
  }
 
96
}
 
97
 
 
98
void TestSetSimpleDirectionalManeuverType() {
 
99
  // Continue lower bound
 
100
  TrySetSimpleDirectionalManeuverType(350,
 
101
                                      TripDirections_Maneuver_Type_kContinue);
 
102
  // Continue middle
 
103
  TrySetSimpleDirectionalManeuverType(0,
 
104
                                      TripDirections_Maneuver_Type_kContinue);
 
105
  // Continue upper bound
 
106
  TrySetSimpleDirectionalManeuverType(10,
 
107
                                      TripDirections_Maneuver_Type_kContinue);
 
108
 
 
109
  // Slight right lower bound
 
110
  TrySetSimpleDirectionalManeuverType(
 
111
      11, TripDirections_Maneuver_Type_kSlightRight);
 
112
  // Slight right middle
 
113
  TrySetSimpleDirectionalManeuverType(
 
114
      28, TripDirections_Maneuver_Type_kSlightRight);
 
115
  // Slight right upper bound
 
116
  TrySetSimpleDirectionalManeuverType(
 
117
      44, TripDirections_Maneuver_Type_kSlightRight);
 
118
 
 
119
  // Right lower bound
 
120
  TrySetSimpleDirectionalManeuverType(45, TripDirections_Maneuver_Type_kRight);
 
121
  // Right middle
 
122
  TrySetSimpleDirectionalManeuverType(90, TripDirections_Maneuver_Type_kRight);
 
123
  // Right upper bound
 
124
  TrySetSimpleDirectionalManeuverType(135, TripDirections_Maneuver_Type_kRight);
 
125
 
 
126
  // Sharp right lower bound
 
127
  TrySetSimpleDirectionalManeuverType(136,
 
128
                                      TripDirections_Maneuver_Type_kSharpRight);
 
129
  // Sharp right middle
 
130
  TrySetSimpleDirectionalManeuverType(158,
 
131
                                      TripDirections_Maneuver_Type_kSharpRight);
 
132
  // Sharp right upper bound
 
133
  TrySetSimpleDirectionalManeuverType(169,
 
134
                                      TripDirections_Maneuver_Type_kSharpRight);
 
135
 
 
136
  // Right side of street driving
 
137
  // Reverse lower bound
 
138
  TrySetSimpleDirectionalManeuverType(170,
 
139
                                      TripDirections_Maneuver_Type_kUturnRight);
 
140
  // Reverse middle
 
141
  TrySetSimpleDirectionalManeuverType(179,
 
142
                                      TripDirections_Maneuver_Type_kUturnRight);
 
143
  // Reverse middle
 
144
  TrySetSimpleDirectionalManeuverType(180,
 
145
                                      TripDirections_Maneuver_Type_kUturnLeft);
 
146
  // Reverse upper bound
 
147
  TrySetSimpleDirectionalManeuverType(190,
 
148
                                      TripDirections_Maneuver_Type_kUturnLeft);
 
149
 
 
150
  // Sharp left lower bound
 
151
  TrySetSimpleDirectionalManeuverType(191,
 
152
                                      TripDirections_Maneuver_Type_kSharpLeft);
 
153
  // Sharp left middle
 
154
  TrySetSimpleDirectionalManeuverType(203,
 
155
                                      TripDirections_Maneuver_Type_kSharpLeft);
 
156
  // Sharp left upper bound
 
157
  TrySetSimpleDirectionalManeuverType(224,
 
158
                                      TripDirections_Maneuver_Type_kSharpLeft);
 
159
 
 
160
  // Left lower bound
 
161
  TrySetSimpleDirectionalManeuverType(225, TripDirections_Maneuver_Type_kLeft);
 
162
  // Left middle
 
163
  TrySetSimpleDirectionalManeuverType(270, TripDirections_Maneuver_Type_kLeft);
 
164
  // Left upper bound
 
165
  TrySetSimpleDirectionalManeuverType(315, TripDirections_Maneuver_Type_kLeft);
 
166
 
 
167
  // Slight left lower bound
 
168
  TrySetSimpleDirectionalManeuverType(316,
 
169
                                      TripDirections_Maneuver_Type_kSlightLeft);
 
170
  // Slight left middle
 
171
  TrySetSimpleDirectionalManeuverType(333,
 
172
                                      TripDirections_Maneuver_Type_kSlightLeft);
 
173
  // Slight left upper bound
 
174
  TrySetSimpleDirectionalManeuverType(349,
 
175
                                      TripDirections_Maneuver_Type_kSlightLeft);
 
176
 
 
177
}
 
178
 
 
179
void TryDetermineCardinalDirection(
 
180
    uint32_t heading, TripDirections_Maneuver_CardinalDirection expected) {
 
181
  ManeuversBuilderTest mbTest;
 
182
  if (mbTest.DetermineCardinalDirection(heading) != expected)
 
183
    throw std::runtime_error("Incorrect cardinal direction");
 
184
}
 
185
 
 
186
void TestDetermineCardinalDirection() {
 
187
  // North lower bound
 
188
  TryDetermineCardinalDirection(
 
189
      337, TripDirections_Maneuver_CardinalDirection_kNorth);
 
190
  // North middle
 
191
  TryDetermineCardinalDirection(
 
192
      0, TripDirections_Maneuver_CardinalDirection_kNorth);
 
193
  // North upper bound
 
194
  TryDetermineCardinalDirection(
 
195
      23, TripDirections_Maneuver_CardinalDirection_kNorth);
 
196
 
 
197
  // Northeast lower bound
 
198
  TryDetermineCardinalDirection(
 
199
      24, TripDirections_Maneuver_CardinalDirection_kNorthEast);
 
200
  // Northeast middle
 
201
  TryDetermineCardinalDirection(
 
202
      45, TripDirections_Maneuver_CardinalDirection_kNorthEast);
 
203
  // Northeast upper bound
 
204
  TryDetermineCardinalDirection(
 
205
      66, TripDirections_Maneuver_CardinalDirection_kNorthEast);
 
206
 
 
207
  // East lower bound
 
208
  TryDetermineCardinalDirection(
 
209
      67, TripDirections_Maneuver_CardinalDirection_kEast);
 
210
  // East middle
 
211
  TryDetermineCardinalDirection(
 
212
      90, TripDirections_Maneuver_CardinalDirection_kEast);
 
213
  // East upper bound
 
214
  TryDetermineCardinalDirection(
 
215
      113, TripDirections_Maneuver_CardinalDirection_kEast);
 
216
 
 
217
  // Southeast lower bound
 
218
  TryDetermineCardinalDirection(
 
219
      114, TripDirections_Maneuver_CardinalDirection_kSouthEast);
 
220
  // Southeast middle
 
221
  TryDetermineCardinalDirection(
 
222
      135, TripDirections_Maneuver_CardinalDirection_kSouthEast);
 
223
  // Southeast upper bound
 
224
  TryDetermineCardinalDirection(
 
225
      156, TripDirections_Maneuver_CardinalDirection_kSouthEast);
 
226
 
 
227
  // South lower bound
 
228
  TryDetermineCardinalDirection(
 
229
      157, TripDirections_Maneuver_CardinalDirection_kSouth);
 
230
  // South middle
 
231
  TryDetermineCardinalDirection(
 
232
      180, TripDirections_Maneuver_CardinalDirection_kSouth);
 
233
  // South upper bound
 
234
  TryDetermineCardinalDirection(
 
235
      203, TripDirections_Maneuver_CardinalDirection_kSouth);
 
236
 
 
237
  // Southwest lower bound
 
238
  TryDetermineCardinalDirection(
 
239
      204, TripDirections_Maneuver_CardinalDirection_kSouthWest);
 
240
  // Southwest middle
 
241
  TryDetermineCardinalDirection(
 
242
      225, TripDirections_Maneuver_CardinalDirection_kSouthWest);
 
243
  // Southwest upper bound
 
244
  TryDetermineCardinalDirection(
 
245
      246, TripDirections_Maneuver_CardinalDirection_kSouthWest);
 
246
 
 
247
  // West lower bound
 
248
  TryDetermineCardinalDirection(
 
249
      247, TripDirections_Maneuver_CardinalDirection_kWest);
 
250
  // West middle
 
251
  TryDetermineCardinalDirection(
 
252
      270, TripDirections_Maneuver_CardinalDirection_kWest);
 
253
  // West upper bound
 
254
  TryDetermineCardinalDirection(
 
255
      293, TripDirections_Maneuver_CardinalDirection_kWest);
 
256
 
 
257
  // Northwest lower bound
 
258
  TryDetermineCardinalDirection(
 
259
      294, TripDirections_Maneuver_CardinalDirection_kNorthWest);
 
260
  // Northwest middle
 
261
  TryDetermineCardinalDirection(
 
262
      315, TripDirections_Maneuver_CardinalDirection_kNorthWest);
 
263
  // Northwest upper bound
 
264
  TryDetermineCardinalDirection(
 
265
      336, TripDirections_Maneuver_CardinalDirection_kNorthWest);
 
266
 
 
267
}
 
268
 
 
269
void TryDetermineRelativeDirection_Maneuver(
 
270
    uint32_t prev_heading, uint32_t curr_heading,
 
271
    const vector<uint32_t>& intersecting_headings,
 
272
    Maneuver::RelativeDirection expected) {
 
273
  DirectionsOptions directions_options;
 
274
  TripPath path;
 
275
  TripPath_Node* node;
 
276
 
 
277
  // node:0
 
278
  node = path.add_node();
 
279
  node->mutable_edge()->set_end_heading(prev_heading);
 
280
 
 
281
  // node:1
 
282
  node = path.add_node();
 
283
  node->mutable_edge()->set_begin_heading(curr_heading);
 
284
  for (auto intersecting_heading : intersecting_headings) {
 
285
    TripPath_IntersectingEdge* xedge = node->add_intersecting_edge();
 
286
    xedge->set_begin_heading(intersecting_heading);
 
287
    xedge->set_driveability(TripPath_Traversability_kBoth);
 
288
  }
 
289
 
 
290
  // node:2 dummy last node
 
291
  node = path.add_node();
 
292
 
 
293
  ManeuversBuilderTest mbTest(directions_options,
 
294
                              static_cast<EnhancedTripPath*>(&path));
 
295
  Maneuver maneuver;
 
296
  maneuver.set_begin_node_index(1);
 
297
  maneuver.set_turn_degree(
 
298
      valhalla::midgard::GetTurnDegree(prev_heading, curr_heading));
 
299
  mbTest.DetermineRelativeDirection(maneuver);
 
300
  if (maneuver.begin_relative_direction() != expected) {
 
301
    throw std::runtime_error(
 
302
        std::string("Incorrect relative direction: ")
 
303
            + std::to_string(static_cast<int>(maneuver.begin_relative_direction()))
 
304
            + " | expected: " + std::to_string(static_cast<int>(expected)));
 
305
  }
 
306
}
 
307
 
 
308
void TestDetermineRelativeDirection_Maneuver() {
 
309
  // Path straight, intersecting straight on the left - thus keep right
 
310
  TryDetermineRelativeDirection_Maneuver(
 
311
      0, 5, { 355 }, Maneuver::RelativeDirection::kKeepRight);
 
312
 
 
313
  // Path straight, intersecting straight on the right - thus keep left
 
314
  TryDetermineRelativeDirection_Maneuver(
 
315
      0, 355, { 5 }, Maneuver::RelativeDirection::kKeepLeft);
 
316
 
 
317
  // Path slight right, intersecting straight on the left - thus keep right
 
318
  TryDetermineRelativeDirection_Maneuver(
 
319
      0, 11, { 0 }, Maneuver::RelativeDirection::kKeepRight);
 
320
 
 
321
  // Path slight right, intersecting straight on the left - thus keep right
 
322
  TryDetermineRelativeDirection_Maneuver(
 
323
      90, 105, { 85 }, Maneuver::RelativeDirection::kKeepRight);
 
324
 
 
325
  // Path slight left, intersecting straight on the right - thus keep left
 
326
  TryDetermineRelativeDirection_Maneuver(
 
327
      0, 345, { 355 }, Maneuver::RelativeDirection::kKeepLeft);
 
328
 
 
329
  // Path slight left, intersecting straight on the right - thus keep left
 
330
  TryDetermineRelativeDirection_Maneuver(
 
331
      270, 255, { 275 }, Maneuver::RelativeDirection::kKeepLeft);
 
332
 
 
333
  // Path slight left, intersecting right and left - thus keep straight
 
334
  TryDetermineRelativeDirection_Maneuver(
 
335
      80, 60, { 157, 337 }, Maneuver::RelativeDirection::kKeepStraight);
 
336
 
 
337
  // Path sharp right, intersecting right and left - thus right
 
338
  TryDetermineRelativeDirection_Maneuver(180, 339, { 355, 270, 180, 90, 10 },
 
339
                                         Maneuver::RelativeDirection::kRight);
 
340
 
 
341
  // Path sharp left, intersecting right and left - thus left
 
342
  TryDetermineRelativeDirection_Maneuver(180, 21, { 90, 180, 270, 352, 355, 5 },
 
343
                                         Maneuver::RelativeDirection::kLeft);
 
344
 
 
345
  // Path reverse right, intersecting right and left - thus reverse
 
346
  TryDetermineRelativeDirection_Maneuver(180, 352, { 355, 270, 180, 90, 10 },
 
347
                                         Maneuver::RelativeDirection::KReverse);
 
348
 
 
349
  // Path reverse left, intersecting right and left - thus reverse
 
350
  TryDetermineRelativeDirection_Maneuver(180, 15, { 355, 270, 180, 90, 10 },
 
351
                                         Maneuver::RelativeDirection::KReverse);
 
352
 
 
353
}
 
354
 
 
355
void TryDetermineRelativeDirection(uint32_t turn_degree,
 
356
                                   Maneuver::RelativeDirection expected) {
 
357
  if (ManeuversBuilderTest::DetermineRelativeDirection(turn_degree) != expected)
 
358
    throw std::runtime_error("Incorrect relative direction");
 
359
}
 
360
 
 
361
void TestDetermineRelativeDirection() {
 
362
  // kKeepStraight lower bound
 
363
  TryDetermineRelativeDirection(330,
 
364
                                Maneuver::RelativeDirection::kKeepStraight);
 
365
  // kKeepStraight middle
 
366
  TryDetermineRelativeDirection(0, Maneuver::RelativeDirection::kKeepStraight);
 
367
  // kKeepStraight upper bound
 
368
  TryDetermineRelativeDirection(30, Maneuver::RelativeDirection::kKeepStraight);
 
369
 
 
370
  // kRight lower bound
 
371
  TryDetermineRelativeDirection(31, Maneuver::RelativeDirection::kRight);
 
372
  // kRight middle
 
373
  TryDetermineRelativeDirection(90, Maneuver::RelativeDirection::kRight);
 
374
  // kRight upper bound
 
375
  TryDetermineRelativeDirection(159, Maneuver::RelativeDirection::kRight);
 
376
 
 
377
  // KReverse lower bound
 
378
  TryDetermineRelativeDirection(160, Maneuver::RelativeDirection::KReverse);
 
379
  // KReverse middle
 
380
  TryDetermineRelativeDirection(180, Maneuver::RelativeDirection::KReverse);
 
381
  // KReverse upper bound
 
382
  TryDetermineRelativeDirection(200, Maneuver::RelativeDirection::KReverse);
 
383
 
 
384
  // kLeft lower bound
 
385
  TryDetermineRelativeDirection(201, Maneuver::RelativeDirection::kLeft);
 
386
  // kLeft middle
 
387
  TryDetermineRelativeDirection(270, Maneuver::RelativeDirection::kLeft);
 
388
  // kLeft upper bound
 
389
  TryDetermineRelativeDirection(329, Maneuver::RelativeDirection::kLeft);
 
390
 
 
391
}
 
392
 
 
393
void TryCombine(ManeuversBuilderTest& mbTest, std::list<Maneuver>& maneuvers,
 
394
                std::list<Maneuver>& expected_maneuvers) {
 
395
  mbTest.Combine(maneuvers);
 
396
 
 
397
  if (maneuvers.size() != expected_maneuvers.size())
 
398
    throw std::runtime_error("Incorrect maneuver count");
 
399
  for (auto man = maneuvers.begin(), expected_man = expected_maneuvers.begin();
 
400
      man != maneuvers.end(); ++man, ++expected_man) {
 
401
    if (man->type() != expected_man->type())
 
402
      throw std::runtime_error("Incorrect maneuver type: " + std::to_string(man->type()) + "  |  expected: " + std::to_string(expected_man->type()));
 
403
    if (!equal<float>(man->length(), expected_man->length())) {
 
404
      throw std::runtime_error(
 
405
          "Incorrect maneuver distance=" + std::to_string(man->length())
 
406
              + std::string(" | Expected distance=")
 
407
              + std::to_string(expected_man->length()));
 
408
    }
 
409
    if (man->time() != expected_man->time())
 
410
      throw std::runtime_error("Incorrect maneuver time");
 
411
  }
 
412
}
 
413
 
 
414
// Deprecated
 
415
void PopulateEdge(TripPath_Edge* edge, std::vector<std::string> names,
 
416
                  float length, float speed, TripPath_RoadClass road_class,
 
417
                  ::google::protobuf::uint32 begin_heading,
 
418
                  ::google::protobuf::uint32 end_heading,
 
419
                  ::google::protobuf::uint32 begin_shape_index,
 
420
                  ::google::protobuf::uint32 end_shape_index,
 
421
                  TripPath_Traversability traversability, bool ramp,
 
422
                  bool turn_channel, bool ferry, bool rail_ferry, bool toll,
 
423
                  bool unpaved, bool tunnel, bool bridge, bool roundabout,
 
424
                  bool internal_intersection,
 
425
                  ::google::protobuf::uint32 end_node_index,
 
426
                  std::vector<std::string> exit_numbers,
 
427
                  std::vector<std::string> exit_branches,
 
428
                  std::vector<std::string> exit_towards,
 
429
                  std::vector<std::string> exit_names,
 
430
                  TripPath_TravelMode travel_mode = TripPath_TravelMode_kDrive) {
 
431
  for (auto& name : names) {
 
432
    edge->add_name(name);
 
433
  }
 
434
  edge->set_length(length);
 
435
  edge->set_speed(speed);
 
436
  edge->set_road_class(road_class);
 
437
  edge->set_begin_heading(begin_heading);
 
438
  edge->set_end_heading(end_heading);
 
439
  edge->set_begin_shape_index(begin_shape_index);
 
440
  edge->set_end_shape_index(end_shape_index);
 
441
  edge->set_traversability(traversability);
 
442
  if (ramp) {
 
443
    edge->set_use(TripPath_Use::TripPath_Use_kRampUse);
 
444
  } else if (turn_channel) {
 
445
    edge->set_use(TripPath_Use::TripPath_Use_kTurnChannelUse);
 
446
  } else if (ferry) {
 
447
    edge->set_use(TripPath_Use::TripPath_Use_kFerryUse);
 
448
  } else if (rail_ferry) {
 
449
    edge->set_use(TripPath_Use::TripPath_Use_kRailFerryUse);
 
450
  }
 
451
  edge->set_toll(toll);
 
452
  edge->set_unpaved(unpaved);
 
453
  edge->set_tunnel(tunnel);
 
454
  edge->set_bridge(bridge);
 
455
  edge->set_roundabout(roundabout);
 
456
  edge->set_internal_intersection(internal_intersection);
 
457
  TripPath_Sign* sign = edge->mutable_sign();
 
458
  for (auto& exit_number : exit_numbers) {
 
459
    sign->add_exit_number(exit_number);
 
460
  }
 
461
  for (auto& exit_branch : exit_branches) {
 
462
    sign->add_exit_branch(exit_branch);
 
463
  }
 
464
  for (auto& exit_toward : exit_towards) {
 
465
    sign->add_exit_toward(exit_toward);
 
466
  }
 
467
  for (auto& exit_name : exit_names) {
 
468
    sign->add_exit_name(exit_name);
 
469
  }
 
470
  edge->set_travel_mode(travel_mode);
 
471
}
 
472
 
 
473
void PopulateIntersectingEdge(TripPath_IntersectingEdge* xedge,
 
474
                              ::google::protobuf::uint32 begin_heading,
 
475
                               bool prev_name_consistency = false,
 
476
                               bool curr_name_consistency = false,
 
477
                               TripPath_Traversability driveability =
 
478
                                   TripPath_Traversability_kBoth,
 
479
                               TripPath_Traversability cyclability =
 
480
                                   TripPath_Traversability_kBoth,
 
481
                               TripPath_Traversability walkability =
 
482
                                   TripPath_Traversability_kBoth) {
 
483
  xedge->set_begin_heading(begin_heading);
 
484
  xedge->set_driveability(driveability);
 
485
  xedge->set_prev_name_consistency(prev_name_consistency);
 
486
  xedge->set_curr_name_consistency(curr_name_consistency);
 
487
}
 
488
 
 
489
void PopulateManeuver(
 
490
    Maneuver& maneuver, TripDirections_Maneuver_Type type,
 
491
    std::vector<std::string> street_names,
 
492
    std::vector<std::string> begin_street_names,
 
493
    std::vector<std::string> cross_street_names, std::string instruction,
 
494
    float distance, uint32_t time, uint32_t turn_degree,
 
495
    Maneuver::RelativeDirection begin_relative_direction,
 
496
    TripDirections_Maneuver_CardinalDirection begin_cardinal_direction,
 
497
    uint32_t begin_heading, uint32_t end_heading, uint32_t begin_node_index,
 
498
    uint32_t end_node_index, uint32_t begin_shape_index,
 
499
    uint32_t end_shape_index, bool ramp, bool turn_channel, bool ferry,
 
500
    bool rail_ferry, bool roundabout, bool portions_toll, bool portions_unpaved,
 
501
    bool portions_highway, bool internal_intersection,
 
502
    std::vector<std::vector<std::string>> exit_numbers,
 
503
    std::vector<std::vector<std::string>> exit_branches,
 
504
    std::vector<std::vector<std::string>> exit_towards,
 
505
    std::vector<std::vector<std::string>> exit_names,
 
506
    uint32_t internal_right_turn_count = 0,
 
507
    uint32_t internal_left_turn_count = 0,
 
508
    uint32_t roundabout_exit_count = 0,
 
509
    bool fork = false,
 
510
    bool begin_intersecting_edge_name_consistency = false,
 
511
    bool intersecting_forward_edge = false,
 
512
    std::string verbal_transition_alert_instruction = "",
 
513
    std::string verbal_pre_transition_instruction = "",
 
514
    std::string verbal_post_transition_instruction = "",
 
515
    bool tee = false,
 
516
    bool unnamed_walkway = false, bool unnamed_cycleway = false,
 
517
    bool unnamed_mountain_bike_trail = false, float basic_time = 0.0f,
 
518
    bool verbal_multi_cue = false) {
 
519
 
 
520
  maneuver.set_type(type);
 
521
 
 
522
  // street_names
 
523
  maneuver.set_street_names(street_names);
 
524
 
 
525
  // begin_street_names
 
526
  maneuver.set_begin_street_names(begin_street_names);
 
527
 
 
528
  // cross_street_names
 
529
  maneuver.set_cross_street_names(cross_street_names);
 
530
 
 
531
  maneuver.set_instruction(instruction);
 
532
  maneuver.set_length(distance);
 
533
  maneuver.set_time(time);
 
534
  maneuver.set_turn_degree(turn_degree);
 
535
  maneuver.set_begin_relative_direction(begin_relative_direction);
 
536
  maneuver.set_begin_cardinal_direction(begin_cardinal_direction);
 
537
  maneuver.set_begin_heading(begin_heading);
 
538
  maneuver.set_end_heading(end_heading);
 
539
  maneuver.set_begin_node_index(begin_node_index);
 
540
  maneuver.set_end_node_index(end_node_index);
 
541
  maneuver.set_begin_shape_index(begin_shape_index);
 
542
  maneuver.set_end_shape_index(end_shape_index);
 
543
  maneuver.set_ramp(ramp);
 
544
  maneuver.set_turn_channel(turn_channel);
 
545
  maneuver.set_ferry(ferry);
 
546
  maneuver.set_rail_ferry(rail_ferry);
 
547
  maneuver.set_roundabout(roundabout);
 
548
  maneuver.set_portions_toll(portions_toll);
 
549
  maneuver.set_portions_unpaved(portions_unpaved);
 
550
  maneuver.set_portions_highway(portions_highway);
 
551
  maneuver.set_internal_intersection(internal_intersection);
 
552
 
 
553
  // exit_numbers
 
554
  std::vector<Sign>* exit_number_list = maneuver.mutable_signs()
 
555
      ->mutable_exit_number_list();
 
556
  for (auto& sign_items : exit_numbers) {
 
557
    exit_number_list->emplace_back(sign_items[0]);
 
558
    Sign& sign = exit_number_list->back();
 
559
    sign.set_consecutive_count(std::stoi(sign_items[1]));
 
560
  }
 
561
 
 
562
  // exit_branches,
 
563
  std::vector<Sign>* exit_branch_list = maneuver.mutable_signs()
 
564
      ->mutable_exit_branch_list();
 
565
  for (auto& sign_items : exit_branches) {
 
566
    exit_branch_list->emplace_back(sign_items[0]);
 
567
    Sign& sign = exit_branch_list->back();
 
568
    sign.set_consecutive_count(std::stoi(sign_items[1]));
 
569
  }
 
570
 
 
571
  //  exit_towards,
 
572
  std::vector<Sign>* exit_toward_list = maneuver.mutable_signs()
 
573
      ->mutable_exit_toward_list();
 
574
  for (auto& sign_items : exit_towards) {
 
575
    exit_toward_list->emplace_back(sign_items[0]);
 
576
    Sign& sign = exit_toward_list->back();
 
577
    sign.set_consecutive_count(std::stoi(sign_items[1]));
 
578
  }
 
579
 
 
580
  //  exit_names
 
581
  std::vector<Sign>* exit_name_list = maneuver.mutable_signs()
 
582
      ->mutable_exit_name_list();
 
583
  for (auto& sign_items : exit_names) {
 
584
    exit_name_list->emplace_back(sign_items[0]);
 
585
    Sign& sign = exit_name_list->back();
 
586
    sign.set_consecutive_count(std::stoi(sign_items[1]));
 
587
  }
 
588
 
 
589
  maneuver.set_internal_right_turn_count(internal_right_turn_count);
 
590
  maneuver.set_internal_left_turn_count(internal_left_turn_count);
 
591
  maneuver.set_roundabout_exit_count(roundabout_exit_count);
 
592
  maneuver.set_fork(fork);
 
593
  maneuver.set_begin_intersecting_edge_name_consistency(begin_intersecting_edge_name_consistency);
 
594
  maneuver.set_intersecting_forward_edge(intersecting_forward_edge);
 
595
  maneuver.set_verbal_transition_alert_instruction(verbal_transition_alert_instruction);
 
596
  maneuver.set_verbal_pre_transition_instruction(verbal_pre_transition_instruction);
 
597
  maneuver.set_verbal_post_transition_instruction(verbal_post_transition_instruction);
 
598
  maneuver.set_tee(tee);
 
599
  maneuver.set_unnamed_walkway(unnamed_walkway);
 
600
  maneuver.set_unnamed_cycleway(unnamed_cycleway);
 
601
  maneuver.set_unnamed_mountain_bike_trail(unnamed_mountain_bike_trail);
 
602
  maneuver.set_basic_time(basic_time);
 
603
  maneuver.set_verbal_multi_cue(verbal_multi_cue);
 
604
}
 
605
 
 
606
void TestLeftInternalStraightCombine() {
 
607
  DirectionsOptions directions_options;
 
608
  TripPath path;
 
609
  TripPath_Node* node;
 
610
  TripPath_Edge* edge;
 
611
 
 
612
  ///////////////////////////////////////////////////////////////////////////
 
613
  // node:0
 
614
  node = path.add_node();
 
615
  edge = node->mutable_edge();
 
616
  PopulateEdge(edge, { "Hershey Road", "PA 743", "PA 341 Truck" }, 0.033835,
 
617
               60.000000, TripPath_RoadClass_kSecondary, 158, 180, 0, 3,
 
618
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
619
               { }, { }, { }, { });
 
620
 
 
621
  // node:1
 
622
  node = path.add_node();
 
623
  edge = node->mutable_edge();
 
624
  PopulateEdge(edge, { "Hershey Road", "PA 743 South" }, 0.181000, 60.000000,
 
625
               TripPath_RoadClass_kSecondary, 187, 192, 3, 8,
 
626
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
627
               { }, { }, { }, { });
 
628
 
 
629
  // node:2
 
630
  node = path.add_node();
 
631
  edge = node->mutable_edge();
 
632
  PopulateEdge(edge, { "Hershey Road", "PA 743 South" }, 0.079000, 60.000000,
 
633
               TripPath_RoadClass_kSecondary, 196, 196, 8, 10,
 
634
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
635
               { }, { }, { }, { });
 
636
 
 
637
  // node:3
 
638
  node = path.add_node();
 
639
  edge = node->mutable_edge();
 
640
  PopulateEdge(edge, { "Hershey Road", "PA 743 South" }, 0.160000, 60.000000,
 
641
               TripPath_RoadClass_kSecondary, 198, 198, 10, 13,
 
642
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
643
               { }, { }, { }, { });
 
644
 
 
645
  // node:4 INTERNAL_INTERSECTION
 
646
  node = path.add_node();
 
647
  edge = node->mutable_edge();
 
648
  PopulateEdge(edge, { }, 0.013000, 50.000000, TripPath_RoadClass_kSecondary,
 
649
               118, 118, 13, 14, TripPath_Traversability_kForward, 1, 0, 0, 0, 0,
 
650
               0, 0, 0, 0, 1, 0, { }, { }, { }, { });
 
651
 
 
652
  // node:5
 
653
  node = path.add_node();
 
654
  edge = node->mutable_edge();
 
655
  PopulateEdge(edge, { }, 0.073000, 50.000000, TripPath_RoadClass_kSecondary,
 
656
               127, 127, 14, 15, TripPath_Traversability_kForward, 1, 0, 0, 0, 0,
 
657
               0, 0, 0, 0, 0, 0, { }, { "PA 283 East" }, { "Lancaster" }, { });
 
658
 
 
659
  // node:6
 
660
  node = path.add_node();
 
661
  edge = node->mutable_edge();
 
662
  PopulateEdge(edge, { }, 0.432000, 50.000000, TripPath_RoadClass_kSecondary,
 
663
               127, 130, 15, 20, TripPath_Traversability_kForward, 1, 0, 0, 0, 0,
 
664
               0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
665
 
 
666
  // node:7
 
667
  node = path.add_node();
 
668
  edge = node->mutable_edge();
 
669
  PopulateEdge(edge, { "PA 283 East" }, 0.176467, 105.000000,
 
670
               TripPath_RoadClass_kMotorway, 134, 134, 20, 22,
 
671
               TripPath_Traversability_kForward, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
672
               { }, { }, { }, { });
 
673
 
 
674
  ManeuversBuilderTest mbTest(directions_options,
 
675
                              static_cast<EnhancedTripPath*>(&path));
 
676
 
 
677
  ///////////////////////////////////////////////////////////////////////////
 
678
  // Create maneuver list
 
679
  std::list<Maneuver> maneuvers;
 
680
  maneuvers.emplace_back();
 
681
  Maneuver& maneuver1 = maneuvers.back();
 
682
  PopulateManeuver(maneuver1, TripDirections_Maneuver_Type_kStart, {
 
683
                       "Hershey Road", "PA 743 South" },
 
684
                   { }, { }, "", 0.453835, 28, 0,
 
685
                   Maneuver::RelativeDirection::kNone,
 
686
                   TripDirections_Maneuver_CardinalDirection_kSouth, 158, 198,
 
687
                   0, 4, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
688
 
 
689
  maneuvers.emplace_back();
 
690
  Maneuver& maneuver2 = maneuvers.back();
 
691
  PopulateManeuver(maneuver2, TripDirections_Maneuver_Type_kNone, { }, { }, { },
 
692
                   "", 0.013000, 1, 280, Maneuver::RelativeDirection::kLeft,
 
693
                   TripDirections_Maneuver_CardinalDirection_kSouthEast, 118,
 
694
                   118, 4, 5, 13, 14, 1, 0, 0, 0, 0, 0, 0, 0, 1, { }, { }, { },
 
695
                   { });
 
696
 
 
697
  maneuvers.emplace_back();
 
698
  Maneuver& maneuver3 = maneuvers.back();
 
699
  PopulateManeuver(maneuver3, TripDirections_Maneuver_Type_kRampStraight, { },
 
700
                   { }, { }, "", 0.505000, 36, 9,
 
701
                   Maneuver::RelativeDirection::kKeepStraight,
 
702
                   TripDirections_Maneuver_CardinalDirection_kSouthEast, 127,
 
703
                   130, 5, 7, 14, 20, 1, 0, 0, 0, 0, 0, 0, 0, 0, { }, { {
 
704
                       "PA 283 East", "0" } },
 
705
                   { { "Lancaster", "0" } }, { });
 
706
 
 
707
  maneuvers.emplace_back();
 
708
  Maneuver& maneuver4 = maneuvers.back();
 
709
  PopulateManeuver(maneuver4, TripDirections_Maneuver_Type_kMerge, {
 
710
                       "PA 283 East" },
 
711
                   { }, { }, "", 0.176467, 6, 4,
 
712
                   Maneuver::RelativeDirection::kKeepStraight,
 
713
                   TripDirections_Maneuver_CardinalDirection_kSouthEast, 134,
 
714
                   134, 7, 8, 20, 22, 0, 0, 0, 0, 0, 0, 0, 1, 0, { }, { }, { },
 
715
                   { });
 
716
 
 
717
  maneuvers.emplace_back();
 
718
  Maneuver& maneuver5 = maneuvers.back();
 
719
  PopulateManeuver(maneuver5, TripDirections_Maneuver_Type_kDestination, { },
 
720
                   { }, { }, "", 0.000000, 0, 0,
 
721
                   Maneuver::RelativeDirection::kNone,
 
722
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 8, 8,
 
723
                   22, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
724
 
 
725
  ///////////////////////////////////////////////////////////////////////////
 
726
  // Create expected combined maneuver list
 
727
  std::list<Maneuver> expected_maneuvers;
 
728
 
 
729
  expected_maneuvers.emplace_back();
 
730
  Maneuver& expected_maneuver1 = expected_maneuvers.back();
 
731
  PopulateManeuver(expected_maneuver1, TripDirections_Maneuver_Type_kStart, {
 
732
                       "Hershey Road", "PA 743 South" },
 
733
                   { }, { }, "", 0.453835, 28, 0,
 
734
                   Maneuver::RelativeDirection::kNone,
 
735
                   TripDirections_Maneuver_CardinalDirection_kSouth, 158, 198,
 
736
                   0, 4, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
737
 
 
738
  expected_maneuvers.emplace_back();
 
739
  Maneuver& expected_maneuver2 = expected_maneuvers.back();
 
740
  PopulateManeuver(expected_maneuver2, TripDirections_Maneuver_Type_kRampLeft,
 
741
                   { }, { }, { }, "", 0.518000, 37, 289,
 
742
                   Maneuver::RelativeDirection::kLeft,
 
743
                   TripDirections_Maneuver_CardinalDirection_kSouthEast, 127,
 
744
                   130, 4, 7, 13, 20, 1, 0, 0, 0, 0, 0, 0, 0, 0, { }, { {
 
745
                       "PA 283 East", "0" } },
 
746
                   { { "Lancaster", "0" } }, { });
 
747
 
 
748
  expected_maneuvers.emplace_back();
 
749
  Maneuver& expected_maneuver3 = expected_maneuvers.back();
 
750
  PopulateManeuver(expected_maneuver3, TripDirections_Maneuver_Type_kMerge, {
 
751
                       "PA 283 East" },
 
752
                   { }, { }, "", 0.176467, 6, 4,
 
753
                   Maneuver::RelativeDirection::kKeepStraight,
 
754
                   TripDirections_Maneuver_CardinalDirection_kSouthEast, 134,
 
755
                   134, 7, 8, 20, 22, 0, 0, 0, 0, 0, 0, 0, 1, 0, { }, { }, { },
 
756
                   { });
 
757
 
 
758
  expected_maneuvers.emplace_back();
 
759
  Maneuver& expected_maneuver4 = expected_maneuvers.back();
 
760
  PopulateManeuver(expected_maneuver4,
 
761
                   TripDirections_Maneuver_Type_kDestination, { }, { }, { }, "",
 
762
                   0.000000, 0, 0, Maneuver::RelativeDirection::kNone,
 
763
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 8, 8,
 
764
                   22, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
765
 
 
766
  TryCombine(mbTest, maneuvers, expected_maneuvers);
 
767
}
 
768
 
 
769
void TestStraightInternalLeftCombine() {
 
770
  DirectionsOptions directions_options;
 
771
  TripPath path;
 
772
  TripPath_Node* node;
 
773
  TripPath_Edge* edge;
 
774
 
 
775
  ///////////////////////////////////////////////////////////////////////////
 
776
  // node:0
 
777
  node = path.add_node();
 
778
  edge = node->mutable_edge();
 
779
  PopulateEdge(edge, { "PA 283 West" }, 0.511447, 105.000000,
 
780
               TripPath_RoadClass_kMotorway, 315, 316, 0, 3,
 
781
               TripPath_Traversability_kForward, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
782
               { }, { }, { }, { });
 
783
 
 
784
  // node:1
 
785
  node = path.add_node();
 
786
  edge = node->mutable_edge();
 
787
  PopulateEdge(edge, { }, 0.397000, 50.000000, TripPath_RoadClass_kSecondary,
 
788
               322, 330, 3, 12, TripPath_Traversability_kForward, 1, 0, 0, 0, 0,
 
789
               0, 0, 0, 0, 0, 0, { }, { "PA 743" },
 
790
               { "Hershey", "Elizabethtown" }, { });
 
791
 
 
792
  // node:2
 
793
  node = path.add_node();
 
794
  edge = node->mutable_edge();
 
795
  PopulateEdge(edge, { }, 0.050000, 50.000000, TripPath_RoadClass_kSecondary,
 
796
               308, 292, 12, 17, TripPath_Traversability_kForward, 1, 0, 0, 0, 0,
 
797
               0, 0, 0, 0, 0, 0, { }, { "PA 743 South" }, { "Elizabethtown" },
 
798
               { });
 
799
 
 
800
  // node:3 INTERNAL_INTERSECTION
 
801
  node = path.add_node();
 
802
  edge = node->mutable_edge();
 
803
  PopulateEdge(edge, { }, 0.012000, 50.000000, TripPath_RoadClass_kSecondary,
 
804
               289, 289, 17, 18, TripPath_Traversability_kForward, 1, 0, 0, 0, 0,
 
805
               0, 0, 0, 0, 1, 0, { }, { }, { }, { });
 
806
 
 
807
  // node:4
 
808
  node = path.add_node();
 
809
  edge = node->mutable_edge();
 
810
  PopulateEdge(edge, { "Hershey Road", "PA 743 South" }, 0.160000, 60.000000,
 
811
               TripPath_RoadClass_kSecondary, 198, 198, 18, 21,
 
812
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
813
               { }, { }, { }, { });
 
814
 
 
815
  // node:5
 
816
  node = path.add_node();
 
817
  edge = node->mutable_edge();
 
818
  PopulateEdge(edge, { "Hershey Road", "PA 743 South" }, 0.084000, 60.000000,
 
819
               TripPath_RoadClass_kSecondary, 199, 198, 21, 23,
 
820
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
821
               { }, { }, { }, { });
 
822
 
 
823
  // node:6
 
824
  node = path.add_node();
 
825
  edge = node->mutable_edge();
 
826
  PopulateEdge(edge, { "Hershey Road", "PA 743 South" }, 0.113000, 60.000000,
 
827
               TripPath_RoadClass_kSecondary, 198, 198, 23, 24,
 
828
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
829
               { }, { }, { }, { });
 
830
 
 
831
  // node:7
 
832
  node = path.add_node();
 
833
  edge = node->mutable_edge();
 
834
  PopulateEdge(edge, { "Hershey Road", "PA 743 South" }, 0.129000, 60.000000,
 
835
               TripPath_RoadClass_kSecondary, 196, 196, 24, 25,
 
836
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
837
               { }, { }, { }, { });
 
838
 
 
839
  // node:8
 
840
  node = path.add_node();
 
841
  edge = node->mutable_edge();
 
842
  PopulateEdge(edge, { "Hershey Road", "PA 743 North" }, 0.000000, 60.000000,
 
843
               TripPath_RoadClass_kSecondary, 22, 19, 25, 25,
 
844
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
845
               { }, { }, { }, { });
 
846
 
 
847
  ManeuversBuilderTest mbTest(directions_options,
 
848
                              static_cast<EnhancedTripPath*>(&path));
 
849
 
 
850
  ///////////////////////////////////////////////////////////////////////////
 
851
  // Create maneuver list
 
852
  std::list<Maneuver> maneuvers;
 
853
  maneuvers.emplace_back();
 
854
  Maneuver& maneuver1 = maneuvers.back();
 
855
  PopulateManeuver(maneuver1, TripDirections_Maneuver_Type_kStart, {
 
856
                       "PA 283 West" },
 
857
                   { }, { }, "", 0.511447, 18, 0,
 
858
                   Maneuver::RelativeDirection::kNone,
 
859
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 315,
 
860
                   316, 0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, { }, { }, { },
 
861
                   { });
 
862
 
 
863
  maneuvers.emplace_back();
 
864
  Maneuver& maneuver2 = maneuvers.back();
 
865
  PopulateManeuver(maneuver2, TripDirections_Maneuver_Type_kExitRight, { }, { },
 
866
                   { }, "", 0.397000, 29, 6,
 
867
                   Maneuver::RelativeDirection::kKeepRight,
 
868
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 322,
 
869
                   330, 1, 2, 3, 12, 1, 0, 0, 0, 0, 0, 0, 0, 0, { }, { {
 
870
                       "PA 743", "0" } },
 
871
                   { { "Hershey", "0" }, { "Elizabethtown", "0" } }, { });
 
872
 
 
873
  maneuvers.emplace_back();
 
874
  Maneuver& maneuver3 = maneuvers.back();
 
875
  PopulateManeuver(maneuver3, TripDirections_Maneuver_Type_kRampLeft, { }, { },
 
876
                   { }, "", 0.050000, 4, 338,
 
877
                   Maneuver::RelativeDirection::kKeepLeft,
 
878
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 308,
 
879
                   292, 2, 3, 12, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, { }, { {
 
880
                       "PA 743 South", "0" } },
 
881
                   { { "Elizabethtown", "0" } }, { });
 
882
 
 
883
  maneuvers.emplace_back();
 
884
  Maneuver& maneuver4 = maneuvers.back();
 
885
  PopulateManeuver(maneuver4, TripDirections_Maneuver_Type_kNone, { }, { }, { },
 
886
                   "", 0.012000, 1, 357,
 
887
                   Maneuver::RelativeDirection::kKeepStraight,
 
888
                   TripDirections_Maneuver_CardinalDirection_kWest, 289, 289, 3,
 
889
                   4, 17, 18, 1, 0, 0, 0, 0, 0, 0, 0, 1, { }, { }, { }, { });
 
890
 
 
891
  maneuvers.emplace_back();
 
892
  Maneuver& maneuver5 = maneuvers.back();
 
893
  PopulateManeuver(maneuver5, TripDirections_Maneuver_Type_kLeft, {
 
894
                       "Hershey Road", "PA 743 South" },
 
895
                   { }, { }, "", 0.486000, 30, 269,
 
896
                   Maneuver::RelativeDirection::kLeft,
 
897
                   TripDirections_Maneuver_CardinalDirection_kSouth, 198, 19, 4,
 
898
                   9, 18, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
899
 
 
900
  maneuvers.emplace_back();
 
901
  Maneuver& maneuver6 = maneuvers.back();
 
902
  PopulateManeuver(maneuver6, TripDirections_Maneuver_Type_kDestination, { },
 
903
                   { }, { }, "", 0.000000, 0, 0,
 
904
                   Maneuver::RelativeDirection::kNone,
 
905
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 9, 9,
 
906
                   25, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
907
 
 
908
  ///////////////////////////////////////////////////////////////////////////
 
909
  // Create expected combined maneuver list
 
910
  std::list<Maneuver> expected_maneuvers;
 
911
 
 
912
  expected_maneuvers.emplace_back();
 
913
  Maneuver& expected_maneuver1 = expected_maneuvers.back();
 
914
  PopulateManeuver(expected_maneuver1, TripDirections_Maneuver_Type_kStart, {
 
915
                       "PA 283 West" },
 
916
                   { }, { }, "", 0.511447, 18, 0,
 
917
                   Maneuver::RelativeDirection::kNone,
 
918
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 315,
 
919
                   316, 0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, { }, { }, { },
 
920
                   { });
 
921
 
 
922
  expected_maneuvers.emplace_back();
 
923
  Maneuver& expected_maneuver2 = expected_maneuvers.back();
 
924
  PopulateManeuver(expected_maneuver2, TripDirections_Maneuver_Type_kExitRight,
 
925
                   { }, { }, { }, "", 0.397000, 29, 6,
 
926
                   Maneuver::RelativeDirection::kKeepRight,
 
927
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 322,
 
928
                   330, 1, 2, 3, 12, 1, 0, 0, 0, 0, 0, 0, 0, 0, { }, { {
 
929
                       "PA 743", "0" } },
 
930
                   { { "Hershey", "0" }, { "Elizabethtown", "0" } }, { });
 
931
 
 
932
  expected_maneuvers.emplace_back();
 
933
  Maneuver& expected_maneuver3 = expected_maneuvers.back();
 
934
  PopulateManeuver(expected_maneuver3, TripDirections_Maneuver_Type_kRampLeft,
 
935
                   { }, { }, { }, "", 0.050000, 4, 338,
 
936
                   Maneuver::RelativeDirection::kKeepLeft,
 
937
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 308,
 
938
                   292, 2, 3, 12, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, { }, { {
 
939
                       "PA 743 South", "0" } },
 
940
                   { { "Elizabethtown", "0" } }, { });
 
941
 
 
942
  expected_maneuvers.emplace_back();
 
943
  Maneuver& expected_maneuver4 = expected_maneuvers.back();
 
944
  PopulateManeuver(expected_maneuver4, TripDirections_Maneuver_Type_kLeft, {
 
945
                       "Hershey Road", "PA 743 South" },
 
946
                   { }, { }, "", 0.498000, 31, 266,
 
947
                   Maneuver::RelativeDirection::kLeft,
 
948
                   TripDirections_Maneuver_CardinalDirection_kSouth, 198, 19, 3,
 
949
                   9, 17, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
950
 
 
951
  expected_maneuvers.emplace_back();
 
952
  Maneuver& expected_maneuver5 = expected_maneuvers.back();
 
953
  PopulateManeuver(expected_maneuver5,
 
954
                   TripDirections_Maneuver_Type_kDestination, { }, { }, { }, "",
 
955
                   0.000000, 0, 0, Maneuver::RelativeDirection::kNone,
 
956
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 9, 9,
 
957
                   25, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
958
 
 
959
  TryCombine(mbTest, maneuvers, expected_maneuvers);
 
960
}
 
961
 
 
962
void TestStraightInternalLeftInternalCombine() {
 
963
  DirectionsOptions directions_options;
 
964
  TripPath path;
 
965
  TripPath_Node* node;
 
966
  TripPath_Edge* edge;
 
967
 
 
968
  ///////////////////////////////////////////////////////////////////////////
 
969
  // node:0
 
970
  node = path.add_node();
 
971
  edge = node->mutable_edge();
 
972
  PopulateEdge(edge, { "Broken Land Parkway" }, 0.056148, 72.000000,
 
973
               TripPath_RoadClass_kSecondary, 26, 24, 0, 2,
 
974
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
975
               { }, { }, { }, { });
 
976
 
 
977
  // node:1
 
978
  node = path.add_node();
 
979
  edge = node->mutable_edge();
 
980
  PopulateEdge(edge, { "Broken Land Parkway" }, 0.081000, 72.000000,
 
981
               TripPath_RoadClass_kSecondary, 24, 24, 2, 3,
 
982
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
983
               { }, { }, { }, { });
 
984
 
 
985
  // node:2 INTERNAL_INTERSECTION
 
986
  node = path.add_node();
 
987
  edge = node->mutable_edge();
 
988
  PopulateEdge(edge, { "Broken Land Parkway" }, 0.017000, 72.000000,
 
989
               TripPath_RoadClass_kSecondary, 25, 25, 3, 4,
 
990
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
991
               { }, { }, { }, { });
 
992
 
 
993
  // node:3 INTERNAL_INTERSECTION
 
994
  node = path.add_node();
 
995
  edge = node->mutable_edge();
 
996
  PopulateEdge(edge, { "Snowden River Parkway" }, 0.030000, 60.000000,
 
997
               TripPath_RoadClass_kSecondary, 291, 291, 4, 5,
 
998
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
999
               { }, { }, { }, { });
 
1000
 
 
1001
  // node:4
 
1002
  node = path.add_node();
 
1003
  edge = node->mutable_edge();
 
1004
  PopulateEdge(edge, { "Patuxent Woods Drive" }, 0.059840, 40.000000,
 
1005
               TripPath_RoadClass_kTertiary, 292, 270, 5, 8,
 
1006
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1007
               { }, { }, { }, { });
 
1008
 
 
1009
  ManeuversBuilderTest mbTest(directions_options,
 
1010
                              static_cast<EnhancedTripPath*>(&path));
 
1011
 
 
1012
  ///////////////////////////////////////////////////////////////////////////
 
1013
  // Create maneuver list
 
1014
  std::list<Maneuver> maneuvers;
 
1015
  maneuvers.emplace_back();
 
1016
  Maneuver& maneuver1 = maneuvers.back();
 
1017
  PopulateManeuver(maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1018
                       "Broken Land Parkway" },
 
1019
                   { }, { }, "", 0.137148, 7, 0,
 
1020
                   Maneuver::RelativeDirection::kNone,
 
1021
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 26, 24,
 
1022
                   0, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1023
 
 
1024
  maneuvers.emplace_back();
 
1025
  Maneuver& maneuver2 = maneuvers.back();
 
1026
  PopulateManeuver(maneuver2, TripDirections_Maneuver_Type_kNone, { }, { }, { },
 
1027
                   "", 0.047000, 3, 1,
 
1028
                   Maneuver::RelativeDirection::kKeepStraight,
 
1029
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 25,
 
1030
                   291, 2, 4, 3, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1, { }, { }, { },
 
1031
                   { });
 
1032
 
 
1033
  maneuvers.emplace_back();
 
1034
  Maneuver& maneuver3 = maneuvers.back();
 
1035
  PopulateManeuver(maneuver3, TripDirections_Maneuver_Type_kContinue, {
 
1036
                       "Patuxent Woods Drive" },
 
1037
                   { }, { }, "", 0.059840, 5, 1,
 
1038
                   Maneuver::RelativeDirection::kKeepStraight,
 
1039
                   TripDirections_Maneuver_CardinalDirection_kWest, 292, 270, 4,
 
1040
                   5, 5, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1041
 
 
1042
  maneuvers.emplace_back();
 
1043
  Maneuver& maneuver4 = maneuvers.back();
 
1044
  PopulateManeuver(maneuver4, TripDirections_Maneuver_Type_kDestination, { },
 
1045
                   { }, { }, "", 0.000000, 0, 0,
 
1046
                   Maneuver::RelativeDirection::kNone,
 
1047
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 5, 5,
 
1048
                   8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1049
 
 
1050
  ///////////////////////////////////////////////////////////////////////////
 
1051
  // Create expected combined maneuver list
 
1052
  std::list<Maneuver> expected_maneuvers;
 
1053
 
 
1054
  expected_maneuvers.emplace_back();
 
1055
  Maneuver& expected_maneuver1 = expected_maneuvers.back();
 
1056
  PopulateManeuver(expected_maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1057
                       "Broken Land Parkway" },
 
1058
                   { }, { }, "", 0.137148, 7, 0,
 
1059
                   Maneuver::RelativeDirection::kNone,
 
1060
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 26, 24,
 
1061
                   0, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1062
 
 
1063
  expected_maneuvers.emplace_back();
 
1064
  Maneuver& expected_maneuver2 = expected_maneuvers.back();
 
1065
  PopulateManeuver(expected_maneuver2, TripDirections_Maneuver_Type_kLeft, {
 
1066
                       "Patuxent Woods Drive" },
 
1067
                   { }, { }, "", 0.106840, 8, 268,
 
1068
                   Maneuver::RelativeDirection::kLeft,
 
1069
                   TripDirections_Maneuver_CardinalDirection_kWest, 292, 270, 2,
 
1070
                   5, 3, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1071
 
 
1072
  expected_maneuvers.emplace_back();
 
1073
  Maneuver& expected_maneuver3 = expected_maneuvers.back();
 
1074
  PopulateManeuver(expected_maneuver3,
 
1075
                   TripDirections_Maneuver_Type_kDestination, { }, { }, { }, "",
 
1076
                   0.000000, 0, 0, Maneuver::RelativeDirection::kNone,
 
1077
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 5, 5,
 
1078
                   8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1079
 
 
1080
  TryCombine(mbTest, maneuvers, expected_maneuvers);
 
1081
}
 
1082
 
 
1083
void TestStraightInternalStraightCombine() {
 
1084
  DirectionsOptions directions_options;
 
1085
  TripPath path;
 
1086
  TripPath_Node* node;
 
1087
  TripPath_Edge* edge;
 
1088
 
 
1089
  ///////////////////////////////////////////////////////////////////////////
 
1090
  // node:0
 
1091
  node = path.add_node();
 
1092
  edge = node->mutable_edge();
 
1093
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.120902,
 
1094
               80.000000, TripPath_RoadClass_kTrunk, 59, 94, 0, 5,
 
1095
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1096
               { }, { }, { }, { });
 
1097
 
 
1098
  // node:1
 
1099
  node = path.add_node();
 
1100
  edge = node->mutable_edge();
 
1101
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.086000,
 
1102
               80.000000, TripPath_RoadClass_kTrunk, 94, 94, 5, 8,
 
1103
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1104
               { }, { }, { }, { });
 
1105
 
 
1106
  // node:2 INTERNAL_INTERSECTION
 
1107
  node = path.add_node();
 
1108
  edge = node->mutable_edge();
 
1109
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.018000,
 
1110
               90.000000, TripPath_RoadClass_kTrunk, 96, 96, 8, 9,
 
1111
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
1112
               { }, { }, { }, { });
 
1113
 
 
1114
  // node:3
 
1115
  node = path.add_node();
 
1116
  edge = node->mutable_edge();
 
1117
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.099000,
 
1118
               80.000000, TripPath_RoadClass_kTrunk, 94, 95, 9, 12,
 
1119
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1120
               { }, { }, { }, { });
 
1121
 
 
1122
  // node:4
 
1123
  node = path.add_node();
 
1124
  edge = node->mutable_edge();
 
1125
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.774000,
 
1126
               80.000000, TripPath_RoadClass_kTrunk, 96, 88, 12, 28,
 
1127
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1128
               { }, { }, { }, { });
 
1129
 
 
1130
  // node:5
 
1131
  node = path.add_node();
 
1132
  edge = node->mutable_edge();
 
1133
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.123000,
 
1134
               80.000000, TripPath_RoadClass_kTrunk, 90, 90, 28, 32,
 
1135
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1136
               { }, { }, { }, { });
 
1137
 
 
1138
  // node:6
 
1139
  node = path.add_node();
 
1140
  edge = node->mutable_edge();
 
1141
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.009000,
 
1142
               80.000000, TripPath_RoadClass_kTrunk, 86, 86, 32, 33,
 
1143
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1144
               { }, { }, { }, { });
 
1145
 
 
1146
  // node:7 INTERNAL_INTERSECTION
 
1147
  node = path.add_node();
 
1148
  edge = node->mutable_edge();
 
1149
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.015000,
 
1150
               72.000000, TripPath_RoadClass_kTrunk, 93, 93, 33, 34,
 
1151
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
1152
               { }, { }, { }, { });
 
1153
 
 
1154
  // node:8
 
1155
  node = path.add_node();
 
1156
  edge = node->mutable_edge();
 
1157
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.077000,
 
1158
               72.000000, TripPath_RoadClass_kTrunk, 90, 90, 34, 35,
 
1159
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1160
               { }, { }, { }, { });
 
1161
 
 
1162
  // node:9
 
1163
  node = path.add_node();
 
1164
  edge = node->mutable_edge();
 
1165
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.217965,
 
1166
               72.000000, TripPath_RoadClass_kTrunk, 90, 89, 35, 40,
 
1167
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1168
               { }, { }, { }, { });
 
1169
 
 
1170
  ManeuversBuilderTest mbTest(directions_options,
 
1171
                              static_cast<EnhancedTripPath*>(&path));
 
1172
 
 
1173
  ///////////////////////////////////////////////////////////////////////////
 
1174
  // Create maneuver list
 
1175
  std::list<Maneuver> maneuvers;
 
1176
  maneuvers.emplace_back();
 
1177
  Maneuver& maneuver1 = maneuvers.back();
 
1178
  PopulateManeuver(maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1179
                       "MD 43 East", "White Marsh Boulevard" },
 
1180
                   { }, { }, "", 0.206902, 9, 0,
 
1181
                   Maneuver::RelativeDirection::kNone,
 
1182
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 59, 94,
 
1183
                   0, 2, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1184
 
 
1185
  maneuvers.emplace_back();
 
1186
  Maneuver& maneuver2 = maneuvers.back();
 
1187
  PopulateManeuver(maneuver2, TripDirections_Maneuver_Type_kNone, { }, { }, { },
 
1188
                   "", 0.018000, 1, 2,
 
1189
                   Maneuver::RelativeDirection::kKeepStraight,
 
1190
                   TripDirections_Maneuver_CardinalDirection_kEast, 96, 96, 2,
 
1191
                   3, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 1, { }, { }, { }, { });
 
1192
 
 
1193
  maneuvers.emplace_back();
 
1194
  Maneuver& maneuver3 = maneuvers.back();
 
1195
  PopulateManeuver(maneuver3, TripDirections_Maneuver_Type_kContinue, {
 
1196
                       "MD 43 East", "White Marsh Boulevard" },
 
1197
                   { }, { }, "", 1.005000, 45, 358,
 
1198
                   Maneuver::RelativeDirection::kKeepStraight,
 
1199
                   TripDirections_Maneuver_CardinalDirection_kEast, 94, 86, 3,
 
1200
                   7, 9, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1201
 
 
1202
  maneuvers.emplace_back();
 
1203
  Maneuver& maneuver4 = maneuvers.back();
 
1204
  PopulateManeuver(maneuver4, TripDirections_Maneuver_Type_kNone, { }, { }, { },
 
1205
                   "", 0.015000, 1, 7,
 
1206
                   Maneuver::RelativeDirection::kKeepStraight,
 
1207
                   TripDirections_Maneuver_CardinalDirection_kEast, 93, 93, 7,
 
1208
                   8, 33, 34, 0, 0, 0, 0, 0, 0, 0, 0, 1, { }, { }, { }, { });
 
1209
 
 
1210
  maneuvers.emplace_back();
 
1211
  Maneuver& maneuver5 = maneuvers.back();
 
1212
  PopulateManeuver(maneuver5, TripDirections_Maneuver_Type_kContinue, {
 
1213
                       "MD 43 East", "White Marsh Boulevard" },
 
1214
                   { }, { }, "", 0.294965, 15, 357,
 
1215
                   Maneuver::RelativeDirection::kKeepStraight,
 
1216
                   TripDirections_Maneuver_CardinalDirection_kEast, 90, 89, 8,
 
1217
                   10, 34, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1218
 
 
1219
  maneuvers.emplace_back();
 
1220
  Maneuver& maneuver6 = maneuvers.back();
 
1221
  PopulateManeuver(maneuver6, TripDirections_Maneuver_Type_kDestination, { },
 
1222
                   { }, { }, "", 0.000000, 0, 0,
 
1223
                   Maneuver::RelativeDirection::kNone,
 
1224
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 10,
 
1225
                   10, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1226
 
 
1227
  ///////////////////////////////////////////////////////////////////////////
 
1228
  // Create expected combined maneuver list
 
1229
  std::list<Maneuver> expected_maneuvers;
 
1230
 
 
1231
  expected_maneuvers.emplace_back();
 
1232
  Maneuver& expected_maneuver1 = expected_maneuvers.back();
 
1233
  PopulateManeuver(expected_maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1234
                       "MD 43 East", "White Marsh Boulevard" },
 
1235
                   { }, { }, "", 1.539867, 71, 0,
 
1236
                   Maneuver::RelativeDirection::kNone,
 
1237
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 59, 10,
 
1238
                   0, 10, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1239
 
 
1240
  expected_maneuvers.emplace_back();
 
1241
  Maneuver& expected_maneuver2 = expected_maneuvers.back();
 
1242
  PopulateManeuver(expected_maneuver2,
 
1243
                   TripDirections_Maneuver_Type_kDestination, { }, { }, { }, "",
 
1244
                   0.000000, 0, 0, Maneuver::RelativeDirection::kNone,
 
1245
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 10,
 
1246
                   10, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1247
 
 
1248
  TryCombine(mbTest, maneuvers, expected_maneuvers);
 
1249
}
 
1250
 
 
1251
void TestLeftInternalUturnCombine() {
 
1252
  DirectionsOptions directions_options;
 
1253
  TripPath path;
 
1254
  TripPath_Node* node;
 
1255
  TripPath_Edge* edge;
 
1256
 
 
1257
  ///////////////////////////////////////////////////////////////////////////
 
1258
  // node:0
 
1259
  node = path.add_node();
 
1260
  edge = node->mutable_edge();
 
1261
  PopulateEdge(edge, { "Jonestown Road", "US 22" }, 0.062923, 75.000000,
 
1262
               TripPath_RoadClass_kPrimary, 36, 32, 0, 2,
 
1263
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1264
               { }, { }, { }, { });
 
1265
 
 
1266
  // node:1 TURN_CHANNNEL
 
1267
  node = path.add_node();
 
1268
  edge = node->mutable_edge();
 
1269
  PopulateEdge(edge, { "Devonshire Road" }, 0.013000, 50.000000,
 
1270
               TripPath_RoadClass_kTertiary, 299, 299, 2, 3,
 
1271
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
1272
               { }, { }, { }, { });
 
1273
 
 
1274
  // node:2
 
1275
  node = path.add_node();
 
1276
  edge = node->mutable_edge();
 
1277
  PopulateEdge(edge, { "Jonestown Road", "US 22" }, 0.059697, 75.000000,
 
1278
               TripPath_RoadClass_kPrimary, 212, 221, 3, 5,
 
1279
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1280
               { }, { }, { }, { });
 
1281
 
 
1282
  ManeuversBuilderTest mbTest(directions_options,
 
1283
                              static_cast<EnhancedTripPath*>(&path));
 
1284
 
 
1285
  ///////////////////////////////////////////////////////////////////////////
 
1286
  // Create maneuver list
 
1287
  std::list<Maneuver> maneuvers;
 
1288
  maneuvers.emplace_back();
 
1289
  Maneuver& maneuver1 = maneuvers.back();
 
1290
  PopulateManeuver(maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1291
                       "Jonestown Road", "US 22" },
 
1292
                   { }, { }, "", 0.062923, 3, 0,
 
1293
                   Maneuver::RelativeDirection::kNone,
 
1294
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 36, 32,
 
1295
                   0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1296
 
 
1297
  maneuvers.emplace_back();
 
1298
  Maneuver& maneuver2 = maneuvers.back();
 
1299
  PopulateManeuver(maneuver2, TripDirections_Maneuver_Type_kNone, {
 
1300
                       "Devonshire Road" },
 
1301
                   { }, { }, "", 0.013000, 1, 267,
 
1302
                   Maneuver::RelativeDirection::kLeft,
 
1303
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 299,
 
1304
                   299, 1, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, { }, { }, { },
 
1305
                   { });
 
1306
 
 
1307
  maneuvers.emplace_back();
 
1308
  Maneuver& maneuver3 = maneuvers.back();
 
1309
  PopulateManeuver(maneuver3, TripDirections_Maneuver_Type_kLeft, {
 
1310
                       "Jonestown Road", "US 22" },
 
1311
                   { }, { }, "", 0.059697, 3, 273,
 
1312
                   Maneuver::RelativeDirection::kLeft,
 
1313
                   TripDirections_Maneuver_CardinalDirection_kSouthWest, 212,
 
1314
                   221, 2, 3, 3, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { },
 
1315
                   { });
 
1316
 
 
1317
  maneuvers.emplace_back();
 
1318
  Maneuver& maneuver4 = maneuvers.back();
 
1319
  PopulateManeuver(maneuver4, TripDirections_Maneuver_Type_kDestination, { },
 
1320
                   { }, { }, "", 0.000000, 0, 0,
 
1321
                   Maneuver::RelativeDirection::kNone,
 
1322
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 3, 3,
 
1323
                   5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1324
 
 
1325
  ///////////////////////////////////////////////////////////////////////////
 
1326
  // Create expected combined maneuver list
 
1327
  std::list<Maneuver> expected_maneuvers;
 
1328
 
 
1329
  expected_maneuvers.emplace_back();
 
1330
  Maneuver& expected_maneuver1 = expected_maneuvers.back();
 
1331
  PopulateManeuver(expected_maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1332
                       "Jonestown Road", "US 22" },
 
1333
                   { }, { }, "", 0.062923, 3, 0,
 
1334
                   Maneuver::RelativeDirection::kNone,
 
1335
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 36, 32,
 
1336
                   0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1337
 
 
1338
  expected_maneuvers.emplace_back();
 
1339
  Maneuver& expected_maneuver2 = expected_maneuvers.back();
 
1340
  PopulateManeuver(expected_maneuver2, TripDirections_Maneuver_Type_kUturnLeft,
 
1341
                   { "Jonestown Road", "US 22" }, { }, { "Devonshire Road" },
 
1342
                   "", 0.072697, 4, 180, Maneuver::RelativeDirection::KReverse,
 
1343
                   TripDirections_Maneuver_CardinalDirection_kSouthWest, 212,
 
1344
                   221, 1, 3, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { },
 
1345
                   { });
 
1346
 
 
1347
  expected_maneuvers.emplace_back();
 
1348
  Maneuver& expected_maneuver3 = expected_maneuvers.back();
 
1349
  PopulateManeuver(expected_maneuver3,
 
1350
                   TripDirections_Maneuver_Type_kDestination, { }, { }, { }, "",
 
1351
                   0.000000, 0, 0, Maneuver::RelativeDirection::kNone,
 
1352
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 3, 3,
 
1353
                   5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1354
 
 
1355
  TryCombine(mbTest, maneuvers, expected_maneuvers);
 
1356
}
 
1357
 
 
1358
void TestLeftInternalUturnProperDirectionCombine() {
 
1359
  DirectionsOptions directions_options;
 
1360
  TripPath path;
 
1361
  TripPath_Node* node;
 
1362
  TripPath_Edge* edge;
 
1363
 
 
1364
  ///////////////////////////////////////////////////////////////////////////
 
1365
  // node:0
 
1366
  node = path.add_node();
 
1367
  edge = node->mutable_edge();
 
1368
  PopulateEdge(edge, { "Pulaski Highway", "US 40 East" }, 0.067483, 75.000000,
 
1369
               TripPath_RoadClass_kPrimary, 48, 52, 0, 3,
 
1370
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1371
               { }, { }, { }, { });
 
1372
 
 
1373
  // node:1 TURN_CHANNNEL
 
1374
  node = path.add_node();
 
1375
  edge = node->mutable_edge();
 
1376
  PopulateEdge(edge, { "Moravia Park Drive" }, 0.019000, 60.000000,
 
1377
               TripPath_RoadClass_kSecondary, 317, 317, 3, 4,
 
1378
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
1379
               { }, { }, { }, { });
 
1380
 
 
1381
  // node:2
 
1382
  node = path.add_node();
 
1383
  edge = node->mutable_edge();
 
1384
  PopulateEdge(edge, { "US 40 West", "Pulaski Highway" }, 0.045000, 90.000000,
 
1385
               TripPath_RoadClass_kTrunk, 229, 229, 4, 5,
 
1386
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1387
               { }, { }, { }, { });
 
1388
 
 
1389
  // node:3
 
1390
  node = path.add_node();
 
1391
  edge = node->mutable_edge();
 
1392
  PopulateEdge(edge, { "Pulaski Highway", "US 40 West" }, 0.000000, 75.000000,
 
1393
               TripPath_RoadClass_kPrimary, 229, 229, 5, 5,
 
1394
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1395
               { }, { }, { }, { });
 
1396
 
 
1397
  ManeuversBuilderTest mbTest(directions_options,
 
1398
                              static_cast<EnhancedTripPath*>(&path));
 
1399
 
 
1400
  ///////////////////////////////////////////////////////////////////////////
 
1401
  // Create maneuver list
 
1402
  std::list<Maneuver> maneuvers;
 
1403
  maneuvers.emplace_back();
 
1404
  Maneuver& maneuver1 = maneuvers.back();
 
1405
  PopulateManeuver(maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1406
                       "Pulaski Highway", "US 40 East" },
 
1407
                   { }, { }, "", 0.067483, 3, 0,
 
1408
                   Maneuver::RelativeDirection::kNone,
 
1409
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 48, 52,
 
1410
                   0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { }, 0,
 
1411
                   0);
 
1412
 
 
1413
  maneuvers.emplace_back();
 
1414
  Maneuver& maneuver2 = maneuvers.back();
 
1415
  PopulateManeuver(maneuver2, TripDirections_Maneuver_Type_kNone, {
 
1416
                       "Moravia Park Drive" },
 
1417
                   { }, { }, "", 0.019000, 1, 265,
 
1418
                   Maneuver::RelativeDirection::kLeft,
 
1419
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 317,
 
1420
                   317, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 1, { }, { }, { },
 
1421
                   { }, 0, 1);
 
1422
 
 
1423
  maneuvers.emplace_back();
 
1424
  Maneuver& maneuver3 = maneuvers.back();
 
1425
  PopulateManeuver(maneuver3, TripDirections_Maneuver_Type_kLeft, {
 
1426
                       "US 40 West", "Pulaski Highway" },
 
1427
                   { }, { }, "", 0.045000, 2, 272,
 
1428
                   Maneuver::RelativeDirection::kLeft,
 
1429
                   TripDirections_Maneuver_CardinalDirection_kSouthWest, 229,
 
1430
                   229, 2, 4, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { },
 
1431
                   { }, 0, 1);
 
1432
 
 
1433
  maneuvers.emplace_back();
 
1434
  Maneuver& maneuver4 = maneuvers.back();
 
1435
  PopulateManeuver(maneuver4, TripDirections_Maneuver_Type_kDestination, { },
 
1436
                   { }, { }, "", 0.000000, 0, 0,
 
1437
                   Maneuver::RelativeDirection::kNone,
 
1438
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 4, 4,
 
1439
                   5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { }, 0, 0);
 
1440
 
 
1441
  ///////////////////////////////////////////////////////////////////////////
 
1442
  // Create expected combined maneuver list
 
1443
  std::list<Maneuver> expected_maneuvers;
 
1444
 
 
1445
  expected_maneuvers.emplace_back();
 
1446
  Maneuver& expected_maneuver1 = expected_maneuvers.back();
 
1447
  PopulateManeuver(expected_maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1448
                       "Pulaski Highway", "US 40 East" },
 
1449
                   { }, { }, "", 0.067483, 3, 0,
 
1450
                   Maneuver::RelativeDirection::kNone,
 
1451
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 48, 52,
 
1452
                   0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { }, 0,
 
1453
                   0);
 
1454
 
 
1455
  expected_maneuvers.emplace_back();
 
1456
  Maneuver& expected_maneuver2 = expected_maneuvers.back();
 
1457
  PopulateManeuver(expected_maneuver2, TripDirections_Maneuver_Type_kUturnLeft,
 
1458
                   { "US 40 West", "Pulaski Highway" }, { }, {
 
1459
                       "Moravia Park Drive" },
 
1460
                   "", 0.064000, 3, 177, Maneuver::RelativeDirection::KReverse,
 
1461
                   TripDirections_Maneuver_CardinalDirection_kSouthWest, 229,
 
1462
                   229, 1, 4, 3, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { },
 
1463
                   { }, 0, 1);
 
1464
 
 
1465
  expected_maneuvers.emplace_back();
 
1466
  Maneuver& expected_maneuver3 = expected_maneuvers.back();
 
1467
  PopulateManeuver(expected_maneuver3,
 
1468
                   TripDirections_Maneuver_Type_kDestination, { }, { }, { }, "",
 
1469
                   0.000000, 0, 0, Maneuver::RelativeDirection::kNone,
 
1470
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 4, 4,
 
1471
                   5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { }, 0, 0);
 
1472
 
 
1473
  TryCombine(mbTest, maneuvers, expected_maneuvers);
 
1474
}
 
1475
 
 
1476
void TestStraightInternalLeftInternalStraightInternalUturnCombine() {
 
1477
  DirectionsOptions directions_options;
 
1478
  TripPath path;
 
1479
  TripPath_Node* node;
 
1480
  TripPath_Edge* edge;
 
1481
 
 
1482
  ///////////////////////////////////////////////////////////////////////////
 
1483
  // node:0
 
1484
  node = path.add_node();
 
1485
  edge = node->mutable_edge();
 
1486
  PopulateEdge(edge, { "MD 24", "Vietnam Veterans Memorial Highway" }, 0.071404,
 
1487
               89.000000, TripPath_RoadClass_kTrunk, 335, 334, 0, 2,
 
1488
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1489
               { }, { }, { }, { });
 
1490
 
 
1491
  // node:1 TURN_CHANNNEL
 
1492
  node = path.add_node();
 
1493
  edge = node->mutable_edge();
 
1494
  PopulateEdge(edge, { "MD 24", "Vietnam Veterans Memorial Highway" }, 0.012000,
 
1495
               89.000000, TripPath_RoadClass_kTrunk, 334, 334, 2, 3,
 
1496
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
1497
               { }, { }, { }, { });
 
1498
 
 
1499
  // node:2
 
1500
  node = path.add_node();
 
1501
  edge = node->mutable_edge();
 
1502
  PopulateEdge(edge, { "Bel Air South Parkway" }, 0.025000, 48.000000,
 
1503
               TripPath_RoadClass_kSecondary, 245, 245, 3, 4,
 
1504
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
1505
               { }, { }, { }, { });
 
1506
 
 
1507
  // node:3
 
1508
  node = path.add_node();
 
1509
  edge = node->mutable_edge();
 
1510
  PopulateEdge(edge, { "MD 24", "Vietnam Veterans Memorial Highway" }, 0.012000,
 
1511
               89.000000, TripPath_RoadClass_kTrunk, 153, 153, 4, 5,
 
1512
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
1513
               { }, { }, { }, { });
 
1514
 
 
1515
  // node:4
 
1516
  node = path.add_node();
 
1517
  edge = node->mutable_edge();
 
1518
  PopulateEdge(edge, { "MD 24", "Vietnam Veterans Memorial Highway" }, 0.070695,
 
1519
               89.000000, TripPath_RoadClass_kTrunk, 155, 156, 5, 9,
 
1520
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1521
               { }, { }, { }, { });
 
1522
 
 
1523
  ManeuversBuilderTest mbTest(directions_options,
 
1524
                              static_cast<EnhancedTripPath*>(&path));
 
1525
 
 
1526
  ///////////////////////////////////////////////////////////////////////////
 
1527
  // Create maneuver list
 
1528
  std::list<Maneuver> maneuvers;
 
1529
  maneuvers.emplace_back();
 
1530
  Maneuver& maneuver1 = maneuvers.back();
 
1531
  PopulateManeuver(maneuver1, TripDirections_Maneuver_Type_kStart, { "MD 24",
 
1532
                       "Vietnam Veterans Memorial Highway" },
 
1533
                   { }, { }, "", 0.071404, 3, 0,
 
1534
                   Maneuver::RelativeDirection::kNone,
 
1535
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 335,
 
1536
                   334, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { },
 
1537
                   { });
 
1538
 
 
1539
  maneuvers.emplace_back();
 
1540
  Maneuver& maneuver2 = maneuvers.back();
 
1541
  PopulateManeuver(maneuver2, TripDirections_Maneuver_Type_kNone, {
 
1542
                       "Bel Air South Parkway" },
 
1543
                   { }, { }, "", 0.049000, 2, 0,
 
1544
                   Maneuver::RelativeDirection::kKeepStraight,
 
1545
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 334,
 
1546
                   153, 1, 4, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1, { }, { }, { },
 
1547
                   { });
 
1548
 
 
1549
  maneuvers.emplace_back();
 
1550
  Maneuver& maneuver3 = maneuvers.back();
 
1551
  PopulateManeuver(maneuver3, TripDirections_Maneuver_Type_kContinue, { "MD 24",
 
1552
                       "Vietnam Veterans Memorial Highway" },
 
1553
                   { }, { }, "", 0.070695, 3, 2,
 
1554
                   Maneuver::RelativeDirection::kKeepStraight,
 
1555
                   TripDirections_Maneuver_CardinalDirection_kSouthEast, 155,
 
1556
                   156, 4, 5, 5, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { },
 
1557
                   { });
 
1558
 
 
1559
  maneuvers.emplace_back();
 
1560
  Maneuver& maneuver4 = maneuvers.back();
 
1561
  PopulateManeuver(maneuver4, TripDirections_Maneuver_Type_kDestination, { },
 
1562
                   { }, { }, "", 0.000000, 0, 0,
 
1563
                   Maneuver::RelativeDirection::kNone,
 
1564
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 5, 5,
 
1565
                   9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1566
 
 
1567
  ///////////////////////////////////////////////////////////////////////////
 
1568
  // Create expected combined maneuver list
 
1569
  std::list<Maneuver> expected_maneuvers;
 
1570
 
 
1571
  expected_maneuvers.emplace_back();
 
1572
  Maneuver& expected_maneuver1 = expected_maneuvers.back();
 
1573
  PopulateManeuver(expected_maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1574
                       "MD 24", "Vietnam Veterans Memorial Highway" },
 
1575
                   { }, { }, "", 0.071404, 3, 0,
 
1576
                   Maneuver::RelativeDirection::kNone,
 
1577
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 335,
 
1578
                   334, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { },
 
1579
                   { });
 
1580
 
 
1581
  expected_maneuvers.emplace_back();
 
1582
  Maneuver& expected_maneuver2 = expected_maneuvers.back();
 
1583
  PopulateManeuver(expected_maneuver2, TripDirections_Maneuver_Type_kUturnLeft,
 
1584
                   { "MD 24", "Vietnam Veterans Memorial Highway" }, { }, {
 
1585
                       "Bel Air South Parkway" },
 
1586
                   "", 0.119695, 5, 181, Maneuver::RelativeDirection::KReverse,
 
1587
                   TripDirections_Maneuver_CardinalDirection_kSouthEast, 155,
 
1588
                   156, 1, 5, 2, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { },
 
1589
                   { });
 
1590
 
 
1591
  expected_maneuvers.emplace_back();
 
1592
  Maneuver& expected_maneuver3 = expected_maneuvers.back();
 
1593
  PopulateManeuver(expected_maneuver3,
 
1594
                   TripDirections_Maneuver_Type_kDestination, { }, { }, { }, "",
 
1595
                   0.000000, 0, 0, Maneuver::RelativeDirection::kNone,
 
1596
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 5, 5,
 
1597
                   9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1598
 
 
1599
  TryCombine(mbTest, maneuvers, expected_maneuvers);
 
1600
}
 
1601
 
 
1602
void TestInternalPencilPointUturnProperDirectionCombine() {
 
1603
  DirectionsOptions directions_options;
 
1604
  TripPath path;
 
1605
  TripPath_Node* node;
 
1606
  TripPath_Edge* edge;
 
1607
 
 
1608
  ///////////////////////////////////////////////////////////////////////////
 
1609
  // node:0
 
1610
  node = path.add_node();
 
1611
  edge = node->mutable_edge();
 
1612
  PopulateEdge(edge, { "Stonewall Shops Square" }, 0.027386, 40.000000,
 
1613
               TripPath_RoadClass_kUnclassified, 352, 343, 0, 2,
 
1614
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1615
               { }, { }, { }, { });
 
1616
 
 
1617
  // node:1 TURN_CHANNNEL
 
1618
  node = path.add_node();
 
1619
  edge = node->mutable_edge();
 
1620
  PopulateEdge(edge, { "Old Carolina Road" }, 0.019000, 50.000000,
 
1621
               TripPath_RoadClass_kTertiary, 331, 331, 2, 3,
 
1622
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
1623
               { }, { }, { }, { });
 
1624
 
 
1625
  // node:2
 
1626
  node = path.add_node();
 
1627
  edge = node->mutable_edge();
 
1628
  PopulateEdge(edge, { "Stonewall Shops Square" }, 0.021000, 50.000000,
 
1629
               TripPath_RoadClass_kTertiary, 187, 187, 3, 4,
 
1630
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
 
1631
               { }, { }, { }, { });
 
1632
 
 
1633
  // node:3
 
1634
  node = path.add_node();
 
1635
  edge = node->mutable_edge();
 
1636
  PopulateEdge(edge, { "Stonewall Shops Square" }, 0.025240, 40.000000,
 
1637
               TripPath_RoadClass_kUnclassified, 162, 149, 4, 6,
 
1638
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1639
               { }, { }, { }, { });
 
1640
 
 
1641
  ManeuversBuilderTest mbTest(directions_options,
 
1642
                              static_cast<EnhancedTripPath*>(&path));
 
1643
 
 
1644
  ///////////////////////////////////////////////////////////////////////////
 
1645
  // Create maneuver list
 
1646
  std::list<Maneuver> maneuvers;
 
1647
  maneuvers.emplace_back();
 
1648
  Maneuver& maneuver1 = maneuvers.back();
 
1649
  PopulateManeuver(maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1650
                       "Stonewall Shops Square" },
 
1651
                   { }, { }, "", 0.027386, 2, 0,
 
1652
                   Maneuver::RelativeDirection::kNone,
 
1653
                   TripDirections_Maneuver_CardinalDirection_kNorth, 352, 343,
 
1654
                   0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { }, 0,
 
1655
                   0);
 
1656
 
 
1657
  maneuvers.emplace_back();
 
1658
  Maneuver& maneuver2 = maneuvers.back();
 
1659
  PopulateManeuver(maneuver2, TripDirections_Maneuver_Type_kNone, {
 
1660
                       "Stonewall Shops Square" },
 
1661
                   { }, { }, "", 0.040000, 3, 348,
 
1662
                   Maneuver::RelativeDirection::kKeepStraight,
 
1663
                   TripDirections_Maneuver_CardinalDirection_kNorthWest, 331,
 
1664
                   187, 1, 3, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 1, { }, { }, { },
 
1665
                   { }, 0, 1);
 
1666
 
 
1667
  maneuvers.emplace_back();
 
1668
  Maneuver& maneuver3 = maneuvers.back();
 
1669
  PopulateManeuver(maneuver3, TripDirections_Maneuver_Type_kSlightLeft, {
 
1670
                       "Stonewall Shops Square" },
 
1671
                   { }, { }, "", 0.025240, 2, 335,
 
1672
                   Maneuver::RelativeDirection::kKeepStraight,
 
1673
                   TripDirections_Maneuver_CardinalDirection_kSouth, 162, 149,
 
1674
                   3, 4, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { }, 0,
 
1675
                   0);
 
1676
 
 
1677
  maneuvers.emplace_back();
 
1678
  Maneuver& maneuver4 = maneuvers.back();
 
1679
  PopulateManeuver(maneuver4, TripDirections_Maneuver_Type_kDestination, { },
 
1680
                   { }, { }, "", 0.000000, 0, 0,
 
1681
                   Maneuver::RelativeDirection::kNone,
 
1682
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 4, 4,
 
1683
                   6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { }, 0, 0);
 
1684
 
 
1685
  ///////////////////////////////////////////////////////////////////////////
 
1686
  // Create expected combined maneuver list
 
1687
  std::list<Maneuver> expected_maneuvers;
 
1688
 
 
1689
  expected_maneuvers.emplace_back();
 
1690
  Maneuver& expected_maneuver1 = expected_maneuvers.back();
 
1691
  PopulateManeuver(expected_maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1692
                       "Stonewall Shops Square" },
 
1693
                   { }, { }, "", 0.027386, 2, 0,
 
1694
                   Maneuver::RelativeDirection::kNone,
 
1695
                   TripDirections_Maneuver_CardinalDirection_kNorth, 352, 343,
 
1696
                   0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { }, 0,
 
1697
                   0);
 
1698
 
 
1699
  expected_maneuvers.emplace_back();
 
1700
  Maneuver& expected_maneuver2 = expected_maneuvers.back();
 
1701
  PopulateManeuver(expected_maneuver2, TripDirections_Maneuver_Type_kUturnLeft,
 
1702
                   { "Stonewall Shops Square" }, { }, { }, "", 0.065240, 5, 179,
 
1703
                   Maneuver::RelativeDirection::KReverse,
 
1704
                   TripDirections_Maneuver_CardinalDirection_kSouth, 162, 149,
 
1705
                   1, 4, 2, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { }, 0,
 
1706
                   1);
 
1707
 
 
1708
  expected_maneuvers.emplace_back();
 
1709
  Maneuver& expected_maneuver3 = expected_maneuvers.back();
 
1710
  PopulateManeuver(expected_maneuver3,
 
1711
                   TripDirections_Maneuver_Type_kDestination, { }, { }, { }, "",
 
1712
                   0.000000, 0, 0, Maneuver::RelativeDirection::kNone,
 
1713
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 4, 4,
 
1714
                   6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { }, 0, 0);
 
1715
 
 
1716
  TryCombine(mbTest, maneuvers, expected_maneuvers);
 
1717
}
 
1718
 
 
1719
void TestSimpleRightTurnChannelCombine() {
 
1720
  DirectionsOptions directions_options;
 
1721
  TripPath path;
 
1722
  TripPath_Node* node;
 
1723
  TripPath_Edge* edge;
 
1724
 
 
1725
  ///////////////////////////////////////////////////////////////////////////
 
1726
  // node:0
 
1727
  node = path.add_node();
 
1728
  edge = node->mutable_edge();
 
1729
  PopulateEdge(edge, { "MD 43 East", "White Marsh Boulevard" }, 0.091237,
 
1730
               80.000000, TripPath_RoadClass_kTrunk, 59, 94, 0, 4,
 
1731
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1732
               { }, { }, { }, { });
 
1733
 
 
1734
  // node:1 TURN_CHANNNEL
 
1735
  node = path.add_node();
 
1736
  edge = node->mutable_edge();
 
1737
  PopulateEdge(edge, { }, 0.142000, 113.000000, TripPath_RoadClass_kSecondary,
 
1738
               105, 179, 4, 11, TripPath_Traversability_kBoth, 0, 1, 0, 0, 0, 0,
 
1739
               0, 0, 0, 0, 0, { }, { }, { }, { });
 
1740
 
 
1741
  // node:2
 
1742
  node = path.add_node();
 
1743
  edge = node->mutable_edge();
 
1744
  PopulateEdge(edge, { "Perry Hall Boulevard" }, 0.065867, 64.000000,
 
1745
               TripPath_RoadClass_kSecondary, 188, 188, 11, 14,
 
1746
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1747
               { }, { }, { }, { });
 
1748
 
 
1749
  ManeuversBuilderTest mbTest(directions_options,
 
1750
                              static_cast<EnhancedTripPath*>(&path));
 
1751
 
 
1752
  ///////////////////////////////////////////////////////////////////////////
 
1753
  // Create maneuver list
 
1754
  std::list<Maneuver> maneuvers;
 
1755
  maneuvers.emplace_back();
 
1756
  Maneuver& maneuver1 = maneuvers.back();
 
1757
  PopulateManeuver(maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1758
                       "MD 43 East", "White Marsh Boulevard" },
 
1759
                   { }, { }, "", 0.091237, 4, 0,
 
1760
                   Maneuver::RelativeDirection::kNone,
 
1761
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 59, 94,
 
1762
                   0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1763
 
 
1764
  maneuvers.emplace_back();
 
1765
  Maneuver& maneuver2 = maneuvers.back();
 
1766
  PopulateManeuver(maneuver2, TripDirections_Maneuver_Type_kNone, { }, { }, { },
 
1767
                   "", 0.142000, 5, 11, Maneuver::RelativeDirection::kKeepRight,
 
1768
                   TripDirections_Maneuver_CardinalDirection_kEast, 105, 179, 1,
 
1769
                   2, 4, 11, 0, 1, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1770
 
 
1771
  maneuvers.emplace_back();
 
1772
  Maneuver& maneuver3 = maneuvers.back();
 
1773
  PopulateManeuver(maneuver3, TripDirections_Maneuver_Type_kContinue, {
 
1774
                       "Perry Hall Boulevard" },
 
1775
                   { }, { }, "", 0.065867, 4, 9,
 
1776
                   Maneuver::RelativeDirection::kKeepStraight,
 
1777
                   TripDirections_Maneuver_CardinalDirection_kSouth, 188, 188,
 
1778
                   2, 3, 11, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1779
 
 
1780
  maneuvers.emplace_back();
 
1781
  Maneuver& maneuver4 = maneuvers.back();
 
1782
  PopulateManeuver(maneuver4, TripDirections_Maneuver_Type_kDestination, { },
 
1783
                   { }, { }, "", 0.000000, 0, 0,
 
1784
                   Maneuver::RelativeDirection::kNone,
 
1785
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 3, 3,
 
1786
                   14, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1787
 
 
1788
  ///////////////////////////////////////////////////////////////////////////
 
1789
  // Create expected combined maneuver list
 
1790
  std::list<Maneuver> expected_maneuvers;
 
1791
 
 
1792
  expected_maneuvers.emplace_back();
 
1793
  Maneuver& expected_maneuver1 = expected_maneuvers.back();
 
1794
  PopulateManeuver(expected_maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1795
                       "MD 43 East", "White Marsh Boulevard" },
 
1796
                   { }, { }, "", 0.091237, 4, 0,
 
1797
                   Maneuver::RelativeDirection::kNone,
 
1798
                   TripDirections_Maneuver_CardinalDirection_kNorthEast, 59, 94,
 
1799
                   0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1800
 
 
1801
  expected_maneuvers.emplace_back();
 
1802
  Maneuver& expected_maneuver2 = expected_maneuvers.back();
 
1803
  PopulateManeuver(expected_maneuver2, TripDirections_Maneuver_Type_kRight, {
 
1804
                       "Perry Hall Boulevard" },
 
1805
                   { }, { }, "", 0.207867, 9, 94,
 
1806
                   Maneuver::RelativeDirection::kKeepRight,
 
1807
                   TripDirections_Maneuver_CardinalDirection_kSouth, 188, 188,
 
1808
                   1, 3, 4, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1809
 
 
1810
  expected_maneuvers.emplace_back();
 
1811
  Maneuver& expected_maneuver3 = expected_maneuvers.back();
 
1812
  PopulateManeuver(expected_maneuver3,
 
1813
                   TripDirections_Maneuver_Type_kDestination, { }, { }, { }, "",
 
1814
                   0.000000, 0, 0, Maneuver::RelativeDirection::kNone,
 
1815
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 3, 3,
 
1816
                   14, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { }, { });
 
1817
 
 
1818
  TryCombine(mbTest, maneuvers, expected_maneuvers);
 
1819
}
 
1820
 
 
1821
void TryCountAndSortExitSigns(std::list<Maneuver>& maneuvers,
 
1822
                              std::list<Maneuver>& expected_maneuvers) {
 
1823
  ManeuversBuilderTest mbTest;
 
1824
  mbTest.CountAndSortExitSigns(maneuvers);
 
1825
 
 
1826
  if (maneuvers.size() != expected_maneuvers.size())
 
1827
    throw std::runtime_error("Incorrect maneuver count");
 
1828
  for (auto man = maneuvers.begin(), expected_man = expected_maneuvers.begin();
 
1829
      man != maneuvers.end(); ++man, ++expected_man) {
 
1830
    if (!(man->signs() == expected_man->signs()))
 
1831
      throw std::runtime_error("Maneuver signs do not match expected");
 
1832
  }
 
1833
}
 
1834
 
 
1835
void TestCountAndSortExitSigns() {
 
1836
 
 
1837
  ///////////////////////////////////////////////////////////////////////////
 
1838
  // Create maneuver list
 
1839
  std::list<Maneuver> maneuvers;
 
1840
  maneuvers.emplace_back();
 
1841
  Maneuver& maneuver1 = maneuvers.back();
 
1842
  PopulateManeuver(maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1843
                       "I 81 South", "US 322 West",
 
1844
                       "American Legion Memorial Highway" },
 
1845
                   { }, { }, "", 0.158406, 10, 0,
 
1846
                   Maneuver::RelativeDirection::kNone,
 
1847
                   TripDirections_Maneuver_CardinalDirection_kWest, 262, 270, 0,
 
1848
                   1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, { }, { }, { }, { }, 0, 0,
 
1849
                   0);
 
1850
 
 
1851
  maneuvers.emplace_back();
 
1852
  Maneuver& maneuver2 = maneuvers.back();
 
1853
  PopulateManeuver(maneuver2, TripDirections_Maneuver_Type_kExitRight, {
 
1854
                       "US 322 West" },
 
1855
                   { }, { }, "", 0.348589, 21, 2,
 
1856
                   Maneuver::RelativeDirection::kKeepRight,
 
1857
                   TripDirections_Maneuver_CardinalDirection_kWest, 272, 278, 1,
 
1858
                   2, 2, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, { { "67A-B", "0" } }, { {
 
1859
                       "US 22 East", "0" }, { "PA 230 East", "0" }, {
 
1860
                       "US 22 West", "0" }, { "US 322 West", "0" }, {
 
1861
                       "Cameron Street", "0" } },
 
1862
                   { { "Harrisburg", "0" }, { "Lewistown", "0" }, {
 
1863
                       "State College", "0" } },
 
1864
                   { }, 0, 0, 0);
 
1865
 
 
1866
  maneuvers.emplace_back();
 
1867
  Maneuver& maneuver3 = maneuvers.back();
 
1868
  PopulateManeuver(maneuver3, TripDirections_Maneuver_Type_kExitRight, {
 
1869
                       "US 322 West" },
 
1870
                   { }, { }, "", 0.633177, 39, 8,
 
1871
                   Maneuver::RelativeDirection::kKeepRight,
 
1872
                   TripDirections_Maneuver_CardinalDirection_kWest, 286, 353, 2,
 
1873
                   4, 6, 31, 1, 0, 0, 0, 0, 0, 0, 0, 0, { { "67B", "0" } }, { {
 
1874
                       "US 22 West", "0" }, { "US 322 West", "0" } },
 
1875
                   { { "Lewistown", "0" }, { "State College", "0" } }, { }, 0,
 
1876
                   0, 0);
 
1877
 
 
1878
  maneuvers.emplace_back();
 
1879
  Maneuver& maneuver4 = maneuvers.back();
 
1880
  PopulateManeuver(maneuver4, TripDirections_Maneuver_Type_kMerge, {
 
1881
                       "US 322 West" },
 
1882
                   { }, { }, "", 55.286610, 3319, 358,
 
1883
                   Maneuver::RelativeDirection::kKeepStraight,
 
1884
                   TripDirections_Maneuver_CardinalDirection_kNorth, 351, 348,
 
1885
                   4, 57, 31, 1303, 0, 0, 0, 0, 0, 0, 0, 1, 0, { }, { }, { },
 
1886
                   { }, 0, 0, 0);
 
1887
 
 
1888
  maneuvers.emplace_back();
 
1889
  Maneuver& maneuver5 = maneuvers.back();
 
1890
  PopulateManeuver(maneuver5, TripDirections_Maneuver_Type_kDestination, { },
 
1891
                   { }, { }, "", 0.000000, 0, 0,
 
1892
                   Maneuver::RelativeDirection::kNone,
 
1893
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 57,
 
1894
                   57, 1303, 1303, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { },
 
1895
                   { }, 0, 0, 0);
 
1896
 
 
1897
 
 
1898
  ///////////////////////////////////////////////////////////////////////////
 
1899
  // Create expected combined maneuver list
 
1900
  std::list<Maneuver> expected_maneuvers;
 
1901
 
 
1902
  expected_maneuvers.emplace_back();
 
1903
  Maneuver& expected_maneuver1 = expected_maneuvers.back();
 
1904
  PopulateManeuver(expected_maneuver1, TripDirections_Maneuver_Type_kStart, {
 
1905
                       "I 81 South", "US 322 West",
 
1906
                       "American Legion Memorial Highway" },
 
1907
                   { }, { }, "", 0.158406, 10, 0,
 
1908
                   Maneuver::RelativeDirection::kNone,
 
1909
                   TripDirections_Maneuver_CardinalDirection_kWest, 262, 270, 0,
 
1910
                   1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, { }, { }, { }, { }, 0, 0,
 
1911
                   0);
 
1912
 
 
1913
  expected_maneuvers.emplace_back();
 
1914
  Maneuver& expected_maneuver2 = expected_maneuvers.back();
 
1915
  PopulateManeuver(expected_maneuver2, TripDirections_Maneuver_Type_kExitRight,
 
1916
                   { "US 322 West" }, { }, { }, "", 0.348589, 21, 2,
 
1917
                   Maneuver::RelativeDirection::kKeepRight,
 
1918
                   TripDirections_Maneuver_CardinalDirection_kWest, 272, 278, 1,
 
1919
                   2, 2, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, { { "67A-B", "0" } }, { {
 
1920
                       "US 322 West", "2" }, { "US 22 West", "1" }, {
 
1921
                       "US 22 East", "0" }, { "PA 230 East", "0" }, {
 
1922
                       "Cameron Street", "0" } },
 
1923
                   { { "Lewistown", "1" }, { "State College", "1" }, {
 
1924
                       "Harrisburg", "0" } },
 
1925
                   { }, 0, 0, 0);
 
1926
 
 
1927
  expected_maneuvers.emplace_back();
 
1928
  Maneuver& expected_maneuver3 = expected_maneuvers.back();
 
1929
  PopulateManeuver(expected_maneuver3, TripDirections_Maneuver_Type_kExitRight,
 
1930
                   { "US 322 West" }, { }, { }, "", 0.633177, 39, 8,
 
1931
                   Maneuver::RelativeDirection::kKeepRight,
 
1932
                   TripDirections_Maneuver_CardinalDirection_kWest, 286, 353, 2,
 
1933
                   4, 6, 31, 1, 0, 0, 0, 0, 0, 0, 0, 0, { { "67B", "0" } }, { {
 
1934
                       "US 322 West", "2" }, { "US 22 West", "1" } },
 
1935
                   { { "Lewistown", "1" }, { "State College", "1" } }, { }, 0,
 
1936
                   0, 0);
 
1937
 
 
1938
  expected_maneuvers.emplace_back();
 
1939
  Maneuver& expected_maneuver4 = expected_maneuvers.back();
 
1940
  PopulateManeuver(expected_maneuver4, TripDirections_Maneuver_Type_kMerge, {
 
1941
                       "US 322 West" },
 
1942
                   { }, { }, "", 55.286610, 3319, 358,
 
1943
                   Maneuver::RelativeDirection::kKeepStraight,
 
1944
                   TripDirections_Maneuver_CardinalDirection_kNorth, 351, 348,
 
1945
                   4, 57, 31, 1303, 0, 0, 0, 0, 0, 0, 0, 1, 0, { }, { }, { },
 
1946
                   { }, 0, 0, 0);
 
1947
 
 
1948
  expected_maneuvers.emplace_back();
 
1949
  Maneuver& expected_maneuver5 = expected_maneuvers.back();
 
1950
  PopulateManeuver(expected_maneuver5,
 
1951
                   TripDirections_Maneuver_Type_kDestination, { }, { }, { }, "",
 
1952
                   0.000000, 0, 0, Maneuver::RelativeDirection::kNone,
 
1953
                   TripDirections_Maneuver_CardinalDirection_kNorth, 0, 0, 57,
 
1954
                   57, 1303, 1303, 0, 0, 0, 0, 0, 0, 0, 0, 0, { }, { }, { },
 
1955
                   { }, 0, 0, 0);
 
1956
 
 
1957
  TryCountAndSortExitSigns(maneuvers, expected_maneuvers);
 
1958
 
 
1959
}
 
1960
 
 
1961
void TryIsIntersectingForwardEdge(ManeuversBuilderTest& mbTest, int node_index,
 
1962
                                  bool expected) {
 
1963
  auto* prev_edge = mbTest.trip_path()->GetPrevEdge(node_index);
 
1964
  auto* curr_edge = mbTest.trip_path()->GetCurrEdge(node_index);
 
1965
 
 
1966
  bool intersecting_forward_link = mbTest.IsIntersectingForwardEdge(node_index,
 
1967
                                                                    prev_edge,
 
1968
                                                                    curr_edge);
 
1969
 
 
1970
  if (intersecting_forward_link != expected) {
 
1971
    throw std::runtime_error(
 
1972
        "Incorrect intersecting forward link value - expected: "
 
1973
            + std::to_string(expected));
 
1974
  }
 
1975
}
 
1976
 
 
1977
void TestPathRightXStraightIsIntersectingForwardEdge() {
 
1978
  DirectionsOptions directions_options;
 
1979
  TripPath path;
 
1980
  TripPath_Node* node;
 
1981
  TripPath_Edge* edge;
 
1982
 
 
1983
  ///////////////////////////////////////////////////////////////////////////
 
1984
  // node:0
 
1985
  node = path.add_node();
 
1986
  edge = node->mutable_edge();
 
1987
  PopulateEdge(edge, { "Raleigh Road" }, 0.027827, 30.000000,
 
1988
               TripPath_RoadClass_kResidential, 250, 291, 0, 1,
 
1989
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1990
               { }, { }, { }, { }, TripPath_TravelMode_kDrive);
 
1991
 
 
1992
  // node:1 Intersecting forward link
 
1993
  node = path.add_node();
 
1994
  edge = node->mutable_edge();
 
1995
  PopulateEdge(edge, { "Raleigh Road" }, 0.054344, 30.000000,
 
1996
               TripPath_RoadClass_kResidential, 20, 337, 1, 3,
 
1997
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
1998
               { }, { }, { }, { }, TripPath_TravelMode_kDrive);
 
1999
  PopulateIntersectingEdge(node->add_intersecting_edge(), 289, 1, 1,
 
2000
                           TripPath_Traversability_kBoth,
 
2001
                           TripPath_Traversability_kBoth,
 
2002
                           TripPath_Traversability_kBoth);
 
2003
 
 
2004
  // node:2
 
2005
  node = path.add_node();
 
2006
 
 
2007
  ManeuversBuilderTest mbTest(directions_options,
 
2008
                              static_cast<EnhancedTripPath*>(&path));
 
2009
 
 
2010
  TryIsIntersectingForwardEdge(mbTest, 1, true);
 
2011
 
 
2012
}
 
2013
 
 
2014
void TestPathLeftXStraightIsIntersectingForwardEdge() {
 
2015
  DirectionsOptions directions_options;
 
2016
  TripPath path;
 
2017
  TripPath_Node* node;
 
2018
  TripPath_Edge* edge;
 
2019
 
 
2020
  ///////////////////////////////////////////////////////////////////////////
 
2021
  // node:0
 
2022
  node = path.add_node();
 
2023
  edge = node->mutable_edge();
 
2024
  PopulateEdge(edge, { "Raleigh Road" }, 0.047007, 30.000000,
 
2025
               TripPath_RoadClass_kResidential, 108, 108, 0, 1,
 
2026
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
2027
               { }, { }, { }, { }, TripPath_TravelMode_kDrive);
 
2028
 
 
2029
  // node:1 Intersecting forward link
 
2030
  node = path.add_node();
 
2031
  edge = node->mutable_edge();
 
2032
  PopulateEdge(edge, { "Raleigh Road" }, 0.046636, 30.000000,
 
2033
               TripPath_RoadClass_kResidential, 20, 337, 1, 3,
 
2034
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
2035
               { }, { }, { }, { }, TripPath_TravelMode_kDrive);
 
2036
  PopulateIntersectingEdge(node->add_intersecting_edge(), 111, 1, 1,
 
2037
                           TripPath_Traversability_kBoth,
 
2038
                           TripPath_Traversability_kBoth,
 
2039
                           TripPath_Traversability_kBoth);
 
2040
 
 
2041
  // node:2
 
2042
  node = path.add_node();
 
2043
 
 
2044
  ManeuversBuilderTest mbTest(directions_options,
 
2045
                              static_cast<EnhancedTripPath*>(&path));
 
2046
 
 
2047
  TryIsIntersectingForwardEdge(mbTest, 1, true);
 
2048
 
 
2049
}
 
2050
 
 
2051
void TestPathSlightRightXSlightLeftIsIntersectingForwardEdge() {
 
2052
  DirectionsOptions directions_options;
 
2053
  TripPath path;
 
2054
  TripPath_Node* node;
 
2055
  TripPath_Edge* edge;
 
2056
 
 
2057
  ///////////////////////////////////////////////////////////////////////////
 
2058
  // node:0
 
2059
  node = path.add_node();
 
2060
  edge = node->mutable_edge();
 
2061
  PopulateEdge(edge, { "Horace Greeley Road" }, 0.102593, 30.000000,
 
2062
               TripPath_RoadClass_kResidential, 23, 13, 0, 6,
 
2063
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
2064
               { }, { }, { }, { }, TripPath_TravelMode_kDrive);
 
2065
 
 
2066
  // node:1 Intersecting forward link
 
2067
  node = path.add_node();
 
2068
  edge = node->mutable_edge();
 
2069
  PopulateEdge(edge, { "Horace Greeley Road" }, 0.205258, 30.000000,
 
2070
               TripPath_RoadClass_kResidential, 35, 19, 6, 12,
 
2071
               TripPath_Traversability_kBoth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
2072
               { }, { }, { }, { }, TripPath_TravelMode_kDrive);
 
2073
  PopulateIntersectingEdge(node->add_intersecting_edge(), 355, 0, 0,
 
2074
                           TripPath_Traversability_kBoth,
 
2075
                           TripPath_Traversability_kBoth,
 
2076
                           TripPath_Traversability_kBoth);
 
2077
 
 
2078
  // node:2
 
2079
  node = path.add_node();
 
2080
 
 
2081
  ManeuversBuilderTest mbTest(directions_options,
 
2082
                              static_cast<EnhancedTripPath*>(&path));
 
2083
 
 
2084
  TryIsIntersectingForwardEdge(mbTest, 1, true);
 
2085
 
 
2086
}
 
2087
 
 
2088
}
 
2089
 
 
2090
int main() {
 
2091
  test::suite suite("maneuversbuilder");
 
2092
 
 
2093
  // SetSimpleDirectionalManeuverType
 
2094
  suite.test(TEST_CASE(TestSetSimpleDirectionalManeuverType));
 
2095
 
 
2096
  // DetermineCardinalDirection
 
2097
  suite.test(TEST_CASE(TestDetermineCardinalDirection));
 
2098
 
 
2099
  // DetermineRelativeDirection_Maneuver
 
2100
  suite.test(TEST_CASE(TestDetermineRelativeDirection_Maneuver));
 
2101
 
 
2102
  // DetermineRelativeDirection
 
2103
  suite.test(TEST_CASE(TestDetermineRelativeDirection));
 
2104
 
 
2105
  // LeftInternalStraightCombine
 
2106
  suite.test(TEST_CASE(TestLeftInternalStraightCombine));
 
2107
 
 
2108
  // StraightInternalLeftCombine
 
2109
  suite.test(TEST_CASE(TestStraightInternalLeftCombine));
 
2110
 
 
2111
  // StraightInternalLeftInternalCombine
 
2112
  suite.test(TEST_CASE(TestStraightInternalLeftInternalCombine));
 
2113
 
 
2114
  // StraightInternalStraightCombine
 
2115
  suite.test(TEST_CASE(TestStraightInternalStraightCombine));
 
2116
 
 
2117
  // LeftInternalUturnCombine
 
2118
  suite.test(TEST_CASE(TestLeftInternalUturnCombine));
 
2119
 
 
2120
  // LeftInternalUturnProperDirectionCombine
 
2121
  suite.test(TEST_CASE(TestLeftInternalUturnProperDirectionCombine));
 
2122
 
 
2123
  // StraightInternalLeftInternalStraightInternalUturnCombine
 
2124
  suite.test(
 
2125
      TEST_CASE(TestStraightInternalLeftInternalStraightInternalUturnCombine));
 
2126
 
 
2127
  // InternalPencilPointUturnProperDirectionCombine
 
2128
  suite.test(TEST_CASE(TestInternalPencilPointUturnProperDirectionCombine));
 
2129
 
 
2130
  // SimpleRightTurnChannelCombine
 
2131
  suite.test(TEST_CASE(TestSimpleRightTurnChannelCombine));
 
2132
 
 
2133
  // CountAndSortExitSigns
 
2134
  suite.test(TEST_CASE(TestCountAndSortExitSigns));
 
2135
 
 
2136
  // PathRightXStraightIsIntersectingForwardEdge
 
2137
  suite.test(TEST_CASE(TestPathRightXStraightIsIntersectingForwardEdge));
 
2138
 
 
2139
  // PathLeftXStraightIsIntersectingForwardEdge
 
2140
  suite.test(TEST_CASE(TestPathLeftXStraightIsIntersectingForwardEdge));
 
2141
 
 
2142
  // PathSlightRightXSlightLeftIsIntersectingForwardEdge
 
2143
  suite.test(TEST_CASE(TestPathSlightRightXSlightLeftIsIntersectingForwardEdge));
 
2144
 
 
2145
  return suite.tear_down();
 
2146
}
 
2147