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

Function TestRouteGeometry

libs/routing/routing_tests/index_graph_tools.cpp:488–538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488void TestRouteGeometry(IndexGraphStarter & starter, AlgorithmForWorldGraph::Result expectedRouteResult,
489 vector<m2::PointD> const & expectedRouteGeom)
490{
491 vector<Segment> routeSegs;
492 double timeSec = 0.0;
493 auto const resultCode = CalculateRoute(starter, routeSegs, timeSec);
494
495 TEST_EQUAL(resultCode, expectedRouteResult, ());
496
497 if (AlgorithmForWorldGraph::Result::NoPath == expectedRouteResult && expectedRouteGeom.empty())
498 {
499 // The route goes through a restriction. So there's no choice for building route
500 // except for going through restriction. So no path.
501 return;
502 }
503
504 if (resultCode != AlgorithmForWorldGraph::Result::OK)
505 return;
506
507 CHECK(!routeSegs.empty(), ());
508 vector<m2::PointD> geom;
509
510 auto const pushPoint = [&geom](ms::LatLon const & ll)
511 {
512 auto const point = mercator::FromLatLon(ll);
513 if (geom.empty() || geom.back() != point)
514 geom.push_back(point);
515 };
516
517 for (auto const & routeSeg : routeSegs)
518 {
519 auto const & ll = starter.GetPoint(routeSeg, false /* front */);
520 // Note. In case of A* router all internal points of route are duplicated.
521 // So it's necessary to exclude the duplicates.
522 pushPoint(ll);
523 }
524
525 pushPoint(starter.GetPoint(routeSegs.back(), false /* front */));
526 TEST_EQUAL(geom.size(), expectedRouteGeom.size(), ("geom:", geom, "expectedRouteGeom:", expectedRouteGeom));
527 for (size_t i = 0; i < geom.size(); ++i)
528 {
529 static double constexpr kEps = 1e-8;
530 if (!AlmostEqualAbs(geom[i], expectedRouteGeom[i], kEps))
531 {
532 for (size_t j = 0; j < geom.size(); ++j)
533 LOG(LINFO, (j, "=>", geom[j], "vs", expectedRouteGeom[j]));
534
535 TEST(false, ("Point with number:", i, "doesn't equal to expected."));
536 }
537 }
538}
539
540void TestRestrictions(vector<m2::PointD> const & expectedRouteGeom, AlgorithmForWorldGraph::Result expectedRouteResult,
541 FakeEnding const & start, FakeEnding const & finish, RestrictionVec && restrictions,

Callers 6

UNIT_CLASS_TESTFunction · 0.85
UNIT_TESTFunction · 0.85
TestRestrictionsFunction · 0.85
UNIT_TESTFunction · 0.85
UNIT_CLASS_TESTFunction · 0.85
UNIT_TESTFunction · 0.85

Calls 9

TESTFunction · 0.85
backMethod · 0.80
CalculateRouteFunction · 0.70
FromLatLonFunction · 0.50
AlmostEqualAbsFunction · 0.50
emptyMethod · 0.45
push_backMethod · 0.45
GetPointMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected