| 393 | |
| 394 | template <typename IntersectionType> |
| 395 | inline bool |
| 396 | IntersectionHandler::IsDistinctWideTurn(const EdgeID via_edge, |
| 397 | const IntersectionType::const_iterator candidate, |
| 398 | const IntersectionType &intersection) const |
| 399 | { |
| 400 | const auto &via_edge_data = node_based_graph.GetEdgeData(via_edge); |
| 401 | const auto &candidate_data = node_based_graph.GetEdgeData(candidate->eid); |
| 402 | auto const candidate_deviation = util::angularDeviation(candidate->angle, STRAIGHT_ANGLE); |
| 403 | |
| 404 | // Deviation is larger than NARROW_TURN_ANGLE0 here for the candidate |
| 405 | // check if there is any turn, that might look just as obvious, even though it might not |
| 406 | // be allowed. Entry-allowed isn't considered a valid distinction criterion here |
| 407 | auto const is_similar_turn = [&](auto const &road) |
| 408 | { |
| 409 | // 1. Skip over our candidate |
| 410 | if (road.eid == candidate->eid) |
| 411 | return false; |
| 412 | |
| 413 | // we do not consider roads of far lesser category to be more obvious |
| 414 | const auto &compare_data = node_based_graph.GetEdgeData(road.eid); |
| 415 | const auto compare_deviation = util::angularDeviation(road.angle, STRAIGHT_ANGLE); |
| 416 | const auto is_compare_straight = |
| 417 | getTurnDirection(road.angle) == DirectionModifier::Straight; |
| 418 | |
| 419 | // 2. Don't consider similarity if a compare road is non-straight and has lower class |
| 420 | if (!is_compare_straight && roadHasLowerClass(via_edge_data, candidate_data, compare_data)) |
| 421 | { |
| 422 | return false; |
| 423 | } |
| 424 | |
| 425 | // 3. If the turn is much stronger, we are also fine (note that we do not have to check |
| 426 | // absolutes, since candidate is at least > NARROW_TURN_ANGLE) |
| 427 | auto const compare_road_deviation_is_distinct = |
| 428 | compare_deviation > DISTINCTION_RATIO * candidate_deviation; |
| 429 | |
| 430 | if (compare_road_deviation_is_distinct) |
| 431 | { |
| 432 | return false; |
| 433 | } |
| 434 | |
| 435 | // 4. If initial and adjusted bearings are quite different then check deviations |
| 436 | // computed in the vicinity of the intersection point based in initial bearings: |
| 437 | // road is not similar to candidate if a road-to-candidate is not a straight direction |
| 438 | // and road has distinctive deviation. |
| 439 | if (util::angularDeviation(intersection[0].initial_bearing, |
| 440 | intersection[0].perceived_bearing) > FUZZY_ANGLE_DIFFERENCE) |
| 441 | { |
| 442 | using osrm::util::bearing::reverse; |
| 443 | using osrm::util::bearing::angleBetween; |
| 444 | using osrm::util::angularDeviation; |
| 445 | |
| 446 | const auto via_edge_initial_bearing = reverse(intersection[0].initial_bearing); |
| 447 | const auto candidate_deviation_initial = angularDeviation( |
| 448 | angleBetween(via_edge_initial_bearing, candidate->initial_bearing), STRAIGHT_ANGLE); |
| 449 | const auto road_deviation_initial = angularDeviation( |
| 450 | angleBetween(via_edge_initial_bearing, road.initial_bearing), STRAIGHT_ANGLE); |
| 451 | const auto road_to_candidate_angle = |
| 452 | angleBetween(reverse(road.initial_bearing), candidate->initial_bearing); |
nothing calls this directly
no test coverage detected