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

Method AdjustRoute

libs/routing/index_router.cpp:986–1078  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

984}
985
986RouterResultCode IndexRouter::AdjustRoute(Checkpoints const & checkpoints, m2::PointD const & startDirection,
987 RouterDelegate const & delegate, Route & route)
988{
989 base::Timer timer;
990 TrafficStash::Guard guard(m_trafficStash);
991 auto graph = MakeWorldGraph();
992 graph->SetMode(WorldGraphMode::NoLeaps);
993
994 vector<Segment> startSegments;
995 m2::PointD const & pointFrom = checkpoints.GetPointFrom();
996 bool bestSegmentIsAlmostCodirectional = false;
997 PointsOnEdgesSnapping snapping(*this, *graph);
998 if (!snapping.FindBestSegments(pointFrom, startDirection, true /* isOutgoing */, startSegments,
999 bestSegmentIsAlmostCodirectional))
1000 {
1001 return RouterResultCode::StartPointNotFound;
1002 }
1003
1004 auto const & lastSubroutes = m_lastRoute->GetSubroutes();
1005 CHECK(!lastSubroutes.empty(), ());
1006 auto const & lastSubroute = m_lastRoute->GetSubroute(checkpoints.GetPassedIdx());
1007
1008 auto const & steps = m_lastRoute->GetSteps();
1009 CHECK(!steps.empty(), ());
1010
1011 FakeEnding dummy{};
1012 IndexGraphStarter starter(MakeFakeEnding(startSegments, pointFrom, *graph), dummy, m_lastFakeEdges->GetNumFakeEdges(),
1013 bestSegmentIsAlmostCodirectional, *graph);
1014
1015 starter.Append(*m_lastFakeEdges);
1016
1017 vector<SegmentEdge> prevEdges;
1018 CHECK_LESS_OR_EQUAL(lastSubroute.GetEndSegmentIdx(), steps.size(), ());
1019 for (size_t i = lastSubroute.GetBeginSegmentIdx(); i < lastSubroute.GetEndSegmentIdx(); ++i)
1020 {
1021 auto const & step = steps[i];
1022 prevEdges.emplace_back(step.GetSegment(),
1023 starter.CalcSegmentWeight(step.GetSegment(), EdgeEstimator::Purpose::Weight));
1024 }
1025
1026 using Visitor = JunctionVisitor<IndexGraphStarter>;
1027 Visitor visitor(starter, delegate, kVisitPeriod);
1028
1029 using Vertex = IndexGraphStarter::Vertex;
1030 using Edge = IndexGraphStarter::Edge;
1031 using Weight = IndexGraphStarter::Weight;
1032
1033 AStarAlgorithm<Vertex, Edge, Weight> algorithm;
1034 AStarAlgorithm<Vertex, Edge, Weight>::Params<Visitor, AdjustLengthChecker> params(
1035 starter, starter.GetStartSegment(), {} /* finalVertex */, delegate.GetCancellable(), std::move(visitor),
1036 AdjustLengthChecker(starter));
1037
1038 RoutingResult<Segment, RouteWeight> result;
1039 auto const resultCode = ConvertResult<Vertex, Edge, Weight>(algorithm.AdjustRoute(params, prevEdges, result));
1040 if (resultCode != RouterResultCode::NoError)
1041 return resultCode;
1042
1043 CHECK_GREATER_OR_EQUAL(result.m_path.size(), 2, ());

Callers

nothing calls this directly

Calls 15

AdjustLengthCheckerClass · 0.85
PushPassedSubroutesFunction · 0.85
FindBestSegmentsMethod · 0.80
GetSubrouteMethod · 0.80
GetPassedIdxMethod · 0.80
GetNumFakeEdgesMethod · 0.80
GetEndSegmentIdxMethod · 0.80
GetBeginSegmentIdxMethod · 0.80
GetSegmentMethod · 0.80
frontMethod · 0.80
backMethod · 0.80
ToPointWithAltitudeMethod · 0.80

Tested by

no test coverage detected