source: ntrip/trunk/BNC/bncmodel.cpp@ 2789

Last change on this file since 2789 was 2789, checked in by mervart, 13 years ago
File size: 38.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 "bncapp.h"
48#include "bncpppclient.h"
49#include "bancroft.h"
50#include "bncutils.h"
51#include "bncsettings.h"
52#include "bnctides.h"
53
54using namespace std;
55
56const unsigned MINOBS = 4;
57const double MINELE_GPS = 10.0 * M_PI / 180.0;
58const double MINELE_GLO = 10.0 * M_PI / 180.0;
59const double MINELE_GAL = 10.0 * M_PI / 180.0;
60const double MAXRES_CODE_GPS = 10.0;
61const double MAXRES_PHASE_GPS = 0.10;
62const double MAXRES_PHASE_GLO = 0.05;
63const double MAXRES_CODE_GAL = 10.0;
64const double MAXRES_PHASE_GAL = 0.10;
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
76}
77
78// Destructor
79////////////////////////////////////////////////////////////////////////////
80bncParam::~bncParam() {
81}
82
83// Partial
84////////////////////////////////////////////////////////////////////////////
85double bncParam::partial(t_satData* satData, bool phase) {
86
87 // Coordinates
88 // -----------
89 if (type == CRD_X) {
90 return (xx - satData->xx(1)) / satData->rho;
91 }
92 else if (type == CRD_Y) {
93 return (xx - satData->xx(2)) / satData->rho;
94 }
95 else if (type == CRD_Z) {
96 return (xx - satData->xx(3)) / satData->rho;
97 }
98
99 // Receiver Clocks
100 // ---------------
101 else if (type == RECCLK) {
102 return 1.0;
103 }
104
105 // Troposphere
106 // -----------
107 else if (type == TROPO) {
108 return 1.0 / sin(satData->eleSat);
109 }
110
111 // Galileo Offset
112 // --------------
113 else if (type == GALILEO_OFFSET) {
114 if (satData->prn[0] == 'E') {
115 return 1.0;
116 }
117 else {
118 return 0.0;
119 }
120 }
121
122 // Ambiguities
123 // -----------
124 else if (type == AMB_L3) {
125 if (phase && satData->prn == prn) {
126 return 1.0;
127 }
128 else {
129 return 0.0;
130 }
131 }
132
133 // Default return
134 // --------------
135 return 0.0;
136}
137
138// Constructor
139////////////////////////////////////////////////////////////////////////////
140bncModel::bncModel(QByteArray staID) {
141
142 _staID = staID;
143
144 bncSettings settings;
145
146 // Observation Sigmas
147 // ------------------
148 _sigP3 = 5.0;
149 if (!settings.value("pppSigmaCode").toString().isEmpty()) {
150 _sigP3 = settings.value("pppSigmaCode").toDouble();
151 }
152 _sigL3 = 0.02;
153 if (!settings.value("pppSigmaPhase").toString().isEmpty()) {
154 _sigL3 = settings.value("pppSigmaPhase").toDouble();
155 }
156
157 // Parameter Sigmas
158 // ----------------
159 _sigCrd0 = 100.0;
160 if (!settings.value("pppSigCrd0").toString().isEmpty()) {
161 _sigCrd0 = settings.value("pppSigCrd0").toDouble();
162 }
163 _sigCrdP = 100.0;
164 if (!settings.value("pppSigCrdP").toString().isEmpty()) {
165 _sigCrdP = settings.value("pppSigCrdP").toDouble();
166 }
167 _sigTrp0 = 0.1;
168 if (!settings.value("pppSigTrp0").toString().isEmpty()) {
169 _sigTrp0 = settings.value("pppSigTrp0").toDouble();
170 }
171 _sigTrpP = 1e-6;
172 if (!settings.value("pppSigTrpP").toString().isEmpty()) {
173 _sigTrpP = settings.value("pppSigTrpP").toDouble();
174 }
175 _sigClk0 = 1000.0;
176 _sigAmb0 = 1000.0;
177 _sigGalileoOffset0 = 1000.0;
178 _sigGalileoOffsetP = 0.0;
179
180 // Quick-Start Mode
181 // ----------------
182 _quickStart = 0;
183 if (settings.value("pppRefCrdX").toString() != "" &&
184 settings.value("pppRefCrdY").toString() != "" &&
185 settings.value("pppRefCrdZ").toString() != "" &&
186 !settings.value("pppQuickStart").toString().isEmpty()) {
187 _quickStart = settings.value("pppQuickStart").toDouble();
188 }
189
190 connect(this, SIGNAL(newMessage(QByteArray,bool)),
191 ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
192
193 _usePhase = false;
194 if ( Qt::CheckState(settings.value("pppUsePhase").toInt()) == Qt::Checked) {
195 _usePhase = true;
196 }
197
198 _estTropo = false;
199 if ( Qt::CheckState(settings.value("pppEstTropo").toInt()) == Qt::Checked) {
200 _estTropo = true;
201 }
202
203 _xcBanc.ReSize(4); _xcBanc = 0.0;
204 _ellBanc.ReSize(3); _ellBanc = 0.0;
205
206 if (_usePhase &&
207 Qt::CheckState(settings.value("pppGLONASS").toInt()) == Qt::Checked) {
208 _useGlonass = true;
209 }
210 else {
211 _useGlonass = false;
212 }
213
214 if ( Qt::CheckState(settings.value("pppGalileo").toInt()) == Qt::Checked) {
215 _useGalileo = true;
216 }
217 else {
218 _useGalileo = false;
219 }
220
221 int nextPar = 0;
222 _params.push_back(new bncParam(bncParam::CRD_X, ++nextPar, ""));
223 _params.push_back(new bncParam(bncParam::CRD_Y, ++nextPar, ""));
224 _params.push_back(new bncParam(bncParam::CRD_Z, ++nextPar, ""));
225 _params.push_back(new bncParam(bncParam::RECCLK, ++nextPar, ""));
226 if (_estTropo) {
227 _params.push_back(new bncParam(bncParam::TROPO, ++nextPar, ""));
228 }
229 if (_useGalileo) {
230 _params.push_back(new bncParam(bncParam::GALILEO_OFFSET, ++nextPar, ""));
231 }
232
233 unsigned nPar = _params.size();
234
235 _QQ.ReSize(nPar);
236
237 _QQ = 0.0;
238
239 for (int iPar = 1; iPar <= _params.size(); iPar++) {
240 bncParam* pp = _params[iPar-1];
241 if (pp->isCrd()) {
242 _QQ(iPar,iPar) = _sigCrd0 * _sigCrd0;
243 }
244 else if (pp->type == bncParam::RECCLK) {
245 _QQ(iPar,iPar) = _sigClk0 * _sigClk0;
246 }
247 else if (pp->type == bncParam::TROPO) {
248 _QQ(iPar,iPar) = _sigTrp0 * _sigTrp0;
249 }
250 else if (pp->type == bncParam::GALILEO_OFFSET) {
251 _QQ(iPar,iPar) = _sigGalileoOffset0 * _sigGalileoOffset0;
252 }
253 }
254
255 // NMEA Output
256 // -----------
257 QString nmeaFileName = settings.value("nmeaFile").toString();
258 if (nmeaFileName.isEmpty()) {
259 _nmeaFile = 0;
260 _nmeaStream = 0;
261 }
262 else {
263 expandEnvVar(nmeaFileName);
264 _nmeaFile = new QFile(nmeaFileName);
265 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
266 _nmeaFile->open(QIODevice::WriteOnly | QIODevice::Append);
267 }
268 else {
269 _nmeaFile->open(QIODevice::WriteOnly);
270 }
271 _nmeaStream = new QTextStream();
272 _nmeaStream->setDevice(_nmeaFile);
273 }
274}
275
276// Destructor
277////////////////////////////////////////////////////////////////////////////
278bncModel::~bncModel() {
279 delete _nmeaStream;
280 delete _nmeaFile;
281 for (int ii = 0; ii < _posAverage.size(); ++ii) {
282 delete _posAverage[ii];
283 }
284}
285
286// Bancroft Solution
287////////////////////////////////////////////////////////////////////////////
288t_irc bncModel::cmpBancroft(t_epoData* epoData) {
289
290 if (epoData->sizeGPS() < MINOBS) {
291 _log += "bncModel::cmpBancroft: not enough data\n";
292 return failure;
293 }
294
295 Matrix BB(epoData->sizeGPS(), 4);
296
297 QMapIterator<QString, t_satData*> it(epoData->satDataGPS);
298 int iObs = 0;
299 while (it.hasNext()) {
300 ++iObs;
301 it.next();
302 QString prn = it.key();
303 t_satData* satData = it.value();
304 BB(iObs, 1) = satData->xx(1);
305 BB(iObs, 2) = satData->xx(2);
306 BB(iObs, 3) = satData->xx(3);
307 BB(iObs, 4) = satData->P3 + satData->clk;
308 }
309
310 bancroft(BB, _xcBanc);
311
312 // Ellipsoidal Coordinates
313 // ------------------------
314 xyz2ell(_xcBanc.data(), _ellBanc.data());
315
316 // Compute Satellite Elevations
317 // ----------------------------
318 QMutableMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
319 while (iGPS.hasNext()) {
320 iGPS.next();
321 t_satData* satData = iGPS.value();
322 cmpEle(satData);
323 if (satData->eleSat < MINELE_GPS) {
324 delete satData;
325 iGPS.remove();
326 }
327 }
328
329 QMutableMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
330 while (iGlo.hasNext()) {
331 iGlo.next();
332 t_satData* satData = iGlo.value();
333 cmpEle(satData);
334 if (satData->eleSat < MINELE_GLO) {
335 delete satData;
336 iGlo.remove();
337 }
338 }
339
340 QMutableMapIterator<QString, t_satData*> iGal(epoData->satDataGal);
341 while (iGal.hasNext()) {
342 iGal.next();
343 t_satData* satData = iGal.value();
344 cmpEle(satData);
345 if (satData->eleSat < MINELE_GAL) {
346 delete satData;
347 iGal.remove();
348 }
349 }
350
351 return success;
352}
353
354// Computed Value
355////////////////////////////////////////////////////////////////////////////
356double bncModel::cmpValue(t_satData* satData, bool phase) {
357
358 ColumnVector xRec(3);
359 xRec(1) = x();
360 xRec(2) = y();
361 xRec(3) = z();
362
363 double rho0 = (satData->xx - xRec).norm_Frobenius();
364 double dPhi = t_CST::omega * rho0 / t_CST::c;
365
366 xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
367 xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
368 xRec(3) = z();
369
370 tides(_time, xRec);
371
372 satData->rho = (satData->xx - xRec).norm_Frobenius();
373
374 double tropDelay = delay_saast(satData->eleSat) +
375 trp() / sin(satData->eleSat);
376
377 double wind = 0.0;
378 if (phase) {
379 wind = windUp(satData->prn, satData->xx, xRec) * satData->lambda3;
380 }
381
382 double offset = 0.0;
383 if (satData->prn[0] == 'E') {
384 offset = Galileo_offset();
385 }
386
387 return satData->rho + clk() + offset - satData->clk + tropDelay + wind;
388}
389
390// Tropospheric Model (Saastamoinen)
391////////////////////////////////////////////////////////////////////////////
392double bncModel::delay_saast(double Ele) {
393
394 double xyz[3];
395 xyz[0] = x();
396 xyz[1] = y();
397 xyz[2] = z();
398 double ell[3];
399 xyz2ell(xyz, 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(t_epoData* epoData) {
432
433 bncSettings settings;
434
435 bool firstCrd = false;
436 if (x() == 0.0 && y() == 0.0 && z() == 0.0) {
437 firstCrd = true;
438 _startTime = QDateTime::currentDateTime();
439 }
440
441 // Use different white noise for Quick-Start mode
442 // ----------------------------------------------
443 double sigCrdP_used = _sigCrdP;
444 if ( _quickStart > 0.0 &&
445 _quickStart > _startTime.secsTo(QDateTime::currentDateTime()) ) {
446 sigCrdP_used = 0.0;
447 }
448
449 // Predict Parameter values, add white noise
450 // -----------------------------------------
451 for (int iPar = 1; iPar <= _params.size(); iPar++) {
452 bncParam* pp = _params[iPar-1];
453
454 // Coordinates
455 // -----------
456 if (pp->type == bncParam::CRD_X) {
457 if (firstCrd) {
458 if (settings.value("pppRefCrdX").toString() != "" &&
459 settings.value("pppRefCrdY").toString() != "" &&
460 settings.value("pppRefCrdZ").toString() != "") {
461 pp->xx = settings.value("pppRefCrdX").toDouble();
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 (settings.value("pppRefCrdX").toString() != "" &&
472 settings.value("pppRefCrdY").toString() != "" &&
473 settings.value("pppRefCrdZ").toString() != "") {
474 pp->xx = settings.value("pppRefCrdY").toDouble();
475 }
476 else {
477 pp->xx = _xcBanc(2);
478 }
479 }
480 _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
481 }
482 else if (pp->type == bncParam::CRD_Z) {
483 if (firstCrd) {
484 if (settings.value("pppRefCrdX").toString() != "" &&
485 settings.value("pppRefCrdY").toString() != "" &&
486 settings.value("pppRefCrdZ").toString() != "") {
487 pp->xx = settings.value("pppRefCrdZ").toDouble();
488 }
489 else {
490 pp->xx = _xcBanc(3);
491 }
492 }
493 _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
494 }
495
496 // Receiver Clocks
497 // ---------------
498 else if (pp->type == bncParam::RECCLK) {
499 pp->xx = _xcBanc(4);
500 for (int jj = 1; jj <= _params.size(); jj++) {
501 _QQ(iPar, jj) = 0.0;
502 }
503 _QQ(iPar,iPar) = _sigClk0 * _sigClk0;
504 }
505
506 // Tropospheric Delay
507 // ------------------
508 else if (pp->type == bncParam::TROPO) {
509 _QQ(iPar,iPar) += _sigTrpP * _sigTrpP;
510 }
511
512 // Galileo Offset
513 // --------------
514 else if (pp->type == bncParam::GALILEO_OFFSET) {
515 _QQ(iPar,iPar) += _sigGalileoOffsetP * _sigGalileoOffsetP;
516 }
517 }
518
519 // Add New Ambiguities if necessary
520 // --------------------------------
521 if (_usePhase) {
522
523 // Make a copy of QQ and xx, set parameter indices
524 // -----------------------------------------------
525 SymmetricMatrix QQ_old = _QQ;
526
527 for (int iPar = 1; iPar <= _params.size(); iPar++) {
528 _params[iPar-1]->index_old = _params[iPar-1]->index;
529 _params[iPar-1]->index = 0;
530 }
531
532 // Remove Ambiguity Parameters without observations
533 // ------------------------------------------------
534 int iPar = 0;
535 QMutableVectorIterator<bncParam*> it(_params);
536 while (it.hasNext()) {
537 bncParam* par = it.next();
538 bool removed = false;
539 if (par->type == bncParam::AMB_L3) {
540 if (epoData->satDataGPS.find(par->prn) == epoData->satDataGPS.end() &&
541 epoData->satDataGlo.find(par->prn) == epoData->satDataGlo.end() &&
542 epoData->satDataGal.find(par->prn) == epoData->satDataGal.end() ) {
543 removed = true;
544 delete par;
545 it.remove();
546 }
547 }
548 if (! removed) {
549 ++iPar;
550 par->index = iPar;
551 }
552 }
553
554 // Add new ambiguity parameters
555 // ----------------------------
556 QMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
557 while (iGPS.hasNext()) {
558 iGPS.next();
559 QString prn = iGPS.key();
560 t_satData* satData = iGPS.value();
561 addAmb(satData);
562 }
563
564 QMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
565 while (iGlo.hasNext()) {
566 iGlo.next();
567 t_satData* satData = iGlo.value();
568 addAmb(satData);
569 }
570
571 QMapIterator<QString, t_satData*> iGal(epoData->satDataGal);
572 while (iGal.hasNext()) {
573 iGal.next();
574 t_satData* satData = iGal.value();
575 addAmb(satData);
576 }
577
578 int nPar = _params.size();
579 _QQ.ReSize(nPar); _QQ = 0.0;
580 for (int i1 = 1; i1 <= nPar; i1++) {
581 bncParam* p1 = _params[i1-1];
582 if (p1->index_old != 0) {
583 _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
584 for (int i2 = 1; i2 <= nPar; i2++) {
585 bncParam* p2 = _params[i2-1];
586 if (p2->index_old != 0) {
587 _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
588 }
589 }
590 }
591 }
592
593 for (int ii = 1; ii <= nPar; ii++) {
594 bncParam* par = _params[ii-1];
595 if (par->index_old == 0) {
596 _QQ(par->index, par->index) = _sigAmb0 * _sigAmb0;
597 }
598 par->index_old = par->index;
599 }
600 }
601}
602
603// Update Step of the Filter (currently just a single-epoch solution)
604////////////////////////////////////////////////////////////////////////////
605t_irc bncModel::update(t_epoData* epoData) {
606
607 bncSettings settings;
608
609 _log.clear();
610
611 _time = epoData->tt;
612
613 _log += "Single Point Positioning of Epoch "
614 + QByteArray(_time.timestr(1).c_str()) +
615 "\n--------------------------------------------------------------\n";
616
617 SymmetricMatrix QQsav;
618 ColumnVector dx;
619 ColumnVector vv;
620
621 // Loop over all outliers
622 // ----------------------
623 do {
624
625 // Bancroft Solution
626 // -----------------
627 if (cmpBancroft(epoData) != success) {
628 emit newMessage(_log, false);
629 return failure;
630 }
631
632 // Status Prediction
633 // -----------------
634 predict(epoData);
635
636 // Create First-Design Matrix
637 // --------------------------
638 unsigned nPar = _params.size();
639 unsigned nObs = 0;
640 if (_usePhase) {
641 nObs = 2 * (epoData->sizeGPS() + epoData->sizeGal()) + epoData->sizeGlo();
642 }
643 else {
644 nObs = epoData->sizeGPS() + epoData->sizeGal(); // Glonass code not used
645 }
646
647 if (nObs < nPar) {
648 _log += "bncModel::update: nObs < nPar\n";
649 emit newMessage(_log, false);
650 return failure;
651 }
652
653 Matrix AA(nObs, nPar); // first design matrix
654 ColumnVector ll(nObs); // tems observed-computed
655 DiagonalMatrix PP(nObs); PP = 0.0;
656
657 unsigned iObs = 0;
658
659 // GPS code and (optionally) phase observations
660 // --------------------------------------------
661 QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS);
662 while (itGPS.hasNext()) {
663 ++iObs;
664 itGPS.next();
665 QString prn = itGPS.key();
666 t_satData* satData = itGPS.value();
667
668 ll(iObs) = satData->P3 - cmpValue(satData, false);
669 PP(iObs,iObs) = 1.0 / (_sigP3 * _sigP3);
670 for (int iPar = 1; iPar <= _params.size(); iPar++) {
671 AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
672 }
673
674 if (_usePhase) {
675 ++iObs;
676 ll(iObs) = satData->L3 - cmpValue(satData, true);
677 PP(iObs,iObs) = 1.0 / (_sigL3 * _sigL3);
678 for (int iPar = 1; iPar <= _params.size(); iPar++) {
679 if (_params[iPar-1]->type == bncParam::AMB_L3 &&
680 _params[iPar-1]->prn == prn) {
681 ll(iObs) -= _params[iPar-1]->xx;
682 }
683 AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
684 }
685 }
686 }
687
688 // Glonass phase observations
689 // --------------------------
690 if (_usePhase) {
691 QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
692 while (itGlo.hasNext()) {
693 ++iObs;
694 itGlo.next();
695 QString prn = itGlo.key();
696 t_satData* satData = itGlo.value();
697
698 ll(iObs) = satData->L3 - cmpValue(satData, true);
699 PP(iObs,iObs) = 1.0 / (_sigL3 * _sigL3);
700 for (int iPar = 1; iPar <= _params.size(); iPar++) {
701 if (_params[iPar-1]->type == bncParam::AMB_L3 &&
702 _params[iPar-1]->prn == prn) {
703 ll(iObs) -= _params[iPar-1]->xx;
704 }
705 AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
706 }
707 }
708 }
709
710 // Galileo code and (optionally) phase observations
711 // ------------------------------------------------
712 QMapIterator<QString, t_satData*> itGal(epoData->satDataGal);
713 while (itGal.hasNext()) {
714 ++iObs;
715 itGal.next();
716 QString prn = itGal.key();
717 t_satData* satData = itGal.value();
718
719 ll(iObs) = satData->P3 - cmpValue(satData, false);
720 PP(iObs,iObs) = 1.0 / (_sigP3 * _sigP3);
721 for (int iPar = 1; iPar <= _params.size(); iPar++) {
722 AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
723 }
724
725 if (_usePhase) {
726 ++iObs;
727 ll(iObs) = satData->L3 - cmpValue(satData, true);
728 PP(iObs,iObs) = 1.0 / (_sigL3 * _sigL3);
729 for (int iPar = 1; iPar <= _params.size(); iPar++) {
730 if (_params[iPar-1]->type == bncParam::AMB_L3 &&
731 _params[iPar-1]->prn == prn) {
732 ll(iObs) -= _params[iPar-1]->xx;
733 }
734 AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
735 }
736 }
737 }
738
739 // Compute Filter Update
740 // ---------------------
741 QQsav = _QQ;
742
743 kalman(AA, ll, PP, _QQ, dx);
744
745 vv = ll - AA * dx;
746
747 ostringstream strA;
748 strA.setf(ios::fixed);
749 ColumnVector vv_code(epoData->sizeGPS());
750 ColumnVector vv_phase(epoData->sizeGPS());
751 ColumnVector vv_glo(epoData->sizeGlo());
752 ColumnVector vv_gal_code(epoData->sizeGal());
753 ColumnVector vv_gal_phase(epoData->sizeGal());
754
755 for (unsigned iobs = 1; iobs <= epoData->sizeGPS(); ++iobs) {
756 if (_usePhase) {
757 vv_code(iobs) = vv(2*iobs-1);
758 vv_phase(iobs) = vv(2*iobs);
759 }
760 else {
761 vv_code(iobs) = vv(iobs);
762 }
763 }
764 if (_useGlonass) {
765 for (unsigned iobs = 1; iobs <= epoData->sizeGlo(); ++iobs) {
766 vv_glo(iobs) = vv(2*epoData->sizeGPS()+iobs);
767 }
768 }
769 if (_useGalileo) {
770 for (unsigned iobs = 1; iobs <= epoData->sizeGal(); ++iobs) {
771 if (_usePhase) {
772 vv_gal_code(iobs) = vv(2*iobs-1);
773 vv_gal_phase(iobs) = vv(2*iobs);
774 }
775 else {
776 vv_gal_code(iobs) = vv(iobs);
777 }
778 }
779 }
780
781 strA << "residuals code " << setw(8) << setprecision(3) << vv_code.t();
782 if (_usePhase) {
783 strA << "residuals phase " << setw(8) << setprecision(3) << vv_phase.t();
784 }
785 if (_useGlonass) {
786 strA << "residuals glo " << setw(8) << setprecision(3) << vv_glo.t();
787 }
788 if (_useGalileo) {
789 strA << "Galileo code " << setw(8) << setprecision(3) << vv_gal_code.t();
790 if (_usePhase) {
791 strA << "Galileo phase " << setw(8) << setprecision(3) << vv_gal_phase.t();
792 }
793 }
794 _log += strA.str().c_str();
795
796 } while (outlierDetection(QQsav, vv, epoData->satDataGPS,
797 epoData->satDataGlo, epoData->satDataGal) != 0);
798
799 // Remember the Epoch-specific Results for the computation of means
800 // ----------------------------------------------------------------
801 pppPos* newPos = new pppPos;
802 newPos->time = epoData->tt;
803
804 // Set Solution Vector
805 // -------------------
806 ostringstream strB;
807 strB.setf(ios::fixed);
808 QVectorIterator<bncParam*> itPar(_params);
809 while (itPar.hasNext()) {
810 bncParam* par = itPar.next();
811 par->xx += dx(par->index);
812
813 if (par->type == bncParam::RECCLK) {
814 strB << "\n clk = " << setw(6) << setprecision(3) << par->xx
815 << " +- " << setw(6) << setprecision(3)
816 << sqrt(_QQ(par->index,par->index));
817 }
818 else if (par->type == bncParam::AMB_L3) {
819 strB << "\n amb " << par->prn.toAscii().data() << " = "
820 << setw(6) << setprecision(3) << par->xx
821 << " +- " << setw(6) << setprecision(3)
822 << sqrt(_QQ(par->index,par->index));
823 }
824 else if (par->type == bncParam::TROPO) {
825 double aprTrp = delay_saast(M_PI/2.0);
826 strB << "\n trp = " << par->prn.toAscii().data()
827 << setw(7) << setprecision(3) << aprTrp << " "
828 << setw(6) << setprecision(3) << showpos << par->xx << noshowpos
829 << " +- " << setw(6) << setprecision(3)
830 << sqrt(_QQ(par->index,par->index));
831 newPos->xnt[6] = aprTrp + par->xx;
832 }
833 else if (par->type == bncParam::GALILEO_OFFSET) {
834 strB << "\n offset = " << setw(6) << setprecision(3) << par->xx
835 << " +- " << setw(6) << setprecision(3)
836 << sqrt(_QQ(par->index,par->index));
837 }
838 }
839 strB << '\n';
840 _log += strB.str().c_str();
841 emit newMessage(_log, false);
842
843 // Final Message (both log file and screen)
844 // ----------------------------------------
845 ostringstream strC;
846 strC.setf(ios::fixed);
847 strC << _staID.data() << " PPP "
848 << epoData->tt.timestr(1) << " " << epoData->sizeAll() << " "
849 << setw(14) << setprecision(3) << x() << " +- "
850 << setw(6) << setprecision(3) << sqrt(_QQ(1,1)) << " "
851 << setw(14) << setprecision(3) << y() << " +- "
852 << setw(6) << setprecision(3) << sqrt(_QQ(2,2)) << " "
853 << setw(14) << setprecision(3) << z() << " +- "
854 << setw(6) << setprecision(3) << sqrt(_QQ(3,3));
855
856 // NEU Output
857 // ----------
858 if (settings.value("pppRefCrdX").toString() != "" &&
859 settings.value("pppRefCrdY").toString() != "" &&
860 settings.value("pppRefCrdZ").toString() != "") {
861
862 double xyzRef[3];
863 xyzRef[0] = settings.value("pppRefCrdX").toDouble();
864 xyzRef[1] = settings.value("pppRefCrdY").toDouble();
865 xyzRef[2] = settings.value("pppRefCrdZ").toDouble();
866
867 newPos->xnt[0] = x() - xyzRef[0];
868 newPos->xnt[1] = y() - xyzRef[1];
869 newPos->xnt[2] = z() - xyzRef[2];
870
871 double ellRef[3];
872 xyz2ell(xyzRef, ellRef);
873 xyz2neu(ellRef, newPos->xnt, &newPos->xnt[3]);
874
875 strC << " NEU "
876 << setw(8) << setprecision(3) << newPos->xnt[3] << " "
877 << setw(8) << setprecision(3) << newPos->xnt[4] << " "
878 << setw(8) << setprecision(3) << newPos->xnt[5];
879
880 }
881
882 emit newMessage(QByteArray(strC.str().c_str()), true);
883
884 if (settings.value("pppAverage").toString() == "") {
885 delete newPos;
886 }
887 else {
888
889 _posAverage.push_back(newPos);
890
891 // Time Span for Average Computation
892 // ---------------------------------
893 double tRangeAverage = settings.value("pppAverage").toDouble() * 60.;
894 if (tRangeAverage < 0) {
895 tRangeAverage = 0;
896 }
897 if (tRangeAverage > 86400) {
898 tRangeAverage = 86400;
899 }
900
901 // Compute the Mean
902 // ----------------
903 ColumnVector mean(7); mean = 0.0;
904
905 QMutableVectorIterator<pppPos*> it(_posAverage);
906 while (it.hasNext()) {
907 pppPos* pp = it.next();
908 if ( (epoData->tt - pp->time) >= tRangeAverage ) {
909 delete pp;
910 it.remove();
911 }
912 else {
913 for (int ii = 0; ii < 7; ++ii) {
914 mean[ii] += pp->xnt[ii];
915 }
916 }
917 }
918
919 int nn = _posAverage.size();
920
921 if (nn > 0) {
922
923 mean /= nn;
924
925 // Compute the Deviation
926 // ---------------------
927 ColumnVector std(7); std = 0.0;
928 QVectorIterator<pppPos*> it2(_posAverage);
929 while (it2.hasNext()) {
930 pppPos* pp = it2.next();
931 for (int ii = 0; ii < 7; ++ii) {
932 std[ii] += (pp->xnt[ii] - mean[ii]) * (pp->xnt[ii] - mean[ii]);
933 }
934 }
935 for (int ii = 0; ii < 7; ++ii) {
936 std[ii] = sqrt(std[ii] / nn);
937 }
938
939 ostringstream strD; strD.setf(ios::fixed);
940 strD << _staID.data() << " AVE-XYZ "
941 << epoData->tt.timestr(1) << " "
942 << setw(13) << setprecision(3) << mean[0] << " +- "
943 << setw(6) << setprecision(3) << std[0] << " "
944 << setw(14) << setprecision(3) << mean[1] << " +- "
945 << setw(6) << setprecision(3) << std[1] << " "
946 << setw(14) << setprecision(3) << mean[2] << " +- "
947 << setw(6) << setprecision(3) << std[2];
948 emit newMessage(QByteArray(strD.str().c_str()), true);
949
950 ostringstream strE; strE.setf(ios::fixed);
951 strE << _staID.data() << " AVE-NEU "
952 << epoData->tt.timestr(1) << " "
953 << setw(13) << setprecision(3) << mean[3] << " +- "
954 << setw(6) << setprecision(3) << std[3] << " "
955 << setw(14) << setprecision(3) << mean[4] << " +- "
956 << setw(6) << setprecision(3) << std[4] << " "
957 << setw(14) << setprecision(3) << mean[5] << " +- "
958 << setw(6) << setprecision(3) << std[5];
959
960 emit newMessage(QByteArray(strE.str().c_str()), true);
961
962 if ( Qt::CheckState(settings.value("pppEstTropo").toInt()) == Qt::Checked) {
963 ostringstream strF; strF.setf(ios::fixed);
964 strF << _staID.data() << " AVE-TRP "
965 << epoData->tt.timestr(1) << " "
966 << setw(13) << setprecision(3) << mean[6] << " +- "
967 << setw(6) << setprecision(3) << std[6] << endl;
968 emit newMessage(QByteArray(strF.str().c_str()), true);
969 }
970 }
971 }
972
973 // NMEA Output
974 // -----------
975 double xyz[3];
976 xyz[0] = x();
977 xyz[1] = y();
978 xyz[2] = z();
979 double ell[3];
980 xyz2ell(xyz, ell);
981 double phiDeg = ell[0] * 180 / M_PI;
982 double lamDeg = ell[1] * 180 / M_PI;
983
984 char phiCh = 'N';
985 if (phiDeg < 0) {
986 phiDeg = -phiDeg;
987 phiCh = 'S';
988 }
989 char lamCh = 'E';
990 if (lamDeg < 0) {
991 lamDeg = -lamDeg;
992 lamCh = 'W';
993 }
994
995 string datestr = epoData->tt.datestr(0); // yyyymmdd
996 ostringstream strRMC;
997 strRMC.setf(ios::fixed);
998 strRMC << "GPRMC,"
999 << epoData->tt.timestr(0,0) << ",A,"
1000 << setw(2) << setfill('0') << int(phiDeg)
1001 << setw(6) << setprecision(3) << setfill('0')
1002 << fmod(60*phiDeg,60) << ',' << phiCh << ','
1003 << setw(3) << setfill('0') << int(lamDeg)
1004 << setw(6) << setprecision(3) << setfill('0')
1005 << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
1006 << datestr[6] << datestr[7] << datestr[4] << datestr[5]
1007 << datestr[2] << datestr[3] << ",,";
1008
1009 writeNMEAstr(QString(strRMC.str().c_str()));
1010
1011 double dop = 2.0; // TODO
1012
1013 ostringstream strGGA;
1014 strGGA.setf(ios::fixed);
1015 strGGA << "GPGGA,"
1016 << epoData->tt.timestr(0,0) << ','
1017 << setw(2) << setfill('0') << int(phiDeg)
1018 << setw(10) << setprecision(7) << setfill('0')
1019 << fmod(60*phiDeg,60) << ',' << phiCh << ','
1020 << setw(3) << setfill('0') << int(lamDeg)
1021 << setw(10) << setprecision(7) << setfill('0')
1022 << fmod(60*lamDeg,60) << ',' << lamCh
1023 << ",1," << setw(2) << setfill('0') << epoData->sizeAll() << ','
1024 << setw(3) << setprecision(1) << dop << ','
1025 << setprecision(3) << ell[2] << ",M,0.0,M,,";
1026
1027 writeNMEAstr(QString(strGGA.str().c_str()));
1028
1029 return success;
1030}
1031
1032// Outlier Detection
1033////////////////////////////////////////////////////////////////////////////
1034int bncModel::outlierDetection(const SymmetricMatrix& QQsav,
1035 const ColumnVector& vv,
1036 QMap<QString, t_satData*>& satDataGPS,
1037 QMap<QString, t_satData*>& satDataGlo,
1038 QMap<QString, t_satData*>& satDataGal) {
1039
1040 double vvMaxCodeGPS = 0.0;
1041 double vvMaxPhaseGPS = 0.0;
1042 double vvMaxPhaseGlo = 0.0;
1043 double vvMaxCodeGal = 0.0;
1044 double vvMaxPhaseGal = 0.0;
1045 QMutableMapIterator<QString, t_satData*> itMaxCodeGPS(satDataGPS);
1046 QMutableMapIterator<QString, t_satData*> itMaxPhaseGPS(satDataGPS);
1047 QMutableMapIterator<QString, t_satData*> itMaxPhaseGlo(satDataGlo);
1048 QMutableMapIterator<QString, t_satData*> itMaxCodeGal(satDataGPS);
1049 QMutableMapIterator<QString, t_satData*> itMaxPhaseGal(satDataGPS);
1050
1051 int ii = 0;
1052
1053 // GPS code and (optionally) phase residuals
1054 // -----------------------------------------
1055 QMutableMapIterator<QString, t_satData*> itGPS(satDataGPS);
1056 while (itGPS.hasNext()) {
1057 itGPS.next();
1058 ++ii;
1059
1060 if (vvMaxCodeGPS == 0.0 || fabs(vv(ii)) > vvMaxCodeGPS) {
1061 vvMaxCodeGPS = fabs(vv(ii));
1062 itMaxCodeGPS = itGPS;
1063 }
1064
1065 if (_usePhase) {
1066 ++ii;
1067 if (vvMaxPhaseGPS == 0.0 || fabs(vv(ii)) > vvMaxPhaseGPS) {
1068 vvMaxPhaseGPS = fabs(vv(ii));
1069 itMaxPhaseGPS = itGPS;
1070 }
1071 }
1072 }
1073
1074 // Glonass phase residuals
1075 // -----------------------
1076 if (_usePhase) {
1077 QMutableMapIterator<QString, t_satData*> itGlo(satDataGlo);
1078 while (itGlo.hasNext()) {
1079 itGlo.next();
1080 ++ii;
1081 if (vvMaxPhaseGlo == 0.0 || fabs(vv(ii)) > vvMaxPhaseGlo) {
1082 vvMaxPhaseGlo = fabs(vv(ii));
1083 itMaxPhaseGlo = itGlo;
1084 }
1085 }
1086 }
1087
1088 // Galileo code and (optionally) phase residuals
1089 // ---------------------------------------------
1090 QMutableMapIterator<QString, t_satData*> itGal(satDataGal);
1091 while (itGal.hasNext()) {
1092 itGal.next();
1093 ++ii;
1094
1095 if (vvMaxCodeGal == 0.0 || fabs(vv(ii)) > vvMaxCodeGal) {
1096 vvMaxCodeGal = fabs(vv(ii));
1097 itMaxCodeGal = itGal;
1098 }
1099
1100 if (_usePhase) {
1101 ++ii;
1102 if (vvMaxPhaseGal == 0.0 || fabs(vv(ii)) > vvMaxPhaseGal) {
1103 vvMaxPhaseGal = fabs(vv(ii));
1104 itMaxPhaseGal = itGal;
1105 }
1106 }
1107 }
1108
1109 if (vvMaxPhaseGlo > MAXRES_PHASE_GLO) {
1110 QString prn = itMaxPhaseGlo.key();
1111 t_satData* satData = itMaxPhaseGlo.value();
1112 delete satData;
1113 itMaxPhaseGlo.remove();
1114 _QQ = QQsav;
1115
1116 _log += "Outlier Phase " + prn.toAscii() + " "
1117 + QByteArray::number(vvMaxPhaseGlo, 'f', 3) + "\n";
1118
1119 return 1;
1120 }
1121
1122 else if (vvMaxCodeGPS > MAXRES_CODE_GPS) {
1123 QString prn = itMaxCodeGPS.key();
1124 t_satData* satData = itMaxCodeGPS.value();
1125 delete satData;
1126 itMaxCodeGPS.remove();
1127 _QQ = QQsav;
1128
1129 _log += "Outlier Code " + prn.toAscii() + " "
1130 + QByteArray::number(vvMaxCodeGPS, 'f', 3) + "\n";
1131
1132 return 1;
1133 }
1134 else if (vvMaxPhaseGPS > MAXRES_PHASE_GPS) {
1135 QString prn = itMaxPhaseGPS.key();
1136 t_satData* satData = itMaxPhaseGPS.value();
1137 delete satData;
1138 itMaxPhaseGPS.remove();
1139 _QQ = QQsav;
1140
1141 _log += "Outlier Phase " + prn.toAscii() + " "
1142 + QByteArray::number(vvMaxPhaseGPS, 'f', 3) + "\n";
1143
1144 return 1;
1145 }
1146
1147 else if (vvMaxCodeGal > MAXRES_CODE_GAL) {
1148 QString prn = itMaxCodeGal.key();
1149 t_satData* satData = itMaxCodeGal.value();
1150 delete satData;
1151 itMaxCodeGal.remove();
1152 _QQ = QQsav;
1153
1154 _log += "Outlier Code " + prn.toAscii() + " "
1155 + QByteArray::number(vvMaxCodeGal, 'f', 3) + "\n";
1156
1157 return 1;
1158 }
1159 else if (vvMaxPhaseGal > MAXRES_PHASE_GAL) {
1160 QString prn = itMaxPhaseGal.key();
1161 t_satData* satData = itMaxPhaseGal.value();
1162 delete satData;
1163 itMaxPhaseGal.remove();
1164 _QQ = QQsav;
1165
1166 _log += "Outlier Phase " + prn.toAscii() + " "
1167 + QByteArray::number(vvMaxPhaseGal, 'f', 3) + "\n";
1168
1169 return 1;
1170 }
1171
1172 return 0;
1173}
1174
1175//
1176////////////////////////////////////////////////////////////////////////////
1177void bncModel::writeNMEAstr(const QString& nmStr) {
1178
1179 unsigned char XOR = 0;
1180 for (int ii = 0; ii < nmStr.length(); ii++) {
1181 XOR ^= (unsigned char) nmStr[ii].toAscii();
1182 }
1183
1184 QString outStr = '$' + nmStr
1185 + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
1186
1187 if (_nmeaStream) {
1188 *_nmeaStream << outStr;
1189 _nmeaStream->flush();
1190 }
1191
1192 emit newNMEAstr(outStr.toAscii());
1193}
1194
1195////
1196//////////////////////////////////////////////////////////////////////////////
1197void bncModel::kalman(const Matrix& AA, const ColumnVector& ll,
1198 const DiagonalMatrix& PP,
1199 SymmetricMatrix& QQ, ColumnVector& dx) {
1200
1201 int nObs = AA.Nrows();
1202 int nPar = AA.Ncols();
1203
1204 UpperTriangularMatrix SS = Cholesky(QQ).t();
1205
1206 Matrix SA = SS*AA.t();
1207 Matrix SRF(nObs+nPar, nObs+nPar); SRF = 0;
1208 for (int ii = 1; ii <= nObs; ++ii) {
1209 SRF(ii,ii) = 1.0 / sqrt(PP(ii,ii));
1210 }
1211
1212 SRF.SubMatrix (nObs+1, nObs+nPar, 1, nObs) = SA;
1213 SRF.SymSubMatrix(nObs+1, nObs+nPar) = SS;
1214
1215 UpperTriangularMatrix UU;
1216 QRZ(SRF, UU);
1217
1218 SS = UU.SymSubMatrix(nObs+1, nObs+nPar);
1219 UpperTriangularMatrix SH_rt = UU.SymSubMatrix(1, nObs);
1220 Matrix YY = UU.SubMatrix(1, nObs, nObs+1, nObs+nPar);
1221
1222 UpperTriangularMatrix SHi = SH_rt.i();
1223
1224 Matrix KT = SHi * YY;
1225 SymmetricMatrix Hi; Hi << SHi * SHi.t();
1226
1227 dx = KT.t() * ll;
1228 QQ << (SS.t() * SS);
1229}
1230
1231// Phase Wind-Up Correction
1232///////////////////////////////////////////////////////////////////////////
1233double bncModel::windUp(const QString& prn, const ColumnVector& rSat,
1234 const ColumnVector& rRec) {
1235
1236 double Mjd = _time.mjd() + _time.daysec() / 86400.0;
1237
1238 // First time - initialize to zero
1239 // -------------------------------
1240 if (!_windUpTime.contains(prn)) {
1241 _windUpTime[prn] = Mjd;
1242 _windUpSum[prn] = 0.0;
1243 }
1244
1245 // Compute the correction for new time
1246 // -----------------------------------
1247 else if (_windUpTime[prn] != Mjd) {
1248 _windUpTime[prn] = Mjd;
1249
1250 // Unit Vector GPS Satellite --> Receiver
1251 // --------------------------------------
1252 ColumnVector rho = rRec - rSat;
1253 rho /= rho.norm_Frobenius();
1254
1255 // GPS Satellite unit Vectors sz, sy, sx
1256 // -------------------------------------
1257 ColumnVector sz = -rSat / rSat.norm_Frobenius();
1258
1259 ColumnVector xSun = Sun(Mjd);
1260 xSun /= xSun.norm_Frobenius();
1261
1262 ColumnVector sy = crossproduct(sz, xSun);
1263 ColumnVector sx = crossproduct(sy, sz);
1264
1265 // Effective Dipole of the GPS Satellite Antenna
1266 // ---------------------------------------------
1267 ColumnVector dipSat = sx - rho * DotProduct(rho,sx)
1268 - crossproduct(rho, sy);
1269
1270 // Receiver unit Vectors rx, ry
1271 // ----------------------------
1272 ColumnVector rx(3);
1273 ColumnVector ry(3);
1274
1275 double recEll[3]; xyz2ell(rRec.data(), recEll) ;
1276 double neu[3];
1277
1278 neu[0] = 1.0;
1279 neu[1] = 0.0;
1280 neu[2] = 0.0;
1281 neu2xyz(recEll, neu, rx.data());
1282
1283 neu[0] = 0.0;
1284 neu[1] = -1.0;
1285 neu[2] = 0.0;
1286 neu2xyz(recEll, neu, ry.data());
1287
1288 // Effective Dipole of the Receiver Antenna
1289 // ----------------------------------------
1290 ColumnVector dipRec = rx - rho * DotProduct(rho,rx)
1291 + crossproduct(rho, ry);
1292
1293 // Resulting Effect
1294 // ----------------
1295 double alpha = DotProduct(dipSat,dipRec) /
1296 (dipSat.norm_Frobenius() * dipRec.norm_Frobenius());
1297
1298 if (alpha > 1.0) alpha = 1.0;
1299 if (alpha < -1.0) alpha = -1.0;
1300
1301 double dphi = acos(alpha) / 2.0 / M_PI; // in cycles
1302
1303 if ( DotProduct(rho, crossproduct(dipSat, dipRec)) < 0.0 ) {
1304 dphi = -dphi;
1305 }
1306
1307 _windUpSum[prn] = floor(_windUpSum[prn] - dphi + 0.5) + dphi;
1308 }
1309
1310 return _windUpSum[prn];
1311}
1312
1313//
1314///////////////////////////////////////////////////////////////////////////
1315void bncModel::cmpEle(t_satData* satData) {
1316 ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
1317 double rho = rr.norm_Frobenius();
1318
1319 double neu[3];
1320 xyz2neu(_ellBanc.data(), rr.data(), neu);
1321
1322 satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
1323 if (neu[2] < 0) {
1324 satData->eleSat *= -1.0;
1325 }
1326 satData->azSat = atan2(neu[1], neu[0]);
1327}
1328
1329//
1330///////////////////////////////////////////////////////////////////////////
1331void bncModel::addAmb(t_satData* satData) {
1332 bool found = false;
1333 for (int iPar = 1; iPar <= _params.size(); iPar++) {
1334 if (_params[iPar-1]->type == bncParam::AMB_L3 &&
1335 _params[iPar-1]->prn == satData->prn) {
1336 found = true;
1337 break;
1338 }
1339 }
1340 if (!found) {
1341 bncParam* par = new bncParam(bncParam::AMB_L3,
1342 _params.size()+1, satData->prn);
1343 _params.push_back(par);
1344 par->xx = satData->L3 - cmpValue(satData, true);
1345 }
1346}
Note: See TracBrowser for help on using the repository browser.