From b7364e0420fc15c4e2b34769c52c1b77acc5263d Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Sat, 8 Jan 2022 20:40:17 +0300 Subject: [PATCH] [routing] Fixed bug with several start/end MWMs in optimal route. Signed-off-by: Viktor Govako --- routing/index_router.cpp | 8 ++++++++ routing/routing_integration_tests/route_test.cpp | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 7f4b85b659..555e86cc31 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -1238,6 +1238,10 @@ RouterResultCode IndexRouter::ProcessLeapsJoints(vector const & input, // To avoid this behavior we collapse all leaps from start to last occurrence of startId to one leap and // use WorldGraph with NoLeaps mode to proccess these leap. Unlike SingleMwm mode used to process ordinary leaps // NoLeaps allows to use all mwms so if we really need to visit other mwm we will. + /// @todo By VNG: This workaround doesn't work on issues below. Comment it and check unneeded loops again. + /// https://github.com/organicmaps/organicmaps/issues/821 + + /* auto const firstMwmId = input[1].GetMwmId(); auto const startLeapEndReverseIt = find_if(input.rbegin() + 2, input.rend(), [firstMwmId](Segment const & s) { return s.GetMwmId() == firstMwmId; }); @@ -1249,6 +1253,10 @@ RouterResultCode IndexRouter::ProcessLeapsJoints(vector const & input, auto const finishLeapStartIt = find_if(startLeapEndIt, input.end(), [lastMwmId](Segment const & s) { return s.GetMwmId() == lastMwmId; }); auto const finishLeapStart = static_cast(distance(input.begin(), finishLeapStartIt)); + */ + + auto const startLeapEnd = 1; + auto const finishLeapStart = input.size() - 2; auto fillMwmIds = [&](size_t start, size_t end, set & mwmIds) { diff --git a/routing/routing_integration_tests/route_test.cpp b/routing/routing_integration_tests/route_test.cpp index f4e435427a..49b2a37233 100644 --- a/routing/routing_integration_tests/route_test.cpp +++ b/routing/routing_integration_tests/route_test.cpp @@ -582,4 +582,13 @@ namespace mercator::FromLatLon(49.512076, 8.284476), {0., 0.}, mercator::FromLatLon(49.523783, 8.288701), 2014.); } + + // https://github.com/organicmaps/organicmaps/issues/821 + UNIT_TEST(Ukraine_UmanOdessa) + { + integration::CalculateRouteAndTestRouteLength( + integration::GetVehicleComponents(VehicleType::Car), + mercator::FromLatLon(48.7498, 30.2203), {0., 0.}, + mercator::FromLatLon(46.4859, 30.6837), 265163.); + } } // namespace