Review fixes.

This commit is contained in:
Lev Dragunov 2016-02-29 20:31:40 +03:00 committed by Sergey Yershov
parent 00ce4641f1
commit 3c9e8305e5
4 changed files with 22 additions and 15 deletions

View file

@ -17,6 +17,14 @@ struct RoutingResult
{
vector<TVertexType> path;
double distance;
RoutingResult() : distance(0) {}
void Clear()
{
path.clear();
distance = 0;
}
};
template <typename TGraph>
@ -180,8 +188,7 @@ typename AStarAlgorithm<TGraph>::Result AStarAlgorithm<TGraph>::FindPath(
my::Cancellable const & cancellable,
TOnVisitedVertexCallback onVisitedVertexCallback) const
{
result.distance = 0;
result.path.clear();
result.Clear();
if (nullptr == onVisitedVertexCallback)
onVisitedVertexCallback = [](TVertexType const &, TVertexType const &){};

View file

@ -58,10 +58,10 @@ IRouter::ResultCode CrossMwmGraph::SetStartNode(CrossNode const & startNode)
for (auto const & nextCross : nextCrosses)
{
if (nextCross.toNode.IsValid())
dummyEdges.emplace_back(nextCross, weights[i]);
}
dummyEdges.emplace_back(nextCross, weights[i]);
}
}
}
m_virtualEdges.insert(make_pair(startNode, dummyEdges));
return IRouter::NoError;
@ -130,7 +130,7 @@ IRouter::ResultCode CrossMwmGraph::SetFinalNode(CrossNode const & finalNode)
}
vector<BorderCross> const & CrossMwmGraph::ConstructBorderCross(OutgoingCrossNode const & startNode,
TRoutingMappingPtr const & currentMapping) const
TRoutingMappingPtr const & currentMapping) const
{
// Check cached crosses.
auto const key = make_pair(startNode.m_nodeId, currentMapping->GetMwmId());
@ -154,10 +154,10 @@ bool CrossMwmGraph::ConstructBorderCrossImpl(OutgoingCrossNode const & startNode
// If we haven't this routing file, we skip this path.
if (!nextMapping->IsValid())
return false;
crosses.clear();
ASSERT(crosses.empty(), ());
nextMapping->LoadCrossContext();
nextMapping->m_crossContext.ForEachIngoingNodeNearPoint(startNode.m_point, [&](IngoingCrossNode const & node)
{
{
if (node.m_point == startNode.m_point)
{
auto const toCross = CrossNode(node.m_nodeId, nextMapping->GetMwmId(), node.m_point);
@ -213,8 +213,8 @@ void CrossMwmGraph::GetOutgoingEdgesList(BorderCross const & v,
for (auto const & target : targets)
{
if (target.toNode.IsValid())
adj.emplace_back(target, outWeight);
}
adj.emplace_back(target, outWeight);
}
}
});
}

View file

@ -10,8 +10,8 @@ namespace
{
/// Function to run AStar Algorithm from the base.
IRouter::ResultCode CalculateRoute(BorderCross const & startPos, BorderCross const & finalPos,
CrossMwmGraph const & roadGraph, RoutingResult<BorderCross> & route,
RouterDelegate const & delegate)
CrossMwmGraph const & roadGraph, RouterDelegate const & delegate,
RoutingResult<BorderCross> & route)
{
using TAlgorithm = AStarAlgorithm<CrossMwmGraph>;
@ -89,7 +89,7 @@ IRouter::ResultCode CalculateCrossMwmPath(TRoutingNodes const & startGraphNodes,
// Finding path through maps.
RoutingResult<BorderCross> tempRoad;
code = CalculateRoute({startNode, startNode}, {finalNode, finalNode}, roadGraph, tempRoad, delegate);
code = CalculateRoute({startNode, startNode}, {finalNode, finalNode}, roadGraph, delegate, tempRoad);
cost = tempRoad.distance;
if (code != IRouter::NoError)
return code;

View file

@ -263,7 +263,7 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
MappingGuard finalMappingGuard(targetMapping);
UNUSED_VALUE(startMappingGuard);
UNUSED_VALUE(finalMappingGuard);
LOG(LINFO, ("Duration of the MWM loading", timer.ElapsedNano()));
LOG(LINFO, ("Duration of the MWM loading", timer.ElapsedNano(), "ns."));
timer.Reset();
delegate.OnProgress(kMwmLoadedProgress);
@ -290,7 +290,7 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
}
INTERRUPT_WHEN_CANCELLED(delegate);
LOG(LINFO, ("Duration of the start/stop points lookup", timer.ElapsedNano()));
LOG(LINFO, ("Duration of the start/stop points lookup", timer.ElapsedNano(), "ns."));
timer.Reset();
delegate.OnProgress(kPointsFoundProgress);
@ -312,7 +312,7 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
});
ResultCode crossCode = CalculateCrossMwmPath(startTask, m_cachedTargets, m_indexManager, crossCost,
delegate, finalPath);
LOG(LINFO, ("Found cross path", timer.ElapsedNano()));
LOG(LINFO, ("Found cross path in", timer.ElapsedNano(), "ns."));
if (!FindRouteFromCases(startTask, m_cachedTargets, startMapping->m_dataFacade,
routingResult))
{