From 775b76fb9e60da81c3fa316f273e2e6f927edabc Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Fri, 4 Dec 2015 10:05:22 +0300 Subject: [PATCH 1/2] Oneway uturn bugfix. --- routing/turns_generator.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/routing/turns_generator.cpp b/routing/turns_generator.cpp index 62f8ff7810..b66171f392 100644 --- a/routing/turns_generator.cpp +++ b/routing/turns_generator.cpp @@ -918,16 +918,13 @@ size_t CheckUTurnOnRoute(vector const & segments, size_t curr checkedSegment.m_isLink == masterSegment.m_isLink && !checkedSegment.m_onRoundabout) { auto const & path = masterSegment.m_path; - m2::PointD p1 = path[path.size() - 1] - path[path.size() - 2]; - m2::PointD p2 = checkedSegment.m_path[1] - checkedSegment.m_path[0]; - // Same segment UTurn case. if (i == 0) { // TODO Fix direction calculation. // Warning! We can not determine UTurn direction in single edge case. So we use UTurnLeft. // We decided to add driving rules (left-right sided driving) to mwm header. - if (p1 == p2) + if (path[path.size() - 2] == checkedSegment.m_path[1]) { turn.m_turn = TurnDirection::UTurnLeft; return 1; @@ -940,7 +937,10 @@ size_t CheckUTurnOnRoute(vector const & segments, size_t curr if (checkedSegment.m_name.empty()) return 0; - auto angle = ang::TwoVectorsAngle(m2::PointD::Zero(), p1, p2); + m2::PointD const v1 = path[path.size() - 1] - path[path.size() - 2]; + m2::PointD const v2 = checkedSegment.m_path[1] - checkedSegment.m_path[0]; + + auto angle = ang::TwoVectorsAngle(m2::PointD::Zero(), v1, v2); if (!my::AlmostEqualAbs(angle, math::pi, kUTurnHeadingSensitivity)) return 0; From b4b550dbc1d1dc4a6e672d530057f631fc1d7042 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Fri, 4 Dec 2015 10:06:24 +0300 Subject: [PATCH 2/2] Adding integration test on oneway uturn bugfix. --- .../routing_integration_tests/osrm_turn_test.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/routing/routing_integration_tests/osrm_turn_test.cpp b/routing/routing_integration_tests/osrm_turn_test.cpp index 756d7dac75..19ad587136 100644 --- a/routing/routing_integration_tests/osrm_turn_test.cpp +++ b/routing/routing_integration_tests/osrm_turn_test.cpp @@ -396,3 +396,16 @@ UNIT_TEST(SwitzerlandSamstagernBergstrasseTest) TEST_EQUAL(result, IRouter::NoError, ()); integration::TestTurnCount(route, 0); } + +UNIT_TEST(RussiaMoscowMikoiankNoUTurnTest) +{ + TRouteResult const routeResult = integration::CalculateRoute( + integration::GetOsrmComponents(), MercatorBounds::FromLatLon(55.79041, 37.53770), {0., 0.}, + MercatorBounds::FromLatLon(55.79182, 37.53008)); + + Route const & route = *routeResult.first; + IRouter::ResultCode const result = routeResult.second; + + TEST_EQUAL(result, IRouter::NoError, ()); + integration::TestTurnCount(route, 0); +}