blob: 45a38bcde78c380be7bf9109754dd54dae015ff7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#pragma once
#include "../std/string.hpp"
#include "../std/vector.hpp"
#include <boost/function.hpp>
namespace location
{
/// after this period we cont position as "too old"
static double const POSITION_TIMEOUT_SECONDS = 300.0;
enum TLocationStatus
{
ENotSupported, //!< GpsInfo fields are not valid with this value
EDisabledByUser, //!< GpsInfo fields are not valid with this value
EAccurateMode,
ERoughMode //!< in this mode compass is turned off
};
/// @note always check m_status before using this structure
class GpsInfo
{
public:
TLocationStatus m_status;
double m_timestamp; //!< how many seconds ago the position was retrieved
double m_latitude; //!< degrees
double m_longitude; //!< degrees
double m_horizontalAccuracy; //!< metres
double m_altitude; //!< metres
double m_verticalAccuracy; //!< metres
double m_course; //!< positive degrees from the true North
double m_speed; //!< metres per second
};
/// @note always check m_status before using this structure
class CompassInfo
{
public:
double m_timestamp; //!< how many seconds ago the heading was retrieved
double m_magneticHeading; //!< positive degrees from the magnetic North
double m_trueHeading; //!< positive degrees from the true North
double m_accuracy; //!< offset from magnetic to true North
int m_x;
int m_y;
int m_z;
};
typedef boost::function<void (GpsInfo const &)> TGpsCallback;
typedef boost::function<void (CompassInfo const &)> TCompassCallback;
class LocationService
{
TGpsCallback m_gpsObserver;
TCompassCallback m_compassObserver;
protected:
void NotifyGpsObserver(GpsInfo const & info)
{
if (m_gpsObserver)
m_gpsObserver(info);
}
void NotifyCompassObserver(CompassInfo const & info)
{
if (m_compassObserver)
m_compassObserver(info);
}
public:
void SetGpsObserver(TGpsCallback observer)
{
m_gpsObserver = observer;
}
void SetCompassObserver(TCompassCallback observer)
{
m_compassObserver = observer;
}
/// to change active accuracy mode just call it again
/// @note also enables compass if it's available
virtual void StartUpdate(bool useAccurateMode) = 0;
virtual void StopUpdate() = 0;
};
}
extern "C" location::LocationService & GetLocationService();
|