source: ntrip/trunk/BNC/src/bncmodel.cpp@ 5805

Last change on this file since 5805 was 5805, checked in by mervart, 10 years ago
File size: 39.7 KB
Line 
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: bncParam, bncModel
30 *
31 * Purpose: Model for PPP
32 *
33 * Author: L. Mervart
34 *
35 * Created: 01-Dec-2009
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iomanip>
42#include <cmath>
43#include <newmatio.h>
44#include <sstream>
45
46#include "bncmodel.h"
47#include "bncpppclient.h"
48#include "bnccore.h"
49#include "bncpppclient.h"
50#include "bancroft.h"
51#include "bncutils.h"
52#include "PPP/pppModel.h"
53#include "bncantex.h"
54#include "pppopt.h"
55
56using namespace BNC;
57using namespace std;
58
59const unsigned MINOBS = 5;
60const double MINELE = 10.0 * M_PI / 180.0;
61const double MAXRES_CODE = 15.0;
62const double MAXRES_PHASE_GPS = 0.04;
63const double MAXRES_PHASE_GLONASS = 0.08;
64const double GLONASS_WEIGHT_FACTOR = 5.0;
65
66// Constructor
67////////////////////////////////////////////////////////////////////////////
68bncParam::bncParam(bncParam::parType typeIn, int indexIn,
69 const QString& prnIn) {
70 type = typeIn;
71 index = indexIn;
72 prn = prnIn;
73 index_old = 0;
74 xx = 0.0;
75 numEpo = 0;
76}
77
78// Destructor
79////////////////////////////////////////////////////////////////////////////
80bncParam::~bncParam() {
81}
82
83// Partial
84////////////////////////////////////////////////////////////////////////////
85double bncParam::partial(t_satData* satData, bool phase) {
86
87 Tracer tracer("bncParam::partial");
88
89 // Coordinates
90 // -----------
91 if (type == CRD_X) {
92 return (xx - satData->xx(1)) / satData->rho;
93 }
94 else if (type == CRD_Y) {
95 return (xx - satData->xx(2)) / satData->rho;
96 }
97 else if (type == CRD_Z) {
98 return (xx - satData->xx(3)) / satData->rho;
99 }
100
101 // Receiver Clocks
102 // ---------------
103 else if (type == RECCLK) {
104 return 1.0;
105 }
106
107 // Troposphere
108 // -----------
109 else if (type == TROPO) {
110 return 1.0 / sin(satData->eleSat);
111 }
112
113 // Glonass Offset
114 // --------------
115 else if (type == GLONASS_OFFSET) {
116 if (satData->prn[0] == 'R') {
117 return 1.0;
118 }
119 else {
120 return 0.0;
121 }
122 }
123
124 // Galileo Offset
125 // --------------
126 else if (type == GALILEO_OFFSET) {
127 if (satData->prn[0] == 'E') {
128 return 1.0;
129 }
130 else {
131 return 0.0;
132 }
133 }
134
135 // Ambiguities
136 // -----------
137 else if (type == AMB_L3) {
138 if (phase && satData->prn == prn) {
139 return 1.0;
140 }
141 else {
142 return 0.0;
143 }
144 }
145
146 // Default return
147 // --------------
148 return 0.0;
149}
150
151// Constructor
152////////////////////////////////////////////////////////////////////////////
153bncModel::bncModel(bncPPPclient* pppClient) {
154
155 _pppClient = pppClient;
156 _staID = pppClient->staID();
157 _opt = pppClient->opt();
158
159 // NMEA Output
160 // -----------
161 if (_opt->nmeaFile.isEmpty()) {
162 _nmeaFile = 0;
163 _nmeaStream = 0;
164 }
165 else {
166 QString hlpName = _opt->nmeaFile; expandEnvVar(hlpName);
167 _nmeaFile = new QFile(hlpName);
168 if (_opt->rnxAppend) {
169 _nmeaFile->open(QIODevice::WriteOnly | QIODevice::Append);
170 }
171 else {
172 _nmeaFile->open(QIODevice::WriteOnly);
173 }
174 _nmeaStream = new QTextStream();
175 _nmeaStream->setDevice(_nmeaFile);
176 }
177
178 // Antenna Name, ANTEX File
179 // ------------------------
180 _antex = 0;
181 if (!_opt->antexFile.isEmpty()) {
182 _antex = new bncAntex();
183 if (_antex->readFile(_opt->antexFile) != success) {
184 _pppClient->emitNewMessage("wrong ANTEX file", true);
185 delete _antex;
186 _antex = 0;
187 }
188 }
189
190 _tides = new t_tides;
191
192 // Bancroft Coordinates
193 // --------------------
194 _xcBanc.ReSize(4); _xcBanc = 0.0;
195 _ellBanc.ReSize(3); _ellBanc = 0.0;
196
197 // Save copy of data (used in outlier detection)
198 // ---------------------------------------------
199 _epoData_sav = new t_epoData();
200}
201
202// Destructor
203////////////////////////////////////////////////////////////////////////////
204bncModel::~bncModel() {
205 delete _nmeaStream;
206 delete _nmeaFile;
207 for (int ii = 0; ii < _posAverage.size(); ++ii) {
208 delete _posAverage[ii];
209 }
210 delete _antex;
211 for (int iPar = 1; iPar <= _params.size(); iPar++) {
212 delete _params[iPar-1];
213 }
214 for (int iPar = 1; iPar <= _params_sav.size(); iPar++) {
215 delete _params_sav[iPar-1];
216 }
217 delete _epoData_sav;
218 delete _tides;
219}
220
221// Reset Parameters and Variance-Covariance Matrix
222////////////////////////////////////////////////////////////////////////////
223void bncModel::reset() {
224
225 Tracer tracer("bncModel::reset");
226
227 double lastTrp = 0.0;
228 for (int ii = 0; ii < _params.size(); ii++) {
229 bncParam* pp = _params[ii];
230 if (pp->type == bncParam::TROPO) {
231 lastTrp = pp->xx;
232 }
233 delete pp;
234 }
235 _params.clear();
236
237 int nextPar = 0;
238 _params.push_back(new bncParam(bncParam::CRD_X, ++nextPar, ""));
239 _params.push_back(new bncParam(bncParam::CRD_Y, ++nextPar, ""));
240 _params.push_back(new bncParam(bncParam::CRD_Z, ++nextPar, ""));
241 _params.push_back(new bncParam(bncParam::RECCLK, ++nextPar, ""));
242 if (_opt->estTropo) {
243 _params.push_back(new bncParam(bncParam::TROPO, ++nextPar, ""));
244 }
245 if (_opt->useGlonass) {
246 _params.push_back(new bncParam(bncParam::GLONASS_OFFSET, ++nextPar, ""));
247 }
248 if (_opt->useGalileo) {
249 _params.push_back(new bncParam(bncParam::GALILEO_OFFSET, ++nextPar, ""));
250 }
251
252 _QQ.ReSize(_params.size());
253 _QQ = 0.0;
254 for (int iPar = 1; iPar <= _params.size(); iPar++) {
255 bncParam* pp = _params[iPar-1];
256 pp->xx = 0.0;
257 if (pp->isCrd()) {
258 _QQ(iPar,iPar) = _opt->sigCrd0 * _opt->sigCrd0;
259 }
260 else if (pp->type == bncParam::RECCLK) {
261 _QQ(iPar,iPar) = _opt->sigClk0 * _opt->sigClk0;
262 }
263 else if (pp->type == bncParam::TROPO) {
264 _QQ(iPar,iPar) = _opt->sigTrp0 * _opt->sigTrp0;
265 pp->xx = lastTrp;
266 }
267 else if (pp->type == bncParam::GLONASS_OFFSET) {
268 _QQ(iPar,iPar) = _opt->sigGlonassOffset0 * _opt->sigGlonassOffset0;
269 }
270 else if (pp->type == bncParam::GALILEO_OFFSET) {
271 _QQ(iPar,iPar) = _opt->sigGalileoOffset0 * _opt->sigGalileoOffset0;
272 }
273 }
274}
275
276// Bancroft Solution
277////////////////////////////////////////////////////////////////////////////
278t_irc bncModel::cmpBancroft(t_epoData* epoData) {
279
280 Tracer tracer("bncModel::cmpBancroft");
281
282 if (epoData->sizeSys('G') < MINOBS) {
283 _log += "bncModel::cmpBancroft: not enough data\n";
284 return failure;
285 }
286
287 Matrix BB(epoData->sizeSys('G'), 4);
288
289 QMapIterator<QString, t_satData*> it(epoData->satData);
290 int iObsBanc = 0;
291 while (it.hasNext()) {
292 it.next();
293 t_satData* satData = it.value();
294 if (satData->system() == 'G') {
295 ++iObsBanc;
296 QString prn = it.key();
297 BB(iObsBanc, 1) = satData->xx(1);
298 BB(iObsBanc, 2) = satData->xx(2);
299 BB(iObsBanc, 3) = satData->xx(3);
300 BB(iObsBanc, 4) = satData->P3 + satData->clk;
301 }
302 }
303
304 bancroft(BB, _xcBanc);
305
306 // Ellipsoidal Coordinates
307 // ------------------------
308 xyz2ell(_xcBanc.data(), _ellBanc.data());
309
310 // Compute Satellite Elevations
311 // ----------------------------
312 QMutableMapIterator<QString, t_satData*> im(epoData->satData);
313 while (im.hasNext()) {
314 im.next();
315 t_satData* satData = im.value();
316 cmpEle(satData);
317 if (satData->eleSat < MINELE) {
318 delete satData;
319 im.remove();
320 }
321 }
322
323 return success;
324}
325
326// Computed Value
327////////////////////////////////////////////////////////////////////////////
328double bncModel::cmpValue(t_satData* satData, bool phase) {
329
330 Tracer tracer("bncModel::cmpValue");
331
332 ColumnVector xRec(3);
333 xRec(1) = x();
334 xRec(2) = y();
335 xRec(3) = z();
336
337 double rho0 = (satData->xx - xRec).norm_Frobenius();
338 double dPhi = t_CST::omega * rho0 / t_CST::c;
339
340 xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
341 xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
342 xRec(3) = z();
343
344 xRec += _tides->displacement(_time, xRec);
345
346 satData->rho = (satData->xx - xRec).norm_Frobenius();
347
348 double tropDelay = delay_saast(xRec, satData->eleSat) +
349 trp() / sin(satData->eleSat);
350
351 double wind = 0.0;
352 if (phase) {
353 wind = windUp(satData->prn, satData->xx, xRec) * satData->lambda3;
354 }
355
356 double offset = 0.0;
357 if (satData->prn[0] == 'R') {
358 offset = Glonass_offset();
359 }
360 else if (satData->prn[0] == 'E') {
361 offset = Galileo_offset();
362 }
363
364 double phaseCenter = 0.0;
365 if (_antex) {
366 bool found;
367 phaseCenter = _antex->pco(_opt->antennaName, satData->eleSat, found);
368 if (!found) {
369 _pppClient->emitNewMessage("ANTEX: antenna >"
370 + _opt->antennaName.toAscii() + "< not found", true);
371 }
372 }
373
374 double antennaOffset = 0.0;
375 if (_opt->antEccSet()) {
376 double cosa = cos(satData->azSat);
377 double sina = sin(satData->azSat);
378 double cose = cos(satData->eleSat);
379 double sine = sin(satData->eleSat);
380 antennaOffset = -_opt->antEccNEU[0] * cosa*cose
381 -_opt->antEccNEU[1] * sina*cose
382 -_opt->antEccNEU[2] * sine;
383 }
384
385 return satData->rho + phaseCenter + antennaOffset + clk()
386 + offset - satData->clk + tropDelay + wind;
387}
388
389// Tropospheric Model (Saastamoinen)
390////////////////////////////////////////////////////////////////////////////
391double bncModel::delay_saast(const ColumnVector& xyz, double Ele) {
392
393 Tracer tracer("bncModel::delay_saast");
394
395 if (xyz[0] == 0.0 && xyz[1] == 0.0 && xyz[2] == 0.0) {
396 return 0.0;
397 }
398
399 double ell[3];
400 xyz2ell(xyz.data(), ell);
401 double height = ell[2];
402
403 double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
404 double TT = 18.0 - height * 0.0065 + 273.15;
405 double hh = 50.0 * exp(-6.396e-4 * height);
406 double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
407
408 double h_km = height / 1000.0;
409
410 if (h_km < 0.0) h_km = 0.0;
411 if (h_km > 5.0) h_km = 5.0;
412 int ii = int(h_km + 1);
413 double href = ii - 1;
414
415 double bCor[6];
416 bCor[0] = 1.156;
417 bCor[1] = 1.006;
418 bCor[2] = 0.874;
419 bCor[3] = 0.757;
420 bCor[4] = 0.654;
421 bCor[5] = 0.563;
422
423 double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
424
425 double zen = M_PI/2.0 - Ele;
426
427 return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
428}
429
430// Prediction Step of the Filter
431////////////////////////////////////////////////////////////////////////////
432void bncModel::predict(int iPhase, t_epoData* epoData) {
433
434 Tracer tracer("bncModel::predict");
435
436 if (iPhase == 0) {
437
438 bool firstCrd = false;
439 if (!_lastTimeOK.valid() || (_opt->maxSolGap > 0 && _time - _lastTimeOK > _opt->maxSolGap)) {
440 firstCrd = true;
441 _startTime = epoData->tt;
442 reset();
443 }
444
445 // Use different white noise for Quick-Start mode
446 // ----------------------------------------------
447 double sigCrdP_used = _opt->sigCrdP;
448 if ( _opt->quickStart > 0.0 && _opt->quickStart > (epoData->tt - _startTime) ) {
449 sigCrdP_used = 0.0;
450 }
451
452 // Predict Parameter values, add white noise
453 // -----------------------------------------
454 for (int iPar = 1; iPar <= _params.size(); iPar++) {
455 bncParam* pp = _params[iPar-1];
456
457 // Coordinates
458 // -----------
459 if (pp->type == bncParam::CRD_X) {
460 if (firstCrd) {
461 if (_opt->refCrdSet()) {
462 pp->xx = _opt->refCrd[0];
463 }
464 else {
465 pp->xx = _xcBanc(1);
466 }
467 }
468 _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
469 }
470 else if (pp->type == bncParam::CRD_Y) {
471 if (firstCrd) {
472 if (_opt->refCrdSet()) {
473 pp->xx = _opt->refCrd[1];
474 }
475 else {
476 pp->xx = _xcBanc(2);
477 }
478 }
479 _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
480 }
481 else if (pp->type == bncParam::CRD_Z) {
482 if (firstCrd) {
483 if (_opt->refCrdSet()) {
484 pp->xx = _opt->refCrd[2];
485 }
486 else {
487 pp->xx = _xcBanc(3);
488 }
489 }
490 _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
491 }
492
493 // Receiver Clocks
494 // ---------------
495 else if (pp->type == bncParam::RECCLK) {
496 pp->xx = _xcBanc(4);
497 for (int jj = 1; jj <= _params.size(); jj++) {
498 _QQ(iPar, jj) = 0.0;
499 }
500 _QQ(iPar,iPar) = _opt->sigClk0 * _opt->sigClk0;
501 }
502
503 // Tropospheric Delay
504 // ------------------
505 else if (pp->type == bncParam::TROPO) {
506 _QQ(iPar,iPar) += _opt->sigTrpP * _opt->sigTrpP;
507 }
508
509 // Glonass Offset
510 // --------------
511 else if (pp->type == bncParam::GLONASS_OFFSET) {
512 bool epoSpec = true;
513 if (epoSpec) {
514 pp->xx = 0.0;
515 for (int jj = 1; jj <= _params.size(); jj++) {
516 _QQ(iPar, jj) = 0.0;
517 }
518 _QQ(iPar,iPar) = _opt->sigGlonassOffset0 * _opt->sigGlonassOffset0;
519 }
520 else {
521 _QQ(iPar,iPar) += _opt->sigGlonassOffsetP * _opt->sigGlonassOffsetP;
522 }
523 }
524
525 // Galileo Offset
526 // --------------
527 else if (pp->type == bncParam::GALILEO_OFFSET) {
528 _QQ(iPar,iPar) += _opt->sigGalileoOffsetP * _opt->sigGalileoOffsetP;
529 }
530 }
531 }
532
533 // Add New Ambiguities if necessary
534 // --------------------------------
535 if (_opt->usePhase) {
536
537 // Make a copy of QQ and xx, set parameter indices
538 // -----------------------------------------------
539 SymmetricMatrix QQ_old = _QQ;
540
541 for (int iPar = 1; iPar <= _params.size(); iPar++) {
542 _params[iPar-1]->index_old = _params[iPar-1]->index;
543 _params[iPar-1]->index = 0;
544 }
545
546 // Remove Ambiguity Parameters without observations
547 // ------------------------------------------------
548 int iPar = 0;
549 QMutableVectorIterator<bncParam*> im(_params);
550 while (im.hasNext()) {
551 bncParam* par = im.next();
552 bool removed = false;
553 if (par->type == bncParam::AMB_L3) {
554 if (epoData->satData.find(par->prn) == epoData->satData.end()) {
555 removed = true;
556 delete par;
557 im.remove();
558 }
559 }
560 if (! removed) {
561 ++iPar;
562 par->index = iPar;
563 }
564 }
565
566 // Add new ambiguity parameters
567 // ----------------------------
568 QMapIterator<QString, t_satData*> it(epoData->satData);
569 while (it.hasNext()) {
570 it.next();
571 t_satData* satData = it.value();
572 addAmb(satData);
573 }
574
575 int nPar = _params.size();
576 _QQ.ReSize(nPar); _QQ = 0.0;
577 for (int i1 = 1; i1 <= nPar; i1++) {
578 bncParam* p1 = _params[i1-1];
579 if (p1->index_old != 0) {
580 _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
581 for (int i2 = 1; i2 <= nPar; i2++) {
582 bncParam* p2 = _params[i2-1];
583 if (p2->index_old != 0) {
584 _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
585 }
586 }
587 }
588 }
589
590 for (int ii = 1; ii <= nPar; ii++) {
591 bncParam* par = _params[ii-1];
592 if (par->index_old == 0) {
593 _QQ(par->index, par->index) = _opt->sigAmb0 * _opt->sigAmb0;
594 }
595 par->index_old = par->index;
596 }
597 }
598}
599
600// Update Step of the Filter (currently just a single-epoch solution)
601////////////////////////////////////////////////////////////////////////////
602t_irc bncModel::update(t_epoData* epoData) {
603
604 Tracer tracer("bncModel::update");
605
606 _log.clear();
607
608 _time = epoData->tt; // current epoch time
609
610 if (_opt->pppMode) {
611 _log += "Precise Point Positioning of Epoch "
612 + QByteArray(_time.timestr(1).c_str()) +
613 "\n---------------------------------------------------------------\n";
614 }
615 else {
616 _log += "Single Point Positioning of Epoch "
617 + QByteArray(_time.timestr(1).c_str()) +
618 "\n--------------------------------------------------------------\n";
619 }
620
621 // Outlier Detection Loop
622 // ----------------------
623 if (update_p(epoData) != success) {
624 _pppClient->emitNewMessage(_log, false);
625 return failure;
626 }
627
628 // Remember the Epoch-specific Results for the computation of means
629 // ----------------------------------------------------------------
630 pppPos* newPos = new pppPos;
631 newPos->time = epoData->tt;
632
633 // Set Solution Vector
634 // -------------------
635 ostringstream strB;
636 strB.setf(ios::fixed);
637 QVectorIterator<bncParam*> itPar(_params);
638 while (itPar.hasNext()) {
639 bncParam* par = itPar.next();
640
641 if (par->type == bncParam::RECCLK) {
642 strB << "\n clk = " << setw(10) << setprecision(3) << par->xx
643 << " +- " << setw(6) << setprecision(3)
644 << sqrt(_QQ(par->index,par->index));
645 }
646 else if (par->type == bncParam::AMB_L3) {
647 ++par->numEpo;
648 strB << "\n amb " << par->prn.toAscii().data() << " = "
649 << setw(10) << setprecision(3) << par->xx
650 << " +- " << setw(6) << setprecision(3)
651 << sqrt(_QQ(par->index,par->index))
652 << " nEpo = " << par->numEpo;
653 }
654 else if (par->type == bncParam::TROPO) {
655 ColumnVector xyz(3); xyz(1) = x(); xyz(2) = y(); xyz(3) = z();
656 double aprTrp = delay_saast(xyz, M_PI/2.0);
657 strB << "\n trp = " << par->prn.toAscii().data()
658 << setw(7) << setprecision(3) << aprTrp << " "
659 << setw(6) << setprecision(3) << showpos << par->xx << noshowpos
660 << " +- " << setw(6) << setprecision(3)
661 << sqrt(_QQ(par->index,par->index));
662 newPos->xnt[6] = aprTrp + par->xx;
663 }
664 else if (par->type == bncParam::GLONASS_OFFSET) {
665 strB << "\n offGlo = " << setw(10) << setprecision(3) << par->xx
666 << " +- " << setw(6) << setprecision(3)
667 << sqrt(_QQ(par->index,par->index));
668 }
669 else if (par->type == bncParam::GALILEO_OFFSET) {
670 strB << "\n offGal = " << setw(10) << setprecision(3) << par->xx
671 << " +- " << setw(6) << setprecision(3)
672 << sqrt(_QQ(par->index,par->index));
673 }
674 }
675 strB << '\n';
676 _log += strB.str().c_str();
677 _pppClient->emitNewMessage(_log, false);
678
679 // Final Message (both log file and screen)
680 // ----------------------------------------
681 ostringstream strC;
682 strC.setf(ios::fixed);
683 strC << _staID.data() << " PPP "
684 << epoData->tt.timestr(1) << " " << epoData->sizeAll() << " "
685 << setw(14) << setprecision(3) << x() << " +- "
686 << setw(6) << setprecision(3) << sqrt(_QQ(1,1)) << " "
687 << setw(14) << setprecision(3) << y() << " +- "
688 << setw(6) << setprecision(3) << sqrt(_QQ(2,2)) << " "
689 << setw(14) << setprecision(3) << z() << " +- "
690 << setw(6) << setprecision(3) << sqrt(_QQ(3,3));
691
692 // NEU Output
693 // ----------
694 if (_opt->refCrdSet()) {
695 newPos->xnt[0] = x() - _opt->refCrd[0];
696 newPos->xnt[1] = y() - _opt->refCrd[1];
697 newPos->xnt[2] = z() - _opt->refCrd[2];
698
699 double ellRef[3];
700 xyz2ell(_opt->refCrd, ellRef);
701 xyz2neu(ellRef, newPos->xnt, &newPos->xnt[3]);
702
703 strC << " NEU "
704 << setw(8) << setprecision(3) << newPos->xnt[3] << " "
705 << setw(8) << setprecision(3) << newPos->xnt[4] << " "
706 << setw(8) << setprecision(3) << newPos->xnt[5] << endl;
707
708 }
709
710 _pppClient->emitNewMessage(QByteArray(strC.str().c_str()), true);
711
712 if (_opt->pppAverage == 0.0) {
713 delete newPos;
714 }
715 else {
716
717 _posAverage.push_back(newPos);
718
719 // Compute the Mean
720 // ----------------
721 ColumnVector mean(7); mean = 0.0;
722
723 QMutableVectorIterator<pppPos*> it(_posAverage);
724 while (it.hasNext()) {
725 pppPos* pp = it.next();
726 if ( (epoData->tt - pp->time) >= _opt->pppAverage ) {
727 delete pp;
728 it.remove();
729 }
730 else {
731 for (int ii = 0; ii < 7; ++ii) {
732 mean[ii] += pp->xnt[ii];
733 }
734 }
735 }
736
737 int nn = _posAverage.size();
738
739 if (nn > 0) {
740
741 mean /= nn;
742
743 // Compute the Deviation
744 // ---------------------
745 ColumnVector std(7); std = 0.0;
746 QVectorIterator<pppPos*> it2(_posAverage);
747 while (it2.hasNext()) {
748 pppPos* pp = it2.next();
749 for (int ii = 0; ii < 7; ++ii) {
750 std[ii] += (pp->xnt[ii] - mean[ii]) * (pp->xnt[ii] - mean[ii]);
751 }
752 }
753 for (int ii = 0; ii < 7; ++ii) {
754 std[ii] = sqrt(std[ii] / nn);
755 }
756
757 if (_opt->refCrdSet()) {
758 ostringstream strD; strD.setf(ios::fixed);
759 strD << _staID.data() << " AVE-XYZ "
760 << epoData->tt.timestr(1) << " "
761 << setw(13) << setprecision(3) << mean[0] + _opt->refCrd[0] << " +- "
762 << setw(6) << setprecision(3) << std[0] << " "
763 << setw(14) << setprecision(3) << mean[1] + _opt->refCrd[1] << " +- "
764 << setw(6) << setprecision(3) << std[1] << " "
765 << setw(14) << setprecision(3) << mean[2] + _opt->refCrd[2] << " +- "
766 << setw(6) << setprecision(3) << std[2];
767 _pppClient->emitNewMessage(QByteArray(strD.str().c_str()), true);
768
769 ostringstream strE; strE.setf(ios::fixed);
770 strE << _staID.data() << " AVE-NEU "
771 << epoData->tt.timestr(1) << " "
772 << setw(13) << setprecision(3) << mean[3] << " +- "
773 << setw(6) << setprecision(3) << std[3] << " "
774 << setw(14) << setprecision(3) << mean[4] << " +- "
775 << setw(6) << setprecision(3) << std[4] << " "
776 << setw(14) << setprecision(3) << mean[5] << " +- "
777 << setw(6) << setprecision(3) << std[5];
778 _pppClient->emitNewMessage(QByteArray(strE.str().c_str()), true);
779
780 if (_opt->estTropo) {
781 ostringstream strF; strF.setf(ios::fixed);
782 strF << _staID.data() << " AVE-TRP "
783 << epoData->tt.timestr(1) << " "
784 << setw(13) << setprecision(3) << mean[6] << " +- "
785 << setw(6) << setprecision(3) << std[6] << endl;
786 _pppClient->emitNewMessage(QByteArray(strF.str().c_str()), true);
787 }
788 }
789 }
790 }
791
792 // NMEA Output
793 // -----------
794 double xyz[3];
795 xyz[0] = x();
796 xyz[1] = y();
797 xyz[2] = z();
798 double ell[3];
799 xyz2ell(xyz, ell);
800 double phiDeg = ell[0] * 180 / M_PI;
801 double lamDeg = ell[1] * 180 / M_PI;
802
803 char phiCh = 'N';
804 if (phiDeg < 0) {
805 phiDeg = -phiDeg;
806 phiCh = 'S';
807 }
808 char lamCh = 'E';
809 if (lamDeg < 0) {
810 lamDeg = -lamDeg;
811 lamCh = 'W';
812 }
813
814 string datestr = epoData->tt.datestr(0); // yyyymmdd
815 ostringstream strRMC;
816 strRMC.setf(ios::fixed);
817 strRMC << "GPRMC,"
818 << epoData->tt.timestr(0,0) << ",A,"
819 << setw(2) << setfill('0') << int(phiDeg)
820 << setw(6) << setprecision(3) << setfill('0')
821 << fmod(60*phiDeg,60) << ',' << phiCh << ','
822 << setw(3) << setfill('0') << int(lamDeg)
823 << setw(6) << setprecision(3) << setfill('0')
824 << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
825 << datestr[6] << datestr[7] << datestr[4] << datestr[5]
826 << datestr[2] << datestr[3] << ",,";
827
828 writeNMEAstr(QString(strRMC.str().c_str()));
829
830 double dop = 2.0; // TODO
831
832 ostringstream strGGA;
833 strGGA.setf(ios::fixed);
834 strGGA << "GPGGA,"
835 << epoData->tt.timestr(0,0) << ','
836 << setw(2) << setfill('0') << int(phiDeg)
837 << setw(10) << setprecision(7) << setfill('0')
838 << fmod(60*phiDeg,60) << ',' << phiCh << ','
839 << setw(3) << setfill('0') << int(lamDeg)
840 << setw(10) << setprecision(7) << setfill('0')
841 << fmod(60*lamDeg,60) << ',' << lamCh
842 << ",1," << setw(2) << setfill('0') << epoData->sizeAll() << ','
843 << setw(3) << setprecision(1) << dop << ','
844 << setprecision(3) << ell[2] << ",M,0.0,M,,";
845
846 writeNMEAstr(QString(strGGA.str().c_str()));
847
848 _lastTimeOK = _time; // remember time of last successful update
849 return success;
850}
851
852// Outlier Detection
853////////////////////////////////////////////////////////////////////////////
854QString bncModel::outlierDetection(int iPhase, const ColumnVector& vv,
855 QMap<QString, t_satData*>& satData) {
856
857 Tracer tracer("bncModel::outlierDetection");
858
859 QString prnGPS;
860 QString prnGlo;
861 double maxResGPS = 0.0;
862 double maxResGlo = 0.0;
863 findMaxRes(vv, satData, prnGPS, prnGlo, maxResGPS, maxResGlo);
864
865 if (iPhase == 1) {
866 if (maxResGlo > MAXRES_PHASE_GLONASS) {
867 _log += "Outlier Phase " + prnGlo + " "
868 + QByteArray::number(maxResGlo, 'f', 3) + "\n";
869 return prnGlo;
870 }
871 else if (maxResGPS > MAXRES_PHASE_GPS) {
872 _log += "Outlier Phase " + prnGPS + " "
873 + QByteArray::number(maxResGPS, 'f', 3) + "\n";
874 return prnGPS;
875 }
876 }
877 else if (iPhase == 0 && maxResGPS > MAXRES_CODE) {
878 _log += "Outlier Code " + prnGPS + " "
879 + QByteArray::number(maxResGPS, 'f', 3) + "\n";
880 return prnGPS;
881 }
882
883 return QString();
884}
885
886//
887////////////////////////////////////////////////////////////////////////////
888void bncModel::writeNMEAstr(const QString& nmStr) {
889
890 Tracer tracer("bncModel::writeNMEAstr");
891
892 unsigned char XOR = 0;
893 for (int ii = 0; ii < nmStr.length(); ii++) {
894 XOR ^= (unsigned char) nmStr[ii].toAscii();
895 }
896
897 QString outStr = '$' + nmStr
898 + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
899
900 if (_nmeaStream) {
901 *_nmeaStream << outStr;
902 _nmeaStream->flush();
903 }
904
905 _pppClient->emitNewNMEAstr(outStr.toAscii());
906}
907
908//
909//////////////////////////////////////////////////////////////////////////////
910void bncModel::kalman(const Matrix& AA, const ColumnVector& ll,
911 const DiagonalMatrix& PP,
912 SymmetricMatrix& QQ, ColumnVector& dx) {
913
914 Tracer tracer("bncModel::kalman");
915
916 int nPar = AA.Ncols();
917#if 1
918 int nObs = AA.Nrows();
919 UpperTriangularMatrix SS = Cholesky(QQ).t();
920
921 Matrix SA = SS*AA.t();
922 Matrix SRF(nObs+nPar, nObs+nPar); SRF = 0;
923 for (int ii = 1; ii <= nObs; ++ii) {
924 SRF(ii,ii) = 1.0 / sqrt(PP(ii,ii));
925 }
926
927 SRF.SubMatrix (nObs+1, nObs+nPar, 1, nObs) = SA;
928 SRF.SymSubMatrix(nObs+1, nObs+nPar) = SS;
929
930 UpperTriangularMatrix UU;
931 QRZ(SRF, UU);
932
933 SS = UU.SymSubMatrix(nObs+1, nObs+nPar);
934 UpperTriangularMatrix SH_rt = UU.SymSubMatrix(1, nObs);
935 Matrix YY = UU.SubMatrix(1, nObs, nObs+1, nObs+nPar);
936
937 UpperTriangularMatrix SHi = SH_rt.i();
938
939 Matrix KT = SHi * YY;
940 SymmetricMatrix Hi; Hi << SHi * SHi.t();
941
942 dx = KT.t() * ll;
943 QQ << (SS.t() * SS);
944#else
945 DiagonalMatrix Ql = PP.i();
946 Matrix DD = QQ * AA.t();
947 SymmetricMatrix SM(nPar); SM << AA * DD + Ql;
948 UpperTriangularMatrix UU = Cholesky(SM).t();
949 UpperTriangularMatrix Ui = UU.i();
950 Matrix EE = DD * Ui;
951 Matrix KK = EE * Ui.t();
952 QQ << QQ - EE * EE.t();
953 dx = KK * ll;
954#endif
955}
956
957// Phase Wind-Up Correction
958///////////////////////////////////////////////////////////////////////////
959double bncModel::windUp(const QString& prn, const ColumnVector& rSat,
960 const ColumnVector& rRec) {
961
962 Tracer tracer("bncModel::windUp");
963
964 double Mjd = _time.mjd() + _time.daysec() / 86400.0;
965
966 // First time - initialize to zero
967 // -------------------------------
968 if (!_windUpTime.contains(prn)) {
969 _windUpSum[prn] = 0.0;
970 }
971
972 // Compute the correction for new time
973 // -----------------------------------
974 if (!_windUpTime.contains(prn) || _windUpTime[prn] != Mjd) {
975 _windUpTime[prn] = Mjd;
976
977 // Unit Vector GPS Satellite --> Receiver
978 // --------------------------------------
979 ColumnVector rho = rRec - rSat;
980 rho /= rho.norm_Frobenius();
981
982 // GPS Satellite unit Vectors sz, sy, sx
983 // -------------------------------------
984 ColumnVector sz = -rSat / rSat.norm_Frobenius();
985
986 ColumnVector xSun = t_astro::Sun(Mjd);
987 xSun /= xSun.norm_Frobenius();
988
989 ColumnVector sy = crossproduct(sz, xSun);
990 ColumnVector sx = crossproduct(sy, sz);
991
992 // Effective Dipole of the GPS Satellite Antenna
993 // ---------------------------------------------
994 ColumnVector dipSat = sx - rho * DotProduct(rho,sx)
995 - crossproduct(rho, sy);
996
997 // Receiver unit Vectors rx, ry
998 // ----------------------------
999 ColumnVector rx(3);
1000 ColumnVector ry(3);
1001
1002 double recEll[3]; xyz2ell(rRec.data(), recEll) ;
1003 double neu[3];
1004
1005 neu[0] = 1.0;
1006 neu[1] = 0.0;
1007 neu[2] = 0.0;
1008 neu2xyz(recEll, neu, rx.data());
1009
1010 neu[0] = 0.0;
1011 neu[1] = -1.0;
1012 neu[2] = 0.0;
1013 neu2xyz(recEll, neu, ry.data());
1014
1015 // Effective Dipole of the Receiver Antenna
1016 // ----------------------------------------
1017 ColumnVector dipRec = rx - rho * DotProduct(rho,rx)
1018 + crossproduct(rho, ry);
1019
1020 // Resulting Effect
1021 // ----------------
1022 double alpha = DotProduct(dipSat,dipRec) /
1023 (dipSat.norm_Frobenius() * dipRec.norm_Frobenius());
1024
1025 if (alpha > 1.0) alpha = 1.0;
1026 if (alpha < -1.0) alpha = -1.0;
1027
1028 double dphi = acos(alpha) / 2.0 / M_PI; // in cycles
1029
1030 if ( DotProduct(rho, crossproduct(dipSat, dipRec)) < 0.0 ) {
1031 dphi = -dphi;
1032 }
1033
1034 _windUpSum[prn] = floor(_windUpSum[prn] - dphi + 0.5) + dphi;
1035 }
1036
1037 return _windUpSum[prn];
1038}
1039
1040//
1041///////////////////////////////////////////////////////////////////////////
1042void bncModel::cmpEle(t_satData* satData) {
1043 Tracer tracer("bncModel::cmpEle");
1044 ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
1045 double rho = rr.norm_Frobenius();
1046
1047 double neu[3];
1048 xyz2neu(_ellBanc.data(), rr.data(), neu);
1049
1050 satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
1051 if (neu[2] < 0) {
1052 satData->eleSat *= -1.0;
1053 }
1054 satData->azSat = atan2(neu[1], neu[0]);
1055}
1056
1057//
1058///////////////////////////////////////////////////////////////////////////
1059void bncModel::addAmb(t_satData* satData) {
1060 Tracer tracer("bncModel::addAmb");
1061 bool found = false;
1062 for (int iPar = 1; iPar <= _params.size(); iPar++) {
1063 if (_params[iPar-1]->type == bncParam::AMB_L3 &&
1064 _params[iPar-1]->prn == satData->prn) {
1065 found = true;
1066 break;
1067 }
1068 }
1069 if (!found) {
1070 bncParam* par = new bncParam(bncParam::AMB_L3,
1071 _params.size()+1, satData->prn);
1072 _params.push_back(par);
1073 par->xx = satData->L3 - cmpValue(satData, true);
1074 }
1075}
1076
1077//
1078///////////////////////////////////////////////////////////////////////////
1079void bncModel::addObs(int iPhase, unsigned& iObs, t_satData* satData,
1080 Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP) {
1081
1082 Tracer tracer("bncModel::addObs");
1083
1084 const double ELEWGHT = 20.0;
1085 double ellWgtCoef = 1.0;
1086 double eleD = satData->eleSat * 180.0 / M_PI;
1087 if (eleD < ELEWGHT) {
1088 ellWgtCoef = 1.5 - 0.5 / (ELEWGHT - 10.0) * (eleD - 10.0);
1089 }
1090
1091 // Remember Observation Index
1092 // --------------------------
1093 ++iObs;
1094 satData->obsIndex = iObs;
1095
1096 // Phase Observations
1097 // ------------------
1098 if (iPhase == 1) {
1099 ll(iObs) = satData->L3 - cmpValue(satData, true);
1100 double sigL3 = _opt->sigL3;
1101 if (satData->system() == 'R') {
1102 sigL3 *= GLONASS_WEIGHT_FACTOR;
1103 }
1104 PP(iObs,iObs) = 1.0 / (sigL3 * sigL3) / (ellWgtCoef * ellWgtCoef);
1105 for (int iPar = 1; iPar <= _params.size(); iPar++) {
1106 if (_params[iPar-1]->type == bncParam::AMB_L3 &&
1107 _params[iPar-1]->prn == satData->prn) {
1108 ll(iObs) -= _params[iPar-1]->xx;
1109 }
1110 AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
1111 }
1112 }
1113
1114 // Code Observations
1115 // -----------------
1116 else {
1117 ll(iObs) = satData->P3 - cmpValue(satData, false);
1118 PP(iObs,iObs) = 1.0 / (_opt->sigP3 * _opt->sigP3) / (ellWgtCoef * ellWgtCoef);
1119 for (int iPar = 1; iPar <= _params.size(); iPar++) {
1120 AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
1121 }
1122 }
1123}
1124
1125//
1126///////////////////////////////////////////////////////////////////////////
1127QByteArray bncModel::printRes(int iPhase, const ColumnVector& vv,
1128 const QMap<QString, t_satData*>& satDataMap) {
1129
1130 Tracer tracer("bncModel::printRes");
1131
1132 ostringstream str;
1133 str.setf(ios::fixed);
1134
1135 QMapIterator<QString, t_satData*> it(satDataMap);
1136 while (it.hasNext()) {
1137 it.next();
1138 t_satData* satData = it.value();
1139 if (satData->obsIndex != 0) {
1140 str << _time.timestr(1)
1141 << " RES " << satData->prn.toAscii().data()
1142 << (iPhase ? " L3 " : " P3 ")
1143 << setw(9) << setprecision(4) << vv(satData->obsIndex) << endl;
1144 }
1145 }
1146
1147 return QByteArray(str.str().c_str());
1148}
1149
1150//
1151///////////////////////////////////////////////////////////////////////////
1152void bncModel::findMaxRes(const ColumnVector& vv,
1153 const QMap<QString, t_satData*>& satData,
1154 QString& prnGPS, QString& prnGlo,
1155 double& maxResGPS, double& maxResGlo) {
1156
1157 Tracer tracer("bncModel::findMaxRes");
1158
1159 maxResGPS = 0.0;
1160 maxResGlo = 0.0;
1161
1162 QMapIterator<QString, t_satData*> it(satData);
1163 while (it.hasNext()) {
1164 it.next();
1165 t_satData* satData = it.value();
1166 if (satData->obsIndex != 0) {
1167 QString prn = satData->prn;
1168 if (prn[0] == 'R') {
1169 if (fabs(vv(satData->obsIndex)) > maxResGlo) {
1170 maxResGlo = fabs(vv(satData->obsIndex));
1171 prnGlo = prn;
1172 }
1173 }
1174 else {
1175 if (fabs(vv(satData->obsIndex)) > maxResGPS) {
1176 maxResGPS = fabs(vv(satData->obsIndex));
1177 prnGPS = prn;
1178 }
1179 }
1180 }
1181 }
1182}
1183
1184// Update Step (private - loop over outliers)
1185////////////////////////////////////////////////////////////////////////////
1186t_irc bncModel::update_p(t_epoData* epoData) {
1187
1188 Tracer tracer("bncModel::update_p");
1189
1190 // Save Variance-Covariance Matrix, and Status Vector
1191 // --------------------------------------------------
1192 rememberState(epoData);
1193
1194 QString lastOutlierPrn;
1195
1196 // Try with all satellites, then with all minus one, etc.
1197 // ------------------------------------------------------
1198 while (selectSatellites(lastOutlierPrn, epoData->satData) == success) {
1199
1200 QByteArray strResCode;
1201 QByteArray strResPhase;
1202
1203 // Bancroft Solution
1204 // -----------------
1205 if (cmpBancroft(epoData) != success) {
1206 break;
1207 }
1208
1209 // First update using code observations, then phase observations
1210 // -------------------------------------------------------------
1211 for (int iPhase = 0; iPhase <= (_opt->usePhase ? 1 : 0); iPhase++) {
1212
1213 // Status Prediction
1214 // -----------------
1215 predict(iPhase, epoData);
1216
1217 // Create First-Design Matrix
1218 // --------------------------
1219 unsigned nPar = _params.size();
1220 unsigned nObs = 0;
1221 if (iPhase == 0) {
1222 nObs = epoData->sizeAll() - epoData->sizeSys('R'); // Glonass code not used
1223 }
1224 else {
1225 nObs = epoData->sizeAll();
1226 }
1227
1228 // Prepare first-design Matrix, vector observed-computed
1229 // -----------------------------------------------------
1230 Matrix AA(nObs, nPar); // first design matrix
1231 ColumnVector ll(nObs); // tems observed-computed
1232 DiagonalMatrix PP(nObs); PP = 0.0;
1233
1234 unsigned iObs = 0;
1235 QMapIterator<QString, t_satData*> it(epoData->satData);
1236 while (it.hasNext()) {
1237 it.next();
1238 t_satData* satData = it.value();
1239 if (iPhase == 1 || satData->system() != 'R') {
1240 QString prn = satData->prn;
1241 addObs(iPhase, iObs, satData, AA, ll, PP);
1242 }
1243 }
1244
1245 // Compute Filter Update
1246 // ---------------------
1247 ColumnVector dx;
1248 kalman(AA, ll, PP, _QQ, dx);
1249 ColumnVector vv = ll - AA * dx;
1250
1251 // Print Residuals
1252 // ---------------
1253 if (iPhase == 0) {
1254 strResCode = printRes(iPhase, vv, epoData->satData);
1255 }
1256 else {
1257 strResPhase = printRes(iPhase, vv, epoData->satData);
1258 }
1259
1260 // Check the residuals
1261 // -------------------
1262 lastOutlierPrn = outlierDetection(iPhase, vv, epoData->satData);
1263
1264 // No Outlier Detected
1265 // -------------------
1266 if (lastOutlierPrn.isEmpty()) {
1267
1268 QVectorIterator<bncParam*> itPar(_params);
1269 while (itPar.hasNext()) {
1270 bncParam* par = itPar.next();
1271 par->xx += dx(par->index);
1272 }
1273
1274 if (!_opt->usePhase || iPhase == 1) {
1275 if (_outlierGPS.size() > 0 || _outlierGlo.size() > 0) {
1276 _log += "Neglected PRNs: ";
1277 if (!_outlierGPS.isEmpty()) {
1278 _log += _outlierGPS.last() + ' ';
1279 }
1280 QStringListIterator itGlo(_outlierGlo);
1281 while (itGlo.hasNext()) {
1282 QString prn = itGlo.next();
1283 _log += prn + ' ';
1284 }
1285 }
1286 _log += '\n';
1287
1288 _log += strResCode + strResPhase;
1289
1290 return success;
1291 }
1292 }
1293
1294 // Outlier Found
1295 // -------------
1296 else {
1297 restoreState(epoData);
1298 break;
1299 }
1300
1301 } // for iPhase
1302
1303 } // while selectSatellites
1304
1305 restoreState(epoData);
1306 return failure;
1307}
1308
1309// Remeber Original State Vector and Variance-Covariance Matrix
1310////////////////////////////////////////////////////////////////////////////
1311void bncModel::rememberState(t_epoData* epoData) {
1312
1313 _QQ_sav = _QQ;
1314
1315 QVectorIterator<bncParam*> itSav(_params_sav);
1316 while (itSav.hasNext()) {
1317 bncParam* par = itSav.next();
1318 delete par;
1319 }
1320 _params_sav.clear();
1321
1322 QVectorIterator<bncParam*> it(_params);
1323 while (it.hasNext()) {
1324 bncParam* par = it.next();
1325 _params_sav.push_back(new bncParam(*par));
1326 }
1327
1328 _epoData_sav->deepCopy(epoData);
1329}
1330
1331// Restore Original State Vector and Variance-Covariance Matrix
1332////////////////////////////////////////////////////////////////////////////
1333void bncModel::restoreState(t_epoData* epoData) {
1334
1335 _QQ = _QQ_sav;
1336
1337 QVectorIterator<bncParam*> it(_params);
1338 while (it.hasNext()) {
1339 bncParam* par = it.next();
1340 delete par;
1341 }
1342 _params.clear();
1343
1344 QVectorIterator<bncParam*> itSav(_params_sav);
1345 while (itSav.hasNext()) {
1346 bncParam* par = itSav.next();
1347 _params.push_back(new bncParam(*par));
1348 }
1349
1350 epoData->deepCopy(_epoData_sav);
1351}
1352
1353//
1354////////////////////////////////////////////////////////////////////////////
1355t_irc bncModel::selectSatellites(const QString& lastOutlierPrn,
1356 QMap<QString, t_satData*>& satData) {
1357
1358 // First Call
1359 // ----------
1360 if (lastOutlierPrn.isEmpty()) {
1361 _outlierGPS.clear();
1362 _outlierGlo.clear();
1363 return success;
1364 }
1365
1366 // Second and next trials
1367 // ----------------------
1368 else {
1369
1370 if (lastOutlierPrn[0] == 'R') {
1371 _outlierGlo << lastOutlierPrn;
1372 }
1373
1374 // Remove all Glonass Outliers
1375 // ---------------------------
1376 QStringListIterator it(_outlierGlo);
1377 while (it.hasNext()) {
1378 QString prn = it.next();
1379 if (satData.contains(prn)) {
1380 delete satData.take(prn);
1381 }
1382 }
1383
1384 if (lastOutlierPrn[0] == 'R') {
1385 _outlierGPS.clear();
1386 return success;
1387 }
1388
1389 // GPS Outlier appeared for the first time - try to delete it
1390 // ----------------------------------------------------------
1391 if (_outlierGPS.indexOf(lastOutlierPrn) == -1) {
1392 _outlierGPS << lastOutlierPrn;
1393 if (satData.contains(lastOutlierPrn)) {
1394 delete satData.take(lastOutlierPrn);
1395 }
1396 return success;
1397 }
1398
1399 }
1400
1401 return failure;
1402}
Note: See TracBrowser for help on using the repository browser.