-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathmonitor_pvt_wrapper.cpp
131 lines (117 loc) · 3.42 KB
/
monitor_pvt_wrapper.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
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
/*!
* \file monitor_pvt_wrapper.cpp
* \brief Implementation of a wrapper class for MonitorPvt objects.
*
* \author Álvaro Cebrián Juan, 2019. acebrianjuan(at)gmail.com
*
* -----------------------------------------------------------------------
*
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR 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 3 of the License, or
* (at your option) any later version.
*
* GNSS-SDR 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 GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
*
* -----------------------------------------------------------------------
*/
#include "monitor_pvt_wrapper.h"
#include <QDebug>
#include <QGeoCoordinate>
/*!
Constructs a MonitorPvtWrapper object.
*/
MonitorPvtWrapper::MonitorPvtWrapper(QObject *parent) : QObject(parent)
{
m_bufferSize = 100;
m_bufferMonitorPvt.resize(m_bufferSize);
m_bufferMonitorPvt.clear();
m_path.resize(m_bufferSize);
m_path.clear();
}
/*!
Populates the internal data structures with the data of the \a monitor_pvt MonitorPvt object.
*/
void MonitorPvtWrapper::addMonitorPvt(const gnss_sdr::MonitorPvt &monitor_pvt)
{
m_bufferMonitorPvt.push_back(monitor_pvt);
Coordinates coord;
coord.latitude = monitor_pvt.latitude();
coord.longitude = monitor_pvt.longitude();
m_path.push_back(coord);
emit dataChanged();
emit altitudeChanged(monitor_pvt.tow_at_current_symbol_ms(), monitor_pvt.height());
emit dopChanged(monitor_pvt.tow_at_current_symbol_ms(), monitor_pvt.gdop(), monitor_pvt.pdop(), monitor_pvt.hdop(), monitor_pvt.vdop());
}
/*!
Gets the last MonitorPvt object.
*/
gnss_sdr::MonitorPvt MonitorPvtWrapper::getLastMonitorPvt()
{
return m_bufferMonitorPvt.back();
}
/*!
Clears all the data from the internal data structures.
*/
void MonitorPvtWrapper::clearData()
{
m_bufferMonitorPvt.clear();
m_path.clear();
emit dataChanged();
}
/*!
Sets the size of the internal circular buffers that store the data.
*/
void MonitorPvtWrapper::setBufferSize(size_t size)
{
m_bufferSize = size;
m_bufferMonitorPvt.resize(m_bufferSize);
}
/*!
Returns the last known position.
*/
QVariant MonitorPvtWrapper::position() const
{
if (!m_bufferMonitorPvt.empty())
{
gnss_sdr::MonitorPvt mpvt = m_bufferMonitorPvt.back();
return QVariant::fromValue(QGeoCoordinate(mpvt.latitude(), mpvt.longitude()));
}
else
{
return QVariant();
}
}
/*!
Returns the path formed by the history of recorded positions.
*/
QVariantList MonitorPvtWrapper::path() const
{
if (!m_path.empty())
{
QVariantList list;
for (size_t i = 0; i < m_path.size(); i++)
{
Coordinates coord = m_path.at(i);
list << QVariant::fromValue(QGeoCoordinate(coord.latitude, coord.longitude));
}
return list;
}
else
{
return QVariantList();
}
}