diff --git a/routing/routing_integration_tests/osrm_turn_test.cpp b/routing/routing_integration_tests/osrm_turn_test.cpp index a1759b4c73..3b63f7b2a5 100644 --- a/routing/routing_integration_tests/osrm_turn_test.cpp +++ b/routing/routing_integration_tests/osrm_turn_test.cpp @@ -8,6 +8,30 @@ using namespace routing; using namespace routing::turns; +UNIT_TEST(RussiaMoscowNagatinoUturnTurnTest) +{ + TRouteResult const routeResult = integration::CalculateRoute( + integration::GetOsrmComponents(), + MercatorBounds::FromLatLon(55.67251, 37.63604), {-0.004, -0.01}, + MercatorBounds::FromLatLon(55.67293, 37.63507)); + + Route const & route = *routeResult.first; + IRouter::ResultCode const result = routeResult.second; + TEST_EQUAL(result, IRouter::NoError, ()); + + integration::TestTurnCount(route, 3); + + integration::GetNthTurn(route, 0) + .TestValid() + .TestDirection(TurnDirection::TurnRight); + integration::GetNthTurn(route, 1) + .TestValid() + .TestDirection(TurnDirection::UTurnLeft); + integration::GetNthTurn(route, 2).TestValid().TestDirection(TurnDirection::TurnLeft); + + integration::TestRouteLength(route, 561.); +} + UNIT_TEST(RussiaMoscowLenigradskiy39UturnTurnTest) { TRouteResult const routeResult = integration::CalculateRoute( diff --git a/routing/turns_generator.cpp b/routing/turns_generator.cpp index 3f03444d76..ecadef2e16 100644 --- a/routing/turns_generator.cpp +++ b/routing/turns_generator.cpp @@ -956,6 +956,10 @@ size_t CheckUTurnOnRoute(vector const & segments, size_t curr if (checkedSegment.m_name.empty()) return 0; + // Avoid returning to the same edge after uturn somewere else. + if (path[path.size() - 2] == checkedSegment.m_path[1]) + return 0; + m2::PointD const v1 = path[path.size() - 1] - path[path.size() - 2]; m2::PointD const v2 = checkedSegment.m_path[1] - checkedSegment.m_path[0];