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{
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
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
@ RoadEnd
Definition VoiceInstructionAgent.h:70
@ Depart
Definition VoiceInstructionAgent.h:46
@ RbExit1
Definition VoiceInstructionAgent.h:62
@ Distance500
Definition VoiceInstructionAgent.h:93
@ RbExit2
Definition VoiceInstructionAgent.h:63
@ AhUTurn
Definition VoiceInstructionAgent.h:42
@ AhRightTurn
Definition VoiceInstructionAgent.h:41
@ UTurn
Definition VoiceInstructionAgent.h:81
@ Distance300
Definition VoiceInstructionAgent.h:91
@ MwExitLeft
Definition VoiceInstructionAgent.h:57
@ TakeFerry
Definition VoiceInstructionAgent.h:76
@ TryUTurn
Definition VoiceInstructionAgent.h:78
@ AhExitRight
Definition VoiceInstructionAgent.h:36
@ RbExit5
Definition VoiceInstructionAgent.h:66
@ Distance400
Definition VoiceInstructionAgent.h:92
@ Distance80
Definition VoiceInstructionAgent.h:88
@ RbRight
Definition VoiceInstructionAgent.h:69
@ AhExitLeft
Definition VoiceInstructionAgent.h:34
@ BearRight
Definition VoiceInstructionAgent.h:45
@ SharpRight
Definition VoiceInstructionAgent.h:74
@ Distance100
Definition VoiceInstructionAgent.h:89
@ TurnRight
Definition VoiceInstructionAgent.h:80
@ AhLeftTurn
Definition VoiceInstructionAgent.h:40
@ Charge
Definition VoiceInstructionAgent.h:49
@ Take2ndRight
Definition VoiceInstructionAgent.h:84
@ GpsLost
Definition VoiceInstructionAgent.h:48
@ LnLeft
Definition VoiceInstructionAgent.h:52
@ AhKeepLeft
Definition VoiceInstructionAgent.h:38
@ KeepRight
Definition VoiceInstructionAgent.h:51
@ Take2ndLeft
Definition VoiceInstructionAgent.h:83
@ After
Definition VoiceInstructionAgent.h:33
@ RbExit6
Definition VoiceInstructionAgent.h:67
@ Marble
Definition VoiceInstructionAgent.h:54
@ LnRight
Definition VoiceInstructionAgent.h:53
@ Meters
Definition VoiceInstructionAgent.h:55
@ TurnLeft
Definition VoiceInstructionAgent.h:79
@ RbExit4
Definition VoiceInstructionAgent.h:65
@ Yards
Definition VoiceInstructionAgent.h:82
@ RbBack
Definition VoiceInstructionAgent.h:60
@ SharpLeft
Definition VoiceInstructionAgent.h:73
@ KeepLeft
Definition VoiceInstructionAgent.h:50
@ RbExit3
Definition VoiceInstructionAgent.h:64
@ Take3rdRight
Definition VoiceInstructionAgent.h:86
@ Straight
Definition VoiceInstructionAgent.h:75
@ GpsFound
Definition VoiceInstructionAgent.h:47
@ RbCross
Definition VoiceInstructionAgent.h:61
@ Distance800
Definition VoiceInstructionAgent.h:96
@ BearLeft
Definition VoiceInstructionAgent.h:44
@ Distance600
Definition VoiceInstructionAgent.h:94
@ Distance200
Definition VoiceInstructionAgent.h:90
@ MwEnter
Definition VoiceInstructionAgent.h:56
@ RouteDeviated
Definition VoiceInstructionAgent.h:72
@ Then
Definition VoiceInstructionAgent.h:77
@ MwExitRight
Definition VoiceInstructionAgent.h:59
@ Distance50
Definition VoiceInstructionAgent.h:87
@ AhExit
Definition VoiceInstructionAgent.h:35
@ AhKeepRight
Definition VoiceInstructionAgent.h:39
@ RouteCalculated
Definition VoiceInstructionAgent.h:71
@ Arrive
Definition VoiceInstructionAgent.h:43
@ RbLeft
Definition VoiceInstructionAgent.h:68
@ Take3rdLeft
Definition VoiceInstructionAgent.h:85
@ AhFerry
Definition VoiceInstructionAgent.h:37
@ MwExit
Definition VoiceInstructionAgent.h:58
@ Distance700
Definition VoiceInstructionAgent.h:95
std::list< NavigationMessageRef > Process(const NavigationMessageRef &message) override
~VoiceInstructionAgent() override=default
MessageType
Definition VoiceInstructionAgent.h:121
@ LeaveMotorway
Definition VoiceInstructionAgent.h:139
@ LeaveRbExit2
Definition VoiceInstructionAgent.h:125
@ Silent
Definition VoiceInstructionAgent.h:143
@ LeaveRbExit5
Definition VoiceInstructionAgent.h:128
@ LeaveRbExit1
Definition VoiceInstructionAgent.h:124
@ LeaveMotorwayRight
Definition VoiceInstructionAgent.h:140
@ LeaveMotorwayLeft
Definition VoiceInstructionAgent.h:141
@ LeaveRbExit3
Definition VoiceInstructionAgent.h:126
@ LeaveRbExit4
Definition VoiceInstructionAgent.h:127
@ LeaveRbExit6
Definition VoiceInstructionAgent.h:129
@ TargetReached
Definition VoiceInstructionAgent.h:131
@ NoMessage
Definition VoiceInstructionAgent.h:122
@ StraightOn
Definition VoiceInstructionAgent.h:135
std::vector< VoiceSample > message
Definition VoiceInstructionAgent.h:99
Definition Area.h:39
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