this function handles a single roundabout between enter (which might be missing) to exit (which might be missing as well)
| 48 | // this function handles a single roundabout between enter (which might be missing) to exit (which |
| 49 | // might be missing as well) |
| 50 | void processRoundaboutExits(const RouteStepIterator begin, const RouteStepIterator end) |
| 51 | { |
| 52 | auto const last = end - 1; |
| 53 | // If we do not exit the roundabout, there is no exit to report. All good here |
| 54 | if (!leavesRoundabout(last->maneuver.instruction)) |
| 55 | { |
| 56 | // first we do some clean-up |
| 57 | if (begin->maneuver.instruction.type == TurnType::EnterRotary || |
| 58 | begin->maneuver.instruction.type == TurnType::EnterRotaryAtExit) |
| 59 | { |
| 60 | begin->rotary_name = begin->name; |
| 61 | begin->rotary_pronunciation = begin->pronunciation; |
| 62 | } |
| 63 | // roundabout turns don't make sense without an exit, update the type |
| 64 | else if (entersRoundabout(begin->maneuver.instruction) && |
| 65 | (begin->maneuver.instruction.type == TurnType::EnterRoundaboutIntersection || |
| 66 | begin->maneuver.instruction.type == TurnType::EnterRoundaboutIntersectionAtExit)) |
| 67 | { |
| 68 | begin->maneuver.instruction.type = TurnType::EnterRoundabout; |
| 69 | } |
| 70 | |
| 71 | // We are doing a roundtrip on the roundabout, Nothing to do here but to remove the |
| 72 | // instructions |
| 73 | compressRange(begin, end); |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | const auto passes_exit_or_leaves_roundabout = [](auto const &step) |
| 78 | { |
| 79 | return staysOnRoundabout(step.maneuver.instruction) || |
| 80 | leavesRoundabout(step.maneuver.instruction); |
| 81 | }; |
| 82 | |
| 83 | // exit count |
| 84 | const auto exit = std::count_if(begin, end, passes_exit_or_leaves_roundabout); |
| 85 | |
| 86 | // removes all intermediate instructions, assigns names and exit numbers |
| 87 | BOOST_ASSERT(leavesRoundabout(last->maneuver.instruction)); |
| 88 | BOOST_ASSERT(std::distance(begin, end) >= 1); |
| 89 | last->maneuver.exit = exit; |
| 90 | |
| 91 | // when we actually have an enter instruction, we can store all the information on it that we |
| 92 | // need, otherwise we only provide the exit instruciton. In case of re-routing on the |
| 93 | // roundabout, this might result in strange behaviour, but this way we are more resiliant and we |
| 94 | // do provide exit after all |
| 95 | if (entersRoundabout(begin->maneuver.instruction)) |
| 96 | { |
| 97 | begin->maneuver.exit = exit; |
| 98 | // special handling for rotaries: remember the name (legacy feature, due to |
| 99 | // adapt-step-signage) |
| 100 | if (begin->maneuver.instruction.type == TurnType::EnterRotary || |
| 101 | begin->maneuver.instruction.type == TurnType::EnterRotaryAtExit) |
| 102 | { |
| 103 | begin->rotary_name = begin->name; |
| 104 | begin->rotary_pronunciation = begin->pronunciation; |
| 105 | } |
| 106 | // compute the total direction modifier for roundabout turns |
| 107 | else if (begin->maneuver.instruction.type == TurnType::EnterRoundaboutIntersection || |
no test coverage detected