From 558512d4eed7c94262299e12d2c7929ae0192465 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Mon, 12 Oct 2015 16:04:05 +0300 Subject: [PATCH 1/3] Pronouncing different notifications when an end user is nearing to the route finish and when he has arrived to the finish. --- routing/turns_tts_text.cpp | 15 ++++++++++++++- routing/turns_tts_text.hpp | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/routing/turns_tts_text.cpp b/routing/turns_tts_text.cpp index 25caeabd75..6493131733 100644 --- a/routing/turns_tts_text.cpp +++ b/routing/turns_tts_text.cpp @@ -124,6 +124,19 @@ string GetRoundaboutTextId(Notification const & notification) return "take_the_" + strings::to_string(static_cast(notification.m_exitNum)) + "th_exit"; } +string GetYouArriveTextId(Notification const & notification) +{ + if (notification.m_turnDir != TurnDirection::ReachedYourDestination) + { + ASSERT(false, ()); + return string(); + } + + if (notification.m_distanceUnits != 0 || notification.m_useThenInsteadOfDistance) + return "destination"; + return "you_have_reached_the_destination"; +} + string GetDirectionTextId(Notification const & notification) { switch (notification.m_turnDir) @@ -149,7 +162,7 @@ string GetDirectionTextId(Notification const & notification) case TurnDirection::LeaveRoundAbout: return GetRoundaboutTextId(notification); case TurnDirection::ReachedYourDestination: - return "you_have_reached_the_destination"; + return GetYouArriveTextId(notification); case TurnDirection::StayOnRoundAbout: case TurnDirection::StartAtEndOfStreet: case TurnDirection::TakeTheExit: diff --git a/routing/turns_tts_text.hpp b/routing/turns_tts_text.hpp index 43390e7463..bb6166e390 100644 --- a/routing/turns_tts_text.hpp +++ b/routing/turns_tts_text.hpp @@ -39,6 +39,9 @@ string GetDistanceTextId(Notification const & notification); /// Generates text message id for roundabouts. /// For example: leave_the_roundabout or take_the_3rd_exit string GetRoundaboutTextId(Notification const & notification); +/// Generates text message id for the finish of the route. +/// For example: destination or you_have_reached_the_destination +string GetYouArriveTextId(Notification const & notification); /// Generates text message id about the direction of the notification. For example: Make a right /// turn. string GetDirectionTextId(Notification const & notification); From 764c8f02f6422d8797ee59e0a098998c847596cc Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Mon, 12 Oct 2015 16:36:15 +0300 Subject: [PATCH 2/3] Adding unit tests on different expressions near the distination point. --- .../routing_tests/turns_tts_text_tests.cpp | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/routing/routing_tests/turns_tts_text_tests.cpp b/routing/routing_tests/turns_tts_text_tests.cpp index b566df4932..184a96a4e4 100644 --- a/routing/routing_tests/turns_tts_text_tests.cpp +++ b/routing/routing_tests/turns_tts_text_tests.cpp @@ -19,7 +19,7 @@ bool PairDistEquals(PairDist const & lhs, PairDist const & rhs) UNIT_TEST(GetDistanceTextIdMetersTest) { // Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance, - // TurnDirection turnDir, Settings::Units lengthUnits) + // TurnDirection turnDir, ::Settings::Units lengthUnits) Notification const notifiation1(500, 0, false, TurnDirection::TurnRight, ::Settings::Metric); TEST_EQUAL(GetDistanceTextId(notifiation1), "in_500_meters", ()); Notification const notifiation2(500, 0, true, TurnDirection::TurnRight, ::Settings::Metric); @@ -32,6 +32,8 @@ UNIT_TEST(GetDistanceTextIdMetersTest) UNIT_TEST(GetDistanceTextIdFeetTest) { + // Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance, + // TurnDirection turnDir, ::Settings::Units lengthUnits) Notification const notifiation1(500, 0, false, TurnDirection::TurnRight, ::Settings::Foot); TEST_EQUAL(GetDistanceTextId(notifiation1), "in_500_feet", ()); Notification const notifiation2(500, 0, true, TurnDirection::TurnRight, ::Settings::Foot); @@ -42,14 +44,46 @@ UNIT_TEST(GetDistanceTextIdFeetTest) TEST_EQUAL(GetDistanceTextId(notifiation4), "in_5000_feet", ()); } +UNIT_TEST(GetRoundaboutTextIdTest) +{ + // Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance, + // TurnDirection turnDir, ::Settings::Units lengthUnits) + Notification const notifiation1(500, 0, false, TurnDirection::LeaveRoundAbout, ::Settings::Foot); + TEST_EQUAL(GetRoundaboutTextId(notifiation1), "leave_the_roundabout", ()); + Notification const notifiation2(0, 3, true, TurnDirection::LeaveRoundAbout, ::Settings::Foot); + TEST_EQUAL(GetRoundaboutTextId(notifiation2), "take_the_3rd_exit", ()); + Notification const notifiation3(0, 7, true, TurnDirection::LeaveRoundAbout, ::Settings::Metric); + TEST_EQUAL(GetRoundaboutTextId(notifiation3), "take_the_7th_exit", ()); + Notification const notifiation4(0, 15, true, TurnDirection::LeaveRoundAbout, ::Settings::Metric); + TEST_EQUAL(GetRoundaboutTextId(notifiation4), "leave_the_roundabout", ()); +} + +UNIT_TEST(GetYouArriveTextIdTest) +{ + // Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance, + // TurnDirection turnDir, ::Settings::Units lengthUnits) + Notification const notifiation1(500, 0, false, TurnDirection::ReachedYourDestination, ::Settings::Foot); + TEST_EQUAL(GetYouArriveTextId(notifiation1), "destination", ()); + Notification const notifiation2(0, 0, false, TurnDirection::ReachedYourDestination, ::Settings::Metric); + TEST_EQUAL(GetYouArriveTextId(notifiation2), "you_have_reached_the_destination", ()); + Notification const notifiation3(0, 0, true, TurnDirection::ReachedYourDestination, ::Settings::Metric); + TEST_EQUAL(GetYouArriveTextId(notifiation3), "destination", ()); +} + UNIT_TEST(GetDirectionTextIdTest) { + // Notification(uint32_t distanceUnits, uint8_t exitNum, bool useThenInsteadOfDistance, + // TurnDirection turnDir, ::Settings::Units lengthUnits) Notification const notifiation1(500, 0, false, TurnDirection::TurnRight, ::Settings::Foot); TEST_EQUAL(GetDirectionTextId(notifiation1), "make_a_right_turn", ()); Notification const notifiation2(1000, 0, false, TurnDirection::GoStraight, ::Settings::Metric); TEST_EQUAL(GetDirectionTextId(notifiation2), "go_straight", ()); Notification const notifiation3(700, 0, false, TurnDirection::UTurn, ::Settings::Metric); TEST_EQUAL(GetDirectionTextId(notifiation3), "make_a_u_turn", ()); + Notification const notifiation4(200, 0, false, TurnDirection::ReachedYourDestination, ::Settings::Metric); + TEST_EQUAL(GetDirectionTextId(notifiation4), "destination", ()); + Notification const notifiation5(0, 0, false, TurnDirection::ReachedYourDestination, ::Settings::Metric); + TEST_EQUAL(GetDirectionTextId(notifiation5), "you_have_reached_the_destination", ()); } UNIT_TEST(GetTtsTextTest) From 5065fd878c1d54be07208e8c35c7ec95410025ef Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Mon, 12 Oct 2015 17:53:22 +0300 Subject: [PATCH 3/3] Corrections after colleagues comments. --- routing/turns_sound_settings.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routing/turns_sound_settings.hpp b/routing/turns_sound_settings.hpp index 6572243eb7..a2e1708ceb 100644 --- a/routing/turns_sound_settings.hpp +++ b/routing/turns_sound_settings.hpp @@ -76,8 +76,13 @@ public: /// notification to pronounce. struct Notification { + /// m_distanceUnits is a distance to the turn in m_lengthUnits (meters or feet). + /// If m_distanceUnits == 0 then the information about distance to the turn shall + /// not be pronounced. uint32_t m_distanceUnits; uint8_t m_exitNum; + /// if m_useThenInsteadOfDistance == true the m_distanceUnits is ignored. + /// The word "Then" shall be pronounced intead of the distance. bool m_useThenInsteadOfDistance; TurnDirection m_turnDir; ::Settings::Units m_lengthUnits;