git-clang-format

This commit is contained in:
Vladimir Byko-Ianko 2017-08-01 09:04:20 +03:00 committed by Yuri Gorshenin
parent b290d8960a
commit 8698f9bdb3
3 changed files with 44 additions and 36 deletions

View file

@ -230,7 +230,8 @@ void PushPassedSubroutes(Checkpoints const & checkpoints, vector<Route::Subroute
namespace routing
{
// IndexRouter::BestEdgeComparator ----------------------------------------------------------------
IndexRouter::BestEdgeComparator::BestEdgeComparator(m2::PointD const & point, m2::PointD const & direction,
IndexRouter::BestEdgeComparator::BestEdgeComparator(m2::PointD const & point,
m2::PointD const & direction,
IsOnewayFn const & isOnewayFn)
: m_point(point), m_direction(direction), m_isOnewayFn(isOnewayFn)
{
@ -421,7 +422,7 @@ IRouter::ResultCode IndexRouter::DoCalculateRoute(Checkpoints const & checkpoint
{
return IRouter::StartPointNotFound;
}
size_t subrouteSegmentsBegin = 0;
vector<Route::SubrouteAttrs> 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<Segment> 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<pair<Edge, Junction>> 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<Edge, Junction> 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<IVehicleModel> model = m_vehicleModelFactory->GetVehicleModelForCountry(featureId.GetMwmName());
shared_ptr<IVehicleModel> model =
m_vehicleModelFactory->GetVehicleModelForCountry(featureId.GetMwmName());
CHECK(model, ());
return model->IsOneWay(ft);
}

View file

@ -36,18 +36,20 @@ public:
public:
using IsOnewayFn = std::function<bool(FeatureID const & featureId)>;
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<Segment> & 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<Segment> const & input,
RouterDelegate const & delegate,
WorldGraph::Mode prevMode,
IndexGraphStarter & starter,
std::vector<Segment> & output);
RouterDelegate const & delegate, WorldGraph::Mode prevMode,
IndexGraphStarter & starter, std::vector<Segment> & output);
IRouter::ResultCode RedressRoute(std::vector<Segment> const & segments,
RouterDelegate const & delegate, IndexGraphStarter & starter,
Route & route) const;

View file

@ -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), ());
}