From 65af8b7ca73c8b907408a3c401655c7b56bb9b6a Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Mon, 21 May 2018 15:06:35 +0300 Subject: [PATCH] [routing] Fix weight calculation for fake parts of real --- routing/index_graph_starter.cpp | 22 ++++++++++++++++------ routing/index_graph_starter.hpp | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/routing/index_graph_starter.cpp b/routing/index_graph_starter.cpp index 14108423ba..a1d5927b8d 100644 --- a/routing/index_graph_starter.cpp +++ b/routing/index_graph_starter.cpp @@ -216,7 +216,7 @@ void IndexGraphStarter::GetEdgesList(Segment const & segment, bool isOutgoing, m_graph.GetEdgeList(segment, isOutgoing, edges); } - AddFakeEdges(segment, edges); + AddFakeEdges(segment, isOutgoing, edges); } RouteWeight IndexGraphStarter::CalcSegmentWeight(Segment const & segment) const @@ -344,18 +344,28 @@ void IndexGraphStarter::AddFinish(FakeEnding const & finishEnding, FakeEnding co fakeNumerationStart); } -void IndexGraphStarter::AddFakeEdges(Segment const & segment, vector & edges) const +void IndexGraphStarter::AddFakeEdges(Segment const & segment, bool isOutgoing, vector & edges) const { vector fakeEdges; for (auto const & edge : edges) { for (auto const & s : m_fake.GetFake(edge.GetTarget())) { - // Check fake segment is connected to source segment. - if (GetJunction(s, false /* front */) == GetJunction(segment, true) || - GetJunction(s, true) == GetJunction(segment, false)) + // |segment| |s| + // *------------>*-----------> + bool const sIsOutgoing = + GetJunction(segment, true /*front */) == GetJunction(s, false /* front */); + + // |s| |segment| + // *------------>*-----------> + bool const sIsIngoing = + GetJunction(s, true /*front */) == GetJunction(segment, false /* front */); + + if ((isOutgoing && sIsOutgoing) || (!isOutgoing && sIsIngoing)) { - fakeEdges.emplace_back(s, edge.GetWeight()); + // For ingoing edges we use source weight which is the same for |s| and for |edge| and is + // already calculated. + fakeEdges.emplace_back(s, isOutgoing ? CalcSegmentWeight(s) : edge.GetWeight()); } } } diff --git a/routing/index_graph_starter.hpp b/routing/index_graph_starter.hpp index db0afe1a64..4e9ad5deaf 100644 --- a/routing/index_graph_starter.hpp +++ b/routing/index_graph_starter.hpp @@ -140,7 +140,7 @@ private: // Adds fake edges of type PartOfReal which correspond real edges from |edges| and are connected // to |segment| - void AddFakeEdges(Segment const & segment, vector & edges) const; + void AddFakeEdges(Segment const & segment, bool isOutgoing, std::vector & edges) const; // Checks whether ending belongs to pass-through or non-pass-through zone. bool EndingPassThroughAllowed(Ending const & ending);