libosmscout 1.1.1
Loading...
Searching...
No Matches
VoiceInstructionAgent.h
Go to the documentation of this file.
1#ifndef LIBOSMSCOUT_VOICEINSTRUCTIONAGENT_H
2#define LIBOSMSCOUT_VOICEINSTRUCTIONAGENT_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2020 Lukas Karas
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
27
28namespace osmscout {
29
30struct OSMSCOUT_API VoiceInstructionMessage CLASS_FINAL : public NavigationMessage
31{
32 enum class VoiceSample {
33 After,
34 AhExitLeft,
35 AhExit,
36 AhExitRight,
37 AhFerry,
38 AhKeepLeft,
39 AhKeepRight,
40 AhLeftTurn,
41 AhRightTurn,
42 AhUTurn,
43 Arrive,
44 BearLeft,
45 BearRight,
46 Depart,
47 GpsFound,
48 GpsLost,
49 Charge,
50 KeepLeft,
51 KeepRight,
52 LnLeft,
53 LnRight,
54 Marble,
56 MwEnter,
57 MwExitLeft,
58 MwExit,
59 MwExitRight,
60 RbBack,
61 RbCross,
62 RbExit1,
63 RbExit2,
64 RbExit3,
65 RbExit4,
66 RbExit5,
67 RbExit6,
68 RbLeft,
69 RbRight,
70 RoadEnd,
71 RouteCalculated,
72 RouteDeviated,
75 Straight,
76 TakeFerry,
77 Then,
78 TryUTurn,
79 TurnLeft,
80 TurnRight,
81 UTurn,
82 Yards,
83 Take2ndLeft,
84 Take2ndRight,
85 Take3rdLeft,
86 Take3rdRight,
87 Distance50,
88 Distance80,
89 Distance100,
90 Distance200,
91 Distance300,
92 Distance400,
93 Distance500,
94 Distance600,
95 Distance700,
96 Distance800,
97 };
98
99 std::vector<VoiceSample> message;
100
101 inline VoiceInstructionMessage(const Timestamp& timestamp, std::vector<VoiceSample> &&message):
103 {}
104};
105
117class OSMSCOUT_API VoiceInstructionAgent CLASS_FINAL : public NavigationAgent
118{
119public:
120
121 enum class MessageType: int {
122 NoMessage = 0,
123
124 LeaveRbExit1,
125 LeaveRbExit2,
126 LeaveRbExit3,
127 LeaveRbExit4,
128 LeaveRbExit5,
129 LeaveRbExit6,
130
131 TargetReached,
132
134 TurnLeft,
135 StraightOn,
136 TurnRight,
138
139 LeaveMotorway,
140 LeaveMotorwayRight,
141 LeaveMotorwayLeft,
142
143 Silent
144 };
145
148 Distance distance;
149
150 MessageStruct() = default;
151 MessageStruct(const MessageStruct&) = default;
153
156
157 ~MessageStruct() = default;
158
161
162 explicit operator bool() const
163 {
165 }
166
167 bool operator==(const MessageStruct &other) const
168 {
169 return type==other.type && distance==other.distance;
170 }
171
172 bool operator!=(const MessageStruct &other) const
173 {
174 return !(*this==other);
175 }
176 };
177
178private:
180 Vehicle vehicle{vehicleCar};
181
182 // state used for triggering GpsFound / GpsLost messages
183 bool prevGpsSignal{true};
184 Timestamp lastSeenGpsSignal{Timestamp::min()};
185
186 MessageStruct lastMessage;
187 Distance lastMessagePosition; // where we trigger last message (it is before lastMessage.disntace usually)
188
189public:
191 units{units}
192 {};
193
194 ~VoiceInstructionAgent() override = default;
195
196 std::list<NavigationMessageRef> Process(const NavigationMessageRef& message) override;
197
198private:
199 void toSamples(std::vector<VoiceInstructionMessage::VoiceSample> &samples,
200 const MessageType &messageType,
201 bool shortRoundaboutMessage);
202
203 std::vector<VoiceInstructionMessage::VoiceSample> toSamples(const Distance &distanceFromStart,
204 const MessageStruct &message,
205 const MessageStruct &then);
206};
207}
208
209#endif //LIBOSMSCOUT_VOICEINSTRUCTIONAGENT_H
#define CLASS_FINAL
Definition Compiler.h:26
#define OSMSCOUT_API
Definition CoreImportExport.h:45
Definition Area.h:88
VoiceInstructionAgent(DistanceUnitSystem units)
Definition VoiceInstructionAgent.h:190
VoiceInstructionMessage(const Timestamp &timestamp, std::vector< VoiceSample > &&message)
Definition VoiceInstructionAgent.h:101
VoiceSample
Definition VoiceInstructionAgent.h:32
std::list< NavigationMessageRef > Process(const NavigationMessageRef &message) override
~VoiceInstructionAgent() override=default
MessageType
Definition VoiceInstructionAgent.h:121
@ NoMessage
Definition VoiceInstructionAgent.h:122
std::vector< VoiceSample > message
Definition VoiceInstructionAgent.h:99
@ SharpRight
Definition LaneTurn.h:64
@ SharpLeft
Definition LaneTurn.h:53
Definition Area.h:39
Distance Meters(double m)
Definition Distance.h:358
std::chrono::system_clock::time_point Timestamp
Definition Time.h:27
DistanceUnitSystem
Definition Distance.h:36
@ Metrics
Definition Distance.h:37
std::shared_ptr< NavigationMessage > NavigationMessageRef
Definition Engine.h:56
Definition VoiceInstructionAgent.h:146
Distance distance
Definition VoiceInstructionAgent.h:148
bool operator!=(const MessageStruct &other) const
Definition VoiceInstructionAgent.h:172
MessageStruct & operator=(MessageStruct &&)=default
MessageStruct(const MessageStruct &)=default
MessageType type
Definition VoiceInstructionAgent.h:147
bool operator==(const MessageStruct &other) const
Definition VoiceInstructionAgent.h:167
MessageStruct(MessageType type, const Distance &distance)
Definition VoiceInstructionAgent.h:154
MessageStruct & operator=(const MessageStruct &)=default
MessageStruct(MessageStruct &&)=default
Definition Engine.h:49
NavigationMessage(const Timestamp &timestamp)
const Timestamp timestamp
Definition Engine.h:50