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

Method GetSegmentRangeAndAdjacentEdges

libs/routing/directions_engine.cpp:110–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110void DirectionsEngine::GetSegmentRangeAndAdjacentEdges(IRoadGraph::EdgeListT const & outgoingEdges, Edge const & inEdge,
111 uint32_t startSegId, uint32_t endSegId,
112 SegmentRange & segmentRange, TurnCandidates & outgoingTurns)
113{
114 outgoingTurns.isCandidatesAngleValid = true;
115 outgoingTurns.candidates.reserve(outgoingEdges.size());
116 segmentRange = SegmentRange(inEdge.GetFeatureId(), startSegId, endSegId, inEdge.IsForward(), inEdge.GetStartPoint(),
117 inEdge.GetEndPoint());
118 CHECK(segmentRange.IsCorrect(), ());
119 m2::PointD const & ingoingPoint = inEdge.GetStartJunction().GetPoint();
120 m2::PointD const & junctionPoint = inEdge.GetEndJunction().GetPoint();
121
122 for (auto const & edge : outgoingEdges)
123 {
124 if (edge.IsFake())
125 continue;
126
127 auto ft = GetFeature(edge.GetFeatureId());
128 if (!ft)
129 continue;
130
131 feature::TypesHolder types(*ft);
132
133 auto const highwayClass = GetHighwayClass(types);
134 ASSERT(highwayClass != HighwayClass::Undefined, (edge.PrintLatLon()));
135
136 double angle = 0;
137
138 if (inEdge.GetFeatureId().m_mwmId == edge.GetFeatureId().m_mwmId)
139 {
140 ASSERT_LESS(mercator::DistanceOnEarth(junctionPoint, edge.GetStartJunction().GetPoint()),
141 turns::kFeaturesNearTurnMeters, ());
142 angle =
143 math::RadToDeg(turns::PiMinusTwoVectorsAngle(junctionPoint, ingoingPoint, edge.GetEndJunction().GetPoint()));
144 }
145 else
146 {
147 // Note. In case of crossing mwm border
148 // (inEdge.GetFeatureId().m_mwmId != edge.GetFeatureId().m_mwmId)
149 // twins of inEdge.GetFeatureId() are considered as outgoing features.
150 // In this case that turn candidate angle is invalid and
151 // should not be used for turn generation.
152 outgoingTurns.isCandidatesAngleValid = false;
153 }
154
155 outgoingTurns.candidates.emplace_back(angle, ConvertEdgeToSegment(*m_numMwmIds, edge), highwayClass,
156 m_linkChecker(types));
157 }
158
159 if (outgoingTurns.isCandidatesAngleValid)
160 sort(outgoingTurns.candidates.begin(), outgoingTurns.candidates.end(), base::LessBy(&TurnCandidate::m_angle));
161}
162
163void DirectionsEngine::FillPathSegmentsAndAdjacentEdgesMap(IndexRoadGraph const & graph,
164 vector<geometry::PointWithAltitude> const & path,

Callers

nothing calls this directly

Calls 15

SegmentRangeClass · 0.85
GetHighwayClassFunction · 0.85
ASSERTFunction · 0.85
RadToDegFunction · 0.85
PiMinusTwoVectorsAngleFunction · 0.85
ConvertEdgeToSegmentFunction · 0.85
LessByFunction · 0.85
IsCorrectMethod · 0.80
PrintLatLonMethod · 0.80
DistanceOnEarthFunction · 0.50
reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected