forked from organicmaps/organicmaps
[routing] fix one segment way
This commit is contained in:
parent
28b2cebdf4
commit
ce41f2982e
2 changed files with 27 additions and 2 deletions
|
@ -82,8 +82,7 @@ void IndexGraphStarter::GetFakeToNormalEdge(FakeVertex const & fakeVertex, bool
|
|||
vector<SegmentEdge> & 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);
|
||||
}
|
||||
|
|
|
@ -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<TestGeometryLoader> loader = make_unique<TestGeometryLoader>();
|
||||
|
||||
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<Joint>());
|
||||
|
||||
IndexGraphStarter::FakeVertex const start(0, 0, m2::PointD(1, 0));
|
||||
IndexGraphStarter::FakeVertex const finish(0, 0, m2::PointD(2, 0));
|
||||
|
||||
vector<Segment> 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
|
||||
|
|
Loading…
Add table
Reference in a new issue