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

Method FillPathSegmentsAndAdjacentEdgesMap

libs/routing/directions_engine.cpp:163–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163void DirectionsEngine::FillPathSegmentsAndAdjacentEdgesMap(IndexRoadGraph const & graph,
164 vector<geometry::PointWithAltitude> const & path,
165 IRoadGraph::EdgeVector const & routeEdges,
166 base::Cancellable const & cancellable)
167{
168 size_t const pathSize = path.size();
169 CHECK_GREATER(pathSize, 1, ());
170 CHECK_EQUAL(routeEdges.size() + 1, pathSize, ());
171
172 // Filling |m_adjacentEdges|.
173 auto constexpr kInvalidSegId = numeric_limits<uint32_t>::max();
174 // |startSegId| is a value to keep start segment id of a new instance of LoadedPathSegment.
175 uint32_t startSegId = kInvalidSegId;
176
177 vector<geometry::PointWithAltitude> prevJunctions;
178 vector<Segment> prevSegments;
179 for (size_t i = 1; i < pathSize; ++i)
180 {
181 if (cancellable.IsCancelled())
182 return;
183
184 auto const & currJunction = path[i];
185 bool const isCurrJunctionFinish = (i + 1 == pathSize);
186
187 IRoadGraph::EdgeListT outgoingEdges, ingoingEdges;
188 if (!isCurrJunctionFinish)
189 graph.GetOutgoingEdges(currJunction, outgoingEdges);
190 graph.GetIngoingEdges(currJunction, ingoingEdges);
191
192 Edge const & inEdge = routeEdges[i - 1];
193 uint32_t const inSegId = inEdge.GetSegId();
194
195 if (startSegId == kInvalidSegId)
196 startSegId = inSegId;
197
198 prevJunctions.push_back(path[i - 1]);
199 prevSegments.push_back(ConvertEdgeToSegment(*m_numMwmIds, inEdge));
200
201 // inEdge.FeatureId may be invalid in case of adding fake features. It happens for example near starts and finishes.
202 if (!isCurrJunctionFinish && inEdge.GetFeatureId().IsValid() &&
203 !IsJoint(ingoingEdges, outgoingEdges, inEdge, routeEdges[i]))
204 {
205 continue;
206 }
207
208 CHECK_EQUAL(prevJunctions.size(), static_cast<size_t>(abs(int(inSegId) - int(startSegId)) + 1), ());
209
210 prevJunctions.push_back(currJunction);
211
212 AdjacentEdges adjacentEdges(ingoingEdges.size());
213 SegmentRange segmentRange;
214 GetSegmentRangeAndAdjacentEdges(outgoingEdges, inEdge, startSegId, inSegId, segmentRange,
215 adjacentEdges.m_outgoingTurns);
216
217 LoadedPathSegment pathSegment;
218 pathSegment.m_segmentRange = segmentRange;
219 // |prevSegments| contains segments which corresponds to road edges between joints. In case of a
220 // fake edge a fake segment is created.

Callers

nothing calls this directly

Calls 15

ConvertEdgeToSegmentFunction · 0.85
IsJointFunction · 0.85
GetSegIdMethod · 0.80
sizeMethod · 0.45
IsCancelledMethod · 0.45
GetOutgoingEdgesMethod · 0.45
GetIngoingEdgesMethod · 0.45
push_backMethod · 0.45
IsValidMethod · 0.45
GetFeatureIdMethod · 0.45
GetFeatureMethod · 0.45
IsForwardMethod · 0.45

Tested by

no test coverage detected