MCPcopy Create free account
hub / github.com/comaps/comaps / BuildSquaresGraph

Function BuildSquaresGraph

libs/routing/routing_tests/restriction_test.cpp:582–610  ·  view source on GitHub ↗

1 *---F4---- | | F2 F3 | | 0 *<--F5---*<--F1----*<--F0---* Start Finish 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.

Source from the content-addressed store, hash-verified

580// Note 1. F0, F1 and F5 are one-way features. F3, F2 and F4 are two-way features.
581// Note 2. Any feature contains of one segment.
582unique_ptr<SingleVehicleWorldGraph> BuildSquaresGraph()
583{
584 unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>();
585 loader->AddRoad(0 /* feature id */, true /* one way */, 1.0 /* speed */,
586 RoadGeometry::Points({{3.0, 0.0}, {2.0, 0.0}}));
587 loader->AddRoad(1 /* feature id */, true /* one way */, 1.0 /* speed */,
588 RoadGeometry::Points({{2.0, 0.0}, {1.0, 0.0}}));
589 loader->AddRoad(2 /* feature id */, false /* one way */, 1.0 /* speed */,
590 RoadGeometry::Points({{1.0, 0.0}, {1.0, 1.0}}));
591 loader->AddRoad(3 /* feature id */, false /* one way */, 1.0 /* speed */,
592 RoadGeometry::Points({{2.0, 0.0}, {2.0, 1.0}}));
593 loader->AddRoad(4 /* feature id */, false /* one way */, 1.0 /* speed */,
594 RoadGeometry::Points({{2.0, 1.0}, {1.0, 1.0}}));
595 loader->AddRoad(5 /* feature id */, true /* one way */, 1.0 /* speed */,
596 RoadGeometry::Points({{1.0, 0.0}, {0.0, 0.0}}));
597
598 vector<Joint> const joints = {
599 MakeJoint({{0 /* feature id */, 0 /* point id */}}), /* joint at point (3, 0) */
600 MakeJoint({{0, 1}, {3, 0}, {1, 0}}), /* joint at point (2, 0) */
601 MakeJoint({{3, 1}, {4, 0}}), /* joint at point (2, 1) */
602 MakeJoint({{2, 1}, {4, 1}}), /* joint at point (1, 1) */
603 MakeJoint({{1, 1}, {2, 0}, {5, 0}}), /* joint at point (1, 0) */
604 MakeJoint({{5, 1}}) /* joint at point (0, 0) */
605 };
606
607 traffic::TrafficCache const trafficCache;
608 shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache);
609 return BuildWorldGraph(std::move(loader), estimator, joints);
610}
611
612UNIT_TEST(SquaresGraph)
613{

Callers 2

UNIT_TESTFunction · 0.85
UNIT_CLASS_TESTFunction · 0.85

Calls 5

PointsFunction · 0.85
MakeJointFunction · 0.85
CreateEstimatorForCarFunction · 0.85
BuildWorldGraphFunction · 0.85
AddRoadMethod · 0.45

Tested by

no test coverage detected