From a6064c7e4858eeb770ea38f3049e5bb0e69c2538 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Thu, 15 Mar 2018 18:13:37 +0300 Subject: Removing more slight turns in case if other roads has less highway class. --- routing/routing_integration_tests/turn_test.cpp | 8 +++----- routing/turns_generator.cpp | 11 ++++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'routing') diff --git a/routing/routing_integration_tests/turn_test.cpp b/routing/routing_integration_tests/turn_test.cpp index dd0b92a41e..daa6ff8d97 100644 --- a/routing/routing_integration_tests/turn_test.cpp +++ b/routing/routing_integration_tests/turn_test.cpp @@ -232,11 +232,10 @@ UNIT_TEST(RussiaMoscowParallelResidentalUTurnAvoiding) IRouter::ResultCode const result = routeResult.second; TEST_EQUAL(result, IRouter::NoError, ()); - integration::TestTurnCount(route, 3 /* expectedTurnCount */); + integration::TestTurnCount(route, 2 /* expectedTurnCount */); // Checking a turn in case going from a not-link to a link integration::GetNthTurn(route, 0).TestValid().TestDirection(CarDirection::TurnLeft); - integration::GetNthTurn(route, 1).TestValid().TestDirection(CarDirection::GoStraight); - integration::GetNthTurn(route, 2).TestValid().TestDirection(CarDirection::TurnLeft); + integration::GetNthTurn(route, 1).TestValid().TestDirection(CarDirection::TurnLeft); } UNIT_TEST(RussiaMoscowPankratevskiPerBolshaySuharedskazPloschadTurnTest) @@ -892,9 +891,8 @@ UNIT_TEST(RussiaMoscowTTKToNMaslovkaTest) IRouter::ResultCode const result = routeResult.second; TEST_EQUAL(result, IRouter::NoError, ()); - integration::TestTurnCount(route, 2 /* expectedTurnCount */); + integration::TestTurnCount(route, 1 /* expectedTurnCount */); integration::GetNthTurn(route, 0).TestValid().TestDirection(CarDirection::ExitHighwayToRight); - integration::GetNthTurn(route, 1).TestValid().TestDirection(CarDirection::GoStraight); } UNIT_TEST(RussiaMoscowComplicatedTurnTest) diff --git a/routing/turns_generator.cpp b/routing/turns_generator.cpp index d6af46f465..d10d8036f7 100644 --- a/routing/turns_generator.cpp +++ b/routing/turns_generator.cpp @@ -150,9 +150,14 @@ bool KeepTurnByHighwayClass(CarDirection turn, TurnCandidates const & possibleTu if (minClassForTheRoute == ftypes::HighwayClass::Undefined) return false; // Fake edges have HighwayClass::Undefined. - int const kMaxHighwayClassDiffToKeepTheTurn = 2; - if (static_cast(maxClassForPossibleTurns) - static_cast(minClassForTheRoute) >= - kMaxHighwayClassDiffToKeepTheTurn) + // Maximum difference between HighwayClasses of route segments and possible way segments + // to keep the bifurcation point as a turn. + int constexpr kMaxHighwayClassDiff = 2; + int constexpr kMaxHighwayClassDiffForService = 1; + int const diff = + static_cast(maxClassForPossibleTurns) - static_cast(minClassForTheRoute); + if (diff >= kMaxHighwayClassDiff || + (maxClassForPossibleTurns == ftypes::HighwayClass::Service && diff >= kMaxHighwayClassDiffForService)) { // The turn shall be removed if the route goes near small roads without changing the direction. return false; -- cgit v1.2.3