source: ntrip/trunk/BNC/src/upload/bncrtnetuploadcaster.cpp@ 9126

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

minor changes

File size: 37.4 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Server
3 * -------------------------------------------------------------------------
4 *
5 * Class: bncRtnetUploadCaster
6 *
7 * Purpose: Connection to NTRIP Caster
8 *
9 * Author: L. Mervart
10 *
11 * Created: 29-Mar-2011
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <math.h>
18#include "bncrtnetuploadcaster.h"
19#include "bncsettings.h"
20#include "bncephuser.h"
21#include "bncclockrinex.h"
22#include "bncsp3.h"
23#include "gnss.h"
24
25using namespace std;
26
27// Constructor
28////////////////////////////////////////////////////////////////////////////
29bncRtnetUploadCaster::bncRtnetUploadCaster(const QString& mountpoint,
30 const QString& outHost, int outPort,
31 const QString& ntripVersion,
32 const QString& userName, const QString& password,
33 const QString& crdTrafo, const QString& ssrFormat, bool CoM, const QString& sp3FileName,
34 const QString& rnxFileName, int PID, int SID, int IOD, int iRow) :
35 bncUploadCaster(mountpoint, outHost, outPort, ntripVersion, userName, password, iRow, 0) {
36
37 if (!mountpoint.isEmpty()) {
38 _casterID += mountpoint;
39 }
40 if (!outHost.isEmpty()) {
41 _casterID += " " + outHost;
42 if (outPort) {
43 _casterID += ":" + QString("%1").arg(outPort, 10);
44 }
45 }
46 if (!crdTrafo.isEmpty()) {
47 _casterID += " " + crdTrafo;
48 }
49 if (!sp3FileName.isEmpty()) {
50 _casterID += " " + sp3FileName;
51 }
52 if (!rnxFileName.isEmpty()) {
53 _casterID += " " + rnxFileName;
54 }
55
56 _crdTrafo = crdTrafo;
57
58 _ssrFormat = ssrFormat;
59
60 _ssrCorr = 0;
61 if (_ssrFormat == "IGS-SSR") {
62 _ssrCorr = new SsrCorrIgs();
63 }
64 else if (_ssrFormat == "RTCM-SSR") {
65 _ssrCorr = new SsrCorrRtcm();
66 }
67
68 _CoM = CoM;
69 _PID = PID;
70 _SID = SID;
71 _IOD = IOD;
72
73 // Member that receives the ephemeris
74 // ----------------------------------
75 _ephUser = new bncEphUser(true);
76
77 bncSettings settings;
78 QString intr = settings.value("uploadIntr").toString();
79 QStringList hlp = settings.value("cmbStreams").toStringList();
80 _samplRtcmEphCorr = settings.value("uploadSamplRtcmEphCorr").toDouble();
81 if (hlp.size() > 1) { // combination stream upload
82 _samplRtcmClkCorr = settings.value("cmbSampl").toInt();
83 }
84 else { // single stream upload or sp3 file generation
85 _samplRtcmClkCorr = 5; // default
86 }
87 int samplClkRnx = settings.value("uploadSamplClkRnx").toInt();
88 int samplSp3 = settings.value("uploadSamplSp3").toInt() * 60;
89
90 if (_samplRtcmEphCorr == 0.0) {
91 _usedEph = 0;
92 }
93 else {
94 _usedEph = new QMap<QString, const t_eph*>;
95 }
96
97 // RINEX writer
98 // ------------
99 if (!rnxFileName.isEmpty()) {
100 _rnx = new bncClockRinex(rnxFileName, intr, samplClkRnx);
101 }
102 else {
103 _rnx = 0;
104 }
105
106 // SP3 writer
107 // ----------
108 if (!sp3FileName.isEmpty()) {
109 _sp3 = new bncSP3(sp3FileName, intr, samplSp3);
110 }
111 else {
112 _sp3 = 0;
113 }
114
115 // Set Transformation Parameters
116 // -----------------------------
117 // Transformation Parameters from ITRF2014 to ETRF2000
118 // EUREF Technical Note 1 Relationship and Transformation between the ITRF and ETRF
119 // Zuheir Altamimi, June 28, 2018
120 if (_crdTrafo == "ETRF2000") {
121 _dx = 0.0547;
122 _dy = 0.0522;
123 _dz = -0.0741;
124
125 _dxr = 0.0001;
126 _dyr = 0.0001;
127 _dzr = -0.0019;
128
129 _ox = 0.001701;
130 _oy = 0.010290;
131 _oz = -0.016632;
132
133 _oxr = 0.000081;
134 _oyr = 0.000490;
135 _ozr = -0.000729;
136
137 _sc = 2.12;
138 _scr = 0.11;
139
140 _t0 = 2010.0;
141 }
142 // Transformation Parameters from ITRF2014 to GDA2020 (Ryan Ruddick, GA)
143 else if (_crdTrafo == "GDA2020") {
144 _dx = 0.0;
145 _dy = 0.0;
146 _dz = 0.0;
147
148 _dxr = 0.0;
149 _dyr = 0.0;
150 _dzr = 0.0;
151
152 _ox = 0.0;
153 _oy = 0.0;
154 _oz = 0.0;
155
156 _oxr = 0.00150379;
157 _oyr = 0.00118346;
158 _ozr = 0.00120716;
159
160 _sc = 0.0;
161 _scr = 0.0;
162
163 _t0 = 2020.0;
164 }
165 // Transformation Parameters from IGb14 to SIRGAS2000 (Thanks to Sonia Costa, BRA)
166 // June 29 2020: TX:-0.0027 m TY:-0.0025 m TZ:-0.0042 m SCL:1.20 (ppb) no rotations and no rates.*/
167 else if (_crdTrafo == "SIRGAS2000") {
168 _dx = -0.0027;
169 _dy = -0.0025;
170 _dz = -0.0042;
171
172 _dxr = 0.0000;
173 _dyr = 0.0000;
174 _dzr = 0.0000;
175
176 _ox = 0.000000;
177 _oy = 0.000000;
178 _oz = 0.000000;
179
180 _oxr = 0.000000;
181 _oyr = 0.000000;
182 _ozr = 0.000000;
183
184 _sc = 1.20000;
185 _scr = 0.00000;
186 _t0 = 2000.0;
187 }
188 // Transformation Parameters from ITRF2014 to DREF91
189 else if (_crdTrafo == "DREF91") {
190 _dx = 0.0547;
191 _dy = 0.0522;
192 _dz = -0.0741;
193
194 _dxr = 0.0001;
195 _dyr = 0.0001;
196 _dzr = -0.0019;
197 // ERTF200 + rotation parameters (ETRF200 => DREF91)
198 _ox = 0.001701 + 0.000658;
199 _oy = 0.010290 - 0.000208;
200 _oz = -0.016632 + 0.000755;
201
202 _oxr = 0.000081;
203 _oyr = 0.000490;
204 _ozr = -0.000729;
205
206 _sc = 2.12;
207 _scr = 0.11;
208
209 _t0 = 2010.0;
210 }
211 else if (_crdTrafo == "Custom") {
212 _dx = settings.value("trafo_dx").toDouble();
213 _dy = settings.value("trafo_dy").toDouble();
214 _dz = settings.value("trafo_dz").toDouble();
215 _dxr = settings.value("trafo_dxr").toDouble();
216 _dyr = settings.value("trafo_dyr").toDouble();
217 _dzr = settings.value("trafo_dzr").toDouble();
218 _ox = settings.value("trafo_ox").toDouble();
219 _oy = settings.value("trafo_oy").toDouble();
220 _oz = settings.value("trafo_oz").toDouble();
221 _oxr = settings.value("trafo_oxr").toDouble();
222 _oyr = settings.value("trafo_oyr").toDouble();
223 _ozr = settings.value("trafo_ozr").toDouble();
224 _sc = settings.value("trafo_sc").toDouble();
225 _scr = settings.value("trafo_scr").toDouble();
226 _t0 = settings.value("trafo_t0").toDouble();
227 }
228}
229
230// Destructor
231////////////////////////////////////////////////////////////////////////////
232bncRtnetUploadCaster::~bncRtnetUploadCaster() {
233 if (isRunning()) {
234 wait();
235 }
236 delete _rnx;
237 delete _sp3;
238 delete _ephUser;
239 delete _usedEph;
240 delete _ssrCorr;
241}
242
243//
244////////////////////////////////////////////////////////////////////////////
245void bncRtnetUploadCaster::decodeRtnetStream(char* buffer, int bufLen) {
246
247 QMutexLocker locker(&_mutex);
248
249 // Append to internal buffer
250 // -------------------------
251 _rtnetStreamBuffer.append(QByteArray(buffer, bufLen));
252
253 // Select buffer part that contains last epoch
254 // -------------------------------------------
255 QStringList lines;
256 int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*'); // begin of last epoch
257 if (iEpoBeg == -1) {
258 _rtnetStreamBuffer.clear();
259 return;
260 }
261 int iEpoBegEarlier = _rtnetStreamBuffer.indexOf('*');
262 if (iEpoBegEarlier != -1 && iEpoBegEarlier < iEpoBeg) { // are there two epoch lines in buffer?
263 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBegEarlier);
264 }
265 else {
266 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
267 }
268 int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end of last epoch
269 if (iEpoEnd == -1) {
270 return;
271 }
272
273 while (_rtnetStreamBuffer.count('*') > 1) { // is there more than 1 epoch line in buffer?
274 QString rtnetStreamBuffer = _rtnetStreamBuffer.mid(1);
275 int nextEpoch = rtnetStreamBuffer.indexOf('*');
276 if (nextEpoch != -1 && nextEpoch < iEpoEnd) {
277 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(nextEpoch);
278 }
279 else if (nextEpoch != -1 && nextEpoch >= iEpoEnd) {
280 break;
281 }
282 }
283
284 lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n',
285 QString::SkipEmptyParts);
286 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd + 3);
287
288 if (lines.size() < 2) {
289 return;
290 }
291
292 // Read first line (with epoch time)
293 // ---------------------------------
294 QTextStream in(lines[0].toLatin1());
295 QString hlp;
296 int year, month, day, hour, min;
297 double sec;
298 in >> hlp >> year >> month >> day >> hour >> min >> sec;
299 bncTime epoTime;
300 epoTime.set(year, month, day, hour, min, sec);
301
302 emit(newMessage(
303 "bncRtnetUploadCaster: decode " + QByteArray(epoTime.datestr().c_str())
304 + " " + QByteArray(epoTime.timestr().c_str()) + " "
305 + _casterID.toLatin1(), false));
306
307 struct SsrCorr::ClockOrbit co;
308 memset(&co, 0, sizeof(co));
309 co.EpochTime[CLOCKORBIT_SATGPS] = static_cast<int>(epoTime.gpssec());
310 if (_ssrFormat == "RTCM-SSR") {
311 double gt = epoTime.gpssec() + 3 * 3600 - gnumleap(year, month, day);
312 co.EpochTime[CLOCKORBIT_SATGLONASS] = static_cast<int>(fmod(gt, 86400.0));
313 }
314 else if (_ssrFormat == "IGS-SSR") {
315 co.EpochTime[CLOCKORBIT_SATGLONASS] = static_cast<int>(epoTime.gpssec());
316 }
317 co.EpochTime[CLOCKORBIT_SATGALILEO] = static_cast<int>(epoTime.gpssec());
318 co.EpochTime[CLOCKORBIT_SATQZSS] = static_cast<int>(epoTime.gpssec());
319 co.EpochTime[CLOCKORBIT_SATSBAS] = static_cast<int>(epoTime.gpssec());
320 if (_ssrFormat == "RTCM-SSR") {
321 co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.bdssec());
322 }
323 else if (_ssrFormat == "IGS-SSR") {
324 co.EpochTime[CLOCKORBIT_SATBDS] = static_cast<int>(epoTime.gpssec());
325 }
326 co.Supplied[_ssrCorr->COBOFS_CLOCK] = 1;
327 co.Supplied[_ssrCorr->COBOFS_ORBIT] = 1;
328 co.SatRefDatum = _ssrCorr->DATUM_ITRF; // ToDo: to decode from RTNET format
329 co.SSRIOD = _IOD;
330 co.SSRProviderID = _PID; // 256 .. BKG, 257 ... EUREF
331 co.SSRSolutionID = _SID;
332
333 struct SsrCorr::CodeBias bias;
334 memset(&bias, 0, sizeof(bias));
335 bias.EpochTime[CLOCKORBIT_SATGPS] = co.EpochTime[CLOCKORBIT_SATGPS];
336 bias.EpochTime[CLOCKORBIT_SATGLONASS] = co.EpochTime[CLOCKORBIT_SATGLONASS];
337 bias.EpochTime[CLOCKORBIT_SATGALILEO] = co.EpochTime[CLOCKORBIT_SATGALILEO];
338 bias.EpochTime[CLOCKORBIT_SATQZSS] = co.EpochTime[CLOCKORBIT_SATQZSS];
339 bias.EpochTime[CLOCKORBIT_SATSBAS] = co.EpochTime[CLOCKORBIT_SATSBAS];
340 bias.EpochTime[CLOCKORBIT_SATBDS] = co.EpochTime[CLOCKORBIT_SATBDS];
341 bias.SSRIOD = _IOD;
342 bias.SSRProviderID = _PID;
343 bias.SSRSolutionID = _SID;
344
345 struct SsrCorr::PhaseBias phasebias;
346 memset(&phasebias, 0, sizeof(phasebias));
347 unsigned int dispersiveBiasConsistenyIndicator = 0;
348 unsigned int mwConsistencyIndicator = 0;
349 phasebias.EpochTime[CLOCKORBIT_SATGPS] = co.EpochTime[CLOCKORBIT_SATGPS];
350 phasebias.EpochTime[CLOCKORBIT_SATGLONASS] = co.EpochTime[CLOCKORBIT_SATGLONASS];
351 phasebias.EpochTime[CLOCKORBIT_SATGALILEO] = co.EpochTime[CLOCKORBIT_SATGALILEO];
352 phasebias.EpochTime[CLOCKORBIT_SATQZSS] = co.EpochTime[CLOCKORBIT_SATQZSS];
353 phasebias.EpochTime[CLOCKORBIT_SATSBAS] = co.EpochTime[CLOCKORBIT_SATSBAS];
354 phasebias.EpochTime[CLOCKORBIT_SATBDS] = co.EpochTime[CLOCKORBIT_SATBDS];
355 phasebias.SSRIOD = _IOD;
356 phasebias.SSRProviderID = _PID;
357 phasebias.SSRSolutionID = _SID;
358
359 struct SsrCorr::VTEC vtec;
360 memset(&vtec, 0, sizeof(vtec));
361 vtec.EpochTime = static_cast<int>(epoTime.gpssec());
362 vtec.SSRIOD = _IOD;
363 vtec.SSRProviderID = _PID;
364 vtec.SSRSolutionID = _SID;
365
366 // Default Update Interval
367 // -----------------------
368 int clkUpdInd = 2; // 5 sec
369 int ephUpdInd = clkUpdInd; // default
370
371 if (_samplRtcmClkCorr > 5.0 && _samplRtcmEphCorr <= 5.0) { // combined orb and clock
372 ephUpdInd = determineUpdateInd(_samplRtcmClkCorr);
373 }
374 if (_samplRtcmClkCorr > 5.0) {
375 clkUpdInd = determineUpdateInd(_samplRtcmClkCorr);
376 }
377 if (_samplRtcmEphCorr > 5.0) {
378 ephUpdInd = determineUpdateInd(_samplRtcmEphCorr);
379 }
380
381 co.UpdateInterval = clkUpdInd;
382 bias.UpdateInterval = ephUpdInd;
383 phasebias.UpdateInterval = ephUpdInd;
384
385 for (int ii = 1; ii < lines.size(); ii++) {
386 QString key; // prn or key VTEC, IND (phase bias indicators)
387 double rtnUra = 0.0; // [m]
388 ColumnVector rtnAPC; rtnAPC.ReSize(3); rtnAPC = 0.0; // [m, m, m]
389 ColumnVector rtnVel; rtnVel.ReSize(3); rtnVel = 0.0; // [m/s, m/s, m/s]
390 ColumnVector rtnCoM; rtnCoM.ReSize(3); rtnCoM = 0.0; // [m, m, m]
391 ColumnVector rtnClk; rtnClk.ReSize(3); rtnClk = 0.0; // [m, m/s, m/s²]
392 ColumnVector rtnClkSig; rtnClkSig.ReSize(3); rtnClkSig = 0.0; // [m, m/s, m/s²]
393 t_prn prn;
394
395 QTextStream in(lines[ii].toLatin1());
396
397 in >> key;
398
399 // non-satellite specific parameters
400 if (key.contains("IND", Qt::CaseSensitive)) {
401 in >> dispersiveBiasConsistenyIndicator >> mwConsistencyIndicator;
402 continue;
403 }
404 // non-satellite specific parameters
405 if (key.contains("VTEC", Qt::CaseSensitive)) {
406 double ui;
407 in >> ui >> vtec.NumLayers;
408 vtec.UpdateInterval = (unsigned int) determineUpdateInd(ui);
409 for (unsigned ll = 0; ll < vtec.NumLayers; ll++) {
410 int dummy;
411 in >> dummy >> vtec.Layers[ll].Degree >> vtec.Layers[ll].Order
412 >> vtec.Layers[ll].Height;
413 for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
414 for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
415 in >> vtec.Layers[ll].Cosinus[iDeg][iOrd];
416 }
417 }
418 for (unsigned iDeg = 0; iDeg <= vtec.Layers[ll].Degree; iDeg++) {
419 for (unsigned iOrd = 0; iOrd <= vtec.Layers[ll].Order; iOrd++) {
420 in >> vtec.Layers[ll].Sinus[iDeg][iOrd];
421 }
422 }
423 }
424 continue;
425 }
426 // satellite specific parameters
427 char sys = key.mid(0, 1).at(0).toLatin1();
428 int number = key.mid(1, 2).toInt();
429 int flags = 0;
430 if (sys == 'E') { // I/NAV
431 flags = 1;
432 }
433 prn.set(sys, number, flags);
434 QString prnInternalStr = QString::fromStdString(prn.toInternalString());
435 QString prnStr = QString::fromStdString(prn.toString());
436
437 const t_eph* ephLast = _ephUser->ephLast(prnInternalStr);
438 const t_eph* ephPrev = _ephUser->ephPrev(prnInternalStr);
439 const t_eph* eph = ephLast;
440 if (eph) {
441
442 // Use previous ephemeris if the last one is too recent
443 // ----------------------------------------------------
444 const int MINAGE = 60; // seconds
445 if (ephPrev && eph->receptDateTime().isValid()
446 && eph->receptDateTime().secsTo(currentDateAndTimeGPS()) < MINAGE) {
447 eph = ephPrev;
448 }
449
450 // Make sure the clock messages refer to same IOD as orbit messages
451 // ----------------------------------------------------------------
452 if (_usedEph) {
453 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
454 (*_usedEph)[prnInternalStr] = eph;
455 }
456 else {
457 eph = 0;
458 if (_usedEph->contains(prnInternalStr)) {
459 const t_eph* usedEph = _usedEph->value(prnInternalStr);
460 if (usedEph == ephLast) {
461 eph = ephLast;
462 }
463 else if (usedEph == ephPrev) {
464 eph = ephPrev;
465 }
466 }
467 }
468 }
469 }
470
471 if (eph &&
472 eph->checkState() != t_eph::bad &&
473 eph->checkState() != t_eph::unhealthy &&
474 eph->checkState() != t_eph::outdated) {
475 QMap<QString, double> codeBiases;
476 QList<phaseBiasSignal> phaseBiasList;
477 phaseBiasesSat pbSat;
478 bool phaseBiasInformationDecoded = false;
479
480 while (true) {
481 QString key;
482 int numVal = 0;
483 in >> key;
484 if (in.status() != QTextStream::Ok) {
485 break;
486 }
487 if (key == "APC") {
488 in >> numVal;
489 rtnAPC.ReSize(3); rtnAPC = 0.0;
490 for (int ii = 0; ii < numVal; ii++) {
491 in >> rtnAPC[ii];
492 }
493 }
494 else if (key == "Ura") {
495 in >> numVal;
496 if (numVal == 1)
497 in >> rtnUra;
498 }
499 else if (key == "Clk") {
500 in >> numVal;
501 rtnClk.ReSize(3); rtnClk = 0.0;
502 for (int ii = 0; ii < numVal; ii++) {
503 in >> rtnClk[ii];
504 }
505 }
506 else if (key == "ClkSig") {
507 in >> numVal;
508 rtnClkSig.ReSize(3); rtnClkSig = 0.0;
509 for (int ii = 0; ii < numVal; ii++) {
510 in >> rtnClkSig[ii];
511 }
512 }
513 else if (key == "Vel") {
514 in >> numVal;
515 rtnVel.ReSize(3); rtnVel = 0.0;
516 for (int ii = 0; ii < numVal; ii++) {
517 in >> rtnVel[ii];
518 }
519 }
520 else if (key == "CoM") {
521 in >> numVal;
522 rtnCoM.ReSize(3); rtnCoM = 0.0;
523 for (int ii = 0; ii < numVal; ii++) {
524 in >> rtnCoM[ii];
525 }
526 }
527 else if (key == "CodeBias") {
528 in >> numVal;
529 for (int ii = 0; ii < numVal; ii++) {
530 QString type;
531 double value;
532 in >> type >> value;
533 codeBiases[type] = value;
534 }
535 }
536 else if (key == "YawAngle") {
537 phaseBiasInformationDecoded = true;
538 in >> numVal >> pbSat.yawAngle;
539 if (pbSat.yawAngle < 0.0) {
540 pbSat.yawAngle += (2*M_PI);
541 }
542 else if (pbSat.yawAngle > 2*M_PI) {
543 pbSat.yawAngle -= (2*M_PI);
544 }
545 }
546 else if (key == "YawRate") {
547 in >> numVal >> pbSat.yawRate;
548 }
549 else if (key == "PhaseBias") {
550 phaseBiasInformationDecoded = true;
551 in >> numVal;
552 for (int ii = 0; ii < numVal; ii++) {
553 phaseBiasSignal pb;
554 in >> pb.type >> pb.bias >> pb.integerIndicator
555 >> pb.wlIndicator >> pb.discontinuityCounter;
556 phaseBiasList.append(pb);
557 }
558 }
559 else {
560 in >> numVal;
561 for (int ii = 0; ii < numVal; ii++) {
562 double dummy;
563 in >> dummy;
564 }
565 emit(newMessage(" RTNET format error: "
566 + lines[ii].toLatin1(), false));
567 }
568 }
569
570 struct SsrCorr::ClockOrbit::SatData* sd = 0;
571 if (prn.system() == 'G') {
572 sd = co.Sat + co.NumberOfSat[CLOCKORBIT_SATGPS];
573 ++co.NumberOfSat[CLOCKORBIT_SATGPS];
574 }
575 else if (prn.system() == 'R') {
576 sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfSat[CLOCKORBIT_SATGLONASS];
577 ++co.NumberOfSat[CLOCKORBIT_SATGLONASS];
578 }
579 else if (prn.system() == 'E') {
580 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
581 + co.NumberOfSat[CLOCKORBIT_SATGALILEO];
582 ++co.NumberOfSat[CLOCKORBIT_SATGALILEO];
583 }
584 else if (prn.system() == 'J') {
585 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
586 + CLOCKORBIT_NUMGALILEO
587 + co.NumberOfSat[CLOCKORBIT_SATQZSS];
588 ++co.NumberOfSat[CLOCKORBIT_SATQZSS];
589 }
590 else if (prn.system() == 'S') {
591 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
592 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
593 + co.NumberOfSat[CLOCKORBIT_SATSBAS];
594 ++co.NumberOfSat[CLOCKORBIT_SATSBAS];
595 }
596 else if (prn.system() == 'C') {
597 sd = co.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
598 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
599 + CLOCKORBIT_NUMSBAS
600 + co.NumberOfSat[CLOCKORBIT_SATBDS];
601 ++co.NumberOfSat[CLOCKORBIT_SATBDS];
602 }
603 if (sd) {
604 QString outLine;
605 t_irc irc = processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prnStr, rtnAPC,
606 rtnUra, rtnClk, rtnVel, rtnCoM, rtnClkSig, sd, outLine);
607 if (irc != success) {
608 // very few cases: check states bad and unhealthy are excluded earlier
609 sd->ID = prnStr.mid(1).toInt(); // to prevent G00, R00 entries
610 sd->IOD = eph->IOD();
611 }
612 }
613
614 // Code Biases
615 // -----------
616 struct SsrCorr::CodeBias::BiasSat* biasSat = 0;
617 if (!codeBiases.isEmpty()) {
618 if (prn.system() == 'G') {
619 biasSat = bias.Sat + bias.NumberOfSat[CLOCKORBIT_SATGPS];
620 ++bias.NumberOfSat[CLOCKORBIT_SATGPS];
621 }
622 else if (prn.system() == 'R') {
623 biasSat = bias.Sat + CLOCKORBIT_NUMGPS
624 + bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
625 ++bias.NumberOfSat[CLOCKORBIT_SATGLONASS];
626 }
627 else if (prn.system() == 'E') {
628 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
629 + bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
630 ++bias.NumberOfSat[CLOCKORBIT_SATGALILEO];
631 }
632 else if (prn.system() == 'J') {
633 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
634 + CLOCKORBIT_NUMGALILEO
635 + bias.NumberOfSat[CLOCKORBIT_SATQZSS];
636 ++bias.NumberOfSat[CLOCKORBIT_SATQZSS];
637 }
638 else if (prn.system() == 'S') {
639 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
640 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
641 + bias.NumberOfSat[CLOCKORBIT_SATSBAS];
642 ++bias.NumberOfSat[CLOCKORBIT_SATSBAS];
643 }
644 else if (prn.system() == 'C') {
645 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
646 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
647 + CLOCKORBIT_NUMSBAS
648 + bias.NumberOfSat[CLOCKORBIT_SATBDS];
649 ++bias.NumberOfSat[CLOCKORBIT_SATBDS];
650 }
651 }
652
653 if (biasSat) {
654 biasSat->ID = prn.number();
655 biasSat->NumberOfCodeBiases = 0;
656 QMapIterator<QString, double> it(codeBiases);
657 while (it.hasNext()) {
658 it.next();
659 int ii = biasSat->NumberOfCodeBiases;
660 if (ii >= CLOCKORBIT_NUMBIAS)
661 break;
662 SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), it.key().toStdString());
663 if (type != _ssrCorr->RESERVED) {
664 biasSat->NumberOfCodeBiases += 1;
665 biasSat->Biases[ii].Type = type;
666 biasSat->Biases[ii].Bias = it.value();
667 }
668 }
669 }
670
671 // Phase Biases
672 // ------------
673 struct SsrCorr::PhaseBias::PhaseBiasSat* phasebiasSat = 0;
674 if (prn.system() == 'G') {
675 phasebiasSat = phasebias.Sat
676 + phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
677 ++phasebias.NumberOfSat[CLOCKORBIT_SATGPS];
678 }
679 else if (prn.system() == 'R') {
680 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS
681 + phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
682 ++phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS];
683 }
684 else if (prn.system() == 'E') {
685 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
686 + phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
687 ++phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO];
688 }
689 else if (prn.system() == 'J') {
690 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
691 + CLOCKORBIT_NUMGALILEO
692 + phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
693 ++phasebias.NumberOfSat[CLOCKORBIT_SATQZSS];
694 }
695 else if (prn.system() == 'S') {
696 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
697 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
698 + phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
699 ++phasebias.NumberOfSat[CLOCKORBIT_SATSBAS];
700 }
701 else if (prn.system() == 'C') {
702 phasebiasSat = phasebias.Sat + CLOCKORBIT_NUMGPS + CLOCKORBIT_NUMGLONASS
703 + CLOCKORBIT_NUMGALILEO + CLOCKORBIT_NUMQZSS
704 + CLOCKORBIT_NUMSBAS
705 + phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
706 ++phasebias.NumberOfSat[CLOCKORBIT_SATBDS];
707 }
708
709 if (phasebiasSat && phaseBiasInformationDecoded) {
710 phasebias.DispersiveBiasConsistencyIndicator = dispersiveBiasConsistenyIndicator;
711 phasebias.MWConsistencyIndicator = mwConsistencyIndicator;
712 phasebiasSat->ID = prn.number();
713 phasebiasSat->NumberOfPhaseBiases = 0;
714 phasebiasSat->YawAngle = pbSat.yawAngle;
715 phasebiasSat->YawRate = pbSat.yawRate;
716 QListIterator<phaseBiasSignal> it(phaseBiasList);
717 while (it.hasNext()) {
718 const phaseBiasSignal &pbSig = it.next();
719 int ii = phasebiasSat->NumberOfPhaseBiases;
720 if (ii >= CLOCKORBIT_NUMBIAS)
721 break;
722 SsrCorr::CodeType type = _ssrCorr->rnxTypeToCodeType(prn.system(), pbSig.type.toStdString());
723 if (type != _ssrCorr->RESERVED) {
724 phasebiasSat->NumberOfPhaseBiases += 1;
725 phasebiasSat->Biases[ii].Type = type;
726 phasebiasSat->Biases[ii].Bias = pbSig.bias;
727 phasebiasSat->Biases[ii].SignalIntegerIndicator = pbSig.integerIndicator;
728 phasebiasSat->Biases[ii].SignalsWideLaneIntegerIndicator = pbSig.wlIndicator;
729 phasebiasSat->Biases[ii].SignalDiscontinuityCounter = pbSig.discontinuityCounter;
730 }
731 }
732 }
733 }
734 }
735
736 QByteArray hlpBufferCo;
737
738 // Orbit and Clock Corrections together
739 // ------------------------------------
740 if (_samplRtcmEphCorr == 0.0) {
741 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0
742 || co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
743 || co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
744 || co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
745 || co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
746 || co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
747 char obuffer[CLOCKORBIT_BUFFERSIZE];
748 int len = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
749 if (len > 0) {
750 hlpBufferCo = QByteArray(obuffer, len);
751 }
752 }
753 }
754
755 // Orbit and Clock Corrections separately
756 // --------------------------------------
757 else {
758 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
759 char obuffer[CLOCKORBIT_BUFFERSIZE];
760 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
761 co.UpdateInterval = ephUpdInd;
762 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSORBIT, 1, obuffer,
763 sizeof(obuffer));
764 co.UpdateInterval = clkUpdInd;
765 if (len1 > 0) {
766 hlpBufferCo += QByteArray(obuffer, len1);
767 }
768 }
769 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0 ||
770 co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
771 co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
772 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
773 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
774 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSCLOCK, mmsg, obuffer,
775 sizeof(obuffer));
776 if (len2 > 0) {
777 hlpBufferCo += QByteArray(obuffer, len2);
778 }
779 }
780 if (co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) {
781 char obuffer[CLOCKORBIT_BUFFERSIZE];
782 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
783 co.UpdateInterval = ephUpdInd;
784 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSORBIT, 1, obuffer,
785 sizeof(obuffer));
786 co.UpdateInterval = clkUpdInd;
787 if (len1 > 0) {
788 hlpBufferCo += QByteArray(obuffer, len1);
789 }
790 }
791 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0 ||
792 co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
793 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
794 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
795 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSCLOCK, mmsg, obuffer,
796 sizeof(obuffer));
797 if (len2 > 0) {
798 hlpBufferCo += QByteArray(obuffer, len2);
799 }
800 }
801 if (co.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0) {
802 char obuffer[CLOCKORBIT_BUFFERSIZE];
803 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
804 co.UpdateInterval = ephUpdInd;
805 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOORBIT, 1, obuffer,
806 sizeof(obuffer));
807 co.UpdateInterval = clkUpdInd;
808 if (len1 > 0) {
809 hlpBufferCo += QByteArray(obuffer, len1);
810 }
811 }
812 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0 ||
813 co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
814 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
815 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOCLOCK, mmsg, obuffer,
816 sizeof(obuffer));
817 if (len2 > 0) {
818 hlpBufferCo += QByteArray(obuffer, len2);
819 }
820 }
821 if (co.NumberOfSat[CLOCKORBIT_SATQZSS] > 0) {
822 char obuffer[CLOCKORBIT_BUFFERSIZE];
823 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
824 co.UpdateInterval = ephUpdInd;
825 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSORBIT, 1, obuffer,
826 sizeof(obuffer));
827 co.UpdateInterval = clkUpdInd;
828 if (len1 > 0) {
829 hlpBufferCo += QByteArray(obuffer, len1);
830 }
831 }
832 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0 ||
833 co.NumberOfSat[CLOCKORBIT_SATBDS] > 0 ) ? 1 : 0;
834 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSCLOCK, mmsg, obuffer,
835 sizeof(obuffer));
836 if (len2 > 0) {
837 hlpBufferCo += QByteArray(obuffer, len2);
838 }
839 }
840 if (co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0) {
841 char obuffer[CLOCKORBIT_BUFFERSIZE];
842 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
843 co.UpdateInterval = ephUpdInd;
844 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASORBIT, 1, obuffer,
845 sizeof(obuffer));
846 co.UpdateInterval = clkUpdInd;
847 if (len1 > 0) {
848 hlpBufferCo += QByteArray(obuffer, len1);
849 }
850 }
851 int mmsg = (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) ? 1 : 0;
852 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASCLOCK, mmsg, obuffer,
853 sizeof(obuffer));
854 if (len2 > 0) {
855 hlpBufferCo += QByteArray(obuffer, len2);
856 }
857 }
858 if (co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
859 char obuffer[CLOCKORBIT_BUFFERSIZE];
860 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
861 co.UpdateInterval = ephUpdInd;
862 int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSORBIT, 1, obuffer,
863 sizeof(obuffer));
864 co.UpdateInterval = clkUpdInd;
865 if (len1 > 0) {
866 hlpBufferCo += QByteArray(obuffer, len1);
867 }
868 }
869 int mmsg = 0;
870 int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSCLOCK, mmsg, obuffer,
871 sizeof(obuffer));
872 if (len2 > 0) {
873 hlpBufferCo += QByteArray(obuffer, len2);
874 }
875 }
876 }
877
878 // Code Biases
879 // -----------
880 QByteArray hlpBufferBias;
881 if (bias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
882 || bias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
883 || bias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
884 || bias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
885 || bias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
886 || bias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
887 char obuffer[CLOCKORBIT_BUFFERSIZE];
888 int len = _ssrCorr->MakeCodeBias(&bias, _ssrCorr->CBTYPE_AUTO, 0, obuffer, sizeof(obuffer));
889 if (len > 0) {
890 hlpBufferBias = QByteArray(obuffer, len);
891 }
892 }
893
894 // Phase Biases
895 // ------------
896 QByteArray hlpBufferPhaseBias;
897 if (phasebias.NumberOfSat[CLOCKORBIT_SATGPS] > 0
898 || phasebias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0
899 || phasebias.NumberOfSat[CLOCKORBIT_SATGALILEO] > 0
900 || phasebias.NumberOfSat[CLOCKORBIT_SATQZSS] > 0
901 || phasebias.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
902 || phasebias.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
903 char obuffer[CLOCKORBIT_BUFFERSIZE];
904 int len = _ssrCorr->MakePhaseBias(&phasebias, _ssrCorr->PBTYPE_AUTO, 0, obuffer,
905 sizeof(obuffer));
906 if (len > 0) {
907 hlpBufferPhaseBias = QByteArray(obuffer, len);
908 }
909 }
910
911 // VTEC
912 // ----
913 QByteArray hlpBufferVtec;
914 if (vtec.NumLayers > 0) {
915 char obuffer[CLOCKORBIT_BUFFERSIZE];
916 int len = _ssrCorr->MakeVTEC(&vtec, 0, obuffer, sizeof(obuffer));
917 if (len > 0) {
918 hlpBufferVtec = QByteArray(obuffer, len);
919 }
920 }
921
922 _outBuffer += hlpBufferCo + hlpBufferBias + hlpBufferPhaseBias
923 + hlpBufferVtec;
924}
925
926//
927////////////////////////////////////////////////////////////////////////////
928t_irc bncRtnetUploadCaster::processSatellite(const t_eph* eph, int GPSweek,
929 double GPSweeks, const QString& prn, const ColumnVector& rtnAPC,
930 double rtnUra, const ColumnVector& rtnClk, const ColumnVector& rtnVel,
931 const ColumnVector& rtnCoM, const ColumnVector& rtnClkSig,
932 struct SsrCorr::ClockOrbit::SatData* sd, QString& outLine) {
933
934 // Broadcast Position and Velocity
935 // -------------------------------
936 ColumnVector xB(6);
937 ColumnVector vB(3);
938 t_irc irc = eph->getCrd(bncTime(GPSweek, GPSweeks), xB, vB, false);
939
940 if (irc != success) {
941 return irc;
942 }
943
944 // Precise Position
945 // ----------------
946 ColumnVector xP = _CoM ? rtnCoM : rtnAPC;
947
948 if (xP.size() == 0) {
949 return failure;
950 }
951
952 double dc = 0.0;
953 if (_crdTrafo != "IGS14") {
954 crdTrafo(GPSweek, xP, dc);
955 }
956
957 // Difference in xyz
958 // -----------------
959 ColumnVector dx = xB.Rows(1, 3) - xP;
960 ColumnVector dv = vB - rtnVel;
961
962 // Difference in RSW
963 // -----------------
964 ColumnVector rsw(3);
965 XYZ_to_RSW(xB.Rows(1, 3), vB, dx, rsw);
966
967 ColumnVector dotRsw(3);
968 XYZ_to_RSW(xB.Rows(1, 3), vB, dv, dotRsw);
969
970 // Clock Correction
971 // ----------------
972 double dClkA0 = rtnClk(1) - (xB(4) - dc) * t_CST::c;
973 double dClkA1 = 0.0;
974 if (rtnClk(2)) {
975 dClkA1 = rtnClk(2) - xB(5) * t_CST::c;
976 }
977 double dClkA2 = 0.0;
978 if (rtnClk(3)) {
979 dClkA2 = rtnClk(3) - xB(6) * t_CST::c;
980 }
981
982 if (sd) {
983 sd->ID = prn.mid(1).toInt();
984 sd->IOD = eph->IOD();
985 sd->Clock.DeltaA0 = dClkA0;
986 sd->Clock.DeltaA1 = dClkA1;
987 sd->Clock.DeltaA2 = dClkA2;
988 sd->UserRangeAccuracy = rtnUra;
989 sd->Orbit.DeltaRadial = rsw(1);
990 sd->Orbit.DeltaAlongTrack = rsw(2);
991 sd->Orbit.DeltaCrossTrack = rsw(3);
992 sd->Orbit.DotDeltaRadial = dotRsw(1);
993 sd->Orbit.DotDeltaAlongTrack = dotRsw(2);
994 sd->Orbit.DotDeltaCrossTrack = dotRsw(3);
995 }
996
997 outLine.sprintf("%d %.1f %s %u %10.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n", GPSweek,
998 GPSweeks, eph->prn().toString().c_str(), eph->IOD(), dClkA0, dClkA1, dClkA2,
999 rsw(1), rsw(2), rsw(3));
1000
1001 // RTNET full clock for RINEX and SP3 file
1002 // ---------------------------------------
1003 double relativity = -2.0 * DotProduct(xP, rtnVel) / t_CST::c;
1004 double clkRnx = (rtnClk[0] - relativity) / t_CST::c; // [s]
1005 double clkRnxRate = rtnClk[1] / t_CST::c; // [s/s = -]
1006 double clkRnxAcc = rtnClk[2] / t_CST::c; // [s/s² ) -/s]
1007
1008 if (_rnx) {
1009 double clkRnxSig, clkRnxRateSig, clkRnxAccSig;
1010 int s = rtnClkSig.size();
1011 switch (s) {
1012 case 1:
1013 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1014 clkRnxRateSig = 0.0; // [s/s = -]
1015 clkRnxAccSig = 0.0; // [s/s² ) -/s]
1016 break;
1017 case 2:
1018 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1019 clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
1020 clkRnxAccSig = 0.0; // [s/s² ) -/s]
1021 break;
1022 case 3:
1023 clkRnxSig = rtnClkSig[0] / t_CST::c; // [s]
1024 clkRnxRateSig = rtnClkSig[1] / t_CST::c; // [s/s = -]
1025 clkRnxAccSig = rtnClkSig[2] / t_CST::c; // [s/s² ) -/s]
1026 break;
1027 }
1028 _rnx->write(GPSweek, GPSweeks, prn, clkRnx, clkRnxRate, clkRnxAcc,
1029 clkRnxSig, clkRnxRateSig, clkRnxAccSig);
1030 }
1031 if (_sp3) {
1032 _sp3->write(GPSweek, GPSweeks, prn, rtnCoM, clkRnx, rtnVel, clkRnxRate);
1033 }
1034 return success;
1035}
1036
1037// Transform Coordinates
1038////////////////////////////////////////////////////////////////////////////
1039void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz,
1040 double& dc) {
1041
1042 // Current epoch minus 2000.0 in years
1043 // ------------------------------------
1044 double dt = (GPSWeek - (1042.0 + 6.0 / 7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
1045
1046 ColumnVector dx(3);
1047
1048 dx(1) = _dx + dt * _dxr;
1049 dx(2) = _dy + dt * _dyr;
1050 dx(3) = _dz + dt * _dzr;
1051
1052 static const double arcSec = 180.0 * 3600.0 / M_PI;
1053
1054 double ox = (_ox + dt * _oxr) / arcSec;
1055 double oy = (_oy + dt * _oyr) / arcSec;
1056 double oz = (_oz + dt * _ozr) / arcSec;
1057
1058 double sc = 1.0 + _sc * 1e-9 + dt * _scr * 1e-9;
1059
1060 // Specify approximate center of area
1061 // ----------------------------------
1062 ColumnVector meanSta(3);
1063
1064 if (_crdTrafo == "ETRF2000") {
1065 meanSta(1) = 3661090.0;
1066 meanSta(2) = 845230.0;
1067 meanSta(3) = 5136850.0;
1068 }
1069 else if (_crdTrafo == "GDA2020") {
1070 meanSta(1) = -4052050.0;
1071 meanSta(2) = 4212840.0;
1072 meanSta(3) = -2545110.0;
1073 }
1074 else if (_crdTrafo == "SIRGAS2000") {
1075 meanSta(1) = 3740860.0;
1076 meanSta(2) = -4964290.0;
1077 meanSta(3) = -1425420.0;
1078 }
1079 else if (_crdTrafo == "DREF91") {
1080 meanSta(1) = 3959579.0;
1081 meanSta(2) = 721719.0;
1082 meanSta(3) = 4931539.0;
1083 }
1084 else if (_crdTrafo == "Custom") {
1085 meanSta(1) = 0.0; // TODO
1086 meanSta(2) = 0.0; // TODO
1087 meanSta(3) = 0.0; // TODO
1088 }
1089
1090 // Clock correction proportional to topocentric distance to satellites
1091 // -------------------------------------------------------------------
1092 double rho = (xyz - meanSta).NormFrobenius();
1093 dc = rho * (sc - 1.0) / sc / t_CST::c;
1094
1095 Matrix rMat(3, 3);
1096 rMat(1, 1) = 1.0;
1097 rMat(1, 2) = -oz;
1098 rMat(1, 3) = oy;
1099 rMat(2, 1) = oz;
1100 rMat(2, 2) = 1.0;
1101 rMat(2, 3) = -ox;
1102 rMat(3, 1) = -oy;
1103 rMat(3, 2) = ox;
1104 rMat(3, 3) = 1.0;
1105
1106 xyz = sc * rMat * xyz + dx;
1107}
1108
1109int bncRtnetUploadCaster::determineUpdateInd(double samplingRate) {
1110
1111 if (samplingRate == 10.0) {
1112 return 3;
1113 }
1114 else if (samplingRate == 15.0) {
1115 return 4;
1116 }
1117 else if (samplingRate == 30.0) {
1118 return 5;
1119 }
1120 else if (samplingRate == 60.0) {
1121 return 6;
1122 }
1123 else if (samplingRate == 120.0) {
1124 return 7;
1125 }
1126 else if (samplingRate == 240.0) {
1127 return 8;
1128 }
1129 else if (samplingRate == 300.0) {
1130 return 9;
1131 }
1132 else if (samplingRate == 600.0) {
1133 return 10;
1134 }
1135 else if (samplingRate == 900.0) {
1136 return 11;
1137 }
1138 else if (samplingRate == 1800.0) {
1139 return 12;
1140 }
1141 else if (samplingRate == 3600.0) {
1142 return 13;
1143 }
1144 else if (samplingRate == 7200.0) {
1145 return 14;
1146 }
1147 else if (samplingRate == 10800.0) {
1148 return 15;
1149 }
1150 return 2; // default
1151}
Note: See TracBrowser for help on using the repository browser.