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>2015-09-10 10:42:26 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 03:04:27 +0300
commitd5dfe3d8cf20edc9ecadf21da1d19a2c9ab78bad (patch)
treea91d018632f8311394d21ee656418f2013b4bfcb /routing
parent947665eb78d2451679f5a9761e63026e3e00239b (diff)
Displaying information about the turn after the next one only in some cases.
Diffstat (limited to 'routing')
-rw-r--r--routing/route.cpp21
-rw-r--r--routing/route.hpp4
-rw-r--r--routing/routing_session.cpp21
-rw-r--r--routing/routing_tests/route_tests.cpp8
4 files changed, 39 insertions, 15 deletions
diff --git a/routing/route.cpp b/routing/route.cpp
index 5467603c24..176d183ce2 100644
--- a/routing/route.cpp
+++ b/routing/route.cpp
@@ -165,14 +165,23 @@ void Route::GetCurrentTurn(double & distanceToTurnMeters, turns::TurnItem & turn
m_poly.GetIterToIndex(segIdx));
}
-void Route::GetNextTurn(turns::TurnItem & turn) const
+void Route::GetNextTurn(double & distanceToTurnMeters, turns::TurnItem & turn) const
{
auto it = GetCurrentTurn();
- if (it != m_turns.end())
- ++it;
- else
- ASSERT(it != m_turns.end(), ());
- turn = it != m_turns.end() ? *it : turns::TurnItem();
+ auto const turnsEnd = m_turns.end();
+ ASSERT(it != turnsEnd, ());
+
+ if (it == turnsEnd || (it + 1) == turnsEnd)
+ {
+ turn = turns::TurnItem();
+ distanceToTurnMeters = 0;
+ return;
+ }
+
+ it += 1;
+ turn = *it;
+ distanceToTurnMeters = m_poly.GetDistanceM(m_poly.GetCurrentIter(),
+ m_poly.GetIterToIndex(it->m_index));
}
void Route::GetCurrentDirectionPoint(m2::PointD & pt) const
diff --git a/routing/route.hpp b/routing/route.hpp
index 138470d35e..5fb780c7eb 100644
--- a/routing/route.hpp
+++ b/routing/route.hpp
@@ -74,7 +74,9 @@ public:
void GetCurrentTurn(double & distanceToTurnMeters, turns::TurnItem & turn) const;
/// Returns turn after current.
- void GetNextTurn(turns::TurnItem & turn) const;
+ /// Fills the field distanceToTurnMeters with distance for current possition to
+ /// the turn after the next turn.
+ void GetNextTurn(double & distanceToTurnMeters, turns::TurnItem & turn) const;
void GetCurrentDirectionPoint(m2::PointD & pt) const;
diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp
index aaaa362940..421ef34190 100644
--- a/routing/routing_session.cpp
+++ b/routing/routing_session.cpp
@@ -17,8 +17,16 @@ namespace
int constexpr kOnRouteMissedCount = 5;
-// @todo(vbykoianko) The distance should depend on the current speed.
+// @TODO(vbykoianko) The distance should depend on the current speed.
double constexpr kShowLanesDistInMeters = 500.;
+// @TODO(vbykoianko) The distance should depend on the current speed.
+// The distance before the next turn in meters when notification
+// about the turn after the next one will be shown if available.
+double constexpr kShowTheTurnAfterTheNexetM = 500.;
+// If the distance between two sequential turns is more than kMaxTurnDistM
+// the information about the second turn will be shown when the user is
+// nearing to the first one.
+double constexpr kMaxTurnDistM = 50.;
// @todo(kshalnev) The distance may depend on the current speed.
double constexpr kShowPedestrianTurnInMeters = 5.;
@@ -200,15 +208,20 @@ void RoutingSession::GetRouteFollowingInfo(FollowingInfo & info) const
{
formatDistFn(m_route.GetCurrentDistanceToEndMeters(), info.m_distToTarget, info.m_targetUnitsSuffix);
- double distanceToTurnMeters = 0.;
+ double distanceToTurnMeters = 0., distanceToNextTurnMeters = 0.;
turns::TurnItem turn;
turns::TurnItem nextTurn;
m_route.GetCurrentTurn(distanceToTurnMeters, turn);
- m_route.GetNextTurn(nextTurn);
+ m_route.GetNextTurn(distanceToNextTurnMeters, nextTurn);
+ double const distBetweenTurnsM = distanceToNextTurnMeters - distanceToTurnMeters;
+ ASSERT_LESS_OR_EQUAL(0, distBetweenTurnsM, ());
formatDistFn(distanceToTurnMeters, info.m_distToTurn, info.m_turnUnitsSuffix);
info.m_turn = turn.m_turn;
- info.m_nextTurn = nextTurn.m_turn;
+ if (distanceToTurnMeters < kShowTheTurnAfterTheNexetM && distBetweenTurnsM < kMaxTurnDistM)
+ info.m_nextTurn = nextTurn.m_turn;
+ else
+ info.m_nextTurn = routing::turns::TurnDirection::NoTurn;
info.m_exitNum = turn.m_exitNum;
info.m_time = m_route.GetCurrentTimeToEndSec();
info.m_sourceName = turn.m_sourceName;
diff --git a/routing/routing_tests/route_tests.cpp b/routing/routing_tests/route_tests.cpp
index 317fb085ff..20763bf9d0 100644
--- a/routing/routing_tests/route_tests.cpp
+++ b/routing/routing_tests/route_tests.cpp
@@ -86,24 +86,24 @@ UNIT_TEST(NextTurnTest)
vector<turns::TurnItem> turns(kTestTurns);
route.SetTurnInstructions(turns);
- double distance;
+ double distance, nextDistance;
turns::TurnItem turn;
turns::TurnItem nextTurn;
route.GetCurrentTurn(distance, turn);
- route.GetNextTurn(nextTurn);
+ route.GetNextTurn(nextDistance, nextTurn);
TEST_EQUAL(turn, kTestTurns[0], ());
TEST_EQUAL(nextTurn, kTestTurns[1], ());
route.MoveIterator(GetGps(0.5, 1));
route.GetCurrentTurn(distance, turn);
- route.GetNextTurn(nextTurn);
+ route.GetNextTurn(nextDistance, nextTurn);
TEST_EQUAL(turn, kTestTurns[1], ());
TEST_EQUAL(nextTurn, kTestTurns[2], ());
route.MoveIterator(GetGps(1, 1.5));
route.GetCurrentTurn(distance, turn);
- route.GetNextTurn(nextTurn);
+ route.GetNextTurn(nextDistance, nextTurn);
TEST_EQUAL(turn, kTestTurns[2], ());
TEST_EQUAL(nextTurn, turns::TurnItem(), ());
}