diff --git a/routing/cross_mwm_index_graph.hpp b/routing/cross_mwm_index_graph.hpp index d3456849f7..f58fb5c857 100644 --- a/routing/cross_mwm_index_graph.hpp +++ b/routing/cross_mwm_index_graph.hpp @@ -46,19 +46,9 @@ public: template void ForEachTransition(NumMwmId numMwmId, bool isEnter, Fn && fn) { - if (isEnter) - { - auto const & enters = - GetCrossMwmConnectorWithTransitions(numMwmId).GetEnters(); - for (auto const & enter : enters) - fn(enter); - } - else - { - std::vector const & exits = GetCrossMwmConnectorWithTransitions(numMwmId).GetExits(); - for (Segment const & exit : exits) - fn(exit); - } + auto const & connectors = GetCrossMwmConnectorWithTransitions(numMwmId); + for (Segment const & t : (isEnter ? connectors.GetEnters() : connectors.GetExits())) + fn(t); } private: diff --git a/routing/cross_mwm_osrm_graph.hpp b/routing/cross_mwm_osrm_graph.hpp index 444681147c..279aef1924 100644 --- a/routing/cross_mwm_osrm_graph.hpp +++ b/routing/cross_mwm_osrm_graph.hpp @@ -34,16 +34,9 @@ public: template void ForEachTransition(NumMwmId numMwmId, bool isEnter, Fn && fn) { - if (isEnter) - { - for (auto const & kv : GetSegmentMaps(numMwmId).m_ingoing) - fn(kv.first); - } - else - { - for (auto const & kv : GetSegmentMaps(numMwmId).m_outgoing) - fn(kv.first); - } + auto const & ts = GetSegmentMaps(numMwmId); + for (auto const & kv : isEnter ? ts.m_ingoing : ts.m_outgoing) + fn(kv.first); } private: diff --git a/routing/edge_estimator.hpp b/routing/edge_estimator.hpp index def69fa598..a866c3e581 100644 --- a/routing/edge_estimator.hpp +++ b/routing/edge_estimator.hpp @@ -28,9 +28,8 @@ public: // edge |from|-|to|. // Note 1. The result of the method should be used if it's necessary to add a leap (fake) edge // (|from|, |to|) in road graph. - // Note 2. The result of the method should be less or equal to CalcHeuristic(|form|, |to|). - // Note 3. It's assumed here that GetEstimator().CalcLeapWeight(p1, p2) == - // GetEstimator().CalcLeapWeight(p2, p1). + // Note 2. The result of the method should be less or equal to CalcHeuristic(|from|, |to|). + // Note 3. It's assumed here that CalcLeapWeight(p1, p2) == CalcLeapWeight(p2, p1). virtual double CalcLeapWeight(m2::PointD const & from, m2::PointD const & to) const = 0; virtual double GetUTurnPenalty() const = 0; // The leap is the shortcut edge from mwm border enter to exit. diff --git a/routing/index_graph_starter.cpp b/routing/index_graph_starter.cpp index 778a4fb93c..a7585487d9 100644 --- a/routing/index_graph_starter.cpp +++ b/routing/index_graph_starter.cpp @@ -124,9 +124,9 @@ void IndexGraphStarter::ConnectLeapToTransitions(FakeVertex const & fakeVertex, m2::PointD const & segmentPoint = fakeVertex.GetPoint(); // Note. If |isOutgoing| == true it's necessary to add edges which connect the start with all - // exits of its mwm. - // So |isEnter| below should be set to false. If |isOutgoing| == false all enters of the - // finish mwm should be connected with the finish point. So |isEnter| below should be set to true. + // exits of its mwm. So |isEnter| below should be set to false. + // If |isOutgoing| == false all enters of the finish mwm should be connected with the finish point. + // So |isEnter| below should be set to true. m_graph.ForEachTransition( fakeVertex.GetMwmId(), !isOutgoing /* isEnter */, [&](Segment const & transition) { edges.emplace_back(transition, m_graph.GetEstimator().CalcLeapWeight( diff --git a/routing/index_graph_starter.hpp b/routing/index_graph_starter.hpp index 68e002e395..3403fba00f 100644 --- a/routing/index_graph_starter.hpp +++ b/routing/index_graph_starter.hpp @@ -111,10 +111,10 @@ private: void GetNormalToFakeEdge(Segment const & segment, FakeVertex const & fakeVertex, Segment const & fakeSegment, bool isOutgoing, vector & edges); - /// \brief If |toExits| == true fills |edges| with SegmentEdge(s) which connects - /// |segment| with all exits of mwm. - /// \brief If |toExits| == false fills |edges| with SegmentEdge(s) which connects - /// all enters to mwm with |segment|. + /// \brief If |isOutgoing| == true fills |edges| with SegmentEdge(s) which connects + /// |fakeVertex| with all exits of mwm. + /// \brief If |isOutgoing| == false fills |edges| with SegmentEdge(s) which connects + /// all enters to mwm with |fakeVertex|. void ConnectLeapToTransitions(FakeVertex const & fakeVertex, bool isOutgoing, vector & edges); diff --git a/routing/routing_tests/index_graph_test.cpp b/routing/routing_tests/index_graph_test.cpp index e8bce04a1e..ef92644d38 100644 --- a/routing/routing_tests/index_graph_test.cpp +++ b/routing/routing_tests/index_graph_test.cpp @@ -462,20 +462,20 @@ UNIT_TEST(SerializeSimpleGraph) // F2 // | // | -// 0.0003 *---------* +// 0.0003 6*---------*5 // | | // | | // | | // | | // | | -// 0.0002 * * +// 0.0002 7* *4 // | | // | | -// 0.00015 * F0 * +// 0.00015 8* F0 *3 // \ / -// \ / -// 0.0001 *---F0-*----* -// ^ +// \ / 1 0 +// 0.0001 9*---F0-*----* +// 2 ^ // | // F1 // | @@ -524,7 +524,7 @@ UNIT_CLASS_TEST(RestrictionTest, LoopGraph) routing::IndexGraphStarter::FakeVertex(kTestNumMwmId, 2, 0 /* seg id */, m2::PointD(0.00005, 0.0004)) /* finish */); - double constexpr kExpectedRouteTimeSec = 3.48; + double constexpr kExpectedRouteTimeSec = 3.92527; TestRouteTime(*m_starter, AStarAlgorithm::Result::OK, kExpectedRouteTimeSec); } diff --git a/routing/world_graph.hpp b/routing/world_graph.hpp index 76160c25c8..984cafe1f5 100644 --- a/routing/world_graph.hpp +++ b/routing/world_graph.hpp @@ -26,7 +26,7 @@ public: LeapsIfPossible, // Mode for building cross mwm and single mwm routes. In case of cross mwm route // if they are neighboring mwms the route will be made without leaps. // If not the route is made with leaps for intermediate mwms. - NoLeaps, // Mode for building route and getting outgoing/ingoing edges without leaps anyway. + NoLeaps, // Mode for building route and getting outgoing/ingoing edges without leaps at all. }; WorldGraph(std::unique_ptr crossMwmGraph, std::unique_ptr loader,