| 369 | } |
| 370 | |
| 371 | Intersection RoundaboutHandler::handleRoundabouts(const RoundaboutType roundabout_type, |
| 372 | const EdgeID via_eid, |
| 373 | const bool on_roundabout, |
| 374 | const bool can_exit_roundabout_separately, |
| 375 | Intersection intersection) const |
| 376 | { |
| 377 | NodeID node_at_center_of_intersection = node_based_graph.GetTarget(via_eid); |
| 378 | const auto &in_edge_data = node_based_graph.GetEdgeData(via_eid); |
| 379 | |
| 380 | const bool lhs = |
| 381 | node_data_container.GetAnnotation(in_edge_data.annotation_data).is_left_hand_driving; |
| 382 | const int step = lhs ? -1 : 1; |
| 383 | |
| 384 | if (on_roundabout) |
| 385 | { |
| 386 | // Shoule hopefully have only a single exit and continue |
| 387 | // at least for cars. How about bikes? |
| 388 | for (std::size_t cnt = 0, idx = lhs ? intersection.size() - 1 : 0; |
| 389 | cnt < intersection.size(); |
| 390 | ++cnt, idx += step) |
| 391 | { |
| 392 | auto &road = intersection[idx]; |
| 393 | auto &turn = road; |
| 394 | const auto &out_data = node_based_graph.GetEdgeData(road.eid).flags; |
| 395 | ; |
| 396 | if (out_data.roundabout || out_data.circular) |
| 397 | { |
| 398 | // TODO can forks happen in roundabouts? E.g. required lane changes |
| 399 | if (1 == node_based_graph.GetDirectedOutDegree(node_at_center_of_intersection)) |
| 400 | { |
| 401 | // No turn possible. |
| 402 | if (intersection.size() == 2) |
| 403 | turn.instruction = TurnInstruction::NO_TURN(); |
| 404 | else |
| 405 | { |
| 406 | turn.instruction.type = |
| 407 | TurnType::Suppressed; // make sure to report intersection |
| 408 | turn.instruction.direction_modifier = getTurnDirection(turn.angle); |
| 409 | } |
| 410 | } |
| 411 | else |
| 412 | { |
| 413 | // Check if there is a non-service exit |
| 414 | const auto has_non_ignorable_exit = [&]() |
| 415 | { |
| 416 | for (const auto eid : |
| 417 | node_based_graph.GetAdjacentEdgeRange(node_at_center_of_intersection)) |
| 418 | { |
| 419 | const auto &leaving_edge = node_based_graph.GetEdgeData(eid); |
| 420 | if (!leaving_edge.reversed && !leaving_edge.flags.roundabout && |
| 421 | !leaving_edge.flags.circular && |
| 422 | !leaving_edge.flags.road_classification.IsLowPriorityRoadClass()) |
| 423 | return true; |
| 424 | } |
| 425 | return false; |
| 426 | }; |
| 427 | |
| 428 | // Count normal exits and service roads, if the roundabout is a service road |
nothing calls this directly
no test coverage detected