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

Method ReconstructJointSegment

libs/routing/index_graph.cpp:318–404  ·  view source on GitHub ↗

\brief Prolongs segments from |parent| to |firstChildren| directions in order to create JointSegments. \param |firstChildren| - vector of neighbouring segments from parent. \param |lastPointIds| - vector of the end numbers of road points for |firstChildren|. \param |jointEdges| - the result vector with JointEdges. \param |parentWeights| - see |IndexGraphStarterJoints::GetEdgeList| method about thi

Source from the content-addressed store, hash-verified

316/// Shortly - in case of |isOutgoing| == false, method saves here the weights
317/// from parent to firstChildren.
318void IndexGraph::ReconstructJointSegment(astar::VertexData<JointSegment, RouteWeight> const & parentVertexData,
319 Segment const & parent, SegmentListT const & firstChildren,
320 PointIdListT const & lastPointIds, bool isOutgoing,
321 JointEdgeListT & jointEdges, WeightListT & parentWeights,
322 Parents<JointSegment> const & parents) const
323{
324 CHECK_EQUAL(firstChildren.size(), lastPointIds.size(), ());
325
326 auto const & weightTimeToParent = parentVertexData.m_realDistance;
327 auto const & parentJoint = parentVertexData.m_vertex;
328 for (size_t i = 0; i < firstChildren.size(); ++i)
329 {
330 auto const & firstChild = firstChildren[i];
331 auto const lastPointId = lastPointIds[i];
332
333 uint32_t currentPointId = firstChild.GetPointId(!isOutgoing /* front */);
334 CHECK_NOT_EQUAL(currentPointId, lastPointId,
335 ("Invariant violated, can not build JointSegment,"
336 "started and ended in the same point."));
337
338 auto const increment = [currentPointId, lastPointId](uint32_t pointId)
339 { return currentPointId < lastPointId ? pointId + 1 : pointId - 1; };
340
341 if (IsAccessNoForSure(firstChild.GetFeatureId(), weightTimeToParent, true /* useAccessConditional */))
342 continue;
343
344 if (IsAccessNoForSure(parent.GetRoadPoint(isOutgoing), weightTimeToParent, true /* useAccessConditional */))
345 continue;
346
347 if (IsUTurn(parent, firstChild) && IsUTurnAndRestricted(parent, firstChild, isOutgoing))
348 continue;
349
350 if (IsRestricted(parentJoint, parent.GetFeatureId(), firstChild.GetFeatureId(), isOutgoing, parents))
351 continue;
352
353 RouteWeight summaryWeight;
354 // Check current JointSegment for bad road access between segments.
355 RoadPoint rp = firstChild.GetRoadPoint(isOutgoing);
356 uint32_t start = currentPointId;
357 bool noRoadAccess = false;
358 do
359 {
360 // This is optimization: we calculate accesses of road points before calculating weight of
361 // segments between these road points. Because of that we make fewer calculations when some
362 // points have RoadAccess::Type::No.
363 // And using |weightTimeToParent| is not fair in fact, because we should calculate weight
364 // until this |rp|. But we assume that segments have small length and inaccuracy will not
365 // affect user.
366 if (IsAccessNoForSure(rp, weightTimeToParent, true /* useAccessConditional */))
367 {
368 noRoadAccess = true;
369 break;
370 }
371
372 start = increment(start);
373 rp.SetPointId(start);
374 }
375 while (start != lastPointId);

Callers

nothing calls this directly

Calls 9

IsUTurnFunction · 0.85
GetRoadPointMethod · 0.80
SetPointIdMethod · 0.80
JointSegmentClass · 0.70
sizeMethod · 0.45
GetPointIdMethod · 0.45
GetFeatureIdMethod · 0.45
emplace_backMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected