forked from mer-hybris/geoclue-providers-mlsdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
locationtypes.h
104 lines (86 loc) · 3.19 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
/*
Copyright (C) 2016 Jolla Ltd.
Contact: Chris Adams <[email protected]>
This file is part of geoclue-mlsdb.
geoclue-mlsdb 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)
{ }
~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;
};
Q_DECLARE_METATYPE(Accuracy)
Q_DECLARE_METATYPE(Location)
#endif // LOCATIONTYPES_H