libosmscout
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
libosmscout
include
osmscout
navigation
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
23
#include <
osmscout/navigation/Engine.h
>
24
#include <
osmscout/navigation/Agents.h
>
25
#include <
osmscout/navigation/PositionAgent.h
>
26
27
namespace
osmscout
{
28
29
struct
OSMSCOUT_API
CurrentSpeedMessage
CLASS_FINAL
:
public
NavigationMessage
30
{
31
double
speed
;
// km/h
32
33
CurrentSpeedMessage
(
const
Timestamp
&
timestamp
,
34
double
speed
);
35
};
36
37
struct
OSMSCOUT_API
MaxAllowedSpeedMessage
CLASS_FINAL
:
public
NavigationMessage
38
{
39
double
maxAllowedSpeed
;
// km/h
40
bool
defined
;
41
42
MaxAllowedSpeedMessage
(
const
Timestamp
&
timestamp
,
43
double
maxAllowedSpeed
,
44
bool
defined
);
45
};
46
47
class
OSMSCOUT_API
SpeedAgent
CLASS_FINAL
:
public
NavigationAgent
48
{
49
private
:
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;
64
Timestamp
time
;
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
75
public
:
76
explicit
SpeedAgent
() =
default
;
77
std::list<NavigationMessageRef>
Process
(
const
NavigationMessageRef
&
message
)
override
;
78
};
79
}
80
81
#endif
//OSMSCOUT_NAVIGATION_SPEED_AGENT_H
82
Agents.h
OSMSCOUT_API
#define OSMSCOUT_API
Definition
CoreImportExport.h:45
Engine.h
PositionAgent.h
osmscout::CLASS_FINAL
Definition
Area.h:88
osmscout::CLASS_FINAL::speed
double speed
Definition
SpeedAgent.h:31
osmscout::CLASS_FINAL::defined
bool defined
Definition
SpeedAgent.h:40
osmscout::CLASS_FINAL::maxAllowedSpeed
double maxAllowedSpeed
Definition
SpeedAgent.h:39
osmscout::CLASS_FINAL::CurrentSpeedMessage
CurrentSpeedMessage(const Timestamp ×tamp, double speed)
osmscout::CLASS_FINAL::Process
std::list< NavigationMessageRef > Process(const NavigationMessageRef &message) override
osmscout::CLASS_FINAL::MaxAllowedSpeedMessage
MaxAllowedSpeedMessage(const Timestamp ×tamp, double maxAllowedSpeed, bool defined)
osmscout::CLASS_FINAL::SpeedAgent
SpeedAgent()=default
osmscout::CLASS_FINAL::message
std::vector< VoiceSample > message
Definition
VoiceInstructionAgent.h:99
osmscout::NavigationAgent
Definition
Engine.h:79
osmscout
Definition
Area.h:39
osmscout::Timestamp
std::chrono::system_clock::time_point Timestamp
Definition
Time.h:27
osmscout::NavigationMessageRef
std::shared_ptr< NavigationMessage > NavigationMessageRef
Definition
Engine.h:56
osmscout::CLASS_FINAL::Position::time
Timestamp time
Definition
SpeedAgent.h:64
osmscout::NavigationMessage
Definition
Engine.h:49
osmscout::NavigationMessage::timestamp
const Timestamp timestamp
Definition
Engine.h:50
Generated by
1.17.0