-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathPositionSimulator.h
115 lines (91 loc) · 3.3 KB
/
PositionSimulator.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
#ifndef LIBOSMSCOUT_POSITIONSIMULATOR_H
#define LIBOSMSCOUT_POSITIONSIMULATOR_H
/*
OSMScout2 - demo application for libosmscout
Copyright (C) 2017 Lukas Karas
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <osmscoutgpx/GpxFile.h>
#include <QObject>
#include <QString>
#include <QTimer>
#include <QDateTime>
class PositionSimulator: public QObject {
Q_OBJECT
Q_PROPERTY(QString track READ getTrack WRITE setTrack)
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
Q_PROPERTY(QDateTime time READ getTime NOTIFY timeChanged)
Q_PROPERTY(double startLat READ getStartLat NOTIFY startChanged)
Q_PROPERTY(double startLon READ getStartLon NOTIFY startChanged)
Q_PROPERTY(double endLat READ getEndLat NOTIFY endChanged)
Q_PROPERTY(double endLon READ getEndLon NOTIFY endChanged)
Q_PROPERTY(double latitude READ getLat NOTIFY positionChanged)
Q_PROPERTY(double longitude READ getLon NOTIFY positionChanged)
private:
std::vector<osmscout::gpx::TrackSegment> segments;
QString trackFile;
bool running{false};
bool fileLoaded{false};
size_t currentSegment{0};
size_t currentPoint{0};
osmscout::GeoCoord currentPosition{osmscout::GeoCoord(0,0)};
QTimer timer;
osmscout::Timestamp simulationTime;
osmscout::gpx::TrackPoint segmentStart{osmscout::GeoCoord(0,0)};
osmscout::gpx::TrackPoint segmentEnd{osmscout::GeoCoord(0,0)};
signals:
void positionChanged(double latitude, double longitude,
bool horizontalAccuracyValid, double horizontalAccuracy,
bool altitudeValid, double altitude,
bool verticalAccuracyValid, double verticalAccuracy);
void runningChanged(bool);
void startChanged(double latitude, double longitude);
void endChanged(double latitude, double longitude);
void timeChanged(QDateTime);
private slots:
void tick();
public:
PositionSimulator();
virtual ~PositionSimulator() = default;
QString getTrack() const {
return trackFile;
}
void setTrack(const QString &t);
bool isRunning() const {
return running;
}
void setRunning(bool);
double getStartLat() const {
return segmentStart.coord.GetLat();
}
double getStartLon() const {
return segmentStart.coord.GetLon();
}
double getEndLat() const {
return segmentEnd.coord.GetLat();
}
double getEndLon() const {
return segmentEnd.coord.GetLon();
}
double getLat() const {
return currentPosition.GetLat();
}
double getLon() const {
return currentPosition.GetLon();
}
QDateTime getTime() const;
Q_INVOKABLE void skipTime(uint64_t millis);
private:
bool setSegment(size_t);
};
#endif //LIBOSMSCOUT_POSITIONSIMULATOR_H