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

Function GetTurnInfo

libs/routing/turns_generator.cpp:347–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347bool GetTurnInfo(IRoutingResult const & result, size_t const outgoingSegmentIndex,
348 RoutingSettings const & vehicleSettings, TurnInfo & turnInfo)
349{
350 auto const & segments = result.GetSegments();
351 CHECK_LESS(outgoingSegmentIndex, segments.size(), ());
352 CHECK_GREATER(outgoingSegmentIndex, 0, ());
353
354 if (PathIsFakeLoop(segments[outgoingSegmentIndex].m_path))
355 return false;
356
357 bool const isStartFakeLoop = PathIsFakeLoop(segments[outgoingSegmentIndex - 1].m_path);
358
359 if (isStartFakeLoop && outgoingSegmentIndex < 2)
360 return false;
361
362 size_t const prevIndex = isStartFakeLoop ? outgoingSegmentIndex - 2 : outgoingSegmentIndex - 1;
363 turnInfo = TurnInfo(&segments[prevIndex], &segments[outgoingSegmentIndex]);
364
365 if (!turnInfo.IsSegmentsValid() || turnInfo.m_ingoing->m_segmentRange.IsEmpty())
366 return false;
367
368 if (isStartFakeLoop)
369 {
370 if (mercator::DistanceOnEarth(turnInfo.m_ingoing->m_path.front().GetPoint(),
371 turnInfo.m_ingoing->m_path.back().GetPoint()) <
372 vehicleSettings.m_minIngoingDistMeters ||
373 mercator::DistanceOnEarth(turnInfo.m_outgoing->m_path.front().GetPoint(),
374 turnInfo.m_outgoing->m_path.back().GetPoint()) <
375 vehicleSettings.m_minOutgoingDistMeters)
376 {
377 return false;
378 }
379 }
380
381 ASSERT(!turnInfo.m_ingoing->m_path.empty(), ());
382 ASSERT(!turnInfo.m_outgoing->m_path.empty(), ());
383 ASSERT_LESS(mercator::DistanceOnEarth(turnInfo.m_ingoing->m_path.back().GetPoint(),
384 turnInfo.m_outgoing->m_path.front().GetPoint()),
385 kFeaturesNearTurnMeters, ());
386
387 return true;
388}
389
390} // namespace turns
391} // namespace routing

Callers 2

GetTurnDirectionBasicFunction · 0.85
GetTurnDirectionMethod · 0.85

Calls 11

PathIsFakeLoopFunction · 0.85
ASSERTFunction · 0.85
IsSegmentsValidMethod · 0.80
frontMethod · 0.80
backMethod · 0.80
TurnInfoClass · 0.70
DistanceOnEarthFunction · 0.50
sizeMethod · 0.45
IsEmptyMethod · 0.45
GetPointMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected