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

Method DoCalculateRoute

libs/routing/index_router.cpp:508–655  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

506}
507
508RouterResultCode IndexRouter::DoCalculateRoute(Checkpoints const & checkpoints, m2::PointD const & startDirection,
509 RouterDelegate const & delegate, Route & route)
510{
511 m_lastRoute.reset();
512 // MwmId used for guides segments in RedressRoute().
513 NumMwmId guidesMwmId = kFakeNumMwmId;
514
515 for (auto const & checkpoint : checkpoints.GetPoints())
516 {
517 auto const country = platform::CountryFile(m_countryFileFn(checkpoint));
518
519 if (country.IsEmpty())
520 {
521 /// @todo Can we pass an error into \a route instance with final message like:
522 /// "Please, try to move start/end point a bit .."
523
524 LOG(LWARNING, ("For point", mercator::ToLatLon(checkpoint),
525 "CountryInfoGetter returns an empty CountryFile(). It happens when checkpoint "
526 "is put at gaps between mwm."));
527 return RouterResultCode::InternalError;
528 }
529
530 if (!m_dataSource.IsLoaded(country))
531 route.AddAbsentCountry(country.GetName());
532 else if (guidesMwmId == kFakeNumMwmId)
533 guidesMwmId = m_numMwmIds->GetId(country);
534 }
535
536 if (!route.GetAbsentCountries().empty())
537 return RouterResultCode::NeedMoreMaps;
538
539 TrafficStash::Guard guard(m_trafficStash);
540 unique_ptr<WorldGraph> graph = MakeWorldGraph();
541
542 vector<Segment> segments;
543
544 m_guides.SetGuidesGraphParams(guidesMwmId, m_estimator->GetMaxWeightSpeedMpS());
545 m_guides.ConnectToGuidesGraph(checkpoints.GetPoints());
546
547 uint32_t const startIdx = ConnectTracksOnGuidesToOsm(checkpoints.GetPoints(), *graph);
548 ConnectCheckpointsOnGuidesToOsm(checkpoints.GetPoints(), *graph);
549
550 size_t subrouteSegmentsBegin = 0;
551 vector<Route::SubrouteAttrs> subroutes;
552 PushPassedSubroutes(checkpoints, subroutes);
553
554 unique_ptr<IndexGraphStarter> starter;
555
556 auto progress = make_shared<AStarProgress>();
557 double const checkpointsLength = checkpoints.GetSummaryLengthBetweenPointsMeters();
558
559 PointsOnEdgesSnapping snapping(*this, *graph);
560 size_t const subroutesCount = checkpoints.GetNumSubroutes();
561 for (size_t i = checkpoints.GetPassedIdx(); i < subroutesCount; ++i)
562 {
563 auto const & startCheckpoint = checkpoints.GetPoint(i);
564 auto const & finishCheckpoint = checkpoints.GetPoint(i + 1);
565

Callers

nothing calls this directly

Calls 15

PushPassedSubroutesFunction · 0.85
GetLastRealOrPartFunction · 0.85
AddAbsentCountryMethod · 0.80
SetGuidesGraphParamsMethod · 0.80
GetMaxWeightSpeedMpSMethod · 0.80
ConnectToGuidesGraphMethod · 0.80
GetNumSubroutesMethod · 0.80
GetPassedIdxMethod · 0.80
SnapMethod · 0.80
GetNumFakeSegmentsMethod · 0.80
AppendSubProgressMethod · 0.80

Tested by

no test coverage detected