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

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