[7237] | 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 | *
|
---|
[7271] | 13 | * Changes:
|
---|
[7237] | 14 | *
|
---|
| 15 | * -----------------------------------------------------------------------*/
|
---|
| 16 |
|
---|
| 17 | #include <QThreadStorage>
|
---|
| 18 |
|
---|
| 19 | #include <iostream>
|
---|
| 20 | #include <iomanip>
|
---|
[8451] | 21 | #include <cmath>
|
---|
[7237] | 22 | #include <string.h>
|
---|
| 23 | #include <stdexcept>
|
---|
| 24 |
|
---|
| 25 | #include "pppClient.h"
|
---|
| 26 | #include "pppEphPool.h"
|
---|
| 27 | #include "pppObsPool.h"
|
---|
| 28 | #include "bncconst.h"
|
---|
| 29 | #include "bncutils.h"
|
---|
| 30 | #include "pppStation.h"
|
---|
| 31 | #include "bncantex.h"
|
---|
| 32 | #include "pppFilter.h"
|
---|
| 33 |
|
---|
| 34 | using namespace BNC_PPP;
|
---|
| 35 | using namespace std;
|
---|
| 36 |
|
---|
| 37 | // Global variable holding thread-specific pointers
|
---|
| 38 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 39 | QThreadStorage<t_pppClient*> CLIENTS;
|
---|
| 40 |
|
---|
| 41 | // Static function returning thread-specific pointer
|
---|
| 42 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 43 | t_pppClient* t_pppClient::instance() {
|
---|
| 44 | return CLIENTS.localData();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | // Constructor
|
---|
| 48 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 49 | t_pppClient::t_pppClient(const t_pppOptions* opt) {
|
---|
| 50 | _output = 0;
|
---|
| 51 | _opt = new t_pppOptions(*opt);
|
---|
| 52 | _log = new ostringstream();
|
---|
| 53 | _ephPool = new t_pppEphPool();
|
---|
| 54 | _obsPool = new t_pppObsPool();
|
---|
| 55 | _staRover = new t_pppStation();
|
---|
[8905] | 56 | _filter = new t_pppFilter(_obsPool);
|
---|
[7237] | 57 | _tides = new t_tides();
|
---|
[8905] | 58 | _antex = 0;
|
---|
[7237] | 59 | if (!_opt->_antexFileName.empty()) {
|
---|
| 60 | _antex = new bncAntex(_opt->_antexFileName.c_str());
|
---|
| 61 | }
|
---|
[8905] | 62 | if (!_opt->_blqFileName.empty()) {
|
---|
| 63 | if (_tides->readBlqFile(_opt->_blqFileName.c_str()) == success) {
|
---|
| 64 | //_tides->printAllBlqSets();
|
---|
| 65 | }
|
---|
[7237] | 66 | }
|
---|
[7996] | 67 |
|
---|
[8910] | 68 | if (_opt->_refSatRequired) {
|
---|
[8912] | 69 | for (unsigned iSys = 0; iSys < _opt->systems().size(); iSys++) {
|
---|
[9508] | 70 | char sys = _opt->systems()[iSys];
|
---|
| 71 | _refSatMap[sys] = new t_pppRefSat();
|
---|
[8905] | 72 | }
|
---|
[7972] | 73 | }
|
---|
[9419] | 74 |
|
---|
[10003] | 75 | _offGlo = 0.0;
|
---|
| 76 | _offGal = 0.0;
|
---|
| 77 | _offBds = 0.0;
|
---|
[7237] | 78 | CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | // Destructor
|
---|
| 82 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 83 | t_pppClient::~t_pppClient() {
|
---|
| 84 | delete _log;
|
---|
| 85 | delete _opt;
|
---|
[8905] | 86 | delete _filter;
|
---|
[7237] | 87 | delete _ephPool;
|
---|
| 88 | delete _obsPool;
|
---|
| 89 | delete _staRover;
|
---|
[7866] | 90 | if (_antex) {
|
---|
| 91 | delete _antex;
|
---|
| 92 | }
|
---|
[7237] | 93 | delete _tides;
|
---|
| 94 | clearObs();
|
---|
[9508] | 95 | QMapIterator<char, t_pppRefSat*> it(_refSatMap);
|
---|
| 96 | while (it.hasNext()) {
|
---|
| 97 | it.next();
|
---|
| 98 | delete it.value();
|
---|
| 99 | }
|
---|
| 100 | _refSatMap.clear();
|
---|
[7237] | 101 | }
|
---|
| 102 |
|
---|
[7271] | 103 | //
|
---|
[7237] | 104 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 105 | void t_pppClient::putEphemeris(const t_eph* eph) {
|
---|
| 106 | const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
|
---|
| 107 | const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
|
---|
| 108 | const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
|
---|
[7271] | 109 | const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
|
---|
[7237] | 110 | if (ephGPS) {
|
---|
| 111 | _ephPool->putEphemeris(new t_ephGPS(*ephGPS));
|
---|
| 112 | }
|
---|
| 113 | else if (ephGlo) {
|
---|
| 114 | _ephPool->putEphemeris(new t_ephGlo(*ephGlo));
|
---|
| 115 | }
|
---|
| 116 | else if (ephGal) {
|
---|
| 117 | _ephPool->putEphemeris(new t_ephGal(*ephGal));
|
---|
| 118 | }
|
---|
[7271] | 119 | else if (ephBDS) {
|
---|
| 120 | _ephPool->putEphemeris(new t_ephBDS(*ephBDS));
|
---|
| 121 | }
|
---|
[7237] | 122 | }
|
---|
| 123 |
|
---|
| 124 | //
|
---|
| 125 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 126 | void t_pppClient::putTec(const t_vTec* vTec) {
|
---|
[7248] | 127 | _obsPool->putTec(new t_vTec(*vTec));
|
---|
[7237] | 128 | }
|
---|
| 129 |
|
---|
[7271] | 130 | //
|
---|
[7237] | 131 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 132 | void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) {
|
---|
| 133 | for (unsigned ii = 0; ii < corr.size(); ii++) {
|
---|
| 134 | _ephPool->putOrbCorrection(new t_orbCorr(*corr[ii]));
|
---|
| 135 | }
|
---|
| 136 | }
|
---|
| 137 |
|
---|
[7271] | 138 | //
|
---|
[7237] | 139 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 140 | void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) {
|
---|
| 141 | for (unsigned ii = 0; ii < corr.size(); ii++) {
|
---|
| 142 | _ephPool->putClkCorrection(new t_clkCorr(*corr[ii]));
|
---|
| 143 | }
|
---|
| 144 | }
|
---|
| 145 |
|
---|
[7271] | 146 | //
|
---|
[7237] | 147 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 148 | void t_pppClient::putCodeBiases(const vector<t_satCodeBias*>& biases) {
|
---|
| 149 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
| 150 | _obsPool->putCodeBias(new t_satCodeBias(*biases[ii]));
|
---|
| 151 | }
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | //
|
---|
| 155 | //////////////////////////////////////////////////////////////////////////////
|
---|
[7288] | 156 | void t_pppClient::putPhaseBiases(const vector<t_satPhaseBias*>& biases) {
|
---|
| 157 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
| 158 | _obsPool->putPhaseBias(new t_satPhaseBias(*biases[ii]));
|
---|
| 159 | }
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | //
|
---|
| 163 | //////////////////////////////////////////////////////////////////////////////
|
---|
[7237] | 164 | t_irc t_pppClient::prepareObs(const vector<t_satObs*>& satObs,
|
---|
| 165 | vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
|
---|
[8905] | 166 |
|
---|
[7271] | 167 | // Default
|
---|
[7237] | 168 | // -------
|
---|
| 169 | epoTime.reset();
|
---|
[8956] | 170 | clearObs();
|
---|
[7237] | 171 |
|
---|
| 172 | // Create vector of valid observations
|
---|
| 173 | // -----------------------------------
|
---|
| 174 | for (unsigned ii = 0; ii < satObs.size(); ii++) {
|
---|
[9567] | 175 | char sys = satObs[ii]->_prn.system();
|
---|
| 176 | if (_opt->useSystem(sys)) {
|
---|
[7237] | 177 | t_pppSatObs* pppSatObs = new t_pppSatObs(*satObs[ii]);
|
---|
| 178 | if (pppSatObs->isValid()) {
|
---|
| 179 | obsVector.push_back(pppSatObs);
|
---|
| 180 | }
|
---|
| 181 | else {
|
---|
| 182 | delete pppSatObs;
|
---|
| 183 | }
|
---|
| 184 | }
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | // Check whether data are synchronized, compute epoTime
|
---|
| 188 | // ----------------------------------------------------
|
---|
| 189 | const double MAXSYNC = 0.05; // synchronization limit
|
---|
| 190 | double meanDt = 0.0;
|
---|
| 191 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 192 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
| 193 | if (epoTime.undef()) {
|
---|
| 194 | epoTime = satObs->time();
|
---|
| 195 | }
|
---|
| 196 | else {
|
---|
| 197 | double dt = satObs->time() - epoTime;
|
---|
| 198 | if (fabs(dt) > MAXSYNC) {
|
---|
| 199 | LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
|
---|
| 200 | return failure;
|
---|
| 201 | }
|
---|
| 202 | meanDt += dt;
|
---|
| 203 | }
|
---|
| 204 | }
|
---|
| 205 |
|
---|
| 206 | if (obsVector.size() > 0) {
|
---|
| 207 | epoTime += meanDt / obsVector.size();
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | return success;
|
---|
| 211 | }
|
---|
| 212 |
|
---|
[8905] | 213 | //
|
---|
| 214 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 215 | bool t_pppClient::preparePseudoObs(std::vector<t_pppSatObs*>& obsVector) {
|
---|
| 216 |
|
---|
| 217 | bool pseudoObsIono = false;
|
---|
| 218 |
|
---|
[8912] | 219 | if (_opt->_pseudoObsIono) {
|
---|
[8905] | 220 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
| 221 | while (it != obsVector.end()) {
|
---|
| 222 | t_pppSatObs* satObs = *it;
|
---|
[9508] | 223 | char sys = satObs->prn().system();
|
---|
| 224 | t_pppRefSat* refSat = _refSatMap[sys];
|
---|
[8905] | 225 | double stecRef = refSat->stecValue();
|
---|
| 226 | if (stecRef && !satObs->isReference()) {
|
---|
| 227 | pseudoObsIono = true;
|
---|
| 228 | satObs->setPseudoObsIono(t_frequency::G1, stecRef);
|
---|
| 229 | }
|
---|
| 230 | it++;
|
---|
| 231 | }
|
---|
| 232 | }
|
---|
[9538] | 233 |
|
---|
[8961] | 234 | /*
|
---|
| 235 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
| 236 | while (it != obsVector.end()) {
|
---|
| 237 | t_pppSatObs* satObs = *it;
|
---|
| 238 | satObs->printObsMinusComputed();
|
---|
| 239 | it++;
|
---|
| 240 | }
|
---|
| 241 | */
|
---|
[8905] | 242 | return pseudoObsIono;
|
---|
| 243 | }
|
---|
| 244 |
|
---|
[9560] | 245 | //
|
---|
| 246 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 247 | void t_pppClient::useObsWithCodeBiasesOnly(std::vector<t_pppSatObs*>& obsVector) {
|
---|
| 248 |
|
---|
| 249 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
| 250 | while (it != obsVector.end()) {
|
---|
| 251 | t_pppSatObs* pppSatObs = *it;
|
---|
| 252 | char sys = pppSatObs->prn().system();
|
---|
| 253 | bool codeBiasesAvailable = false;
|
---|
| 254 | t_frequency::type fType1 = t_lc::toFreq(sys,t_lc::c1);
|
---|
| 255 | t_frequency::type fType2 = t_lc::toFreq(sys,t_lc::c2);
|
---|
| 256 | if (pppSatObs->getCodeBias(fType1) &&
|
---|
| 257 | pppSatObs->getCodeBias(fType2)) {
|
---|
| 258 | codeBiasesAvailable = true;
|
---|
| 259 | }
|
---|
| 260 | if (codeBiasesAvailable) {
|
---|
| 261 | ++it;
|
---|
| 262 | }
|
---|
| 263 | else {
|
---|
| 264 | it = obsVector.erase(it);
|
---|
| 265 | delete pppSatObs;
|
---|
| 266 | }
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 | }
|
---|
| 270 |
|
---|
| 271 |
|
---|
[7237] | 272 | // Compute the Bancroft position, check for blunders
|
---|
| 273 | //////////////////////////////////////////////////////////////////////////////
|
---|
[7271] | 274 | t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
|
---|
[7237] | 275 | vector<t_pppSatObs*>& obsVector,
|
---|
| 276 | ColumnVector& xyzc, bool print) {
|
---|
| 277 |
|
---|
| 278 | t_lc::type tLC = t_lc::dummy;
|
---|
| 279 |
|
---|
| 280 | while (true) {
|
---|
| 281 | Matrix BB(obsVector.size(), 4);
|
---|
| 282 | int iObs = -1;
|
---|
| 283 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 284 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
[8034] | 285 | if (tLC == t_lc::dummy) {
|
---|
| 286 | if (satObs->isValid(t_lc::cIF)) {
|
---|
| 287 | tLC = t_lc::cIF;
|
---|
[7237] | 288 | }
|
---|
[8034] | 289 | else if (satObs->isValid(t_lc::c1)) {
|
---|
| 290 | tLC = t_lc::c1;
|
---|
[7237] | 291 | }
|
---|
[8445] | 292 | else if (satObs->isValid(t_lc::c2)) {
|
---|
[8034] | 293 | tLC = t_lc::c2;
|
---|
| 294 | }
|
---|
[7237] | 295 | }
|
---|
[9600] | 296 | if ( satObs->isValid(tLC) &&
|
---|
| 297 | (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
|
---|
[8034] | 298 | ++iObs;
|
---|
| 299 | BB[iObs][0] = satObs->xc()[0];
|
---|
| 300 | BB[iObs][1] = satObs->xc()[1];
|
---|
| 301 | BB[iObs][2] = satObs->xc()[2];
|
---|
| 302 | BB[iObs][3] = satObs->obsValue(tLC) - satObs->cmpValueForBanc(tLC);
|
---|
| 303 | }
|
---|
[7237] | 304 | }
|
---|
[8912] | 305 | if (iObs + 1 < _opt->_minObs) {
|
---|
[9943] | 306 | LOG << "t_pppClient::cmpBancroft not enough observations: " << iObs + 1 << endl;
|
---|
[7237] | 307 | return failure;
|
---|
| 308 | }
|
---|
| 309 | BB = BB.Rows(1,iObs+1);
|
---|
[9600] | 310 | if (bancroft(BB, xyzc) != success) {
|
---|
| 311 | return failure;
|
---|
| 312 | }
|
---|
[7237] | 313 |
|
---|
| 314 | xyzc[3] /= t_CST::c;
|
---|
| 315 |
|
---|
| 316 | // Check Blunders
|
---|
| 317 | // --------------
|
---|
| 318 | const double BLUNDER = 100.0;
|
---|
| 319 | double maxRes = 0.0;
|
---|
| 320 | unsigned maxResIndex = 0;
|
---|
| 321 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 322 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
[8905] | 323 | if (satObs->isValid() &&
|
---|
[8912] | 324 | (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
|
---|
[7237] | 325 | ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
|
---|
[8905] | 326 | double res = rr.NormFrobenius() - satObs->obsValue(tLC)
|
---|
[8453] | 327 | - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
|
---|
[9600] | 328 | if (fabs(res) > maxRes) {
|
---|
| 329 | maxRes = fabs(res);
|
---|
[7237] | 330 | maxResIndex = ii;
|
---|
| 331 | }
|
---|
| 332 | }
|
---|
| 333 | }
|
---|
[9600] | 334 | if (maxRes < BLUNDER) {
|
---|
[9386] | 335 | if (print && _numEpoProcessing == 1) {
|
---|
[7237] | 336 | LOG.setf(ios::fixed);
|
---|
[9783] | 337 | LOG << "\nPPP of Epoch ";
|
---|
| 338 | if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
|
---|
| 339 | LOG << "\n---------------------------------------------------------------\n";
|
---|
[7237] | 340 | LOG << string(epoTime) << " BANCROFT:" << ' '
|
---|
| 341 | << setw(14) << setprecision(3) << xyzc[0] << ' '
|
---|
| 342 | << setw(14) << setprecision(3) << xyzc[1] << ' '
|
---|
| 343 | << setw(14) << setprecision(3) << xyzc[2] << ' '
|
---|
| 344 | << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
|
---|
| 345 | }
|
---|
| 346 | break;
|
---|
| 347 | }
|
---|
| 348 | else {
|
---|
| 349 | t_pppSatObs* satObs = obsVector.at(maxResIndex);
|
---|
| 350 | LOG << "t_pppClient::cmpBancroft outlier " << satObs->prn().toString()
|
---|
| 351 | << " " << maxRes << endl;
|
---|
| 352 | delete satObs;
|
---|
| 353 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
| 354 | }
|
---|
| 355 | }
|
---|
| 356 |
|
---|
| 357 | return success;
|
---|
| 358 | }
|
---|
[10002] | 359 | // Compute A Priori GPS-Glonass Offset
|
---|
| 360 | //////////////////////////////////////////////////////////////////////////////
|
---|
[10003] | 361 | double t_pppClient::cmpOffGlo(vector<t_pppSatObs*>& obsVector) {
|
---|
[7237] | 362 |
|
---|
[10002] | 363 | t_lc::type tLC = t_lc::dummy;
|
---|
[10003] | 364 | double offGlo = 0.0;
|
---|
[10002] | 365 |
|
---|
| 366 | if (OPT->useSystem('R')) {
|
---|
| 367 |
|
---|
| 368 | while (obsVector.size() > 0) {
|
---|
[10003] | 369 | offGlo = 0.0;
|
---|
[10002] | 370 | double maxRes = 0.0;
|
---|
| 371 | int maxResIndex = -1;
|
---|
| 372 | t_prn maxResPrn;
|
---|
| 373 | unsigned nObs = 0;
|
---|
| 374 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 375 | t_pppSatObs* satObs = obsVector.at(ii);
|
---|
| 376 | if (satObs->prn().system() == 'R') {
|
---|
| 377 | if (tLC == t_lc::dummy) {
|
---|
| 378 | tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
|
---|
| 379 | }
|
---|
| 380 | if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle)) {
|
---|
| 381 | double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
|
---|
| 382 | ++nObs;
|
---|
[10003] | 383 | offGlo += ll;
|
---|
[10002] | 384 | if (fabs(ll) > fabs(maxRes)) {
|
---|
| 385 | maxRes = ll;
|
---|
| 386 | maxResIndex = ii;
|
---|
| 387 | maxResPrn = satObs->prn();
|
---|
| 388 | }
|
---|
| 389 | }
|
---|
| 390 | }
|
---|
| 391 | }
|
---|
| 392 |
|
---|
| 393 | if (nObs > 0) {
|
---|
[10003] | 394 | offGlo = offGlo / nObs;
|
---|
[10002] | 395 | }
|
---|
| 396 | else {
|
---|
[10003] | 397 | offGlo = 0.0;
|
---|
[10002] | 398 | }
|
---|
| 399 |
|
---|
| 400 | if (fabs(maxRes) > 1000.0) {
|
---|
[10003] | 401 | LOG << "t_pppClient::cmpOffGlo outlier " << maxResPrn.toString() << " " << maxRes << endl;
|
---|
[10002] | 402 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
| 403 | }
|
---|
| 404 | else {
|
---|
| 405 | break;
|
---|
| 406 | }
|
---|
| 407 | }
|
---|
| 408 | }
|
---|
| 409 |
|
---|
[10003] | 410 | return offGlo;
|
---|
[10002] | 411 | }
|
---|
| 412 |
|
---|
[10003] | 413 | // Compute A Priori GPS-Galileo Offset
|
---|
| 414 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 415 | double t_pppClient::cmpOffGal(vector<t_pppSatObs*>& obsVector) {
|
---|
| 416 |
|
---|
| 417 | t_lc::type tLC = t_lc::dummy;
|
---|
| 418 | double offGal = 0.0;
|
---|
| 419 |
|
---|
| 420 | if (OPT->useSystem('E')) {
|
---|
| 421 |
|
---|
| 422 | while (obsVector.size() > 0) {
|
---|
| 423 | offGal = 0.0;
|
---|
| 424 | double maxRes = 0.0;
|
---|
| 425 | int maxResIndex = -1;
|
---|
| 426 | t_prn maxResPrn;
|
---|
| 427 | unsigned nObs = 0;
|
---|
| 428 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 429 | t_pppSatObs* satObs = obsVector.at(ii);
|
---|
| 430 | if (satObs->prn().system() == 'E') {
|
---|
| 431 | if (tLC == t_lc::dummy) {
|
---|
| 432 | tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
|
---|
| 433 | }
|
---|
| 434 | if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle)) {
|
---|
| 435 | double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
|
---|
| 436 | ++nObs;
|
---|
| 437 | offGal += ll;
|
---|
| 438 | if (fabs(ll) > fabs(maxRes)) {
|
---|
| 439 | maxRes = ll;
|
---|
| 440 | maxResIndex = ii;
|
---|
| 441 | maxResPrn = satObs->prn();
|
---|
| 442 | }
|
---|
| 443 | }
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 |
|
---|
| 447 | if (nObs > 0) {
|
---|
| 448 | offGal = offGal / nObs;
|
---|
| 449 | }
|
---|
| 450 | else {
|
---|
| 451 | offGal = 0.0;
|
---|
| 452 | }
|
---|
| 453 |
|
---|
| 454 | if (fabs(maxRes) > 1000.0) {
|
---|
| 455 | LOG << "t_pppClient::cmpOffGal outlier " << maxResPrn.toString() << " " << maxRes << endl;
|
---|
| 456 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
| 457 | }
|
---|
| 458 | else {
|
---|
| 459 | break;
|
---|
| 460 | }
|
---|
| 461 | }
|
---|
| 462 | }
|
---|
| 463 |
|
---|
| 464 | return offGal;
|
---|
| 465 | }
|
---|
| 466 |
|
---|
| 467 |
|
---|
| 468 | // Compute A Priori GPS-BDS Offset
|
---|
| 469 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 470 | double t_pppClient::cmpOffBds(vector<t_pppSatObs*>& obsVector) {
|
---|
| 471 |
|
---|
| 472 | t_lc::type tLC = t_lc::dummy;
|
---|
| 473 | double offBds = 0.0;
|
---|
| 474 |
|
---|
| 475 | if (_opt->useSystem('C')) {
|
---|
| 476 | while (obsVector.size() > 0) {
|
---|
| 477 | offBds = 0.0;
|
---|
| 478 | double maxRes = 0.0;
|
---|
| 479 | int maxResIndex = -1;
|
---|
| 480 | t_prn maxResPrn;
|
---|
| 481 | unsigned nObs = 0;
|
---|
| 482 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 483 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
| 484 | if (satObs->prn().system() == 'C') {
|
---|
| 485 | if (tLC == t_lc::dummy) {
|
---|
| 486 | tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
|
---|
| 487 | }
|
---|
| 488 | if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
|
---|
| 489 | double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
|
---|
| 490 | ++nObs;
|
---|
| 491 | offBds += ll;
|
---|
| 492 | if (fabs(ll) > fabs(maxRes)) {
|
---|
| 493 | maxRes = ll;
|
---|
| 494 | maxResIndex = ii;
|
---|
| 495 | maxResPrn = satObs->prn();
|
---|
| 496 | }
|
---|
| 497 | }
|
---|
| 498 | }
|
---|
| 499 | }
|
---|
| 500 |
|
---|
| 501 | if (nObs > 0) {
|
---|
| 502 | offBds = offBds / nObs;
|
---|
| 503 | }
|
---|
| 504 | else {
|
---|
| 505 | offBds = 0.0;
|
---|
| 506 | }
|
---|
| 507 |
|
---|
| 508 | if (fabs(maxRes) > 1000.0) {
|
---|
| 509 | LOG << "t_pppClient::cmpOffBds outlier " << maxResPrn.toString() << " " << maxRes << endl;
|
---|
| 510 | delete obsVector.at(maxResIndex);
|
---|
| 511 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
| 512 | }
|
---|
| 513 | else {
|
---|
| 514 | break;
|
---|
| 515 | }
|
---|
| 516 | }
|
---|
| 517 | }
|
---|
| 518 | return offBds;
|
---|
| 519 | }
|
---|
[7271] | 520 | //
|
---|
[7237] | 521 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 522 | void t_pppClient::initOutput(t_output* output) {
|
---|
| 523 | _output = output;
|
---|
| 524 | _output->_numSat = 0;
|
---|
[7927] | 525 | _output->_hDop = 0.0;
|
---|
[7237] | 526 | _output->_error = false;
|
---|
| 527 | }
|
---|
| 528 |
|
---|
[7271] | 529 | //
|
---|
[7237] | 530 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 531 | void t_pppClient::clearObs() {
|
---|
| 532 | for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
|
---|
| 533 | delete _obsRover.at(ii);
|
---|
| 534 | }
|
---|
| 535 | _obsRover.clear();
|
---|
| 536 | }
|
---|
| 537 |
|
---|
[7271] | 538 | //
|
---|
[7237] | 539 | //////////////////////////////////////////////////////////////////////////////
|
---|
[9585] | 540 | void t_pppClient::finish(t_irc irc, int ind) {
|
---|
[9783] | 541 | #ifdef BNC_DEBUG_PPP
|
---|
[9585] | 542 | LOG << "t_pppClient::finish(" << ind << "): " << irc << endl;
|
---|
[9783] | 543 | #endif
|
---|
[9585] | 544 |
|
---|
[7237] | 545 | clearObs();
|
---|
| 546 |
|
---|
| 547 | _output->_epoTime = _epoTimeRover;
|
---|
| 548 |
|
---|
| 549 | if (irc == success) {
|
---|
| 550 | _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
|
---|
| 551 | _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
|
---|
| 552 | _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
|
---|
| 553 |
|
---|
| 554 | xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
|
---|
| 555 |
|
---|
| 556 | copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
|
---|
| 557 |
|
---|
| 558 | _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
|
---|
| 559 | _output->_trp = _filter->trp();
|
---|
| 560 | _output->_trpStdev = _filter->trpStdev();
|
---|
| 561 |
|
---|
[9386] | 562 | _output->_numSat = _filter->numSat();
|
---|
| 563 | _output->_hDop = _filter->HDOP();
|
---|
[7237] | 564 | _output->_error = false;
|
---|
| 565 | }
|
---|
| 566 | else {
|
---|
| 567 | _output->_error = true;
|
---|
[9581] | 568 | if (OPT->_obsModelType == OPT->DCMcodeBias ||
|
---|
| 569 | OPT->_obsModelType == OPT->DCMphaseBias) {
|
---|
[9607] | 570 | if (ind == 1 || ind > 7) {
|
---|
| 571 | reset();
|
---|
| 572 | }
|
---|
[9581] | 573 | }
|
---|
[7237] | 574 | }
|
---|
| 575 | _output->_log = _log->str();
|
---|
| 576 | delete _log; _log = new ostringstream();
|
---|
[9545] | 577 |
|
---|
| 578 | return;
|
---|
[7237] | 579 | }
|
---|
| 580 |
|
---|
[7271] | 581 | //
|
---|
[7237] | 582 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 583 | t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
|
---|
| 584 | vector<t_pppSatObs*>& obsVector) {
|
---|
| 585 | bncTime time;
|
---|
| 586 | time = _epoTimeRover;
|
---|
[8912] | 587 | station->setName(_opt->_roverName);
|
---|
| 588 | station->setAntName(_opt->_antNameRover);
|
---|
[8905] | 589 | station->setEpochTime(time);
|
---|
[8912] | 590 | if (_opt->xyzAprRoverSet()) {
|
---|
| 591 | station->setXyzApr(_opt->_xyzAprRover);
|
---|
[7237] | 592 | }
|
---|
| 593 | else {
|
---|
| 594 | station->setXyzApr(xyzc.Rows(1,3));
|
---|
| 595 | }
|
---|
[8912] | 596 | station->setNeuEcc(_opt->_neuEccRover);
|
---|
[7237] | 597 |
|
---|
| 598 | // Receiver Clock
|
---|
| 599 | // --------------
|
---|
| 600 | station->setDClk(xyzc[3]);
|
---|
| 601 |
|
---|
| 602 | // Tides
|
---|
| 603 | // -----
|
---|
[8905] | 604 | station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
|
---|
| 605 | station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
|
---|
[7271] | 606 |
|
---|
[7237] | 607 | // Observation model
|
---|
| 608 | // -----------------
|
---|
| 609 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
| 610 | while (it != obsVector.end()) {
|
---|
| 611 | t_pppSatObs* satObs = *it;
|
---|
[7254] | 612 | t_irc modelSetup;
|
---|
[7237] | 613 | if (satObs->isValid()) {
|
---|
[7254] | 614 | modelSetup = satObs->cmpModel(station);
|
---|
[7237] | 615 | }
|
---|
[7254] | 616 | if (satObs->isValid() &&
|
---|
[8912] | 617 | satObs->eleSat() >= _opt->_minEle &&
|
---|
[7254] | 618 | modelSetup == success) {
|
---|
[7237] | 619 | ++it;
|
---|
| 620 | }
|
---|
| 621 | else {
|
---|
| 622 | delete satObs;
|
---|
| 623 | it = obsVector.erase(it);
|
---|
| 624 | }
|
---|
| 625 | }
|
---|
| 626 |
|
---|
| 627 | return success;
|
---|
| 628 | }
|
---|
| 629 |
|
---|
[7271] | 630 | //
|
---|
[7237] | 631 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 632 | void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
|
---|
| 633 |
|
---|
| 634 | try {
|
---|
| 635 | initOutput(output);
|
---|
[8912] | 636 | bool epochReProcessing = false;
|
---|
[9386] | 637 | _numEpoProcessing = 0;
|
---|
[9419] | 638 | _historicalRefSats.clear();
|
---|
| 639 |
|
---|
[8905] | 640 | do {
|
---|
[9386] | 641 | _numEpoProcessing++;
|
---|
[9419] | 642 | #ifdef BNC_DEBUG_PPP
|
---|
| 643 | LOG << "_numEpoProcessing " << _numEpoProcessing << endl;
|
---|
| 644 | #endif
|
---|
[9386] | 645 | if (_obsPool->refSatChanged()) {
|
---|
[9508] | 646 | if(_filter->datumTransformation(_refSatMap) != success) {
|
---|
| 647 | LOG << "t_pppFilter::datumTransformation() != success" << endl;
|
---|
[9545] | 648 | return finish(failure,1);
|
---|
[9386] | 649 | }
|
---|
| 650 | else {
|
---|
[9508] | 651 | LOG << "t_pppFilter::datumTransformation() == success" << endl;
|
---|
[9527] | 652 | _filter->rememberState(1);
|
---|
[9386] | 653 | }
|
---|
[8956] | 654 | }
|
---|
[8905] | 655 | // Prepare Observations of the Rover
|
---|
| 656 | // ---------------------------------
|
---|
| 657 | if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
|
---|
[9545] | 658 | return finish(failure,2);
|
---|
[7237] | 659 | }
|
---|
[8905] | 660 |
|
---|
| 661 | for (int iter = 1; iter <= 2; iter++) {
|
---|
| 662 | ColumnVector xyzc(4); xyzc = 0.0;
|
---|
| 663 | bool print = (iter == 2);
|
---|
| 664 | if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
|
---|
[9545] | 665 | return finish(failure,3);
|
---|
[8905] | 666 | }
|
---|
[9783] | 667 |
|
---|
[8905] | 668 | if (cmpModel(_staRover, xyzc, _obsRover) != success) {
|
---|
[9545] | 669 | return finish(failure,4);
|
---|
[8905] | 670 | }
|
---|
| 671 | }
|
---|
| 672 |
|
---|
[8912] | 673 | if (_opt->_refSatRequired) {
|
---|
[9386] | 674 | if (handleRefSatellites(_obsRover) != success) {
|
---|
[9545] | 675 | return finish(failure,6);
|
---|
[8905] | 676 | }
|
---|
[9508] | 677 | if (_obsPool->refSatChanged()) {
|
---|
| 678 | LOG << "t_pppFilter: refSatChanged()" << endl;
|
---|
[9527] | 679 | epochReProcessing = true;
|
---|
| 680 | continue;
|
---|
[9386] | 681 | }
|
---|
[8905] | 682 | }
|
---|
[7237] | 683 |
|
---|
[9565] | 684 | // use observations only if satellite code biases are available
|
---|
| 685 | // ------------------------------------------------------------
|
---|
[9783] | 686 | if (!_opt->_corrMount.empty() &&
|
---|
[9601] | 687 | (OPT->_obsModelType == OPT->DCMcodeBias ||
|
---|
| 688 | OPT->_obsModelType == OPT->DCMphaseBias)) {
|
---|
[9584] | 689 | useObsWithCodeBiasesOnly(_obsRover);
|
---|
| 690 | }
|
---|
[9560] | 691 |
|
---|
| 692 | if (int(_obsRover.size()) < _opt->_minObs) {
|
---|
| 693 | LOG << "t_pppClient::processEpoch not enough observations" << endl;
|
---|
| 694 | return finish(failure,5);
|
---|
| 695 | }
|
---|
| 696 |
|
---|
[10003] | 697 | _offGlo = cmpOffGlo(_obsRover);
|
---|
| 698 | _offGal = cmpOffGal(_obsRover);
|
---|
| 699 | _offBds = cmpOffBds(_obsRover);
|
---|
[10002] | 700 |
|
---|
[8956] | 701 | // Prepare Pseudo Observations of the Rover
|
---|
| 702 | // ----------------------------------------
|
---|
| 703 | _pseudoObsIono = preparePseudoObs(_obsRover);
|
---|
| 704 |
|
---|
[8905] | 705 | // Store last epoch of data
|
---|
| 706 | // ------------------------
|
---|
[9508] | 707 | _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono, _refSatMap);
|
---|
[7904] | 708 |
|
---|
[8905] | 709 | // Process Epoch in Filter
|
---|
| 710 | // -----------------------
|
---|
[9386] | 711 | if (_filter->processEpoch() != success) {
|
---|
[9545] | 712 | LOG << "filter->processEpoch() != success" << endl;
|
---|
| 713 | return finish(failure,7);
|
---|
[8905] | 714 | }
|
---|
[8912] | 715 |
|
---|
| 716 | // Epoch re-processing required?
|
---|
| 717 | // -----------------------------
|
---|
[9395] | 718 | if (_obsPool->refSatChangeRequired() && //SLIP
|
---|
| 719 | _opt->_obsModelType != t_pppOptions::UncombPPP) {
|
---|
[9545] | 720 | LOG << "pppClient: _obsPool->refSatChangeRequired() " << endl;
|
---|
[8912] | 721 | epochReProcessing = true;
|
---|
[8956] | 722 | _obsPool->deleteLastEpoch();
|
---|
[9527] | 723 | _filter->restoreState(0);
|
---|
[9386] | 724 | setHistoricalRefSats();
|
---|
[8912] | 725 | }
|
---|
| 726 | else {
|
---|
| 727 | epochReProcessing = false;
|
---|
[9537] | 728 | if (OPT->_obsModelType == OPT->DCMcodeBias ||
|
---|
| 729 | OPT->_obsModelType == OPT->DCMphaseBias) {
|
---|
| 730 | _filter->rememberState(0);
|
---|
| 731 | }
|
---|
[8912] | 732 | }
|
---|
| 733 | } while (epochReProcessing);
|
---|
[9431] | 734 |
|
---|
[7237] | 735 | }
|
---|
| 736 | catch (Exception& exc) {
|
---|
| 737 | LOG << exc.what() << endl;
|
---|
[9545] | 738 | return finish(failure,8);
|
---|
[7237] | 739 | }
|
---|
| 740 | catch (t_except msg) {
|
---|
| 741 | LOG << msg.what() << endl;
|
---|
[9545] | 742 | return finish(failure,9);
|
---|
[7237] | 743 | }
|
---|
| 744 | catch (const char* msg) {
|
---|
| 745 | LOG << msg << endl;
|
---|
[9545] | 746 | return finish(failure,10);
|
---|
[7237] | 747 | }
|
---|
| 748 | catch (...) {
|
---|
| 749 | LOG << "unknown exception" << endl;
|
---|
[9545] | 750 | return finish(failure,11);
|
---|
[7237] | 751 | }
|
---|
[9545] | 752 | return finish(success,12);
|
---|
[7237] | 753 | }
|
---|
| 754 |
|
---|
[7271] | 755 | //
|
---|
[7237] | 756 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 757 | double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
|
---|
| 758 | return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
|
---|
| 759 | }
|
---|
| 760 |
|
---|
[7271] | 761 | //
|
---|
[7237] | 762 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9600] | 763 | t_irc t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
|
---|
[7237] | 764 |
|
---|
| 765 | if (pos.Nrows() != 4) {
|
---|
| 766 | pos.ReSize(4);
|
---|
| 767 | }
|
---|
| 768 | pos = 0.0;
|
---|
| 769 |
|
---|
| 770 | for (int iter = 1; iter <= 2; iter++) {
|
---|
| 771 | Matrix BB = BBpass;
|
---|
| 772 | int mm = BB.Nrows();
|
---|
| 773 | for (int ii = 1; ii <= mm; ii++) {
|
---|
| 774 | double xx = BB(ii,1);
|
---|
| 775 | double yy = BB(ii,2);
|
---|
| 776 | double traveltime = 0.072;
|
---|
| 777 | if (iter > 1) {
|
---|
| 778 | double zz = BB(ii,3);
|
---|
[7271] | 779 | double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
|
---|
| 780 | (yy-pos(2)) * (yy-pos(2)) +
|
---|
[7237] | 781 | (zz-pos(3)) * (zz-pos(3)) );
|
---|
| 782 | traveltime = rho / t_CST::c;
|
---|
| 783 | }
|
---|
| 784 | double angle = traveltime * t_CST::omega;
|
---|
| 785 | double cosa = cos(angle);
|
---|
| 786 | double sina = sin(angle);
|
---|
| 787 | BB(ii,1) = cosa * xx + sina * yy;
|
---|
| 788 | BB(ii,2) = -sina * xx + cosa * yy;
|
---|
| 789 | }
|
---|
[7271] | 790 |
|
---|
[7237] | 791 | Matrix BBB;
|
---|
| 792 | if (mm > 4) {
|
---|
| 793 | SymmetricMatrix hlp; hlp << BB.t() * BB;
|
---|
| 794 | BBB = hlp.i() * BB.t();
|
---|
| 795 | }
|
---|
| 796 | else {
|
---|
| 797 | BBB = BB.i();
|
---|
| 798 | }
|
---|
| 799 | ColumnVector ee(mm); ee = 1.0;
|
---|
| 800 | ColumnVector alpha(mm); alpha = 0.0;
|
---|
| 801 | for (int ii = 1; ii <= mm; ii++) {
|
---|
[7271] | 802 | alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
|
---|
[7237] | 803 | }
|
---|
| 804 | ColumnVector BBBe = BBB * ee;
|
---|
| 805 | ColumnVector BBBalpha = BBB * alpha;
|
---|
| 806 | double aa = lorentz(BBBe, BBBe);
|
---|
| 807 | double bb = lorentz(BBBe, BBBalpha)-1;
|
---|
| 808 | double cc = lorentz(BBBalpha, BBBalpha);
|
---|
| 809 | double root = sqrt(bb*bb-aa*cc);
|
---|
| 810 |
|
---|
[7271] | 811 | Matrix hlpPos(4,2);
|
---|
[7237] | 812 | hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
|
---|
| 813 | hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
|
---|
| 814 |
|
---|
| 815 | ColumnVector omc(2);
|
---|
| 816 | for (int pp = 1; pp <= 2; pp++) {
|
---|
| 817 | hlpPos(4,pp) = -hlpPos(4,pp);
|
---|
[7271] | 818 | omc(pp) = BB(1,4) -
|
---|
[7237] | 819 | sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
|
---|
| 820 | (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
|
---|
[7271] | 821 | (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
|
---|
[7237] | 822 | hlpPos(4,pp);
|
---|
| 823 | }
|
---|
| 824 | if ( fabs(omc(1)) > fabs(omc(2)) ) {
|
---|
| 825 | pos = hlpPos.Column(2);
|
---|
| 826 | }
|
---|
| 827 | else {
|
---|
| 828 | pos = hlpPos.Column(1);
|
---|
| 829 | }
|
---|
| 830 | }
|
---|
[9600] | 831 | if (pos.size() != 4 ||
|
---|
| 832 | std::isnan(pos(1)) ||
|
---|
| 833 | std::isnan(pos(2)) ||
|
---|
| 834 | std::isnan(pos(3)) ||
|
---|
| 835 | std::isnan(pos(4))) {
|
---|
| 836 | return failure;
|
---|
| 837 | }
|
---|
| 838 |
|
---|
| 839 | return success;
|
---|
[7237] | 840 | }
|
---|
| 841 |
|
---|
[7972] | 842 | //
|
---|
| 843 | //////////////////////////////////////////////////////////////////////////////
|
---|
[8956] | 844 | void t_pppClient::setRefSatellites(std::vector<t_pppSatObs*>& obsVector) {
|
---|
| 845 | // reference satellite definition per system
|
---|
| 846 | for (unsigned iSys = 0; iSys < _opt->systems().size(); iSys++) {
|
---|
[9490] | 847 | t_irc refSatReDefinition = success;
|
---|
[9386] | 848 | char sys = _opt->systems()[iSys];
|
---|
[8956] | 849 | bool refSatDefined = false;
|
---|
[9508] | 850 | t_pppRefSat* refSat = _refSatMap[sys];
|
---|
[8956] | 851 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 852 | t_pppSatObs* satObs = obsVector.at(ii);
|
---|
[9386] | 853 | if (satObs->eleSat() < _opt->_minEle) {
|
---|
| 854 | continue;
|
---|
| 855 | }
|
---|
[8956] | 856 | // reference satellite is unchanged
|
---|
[9395] | 857 | // ================================
|
---|
[9508] | 858 | if ( !_obsPool->refSatChangeRequired(sys) && refSat->prn() == satObs->prn()) {
|
---|
[8956] | 859 | refSatDefined = true;
|
---|
| 860 | obsVector[ii]->setAsReference();
|
---|
| 861 | }
|
---|
| 862 | // reference satellite has changed
|
---|
[9395] | 863 | // ===============================
|
---|
| 864 | else if ( _obsPool->refSatChangeRequired(sys) && refSat->prn() != satObs->prn()) {
|
---|
[9386] | 865 | if (satObs->prn().system() == sys) {
|
---|
[9395] | 866 | if (!_historicalRefSats[sys].contains(satObs->prn())) {
|
---|
| 867 | refSatDefined = true;
|
---|
| 868 | obsVector[ii]->setAsReference();
|
---|
| 869 | refSat->setPrn(satObs->prn());
|
---|
| 870 | }
|
---|
| 871 | else if ( _historicalRefSats[sys].contains(satObs->prn())) {
|
---|
| 872 | refSatReDefinition = failure;
|
---|
| 873 | }
|
---|
[8956] | 874 | }
|
---|
| 875 | }
|
---|
| 876 | if (refSatDefined) {
|
---|
| 877 | if (OPT->_pseudoObsIono) {
|
---|
| 878 | refSat->setStecValue(satObs->getIonoCodeDelay(t_frequency::G1));
|
---|
| 879 | }
|
---|
| 880 | break;
|
---|
| 881 | }
|
---|
| 882 | }
|
---|
[9490] | 883 |
|
---|
[9398] | 884 | // all available satellites were already tried to use
|
---|
[9395] | 885 | if ((!refSatDefined) && (refSatReDefinition == failure)) {
|
---|
| 886 | refSat->setPrn(t_prn(sys, 99));
|
---|
[9398] | 887 | _obsPool->setRefSatChangeRequired(sys, false);
|
---|
| 888 | return;
|
---|
[9395] | 889 | }
|
---|
| 890 |
|
---|
[8956] | 891 | // reference satellite has to be initialized
|
---|
[9395] | 892 | // =========================================
|
---|
[8956] | 893 | if (!refSatDefined) {
|
---|
| 894 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 895 | t_pppSatObs* satObs = obsVector.at(ii);
|
---|
| 896 | if (satObs->eleSat() < _opt->_minEle) {
|
---|
| 897 | continue;
|
---|
| 898 | }
|
---|
[9583] | 899 | if (satObs->prn().system() == sys &&
|
---|
| 900 | !_historicalRefSats[sys].contains(satObs->prn())) {
|
---|
[8956] | 901 | obsVector[ii]->setAsReference();
|
---|
| 902 | refSat->setPrn(satObs->prn());
|
---|
| 903 | if (OPT->_pseudoObsIono) {
|
---|
| 904 | refSat->setStecValue(satObs->getIonoCodeDelay(t_frequency::G1));
|
---|
| 905 | }
|
---|
| 906 | refSatDefined = true;
|
---|
| 907 | break;
|
---|
| 908 | }
|
---|
| 909 | }
|
---|
| 910 | }
|
---|
[9395] | 911 |
|
---|
[9398] | 912 | // no observations for that system
|
---|
| 913 | // ===============================
|
---|
| 914 | if (!refSatDefined) {
|
---|
[9386] | 915 | refSat->setPrn(t_prn());
|
---|
| 916 | }
|
---|
[9398] | 917 | _obsPool->setRefSatChangeRequired(sys, false); // done or impossible
|
---|
[8956] | 918 | }
|
---|
[9398] | 919 |
|
---|
| 920 | return;
|
---|
[9386] | 921 | }
|
---|
[8956] | 922 |
|
---|
[9386] | 923 | //
|
---|
| 924 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 925 | t_irc t_pppClient::handleRefSatellites(std::vector<t_pppSatObs*>& obsVector) {
|
---|
| 926 |
|
---|
| 927 | // set refSats in current epoch
|
---|
| 928 | // ============================
|
---|
| 929 | setRefSatellites(obsVector); // current epoch
|
---|
| 930 | LOG.setf(ios::fixed);
|
---|
[9508] | 931 | t_pppObsPool::t_epoch* epoch = _obsPool->lastEpoch();
|
---|
| 932 | const QMap<char, t_pppRefSat*>& refSatMapLastEpoch = epoch->refSatMap();
|
---|
[9527] | 933 |
|
---|
[9508] | 934 | QMapIterator<char, t_pppRefSat*> it(_refSatMap);
|
---|
[9386] | 935 | while (it.hasNext()) {
|
---|
| 936 | it.next();
|
---|
| 937 | char sys = it.key();
|
---|
| 938 | t_prn prn = it.value()->prn();
|
---|
[9508] | 939 | t_prn refSatLastEpochPrn = t_prn();
|
---|
| 940 | if (epoch) {
|
---|
| 941 | refSatLastEpochPrn = refSatMapLastEpoch[sys]->prn();
|
---|
| 942 | }
|
---|
[9395] | 943 | if (prn.number() == 0) { // no obs for that system available
|
---|
| 944 | continue;
|
---|
| 945 | }
|
---|
| 946 | else if (prn.number() == 99) { // refSat re-definition not possible
|
---|
[9490] | 947 | LOG << " => refSat re-definition impossible: " << sys << endl;
|
---|
[9386] | 948 | return failure;
|
---|
| 949 | }
|
---|
[9432] | 950 | QString str;
|
---|
[9508] | 951 | if (prn == refSatLastEpochPrn || refSatLastEpochPrn == t_prn() ) {
|
---|
[9386] | 952 | _obsPool->setRefSatChanged(sys, false);
|
---|
| 953 | str = " SET ";
|
---|
| 954 | }
|
---|
| 955 | else {
|
---|
| 956 | _obsPool->setRefSatChanged(sys, true);
|
---|
| 957 | str = " RESET ";
|
---|
| 958 | }
|
---|
| 959 | LOG << string(_epoTimeRover) << str.toStdString() << " REFSAT " << sys << ": " << prn.toString() << endl;
|
---|
| 960 | }
|
---|
| 961 | return success;
|
---|
[8956] | 962 | }
|
---|
| 963 |
|
---|
[9386] | 964 | void t_pppClient::setHistoricalRefSats() {
|
---|
[9508] | 965 | QMapIterator<char, t_pppRefSat*> it(_refSatMap);
|
---|
[9386] | 966 | while (it.hasNext()) {
|
---|
| 967 | it.next();
|
---|
| 968 | t_prn prn = it.value()->prn();
|
---|
| 969 | char sys = prn.system();
|
---|
[9548] | 970 | if (_obsPool->refSatChangeRequired(sys)) {
|
---|
[9386] | 971 | _historicalRefSats[sys].append(prn);
|
---|
| 972 | }
|
---|
[9508] | 973 | }
|
---|
| 974 | }
|
---|
[9386] | 975 |
|
---|
[8956] | 976 | //
|
---|
| 977 | //////////////////////////////////////////////////////////////////////////////
|
---|
[9548] | 978 | void t_pppClient::reset() {LOG << "t_pppClient::reset()" << endl;
|
---|
[7972] | 979 |
|
---|
| 980 | // to delete old orbit and clock corrections
|
---|
| 981 | delete _ephPool;
|
---|
| 982 | _ephPool = new t_pppEphPool();
|
---|
| 983 |
|
---|
| 984 | // to delete old code biases
|
---|
| 985 | delete _obsPool;
|
---|
| 986 | _obsPool = new t_pppObsPool();
|
---|
[8905] | 987 |
|
---|
| 988 | // to delete all parameters
|
---|
| 989 | delete _filter;
|
---|
| 990 | _filter = new t_pppFilter(_obsPool);
|
---|
| 991 |
|
---|
[7996] | 992 | }
|
---|