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

Last change on this file since 11041 was 11041, checked in by stuerze, 2 days ago

updates regarding RTCM-SSR

  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 22.1 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 _running = true;
52 _output = 0;
53 _opt = new t_pppOptions(*opt);
54 _log = new ostringstream();
55 _ephPool = new t_pppEphPool();
56 _obsPool = new t_pppObsPool();
57 _staRover = new t_pppStation();
58 _filter = new t_pppFilter();
59 _tides = new t_tides();
60 _antex = 0;
61 if (!_opt->_antexFileName.empty()) {
62 _antex = new bncAntex(_opt->_antexFileName.c_str());
63 }
64 if (!_opt->_blqFileName.empty()) {
65 if (_tides->readBlqFile(_opt->_blqFileName.c_str()) == success) {
66 //_tides->printAllBlqSets();
67 }
68 }
69 CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
70}
71
72// Destructor
73//////////////////////////////////////////////////////////////////////////////
74t_pppClient::~t_pppClient() {
75 _running = false;
76 delete _log;
77 delete _opt;
78 delete _ephPool;
79 delete _obsPool;
80 delete _staRover;
81 if (_antex) {
82 delete _antex;
83 }
84 delete _filter;
85 delete _tides;
86 clearObs();
87}
88
89//
90//////////////////////////////////////////////////////////////////////////////
91void t_pppClient::putEphemeris(const t_eph* eph) {
92 const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
93 const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
94 const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
95 const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
96 if (ephGPS) {
97 _ephPool->putEphemeris(new t_ephGPS(*ephGPS));
98 }
99 else if (ephGlo) {
100 _ephPool->putEphemeris(new t_ephGlo(*ephGlo));
101 }
102 else if (ephGal) {
103 _ephPool->putEphemeris(new t_ephGal(*ephGal));
104 }
105 else if (ephBDS) {
106 _ephPool->putEphemeris(new t_ephBDS(*ephBDS));
107 }
108}
109
110//
111//////////////////////////////////////////////////////////////////////////////
112void t_pppClient::putTec(const t_vTec* vTec) {
113 _obsPool->putTec(new t_vTec(*vTec));
114}
115
116//
117//////////////////////////////////////////////////////////////////////////////
118void t_pppClient::putMetaData(const t_metaData* metaData) {
119 _obsPool->putMetaData(new t_metaData(*metaData));
120}
121
122//
123//////////////////////////////////////////////////////////////////////////////
124void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) {
125 if (OPT->_logMode == t_pppOptions::normal && corr.size() > 0) {
126 LOG << "orbCorrections " << string(corr[0]->_time) << ' ' << corr.size() << endl;
127 }
128 for (unsigned ii = 0; ii < corr.size(); ii++) {
129 _ephPool->putOrbCorrection(new t_orbCorr(*corr[ii]));
130 }
131}
132
133//
134//////////////////////////////////////////////////////////////////////////////
135void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) {
136 if (OPT->_logMode == t_pppOptions::normal && corr.size() > 0) {
137 LOG << "clkCorrections " << string(corr[0]->_time) << ' ' << corr.size() << endl;
138 }
139 for (unsigned ii = 0; ii < corr.size(); ii++) {
140 _ephPool->putClkCorrection(new t_clkCorr(*corr[ii]));
141 }
142}
143
144//
145//////////////////////////////////////////////////////////////////////////////
146void t_pppClient::putCodeBiases(const vector<t_satCodeBias*>& biases) {
147 if (OPT->_logMode == t_pppOptions::normal && biases.size() > 0) {
148 LOG << "codeBiases " << string(biases[0]->_time) << ' ' << biases.size() << endl;
149 }
150 set<char> systems;
151 for (unsigned ii = 0; ii < biases.size(); ii++) {
152 t_satCodeBias* newBias = new t_satCodeBias(*biases[ii]);
153 char sys = newBias->_prn.system();
154 if (systems.find(sys) == systems.end()) {
155 _obsPool->clearCodeBiases(sys);
156 systems.insert(sys);
157 }
158 _obsPool->putCodeBias(newBias);
159 }
160}
161
162//
163//////////////////////////////////////////////////////////////////////////////
164void t_pppClient::putSatAntennas(const vector<t_satAntenna*>& satAntennas) {
165 if (OPT->_logMode == t_pppOptions::normal && satAntennas.size() > 0) {
166 LOG << "satAntennas " << string(satAntennas[0]->_time) << ' ' << satAntennas.size() << endl;
167 }
168 for (unsigned ii = 0; ii < satAntennas.size(); ii++) {
169 _obsPool->putSatAntenna(new t_satAntenna(*satAntennas[ii]));
170 }
171}
172
173//
174//////////////////////////////////////////////////////////////////////////////
175void t_pppClient::putPhaseBiases(const vector<t_satPhaseBias*>& biases) {
176 if (OPT->_logMode == t_pppOptions::normal && biases.size() > 0) {
177 LOG << "phaseBiases " << string(biases[0]->_time) << ' ' << biases.size() << endl;
178 }
179 set<char> systems;
180 for (unsigned ii = 0; ii < biases.size(); ii++) {
181 t_satPhaseBias* newBias = new t_satPhaseBias(*biases[ii]);
182 char sys = newBias->_prn.system();
183 if (systems.find(sys) == systems.end()) {
184 _obsPool->clearPhaseBiases(sys);
185 systems.insert(sys);
186 }
187 _obsPool->putPhaseBias(newBias);
188 }
189}
190
191//
192//////////////////////////////////////////////////////////////////////////////
193t_irc t_pppClient::prepareObs(const vector<t_satObs*>& satObs,
194 vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
195
196 // Default
197 // -------
198 epoTime.reset();
199 clearObs();
200
201 // Create vector of valid observations
202 // -----------------------------------
203 for (unsigned ii = 0; ii < satObs.size(); ii++) {
204 char sys = satObs[ii]->_prn.system();
205 if (_opt->useSystem(sys)) {
206 t_pppSatObs* pppSatObs = new t_pppSatObs(*satObs[ii]);
207 if (pppSatObs->isValid()) {
208 obsVector.push_back(pppSatObs);
209 }
210 else {
211 delete pppSatObs;
212 }
213 }
214 }
215
216 // Check whether data are synchronized, compute epoTime
217 // ----------------------------------------------------
218 const double MAXSYNC = 0.05; // synchronization limit
219 double meanDt = 0.0;
220 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
221 const t_pppSatObs* satObs = obsVector.at(ii);
222 if (epoTime.undef()) {
223 epoTime = satObs->time();
224 }
225 else {
226 double dt = satObs->time() - epoTime;
227 if (fabs(dt) > MAXSYNC) {
228 LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
229 return failure;
230 }
231 meanDt += dt;
232 }
233 }
234
235 if (obsVector.size() > 0) {
236 epoTime += meanDt / obsVector.size();
237 }
238
239 return success;
240}
241
242//
243//////////////////////////////////////////////////////////////////////////////
244bool t_pppClient::preparePseudoObs(std::vector<t_pppSatObs*>& obsVector) {
245
246 bool pseudoObsIono = false;
247
248 if (_opt->_pseudoObsIono) {
249
250 // Select reference satellite per system: keep the current one if still
251 // visible; only switch to highest elevation when the current one disappears
252 // -------------------------------------------------------------------------
253 map<char, t_pppSatObs*> refSatMap;
254 map<char, t_pppSatObs*> bestEleMap;
255 for (t_pppSatObs* satObs : obsVector) {
256 satObs->resetReference();
257 double stec = satObs->getIonoCodeDelay(t_frequency::G1);
258 if (stec == 0.0) continue;
259 char sys = satObs->prn().system();
260 if (!bestEleMap.count(sys) || satObs->eleSat() > bestEleMap[sys]->eleSat()) {
261 bestEleMap[sys] = satObs;
262 }
263 if (_refPrnMap.count(sys) && satObs->prn() == _refPrnMap[sys]) {
264 refSatMap[sys] = satObs;
265 }
266 }
267 for (auto& kv : bestEleMap) {
268 if (!refSatMap.count(kv.first)) {
269 refSatMap[kv.first] = kv.second;
270 }
271 }
272 for (auto& kv : refSatMap) {
273 _refPrnMap[kv.first] = kv.second->prn();
274 kv.second->setAsReference();
275 }
276
277 if (bestEleMap.empty()) {
278 LOG << "GIM pseudo-obs unavailable: no valid STEC (vTec data missing?)" << endl;
279 }
280
281 // Set STEC pseudo-observations (single-differenced vs reference satellite)
282 // -------------------------------------------------------------------------
283 int nGIM = 0;
284 for (t_pppSatObs* satObs : obsVector) {
285 char sys = satObs->prn().system();
286 double stecRefSat = refSatMap.count(sys)
287 ? refSatMap[sys]->getIonoCodeDelay(t_frequency::G1)
288 : 0.0;
289 if (satObs->setPseudoObsIono(t_frequency::G1, stecRefSat)) {
290 pseudoObsIono = true;
291 nGIM++;
292 }
293 }
294 if (nGIM > 0) {
295 LOG << "GIM pseudo-obs: " << nGIM << " satellites, ref:";
296 for (auto& kv : refSatMap) {
297 LOG << ' ' << kv.second->prn().toString();
298 }
299 LOG << endl;
300 }
301 }
302
303 if (OPT->_logMode == t_pppOptions::all) {
304 vector<t_pppSatObs*>::iterator it = obsVector.begin();
305 while (it != obsVector.end()) {
306 t_pppSatObs* satObs = *it;
307 satObs->printObsMinusComputed();
308 it++;
309 }
310 }
311 return pseudoObsIono;
312}
313
314// Compute the Bancroft position, check for blunders
315//////////////////////////////////////////////////////////////////////////////
316t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
317 vector<t_pppSatObs*>& obsVector,
318 ColumnVector& xyzc, bool print) {
319
320 int numBancroft = obsVector.size();
321
322 while (_running) {
323 Matrix BB(numBancroft, 4);
324 int iObs = -1;
325 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
326 const t_pppSatObs* satObs = obsVector.at(ii);
327 t_lc LC = satObs->rangeLC();
328 if ( satObs->isValid(LC) &&
329 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
330 ++iObs;
331 BB[iObs][0] = satObs->xc()[0];
332 BB[iObs][1] = satObs->xc()[1];
333 BB[iObs][2] = satObs->xc()[2];
334 BB[iObs][3] = satObs->obsValue(LC) - satObs->cmpValueForBanc(LC);
335 }
336 }
337 if (iObs + 1 < _opt->_minObs) {
338 LOG << "t_pppClient::cmpBancroft not enough observations: " << iObs + 1 << endl;
339 return failure;
340 }
341 BB = BB.Rows(1,iObs+1);
342 if (bancroft(BB, xyzc) != success) {
343 return failure;
344 }
345
346 xyzc[3] /= t_CST::c;
347
348 // Check Blunders
349 // --------------
350 const double BLUNDER = 1500.0;
351 double maxRes = 0.0;
352 unsigned maxResIndex = 0;
353 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
354 const t_pppSatObs* satObs = obsVector.at(ii);
355 t_lc LC = satObs->rangeLC();
356 if (satObs->isValid(LC) &&
357 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
358 ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
359 double res = rr.NormFrobenius() - satObs->obsValue(LC)
360 - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
361 if (fabs(res) > maxRes) {
362 maxRes = fabs(res);
363 maxResIndex = ii;
364 }
365 }
366 }
367 if (maxRes < BLUNDER) {
368 if (print) {
369 LOG.setf(ios::fixed);
370 LOG << "\nPPP of Epoch ";
371 if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
372 LOG << " using " << _opt->_corrMount;
373 LOG << "\n---------------------------------------------------------------\n";
374 LOG << string(epoTime) << " BANCROFT: "
375 << setw(14) << setprecision(3) << xyzc[0] << ' '
376 << setw(14) << setprecision(3) << xyzc[1] << ' '
377 << setw(14) << setprecision(3) << xyzc[2] << ' '
378 << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
379 }
380 break;
381 }
382 else {
383 t_pppSatObs* satObs = obsVector.at(maxResIndex);
384 LOG << "t_pppClient::cmpBancroft Outlier " << satObs->prn().toString()
385 << " " << maxRes << endl;
386 delete satObs;
387 obsVector.erase(obsVector.begin() + maxResIndex);
388 }
389 }
390
391 return success;
392}
393
394//
395//////////////////////////////////////////////////////////////////////////////
396void t_pppClient::initOutput(t_output* output) {
397 _output = output;
398 _output->_numSat = 0;
399 _output->_hDop = 0.0;
400 _output->_error = false;
401}
402
403//
404//////////////////////////////////////////////////////////////////////////////
405void t_pppClient::clearObs() {
406 for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
407 delete _obsRover.at(ii);
408 }
409 _obsRover.clear();
410}
411
412//
413//////////////////////////////////////////////////////////////////////////////
414void t_pppClient::finish(t_irc irc, int ind) {
415#ifdef BNC_DEBUG_PPP
416 LOG << "t_pppClient::finish(" << ind << "): " << irc << endl;
417#endif
418
419 clearObs();
420
421 _output->_epoTime = _epoTimeRover;
422
423 if (irc == success) {
424 _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
425 _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
426 _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
427
428 xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
429
430 copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
431
432 _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
433 _output->_trp = _filter->trp();
434 _output->_trpStdev = _filter->trpStdev();
435
436 _output->_fixRatio = _filter->fixRatio();
437
438 _output->_numSat = _filter->numSat();
439 _output->_hDop = _filter->HDOP();
440 _output->_error = false;
441 }
442 else {
443 _output->_error = true;
444 }
445
446 _output->_log = _log->str();
447 delete _log; _log = new ostringstream();
448
449 return;
450}
451
452//
453//////////////////////////////////////////////////////////////////////////////
454t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
455 vector<t_pppSatObs*>& obsVector) {
456 bncTime time;
457 time = _epoTimeRover;
458 station->setName(_opt->_roverName);
459 station->setAntName(_opt->_antNameRover);
460 station->setEpochTime(time);
461
462 if (_opt->xyzAprRoverSet()) {
463 if (_opt->_refEpochRover != 0.0) {
464 double dt = decimalYear(time) - _opt->_refEpochRover;
465 station->setXyzApr(_opt->_xyzAprRover + dt * _opt->_velRover);
466 }
467 else {
468 station->setXyzApr(_opt->_xyzAprRover);
469 }
470 }
471 else {
472 station->setXyzApr(xyzc.Rows(1,3));
473 }
474 station->setNeuEcc(_opt->_neuEccRover);
475
476 // Receiver Clock
477 // --------------
478 station->setDClk(xyzc[3]);
479
480 // Tides
481 // -----
482 // RTCM-SSR Metadata (model correction type 3 = solid earth tides) tells us
483 // whether - and with which model - the correction stream's generation
484 // system already accounted for solid earth tides. To stay consistent with
485 // the orbit/clock corrections, mirror that choice here: skip our own
486 // correction if the provider applied none, apply our default model if the
487 // provider used its own default, and fall back to our default (with a
488 // warning) if the provider used some other, unsupported model - we have no
489 // way to reproduce an unknown model exactly. Absent any Metadata message
490 // (e.g. RTNET or older streams), keep today's unconditional behavior.
491 bool applyEarthTide = true;
492 const t_metaData* metaData = _obsPool->metaData();
493 if (metaData) {
494 for (unsigned ii = 0; ii < metaData->_entries.size(); ii++) {
495 const t_metaDataEntry& entry = metaData->_entries[ii];
496 if (entry._typeIndicator == 3) { // solid earth tides
497 if (!entry._applicationIndicator) {
498 applyEarthTide = false;
499 }
500 else if (entry._nonDefaultIndicator) {
501 LOG << "WARNING: SSR Metadata signals a non-default solid earth "
502 << "tide model (identifier " << entry._nonDefaultIdentifier
503 << "); applying BNC's default model anyway, results may be "
504 << "inconsistent" << endl;
505 }
506 break;
507 }
508 }
509 }
510 if (applyEarthTide) {
511 station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
512 }
513 else {
514 ColumnVector tideDsplEarth(3); tideDsplEarth = 0.0;
515 station->setTideDsplEarth(tideDsplEarth);
516 }
517 station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
518
519 // Observation model
520 // -----------------
521 vector<t_pppSatObs*>::iterator it = obsVector.begin();
522 while (it != obsVector.end()) {
523 t_pppSatObs* satObs = *it;
524 t_irc modelSetup;
525 if (satObs->isValid()) {
526 modelSetup = satObs->cmpModel(station);
527 }
528 if (satObs->isValid() &&
529 satObs->eleSat() >= _opt->_minEle &&
530 modelSetup == success) {
531 ++it;
532 }
533 else {
534 delete satObs;
535 it = obsVector.erase(it);
536 }
537 }
538
539 return success;
540}
541
542//
543//////////////////////////////////////////////////////////////////////////////
544void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
545
546 try {
547 initOutput(output);
548
549 // Prepare Observations of the Rover
550 // ---------------------------------
551 if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
552 return finish(failure, 1);
553 }
554
555 for (int iter = 1; iter <= 2; iter++) {
556 ColumnVector xyzc(4); xyzc = 0.0;
557 bool print = (iter == 2);
558 if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
559 return finish(failure, 2);
560 }
561 if (cmpModel(_staRover, xyzc, _obsRover) != success) {
562 return finish(failure, 3);
563 }
564 }
565
566 // Use observations only if satellite code biases are available
567 // ------------------------------------------------------------
568 if (_opt->ambRes()) {
569 useObsWithBiasesOnly(_obsRover);
570 }
571
572 if (int(_obsRover.size()) < _opt->_minObs) {
573 LOG << "t_pppClient::processEpoch not enough observations" << endl;
574 return finish(failure, 4);
575 }
576
577 // Prepare Pseudo Observations of the Rover
578 // ----------------------------------------
579 _pseudoObsIono = preparePseudoObs(_obsRover);
580
581 // Store last epoch of data
582 // ------------------------
583 _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
584
585 // Process Epoch in Filter
586 // -----------------------
587 if (_filter->processEpoch(_obsPool) != success) {
588 LOG << "t_pppFilter::processEpoch() != success" << endl;
589 return finish(failure, 5);
590 }
591 }
592 catch (Exception& exc) {
593 LOG << exc.what() << endl;
594 return finish(failure, 6);
595 }
596 catch (t_except msg) {
597 LOG << msg.what() << endl;
598 return finish(failure, 7);
599 }
600 catch (const char* msg) {
601 LOG << msg << endl;
602 return finish(failure, 8);
603 }
604 catch (...) {
605 LOG << "unknown exception" << endl;
606 return finish(failure, 9);
607 }
608 return finish(success, 0);
609}
610
611//
612////////////////////////////////////////////////////////////////////////////
613double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
614 return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
615}
616
617//
618////////////////////////////////////////////////////////////////////////////
619t_irc t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
620
621 if (pos.Nrows() != 4) {
622 pos.ReSize(4);
623 }
624 pos = 0.0;
625
626 for (int iter = 1; iter <= 2; iter++) {
627 Matrix BB = BBpass;
628 int mm = BB.Nrows();
629 for (int ii = 1; ii <= mm; ii++) {
630 double xx = BB(ii,1);
631 double yy = BB(ii,2);
632 double traveltime = 0.072;
633 if (iter > 1) {
634 double zz = BB(ii,3);
635 double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
636 (yy-pos(2)) * (yy-pos(2)) +
637 (zz-pos(3)) * (zz-pos(3)) );
638 traveltime = rho / t_CST::c;
639 }
640 double angle = traveltime * t_CST::omega;
641 double cosa = cos(angle);
642 double sina = sin(angle);
643 BB(ii,1) = cosa * xx + sina * yy;
644 BB(ii,2) = -sina * xx + cosa * yy;
645 }
646
647 Matrix BBB;
648 if (mm > 4) {
649 SymmetricMatrix hlp; hlp << BB.t() * BB;
650 BBB = hlp.i() * BB.t();
651 }
652 else {
653 BBB = BB.i();
654 }
655 ColumnVector ee(mm); ee = 1.0;
656 ColumnVector alpha(mm); alpha = 0.0;
657 for (int ii = 1; ii <= mm; ii++) {
658 alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
659 }
660 ColumnVector BBBe = BBB * ee;
661 ColumnVector BBBalpha = BBB * alpha;
662 double aa = lorentz(BBBe, BBBe);
663 double bb = lorentz(BBBe, BBBalpha)-1;
664 double cc = lorentz(BBBalpha, BBBalpha);
665 double root = sqrt(bb*bb-aa*cc);
666
667 Matrix hlpPos(4,2);
668 hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
669 hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
670
671 ColumnVector omc(2);
672 for (int pp = 1; pp <= 2; pp++) {
673 hlpPos(4,pp) = -hlpPos(4,pp);
674 omc(pp) = BB(1,4) -
675 sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
676 (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
677 (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
678 hlpPos(4,pp);
679 }
680 if ( fabs(omc(1)) > fabs(omc(2)) ) {
681 pos = hlpPos.Column(2);
682 }
683 else {
684 pos = hlpPos.Column(1);
685 }
686 }
687 if (pos.size() != 4 ||
688 std::isnan(pos(1)) ||
689 std::isnan(pos(2)) ||
690 std::isnan(pos(3)) ||
691 std::isnan(pos(4))) {
692 return failure;
693 }
694
695 return success;
696}
697
698//
699//////////////////////////////////////////////////////////////////////////////
700void t_pppClient::reset() {
701
702 LOG << "pppClient: reset" << endl;
703 _refPrnMap.clear();
704 // to delete old orbit and clock corrections
705 delete _ephPool;
706 _ephPool = new t_pppEphPool();
707
708 // to delete old biases
709 delete _obsPool;
710 _obsPool = new t_pppObsPool();
711
712 // to delete all parameters
713 delete _filter;
714 _filter = new t_pppFilter();
715
716}
717
718//
719//////////////////////////////////////////////////////////////////////////////
720void t_pppClient::useObsWithBiasesOnly(vector<t_pppSatObs*>& obsVector) const {
721 vector<t_pppSatObs*>::iterator it = obsVector.begin();
722 while (it != obsVector.end()) {
723 t_pppSatObs* pppSatObs = *it;
724 if (pppSatObs->hasBiases()) {
725 ++it;
726 }
727 else {
728 LOG << "t_pppClient::useObsWithBiasesOnly: no biases: " << pppSatObs->prn().toString().c_str() << endl;
729 it = obsVector.erase(it);
730 delete pppSatObs;
731 }
732 }
733}
Note: See TracBrowser for help on using the repository browser.