forked from mer-hybris/geoclue-providers-hybris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocationtypes.h
143 lines (120 loc) · 4.39 KB
/
locationtypes.h
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
Copyright (C) 2015 Jolla Ltd.
Contact: Aaron McCarthy <[email protected]>
This file is part of geoclue-hybris.
Geoclue-hybris is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License.
*/
#ifndef LOCATIONTYPES_H
#define LOCATIONTYPES_H
#include <QtCore/QtNumeric>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QMetaType>
class AccuracyData : public QSharedData
{
public:
AccuracyData() : horizontal(qQNaN()), vertical(qQNaN()) { }
AccuracyData(const AccuracyData &other)
: QSharedData(other), horizontal(other.horizontal), vertical(other.vertical)
{ }
~AccuracyData() { }
double horizontal;
double vertical;
};
class Accuracy
{
public:
Accuracy() : d(new AccuracyData) { }
Accuracy(const Accuracy &other) : d(other.d) { }
inline double horizontal() const { return d->horizontal; }
inline void setHorizontal(double accuracy) { d->horizontal = accuracy; }
inline double vertical() const { return d->vertical; }
inline void setVertical(double accuracy) { d->vertical = accuracy; }
private:
QSharedDataPointer<AccuracyData> d;
};
class LocationData : public QSharedData
{
public:
LocationData()
: timestamp(0), latitude(qQNaN()), longitude(qQNaN()), altitude(qQNaN()), speed(qQNaN()),
direction(qQNaN()), climb(qQNaN())
{ }
LocationData(const LocationData &other)
: QSharedData(other), timestamp(other.timestamp), latitude(other.latitude),
longitude(other.longitude), altitude(other.altitude), speed(other.speed),
direction(other.direction), climb(other.climb), accuracy(other.accuracy)
{ }
~LocationData() { }
qint64 timestamp;
double latitude;
double longitude;
double altitude;
double speed;
double direction;
double climb;
Accuracy accuracy;
};
class Location
{
public:
Location() : d(new LocationData) { }
Location(const Location &other) : d(other.d) { }
inline qint64 timestamp() const { return d->timestamp; }
inline void setTimestamp(qint64 timestamp) { d->timestamp = timestamp; }
inline double latitude() const { return d->latitude; }
inline void setLatitude(double latitude) { d->latitude = latitude; }
inline double longitude() const { return d->longitude; }
inline void setLongitude(double longitude) { d->longitude = longitude; }
inline double altitude() const { return d->altitude; }
inline void setAltitude(double altitude) { d->altitude = altitude; }
inline double speed() const { return d->speed; }
inline void setSpeed(double speed) { d->speed = speed; }
inline double direction() const { return d->direction; }
inline void setDirection(double direction) { d->direction = direction; }
inline double climb() const { return d->climb; }
inline void setClimb(double climb) { d->climb = climb; }
inline Accuracy accuracy() const { return d->accuracy; }
inline void setAccuracy(const Accuracy &accuracy) { d->accuracy = accuracy; }
private:
QSharedDataPointer<LocationData> d;
};
class SatelliteInfoData : public QSharedData
{
public:
SatelliteInfoData()
: prn(0), elevation(0), azimuth(0), snr(0)
{ }
SatelliteInfoData(const SatelliteInfoData &other)
: QSharedData(other), prn(other.prn), elevation(other.elevation), azimuth(other.azimuth),
snr(other.snr)
{ }
~SatelliteInfoData() { }
int prn; // Item 0
int elevation; // Item 1
int azimuth; // Item 2
int snr; // Item 3
};
class SatelliteInfo
{
public:
SatelliteInfo() : d(new SatelliteInfoData) { }
SatelliteInfo(const SatelliteInfo &other) : d(other.d) { }
inline int prn() const { return d->prn; }
inline void setPrn(int prn) { d->prn = prn; }
inline int elevation() const { return d->elevation; }
inline void setElevation(int elevation) { d->elevation = elevation; }
inline int azimuth() const { return d->azimuth; }
inline void setAzimuth(int azimuth) { d->azimuth = azimuth; }
inline int snr() const { return d->snr; }
inline void setSnr(int snr) { d->snr = snr; }
private:
QSharedDataPointer<SatelliteInfoData> d;
};
Q_DECLARE_METATYPE(Accuracy)
Q_DECLARE_METATYPE(Location)
Q_DECLARE_METATYPE(SatelliteInfo)
Q_DECLARE_METATYPE(QList<SatelliteInfo>)
#endif // LOCATIONTYPES_H