diff --git a/map/framework.cpp b/map/framework.cpp index f2428e5f94..4d9a928ef9 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -356,8 +356,7 @@ Framework::Framework() , m_isRenderingEnabled(true) , m_trackingReporter(platform::CreateSocket(), TRACKING_REALTIME_HOST, TRACKING_REALTIME_PORT, tracking::Reporter::kPushDelayMs) - , m_trafficManager(bind(&Framework::GetMwmsByRect, this, _1), - kMaxTrafficCacheSizeBytes, + , m_trafficManager(bind(&Framework::GetMwmsByRect, this, _1), kMaxTrafficCacheSizeBytes, // Note. |m_routingSession| should be declared before |m_trafficManager|. m_routingSession) , m_displacementModeManager([this](bool show) { diff --git a/map/traffic_manager.cpp b/map/traffic_manager.cpp index a7cea9da6a..c356005b71 100644 --- a/map/traffic_manager.cpp +++ b/map/traffic_manager.cpp @@ -37,8 +37,7 @@ TrafficManager::CacheEntry::CacheEntry(time_point const & requestT , m_lastAvailability(traffic::TrafficInfo::Availability::Unknown) {} -TrafficManager::TrafficManager(GetMwmsByRectFn const & getMwmsByRectFn, - size_t maxCacheSizeBytes, +TrafficManager::TrafficManager(GetMwmsByRectFn const & getMwmsByRectFn, size_t maxCacheSizeBytes, traffic::RoutingObserver & routingObserver) : m_getMwmsByRectFn(getMwmsByRectFn) , m_routingObserver(routingObserver) diff --git a/routing/edge_estimator.cpp b/routing/edge_estimator.cpp index fe05f186a3..13911d50cc 100644 --- a/routing/edge_estimator.cpp +++ b/routing/edge_estimator.cpp @@ -51,9 +51,12 @@ double CarEdgeEstimator::CalcEdgesWeight(uint32_t featureId, RoadGeometry const double factor = 1.0; if (m_trafficInfo) { - SpeedGroup const speedGroup = m_trafficInfo->GetSpeedGroup(TrafficInfo::RoadSegmentId(featureId, i, dir)); + SpeedGroup const speedGroup = + m_trafficInfo->GetSpeedGroup(TrafficInfo::RoadSegmentId(featureId, i, dir)); CHECK_LESS(speedGroup, SpeedGroup::Count, ()); - double const percentage = 0.01 * static_cast(kSpeedGroupThresholdPercentage[static_cast(speedGroup)]); + double const percentage = + 0.01 * + static_cast(kSpeedGroupThresholdPercentage[static_cast(speedGroup)]); factor = 1.0 / percentage; } result += factor * TimeBetweenSec(road.GetPoint(i), road.GetPoint(i + 1), speedMPS); diff --git a/routing/edge_estimator.hpp b/routing/edge_estimator.hpp index 3a3b8ae14d..d39090ed18 100644 --- a/routing/edge_estimator.hpp +++ b/routing/edge_estimator.hpp @@ -17,8 +17,8 @@ class EdgeEstimator public: virtual ~EdgeEstimator() = default; - virtual double CalcEdgesWeight(uint32_t featureId, RoadGeometry const & road, - uint32_t pointFrom, uint32_t pointTo) const = 0; + virtual double CalcEdgesWeight(uint32_t featureId, RoadGeometry const & road, uint32_t pointFrom, + uint32_t pointTo) const = 0; virtual double CalcHeuristic(m2::PointD const & from, m2::PointD const & to) const = 0; void SetTrafficInfo(shared_ptr trafficInfo); diff --git a/routing/index_graph.cpp b/routing/index_graph.cpp index 296e29d298..2a5fde1693 100644 --- a/routing/index_graph.cpp +++ b/routing/index_graph.cpp @@ -72,8 +72,8 @@ void IndexGraph::GetNeighboringEdge(RoadGeometry const & road, RoadPoint const & pair const & neighbor = m_roadIndex.FindNeighbor(rp, forward); if (neighbor.first != Joint::kInvalidId) { - double const distance = m_estimator->CalcEdgesWeight(rp.GetFeatureId(), road, - rp.GetPointId(), neighbor.second); + double const distance = + m_estimator->CalcEdgesWeight(rp.GetFeatureId(), road, rp.GetPointId(), neighbor.second); edges.push_back({neighbor.first, distance}); } } diff --git a/routing/index_graph_starter.cpp b/routing/index_graph_starter.cpp index 30659cd61e..158b7030b3 100644 --- a/routing/index_graph_starter.cpp +++ b/routing/index_graph_starter.cpp @@ -154,12 +154,12 @@ void IndexGraphStarter::FindPointsWithCommonFeature(Joint::Id jointId0, Joint::I // CalcEdgesWeight is very expensive. // So calculate it only if second common feature found. RoadGeometry const & prevRoad = m_graph.GetGeometry().GetRoad(result0.GetFeatureId()); - minWeight = m_graph.GetEstimator().CalcEdgesWeight(rp0.GetFeatureId(),prevRoad, - result0.GetPointId(), result1.GetPointId()); + minWeight = m_graph.GetEstimator().CalcEdgesWeight( + rp0.GetFeatureId(), prevRoad, result0.GetPointId(), result1.GetPointId()); } - double const weight = m_graph.GetEstimator().CalcEdgesWeight(rp0.GetFeatureId(), road, - rp0.GetPointId(), rp1.GetPointId()); + double const weight = m_graph.GetEstimator().CalcEdgesWeight( + rp0.GetFeatureId(), road, rp0.GetPointId(), rp1.GetPointId()); if (weight < minWeight) { minWeight = weight; diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp index edc3fecbd2..7c065f03e9 100644 --- a/routing/routing_integration_tests/routing_test_tools.cpp +++ b/routing/routing_integration_tests/routing_test_tools.cpp @@ -83,8 +83,8 @@ namespace integration return infoGetter.GetRegionCountryId(pt); }; - auto carRouter = make_unique( - index, countryFileGetter, SingleMwmRouter::CreateCarRouter(index, trafficGetter)); + auto carRouter = make_unique(index, countryFileGetter, + SingleMwmRouter::CreateCarRouter(index, trafficGetter)); return carRouter; } @@ -112,7 +112,6 @@ namespace integration } IRouter * GetRouter() const override { return m_carRouter.get(); } - private: TrafficInfoGetterTest m_trafficGetter; unique_ptr m_carRouter; diff --git a/routing/routing_integration_tests/routing_test_tools.hpp b/routing/routing_integration_tests/routing_test_tools.hpp index 40b8ad132a..fcfd8e8113 100644 --- a/routing/routing_integration_tests/routing_test_tools.hpp +++ b/routing/routing_integration_tests/routing_test_tools.hpp @@ -56,8 +56,7 @@ class IRouterComponents { public: IRouterComponents(vector const & localFiles) - : m_featuresFetcher(CreateFeaturesFetcher(localFiles)) - , m_infoGetter(CreateCountryInfoGetter()) + : m_featuresFetcher(CreateFeaturesFetcher(localFiles)), m_infoGetter(CreateCountryInfoGetter()) { } @@ -65,12 +64,8 @@ public: virtual IRouter * GetRouter() const = 0; - storage::CountryInfoGetter const & GetCountryInfoGetter() const noexcept - { - return *m_infoGetter; - } - - protected: + storage::CountryInfoGetter const & GetCountryInfoGetter() const noexcept { return *m_infoGetter; } +protected: shared_ptr m_featuresFetcher; unique_ptr m_infoGetter; }; @@ -92,11 +87,13 @@ void TestOnlineFetcher(ms::LatLon const & startPoint, ms::LatLon const & finalPo /// Gets OSRM router components IRouterComponents & GetOsrmComponents(); -shared_ptr GetOsrmComponents(vector const & localFiles); +shared_ptr GetOsrmComponents( + vector const & localFiles); /// Gets pedestrian router components IRouterComponents & GetPedestrianComponents(); -shared_ptr GetPedestrianComponents(vector const & localFiles); +shared_ptr GetPedestrianComponents( + vector const & localFiles); /// Gets bicycle router components. IRouterComponents & GetBicycleComponents(); @@ -114,10 +111,8 @@ void TestTurnCount(Route const & route, uint32_t expectedTurnCount); /// A created route will pass the test iff /// expectedRouteMeters - expectedRouteMeters * relativeError <= route->GetDistance() /// && expectedRouteMeters + expectedRouteMeters * relativeError >= route->GetDistance() -void TestRouteLength(Route const & route, double expectedRouteMeters, - double relativeError = 0.01); -void TestRouteTime(Route const & route, double expectedRouteSeconds, - double relativeError = 0.01); +void TestRouteLength(Route const & route, double expectedRouteMeters, double relativeError = 0.01); +void TestRouteTime(Route const & route, double expectedRouteSeconds, double relativeError = 0.01); void CalculateRouteAndTestRouteLength(IRouterComponents const & routerComponents, m2::PointD const & startPoint, @@ -135,24 +130,21 @@ class TestTurn bool const m_isValid; TestTurn() - : m_point({0., 0.}), - m_direction(TurnDirection::NoTurn), - m_roundAboutExitNum(0), - m_isValid(false) + : m_point({0., 0.}) + , m_direction(TurnDirection::NoTurn) + , m_roundAboutExitNum(0) + , m_isValid(false) { } TestTurn(m2::PointD const & pnt, TurnDirection direction, uint32_t roundAboutExitNum) - : m_point(pnt), - m_direction(direction), - m_roundAboutExitNum(roundAboutExitNum), - m_isValid(true) + : m_point(pnt), m_direction(direction), m_roundAboutExitNum(roundAboutExitNum), m_isValid(true) { } public: const TestTurn & TestValid() const; const TestTurn & TestNotValid() const; - const TestTurn & TestPoint(m2::PointD const & expectedPoint, double inaccuracyMeters = 3.) const; + const TestTurn & TestPoint(m2::PointD const & expectedPoint, double inaccuracyMeters = 3.) const; const TestTurn & TestDirection(TurnDirection expectedDirection) const; const TestTurn & TestOneOfDirections(set const & expectedDirections) const; const TestTurn & TestRoundAboutExitNum(uint32_t expectedRoundAboutExitNum) const; diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index 26dfefb181..c62f4defde 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -594,8 +594,7 @@ void RoutingSession::OnTrafficInfoAdded(TrafficInfo const & info) UNUSED_VALUE(guard); // @TODO(bykoianko) It's worth considering moving a big |info.GetColoring()| // not copying as it's done now. - m_trafficInfo.insert(make_pair(info.GetMwmId(), - make_shared(info))); + m_trafficInfo.insert(make_pair(info.GetMwmId(), make_shared(info))); } void RoutingSession::OnTrafficInfoRemoved(MwmSet::MwmId const & mwmId) diff --git a/routing/routing_tests/applying_traffic_test.cpp b/routing/routing_tests/applying_traffic_test.cpp index 01cd2f0dfa..1adee5658d 100644 --- a/routing/routing_tests/applying_traffic_test.cpp +++ b/routing/routing_tests/applying_traffic_test.cpp @@ -68,8 +68,8 @@ AStarAlgorithm::Result CalculateRoute(IndexGraphStarter & sta { AStarAlgorithm algorithm; RoutingResult routingResult; - auto const resultCode = algorithm.FindPath( - starter, starter.GetStartJoint(), starter.GetFinishJoint(), routingResult, {}, {}); + auto const resultCode = algorithm.FindPath(starter, starter.GetStartJoint(), + starter.GetFinishJoint(), routingResult, {}, {}); starter.RedressRoute(routingResult.path, roadPoints); return resultCode; @@ -135,15 +135,15 @@ unique_ptr BuildXXGraph(shared_ptr estimator) RoadGeometry::Points({{3.0, 0.0}, {3.0, 1.0}})); vector const joints = { - MakeJoint({{0 /* feature id */, 0 /* point id */}}), /* joint at point (0, 0) */ - MakeJoint({{1, 0}, {7, 0}}), /* joint at point (2, 0) */ - MakeJoint({{0, 1}, {1, 1}, {2, 0}, {3, 0}}), /* joint at point (1, 1) */ - MakeJoint({{2, 1}}), /* joint at point (0, 2) */ - MakeJoint({{3, 1}, {4, 1}, {5, 0}, {6, 0}}), /* joint at point (2, 2) */ - MakeJoint({{4, 0}, {8, 1}}), /* joint at point (3, 1) */ - MakeJoint({{5, 1}}), /* joint at point (1, 3) */ - MakeJoint({{6, 1}}), /* joint at point (3, 3) */ - MakeJoint({{7, 1}, {8, 0}}), /* joint at point (3, 0) */ + MakeJoint({{0 /* feature id */, 0 /* point id */}}), /* joint at point (0, 0) */ + MakeJoint({{1, 0}, {7, 0}}), /* joint at point (2, 0) */ + MakeJoint({{0, 1}, {1, 1}, {2, 0}, {3, 0}}), /* joint at point (1, 1) */ + MakeJoint({{2, 1}}), /* joint at point (0, 2) */ + MakeJoint({{3, 1}, {4, 1}, {5, 0}, {6, 0}}), /* joint at point (2, 2) */ + MakeJoint({{4, 0}, {8, 1}}), /* joint at point (3, 1) */ + MakeJoint({{5, 1}}), /* joint at point (1, 3) */ + MakeJoint({{6, 1}}), /* joint at point (3, 3) */ + MakeJoint({{7, 1}, {8, 0}}), /* joint at point (3, 0) */ }; unique_ptr graph = make_unique(move(loader), estimator); @@ -170,8 +170,9 @@ UNIT_TEST(XXGraph_G0onF3) classificator::Load(); shared_ptr estimator = EdgeEstimator::CreateForCar(*make_shared()->GetVehicleModel()); - TrafficInfo::Coloring coloring = - {{{3 /* feature id */, 0 /* segment id */, TrafficInfo::RoadSegmentId::kForwardDirection}, SpeedGroup::G0}}; + TrafficInfo::Coloring coloring = { + {{3 /* feature id */, 0 /* segment id */, TrafficInfo::RoadSegmentId::kForwardDirection}, + SpeedGroup::G0}}; shared_ptr trafficInfo = make_shared(); trafficInfo->SetColoringForTesting(coloring); estimator->SetTrafficInfo(trafficInfo); @@ -187,11 +188,15 @@ UNIT_TEST(XXGraph_G0onF3andF6andG4onF8andF4) { shared_ptr estimator = EdgeEstimator::CreateForCar(*make_shared()->GetVehicleModel()); - TrafficInfo::Coloring coloring = - {{{3 /* feature id */, 0 /* segment id */, TrafficInfo::RoadSegmentId::kForwardDirection}, SpeedGroup::G0}, - {{6 /* feature id */, 0 /* segment id */, TrafficInfo::RoadSegmentId::kForwardDirection}, SpeedGroup::G0}, - {{8 /* feature id */, 0 /* segment id */, TrafficInfo::RoadSegmentId::kForwardDirection}, SpeedGroup::G4}, - {{7 /* feature id */, 0 /* segment id */, TrafficInfo::RoadSegmentId::kForwardDirection}, SpeedGroup::G4}}; + TrafficInfo::Coloring coloring = { + {{3 /* feature id */, 0 /* segment id */, TrafficInfo::RoadSegmentId::kForwardDirection}, + SpeedGroup::G0}, + {{6 /* feature id */, 0 /* segment id */, TrafficInfo::RoadSegmentId::kForwardDirection}, + SpeedGroup::G0}, + {{8 /* feature id */, 0 /* segment id */, TrafficInfo::RoadSegmentId::kForwardDirection}, + SpeedGroup::G4}, + {{7 /* feature id */, 0 /* segment id */, TrafficInfo::RoadSegmentId::kForwardDirection}, + SpeedGroup::G4}}; shared_ptr trafficInfo = make_shared(); trafficInfo->SetColoringForTesting(coloring); estimator->SetTrafficInfo(trafficInfo); diff --git a/routing/single_mwm_router.cpp b/routing/single_mwm_router.cpp index 265649de7e..7fff098e56 100644 --- a/routing/single_mwm_router.cpp +++ b/routing/single_mwm_router.cpp @@ -214,8 +214,8 @@ bool SingleMwmRouter::LoadIndex(MwmSet::MwmId const & mwmId, string const & coun } // static -unique_ptr SingleMwmRouter::CreateCarRouter(Index const & index, - traffic::TrafficInfoGetter const & getter) +unique_ptr SingleMwmRouter::CreateCarRouter( + Index const & index, traffic::TrafficInfoGetter const & getter) { auto vehicleModelFactory = make_shared(); // @TODO Bicycle turn generation engine is used now. It's ok for the time being. diff --git a/traffic/traffic_info.hpp b/traffic/traffic_info.hpp index 99d5a8d974..53f485b49c 100644 --- a/traffic/traffic_info.hpp +++ b/traffic/traffic_info.hpp @@ -69,7 +69,6 @@ public: TrafficInfo(MwmSet::MwmId const & mwmId, int64_t currentDataVersion); void SetColoringForTesting(Coloring & coloring) { m_coloring = coloring; } - // Fetches the latest traffic data from the server and updates the coloring. // Construct the url by passing an MwmId. // *NOTE* This method must not be called on the UI thread. @@ -109,6 +108,6 @@ class TrafficInfoGetter public: virtual ~TrafficInfoGetter() = default; - virtual shared_ptrGetTrafficInfo(MwmSet::MwmId const & mwmId) const = 0; + virtual shared_ptr GetTrafficInfo(MwmSet::MwmId const & mwmId) const = 0; }; } // namespace traffic