diff options
author | Mikhail Gorbushin <m.gorbushin@corp.mail.ru> | 2019-02-21 15:48:31 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <bykoianko@gmail.com> | 2019-02-27 13:36:17 +0300 |
commit | 7aa880286331f7dbfd6546020188295b39ea711b (patch) | |
tree | 93a872bd478e4c736e8beb75bcac8b0e88971c0f /routing | |
parent | bee78bf6ccf17ac92f8378798c1d0c9ea816772d (diff) |
[routing] Fix warnings from static analyzer
Diffstat (limited to 'routing')
-rw-r--r-- | routing/cross_mwm_graph.cpp | 1 | ||||
-rw-r--r-- | routing/edge_estimator.cpp | 17 | ||||
-rw-r--r-- | routing/routing_helpers.cpp | 34 | ||||
-rw-r--r-- | routing/routing_helpers.hpp | 4 | ||||
-rw-r--r-- | routing/routing_integration_tests/routing_test_tools.cpp | 20 | ||||
-rw-r--r-- | routing/routing_tests/astar_router_test.cpp | 2 | ||||
-rw-r--r-- | routing/routing_tests/async_router_test.cpp | 2 | ||||
-rw-r--r-- | routing/routing_tests/routing_algorithm.cpp | 2 | ||||
-rw-r--r-- | routing/turns_sound_settings.cpp | 1 |
9 files changed, 12 insertions, 71 deletions
diff --git a/routing/cross_mwm_graph.cpp b/routing/cross_mwm_graph.cpp index 31abdad694..3f71969da6 100644 --- a/routing/cross_mwm_graph.cpp +++ b/routing/cross_mwm_graph.cpp @@ -156,7 +156,6 @@ void CrossMwmGraph::Clear() void CrossMwmGraph::GetTwinFeature(Segment const & segment, bool isOutgoing, vector<Segment> & twins) { - vector<Segment> result; std::vector<uint32_t> const & transitSegmentIds = m_crossMwmIndexGraph.GetTransitSegmentId(segment.GetMwmId(), segment.GetFeatureId()); diff --git a/routing/edge_estimator.cpp b/routing/edge_estimator.cpp index 39bef23fba..40a324e1a0 100644 --- a/routing/edge_estimator.cpp +++ b/routing/edge_estimator.cpp @@ -36,9 +36,11 @@ double TimeBetweenSec(m2::PointD const & from, m2::PointD const & to, double spe double CalcTrafficFactor(SpeedGroup speedGroup) { - double constexpr kImpossibleDrivingFactor = 1e4; if (speedGroup == SpeedGroup::TempBlock) + { + double constexpr kImpossibleDrivingFactor = 1e4; return kImpossibleDrivingFactor; + } double const percentage = 0.01 * static_cast<double>(kSpeedGroupThresholdPercentage[static_cast<size_t>(speedGroup)]); @@ -219,12 +221,6 @@ bool CarEstimator::LeapIsAllowed(NumMwmId mwmId) const { return !m_trafficStash- double CarEstimator::CalcSegment(Purpose purpose, Segment const & segment, RoadGeometry const & road) const { - // Current time estimation are too optimistic. - // Need more accurate tuning: traffic lights, traffic jams, road models and so on. - // Add some penalty to make estimation of a more realistic. - // TODO: make accurate tuning, remove penalty. - double constexpr kTimePenalty = 1.8; - double result = CalcClimbSegment(purpose, segment, road, GetCarClimbPenalty); if (m_trafficStash) @@ -234,7 +230,14 @@ double CarEstimator::CalcSegment(Purpose purpose, Segment const & segment, RoadG double const trafficFactor = CalcTrafficFactor(speedGroup); result *= trafficFactor; if (speedGroup != SpeedGroup::Unknown && speedGroup != SpeedGroup::G5) + { + // Current time estimation are too optimistic. + // Need more accurate tuning: traffic lights, traffic jams, road models and so on. + // Add some penalty to make estimation of a more realistic. + // TODO: make accurate tuning, remove penalty. + double constexpr kTimePenalty = 1.8; result *= kTimePenalty; + } } return result; diff --git a/routing/routing_helpers.cpp b/routing/routing_helpers.cpp index 09ac8fa738..b532ac8011 100644 --- a/routing/routing_helpers.cpp +++ b/routing/routing_helpers.cpp @@ -151,38 +151,4 @@ Segment ConvertEdgeToSegment(NumMwmIds const & numMwmIds, Edge const & edge) numMwmIds.GetId(edge.GetFeatureId().m_mwmId.GetInfo()->GetLocalFile().GetCountryFile()); return Segment(numMwmId, edge.GetFeatureId().m_index, edge.GetSegId(), edge.IsForward()); } - -void CalculateMaxSpeedTimes(RoadGraphBase const & graph, vector<Junction> const & path, - Route::TTimes & times) -{ - times.clear(); - if (path.empty()) - return; - - // graph.GetMaxSpeedKMpH() below is used on purpose. - // The idea is while pedestrian (bicycle) routing ways for pedestrians (cyclists) are preferred. - // At the same time routing along big roads is still possible but if there's - // a pedestrian (bicycle) alternative it's prefered. To implement it a small speed - // is set in pedestrian_model (bicycle_model) for big roads. On the other hand - // the most likely a pedestrian (a cyclist) will go along big roads with average - // speed (graph.GetMaxSpeedKMpH()). - // @TODO Eta part of speed should be used here. - double const speedMpS = KMPH2MPS(graph.GetMaxSpeedKMpH()); - CHECK_GREATER(speedMpS, 0.0, ()); - - times.reserve(path.size()); - - double trackTimeSec = 0.0; - times.emplace_back(0, trackTimeSec); - - for (size_t i = 1; i < path.size(); ++i) - { - double const lengthM = - MercatorBounds::DistanceOnEarth(path[i - 1].GetPoint(), path[i].GetPoint()); - trackTimeSec += lengthM / speedMpS; - - times.emplace_back(i, trackTimeSec); - } - CHECK_EQUAL(times.size(), path.size(), ()); -} } // namespace routing diff --git a/routing/routing_helpers.hpp b/routing/routing_helpers.hpp index 0568f05d56..72e6e311f8 100644 --- a/routing/routing_helpers.hpp +++ b/routing/routing_helpers.hpp @@ -50,10 +50,6 @@ void ReconstructRoute(IDirectionsEngine & engine, IndexRoadGraph const & graph, /// \returns Segment() if mwm of |edge| is not alive. Segment ConvertEdgeToSegment(NumMwmIds const & numMwmIds, Edge const & edge); -/// \brief Fills |times| according to max speed at |graph| and |path|. -void CalculateMaxSpeedTimes(RoadGraphBase const & graph, std::vector<Junction> const & path, - Route::TTimes & times); - /// \brief Checks is edge connected with world graph. Function does BFS while it finds some number /// of edges, /// if graph ends before this number is reached then junction is assumed as not connected to the diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp index fd3732adbc..8f879c9842 100644 --- a/routing/routing_integration_tests/routing_test_tools.cpp +++ b/routing/routing_integration_tests/routing_test_tools.cpp @@ -122,26 +122,6 @@ unique_ptr<IndexRouter> CreateVehicleRouter(DataSource & dataSource, return indexRouter; } -unique_ptr<IRouter> CreateAStarRouter(DataSource & dataSource, - storage::CountryInfoGetter const & infoGetter, - vector<LocalCountryFile> const & localFiles, - TRouterFactory const & routerFactory) -{ - // |infoGetter| should be a reference to an object which exists while the - // result of the function is used. - auto countryFileGetter = [&infoGetter](m2::PointD const & pt) - { - return infoGetter.GetRegionCountryId(pt); - }; - - auto numMwmIds = make_shared<NumMwmIds>(); - for (auto const & file : localFiles) - numMwmIds->RegisterFile(file.GetCountryFile()); - - unique_ptr<IRouter> router = routerFactory(dataSource, countryFileGetter, numMwmIds); - return unique_ptr<IRouter>(move(router)); -} - void GetAllLocalFiles(vector<LocalCountryFile> & localFiles) { // Setting stored paths from testingmain.cpp diff --git a/routing/routing_tests/astar_router_test.cpp b/routing/routing_tests/astar_router_test.cpp index bc4b20f1d3..cd495a3ff8 100644 --- a/routing/routing_tests/astar_router_test.cpp +++ b/routing/routing_tests/astar_router_test.cpp @@ -133,7 +133,6 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents) {MakeJunctionForTesting(m2::PointD(10, 90)), MakeJunctionForTesting(m2::PointD(10, 10))}), // feature 3 }; - vector<uint32_t> const featureId_1 = { 0, 1, 2, 3 }; // featureIDs in the first connected component // Roads in the second connected component. vector<IRoadGraph::RoadInfo> const roadInfo_2 = { @@ -150,7 +149,6 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents) {MakeJunctionForTesting(m2::PointD(30, 70)), MakeJunctionForTesting(m2::PointD(30, 30))}), // feature 7 }; - vector<uint32_t> const featureId_2 = { 4, 5, 6, 7 }; // featureIDs in the second connected component for (auto const & ri : roadInfo_1) graph.AddRoad(IRoadGraph::RoadInfo(ri)); diff --git a/routing/routing_tests/async_router_test.cpp b/routing/routing_tests/async_router_test.cpp index 6f915c0810..f6d78fee9c 100644 --- a/routing/routing_tests/async_router_test.cpp +++ b/routing/routing_tests/async_router_test.cpp @@ -55,7 +55,7 @@ class DummyFetcher : public IOnlineFetcher vector<string> m_absent; public: - DummyFetcher(vector<string> const & absent) : m_absent(absent) {} + explicit DummyFetcher(vector<string> const & absent) : m_absent(absent) {} // IOnlineFetcher overrides: void GenerateRequest(Checkpoints const &) override {} diff --git a/routing/routing_tests/routing_algorithm.cpp b/routing/routing_tests/routing_algorithm.cpp index b4428193ef..b4267a7ca1 100644 --- a/routing/routing_tests/routing_algorithm.cpp +++ b/routing/routing_tests/routing_algorithm.cpp @@ -52,7 +52,7 @@ public: using Edge = WeightedEdge; using Weight = double; - RoadGraph(IRoadGraph const & roadGraph) + explicit RoadGraph(IRoadGraph const & roadGraph) : m_roadGraph(roadGraph), m_maxSpeedMPS(KMPH2MPS(roadGraph.GetMaxSpeedKMpH())) {} diff --git a/routing/turns_sound_settings.cpp b/routing/turns_sound_settings.cpp index a753f325e1..8e922a76d2 100644 --- a/routing/turns_sound_settings.cpp +++ b/routing/turns_sound_settings.cpp @@ -108,7 +108,6 @@ uint32_t Settings::ComputeDistToPronounceDistM(double speedMetersPerSecond) cons string DebugPrint(Notification const & notification) { - string units; stringstream out; out << "Notification [ m_distanceUnits == " << notification.m_distanceUnits << ", m_exitNum == " << notification.m_exitNum |