diff --git a/routing/base/astar_algorithm.hpp b/routing/base/astar_algorithm.hpp index 9ea5f09374..495b07260a 100644 --- a/routing/base/astar_algorithm.hpp +++ b/routing/base/astar_algorithm.hpp @@ -17,6 +17,14 @@ struct RoutingResult { vector path; double distance; + + RoutingResult() : distance(0) {} + + void Clear() + { + path.clear(); + distance = 0; + } }; template @@ -180,8 +188,7 @@ typename AStarAlgorithm::Result AStarAlgorithm::FindPath( my::Cancellable const & cancellable, TOnVisitedVertexCallback onVisitedVertexCallback) const { - result.distance = 0; - result.path.clear(); + result.Clear(); if (nullptr == onVisitedVertexCallback) onVisitedVertexCallback = [](TVertexType const &, TVertexType const &){}; diff --git a/routing/cross_mwm_road_graph.cpp b/routing/cross_mwm_road_graph.cpp index e95c51c75e..6ef65978ea 100644 --- a/routing/cross_mwm_road_graph.cpp +++ b/routing/cross_mwm_road_graph.cpp @@ -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 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); + } } }); } diff --git a/routing/cross_mwm_router.cpp b/routing/cross_mwm_router.cpp index 9207f85f85..7d398ca9af 100644 --- a/routing/cross_mwm_router.cpp +++ b/routing/cross_mwm_router.cpp @@ -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 & route, - RouterDelegate const & delegate) + CrossMwmGraph const & roadGraph, RouterDelegate const & delegate, + RoutingResult & route) { using TAlgorithm = AStarAlgorithm; @@ -89,7 +89,7 @@ IRouter::ResultCode CalculateCrossMwmPath(TRoutingNodes const & startGraphNodes, // Finding path through maps. RoutingResult 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; diff --git a/routing/osrm_router.cpp b/routing/osrm_router.cpp index cf5760e532..28ee8aecef 100644 --- a/routing/osrm_router.cpp +++ b/routing/osrm_router.cpp @@ -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)) {