1 | // Part of BNC, a utility for retrieving decoding and
|
---|
2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2007
|
---|
5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
6 | // http://www.bkg.bund.de
|
---|
7 | // Czech Technical University Prague, Department of Geodesy
|
---|
8 | // http://www.fsv.cvut.cz
|
---|
9 | //
|
---|
10 | // Email: euref-ip@bkg.bund.de
|
---|
11 | //
|
---|
12 | // This program is free software; you can redistribute it and/or
|
---|
13 | // modify it under the terms of the GNU General Public License
|
---|
14 | // as published by the Free Software Foundation, version 2.
|
---|
15 | //
|
---|
16 | // This program is distributed in the hope that it will be useful,
|
---|
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | // GNU General Public License for more details.
|
---|
20 | //
|
---|
21 | // You should have received a copy of the GNU General Public License
|
---|
22 | // along with this program; if not, write to the Free Software
|
---|
23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
24 |
|
---|
25 | /* -------------------------------------------------------------------------
|
---|
26 | * BKG NTRIP Client
|
---|
27 | * -------------------------------------------------------------------------
|
---|
28 | *
|
---|
29 | * Class: bncPPPclient
|
---|
30 | *
|
---|
31 | * Purpose: Precise Point Positioning
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 21-Nov-2009
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include <iomanip>
|
---|
42 | #include <newmatio.h>
|
---|
43 |
|
---|
44 | #include "bncpppclient.h"
|
---|
45 |
|
---|
46 | extern "C" {
|
---|
47 | #include "clock_orbit_rtcm.h"
|
---|
48 | }
|
---|
49 |
|
---|
50 | using namespace std;
|
---|
51 |
|
---|
52 | // Constructor
|
---|
53 | ////////////////////////////////////////////////////////////////////////////
|
---|
54 | bncPPPclient::bncPPPclient(QByteArray staID) {
|
---|
55 | _staID = staID;
|
---|
56 | _data = 0;
|
---|
57 | _dataHlp = 0;
|
---|
58 | }
|
---|
59 |
|
---|
60 | // Destructor
|
---|
61 | ////////////////////////////////////////////////////////////////////////////
|
---|
62 | bncPPPclient::~bncPPPclient() {
|
---|
63 | delete _data;
|
---|
64 | delete _dataHlp;
|
---|
65 | QMapIterator<QString, t_eph*> it(_eph);
|
---|
66 | while (it.hasNext()) {
|
---|
67 | it.next();
|
---|
68 | delete it.value();
|
---|
69 | }
|
---|
70 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
71 | while (ic.hasNext()) {
|
---|
72 | ic.next();
|
---|
73 | delete ic.value();
|
---|
74 | }
|
---|
75 | }
|
---|
76 |
|
---|
77 | //
|
---|
78 | ////////////////////////////////////////////////////////////////////////////
|
---|
79 | void bncPPPclient::putNewObs(p_obs pp) {
|
---|
80 | QMutexLocker locker(&_mutex);
|
---|
81 |
|
---|
82 | t_obsInternal* obs = &(pp->_o);
|
---|
83 |
|
---|
84 | t_time tt(obs->GPSWeek, obs->GPSWeeks);
|
---|
85 |
|
---|
86 | if (!_dataHlp) {
|
---|
87 | _dataHlp = new t_data();
|
---|
88 | _dataHlp->tt = tt;
|
---|
89 | }
|
---|
90 | else if (tt != _dataHlp->tt) {
|
---|
91 | _data = _dataHlp;
|
---|
92 | _dataHlp = new t_data();
|
---|
93 | _dataHlp->tt = tt;
|
---|
94 | processEpoch();
|
---|
95 | }
|
---|
96 |
|
---|
97 | ++_dataHlp->numSat;
|
---|
98 |
|
---|
99 | if (_dataHlp->numSat > t_data::MAXOBS) {
|
---|
100 | cerr << "putNewObs: numSat > MAXOBS\n";
|
---|
101 | exit(1);
|
---|
102 | }
|
---|
103 |
|
---|
104 | _dataHlp->prn[_dataHlp->numSat] =
|
---|
105 | QString("%1%2").arg(obs->satSys).arg(obs->satNum, 2, 10, QChar('0'));
|
---|
106 |
|
---|
107 | _dataHlp->C1[_dataHlp->numSat] = obs->C1;
|
---|
108 | _dataHlp->C2[_dataHlp->numSat] = obs->C2;
|
---|
109 | _dataHlp->P1[_dataHlp->numSat] = obs->P1;
|
---|
110 | _dataHlp->P2[_dataHlp->numSat] = obs->P2;
|
---|
111 | _dataHlp->L1[_dataHlp->numSat] = obs->L1;
|
---|
112 | _dataHlp->L2[_dataHlp->numSat] = obs->L2;
|
---|
113 | }
|
---|
114 |
|
---|
115 | //
|
---|
116 | ////////////////////////////////////////////////////////////////////////////
|
---|
117 | void bncPPPclient::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
118 | QMutexLocker locker(&_mutex);
|
---|
119 |
|
---|
120 | QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
|
---|
121 |
|
---|
122 | if (_eph.contains(prn)) {
|
---|
123 | (static_cast<t_ephGPS*>(_eph.value(prn)))->set(&gpseph);
|
---|
124 | }
|
---|
125 | else {
|
---|
126 | t_ephGPS* ee = new t_ephGPS();
|
---|
127 | ee->set(&gpseph);
|
---|
128 | _eph[prn] = ee;
|
---|
129 | }
|
---|
130 | }
|
---|
131 |
|
---|
132 | //
|
---|
133 | ////////////////////////////////////////////////////////////////////////////
|
---|
134 | void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
|
---|
135 | QMutexLocker locker(&_mutex);
|
---|
136 | QListIterator<QString> it(corrList);
|
---|
137 | while (it.hasNext()) {
|
---|
138 | QTextStream in(it.next().toAscii());
|
---|
139 | int messageType;
|
---|
140 | int updateInterval;
|
---|
141 | int GPSweek;
|
---|
142 | double GPSweeks;
|
---|
143 | QString prn;
|
---|
144 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
145 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
146 | messageType == COTYPE_GLONASSCOMBINED ) {
|
---|
147 | t_corr* cc = 0;
|
---|
148 | if (_corr.contains(prn)) {
|
---|
149 | cc = _corr.value(prn);
|
---|
150 | }
|
---|
151 | else {
|
---|
152 | cc = new t_corr();
|
---|
153 | _corr[prn] = cc;
|
---|
154 | }
|
---|
155 | cc->tt.set(GPSweek, GPSweeks);
|
---|
156 | in >> cc->iod >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2];
|
---|
157 | }
|
---|
158 | }
|
---|
159 | }
|
---|
160 |
|
---|
161 | // Satellite Position
|
---|
162 | ////////////////////////////////////////////////////////////////////////////
|
---|
163 | t_irc bncPPPclient::getSatPos(const t_time& tt, const QString& prn,
|
---|
164 | ColumnVector& xc, ColumnVector& vv) {
|
---|
165 |
|
---|
166 | if (_eph.contains(prn)) {
|
---|
167 | _eph.value(prn)->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
168 | return success;
|
---|
169 | }
|
---|
170 |
|
---|
171 | return failure;
|
---|
172 | }
|
---|
173 |
|
---|
174 | //
|
---|
175 | ////////////////////////////////////////////////////////////////////////////
|
---|
176 | void bncPPPclient::processEpoch() {
|
---|
177 | if (!_data) {
|
---|
178 | return;
|
---|
179 | }
|
---|
180 |
|
---|
181 | for (int is = 1; is <= _data->numSat; is++) {
|
---|
182 | QString prn = _data->prn[is];
|
---|
183 |
|
---|
184 | ColumnVector xc(4);
|
---|
185 | ColumnVector vv(3);
|
---|
186 |
|
---|
187 | cout.setf(ios::fixed);
|
---|
188 |
|
---|
189 | if (getSatPos(_data->tt, prn, xc, vv) == success) {
|
---|
190 | cout << _data->tt.timestr(1) << " " << prn.toAscii().data() << " "
|
---|
191 | << setw(14) << setprecision(3) << xc(1) << " "
|
---|
192 | << setw(14) << setprecision(3) << xc(2) << " "
|
---|
193 | << setw(14) << setprecision(3) << xc(3) << " "
|
---|
194 | << setw(14) << setprecision(6) << xc(4)*1.e6 << endl;
|
---|
195 | }
|
---|
196 | }
|
---|
197 |
|
---|
198 | cout << endl;
|
---|
199 | cout.flush();
|
---|
200 |
|
---|
201 | delete _data;
|
---|
202 | _data = 0;
|
---|
203 | }
|
---|
204 |
|
---|