-
Notifications
You must be signed in to change notification settings - Fork 0
/
positionsourcesimulator.cpp
81 lines (63 loc) · 2.1 KB
/
positionsourcesimulator.cpp
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
#include"positionsourcesimulator.h"
#include "Point.h"
#include "Location.h"
using namespace Esri::ArcGISRuntime;
PositionSourceSimulator::PositionSourceSimulator(ZmqReciever* zmqReciever, QObject* parent) :
QGeoPositionInfoSource(parent)
{
setUpdateInterval(500);
m_currentPosition.setCoordinate(QGeoCoordinate(52.920905, 4.862173));
emit positionUpdated(m_currentPosition);
m_zmqReciever = zmqReciever;
QObject::connect( zmqReciever, &ZmqReciever::gpsPositionChanged,
this, &PositionSourceSimulator::updateFromZmq
);
}
PositionSourceSimulator::~PositionSourceSimulator()
{}
void PositionSourceSimulator::startUpdates()
{
if(m_started)
return;
m_started = true;
//TODO: start communication with bridge
}
void PositionSourceSimulator::stopUpdates()
{
if(!m_started)
return;
m_started = false;
//TODO: stop communication with bridge
}
void PositionSourceSimulator::requestUpdate(int timeout)
{
Q_UNIMPLEMENTED();
}
QGeoPositionInfo PositionSourceSimulator::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
{
Q_UNUSED(fromSatellitePositioningMethodsOnly);
return m_currentPosition;
}
QGeoPositionInfoSource::PositioningMethods PositionSourceSimulator::supportedPositioningMethods() const
{
return QGeoPositionInfoSource::PositioningMethod::NoPositioningMethods;
}
int PositionSourceSimulator::minimumUpdateInterval() const
{
return updateInterval();
}
QGeoPositionInfoSource::Error PositionSourceSimulator::error() const
{
return m_lastError;
}
void PositionSourceSimulator::updateFromZmq(QVector< double> newLocation){
double lat = newLocation[0];
double lon = newLocation[1];
// double heading = newLocation[5];
Point point(lat, lon, SpatialReference::wgs84());
Location location(point, 10,10,10,10); //random values
m_currentPosition.setCoordinate(QGeoCoordinate(lat,lon));
// m_currentPosition.setAttribute(QGeoPositionInfo::Direction, heading);
emit positionUpdated(m_currentPosition);
//qDebug() << "called this here form Position source";
}