|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
#include "testing/testing.hpp"
|
|
|
|
|
|
|
|
|
|
#include "generator/generator_tests/routing_tools.hpp"
|
|
|
|
|
#include "generator/generator_tests_support/routing_helpers.hpp"
|
|
|
|
|
|
|
|
|
|
#include "routing/routing_tests/index_graph_tools.hpp"
|
|
|
|
|
|
|
|
|
@ -11,6 +11,7 @@
|
|
|
|
|
#include "geometry/point2d.hpp"
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <utility>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace routing_test
|
|
|
|
@ -61,7 +62,7 @@ unique_ptr<SingleVehicleWorldGraph> BuildCrossGraph()
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using Algorithm = AStarAlgorithm<Segment, SegmentEdge, RouteWeight>;
|
|
|
|
@ -83,15 +84,16 @@ UNIT_CLASS_TEST(RestrictionTest, CrossGraph_UTurn)
|
|
|
|
|
SetStarter(MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(-1, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(7, 0, m2::PointD(1, 2), *m_graph));
|
|
|
|
|
|
|
|
|
|
RestrictionVec restrictions = {
|
|
|
|
|
{Restriction::Type::No, {1 /* feature from */, 6 /* feature to */}}};
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{1 /* feature from */, 6 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
vector<m2::PointD> const expectedGeom = {{-1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {1.0, -1.0},
|
|
|
|
|
{1.0, 0.0}, {1.0, 1.0}, {1.0, 2.0}};
|
|
|
|
|
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(-1, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(7, 0, m2::PointD(1, 2), *m_graph), move(restrictions), *this);
|
|
|
|
|
MakeFakeEnding(7, 0, m2::PointD(1, 2), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Finish
|
|
|
|
@ -138,7 +140,7 @@ unique_ptr<SingleVehicleWorldGraph> BuildTriangularGraph()
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Route through triangular graph without any restrictions.
|
|
|
|
@ -158,36 +160,36 @@ UNIT_CLASS_TEST(RestrictionTest, TriangularGraph)
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, TriangularGraph_RestrictionNoF2F1)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTriangularGraph());
|
|
|
|
|
RestrictionVec restrictions = {
|
|
|
|
|
{Restriction::Type::No, {2 /* feature from */, 1 /* feature to */}}};
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{2 /* feature from */, 1 /* feature to */}};
|
|
|
|
|
vector<m2::PointD> const expectedGeom = {
|
|
|
|
|
{3 /* x */, 0 /* y */}, {2, 0}, {1, 0}, {0, 0}, {0, 2}, {0, 3}};
|
|
|
|
|
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(5 /* featureId */, 0 /* senmentIdx */, m2::PointD(3, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), move(restrictions), *this);
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, TriangularGraph_RestrictionNoF5F2)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTriangularGraph());
|
|
|
|
|
RestrictionVec restrictions = {
|
|
|
|
|
{Restriction::Type::No, {5 /* feature from */, 2 /* feature to */}}};
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{5 /* feature from */, 2 /* feature to */}};
|
|
|
|
|
vector<m2::PointD> const expectedGeom = {
|
|
|
|
|
{3 /* x */, 0 /* y */}, {2, 0}, {1, 0}, {0, 0}, {0, 2}, {0, 3}};
|
|
|
|
|
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(5 /* featureId */, 0 /* segmentIdx */, m2::PointD(3, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), move(restrictions), *this);
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, TriangularGraph_RestrictionOnlyF5F3)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTriangularGraph());
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{Restriction::Type::Only, {5 /* feature from */, 3 /* feature to */}}};
|
|
|
|
|
{{5 /* feature from */, 3 /* feature to */}}};
|
|
|
|
|
RestrictionVec restrictionsNo;
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
|
restrictionsNo);
|
|
|
|
@ -197,18 +199,18 @@ UNIT_CLASS_TEST(RestrictionTest, TriangularGraph_RestrictionOnlyF5F3)
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(5 /* featureId */, 0 /* segmentIdx */, m2::PointD(3, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), move(restrictionsNo), *this);
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, TriangularGraph_RestrictionNoF5F2RestrictionOnlyF5F3)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTriangularGraph());
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{Restriction::Type::No, {5 /* feature from */, 2 /* feature to */}},
|
|
|
|
|
{5 /* feature from */, 2 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{Restriction::Type::Only, {5 /* feature from */, 3 /* feature to */}},
|
|
|
|
|
{5 /* feature from */, 3 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
|
restrictionsNo);
|
|
|
|
@ -219,7 +221,7 @@ UNIT_CLASS_TEST(RestrictionTest, TriangularGraph_RestrictionNoF5F2RestrictionOnl
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(5 /* featureId */, 0 /* segmentIdx */, m2::PointD(3, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), move(restrictionsNo), *this);
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Finish
|
|
|
|
@ -262,7 +264,7 @@ unique_ptr<SingleVehicleWorldGraph> BuildTwowayCornerGraph()
|
|
|
|
|
};
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, TwowayCornerGraph)
|
|
|
|
@ -279,22 +281,24 @@ UNIT_CLASS_TEST(RestrictionTest, TwowayCornerGraph)
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, TwowayCornerGraph_RestrictionF3F2No)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTwowayCornerGraph());
|
|
|
|
|
RestrictionVec restrictions = {
|
|
|
|
|
{Restriction::Type::No, {3 /* feature from */, 2 /* feature to */}}};
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{3 /* feature from */, 2 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
vector<m2::PointD> const expectedGeom = {
|
|
|
|
|
{3 /* x */, 0 /* y */}, {2, 0}, {1, 0}, {0, 0}, {0, 1}, {0, 2}, {0, 3}};
|
|
|
|
|
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(3 /* featureId */, 0 /* segmentIdx */, m2::PointD(3, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), move(restrictions), *this);
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, TwowayCornerGraph_RestrictionF3F1Only)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTwowayCornerGraph());
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{Restriction::Type::Only, {3 /* feature from */, 1 /* feature to */}}};
|
|
|
|
|
{3 /* feature from */, 1 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
RestrictionVec restrictionsNo;
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
|
restrictionsNo);
|
|
|
|
@ -304,7 +308,7 @@ UNIT_CLASS_TEST(RestrictionTest, TwowayCornerGraph_RestrictionF3F1Only)
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(3 /* featureId */, 0 /* segmentIdx */, m2::PointD(3, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), move(restrictionsNo), *this);
|
|
|
|
|
MakeFakeEnding(4, 0, m2::PointD(0, 3), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Finish
|
|
|
|
@ -368,7 +372,7 @@ unique_ptr<SingleVehicleWorldGraph> BuildTwoSquaresGraph()
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph)
|
|
|
|
@ -386,7 +390,8 @@ UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph_RestrictionF10F3Only)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTwoSquaresGraph());
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{Restriction::Type::Only, {10 /* feature from */, 3 /* feature to */}}};
|
|
|
|
|
{10 /* feature from */, 3 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
RestrictionVec restrictionsNo;
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
|
restrictionsNo);
|
|
|
|
@ -397,15 +402,16 @@ UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph_RestrictionF10F3Only)
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(10 /* featureId */, 0 /* segmentIdx */, m2::PointD(3, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(11, 0, m2::PointD(0, 3), *m_graph), move(restrictionsNo), *this);
|
|
|
|
|
MakeFakeEnding(11, 0, m2::PointD(0, 3), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph_RestrictionF10F3OnlyF3F4Only)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTwoSquaresGraph());
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{Restriction::Type::Only, {3 /* feature from */, 4 /* feature to */}},
|
|
|
|
|
{Restriction::Type::Only, {10 /* feature from */, 3 /* feature to */}}};
|
|
|
|
|
{3 /* feature from */, 4 /* feature to */},
|
|
|
|
|
{10 /* feature from */, 3 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
RestrictionVec restrictionsNo;
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
|
restrictionsNo);
|
|
|
|
@ -416,17 +422,18 @@ UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph_RestrictionF10F3OnlyF3F4Only)
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(10 /* featureId */, 0 /* segmentIdx */, m2::PointD(3, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(11, 0, m2::PointD(0, 3), *m_graph), move(restrictionsNo), *this);
|
|
|
|
|
MakeFakeEnding(11, 0, m2::PointD(0, 3), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph_RestrictionF2F8NoRestrictionF9F1Only)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTwoSquaresGraph());
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{Restriction::Type::No, {2 /* feature from */, 8 /* feature to */}}}; // Invalid restriction.
|
|
|
|
|
RestrictionVec const restrictionsOnly = {
|
|
|
|
|
{Restriction::Type::Only,
|
|
|
|
|
{9 /* feature from */, 1 /* feature to */}}}; // Invalid restriction.
|
|
|
|
|
{2 /* feature from */, 8 /* feature to */}
|
|
|
|
|
}; // Invalid restriction.
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{9 /* feature from */, 1 /* feature to */}
|
|
|
|
|
}; // Invalid restriction.
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
|
restrictionsNo);
|
|
|
|
|
|
|
|
|
@ -435,7 +442,7 @@ UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph_RestrictionF2F8NoRestrictionF9F
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(10 /* featureId */, 0 /* segmentIdx */, m2::PointD(3, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(11, 0, m2::PointD(0, 3), *m_graph), move(restrictionsNo), *this);
|
|
|
|
|
MakeFakeEnding(11, 0, m2::PointD(0, 3), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2 *
|
|
|
|
@ -448,7 +455,7 @@ UNIT_CLASS_TEST(RestrictionTest, TwoSquaresGraph_RestrictionF2F8NoRestrictionF9F
|
|
|
|
|
// | |
|
|
|
|
|
// 0 *---F1----*---F0---* Start
|
|
|
|
|
// 0 1 2
|
|
|
|
|
// Note 1. All features are two-way. (It's possible to move along any direction of the features.)
|
|
|
|
|
// Note 1. All features are two-way. (It's possible to std::move along any direction of the features.)
|
|
|
|
|
// Note 2. Any feature contains of one segment.
|
|
|
|
|
unique_ptr<SingleVehicleWorldGraph> BuildFlagGraph()
|
|
|
|
|
{
|
|
|
|
@ -480,7 +487,7 @@ unique_ptr<SingleVehicleWorldGraph> BuildFlagGraph()
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Route through flag graph without any restrictions.
|
|
|
|
@ -498,41 +505,43 @@ UNIT_TEST(FlagGraph)
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, FlagGraph_RestrictionF0F3No)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildFlagGraph());
|
|
|
|
|
RestrictionVec restrictions = {
|
|
|
|
|
{Restriction::Type::No, {0 /* feature from */, 3 /* feature to */}}};
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{0 /* feature from */, 3 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
vector<m2::PointD> const expectedGeom = {
|
|
|
|
|
{2 /* x */, 0 /* y */}, {1, 0}, {0, 0}, {0, 1}, {0.5, 1}};
|
|
|
|
|
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(2, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(6, 0, m2::PointD(0.5, 1), *m_graph), move(restrictions), *this);
|
|
|
|
|
MakeFakeEnding(6, 0, m2::PointD(0.5, 1), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Route through flag graph with one restriciton (type only) from F0 to F1.
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, FlagGraph_RestrictionF0F1Only)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildFlagGraph());
|
|
|
|
|
RestrictionVec restrictions = {
|
|
|
|
|
{Restriction::Type::No, {0 /* feature from */, 1 /* feature to */}}};
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{0 /* feature from */, 1 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
vector<m2::PointD> const expectedGeom = {{2 /* x */, 0 /* y */}, {1, 0}, {1, 1}, {0.5, 1}};
|
|
|
|
|
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(2, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(6, 0, m2::PointD(0.5, 1), *m_graph), move(restrictions), *this);
|
|
|
|
|
MakeFakeEnding(6, 0, m2::PointD(0.5, 1), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, FlagGraph_PermutationsF1F3NoF7F8OnlyF8F4OnlyF4F6Only)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildFlagGraph());
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{Restriction::Type::No, {0 /* feature from */, 3 /* feature to */}}
|
|
|
|
|
{0 /* feature from */, 3 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{Restriction::Type::Only, {0 /* feature from */, 1 /* feature to */}},
|
|
|
|
|
{Restriction::Type::Only, {1 /* feature from */, 2 /* feature to */}}
|
|
|
|
|
{0 /* feature from */, 1 /* feature to */},
|
|
|
|
|
{1 /* feature from */, 2 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
@ -543,7 +552,7 @@ UNIT_CLASS_TEST(RestrictionTest, FlagGraph_PermutationsF1F3NoF7F8OnlyF8F4OnlyF4F
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(2, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(6, 0, m2::PointD(0.5, 1), *m_graph), move(restrictionsNo), *this);
|
|
|
|
|
MakeFakeEnding(6, 0, m2::PointD(0.5, 1), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 1 *-F4-*-F5-*---F6---* Finish
|
|
|
|
@ -584,7 +593,7 @@ unique_ptr<SingleVehicleWorldGraph> BuildPosterGraph()
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Route through poster graph without any restrictions.
|
|
|
|
@ -603,15 +612,16 @@ UNIT_TEST(PosterGraph)
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, PosterGraph_RestrictionF0F3No)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildPosterGraph());
|
|
|
|
|
RestrictionVec restrictions = {
|
|
|
|
|
{Restriction::Type::No, {0 /* feature from */, 3 /* feature to */}}};
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{0 /* feature from */, 3 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
vector<m2::PointD> const expectedGeom = {
|
|
|
|
|
{2 /* x */, 0 /* y */}, {1, 0}, {0, 0}, {0, 1}, {0.5, 1}, {1, 1}, {2, 1}};
|
|
|
|
|
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(2, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(6, 0, m2::PointD(2, 1), *m_graph), move(restrictions), *this);
|
|
|
|
|
MakeFakeEnding(6, 0, m2::PointD(2, 1), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Route through poster graph with restrictions F0-F1 (type only).
|
|
|
|
@ -620,7 +630,8 @@ UNIT_CLASS_TEST(RestrictionTest, PosterGraph_RestrictionF0F1Only)
|
|
|
|
|
Init(BuildPosterGraph());
|
|
|
|
|
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{Restriction::Type::Only, {0 /* feature from */, 1 /* feature to */}}};
|
|
|
|
|
{0 /* feature from */, 1 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
RestrictionVec restrictionsNo;
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
|
restrictionsNo);
|
|
|
|
@ -630,7 +641,7 @@ UNIT_CLASS_TEST(RestrictionTest, PosterGraph_RestrictionF0F1Only)
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(2, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(6, 0, m2::PointD(2, 1), *m_graph), move(restrictionsNo), *this);
|
|
|
|
|
MakeFakeEnding(6, 0, m2::PointD(2, 1), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 1 *--F1-->*
|
|
|
|
@ -664,7 +675,7 @@ unique_ptr<WorldGraph> BuildTwoWayGraph()
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_TEST(TwoWayGraph)
|
|
|
|
@ -684,7 +695,7 @@ UNIT_TEST(TwoWayGraph)
|
|
|
|
|
// | |
|
|
|
|
|
// 0 *<--F5---*<--F1----*<--F0---* Start
|
|
|
|
|
// Finish
|
|
|
|
|
// 0 1 2 3
|
|
|
|
|
// 0 1 2 3
|
|
|
|
|
// Note 1. F0, F1 and F5 are one-way features. F3, F2 and F4 are two-way features.
|
|
|
|
|
// Note 2. Any feature contains of one segment.
|
|
|
|
|
unique_ptr<SingleVehicleWorldGraph> BuildSquaresGraph()
|
|
|
|
@ -714,7 +725,7 @@ unique_ptr<SingleVehicleWorldGraph> BuildSquaresGraph()
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_TEST(SquaresGraph)
|
|
|
|
@ -727,29 +738,29 @@ UNIT_TEST(SquaresGraph)
|
|
|
|
|
TestRouteGeometry(*starter, Algorithm::Result::OK, expectedGeom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// It's a test on correct working in case when because of adding restrictions
|
|
|
|
|
// start and finish could be match on blocked, moved or copied edges.
|
|
|
|
|
// See IndexGraphStarter constructor for a detailed description.
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, SquaresGraph_RestrictionF0F1OnlyF1F5Only)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildSquaresGraph());
|
|
|
|
|
RestrictionVec restrictionsNo;
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{Restriction::Type::Only, {0 /* feature from */, 1 /* feature to */}},
|
|
|
|
|
{Restriction::Type::Only, {1 /* feature from */, 5 /* feature to */}}};
|
|
|
|
|
{0 /* feature from */, 3 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
|
restrictionsNo);
|
|
|
|
|
|
|
|
|
|
vector<m2::PointD> const expectedGeom = {{3 /* x */, 0 /* y */}, {2, 0}, {1, 0}, {0, 0}};
|
|
|
|
|
vector<m2::PointD> const expectedGeom = {
|
|
|
|
|
{3.0, 0.0}, {2.0, 0.0}, {2.0, 1.0}, {1.0, 1.0}, {1.0, 0.0}, {0.0, 0.0}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(3, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(5, 0, m2::PointD(0, 0), *m_graph), move(restrictionsNo), *this);
|
|
|
|
|
MakeFakeEnding(5, 0, m2::PointD(0, 0), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 0 Start *--F0--->*---F1---*---F1---*---F1---*---F2-->* Finish
|
|
|
|
|
// TODO (@gmoryes) make true u_turn restriction
|
|
|
|
|
// 0 Start *--F0--->*<--F1---*---F1---*---F1---*---F2-->* Finish
|
|
|
|
|
// 0 1 2 3 4 5
|
|
|
|
|
// Note. F0 and F2 are one segment one-way features. F1 is a 3 segment two-way feature.
|
|
|
|
|
unique_ptr<SingleVehicleWorldGraph> BuildLineGraph()
|
|
|
|
@ -771,24 +782,25 @@ unique_ptr<SingleVehicleWorldGraph> BuildLineGraph()
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This test checks that despite the fact uturn on F1 is prohibited (moving from F1 to F1 is
|
|
|
|
|
// prohibited)
|
|
|
|
|
// it's still possible to move from F1 to F1 in straight direction.
|
|
|
|
|
// it's still possible to std::move from F1 to F1 in straight direction.
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, LineGraph_RestrictionF1F1No)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildLineGraph());
|
|
|
|
|
RestrictionVec restrictions = {
|
|
|
|
|
{Restriction::Type::No, {1 /* feature from */, 1 /* feature to */}}};
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{1 /* feature from */, 1 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
vector<m2::PointD> const expectedGeom = {
|
|
|
|
|
{0 /* x */, 0 /* y */}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}};
|
|
|
|
|
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(0, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(2, 0, m2::PointD(5, 0), *m_graph), move(restrictions), *this);
|
|
|
|
|
MakeFakeEnding(2, 0, m2::PointD(5, 0), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2 *---F2-->*
|
|
|
|
@ -822,17 +834,18 @@ unique_ptr<SingleVehicleWorldGraph> BuildFGraph()
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This test checks that having a Only restriction from F0 to F2 it's still possible move
|
|
|
|
|
// This test checks that having a Only restriction from F0 to F2 it's still possible std::move
|
|
|
|
|
// from F0 to F1.
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, FGraph_RestrictionF0F2Only)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildFGraph());
|
|
|
|
|
RestrictionVec restrictionsNo;
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{Restriction::Type::Only, {0 /* feature from */, 2 /* feature to */}}};
|
|
|
|
|
{0 /* feature from */, 2 /* feature to */}
|
|
|
|
|
};
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
|
restrictionsNo);
|
|
|
|
|
|
|
|
|
@ -841,7 +854,7 @@ UNIT_CLASS_TEST(RestrictionTest, FGraph_RestrictionF0F2Only)
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(0 /* featureId */, 0 /* segmentIdx */, m2::PointD(0, 0), *m_graph),
|
|
|
|
|
MakeFakeEnding(1, 0, m2::PointD(1, 1), *m_graph), move(restrictionsNo), *this);
|
|
|
|
|
MakeFakeEnding(1, 0, m2::PointD(1, 1), *m_graph), std::move(restrictionsNo), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// *---F4---*
|
|
|
|
@ -882,7 +895,7 @@ unique_ptr<SingleVehicleWorldGraph> BuildNonPassThroughGraph(bool passThroughSta
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(move(loader), estimator, joints);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, NonPassThroughStart)
|
|
|
|
@ -929,4 +942,193 @@ UNIT_CLASS_TEST(RestrictionTest, NontransiStartAndShortWay)
|
|
|
|
|
MakeFakeEnding(2, 0, m2::PointD(3, 0), *m_graph));
|
|
|
|
|
TestRouteGeometry(*m_starter, Algorithm::Result::OK, expectedGeom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2 *
|
|
|
|
|
// ↗ ↘
|
|
|
|
|
// F5 F4
|
|
|
|
|
// ↗ ↘ Finish
|
|
|
|
|
// 1 * *<- F3 ->*-> F8 -> *
|
|
|
|
|
// ↖ ↑
|
|
|
|
|
// F6 F2
|
|
|
|
|
// Start ↖ ↑
|
|
|
|
|
// 0 *-> F7 ->*-> F0 ->*-> F1 ->*
|
|
|
|
|
// -1 0 1 2 3
|
|
|
|
|
//
|
|
|
|
|
unique_ptr<SingleVehicleWorldGraph> BuildTwoCubeGraph1()
|
|
|
|
|
{
|
|
|
|
|
unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>();
|
|
|
|
|
loader->AddRoad(0 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{0.0, 0.0}, {1.0, 0.0}}));
|
|
|
|
|
loader->AddRoad(1 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{1.0, 0.0}, {2.0, 0.0}}));
|
|
|
|
|
loader->AddRoad(2 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{2.0, 0.0}, {2.0, 1.0}}));
|
|
|
|
|
loader->AddRoad(3 /* feature id */, false /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{1.0, 1.0}, {2.0, 1.0}}));
|
|
|
|
|
loader->AddRoad(4 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{0.0, 2.0}, {1.0, 1.0}}));
|
|
|
|
|
loader->AddRoad(5 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{-1.0, 1.0}, {0.0, 2.0}}));
|
|
|
|
|
loader->AddRoad(6 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{0.0, 0.0}, {-1.0, 1.0}}));
|
|
|
|
|
loader->AddRoad(7 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{-1.0, 0.0}, {0.0, 0.0}}));
|
|
|
|
|
loader->AddRoad(8 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{2.0, 1.0}, {3.0, 1.0}}));
|
|
|
|
|
|
|
|
|
|
vector<Joint> const joints = {
|
|
|
|
|
// {{/* feature id */, /* point id */}, ... }
|
|
|
|
|
MakeJoint({{7, 0}}), /* joint at point (-1, 0) */
|
|
|
|
|
MakeJoint({{0, 0}, {6, 0}, {7, 1}}), /* joint at point (0, 0) */
|
|
|
|
|
MakeJoint({{0, 1}, {1, 0}}), /* joint at point (1, 0) */
|
|
|
|
|
MakeJoint({{1, 1}, {2, 0}}), /* joint at point (2, 0) */
|
|
|
|
|
MakeJoint({{2, 1}, {3, 1}, {8, 0}}), /* joint at point (2, 1) */
|
|
|
|
|
MakeJoint({{3, 0}, {4, 1}}), /* joint at point (1, 1) */
|
|
|
|
|
MakeJoint({{5, 1}, {4, 0}}), /* joint at point (0, 2) */
|
|
|
|
|
MakeJoint({{6, 1}, {5, 0}}), /* joint at point (-1, 1) */
|
|
|
|
|
MakeJoint({{8, 1}}), /* joint at point (3, 1) */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2 *
|
|
|
|
|
// ↗ ↘
|
|
|
|
|
// F5 F4
|
|
|
|
|
// ↗ ↘ Finish
|
|
|
|
|
// 1 * *<- F3 ->*-> F8 -> *-> F10 -> *
|
|
|
|
|
// ↖ ↑ ↗
|
|
|
|
|
// F6 F2 F9
|
|
|
|
|
// Start ↖ ↑ ↗
|
|
|
|
|
// 0 *-> F7 ->*-> F0 ->*-> F1 ->*
|
|
|
|
|
// -1 0 1 2 3 4
|
|
|
|
|
//
|
|
|
|
|
unique_ptr<SingleVehicleWorldGraph> BuildTwoCubeGraph2()
|
|
|
|
|
{
|
|
|
|
|
unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>();
|
|
|
|
|
loader->AddRoad(0 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{0.0, 0.0}, {1.0, 0.0}}));
|
|
|
|
|
loader->AddRoad(1 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{1.0, 0.0}, {2.0, 0.0}}));
|
|
|
|
|
loader->AddRoad(2 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{2.0, 0.0}, {2.0, 1.0}}));
|
|
|
|
|
loader->AddRoad(3 /* feature id */, false /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{1.0, 1.0}, {2.0, 1.0}}));
|
|
|
|
|
loader->AddRoad(4 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{0.0, 2.0}, {1.0, 1.0}}));
|
|
|
|
|
loader->AddRoad(5 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{-1.0, 1.0}, {0.0, 2.0}}));
|
|
|
|
|
loader->AddRoad(6 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{0.0, 0.0}, {-1.0, 1.0}}));
|
|
|
|
|
loader->AddRoad(7 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{-1.0, 0.0}, {0.0, 0.0}}));
|
|
|
|
|
loader->AddRoad(8 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{2.0, 1.0}, {3.0, 1.0}}));
|
|
|
|
|
loader->AddRoad(9 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{2.0, 0.0}, {3.0, 1.0}}));
|
|
|
|
|
loader->AddRoad(10 /* feature id */, true /* one way */, 1.0 /* speed */,
|
|
|
|
|
RoadGeometry::Points({{3.0, 1.0}, {4.0, 1.0}}));
|
|
|
|
|
|
|
|
|
|
vector<Joint> const joints = {
|
|
|
|
|
// {{/* feature id */, /* point id */}, ... }
|
|
|
|
|
MakeJoint({{7, 0}}), /* joint at point (-1, 0) */
|
|
|
|
|
MakeJoint({{0, 0}, {6, 0}, {7, 1}}), /* joint at point (0, 0) */
|
|
|
|
|
MakeJoint({{0, 1}, {1, 0}}), /* joint at point (1, 0) */
|
|
|
|
|
MakeJoint({{1, 1}, {2, 0}, {9, 0}}), /* joint at point (2, 0) */
|
|
|
|
|
MakeJoint({{2, 1}, {3, 1}, {8, 0}}), /* joint at point (2, 1) */
|
|
|
|
|
MakeJoint({{3, 0}, {4, 1}}), /* joint at point (1, 1) */
|
|
|
|
|
MakeJoint({{5, 1}, {4, 0}}), /* joint at point (0, 2) */
|
|
|
|
|
MakeJoint({{6, 1}, {5, 0}}), /* joint at point (-1, 1) */
|
|
|
|
|
MakeJoint({{8, 1}, {9, 1}, {10, 0}}), /* joint at point (3, 1) */
|
|
|
|
|
MakeJoint({{10, 1}}) /* joint at point (4, 1) */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
traffic::TrafficCache const trafficCache;
|
|
|
|
|
shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
|
|
|
|
|
return BuildWorldGraph(std::move(loader), estimator, joints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, RestrictionNoWithWayAsVia_1)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTwoCubeGraph1());
|
|
|
|
|
|
|
|
|
|
m2::PointD const start(-1.0, 0.0);
|
|
|
|
|
m2::PointD const finish(3.0, 1.0);
|
|
|
|
|
auto const test = [&](vector<m2::PointD> const & expectedGeom, RestrictionVec && restrictionsNo) {
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(7 /* featureId */, 0 /* segmentIdx */, start, *m_graph),
|
|
|
|
|
MakeFakeEnding(8 /* featureId */, 0 /* segmentIdx */, finish, *m_graph),
|
|
|
|
|
std::move(restrictionsNo), *this);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Can not go from |0| to |2| via |1|
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{0 /* feature 0 */, 1 /* feature 1 */, 2 /* feature 2 */}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Check that without restrictions we can find path better.
|
|
|
|
|
test({start, {0.0, 0.0}, {-1.0, 1.0}, {0.0, 2.0}, {1.0, 1.0}, {2.0, 1.0}, finish},
|
|
|
|
|
std::move(restrictionsNo));
|
|
|
|
|
|
|
|
|
|
test({start, {0.0, 0.0}, {1.0, 0.0}, {2.0, 0.0}, {2.0, 1.0}, finish},
|
|
|
|
|
RestrictionVec());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, RestrictionNoWithWayAsVia_2)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTwoCubeGraph2());
|
|
|
|
|
|
|
|
|
|
m2::PointD const start(-1.0, 0.0);
|
|
|
|
|
m2::PointD const finish(4.0, 1.0);
|
|
|
|
|
auto const test = [&](vector<m2::PointD> const & expectedGeom, RestrictionVec && restrictionsNo) {
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(7 /* featureId */, 0 /* segmentIdx */, start, *m_graph),
|
|
|
|
|
MakeFakeEnding(10 /* featureId */, 0 /* segmentIdx */, finish, *m_graph),
|
|
|
|
|
std::move(restrictionsNo), *this);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Can go from |0| to |9| only via |1|
|
|
|
|
|
RestrictionVec restrictionsNo = {
|
|
|
|
|
{0 /* feature 0 */, 1 /* feature 1 */, 9 /* feature 2 */}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Check that without restrictions we can find path better.
|
|
|
|
|
test({start, {0.0, 0.0}, {1.0, 0.0}, {2.0, 0.0}, {2.0, 1.0}, {3.0, 1.0}, finish},
|
|
|
|
|
std::move(restrictionsNo));
|
|
|
|
|
|
|
|
|
|
test({start, {0.0, 0.0}, {1.0, 0.0}, {2.0, 0.0}, {3.0, 1.0}, finish},
|
|
|
|
|
RestrictionVec());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNIT_CLASS_TEST(RestrictionTest, RestrictionOnlyWithWayAsVia_1)
|
|
|
|
|
{
|
|
|
|
|
Init(BuildTwoCubeGraph2());
|
|
|
|
|
|
|
|
|
|
m2::PointD const start(-1.0, 0.0);
|
|
|
|
|
m2::PointD const finish(4.0, 1.0);
|
|
|
|
|
auto const test = [&](vector<m2::PointD> const & expectedGeom, RestrictionVec && restrictionsNo) {
|
|
|
|
|
TestRestrictions(
|
|
|
|
|
expectedGeom, Algorithm::Result::OK,
|
|
|
|
|
MakeFakeEnding(7 /* featureId */, 0 /* segmentIdx */, start, *m_graph),
|
|
|
|
|
MakeFakeEnding(10 /* featureId */, 0 /* segmentIdx */, finish, *m_graph),
|
|
|
|
|
std::move(restrictionsNo), *this);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
RestrictionVec restrictionsNo;
|
|
|
|
|
// Can go from |0| to |2| only via |1|
|
|
|
|
|
RestrictionVec restrictionsOnly = {
|
|
|
|
|
{0 /* feature 0 */, 1 /* feature 1 */, 2 /* feature 2 */}
|
|
|
|
|
};
|
|
|
|
|
ConvertRestrictionsOnlyToNoAndSort(m_graph->GetIndexGraphForTests(kTestNumMwmId), restrictionsOnly,
|
|
|
|
|
restrictionsNo);
|
|
|
|
|
|
|
|
|
|
// Check that without restrictions we can find path better.
|
|
|
|
|
test({start, {0, 0}, {1, 0}, {2, 0}, {2, 1}, {3, 1}, finish}, std::move(restrictionsNo));
|
|
|
|
|
test({start, {0, 0}, {1, 0}, {2, 0}, {3, 1}, finish}, RestrictionVec());
|
|
|
|
|
}
|
|
|
|
|
} // namespace routing_test
|
|
|
|
|
|
|
|
|
|