forked from organicmaps/organicmaps
Review fixes.
This commit is contained in:
parent
c8a5ed6a93
commit
29013fc0ac
9 changed files with 86 additions and 74 deletions
|
@ -12,6 +12,13 @@
|
|||
namespace routing
|
||||
{
|
||||
|
||||
template <typename TVertexType>
|
||||
struct RoutingResult
|
||||
{
|
||||
vector<TVertexType> path;
|
||||
double distance;
|
||||
};
|
||||
|
||||
template <typename TGraph>
|
||||
class AStarAlgorithm
|
||||
{
|
||||
|
@ -48,14 +55,13 @@ public:
|
|||
|
||||
Result FindPath(TGraphType const & graph,
|
||||
TVertexType const & startVertex, TVertexType const & finalVertex,
|
||||
vector<TVertexType> & path,
|
||||
double & distance,
|
||||
RoutingResult<TVertexType> & result,
|
||||
my::Cancellable const & cancellable = my::Cancellable(),
|
||||
TOnVisitedVertexCallback onVisitedVertexCallback = nullptr) const;
|
||||
|
||||
Result FindPathBidirectional(TGraphType const & graph,
|
||||
TVertexType const & startVertex, TVertexType const & finalVertex,
|
||||
vector<TVertexType> & path,
|
||||
RoutingResult<TVertexType> & result,
|
||||
my::Cancellable const & cancellable = my::Cancellable(),
|
||||
TOnVisitedVertexCallback onVisitedVertexCallback = nullptr) const;
|
||||
|
||||
|
@ -170,11 +176,12 @@ template <typename TGraph>
|
|||
typename AStarAlgorithm<TGraph>::Result AStarAlgorithm<TGraph>::FindPath(
|
||||
TGraphType const & graph,
|
||||
TVertexType const & startVertex, TVertexType const & finalVertex,
|
||||
vector<TVertexType> & path,
|
||||
double & distance,
|
||||
RoutingResult<TVertexType> & result,
|
||||
my::Cancellable const & cancellable,
|
||||
TOnVisitedVertexCallback onVisitedVertexCallback) const
|
||||
{
|
||||
result.distance = 0;
|
||||
result.path.clear();
|
||||
if (nullptr == onVisitedVertexCallback)
|
||||
onVisitedVertexCallback = [](TVertexType const &, TVertexType const &){};
|
||||
|
||||
|
@ -206,8 +213,8 @@ typename AStarAlgorithm<TGraph>::Result AStarAlgorithm<TGraph>::FindPath(
|
|||
|
||||
if (stateV.vertex == finalVertex)
|
||||
{
|
||||
ReconstructPath(stateV.vertex, parent, path);
|
||||
distance = stateV.distance;
|
||||
ReconstructPath(stateV.vertex, parent, result.path);
|
||||
result.distance = stateV.distance;
|
||||
return Result::OK;
|
||||
}
|
||||
|
||||
|
@ -244,7 +251,7 @@ template <typename TGraph>
|
|||
typename AStarAlgorithm<TGraph>::Result AStarAlgorithm<TGraph>::FindPathBidirectional(
|
||||
TGraphType const & graph,
|
||||
TVertexType const & startVertex, TVertexType const & finalVertex,
|
||||
vector<TVertexType> & path,
|
||||
RoutingResult<TVertexType> & result,
|
||||
my::Cancellable const & cancellable,
|
||||
TOnVisitedVertexCallback onVisitedVertexCallback) const
|
||||
{
|
||||
|
@ -305,10 +312,11 @@ typename AStarAlgorithm<TGraph>::Result AStarAlgorithm<TGraph>::FindPathBidirect
|
|||
if (curTop + nxtTop >= bestPathReducedLength - kEpsilon)
|
||||
{
|
||||
ReconstructPathBidirectional(cur->bestVertex, nxt->bestVertex, cur->parent, nxt->parent,
|
||||
path);
|
||||
CHECK(!path.empty(), ());
|
||||
result.path);
|
||||
result.distance = bestPathReducedLength;
|
||||
CHECK(!result.path.empty(), ());
|
||||
if (!cur->forward)
|
||||
reverse(path.begin(), path.end());
|
||||
reverse(result.path.begin(), result.path.end());
|
||||
return Result::OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
@ -148,6 +148,7 @@ bool CrossMwmGraph::ConstructBorderCrossImpl(OutgoingCrossNode const & startNode
|
|||
TRoutingMappingPtr const & currentMapping,
|
||||
vector<BorderCross> & crosses) const
|
||||
{
|
||||
auto const fromCross = CrossNode(startNode.m_nodeId, currentMapping->GetMwmId(), startNode.m_point);
|
||||
string const & nextMwm = currentMapping->m_crossContext.GetOutgoingMwmName(startNode);
|
||||
TRoutingMappingPtr nextMapping = m_indexManager.GetMappingByName(nextMwm);
|
||||
// If we haven't this routing file, we skip this path.
|
||||
|
@ -156,9 +157,13 @@ bool CrossMwmGraph::ConstructBorderCrossImpl(OutgoingCrossNode const & startNode
|
|||
crosses.clear();
|
||||
nextMapping->LoadCrossContext();
|
||||
nextMapping->m_crossContext.ForEachIngoingNodeNearPoint(startNode.m_point, [&](IngoingCrossNode const & node)
|
||||
{
|
||||
crosses.emplace_back(CrossNode(startNode.m_nodeId, currentMapping->GetMwmId(), node.m_point),
|
||||
CrossNode(node.m_nodeId, nextMapping->GetMwmId(), node.m_point));
|
||||
{
|
||||
if (node.m_point == startNode.m_point)
|
||||
{
|
||||
auto const toCross = CrossNode(node.m_nodeId, nextMapping->GetMwmId(), node.m_point);
|
||||
if (toCross.IsValid())
|
||||
crosses.emplace_back(fromCross, toCross);
|
||||
}
|
||||
});
|
||||
return !crosses.empty();
|
||||
}
|
||||
|
@ -187,12 +192,12 @@ void CrossMwmGraph::GetOutgoingEdgesList(BorderCross const & v,
|
|||
IngoingCrossNode ingoingNode;
|
||||
bool found = false;
|
||||
auto findingFn = [&ingoingNode, &v, &found](IngoingCrossNode const & node)
|
||||
{
|
||||
{
|
||||
if (node.m_nodeId == v.toNode.node)
|
||||
{
|
||||
{
|
||||
found = true;
|
||||
ingoingNode = node;
|
||||
}
|
||||
ingoingNode = node;
|
||||
}
|
||||
};
|
||||
CHECK(currentContext.ForEachIngoingNodeNearPoint(v.toNode.point, findingFn), ());
|
||||
|
||||
|
|
|
@ -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, vector<BorderCross> & route,
|
||||
double & cost, RouterDelegate const & delegate)
|
||||
CrossMwmGraph const & roadGraph, RoutingResult<BorderCross> & route,
|
||||
RouterDelegate const & delegate)
|
||||
{
|
||||
using TAlgorithm = AStarAlgorithm<CrossMwmGraph>;
|
||||
|
||||
|
@ -23,13 +23,13 @@ IRouter::ResultCode CalculateRoute(BorderCross const & startPos, BorderCross con
|
|||
|
||||
my::HighResTimer timer(true);
|
||||
TAlgorithm::Result const result =
|
||||
TAlgorithm().FindPath(roadGraph, startPos, finalPos, route, cost, delegate, onVisitedVertex);
|
||||
TAlgorithm().FindPath(roadGraph, startPos, finalPos, route, delegate, onVisitedVertex);
|
||||
LOG(LINFO, ("Duration of the cross MWM path finding", timer.ElapsedNano()));
|
||||
switch (result)
|
||||
{
|
||||
case TAlgorithm::Result::OK:
|
||||
ASSERT_EQUAL(route.front(), startPos, ());
|
||||
ASSERT_EQUAL(route.back(), finalPos, ());
|
||||
ASSERT_EQUAL(route.path.front(), startPos, ());
|
||||
ASSERT_EQUAL(route.path.back(), finalPos, ());
|
||||
return IRouter::NoError;
|
||||
case TAlgorithm::Result::NoPath:
|
||||
return IRouter::RouteNotFound;
|
||||
|
@ -88,16 +88,16 @@ IRouter::ResultCode CalculateCrossMwmPath(TRoutingNodes const & startGraphNodes,
|
|||
return IRouter::EndPointNotFound;
|
||||
|
||||
// Finding path through maps.
|
||||
vector<BorderCross> tempRoad;
|
||||
code = CalculateRoute({startNode, startNode}, {finalNode, finalNode}, roadGraph, tempRoad, cost,
|
||||
delegate);
|
||||
RoutingResult<BorderCross> tempRoad;
|
||||
code = CalculateRoute({startNode, startNode}, {finalNode, finalNode}, roadGraph, tempRoad, delegate);
|
||||
cost = tempRoad.distance;
|
||||
if (code != IRouter::NoError)
|
||||
return code;
|
||||
if (delegate.IsCancelled())
|
||||
return IRouter::Cancelled;
|
||||
|
||||
// Final path conversion to output type.
|
||||
ConvertToSingleRouterTasks(tempRoad, startGraphNode, finalGraphNode, route);
|
||||
ConvertToSingleRouterTasks(tempRoad.path, startGraphNode, finalGraphNode, route);
|
||||
|
||||
return route.empty() ? IRouter::RouteNotFound : IRouter::NoError;
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
|
|||
{
|
||||
LOG(LINFO, ("Found only cross path."));
|
||||
auto code = MakeRouteFromCrossesPath(finalPath, delegate, route);
|
||||
LOG(LINFO, ("Make final route", timer.ElapsedNano()));
|
||||
LOG(LINFO, ("Made final route in", timer.ElapsedNano(), "ns."));
|
||||
return code;
|
||||
}
|
||||
return RouteNotFound;
|
||||
|
@ -329,7 +329,7 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
|
|||
{
|
||||
LOG(LINFO, ("Cross mwm path shorter. Cross cost:", crossCost, "single cost:", routingResult.shortestPathLength));
|
||||
auto code = MakeRouteFromCrossesPath(finalPath, delegate, route);
|
||||
LOG(LINFO, ("Make final route", timer.ElapsedNano()));
|
||||
LOG(LINFO, ("Made final route in", timer.ElapsedNano(), "ns."));
|
||||
timer.Reset();
|
||||
return code;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
|
|||
{
|
||||
indexPair.second->FreeCrossContext();
|
||||
});
|
||||
LOG(LINFO, ("Make final route", timer.ElapsedNano()));
|
||||
LOG(LINFO, ("Made final route in", timer.ElapsedNano(), "ns."));
|
||||
timer.Reset();
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -212,16 +212,16 @@ IRouter::ResultCode RoadGraphRouter::CalculateRoute(m2::PointD const & startPoin
|
|||
m_roadGraph->AddFakeEdges(startPos, startVicinity);
|
||||
m_roadGraph->AddFakeEdges(finalPos, finalVicinity);
|
||||
|
||||
vector<Junction> path;
|
||||
RoutingResult<Junction> result;
|
||||
IRoutingAlgorithm::Result const resultCode =
|
||||
m_algorithm->CalculateRoute(*m_roadGraph, startPos, finalPos, delegate, path);
|
||||
m_algorithm->CalculateRoute(*m_roadGraph, startPos, finalPos, delegate, result);
|
||||
|
||||
if (resultCode == IRoutingAlgorithm::Result::OK)
|
||||
{
|
||||
ASSERT(!path.empty(), ());
|
||||
ASSERT_EQUAL(path.front(), startPos, ());
|
||||
ASSERT_EQUAL(path.back(), finalPos, ());
|
||||
ReconstructRoute(move(path), route, delegate);
|
||||
ASSERT(!result.path.empty(), ());
|
||||
ASSERT_EQUAL(result.path.front(), startPos, ());
|
||||
ASSERT_EQUAL(result.path.back(), finalPos, ());
|
||||
ReconstructRoute(move(result.path), route, delegate);
|
||||
}
|
||||
|
||||
m_roadGraph->ResetFakes();
|
||||
|
|
|
@ -128,7 +128,7 @@ IRoutingAlgorithm::Result AStarRoutingAlgorithm::CalculateRoute(IRoadGraph const
|
|||
Junction const & startPos,
|
||||
Junction const & finalPos,
|
||||
RouterDelegate const & delegate,
|
||||
vector<Junction> & path)
|
||||
RoutingResult<Junction> & path)
|
||||
{
|
||||
AStarProgress progress(0, 100);
|
||||
|
||||
|
@ -145,9 +145,8 @@ IRoutingAlgorithm::Result AStarRoutingAlgorithm::CalculateRoute(IRoadGraph const
|
|||
|
||||
my::Cancellable const & cancellable = delegate;
|
||||
progress.Initialize(startPos.GetPoint(), finalPos.GetPoint());
|
||||
double cost = 0;
|
||||
TAlgorithmImpl::Result const res = TAlgorithmImpl().FindPath(
|
||||
RoadGraph(graph), startPos, finalPos, path, cost, cancellable, onVisitJunctionFn);
|
||||
RoadGraph(graph), startPos, finalPos, path, cancellable, onVisitJunctionFn);
|
||||
return Convert(res);
|
||||
}
|
||||
|
||||
|
@ -155,7 +154,7 @@ IRoutingAlgorithm::Result AStarRoutingAlgorithm::CalculateRoute(IRoadGraph const
|
|||
|
||||
IRoutingAlgorithm::Result AStarBidirectionalRoutingAlgorithm::CalculateRoute(
|
||||
IRoadGraph const & graph, Junction const & startPos, Junction const & finalPos,
|
||||
RouterDelegate const & delegate, vector<Junction> & path)
|
||||
RouterDelegate const & delegate, RoutingResult<Junction> & path)
|
||||
{
|
||||
AStarProgress progress(0, 100);
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "routing/road_graph.hpp"
|
||||
#include "routing/router.hpp"
|
||||
#include "routing/base/astar_algorithm.hpp"
|
||||
|
||||
#include "std/functional.hpp"
|
||||
#include "std/string.hpp"
|
||||
|
@ -26,7 +27,7 @@ public:
|
|||
|
||||
virtual Result CalculateRoute(IRoadGraph const & graph, Junction const & startPos,
|
||||
Junction const & finalPos, RouterDelegate const & delegate,
|
||||
vector<Junction> & path) = 0;
|
||||
RoutingResult<Junction> & path) = 0;
|
||||
};
|
||||
|
||||
string DebugPrint(IRoutingAlgorithm::Result const & result);
|
||||
|
@ -38,7 +39,7 @@ public:
|
|||
// IRoutingAlgorithm overrides:
|
||||
Result CalculateRoute(IRoadGraph const & graph, Junction const & startPos,
|
||||
Junction const & finalPos, RouterDelegate const & delegate,
|
||||
vector<Junction> & path) override;
|
||||
RoutingResult<Junction> & path) override;
|
||||
};
|
||||
|
||||
// AStar-bidirectional routing algorithm implementation
|
||||
|
@ -48,7 +49,7 @@ public:
|
|||
// IRoutingAlgorithm overrides:
|
||||
Result CalculateRoute(IRoadGraph const & graph, Junction const & startPos,
|
||||
Junction const & finalPos, RouterDelegate const & delegate,
|
||||
vector<Junction> & path) override;
|
||||
RoutingResult<Junction> & path) override;
|
||||
};
|
||||
|
||||
} // namespace routing
|
||||
|
|
|
@ -62,15 +62,14 @@ void TestAStar(UndirectedGraph const & graph, vector<unsigned> const & expectedR
|
|||
using TAlgorithm = AStarAlgorithm<UndirectedGraph>;
|
||||
|
||||
TAlgorithm algo;
|
||||
double cost = 0;
|
||||
|
||||
vector<unsigned> actualRoute;
|
||||
TEST_EQUAL(TAlgorithm::Result::OK, algo.FindPath(graph, 0u, 4u, actualRoute, cost), ());
|
||||
TEST_EQUAL(expectedRoute, actualRoute, ());
|
||||
RoutingResult<unsigned> actualRoute;
|
||||
TEST_EQUAL(TAlgorithm::Result::OK, algo.FindPath(graph, 0u, 4u, actualRoute), ());
|
||||
TEST_EQUAL(expectedRoute, actualRoute.path, ());
|
||||
|
||||
actualRoute.clear();
|
||||
actualRoute.path.clear();
|
||||
TEST_EQUAL(TAlgorithm::Result::OK, algo.FindPathBidirectional(graph, 0u, 4u, actualRoute), ());
|
||||
TEST_EQUAL(expectedRoute, actualRoute, ());
|
||||
TEST_EQUAL(expectedRoute, actualRoute.path, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(AStarAlgorithm_Sample)
|
||||
|
|
|
@ -29,12 +29,12 @@ void TestAStarRouterMock(Junction const & startPos, Junction const & finalPos,
|
|||
InitRoadGraphMockSourceWithTest2(graph);
|
||||
|
||||
RouterDelegate delegate;
|
||||
vector<Junction> path;
|
||||
RoutingResult<Junction> result;
|
||||
TRoutingAlgorithm algorithm;
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, delegate, path), ());
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, delegate, result), ());
|
||||
|
||||
TEST_EQUAL(expected, path, ());
|
||||
TEST_EQUAL(expected, result.path, ());
|
||||
}
|
||||
|
||||
void AddRoad(RoadGraphMockSource & graph, double speedKMPH, initializer_list<m2::PointD> const & points)
|
||||
|
@ -91,12 +91,12 @@ UNIT_TEST(AStarRouter_SimpleGraph_RouteIsFound)
|
|||
vector<Junction> const expected = {m2::PointD(0, 0), m2::PointD(0, 30), m2::PointD(0, 60), m2::PointD(40, 100)};
|
||||
|
||||
RouterDelegate delegate;
|
||||
vector<Junction> path;
|
||||
RoutingResult<Junction> result;
|
||||
TRoutingAlgorithm algorithm;
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, delegate, path), ());
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, delegate, result), ());
|
||||
|
||||
TEST_EQUAL(expected, path, ());
|
||||
TEST_EQUAL(expected, result.path, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents)
|
||||
|
@ -146,11 +146,11 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents)
|
|||
{
|
||||
RouterDelegate delegate;
|
||||
Junction const finalPos(roadInfo_2[j].m_points[0]);
|
||||
vector<Junction> path;
|
||||
RoutingResult<Junction> result;
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::NoPath,
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, delegate, path), ());
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, delegate, result), ());
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::NoPath,
|
||||
algorithm.CalculateRoute(graph, finalPos, startPos, delegate, path), ());
|
||||
algorithm.CalculateRoute(graph, finalPos, startPos, delegate, result), ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,11 +162,11 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents)
|
|||
{
|
||||
RouterDelegate delegate;
|
||||
Junction const finalPos(roadInfo_1[j].m_points[0]);
|
||||
vector<Junction> path;
|
||||
RoutingResult<Junction> result;
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, delegate, path), ());
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, delegate, result), ());
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
|
||||
algorithm.CalculateRoute(graph, finalPos, startPos, delegate, path), ());
|
||||
algorithm.CalculateRoute(graph, finalPos, startPos, delegate, result), ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,11 +178,11 @@ UNIT_TEST(AStarRouter_SimpleGraph_RoutesInConnectedComponents)
|
|||
{
|
||||
RouterDelegate delegate;
|
||||
Junction const finalPos(roadInfo_2[j].m_points[0]);
|
||||
vector<Junction> path;
|
||||
RoutingResult<Junction> result;
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, delegate, path), ());
|
||||
algorithm.CalculateRoute(graph, startPos, finalPos, delegate, result), ());
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
|
||||
algorithm.CalculateRoute(graph, finalPos, startPos, delegate, path), ());
|
||||
algorithm.CalculateRoute(graph, finalPos, startPos, delegate, result), ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,12 +206,12 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad1)
|
|||
// path3 = 1/5 + 8/4 + 1/5 = 2.4
|
||||
|
||||
RouterDelegate delegate;
|
||||
vector<Junction> path;
|
||||
RoutingResult<Junction> result;
|
||||
TRoutingAlgorithm algorithm;
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
|
||||
algorithm.CalculateRoute(graph, m2::PointD(2, 2), m2::PointD(10, 2), delegate, path),
|
||||
algorithm.CalculateRoute(graph, m2::PointD(2, 2), m2::PointD(10, 2), delegate, result),
|
||||
());
|
||||
TEST_EQUAL(path, vector<Junction>({m2::PointD(2,2), m2::PointD(2,3), m2::PointD(4,3), m2::PointD(6,3),
|
||||
TEST_EQUAL(result.path, vector<Junction>({m2::PointD(2,2), m2::PointD(2,3), m2::PointD(4,3), m2::PointD(6,3),
|
||||
m2::PointD(8,3), m2::PointD(10,3), m2::PointD(10,2)}), ());
|
||||
}
|
||||
|
||||
|
@ -233,12 +233,12 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad2)
|
|||
// path3 = 1/5 + 8/4.4 + 1/5 = 2.2
|
||||
|
||||
RouterDelegate delegate;
|
||||
vector<Junction> path;
|
||||
RoutingResult<Junction> result;
|
||||
TRoutingAlgorithm algorithm;
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
|
||||
algorithm.CalculateRoute(graph, m2::PointD(2, 2), m2::PointD(10, 2), delegate, path),
|
||||
algorithm.CalculateRoute(graph, m2::PointD(2, 2), m2::PointD(10, 2), delegate, result),
|
||||
());
|
||||
TEST_EQUAL(path, vector<Junction>({m2::PointD(2,2), m2::PointD(6,2), m2::PointD(10,2)}), ());
|
||||
TEST_EQUAL(result.path, vector<Junction>({m2::PointD(2,2), m2::PointD(6,2), m2::PointD(10,2)}), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad3)
|
||||
|
@ -259,10 +259,10 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad3)
|
|||
// path3 = 1/5 + 8/4.9 + 1/5 = 2.03
|
||||
|
||||
RouterDelegate delegate;
|
||||
vector<Junction> path;
|
||||
RoutingResult<Junction> result;
|
||||
TRoutingAlgorithm algorithm;
|
||||
TEST_EQUAL(TRoutingAlgorithm::Result::OK,
|
||||
algorithm.CalculateRoute(graph, m2::PointD(2, 2), m2::PointD(10, 2), delegate, path),
|
||||
algorithm.CalculateRoute(graph, m2::PointD(2, 2), m2::PointD(10, 2), delegate, result),
|
||||
());
|
||||
TEST_EQUAL(path, vector<Junction>({m2::PointD(2,2), m2::PointD(2,1), m2::PointD(10,1), m2::PointD(10,2)}), ());
|
||||
TEST_EQUAL(result.path, vector<Junction>({m2::PointD(2,2), m2::PointD(2,1), m2::PointD(10,1), m2::PointD(10,2)}), ());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue