libosmscout 1.1.1
Loading...
Searching...
No Matches
SpeedAgent.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_NAVIGATION_SPEED_AGENT_H
2#define OSMSCOUT_NAVIGATION_SPEED_AGENT_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2019 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
26
27namespace osmscout {
28
29struct OSMSCOUT_API CurrentSpeedMessage CLASS_FINAL : public NavigationMessage
30{
31 double speed; // km/h
32
34 double speed);
35};
36
37struct OSMSCOUT_API MaxAllowedSpeedMessage CLASS_FINAL : public NavigationMessage
38{
39 double maxAllowedSpeed; // km/h
40 bool defined;
41
43 double maxAllowedSpeed,
44 bool defined);
45};
46
47class OSMSCOUT_API SpeedAgent CLASS_FINAL : public NavigationAgent
48{
49private:
50 struct TrackSegment
51 {
52 Distance distance;
53 Timestamp::duration duration{Timestamp::duration::zero()};
54
55 TrackSegment(const Distance &distance, const Timestamp::duration &duration):
56 distance(distance), duration(duration)
57 {}
58 };
59 std::list<TrackSegment> segmentFifo; // buffer of segments for 5 seconds used for speed computation
60
61 struct Position
62 {
63 GeoCoord coord;
65
66 explicit operator bool() const
67 {
68 return time.time_since_epoch()!=Timestamp::duration::zero();
69 }
70 };
71 Position lastPosition;
72
73 double lastReportedMaxSpeed{-1};
74
75public:
76 explicit SpeedAgent() = default;
77 std::list<NavigationMessageRef> Process(const NavigationMessageRef& message) override;
78};
79}
80
81#endif //OSMSCOUT_NAVIGATION_SPEED_AGENT_H
82
#define OSMSCOUT_API
Definition CoreImportExport.h:45
Definition Area.h:88
double speed
Definition SpeedAgent.h:31
bool defined
Definition SpeedAgent.h:40
double maxAllowedSpeed
Definition SpeedAgent.h:39
CurrentSpeedMessage(const Timestamp &timestamp, double speed)
std::list< NavigationMessageRef > Process(const NavigationMessageRef &message) override
MaxAllowedSpeedMessage(const Timestamp &timestamp, double maxAllowedSpeed, bool defined)
std::vector< VoiceSample > message
Definition VoiceInstructionAgent.h:99
Definition Engine.h:79
Definition Area.h:39
std::chrono::system_clock::time_point Timestamp
Definition Time.h:27
std::shared_ptr< NavigationMessage > NavigationMessageRef
Definition Engine.h:56
Timestamp time
Definition SpeedAgent.h:64
Definition Engine.h:49
const Timestamp timestamp
Definition Engine.h:50