diff --git a/routing/index_graph_starter.cpp b/routing/index_graph_starter.cpp index ab5516b455..e285bbd64f 100644 --- a/routing/index_graph_starter.cpp +++ b/routing/index_graph_starter.cpp @@ -1,6 +1,19 @@ #include "routing/index_graph_starter.hpp" -#include "routing/routing_exceptions.hpp" +#include "geometry/distance.hpp" + +namespace +{ +using namespace routing; + +m2::PointD CalcProjectionToSegment(Segment const & segment, m2::PointD const & point, + WorldGraph & graph) +{ + m2::ProjectionToSection projection; + projection.SetBounds(graph.GetPoint(segment, false), graph.GetPoint(segment, true)); + return projection(point); +} +} namespace routing { @@ -10,7 +23,11 @@ Segment constexpr IndexGraphStarter::kFinishFakeSegment; IndexGraphStarter::IndexGraphStarter(FakeVertex const & start, FakeVertex const & finish, WorldGraph & graph) - : m_graph(graph), m_start(start), m_finish(finish) + : m_graph(graph) + , m_start(start.GetSegment(), + CalcProjectionToSegment(start.GetSegment(), start.GetPoint(), graph)) + , m_finish(finish.GetSegment(), + CalcProjectionToSegment(finish.GetSegment(), finish.GetPoint(), graph)) { } diff --git a/routing/index_graph_starter.hpp b/routing/index_graph_starter.hpp index 93e1edc6e4..197fc7aa4c 100644 --- a/routing/index_graph_starter.hpp +++ b/routing/index_graph_starter.hpp @@ -36,6 +36,7 @@ public: NumMwmId GetMwmId() const { return m_segment.GetMwmId(); } uint32_t GetFeatureId() const { return m_segment.GetFeatureId(); } m2::PointD const & GetPoint() const { return m_point; } + Segment const & GetSegment() const { return m_segment; } Segment GetSegmentWithDirection(bool forward) const { diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 3a7c7fa3aa..4fbb94863f 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -213,7 +213,7 @@ IRouter::ResultCode IndexRouter::DoCalculateRoute(string const & startCountry, IndexGraphStarter starter(start, finish, graph); AStarProgress progress(0, 100); - progress.Initialize(startPoint, finalPoint); + progress.Initialize(starter.GetStartVertex().GetPoint(), starter.GetFinishVertex().GetPoint()); uint32_t drawPointsStep = 0; auto onVisitJunction = [&](Segment const & from, Segment const & to) {