| 516 | } |
| 517 | |
| 518 | std::vector<RouteStep> buildIntersections(std::vector<RouteStep> steps) |
| 519 | { |
| 520 | std::size_t last_valid_instruction = 0; |
| 521 | for (std::size_t step_index = 0; step_index < steps.size(); ++step_index) |
| 522 | { |
| 523 | auto &step = steps[step_index]; |
| 524 | const auto instruction = step.maneuver.instruction; |
| 525 | if (instruction.type == TurnType::Suppressed) |
| 526 | { |
| 527 | BOOST_ASSERT(steps[last_valid_instruction].mode == step.mode); |
| 528 | // count intersections. We cannot use exit, since intersections can follow directly |
| 529 | // after a roundabout |
| 530 | steps[last_valid_instruction].ElongateBy(step); |
| 531 | steps[step_index].Invalidate(); |
| 532 | } |
| 533 | else if (!isSilent(instruction)) |
| 534 | { |
| 535 | |
| 536 | // End of road is a turn that helps to identify the location of a turn. If the turn does |
| 537 | // not pass by any other intersections, the end-of-road characteristic does not improve |
| 538 | // the instructions. |
| 539 | // Here we reduce the verbosity of our output by reducing end-of-road emissions in cases |
| 540 | // where no intersections have been passed in between. |
| 541 | // Since the instruction is located at the beginning of a step, we need to check the |
| 542 | // previous instruction. |
| 543 | if (instruction.type == TurnType::EndOfRoad) |
| 544 | { |
| 545 | BOOST_ASSERT(step_index > 0); |
| 546 | const auto &previous_step = steps[last_valid_instruction]; |
| 547 | if (previous_step.intersections.size() < MIN_END_OF_ROAD_INTERSECTIONS) |
| 548 | { |
| 549 | bool same_name = |
| 550 | !(step.name.empty() && step.ref.empty()) && |
| 551 | !util::guidance::requiresNameAnnounced(previous_step.name, |
| 552 | previous_step.ref, |
| 553 | previous_step.pronunciation, |
| 554 | previous_step.exits, |
| 555 | step.name, |
| 556 | step.ref, |
| 557 | step.pronunciation, |
| 558 | step.exits); |
| 559 | |
| 560 | step.maneuver.instruction.type = |
| 561 | same_name ? TurnType::Continue : TurnType::Turn; |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | // Remember the last non silent instruction |
| 566 | last_valid_instruction = step_index; |
| 567 | } |
| 568 | } |
| 569 | return removeNoTurnInstructions(std::move(steps)); |
| 570 | } |
| 571 | |
| 572 | void applyOverrides(const datafacade::BaseDataFacade &facade, |
| 573 | std::vector<RouteStep> &steps, |
no test coverage detected