| 432 | } |
| 433 | |
| 434 | void GetTurnDirectionBasic(IRoutingResult const & result, size_t const outgoingSegmentIndex, |
| 435 | NumMwmIds const & numMwmIds, RoutingSettings const & vehicleSettings, TurnItem & turn) |
| 436 | { |
| 437 | TurnInfo turnInfo; |
| 438 | if (!GetTurnInfo(result, outgoingSegmentIndex, vehicleSettings, turnInfo)) |
| 439 | return; |
| 440 | |
| 441 | turn.m_turn = CarDirection::None; |
| 442 | |
| 443 | ASSERT_GREATER(turnInfo.m_ingoing->m_path.size(), 1, ()); |
| 444 | TurnCandidates nodes; |
| 445 | size_t ingoingCount; |
| 446 | m2::PointD const junctionPoint = turnInfo.m_ingoing->m_path.back().GetPoint(); |
| 447 | result.GetPossibleTurns(turnInfo.m_ingoing->m_segmentRange, junctionPoint, ingoingCount, nodes); |
| 448 | if (nodes.isCandidatesAngleValid) |
| 449 | { |
| 450 | ASSERT(is_sorted(nodes.candidates.begin(), nodes.candidates.end(), base::LessBy(&TurnCandidate::m_angle)), |
| 451 | ("Turn candidates should be sorted by its angle field.")); |
| 452 | } |
| 453 | |
| 454 | /// @todo Proper handling of isCandidatesAngleValid == False, when we don't have angles of candidates. |
| 455 | |
| 456 | if (nodes.candidates.size() == 0) |
| 457 | return; |
| 458 | |
| 459 | // No turns are needed on transported road. |
| 460 | if (turnInfo.m_ingoing->m_highwayClass == HighwayClass::Transported && |
| 461 | turnInfo.m_outgoing->m_highwayClass == HighwayClass::Transported) |
| 462 | return; |
| 463 | |
| 464 | Segment firstOutgoingSeg; |
| 465 | if (!turnInfo.m_outgoing->m_segmentRange.GetFirstSegment(numMwmIds, firstOutgoingSeg)) |
| 466 | return; |
| 467 | |
| 468 | CorrectCandidatesSegmentByOutgoing(turnInfo, firstOutgoingSeg, nodes); |
| 469 | |
| 470 | RemoveUTurnCandidate(turnInfo, numMwmIds, nodes.candidates); |
| 471 | auto const & turnCandidates = nodes.candidates; |
| 472 | |
| 473 | // Check for enter or exit to/from roundabout. |
| 474 | if (turnInfo.m_ingoing->m_onRoundabout || turnInfo.m_outgoing->m_onRoundabout) |
| 475 | { |
| 476 | turn.m_turn = GetRoundaboutDirection(turnInfo, nodes, numMwmIds); |
| 477 | // If there is 1 or more exits (nodes.candidates > 1) right at the enter it should be counted. Issue #3027. |
| 478 | if (turn.m_turn == CarDirection::EnterRoundAbout && nodes.candidates.size() > 1) |
| 479 | turn.m_exitNum = 1; |
| 480 | return; |
| 481 | } |
| 482 | |
| 483 | double const turnAngle = CalcTurnAngle(result, outgoingSegmentIndex, numMwmIds, vehicleSettings); |
| 484 | |
| 485 | CarDirection const intermediateDirection = IntermediateDirection(turnAngle); |
| 486 | |
| 487 | // Checking for exits from highways. |
| 488 | turn.m_turn = TryToGetExitDirection(nodes, turnInfo, firstOutgoingSeg, intermediateDirection); |
| 489 | if (turn.m_turn != CarDirection::None) |
| 490 | return; |
| 491 |
no test coverage detected