source: ntrip/trunk/BNC/src/PPP/pppClient.cpp@ 9241

Last change on this file since 9241 was 8993, checked in by stuerze, 4 years ago

minor changes in PPP

  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 23.0 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Client
3 * -------------------------------------------------------------------------
4 *
5 * Class: t_pppClient
6 *
7 * Purpose: PPP Client processing starts here
8 *
9 * Author: L. Mervart
10 *
11 * Created: 29-Jul-2014
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <QThreadStorage>
18
19#include <iostream>
20#include <iomanip>
21#include <cmath>
22#include <stdlib.h>
23#include <string.h>
24#include <stdexcept>
25
26#include "pppClient.h"
27#include "pppEphPool.h"
28#include "pppObsPool.h"
29#include "bncconst.h"
30#include "bncutils.h"
31#include "pppStation.h"
32#include "bncantex.h"
33#include "pppFilter.h"
34
35using namespace BNC_PPP;
36using namespace std;
37
38// Global variable holding thread-specific pointers
39//////////////////////////////////////////////////////////////////////////////
40QThreadStorage<t_pppClient*> CLIENTS;
41
42// Static function returning thread-specific pointer
43//////////////////////////////////////////////////////////////////////////////
44t_pppClient* t_pppClient::instance() {
45 return CLIENTS.localData();
46}
47
48// Constructor
49//////////////////////////////////////////////////////////////////////////////
50t_pppClient::t_pppClient(const t_pppOptions* opt) {
51 _output = 0;
52 _opt = new t_pppOptions(*opt);
53 _log = new ostringstream();
54 _ephPool = new t_pppEphPool();
55 _obsPool = new t_pppObsPool();
56 _staRover = new t_pppStation();
57 _filter = new t_pppFilter(_obsPool);
58 _tides = new t_tides();
59 _antex = 0;
60 if (!_opt->_antexFileName.empty()) {
61 _antex = new bncAntex(_opt->_antexFileName.c_str());
62 }
63 if (!_opt->_blqFileName.empty()) {
64 if (_tides->readBlqFile(_opt->_blqFileName.c_str()) == success) {
65 //_tides->printAllBlqSets();
66 }
67 }
68
69 if (_opt->_refSatRequired) {
70 for (unsigned iSys = 0; iSys < _opt->systems().size(); iSys++) {
71 char system = _opt->systems()[iSys];
72 _obsPool->initRefSatMapElement(system);
73 }
74 }
75 _offGG = 0.0;
76 _offGB = 0.0;
77 CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
78}
79
80// Destructor
81//////////////////////////////////////////////////////////////////////////////
82t_pppClient::~t_pppClient() {
83 delete _log;
84 delete _opt;
85 delete _filter;
86 delete _ephPool;
87 delete _obsPool;
88 delete _staRover;
89 if (_antex) {
90 delete _antex;
91 }
92 delete _tides;
93 clearObs();
94}
95
96//
97//////////////////////////////////////////////////////////////////////////////
98void t_pppClient::putEphemeris(const t_eph* eph) {
99 const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
100 const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
101 const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
102 const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
103 if (ephGPS) {
104 _ephPool->putEphemeris(new t_ephGPS(*ephGPS));
105 }
106 else if (ephGlo) {
107 _ephPool->putEphemeris(new t_ephGlo(*ephGlo));
108 }
109 else if (ephGal) {
110 _ephPool->putEphemeris(new t_ephGal(*ephGal));
111 }
112 else if (ephBDS) {
113 _ephPool->putEphemeris(new t_ephBDS(*ephBDS));
114 }
115}
116
117//
118//////////////////////////////////////////////////////////////////////////////
119void t_pppClient::putTec(const t_vTec* vTec) {
120 _obsPool->putTec(new t_vTec(*vTec));
121}
122
123//
124//////////////////////////////////////////////////////////////////////////////
125void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) {
126 for (unsigned ii = 0; ii < corr.size(); ii++) {
127 _ephPool->putOrbCorrection(new t_orbCorr(*corr[ii]));
128 }
129}
130
131//
132//////////////////////////////////////////////////////////////////////////////
133void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) {
134 for (unsigned ii = 0; ii < corr.size(); ii++) {
135 _ephPool->putClkCorrection(new t_clkCorr(*corr[ii]));
136 }
137}
138
139//
140//////////////////////////////////////////////////////////////////////////////
141void t_pppClient::putCodeBiases(const vector<t_satCodeBias*>& biases) {
142 for (unsigned ii = 0; ii < biases.size(); ii++) {
143 _obsPool->putCodeBias(new t_satCodeBias(*biases[ii]));
144 }
145}
146
147//
148//////////////////////////////////////////////////////////////////////////////
149void t_pppClient::putPhaseBiases(const vector<t_satPhaseBias*>& biases) {
150 for (unsigned ii = 0; ii < biases.size(); ii++) {
151 _obsPool->putPhaseBias(new t_satPhaseBias(*biases[ii]));
152 }
153}
154
155//
156//////////////////////////////////////////////////////////////////////////////
157t_irc t_pppClient::prepareObs(const vector<t_satObs*>& satObs,
158 vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
159
160 // Default
161 // -------
162 epoTime.reset();
163 clearObs();
164
165 // Create vector of valid observations
166 // -----------------------------------
167 for (unsigned ii = 0; ii < satObs.size(); ii++) {
168 char system = satObs[ii]->_prn.system();
169 if (_opt->useSystem(system)) {
170 t_pppSatObs* pppSatObs = new t_pppSatObs(*satObs[ii]);
171 if (pppSatObs->isValid()) {
172 obsVector.push_back(pppSatObs);
173 }
174 else {
175 delete pppSatObs;
176 }
177 }
178 }
179
180 // Check whether data are synchronized, compute epoTime
181 // ----------------------------------------------------
182 const double MAXSYNC = 0.05; // synchronization limit
183 double meanDt = 0.0;
184 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
185 const t_pppSatObs* satObs = obsVector.at(ii);
186 if (epoTime.undef()) {
187 epoTime = satObs->time();
188 }
189 else {
190 double dt = satObs->time() - epoTime;
191 if (fabs(dt) > MAXSYNC) {
192 LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
193 return failure;
194 }
195 meanDt += dt;
196 }
197 }
198
199 if (obsVector.size() > 0) {
200 epoTime += meanDt / obsVector.size();
201 }
202
203 return success;
204}
205
206//
207//////////////////////////////////////////////////////////////////////////////
208bool t_pppClient::preparePseudoObs(std::vector<t_pppSatObs*>& obsVector) {
209
210 bool pseudoObsIono = false;
211
212 if (_opt->_pseudoObsIono) {
213 vector<t_pppSatObs*>::iterator it = obsVector.begin();
214 while (it != obsVector.end()) {
215 t_pppSatObs* satObs = *it;
216 char system = satObs->prn().system();
217 t_pppRefSat* refSat = _obsPool->getRefSatMapElement(system);
218 double stecRef = refSat->stecValue();
219 if (stecRef && !satObs->isReference()) {
220 pseudoObsIono = true;
221 satObs->setPseudoObsIono(t_frequency::G1, stecRef);
222 }
223 it++;
224 }
225 }
226 if (_opt->_pseudoObsTropo) {
227 vector<t_pppSatObs*>::iterator it = obsVector.begin();
228 while (it != obsVector.end()) {
229 t_pppSatObs* satObs = *it;
230 if (satObs->isReference()) {
231 satObs->setPseudoObsTropo();
232 }
233 it++;
234 }
235 }
236/*
237 vector<t_pppSatObs*>::iterator it = obsVector.begin();
238 while (it != obsVector.end()) {
239 t_pppSatObs* satObs = *it;
240 satObs->printObsMinusComputed();
241 it++;
242 }
243*/
244 return pseudoObsIono;
245}
246
247// Compute the Bancroft position, check for blunders
248//////////////////////////////////////////////////////////////////////////////
249t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
250 vector<t_pppSatObs*>& obsVector,
251 ColumnVector& xyzc, bool print) {
252
253 t_lc::type tLC = t_lc::dummy;
254
255 while (true) {
256 Matrix BB(obsVector.size(), 4);
257 int iObs = -1;
258 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
259 const t_pppSatObs* satObs = obsVector.at(ii);
260 if (tLC == t_lc::dummy) {
261 if (satObs->isValid(t_lc::cIF)) {
262 tLC = t_lc::cIF;
263 }
264 else if (satObs->isValid(t_lc::c1)) {
265 tLC = t_lc::c1;
266 }
267 else if (satObs->isValid(t_lc::c2)) {
268 tLC = t_lc::c2;
269 }
270 }
271 if ( satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
272 ++iObs;
273 BB[iObs][0] = satObs->xc()[0];
274 BB[iObs][1] = satObs->xc()[1];
275 BB[iObs][2] = satObs->xc()[2];
276 BB[iObs][3] = satObs->obsValue(tLC) - satObs->cmpValueForBanc(tLC);
277 }
278 }
279 if (iObs + 1 < _opt->_minObs) {
280 LOG << "t_pppClient::cmpBancroft not enough observations" << endl;
281 return failure;
282 }
283 BB = BB.Rows(1,iObs+1);
284 bancroft(BB, xyzc);
285
286 xyzc[3] /= t_CST::c;
287
288 // Check Blunders
289 // --------------
290 const double BLUNDER = 100.0;
291 double maxRes = 0.0;
292 unsigned maxResIndex = 0;
293 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
294 const t_pppSatObs* satObs = obsVector.at(ii);
295 if (satObs->isValid() &&
296 satObs->prn().system() == 'G' &&
297 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
298 ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
299 double res = rr.NormFrobenius() - satObs->obsValue(tLC)
300 - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
301 if (std::isnan(res) || fabs(res) > maxRes) {
302 std::isnan(res) ?
303 maxRes = res :
304 maxRes = fabs(res);
305 maxResIndex = ii;
306 }
307 }
308 }
309 if (!std::isnan(maxRes) && maxRes < BLUNDER) {
310 if (print) {
311 LOG.setf(ios::fixed);
312 LOG << string(epoTime) << " BANCROFT:" << ' '
313 << setw(14) << setprecision(3) << xyzc[0] << ' '
314 << setw(14) << setprecision(3) << xyzc[1] << ' '
315 << setw(14) << setprecision(3) << xyzc[2] << ' '
316 << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
317 }
318 break;
319 }
320 else {
321 t_pppSatObs* satObs = obsVector.at(maxResIndex);
322 LOG << "t_pppClient::cmpBancroft outlier " << satObs->prn().toString()
323 << " " << maxRes << endl;
324 delete satObs;
325 obsVector.erase(obsVector.begin() + maxResIndex);
326 }
327 }
328
329 return success;
330}
331
332// Compute A Priori GPS-Glonass Offset
333//////////////////////////////////////////////////////////////////////////////
334double t_pppClient::cmpOffGG(vector<t_pppSatObs*>& obsVector) {
335
336 t_lc::type tLC = t_lc::dummy;
337 double offGG = 0.0;
338
339 if (_opt->useSystem('R')) {
340 while (obsVector.size() > 0) {
341 offGG = 0.0;
342 double maxRes = 0.0;
343 int maxResIndex = -1;
344 t_prn maxResPrn;
345 unsigned nObs = 0;
346 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
347 const t_pppSatObs* satObs = obsVector.at(ii);
348 if (satObs->prn().system() == 'R') {
349 if (tLC == t_lc::dummy) {
350 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
351 }
352 if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
353 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
354 ++nObs;
355 offGG += ll;
356 if (fabs(ll) > fabs(maxRes)) {
357 maxRes = ll;
358 maxResIndex = ii;
359 maxResPrn = satObs->prn();
360 }
361 }
362 }
363 }
364
365 if (nObs > 0) {
366 offGG = offGG / nObs;
367 }
368 else {
369 offGG = 0.0;
370 }
371
372 if (fabs(maxRes) > 1000.0) {
373 LOG << "t_pppClient::cmpOffGG outlier " << maxResPrn.toString() << " " << maxRes << endl;
374 delete obsVector.at(maxResIndex);
375 obsVector.erase(obsVector.begin() + maxResIndex);
376 }
377 else {
378 break;
379 }
380 }
381 }
382 return offGG;
383}
384
385// Compute A Priori GPS-BDS Offset
386//////////////////////////////////////////////////////////////////////////////
387double t_pppClient::cmpOffGB(vector<t_pppSatObs*>& obsVector) {
388
389 t_lc::type tLC = t_lc::dummy;
390 double offGB = 0.0;
391
392 if (_opt->useSystem('C')) {
393 while (obsVector.size() > 0) {
394 offGB = 0.0;
395 double maxRes = 0.0;
396 int maxResIndex = -1;
397 t_prn maxResPrn;
398 unsigned nObs = 0;
399 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
400 const t_pppSatObs* satObs = obsVector.at(ii);
401 if (satObs->prn().system() == 'C') {
402 if (tLC == t_lc::dummy) {
403 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
404 }
405 if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
406 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
407 ++nObs;
408 offGB += ll;
409 if (fabs(ll) > fabs(maxRes)) {
410 maxRes = ll;
411 maxResIndex = ii;
412 maxResPrn = satObs->prn();
413 }
414 }
415 }
416 }
417
418 if (nObs > 0) {
419 offGB = offGB / nObs;
420 }
421 else {
422 offGB = 0.0;
423 }
424
425 if (fabs(maxRes) > 1000.0) {
426 LOG << "t_pppClient::cmpOffGB outlier " << maxResPrn.toString() << " " << maxRes << endl;
427 delete obsVector.at(maxResIndex);
428 obsVector.erase(obsVector.begin() + maxResIndex);
429 }
430 else {
431 break;
432 }
433 }
434 }
435 return offGB;
436}
437
438//
439//////////////////////////////////////////////////////////////////////////////
440void t_pppClient::initOutput(t_output* output) {
441 _output = output;
442 _output->_numSat = 0;
443 _output->_hDop = 0.0;
444 _output->_error = false;
445}
446
447//
448//////////////////////////////////////////////////////////////////////////////
449void t_pppClient::clearObs() {
450 for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
451 delete _obsRover.at(ii);
452 }
453 _obsRover.clear();
454}
455
456//
457//////////////////////////////////////////////////////////////////////////////
458void t_pppClient::finish(t_irc irc) {
459
460 clearObs();
461
462 _output->_epoTime = _epoTimeRover;
463
464 if (irc == success) {
465 _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
466 _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
467 _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
468
469 xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
470
471 copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
472
473 _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
474 _output->_trp = _filter->trp();
475 _output->_trpStdev = _filter->trpStdev();
476
477 _output->_numSat = _filter->numSat();
478 _output->_hDop = _filter->HDOP();
479 _output->_error = false;
480 }
481 else {
482 _output->_error = true;
483 }
484 _output->_log = _log->str();
485 delete _log; _log = new ostringstream();
486}
487
488//
489//////////////////////////////////////////////////////////////////////////////
490t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
491 vector<t_pppSatObs*>& obsVector) {
492 bncTime time;
493 time = _epoTimeRover;
494 station->setName(_opt->_roverName);
495 station->setAntName(_opt->_antNameRover);
496 station->setEpochTime(time);
497 if (_opt->xyzAprRoverSet()) {
498 station->setXyzApr(_opt->_xyzAprRover);
499 }
500 else {
501 station->setXyzApr(xyzc.Rows(1,3));
502 }
503 station->setNeuEcc(_opt->_neuEccRover);
504
505 // Receiver Clock
506 // --------------
507 station->setDClk(xyzc[3]);
508
509 // Tides
510 // -----
511 station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
512 station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
513
514 // Observation model
515 // -----------------
516 vector<t_pppSatObs*>::iterator it = obsVector.begin();
517 while (it != obsVector.end()) {
518 t_pppSatObs* satObs = *it;
519 t_irc modelSetup;
520 if (satObs->isValid()) {
521 modelSetup = satObs->cmpModel(station);
522 }
523 if (satObs->isValid() &&
524 satObs->eleSat() >= _opt->_minEle &&
525 modelSetup == success) {
526 ++it;
527 }
528 else {
529 delete satObs;
530 it = obsVector.erase(it);
531 }
532 }
533
534 return success;
535}
536
537//
538//////////////////////////////////////////////////////////////////////////////
539void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
540
541 _historicalRefSats.clear();
542 try {
543 initOutput(output);
544 int num = 0;
545 bool epochReProcessing = false;
546
547 do {
548 num++;
549 if (num == 1) {
550 LOG << "\nPPP of Epoch ";
551 if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
552 LOG << "\n---------------------------------------------------------------\n";
553 }
554
555 // Prepare Observations of the Rover
556 // ---------------------------------
557 if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
558 return finish(failure);
559 }
560
561 for (int iter = 1; iter <= 2; iter++) {
562 ColumnVector xyzc(4); xyzc = 0.0;
563 bool print = (iter == 2);
564 if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
565 return finish(failure);
566 }
567 if (cmpModel(_staRover, xyzc, _obsRover) != success) {
568 return finish(failure);
569 }
570 }
571
572 _offGG = cmpOffGG(_obsRover);
573 _offGB = cmpOffGB(_obsRover);
574
575 if (_opt->_refSatRequired) {
576 setRefSatellites(_obsRover);
577 LOG.setf(ios::fixed);
578 QMapIterator<char, t_pppRefSat*> it(_obsPool->getRefSatMap());
579 while (it.hasNext()) {
580 it.next();
581 char sys = it.key();
582 string prn = it.value()->prn().toString();
583 if (num == 1) {
584 LOG << "set ";
585 }
586 else {
587 LOG << "reset ";
588 }
589 LOG << string(_epoTimeRover) << " REFSAT " << sys << ": " << prn << endl;
590 }
591 }
592
593
594 // Prepare Pseudo Observations of the Rover
595 // ----------------------------------------
596 _pseudoObsIono = preparePseudoObs(_obsRover);
597
598 if (int(_obsRover.size()) < _opt->_minObs) {
599 LOG << "t_pppClient::processEpoch not enough observations" << endl;
600 return finish(failure);
601 }
602
603
604 // Store last epoch of data
605 // ------------------------
606 _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
607 _obsPool->setHistoricalRefSatList(_historicalRefSats);
608
609 // Process Epoch in Filter
610 // -----------------------
611 if (_filter->processEpoch(num) != success) {
612 return finish(failure);
613 }
614
615 // Epoch re-processing required?
616 // -----------------------------
617 if (_obsPool->refSatChangeRequired()) {
618 epochReProcessing = true;
619 _obsPool->deleteLastEpoch();
620 QMapIterator<char, t_pppRefSat*> it(_obsPool->getRefSatMap());
621 while (it.hasNext()) {
622 it.next();
623 _historicalRefSats.append(it.value()->prn());
624 }
625 }
626 else {
627 epochReProcessing = false;
628
629 }
630 } while (epochReProcessing);
631 }
632 catch (Exception& exc) {
633 LOG << exc.what() << endl;
634 return finish(failure);
635 }
636 catch (t_except msg) {
637 LOG << msg.what() << endl;
638 return finish(failure);
639 }
640 catch (const char* msg) {
641 LOG << msg << endl;
642 return finish(failure);
643 }
644 catch (...) {
645 LOG << "unknown exception" << endl;
646 return finish(failure);
647 }
648
649 return finish(success);
650}
651
652//
653////////////////////////////////////////////////////////////////////////////
654double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
655 return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
656}
657
658//
659////////////////////////////////////////////////////////////////////////////
660void t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
661
662 if (pos.Nrows() != 4) {
663 pos.ReSize(4);
664 }
665 pos = 0.0;
666
667 for (int iter = 1; iter <= 2; iter++) {
668 Matrix BB = BBpass;
669 int mm = BB.Nrows();
670 for (int ii = 1; ii <= mm; ii++) {
671 double xx = BB(ii,1);
672 double yy = BB(ii,2);
673 double traveltime = 0.072;
674 if (iter > 1) {
675 double zz = BB(ii,3);
676 double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
677 (yy-pos(2)) * (yy-pos(2)) +
678 (zz-pos(3)) * (zz-pos(3)) );
679 traveltime = rho / t_CST::c;
680 }
681 double angle = traveltime * t_CST::omega;
682 double cosa = cos(angle);
683 double sina = sin(angle);
684 BB(ii,1) = cosa * xx + sina * yy;
685 BB(ii,2) = -sina * xx + cosa * yy;
686 }
687
688 Matrix BBB;
689 if (mm > 4) {
690 SymmetricMatrix hlp; hlp << BB.t() * BB;
691 BBB = hlp.i() * BB.t();
692 }
693 else {
694 BBB = BB.i();
695 }
696 ColumnVector ee(mm); ee = 1.0;
697 ColumnVector alpha(mm); alpha = 0.0;
698 for (int ii = 1; ii <= mm; ii++) {
699 alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
700 }
701 ColumnVector BBBe = BBB * ee;
702 ColumnVector BBBalpha = BBB * alpha;
703 double aa = lorentz(BBBe, BBBe);
704 double bb = lorentz(BBBe, BBBalpha)-1;
705 double cc = lorentz(BBBalpha, BBBalpha);
706 double root = sqrt(bb*bb-aa*cc);
707
708 Matrix hlpPos(4,2);
709 hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
710 hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
711
712 ColumnVector omc(2);
713 for (int pp = 1; pp <= 2; pp++) {
714 hlpPos(4,pp) = -hlpPos(4,pp);
715 omc(pp) = BB(1,4) -
716 sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
717 (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
718 (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
719 hlpPos(4,pp);
720 }
721 if ( fabs(omc(1)) > fabs(omc(2)) ) {
722 pos = hlpPos.Column(2);
723 }
724 else {
725 pos = hlpPos.Column(1);
726 }
727 }
728}
729
730//
731//////////////////////////////////////////////////////////////////////////////
732void t_pppClient::setRefSatellites(std::vector<t_pppSatObs*>& obsVector) {
733
734 // reference satellite definition per system
735 for (unsigned iSys = 0; iSys < _opt->systems().size(); iSys++) {
736 char system = _opt->systems()[iSys];
737 bool refSatDefined = false;
738 t_pppRefSat* refSat = _obsPool->getRefSatMapElement(system);
739 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
740 t_pppSatObs* satObs = obsVector.at(ii);
741 if (satObs->eleSat() < _opt->_minEle) {continue;}
742 // reference satellite is unchanged
743 if (!_obsPool->refSatChangeRequired() && refSat->prn() == satObs->prn()) {
744 refSatDefined = true;
745 obsVector[ii]->setAsReference();
746 }
747 // reference satellite has changed
748 else if ( _obsPool->refSatChangeRequired() && refSat->prn() != satObs->prn() && !_historicalRefSats.contains(satObs->prn())) {
749 if (satObs->prn().system() == system) {
750 refSatDefined = true;
751 obsVector[ii]->setAsReference();
752 refSat->setPrn(satObs->prn());
753 }
754 }
755 if (refSatDefined) {
756 if (OPT->_pseudoObsIono) {
757 refSat->setStecValue(satObs->getIonoCodeDelay(t_frequency::G1));
758 }
759 break;
760 }
761 }
762 // reference satellite has to be initialized
763 if (!refSatDefined) {
764 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
765 t_pppSatObs* satObs = obsVector.at(ii);
766 if (satObs->eleSat() < _opt->_minEle) {
767 continue;
768 }
769 if (satObs->prn().system() == system) {
770 obsVector[ii]->setAsReference();
771 refSat->setPrn(satObs->prn());
772 if (OPT->_pseudoObsIono) {
773 refSat->setStecValue(satObs->getIonoCodeDelay(t_frequency::G1));
774 }
775 refSatDefined = true;
776 break;
777 }
778 }
779 }
780 }
781 _obsPool->setRefSatChangeRequired(false);
782
783}
784
785//
786//////////////////////////////////////////////////////////////////////////////
787void t_pppClient::reset() {
788
789 // to delete old orbit and clock corrections
790 delete _ephPool;
791 _ephPool = new t_pppEphPool();
792
793 // to delete old code biases
794 delete _obsPool;
795 _obsPool = new t_pppObsPool();
796
797 // to delete all parameters
798 delete _filter;
799 _filter = new t_pppFilter(_obsPool);
800
801}
Note: See TracBrowser for help on using the repository browser.