MCPcopy Create free account
hub / github.com/comaps/comaps / GetTurnDirection

Method GetTurnDirection

libs/routing/pedestrian_directions.cpp:34–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32double constexpr kMaxForwardAngleActual = 60.0;
33
34size_t PedestrianDirectionsEngine::GetTurnDirection(IRoutingResult const & result, size_t const outgoingSegmentIndex,
35 NumMwmIds const & numMwmIds,
36 RoutingSettings const & vehicleSettings, TurnItem & turn)
37{
38 if (outgoingSegmentIndex == result.GetSegments().size())
39 {
40 turn.m_pedestrianTurn = PedestrianDirection::ReachedYourDestination;
41 return 0;
42 }
43
44 // See comment for the same in CarDirectionsEngine::GetTurnDirection().
45 if (outgoingSegmentIndex == 2) // The same as turnItem.m_index == 2.
46 return 0;
47
48 TurnInfo turnInfo;
49 if (!GetTurnInfo(result, outgoingSegmentIndex, vehicleSettings, turnInfo))
50 return 0;
51
52 double const turnAngle = CalcTurnAngle(result, outgoingSegmentIndex, numMwmIds, vehicleSettings);
53
54 turn.m_pedestrianTurn = PedestrianDirection::None;
55
56 ASSERT_GREATER(turnInfo.m_ingoing->m_path.size(), 1, ());
57
58 TurnCandidates nodes;
59 size_t ingoingCount = 0;
60 m2::PointD const junctionPoint = turnInfo.m_ingoing->m_path.back().GetPoint();
61 result.GetPossibleTurns(turnInfo.m_ingoing->m_segmentRange, junctionPoint, ingoingCount, nodes);
62 if (nodes.isCandidatesAngleValid)
63 {
64 ASSERT(is_sorted(nodes.candidates.begin(), nodes.candidates.end(), base::LessBy(&TurnCandidate::m_angle)),
65 ("Turn candidates should be sorted by its angle field."));
66 }
67
68 /// @todo Proper handling of isCandidatesAngleValid == False, when we don't have angles of candidates.
69
70 if (nodes.candidates.size() == 0)
71 return 0;
72
73 turn.m_pedestrianTurn = IntermediateDirectionPedestrian(turnAngle);
74
75 if (turn.m_pedestrianTurn == PedestrianDirection::GoStraight)
76 {
77 turn.m_pedestrianTurn = PedestrianDirection::None;
78 return 0;
79 }
80
81 Segment firstOutgoingSeg;
82 if (!turnInfo.m_outgoing->m_segmentRange.GetFirstSegment(numMwmIds, firstOutgoingSeg))
83 return 0;
84
85 CorrectCandidatesSegmentByOutgoing(turnInfo, firstOutgoingSeg, nodes);
86 RemoveUTurnCandidate(turnInfo, numMwmIds, nodes.candidates);
87
88 // If there is no fork on the road we don't need to generate any turn. It is pointless because
89 // there is no possibility of leaving the route.
90 if (nodes.candidates.size() <= 1)
91 turn.m_pedestrianTurn = PedestrianDirection::None;

Callers

nothing calls this directly

Calls 15

GetTurnInfoFunction · 0.85
CalcTurnAngleFunction · 0.85
ASSERTFunction · 0.85
LessByFunction · 0.85
RemoveUTurnCandidateFunction · 0.85
CalcOneSegmentTurnAngleFunction · 0.85
HasSingleForwardTurnFunction · 0.85
backMethod · 0.80
GetFirstSegmentMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected