From ce41f2982e5772ed0d976cda62a5d5b236fb4d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BE=D0=B1=D1=80=D1=8B=D0=B8=CC=86=20=D0=AD=D1=8D?= =?UTF-8?q?=D1=85?= Date: Thu, 19 Jan 2017 14:31:27 +0300 Subject: [PATCH] [routing] fix one segment way --- routing/index_graph_starter.cpp | 3 +-- routing/routing_tests/index_graph_test.cpp | 26 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/routing/index_graph_starter.cpp b/routing/index_graph_starter.cpp index 0ba068c559..28a8bc55a9 100644 --- a/routing/index_graph_starter.cpp +++ b/routing/index_graph_starter.cpp @@ -82,8 +82,7 @@ void IndexGraphStarter::GetFakeToNormalEdge(FakeVertex const & fakeVertex, bool vector & edges) { Segment const segment(fakeVertex.GetFeatureId(), fakeVertex.GetSegmentIdx(), forward); - RoadPoint const & roadPoint = segment.GetRoadPoint(true /* front */); - m2::PointD const & pointTo = m_graph.GetGeometry().GetPoint(roadPoint); + m2::PointD const & pointTo = GetPoint(segment, true /* front */); double const weight = m_graph.GetEstimator().CalcHeuristic(fakeVertex.GetPoint(), pointTo); edges.emplace_back(segment, weight); } diff --git a/routing/routing_tests/index_graph_test.cpp b/routing/routing_tests/index_graph_test.cpp index d76872de60..133543e1f1 100644 --- a/routing/routing_tests/index_graph_test.cpp +++ b/routing/routing_tests/index_graph_test.cpp @@ -325,6 +325,32 @@ UNIT_TEST(RoadSpeed) TestRoute(graph, start, finish, 6, &expectedRoute); } +// Roads y: +// +// R0 * - - - - - - - - * 0 +// ^ ^ +// start finish +// +// x: 0 1 2 3 +// +UNIT_TEST(OneSegmentWay) +{ + unique_ptr loader = make_unique(); + + loader->AddRoad(0 /* featureId */, false, 1.0 /* speed */, + RoadGeometry::Points({{0.0, 0.0}, {3.0, 0.0}})); + + traffic::TrafficCache const trafficCache; + IndexGraph graph(move(loader), CreateEstimator(trafficCache)); + graph.Import(vector()); + + IndexGraphStarter::FakeVertex const start(0, 0, m2::PointD(1, 0)); + IndexGraphStarter::FakeVertex const finish(0, 0, m2::PointD(2, 0)); + + vector const expectedRoute({{0, 0, true}}); + TestRoute(graph, start, finish, 1 /* expectedLength */, &expectedRoute); +} + // // Road R0 (ped) R1 (car) R2 (car) // 0----------1 * 0----------1 * 0----------1