From 8698f9bdb307dc89ebacebb4c17b53ad9ee514e5 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Tue, 1 Aug 2017 09:04:20 +0300 Subject: [PATCH] git-clang-format --- routing/index_router.cpp | 43 ++++++++++++---------- routing/index_router.hpp | 22 ++++++----- routing/routing_tests/index_graph_test.cpp | 15 +++++--- 3 files changed, 44 insertions(+), 36 deletions(-) diff --git a/routing/index_router.cpp b/routing/index_router.cpp index f1b71ba933..d7f76a8f18 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -230,7 +230,8 @@ void PushPassedSubroutes(Checkpoints const & checkpoints, vector subroutes; PushPassedSubroutes(checkpoints, subroutes); @@ -429,10 +430,10 @@ IRouter::ResultCode IndexRouter::DoCalculateRoute(Checkpoints const & checkpoint for (size_t i = checkpoints.GetPassedIdx(); i < checkpoints.GetNumSubroutes(); ++i) { vector subroute; - Junction startJunction; - auto const result = CalculateSubroute(checkpoints, i, startSegment, startSegmentIsAlmostParallelDirection, - delegate, graph, subroute, startJunction); + auto const result = + CalculateSubroute(checkpoints, i, startSegment, startSegmentIsAlmostParallelDirection, + delegate, graph, subroute, startJunction); if (result != IRouter::NoError) return result; @@ -500,7 +501,8 @@ IRouter::ResultCode IndexRouter::CalculateSubroute(Checkpoints const & checkpoin Segment finishSegment; bool dummy = false; - if (!FindBestSegment(finishCheckpoint, m2::PointD::Zero(), false /* isOutgoing */, graph, finishSegment, dummy)) + if (!FindBestSegment(finishCheckpoint, m2::PointD::Zero(), false /* isOutgoing */, graph, + finishSegment, dummy)) { bool const isLastSubroute = subrouteIdx == checkpoints.GetNumSubroutes() - 1; return isLastSubroute ? IRouter::EndPointNotFound : IRouter::IntermediatePointNotFound; @@ -511,8 +513,8 @@ IRouter::ResultCode IndexRouter::CalculateSubroute(Checkpoints const & checkpoin : WorldGraph::Mode::LeapsOnly); LOG(LINFO, ("Routing in mode:", graph.GetMode())); - bool const isStartSegmentStrictForward = subrouteIdx == checkpoints.GetPassedIdx() ? startSegmentIsAlmostParallelDirection - : true; + bool const isStartSegmentStrictForward = + subrouteIdx == checkpoints.GetPassedIdx() ? startSegmentIsAlmostParallelDirection : true; IndexGraphStarter starter( MakeFakeVertex(startSegment, startCheckpoint, isStartSegmentStrictForward, graph), MakeFakeVertex(finishSegment, finishCheckpoint, false /* strictForward */, graph), graph); @@ -569,7 +571,8 @@ IRouter::ResultCode IndexRouter::AdjustRoute(Checkpoints const & checkpoints, Segment startSegment; m2::PointD const & pointFrom = checkpoints.GetPointFrom(); bool bestSegmentIsAlmostConformDirection = false; - if (!FindBestSegment(pointFrom, startDirection, true, graph, startSegment, bestSegmentIsAlmostConformDirection)) + if (!FindBestSegment(pointFrom, startDirection, true, graph, startSegment, + bestSegmentIsAlmostConformDirection)) return IRouter::StartPointNotFound; auto const & lastSubroutes = m_lastRoute->GetSubroutes(); @@ -670,8 +673,8 @@ WorldGraph IndexRouter::MakeWorldGraph() } bool IndexRouter::FindBestSegment(m2::PointD const & point, m2::PointD const & direction, - bool isOutgoing, WorldGraph & worldGraph, - Segment & bestSegment, bool & bestSegmentIsAlmostConformDirection) const + bool isOutgoing, WorldGraph & worldGraph, Segment & bestSegment, + bool & bestSegmentIsAlmostConformDirection) const { auto const file = platform::CountryFile(m_countryFileFn(point)); MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(file); @@ -684,22 +687,21 @@ bool IndexRouter::FindBestSegment(m2::PointD const & point, m2::PointD const & d vector> candidates; m_roadGraph.FindClosestEdges(point, kMaxRoadCandidates, candidates); - auto const getSegmentByEdge = [&numMwmId](Edge const & edge, bool isForward){ - return Segment(numMwmId, edge.GetFeatureId().m_index, edge.GetSegId(), isForward); + auto const getSegmentByEdge = [&numMwmId](Edge const & edge, bool isForward) { + return Segment(numMwmId, edge.GetFeatureId().m_index, edge.GetSegId(), isForward); }; // Getting rid of knowingly bad candidates. my::EraseIf(candidates, [&](pair const & p){ Edge const & edge = p.first; - return edge.GetFeatureId().m_mwmId != mwmId - || IsDeadEnd(getSegmentByEdge(edge, edge.IsForward()), isOutgoing, worldGraph); + return edge.GetFeatureId().m_mwmId != mwmId || + IsDeadEnd(getSegmentByEdge(edge, edge.IsForward()), isOutgoing, worldGraph); }); if (candidates.empty()) return false; - - BestEdgeComparator bestEdgeComparator(point, direction, [this](FeatureID const & featureId){ + BestEdgeComparator bestEdgeComparator(point, direction, [this](FeatureID const & featureId) { return this->IsOneWayFeature(featureId); }); Edge bestEdge = candidates[0].first; @@ -710,8 +712,8 @@ bool IndexRouter::FindBestSegment(m2::PointD const & point, m2::PointD const & d bestEdge = edge; } - bestSegmentIsAlmostConformDirection = bestEdgeComparator.IsDirectionValid() - && bestEdgeComparator.IsAlmostConformed(bestEdge); + bestSegmentIsAlmostConformDirection = + bestEdgeComparator.IsDirectionValid() && bestEdgeComparator.IsAlmostConformed(bestEdge); bool bestSegmentForward = true; if (bestEdgeComparator.IsDirectionValid()) @@ -842,7 +844,8 @@ bool IndexRouter::IsOneWayFeature(FeatureID const & featureId) const LOG(LERROR, ("Feature can't be loaded:", featureId)); return false; } - shared_ptr model = m_vehicleModelFactory->GetVehicleModelForCountry(featureId.GetMwmName()); + shared_ptr model = + m_vehicleModelFactory->GetVehicleModelForCountry(featureId.GetMwmName()); CHECK(model, ()); return model->IsOneWay(ft); } diff --git a/routing/index_router.hpp b/routing/index_router.hpp index 6abdd171e8..d2f0599777 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -36,18 +36,20 @@ public: public: using IsOnewayFn = std::function; - BestEdgeComparator(m2::PointD const & point, m2::PointD const & direction, IsOnewayFn const & isOnewayFn); + BestEdgeComparator(m2::PointD const & point, m2::PointD const & direction, + IsOnewayFn const & isOnewayFn); /// \returns true if |edge1| is closer to |m_point| and |m_direction| than |edge2|. bool Compare(Edge const & edge1, Edge const & edge2) const; - /// \returns true if |edge| has a oneway feature and if |edge| is almost parallel to vector |m_direction|. - /// returns true if |edge| has a twoway feature and if |edge| is almost collinear to vector |m_direction|. + /// \returns true if |edge| has a oneway feature and if |edge| is almost parallel to vector + /// |m_direction|. + /// returns true if |edge| has a twoway feature and if |edge| is almost collinear to vector + /// |m_direction|. /// returns false otherwise. bool IsAlmostConformed(Edge const & edge) const; bool IsDirectionValid() const { return !m_direction.IsAlmostZero(); } - /// \brief According to current implementation vectors |edge| and |m_direction| /// are almost collinear if angle between line of the vectors less than 14 degrees. /// If also the angle between the vectors is less than 14 degrees |forward| will be set to true. @@ -89,7 +91,8 @@ private: m2::PointD const & startDirection, RouterDelegate const & delegate, Route & route); IRouter::ResultCode CalculateSubroute(Checkpoints const & checkpoints, size_t subrouteIdx, - Segment const & startSegment, bool startSegmentIsAlmostParallelDirection, + Segment const & startSegment, + bool startSegmentIsAlmostParallelDirection, RouterDelegate const & delegate, WorldGraph & graph, std::vector & subroute, Junction & startJunction); @@ -105,7 +108,8 @@ private: /// segment in neighbourhoods the closest segment to |point| will be chosen. /// \param isOutgoing == true is |point| is considered as the start of the route. /// isOutgoing == false is |point| is considered as the finish of the route. - /// \param bestSegmentIsAlmostConformDirection is filled with true if |bestSegment| is chosen because + /// \param bestSegmentIsAlmostConformDirection is filled with true if |bestSegment| is chosen + /// because /// vector |direction| and vector of |bestSegment| are almost equal and with false otherwise. bool FindBestSegment(m2::PointD const & point, m2::PointD const & direction, bool isOutgoing, WorldGraph & worldGraph, Segment & bestSegment, @@ -113,10 +117,8 @@ private: // Input route may contains 'leaps': shortcut edges from mwm border enter to exit. // ProcessLeaps replaces each leap with calculated route through mwm. IRouter::ResultCode ProcessLeaps(std::vector const & input, - RouterDelegate const & delegate, - WorldGraph::Mode prevMode, - IndexGraphStarter & starter, - std::vector & output); + RouterDelegate const & delegate, WorldGraph::Mode prevMode, + IndexGraphStarter & starter, std::vector & output); IRouter::ResultCode RedressRoute(std::vector const & segments, RouterDelegate const & delegate, IndexGraphStarter & starter, Route & route) const; diff --git a/routing/routing_tests/index_graph_test.cpp b/routing/routing_tests/index_graph_test.cpp index af273c7bc1..4d3a71f0e6 100644 --- a/routing/routing_tests/index_graph_test.cpp +++ b/routing/routing_tests/index_graph_test.cpp @@ -596,8 +596,9 @@ UNIT_TEST(BestEdgeComparator_OneParallelEdge) MakeJunctionForTesting({-0.002, 0.002}), true /* partOfRead */); Edge edge2 = Edge::MakeFake(MakeJunctionForTesting({-0.002, 0.0}), MakeJunctionForTesting({0.002, 0.0}), true /* partOfRead */); - IndexRouter::BestEdgeComparator bestEdgeComparator(m2::PointD(0.0, 0.0), m2::PointD(0.0, 0.001), - [](FeatureID const & /* featureId */){ return true; }); + IndexRouter::BestEdgeComparator bestEdgeComparator( + m2::PointD(0.0, 0.0), m2::PointD(0.0, 0.001), + [](FeatureID const & /* featureId */) { return true; }); TEST(bestEdgeComparator.Compare(edge1, edge2), ()); } @@ -621,8 +622,9 @@ UNIT_TEST(BestEdgeComparator_TwoParallelEdges) Edge::MakeFake(MakeJunctionForTesting({-0.002, 0.0}), MakeJunctionForTesting({-0.002, 0.004}), true /* partOfRead */); Edge edge2 = Edge::MakeFake(MakeJunctionForTesting({0.0, 0.0}), MakeJunctionForTesting({0.0, 0.002}), true /* partOfRead */); - IndexRouter::BestEdgeComparator bestEdgeComparator(m2::PointD(0.0, 0.0), m2::PointD(0.0, 0.001), - [](FeatureID const & /* featureId */){ return true; }); + IndexRouter::BestEdgeComparator bestEdgeComparator( + m2::PointD(0.0, 0.0), m2::PointD(0.0, 0.001), + [](FeatureID const & /* featureId */) { return true; }); TEST(!bestEdgeComparator.Compare(edge1, edge2), ()); } @@ -641,8 +643,9 @@ UNIT_TEST(BestEdgeComparator_TwoNotParallelEdges) Edge::MakeFake(MakeJunctionForTesting({-0.002, 0.002}), MakeJunctionForTesting({-0.002, 0.002}), true /* partOfRead */); Edge edge2 = Edge::MakeFake(MakeJunctionForTesting({-0.002, 0.0}), MakeJunctionForTesting({0.002, 0.0}), true /* partOfRead */); - IndexRouter::BestEdgeComparator bestEdgeComparator(m2::PointD(0.0, 0.0), m2::PointD(0.0, 0.001), - [](FeatureID const & /* featureId */){ return true; }); + IndexRouter::BestEdgeComparator bestEdgeComparator( + m2::PointD(0.0, 0.0), m2::PointD(0.0, 0.001), + [](FeatureID const & /* featureId */) { return true; }); TEST(!bestEdgeComparator.Compare(edge1, edge2), ()); }