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

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

some modification to allow encoding and decoding of SSR corrections in RTCM-SSR and IGS-SSR formats

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