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

Method SetRouterImpl

libs/map/routing_manager.cpp:515–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515void RoutingManager::SetRouterImpl(RouterType type)
516{
517 auto const dataSourceGetterFn = m_callbacks.m_dataSourceGetter;
518 CHECK(dataSourceGetterFn, ("Type:", type));
519
520 VehicleType const vehicleType = GetVehicleType(type);
521
522 m_loadAltitudes = vehicleType != VehicleType::Car;
523
524 auto const countryFileGetter = [this](m2::PointD const & p) -> string
525 {
526 // TODO (@gorshenin): fix CountryInfoGetter to return CountryFile
527 // instances instead of plain strings.
528 return m_callbacks.m_countryInfoGetter().GetRegionCountryId(p);
529 };
530
531 auto numMwmIds = make_shared<NumMwmIds>();
532 m_delegate.RegisterCountryFilesOnRoute(numMwmIds);
533
534 auto & dataSource = m_callbacks.m_dataSourceGetter();
535
536 auto localFileChecker = [this](string const & countryFile) -> bool
537 {
538 MwmSet::MwmId const mwmId =
539 m_callbacks.m_dataSourceGetter().GetMwmIdByCountryFile(platform::CountryFile(countryFile));
540 return mwmId.IsAlive();
541 };
542
543 auto const getMwmRectByName = [this](string const & countryId) -> m2::RectD
544 { return m_callbacks.m_countryInfoGetter().GetLimitRectForLeaf(countryId); };
545
546 auto regionsFinder = make_unique<AbsentRegionsFinder>(countryFileGetter, localFileChecker, numMwmIds, dataSource);
547
548 std::unique_ptr<IRouter> router;
549 if (type == RouterType::Ruler)
550 router = make_unique<RulerRouter>();
551 else
552 router = make_unique<IndexRouter>(
553 vehicleType, m_loadAltitudes, m_callbacks.m_countryParentNameGetterFn, countryFileGetter, getMwmRectByName,
554 numMwmIds, MakeNumMwmTree(*numMwmIds, m_callbacks.m_countryInfoGetter()), m_routingSession, dataSource);
555
556 m_routingSession.SetRoutingSettings(GetRoutingSettings(vehicleType));
557 m_routingSession.SetRouter(std::move(router), std::move(regionsFinder));
558 m_currentRouterType = type;
559}
560
561void RoutingManager::RemoveRoute(bool deactivateFollowing)
562{

Callers 1

FrameworkMethod · 0.80

Calls 11

GetVehicleTypeFunction · 0.85
MakeNumMwmTreeFunction · 0.85
GetRoutingSettingsFunction · 0.85
GetRegionCountryIdMethod · 0.80
GetMwmIdByCountryFileMethod · 0.80
GetLimitRectForLeafMethod · 0.80
CountryFileClass · 0.50
IsAliveMethod · 0.45
SetRoutingSettingsMethod · 0.45
SetRouterMethod · 0.45

Tested by

no test coverage detected