Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2018-02-01 11:16:51 +0300
committermpimenov <mpimenov@users.noreply.github.com>2018-02-19 20:26:27 +0300
commit6e2d1076b2538813a07c52d726df51105b640ca7 (patch)
treec4a54f32bbd6ce2ef7cd4471d7b80f5dcf2c1d64 /routing
parent896439001935f7d624a5a9484bb0ab5cff860883 (diff)
Preventing UTurn notification in case of zero length segments.
Diffstat (limited to 'routing')
-rw-r--r--routing/turns_generator.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/routing/turns_generator.cpp b/routing/turns_generator.cpp
index aa14426906..4b61d867db 100644
--- a/routing/turns_generator.cpp
+++ b/routing/turns_generator.cpp
@@ -37,7 +37,8 @@ bool KeepTurnByHighwayClass(CarDirection turn, TurnCandidates const & possibleTu
if (!IsGoStraightOrSlightTurn(turn))
return true; // The road significantly changes its direction here. So this turn shall be kept.
- // There's only one exit from this junction. NodeID of the exit is outgoingNode.
+ // There's only one exit from this junction. This turn should be left.
+ // It may be kept later according to the result of the method KeepTurnByIngoingEdges().
if (possibleTurns.candidates.size() == 1)
return true;
@@ -55,15 +56,20 @@ bool KeepTurnByHighwayClass(CarDirection turn, TurnCandidates const & possibleTu
ASSERT(false, ("One of possible turns follows along an undefined HighwayClass."));
return true;
}
+ if (maxClassForPossibleTurns == ftypes::HighwayClass::Undefined)
+ return false; // Fake edges has HighwayClass::Undefined.
ftypes::HighwayClass const minClassForTheRoute =
static_cast<ftypes::HighwayClass>(min(static_cast<int>(turnInfo.m_ingoing.m_highwayClass),
static_cast<int>(turnInfo.m_outgoing.m_highwayClass)));
+
if (minClassForTheRoute == ftypes::HighwayClass::Error)
{
ASSERT(false, ("The route contains undefined HighwayClass."));
return false;
}
+ if (minClassForTheRoute == ftypes::HighwayClass::Undefined)
+ return false; // Fake edges has HighwayClass::Undefined.
int const kMaxHighwayClassDiffToKeepTheTurn = 2;
if (static_cast<int>(maxClassForPossibleTurns) - static_cast<int>(minClassForTheRoute) >=
@@ -660,13 +666,16 @@ size_t CheckUTurnOnRoute(TUnpackedPathSegments const & segments,
checkedSegment.m_isLink == masterSegment.m_isLink && !checkedSegment.m_onRoundabout)
{
auto const & path = masterSegment.m_path;
+ auto const & pointBeforeTurn = path[path.size() - 2];
+ auto const & turnPoint = path[path.size() - 1];
+ auto const & pointAfterTurn = checkedSegment.m_path[1];
// 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 (path[path.size() - 2] == checkedSegment.m_path[1])
+ if (pointBeforeTurn == pointAfterTurn && turnPoint != pointBeforeTurn)
{
turn.m_turn = CarDirection::UTurnLeft;
return 1;
@@ -680,11 +689,11 @@ size_t CheckUTurnOnRoute(TUnpackedPathSegments const & segments,
return 0;
// Avoid returning to the same edge after uturn somewere else.
- if (path[path.size() - 2] == checkedSegment.m_path[1])
+ if (pointBeforeTurn == pointAfterTurn)
return 0;
- m2::PointD const v1 = path[path.size() - 1].GetPoint() - path[path.size() - 2].GetPoint();
- m2::PointD const v2 = checkedSegment.m_path[1].GetPoint() - checkedSegment.m_path[0].GetPoint();
+ m2::PointD const v1 = turnPoint.GetPoint() - pointBeforeTurn.GetPoint();
+ m2::PointD const v2 = pointAfterTurn.GetPoint() - checkedSegment.m_path[0].GetPoint();
auto angle = ang::TwoVectorsAngle(m2::PointD::Zero(), v1, v2);