-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcgps.cpp
More file actions
63 lines (55 loc) · 1.85 KB
/
Copy pathcgps.cpp
File metadata and controls
63 lines (55 loc) · 1.85 KB
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
#include "cgps.h"
#include <QDebug>
#include <QTime>
#include "trackpoint.h"
#include "tracklist.h"
CGps::CGps(QString filename) {
loaded = false;
fn = filename;
}
int CGps::parsefile() {
return -1;
}
int CGps::getTZ(QString lat, QString lon, QDateTime ts) {
Q_UNUSED(lat);
Q_UNUSED(lon);
Q_UNUSED(ts);
//Example http://api.geonames.org/timezone?lat=47.01&lng=10.2&username=demo
//or http://api.geonames.org/timezoneJSON?lat=47.01&lng=10.2&username=demo
// QString querystring=
return 0;
}
void CGps::convertTZ(QDateTime *ts, bool localtz, int tzdata, int offset) {
if (localtz) {
ts->setTimeSpec(Qt::LocalTime); // mark the timestamp as LocalTime (but don't convert it)
*ts = ts->toUTC();
ts->setTimeSpec(Qt::UTC);
} else {
ts->setTimeSpec(Qt::UTC); // mark it as UTC
*ts = ts->addSecs(-3600 * tzdata);
}
*ts = ts->addSecs(offset);
}
void CGps::addElement(double lat, double lon, double elevation, QDateTime time, TrackPoint::TP_TYPE type,
QString name) {
// qDebug() << "pointTime:" << time;
time.setTimeSpec(Qt::UTC);
TrackPoint loc(time, lat, lon, elevation, type, name);
int a = 0, b = this->size() - 1;
if (this->binarySearch(time, a, b)) {
this->insert(b, loc);
} else {
this->append(loc);
}
}
CGps::ParseResult CGps::searchElement(QDateTime timestamp, bool localTZ, int tzData, int offset) {
convertTZ(×tamp, localTZ, tzData, offset);
position = this->search(timestamp);
// qDebug() << "photoTime:" << timestamp << " positionTime:" << position.time << " TYPE:" << position.type;
if (position.type != TrackPoint::INVALID) {
return CGps::OK;
} else {
position.time = timestamp; // used for user info
return CGps::Outside;
}
}