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 |
|
---|
35 | using namespace BNC_PPP;
|
---|
36 | using namespace std;
|
---|
37 |
|
---|
38 | // Global variable holding thread-specific pointers
|
---|
39 | //////////////////////////////////////////////////////////////////////////////
|
---|
40 | QThreadStorage<t_pppClient*> CLIENTS;
|
---|
41 |
|
---|
42 | // Static function returning thread-specific pointer
|
---|
43 | //////////////////////////////////////////////////////////////////////////////
|
---|
44 | t_pppClient* t_pppClient::instance() {
|
---|
45 | return CLIENTS.localData();
|
---|
46 | }
|
---|
47 |
|
---|
48 | // Constructor
|
---|
49 | //////////////////////////////////////////////////////////////////////////////
|
---|
50 | t_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();
|
---|
58 | _tides = new t_tides();
|
---|
59 |
|
---|
60 | if (!_opt->_antexFileName.empty()) {
|
---|
61 | _antex = new bncAntex(_opt->_antexFileName.c_str());
|
---|
62 | }
|
---|
63 | else {
|
---|
64 | _antex = 0;
|
---|
65 | }
|
---|
66 |
|
---|
67 | CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
|
---|
68 | }
|
---|
69 |
|
---|
70 | // Destructor
|
---|
71 | //////////////////////////////////////////////////////////////////////////////
|
---|
72 | t_pppClient::~t_pppClient() {
|
---|
73 | delete _log;
|
---|
74 | delete _opt;
|
---|
75 | delete _ephPool;
|
---|
76 | delete _obsPool;
|
---|
77 | delete _staRover;
|
---|
78 | if (_antex) {
|
---|
79 | delete _antex;
|
---|
80 | }
|
---|
81 | delete _filter;
|
---|
82 | delete _tides;
|
---|
83 | clearObs();
|
---|
84 | }
|
---|
85 |
|
---|
86 | //
|
---|
87 | //////////////////////////////////////////////////////////////////////////////
|
---|
88 | void t_pppClient::putEphemeris(const t_eph* eph) {
|
---|
89 | const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
|
---|
90 | const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
|
---|
91 | const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
|
---|
92 | const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
|
---|
93 | if (ephGPS) {
|
---|
94 | _ephPool->putEphemeris(new t_ephGPS(*ephGPS));
|
---|
95 | }
|
---|
96 | else if (ephGlo) {
|
---|
97 | _ephPool->putEphemeris(new t_ephGlo(*ephGlo));
|
---|
98 | }
|
---|
99 | else if (ephGal) {
|
---|
100 | _ephPool->putEphemeris(new t_ephGal(*ephGal));
|
---|
101 | }
|
---|
102 | else if (ephBDS) {
|
---|
103 | _ephPool->putEphemeris(new t_ephBDS(*ephBDS));
|
---|
104 | }
|
---|
105 | }
|
---|
106 |
|
---|
107 | //
|
---|
108 | //////////////////////////////////////////////////////////////////////////////
|
---|
109 | void t_pppClient::putTec(const t_vTec* vTec) {
|
---|
110 | _obsPool->putTec(new t_vTec(*vTec));
|
---|
111 | }
|
---|
112 |
|
---|
113 | //
|
---|
114 | //////////////////////////////////////////////////////////////////////////////
|
---|
115 | void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) {
|
---|
116 | for (unsigned ii = 0; ii < corr.size(); ii++) {
|
---|
117 | _ephPool->putOrbCorrection(new t_orbCorr(*corr[ii]));
|
---|
118 | }
|
---|
119 | }
|
---|
120 |
|
---|
121 | //
|
---|
122 | //////////////////////////////////////////////////////////////////////////////
|
---|
123 | void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) {
|
---|
124 | for (unsigned ii = 0; ii < corr.size(); ii++) {
|
---|
125 | _ephPool->putClkCorrection(new t_clkCorr(*corr[ii]));
|
---|
126 | }
|
---|
127 | }
|
---|
128 |
|
---|
129 | //
|
---|
130 | //////////////////////////////////////////////////////////////////////////////
|
---|
131 | void t_pppClient::putCodeBiases(const vector<t_satCodeBias*>& biases) {
|
---|
132 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
133 | _obsPool->putCodeBias(new t_satCodeBias(*biases[ii]));
|
---|
134 | }
|
---|
135 | }
|
---|
136 |
|
---|
137 | //
|
---|
138 | //////////////////////////////////////////////////////////////////////////////
|
---|
139 | void t_pppClient::putPhaseBiases(const vector<t_satPhaseBias*>& biases) {
|
---|
140 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
141 | _obsPool->putPhaseBias(new t_satPhaseBias(*biases[ii]));
|
---|
142 | }
|
---|
143 | }
|
---|
144 |
|
---|
145 | //
|
---|
146 | //////////////////////////////////////////////////////////////////////////////
|
---|
147 | t_irc t_pppClient::prepareObs(const vector<t_satObs*>& satObs,
|
---|
148 | vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
|
---|
149 | // Default
|
---|
150 | // -------
|
---|
151 | epoTime.reset();
|
---|
152 |
|
---|
153 | // Create vector of valid observations
|
---|
154 | // -----------------------------------
|
---|
155 | for (unsigned ii = 0; ii < satObs.size(); ii++) {
|
---|
156 | char system = satObs[ii]->_prn.system();
|
---|
157 | if (OPT->useSystem(system)) {
|
---|
158 | t_pppSatObs* pppSatObs = new t_pppSatObs(*satObs[ii]);
|
---|
159 | if (pppSatObs->isValid()) {
|
---|
160 | obsVector.push_back(pppSatObs);
|
---|
161 | }
|
---|
162 | else {
|
---|
163 | delete pppSatObs;
|
---|
164 | }
|
---|
165 | }
|
---|
166 | }
|
---|
167 |
|
---|
168 | // Check whether data are synchronized, compute epoTime
|
---|
169 | // ----------------------------------------------------
|
---|
170 | const double MAXSYNC = 0.05; // synchronization limit
|
---|
171 | double meanDt = 0.0;
|
---|
172 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
173 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
174 | if (epoTime.undef()) {
|
---|
175 | epoTime = satObs->time();
|
---|
176 | }
|
---|
177 | else {
|
---|
178 | double dt = satObs->time() - epoTime;
|
---|
179 | if (fabs(dt) > MAXSYNC) {
|
---|
180 | LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
|
---|
181 | return failure;
|
---|
182 | }
|
---|
183 | meanDt += dt;
|
---|
184 | }
|
---|
185 | }
|
---|
186 |
|
---|
187 | if (obsVector.size() > 0) {
|
---|
188 | epoTime += meanDt / obsVector.size();
|
---|
189 | }
|
---|
190 |
|
---|
191 | return success;
|
---|
192 | }
|
---|
193 |
|
---|
194 | // Compute the Bancroft position, check for blunders
|
---|
195 | //////////////////////////////////////////////////////////////////////////////
|
---|
196 | t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
|
---|
197 | vector<t_pppSatObs*>& obsVector,
|
---|
198 | ColumnVector& xyzc, bool print) {
|
---|
199 |
|
---|
200 | t_lc::type tLC = t_lc::dummy;
|
---|
201 |
|
---|
202 | while (true) {
|
---|
203 | Matrix BB(obsVector.size(), 4);
|
---|
204 | int iObs = -1;
|
---|
205 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
206 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
207 | if (tLC == t_lc::dummy) {
|
---|
208 | if (satObs->isValid(t_lc::cIF)) {
|
---|
209 | tLC = t_lc::cIF;
|
---|
210 | }
|
---|
211 | else if (satObs->isValid(t_lc::c1)) {
|
---|
212 | tLC = t_lc::c1;
|
---|
213 | }
|
---|
214 | else if (satObs->isValid(t_lc::c2)) {
|
---|
215 | tLC = t_lc::c2;
|
---|
216 | }
|
---|
217 | }
|
---|
218 | if ( satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
219 | ++iObs;
|
---|
220 | BB[iObs][0] = satObs->xc()[0];
|
---|
221 | BB[iObs][1] = satObs->xc()[1];
|
---|
222 | BB[iObs][2] = satObs->xc()[2];
|
---|
223 | BB[iObs][3] = satObs->obsValue(tLC) - satObs->cmpValueForBanc(tLC);
|
---|
224 | }
|
---|
225 | }
|
---|
226 | if (iObs + 1 < OPT->_minObs) {
|
---|
227 | LOG << "t_pppClient::cmpBancroft not enough observations" << endl;
|
---|
228 | return failure;
|
---|
229 | }
|
---|
230 | BB = BB.Rows(1,iObs+1);
|
---|
231 | bancroft(BB, xyzc);
|
---|
232 |
|
---|
233 | xyzc[3] /= t_CST::c;
|
---|
234 |
|
---|
235 | // Check Blunders
|
---|
236 | // --------------
|
---|
237 | const double BLUNDER = 100.0;
|
---|
238 | double maxRes = 0.0;
|
---|
239 | unsigned maxResIndex = 0;
|
---|
240 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
241 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
242 | if ( satObs->isValid() && satObs->prn().system() == 'G' &&
|
---|
243 | (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
244 | ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
|
---|
245 | double res = rr.norm_Frobenius() - satObs->obsValue(tLC)
|
---|
246 | - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
|
---|
247 | if (fabs(res) > maxRes || std::isnan(res)) {
|
---|
248 | maxRes = fabs(res);
|
---|
249 | maxResIndex = ii;
|
---|
250 | }
|
---|
251 | }
|
---|
252 | }
|
---|
253 | if (maxRes < BLUNDER) {
|
---|
254 | if (print) {
|
---|
255 | LOG.setf(ios::fixed);
|
---|
256 | LOG << string(epoTime) << " BANCROFT:" << ' '
|
---|
257 | << setw(14) << setprecision(3) << xyzc[0] << ' '
|
---|
258 | << setw(14) << setprecision(3) << xyzc[1] << ' '
|
---|
259 | << setw(14) << setprecision(3) << xyzc[2] << ' '
|
---|
260 | << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
|
---|
261 | }
|
---|
262 | break;
|
---|
263 | }
|
---|
264 | else {
|
---|
265 | t_pppSatObs* satObs = obsVector.at(maxResIndex);
|
---|
266 | LOG << "t_pppClient::cmpBancroft outlier " << satObs->prn().toString()
|
---|
267 | << " " << maxRes << endl;
|
---|
268 | delete satObs;
|
---|
269 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
270 | }
|
---|
271 | }
|
---|
272 |
|
---|
273 | return success;
|
---|
274 | }
|
---|
275 |
|
---|
276 | // Compute A Priori GPS-Glonass Offset
|
---|
277 | //////////////////////////////////////////////////////////////////////////////
|
---|
278 | double t_pppClient::cmpOffGG(vector<t_pppSatObs*>& obsVector) {
|
---|
279 |
|
---|
280 | t_lc::type tLC = t_lc::dummy;
|
---|
281 | double offGG = 0.0;
|
---|
282 |
|
---|
283 | if (OPT->useSystem('R')) {
|
---|
284 | while (obsVector.size() > 0) {
|
---|
285 | offGG = 0.0;
|
---|
286 | double maxRes = 0.0;
|
---|
287 | int maxResIndex = -1;
|
---|
288 | t_prn maxResPrn;
|
---|
289 | unsigned nObs = 0;
|
---|
290 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
291 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
292 | if (satObs->prn().system() == 'R') {
|
---|
293 | if (tLC == t_lc::dummy) {
|
---|
294 | tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
|
---|
295 | }
|
---|
296 | if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle)) {
|
---|
297 | double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
|
---|
298 | ++nObs;
|
---|
299 | offGG += ll;
|
---|
300 | if (fabs(ll) > fabs(maxRes)) {
|
---|
301 | maxRes = ll;
|
---|
302 | maxResIndex = ii;
|
---|
303 | maxResPrn = satObs->prn();
|
---|
304 | }
|
---|
305 | }
|
---|
306 | }
|
---|
307 | }
|
---|
308 |
|
---|
309 | if (nObs > 0) {
|
---|
310 | offGG = offGG / nObs;
|
---|
311 | }
|
---|
312 | else {
|
---|
313 | offGG = 0.0;
|
---|
314 | }
|
---|
315 |
|
---|
316 | if (fabs(maxRes) > 1000.0) {
|
---|
317 | LOG << "t_pppClient::cmpOffGG outlier " << maxResPrn.toString() << " " << maxRes << endl;
|
---|
318 | delete obsVector.at(maxResIndex);
|
---|
319 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
320 | }
|
---|
321 | else {
|
---|
322 | break;
|
---|
323 | }
|
---|
324 | }
|
---|
325 | }
|
---|
326 | return offGG;
|
---|
327 | }
|
---|
328 |
|
---|
329 | //
|
---|
330 | //////////////////////////////////////////////////////////////////////////////
|
---|
331 | void t_pppClient::initOutput(t_output* output) {
|
---|
332 | _output = output;
|
---|
333 | _output->_numSat = 0;
|
---|
334 | _output->_hDop = 0.0;
|
---|
335 | _output->_error = false;
|
---|
336 | }
|
---|
337 |
|
---|
338 | //
|
---|
339 | //////////////////////////////////////////////////////////////////////////////
|
---|
340 | void t_pppClient::clearObs() {
|
---|
341 | for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
|
---|
342 | delete _obsRover.at(ii);
|
---|
343 | }
|
---|
344 | _obsRover.clear();
|
---|
345 | }
|
---|
346 |
|
---|
347 | //
|
---|
348 | //////////////////////////////////////////////////////////////////////////////
|
---|
349 | void t_pppClient::finish(t_irc irc) {
|
---|
350 |
|
---|
351 | clearObs();
|
---|
352 |
|
---|
353 | _output->_epoTime = _epoTimeRover;
|
---|
354 |
|
---|
355 | if (irc == success) {
|
---|
356 | _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
|
---|
357 | _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
|
---|
358 | _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
|
---|
359 |
|
---|
360 | xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
|
---|
361 |
|
---|
362 | copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
|
---|
363 |
|
---|
364 | _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
|
---|
365 | _output->_trp = _filter->trp();
|
---|
366 | _output->_trpStdev = _filter->trpStdev();
|
---|
367 |
|
---|
368 | _output->_numSat = _filter->numSat();
|
---|
369 | _output->_hDop = _filter->HDOP();
|
---|
370 | _output->_error = false;
|
---|
371 | }
|
---|
372 | else {
|
---|
373 | _output->_error = true;
|
---|
374 | }
|
---|
375 | _output->_log = _log->str();
|
---|
376 | delete _log; _log = new ostringstream();
|
---|
377 | }
|
---|
378 |
|
---|
379 | //
|
---|
380 | //////////////////////////////////////////////////////////////////////////////
|
---|
381 | t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
|
---|
382 | vector<t_pppSatObs*>& obsVector) {
|
---|
383 |
|
---|
384 | bncTime time;
|
---|
385 | time = _epoTimeRover;
|
---|
386 | station->setName(OPT->_roverName);
|
---|
387 | station->setAntName(OPT->_antNameRover);
|
---|
388 | if (OPT->xyzAprRoverSet()) {
|
---|
389 | station->setXyzApr(OPT->_xyzAprRover);
|
---|
390 | }
|
---|
391 | else {
|
---|
392 | station->setXyzApr(xyzc.Rows(1,3));
|
---|
393 | }
|
---|
394 | station->setNeuEcc(OPT->_neuEccRover);
|
---|
395 |
|
---|
396 | // Receiver Clock
|
---|
397 | // --------------
|
---|
398 | station->setDClk(xyzc[3]);
|
---|
399 |
|
---|
400 | // Tides
|
---|
401 | // -----
|
---|
402 | station->setTideDspl( _tides->displacement(time, station->xyzApr()) );
|
---|
403 |
|
---|
404 | // Ionosphere
|
---|
405 | // ----------
|
---|
406 | station->setIonoEpochTime(time);
|
---|
407 |
|
---|
408 | // Observation model
|
---|
409 | // -----------------
|
---|
410 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
411 | while (it != obsVector.end()) {
|
---|
412 | t_pppSatObs* satObs = *it;
|
---|
413 | t_irc modelSetup;
|
---|
414 | if (satObs->isValid()) {
|
---|
415 | modelSetup = satObs->cmpModel(station);
|
---|
416 | }
|
---|
417 | if (satObs->isValid() &&
|
---|
418 | satObs->eleSat() >= OPT->_minEle &&
|
---|
419 | modelSetup == success) {
|
---|
420 | ++it;
|
---|
421 | }
|
---|
422 | else {
|
---|
423 | delete satObs;
|
---|
424 | it = obsVector.erase(it);
|
---|
425 | }
|
---|
426 | }
|
---|
427 |
|
---|
428 | return success;
|
---|
429 | }
|
---|
430 |
|
---|
431 | //
|
---|
432 | //////////////////////////////////////////////////////////////////////////////
|
---|
433 | void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
|
---|
434 |
|
---|
435 | try {
|
---|
436 | initOutput(output);
|
---|
437 |
|
---|
438 | // Prepare Observations of the Rover
|
---|
439 | // ---------------------------------
|
---|
440 | if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
|
---|
441 | return finish(failure);
|
---|
442 | }
|
---|
443 |
|
---|
444 | LOG << "\nPPP of Epoch ";
|
---|
445 | if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
|
---|
446 | LOG << "\n---------------------------------------------------------------\n";
|
---|
447 |
|
---|
448 | for (int iter = 1; iter <= 2; iter++) {
|
---|
449 | ColumnVector xyzc(4); xyzc = 0.0;
|
---|
450 | bool print = (iter == 2);
|
---|
451 | if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
|
---|
452 | return finish(failure);
|
---|
453 | }
|
---|
454 | if (cmpModel(_staRover, xyzc, _obsRover) != success) {
|
---|
455 | return finish(failure);
|
---|
456 | }
|
---|
457 | }
|
---|
458 |
|
---|
459 | _offGG = cmpOffGG(_obsRover);
|
---|
460 |
|
---|
461 | if (int(_obsRover.size()) < OPT->_minObs) {
|
---|
462 | LOG << "t_pppClient::processEpoch not enough observations" << endl;
|
---|
463 | return finish(failure);
|
---|
464 | }
|
---|
465 |
|
---|
466 | // Store last epoch of data
|
---|
467 | // ------------------------
|
---|
468 | _obsPool->putEpoch(_epoTimeRover, _obsRover);
|
---|
469 |
|
---|
470 | // Process Epoch in Filter
|
---|
471 | // -----------------------
|
---|
472 | if (_filter->processEpoch(_obsPool) != success) {
|
---|
473 | return finish(failure);
|
---|
474 | }
|
---|
475 | }
|
---|
476 | catch (Exception& exc) {
|
---|
477 | LOG << exc.what() << endl;
|
---|
478 | return finish(failure);
|
---|
479 | }
|
---|
480 | catch (t_except msg) {
|
---|
481 | LOG << msg.what() << endl;
|
---|
482 | return finish(failure);
|
---|
483 | }
|
---|
484 | catch (const char* msg) {
|
---|
485 | LOG << msg << endl;
|
---|
486 | return finish(failure);
|
---|
487 | }
|
---|
488 | catch (...) {
|
---|
489 | LOG << "unknown exception" << endl;
|
---|
490 | return finish(failure);
|
---|
491 | }
|
---|
492 |
|
---|
493 | return finish(success);
|
---|
494 | }
|
---|
495 |
|
---|
496 | //
|
---|
497 | ////////////////////////////////////////////////////////////////////////////
|
---|
498 | double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
|
---|
499 | return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
|
---|
500 | }
|
---|
501 |
|
---|
502 | //
|
---|
503 | ////////////////////////////////////////////////////////////////////////////
|
---|
504 | void t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
|
---|
505 |
|
---|
506 | if (pos.Nrows() != 4) {
|
---|
507 | pos.ReSize(4);
|
---|
508 | }
|
---|
509 | pos = 0.0;
|
---|
510 |
|
---|
511 | for (int iter = 1; iter <= 2; iter++) {
|
---|
512 | Matrix BB = BBpass;
|
---|
513 | int mm = BB.Nrows();
|
---|
514 | for (int ii = 1; ii <= mm; ii++) {
|
---|
515 | double xx = BB(ii,1);
|
---|
516 | double yy = BB(ii,2);
|
---|
517 | double traveltime = 0.072;
|
---|
518 | if (iter > 1) {
|
---|
519 | double zz = BB(ii,3);
|
---|
520 | double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
|
---|
521 | (yy-pos(2)) * (yy-pos(2)) +
|
---|
522 | (zz-pos(3)) * (zz-pos(3)) );
|
---|
523 | traveltime = rho / t_CST::c;
|
---|
524 | }
|
---|
525 | double angle = traveltime * t_CST::omega;
|
---|
526 | double cosa = cos(angle);
|
---|
527 | double sina = sin(angle);
|
---|
528 | BB(ii,1) = cosa * xx + sina * yy;
|
---|
529 | BB(ii,2) = -sina * xx + cosa * yy;
|
---|
530 | }
|
---|
531 |
|
---|
532 | Matrix BBB;
|
---|
533 | if (mm > 4) {
|
---|
534 | SymmetricMatrix hlp; hlp << BB.t() * BB;
|
---|
535 | BBB = hlp.i() * BB.t();
|
---|
536 | }
|
---|
537 | else {
|
---|
538 | BBB = BB.i();
|
---|
539 | }
|
---|
540 | ColumnVector ee(mm); ee = 1.0;
|
---|
541 | ColumnVector alpha(mm); alpha = 0.0;
|
---|
542 | for (int ii = 1; ii <= mm; ii++) {
|
---|
543 | alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
|
---|
544 | }
|
---|
545 | ColumnVector BBBe = BBB * ee;
|
---|
546 | ColumnVector BBBalpha = BBB * alpha;
|
---|
547 | double aa = lorentz(BBBe, BBBe);
|
---|
548 | double bb = lorentz(BBBe, BBBalpha)-1;
|
---|
549 | double cc = lorentz(BBBalpha, BBBalpha);
|
---|
550 | double root = sqrt(bb*bb-aa*cc);
|
---|
551 |
|
---|
552 | Matrix hlpPos(4,2);
|
---|
553 | hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
|
---|
554 | hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
|
---|
555 |
|
---|
556 | ColumnVector omc(2);
|
---|
557 | for (int pp = 1; pp <= 2; pp++) {
|
---|
558 | hlpPos(4,pp) = -hlpPos(4,pp);
|
---|
559 | omc(pp) = BB(1,4) -
|
---|
560 | sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
|
---|
561 | (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
|
---|
562 | (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
|
---|
563 | hlpPos(4,pp);
|
---|
564 | }
|
---|
565 | if ( fabs(omc(1)) > fabs(omc(2)) ) {
|
---|
566 | pos = hlpPos.Column(2);
|
---|
567 | }
|
---|
568 | else {
|
---|
569 | pos = hlpPos.Column(1);
|
---|
570 | }
|
---|
571 | }
|
---|
572 | }
|
---|
573 |
|
---|
574 | //
|
---|
575 | //////////////////////////////////////////////////////////////////////////////
|
---|
576 | void t_pppClient::reset() {
|
---|
577 |
|
---|
578 | // to delete all parameters
|
---|
579 | delete _filter;
|
---|
580 | _filter = new t_pppFilter();
|
---|
581 |
|
---|
582 | // to delete old orbit and clock corrections
|
---|
583 | delete _ephPool;
|
---|
584 | _ephPool = new t_pppEphPool();
|
---|
585 |
|
---|
586 | // to delete old code biases
|
---|
587 | delete _obsPool;
|
---|
588 | _obsPool = new t_pppObsPool();
|
---|
589 | }
|
---|