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

Last change on this file since 5340 was 5340, checked in by weber, 11 years ago

DREF91 transformation added

File size: 19.4 KB
RevLine 
[3222]1/* -------------------------------------------------------------------------
2 * BKG NTRIP Server
3 * -------------------------------------------------------------------------
4 *
[3224]5 * Class: bncRtnetUploadCaster
[3222]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>
[3224]18#include "bncrtnetuploadcaster.h"
[3222]19#include "bncsettings.h"
[3224]20#include "bncephuser.h"
[3222]21#include "bncclockrinex.h"
22#include "bncsp3.h"
23
24using namespace std;
25
26// Constructor
27////////////////////////////////////////////////////////////////////////////
[3224]28bncRtnetUploadCaster::bncRtnetUploadCaster(const QString& mountpoint,
[3222]29 const QString& outHost, int outPort,
30 const QString& password,
31 const QString& crdTrafo, bool CoM,
32 const QString& sp3FileName,
33 const QString& rnxFileName,
[4111]34 int PID, int SID, int IOD, int iRow) :
[3273]35 bncUploadCaster(mountpoint, outHost, outPort, password, iRow, 0) {
[3224]36
[5130]37 if (!outHost.isEmpty()) {
38 _casterID += outHost;
39 }
40 if (!crdTrafo.isEmpty()) {
41 _casterID += " " + crdTrafo;
42 }
43 if (!sp3FileName.isEmpty()) {
44 _casterID += " " + sp3FileName;
45 }
46 if (!rnxFileName.isEmpty()) {
47 _casterID += " " + rnxFileName;
48 }
49
[3222]50 _crdTrafo = crdTrafo;
51 _CoM = CoM;
[4111]52 _PID = PID;
53 _SID = SID;
54 _IOD = IOD;
[3222]55
[3224]56 // Member that receives the ephemeris
57 // ----------------------------------
58 _ephUser = new bncEphUser();
[3222]59
[3272]60 bncSettings settings;
61 QString intr = settings.value("uploadIntr").toString();
[4174]62
63 _samplRtcmEphCorr = settings.value("uploadSamplRtcmEphCorr").toDouble();
[4542]64 int samplClkRnx = settings.value("uploadSamplClkRnx").toInt();
65 int samplSp3 = settings.value("uploadSamplSp3").toInt() * 60;
[4174]66
67 if (_samplRtcmEphCorr == 0.0) {
[3753]68 _usedEph = 0;
69 }
70 else {
71 _usedEph = new QMap<QString, t_eph*>;
72 }
[3272]73
[3222]74 // RINEX writer
75 // ------------
76 if (!rnxFileName.isEmpty()) {
[4174]77 _rnx = new bncClockRinex(rnxFileName, intr, samplClkRnx);
[3222]78 }
79 else {
80 _rnx = 0;
81 }
82
83 // SP3 writer
84 // ----------
85 if (!sp3FileName.isEmpty()) {
[4174]86 _sp3 = new bncSP3(sp3FileName, intr, samplSp3);
[3222]87 }
88 else {
89 _sp3 = 0;
90 }
91
92 // Set Transformation Parameters
93 // -----------------------------
94 if (_crdTrafo == "ETRF2000") {
[3890]95 _dx = 0.0521;
96 _dy = 0.0493;
97 _dz = -0.0585;
98 _dxr = 0.0001;
[3222]99 _dyr = 0.0001;
100 _dzr = -0.0018;
101 _ox = 0.000891;
102 _oy = 0.005390;
103 _oz = -0.008712;
104 _oxr = 0.000081;
105 _oyr = 0.000490;
106 _ozr = -0.000792;
[3890]107 _sc = 1.34;
[3222]108 _scr = 0.08;
109 _t0 = 2000.0;
110 }
111 else if (_crdTrafo == "NAD83") {
112 _dx = 0.9963;
113 _dy = -1.9024;
114 _dz = -0.5210;
115 _dxr = 0.0005;
116 _dyr = -0.0006;
117 _dzr = -0.0013;
[3498]118 _ox = -0.025915;
119 _oy = -0.009426;
120 _oz = -0.011599;
121 _oxr = -0.000067;
122 _oyr = 0.000757;
123 _ozr = 0.000051;
[3222]124 _sc = 0.78;
125 _scr = -0.10;
126 _t0 = 1997.0;
127 }
128 else if (_crdTrafo == "GDA94") {
[4963]129 _dx = -0.08468;
130 _dy = -0.01942;
131 _dz = 0.03201;
132 _dxr = 0.00142;
133 _dyr = 0.00134;
134 _dzr = 0.00090;
135 _ox = 0.0004254;
136 _oy = -0.0022578;
137 _oz = -0.0024015;
138 _oxr = -0.0015461;
139 _oyr = -0.0011820;
140 _ozr = -0.0011551;
141 _sc = 9.710;
142 _scr = 0.109;
[3222]143 _t0 = 1994.0;
144 }
145 else if (_crdTrafo == "SIRGAS2000") {
[4956]146 _dx = 0.0020;
147 _dy = 0.0041;
148 _dz = 0.0039;
[3222]149 _dxr = 0.0000;
150 _dyr = 0.0000;
151 _dzr = 0.0000;
[4956]152 _ox = 0.000170;
153 _oy = -0.000030;
154 _oz = 0.000070;
[3222]155 _oxr = 0.000000;
156 _oyr = 0.000000;
157 _ozr = 0.000000;
158 _sc = 0.000;
159 _scr = 0.000;
160 _t0 = 0000.0;
161 }
162 else if (_crdTrafo == "SIRGAS95") {
163 _dx = 0.0077;
164 _dy = 0.0058;
165 _dz = -0.0138;
166 _dxr = 0.0000;
167 _dyr = 0.0000;
168 _dzr = 0.0000;
169 _ox = 0.000000;
170 _oy = 0.000000;
171 _oz = -0.000030;
172 _oxr = 0.000000;
173 _oyr = 0.000000;
174 _ozr = 0.000000;
175 _sc = 1.570;
176 _scr = 0.000;
177 _t0 = 0000.0;
178 }
[5340]179 elso if (_crdTrafo == "DREF91") {
180 _dx = -0.0118;
181 _dy = 0.1432;
182 _dz = -0.1117;
183 _dxr = 0.0001;
184 _dyr = 0.0001;
185 _dzr = -0.0018;
186 _ox = 0.003291;
187 _oy = 0.006190;
188 _oz = -0.011012;
189 _oxr = 0.000081;
190 _oyr = 0.000490;
191 _ozr = -0.000792;
192 _sc = 12.24;
193 _scr = 0.08;
194 _t0 = 2000.0;
195 }
[3222]196 else if (_crdTrafo == "Custom") {
197 _dx = settings.value("trafo_dx").toDouble();
198 _dy = settings.value("trafo_dy").toDouble();
199 _dz = settings.value("trafo_dz").toDouble();
200 _dxr = settings.value("trafo_dxr").toDouble();
201 _dyr = settings.value("trafo_dyr").toDouble();
202 _dzr = settings.value("trafo_dzr").toDouble();
203 _ox = settings.value("trafo_ox").toDouble();
204 _oy = settings.value("trafo_oy").toDouble();
205 _oz = settings.value("trafo_oz").toDouble();
206 _oxr = settings.value("trafo_oxr").toDouble();
207 _oyr = settings.value("trafo_oyr").toDouble();
208 _ozr = settings.value("trafo_ozr").toDouble();
209 _sc = settings.value("trafo_sc").toDouble();
210 _scr = settings.value("trafo_scr").toDouble();
211 _t0 = settings.value("trafo_t0").toDouble();
212 }
213}
214
215// Destructor
216////////////////////////////////////////////////////////////////////////////
[3224]217bncRtnetUploadCaster::~bncRtnetUploadCaster() {
[3222]218 if (isRunning()) {
219 wait();
220 }
221 delete _rnx;
222 delete _sp3;
223 delete _ephUser;
[3753]224 delete _usedEph;
[3222]225}
226
227//
228////////////////////////////////////////////////////////////////////////////
[3224]229void bncRtnetUploadCaster::decodeRtnetStream(char* buffer, int bufLen) {
[3222]230
231 QMutexLocker locker(&_mutex);
232
[3230]233 // Append to internal buffer
234 // -------------------------
[3222]235 _rtnetStreamBuffer.append(QByteArray(buffer, bufLen));
[3230]236
237 // Select buffer part that contains last epoch
238 // -------------------------------------------
239 QStringList lines;
240 int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*'); // begin of last epoch
241 if (iEpoBeg == -1) {
[3226]242 _rtnetStreamBuffer.clear();
243 return;
[3222]244 }
[3230]245 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
246
247 int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end of last epoch
248 if (iEpoEnd == -1) {
249 return;
250 }
[3226]251 else {
[3230]252 lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
253 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd+3);
[3226]254 }
[3222]255
[3226]256 if (lines.size() < 2) {
[3222]257 return;
258 }
259
[3226]260 // Keep the last unfinished line in buffer
261 // ---------------------------------------
262 int iLastEOL = _rtnetStreamBuffer.lastIndexOf('\n');
263 if (iLastEOL != -1) {
264 _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastEOL+1);
265 }
266
267 // Read first line (with epoch time)
268 // ---------------------------------
269 QTextStream in(lines[0].toAscii());
270 QString hlp;
271 int year, month, day, hour, min;
272 double sec;
273 in >> hlp >> year >> month >> day >> hour >> min >> sec;
274 bncTime epoTime; epoTime.set( year, month, day, hour, min, sec);
275
[5131]276 emit(newMessage("bncRtnetUploadCaster: decode " +
277 QByteArray(epoTime.datestr().c_str()) + " " +
[5132]278 QByteArray(epoTime.timestr().c_str()) + " " +
279 _casterID.toAscii(), false));
[4808]280
[3222]281 struct ClockOrbit co;
282 memset(&co, 0, sizeof(co));
[3226]283 co.GPSEpochTime = static_cast<int>(epoTime.gpssec());
284 co.GLONASSEpochTime = static_cast<int>(fmod(epoTime.gpssec(), 86400.0))
[3222]285 + 3 * 3600 - gnumleap(year, month, day);
286 co.ClockDataSupplied = 1;
287 co.OrbitDataSupplied = 1;
288 co.SatRefDatum = DATUM_ITRF;
[4111]289 co.SSRIOD = _IOD;
290 co.SSRProviderID = _PID; // 256 .. BKG, 257 ... EUREF
291 co.SSRSolutionID = _SID;
[3222]292
293 struct Bias bias;
294 memset(&bias, 0, sizeof(bias));
[3226]295 bias.GPSEpochTime = co.GPSEpochTime;
296 bias.GLONASSEpochTime = co.GLONASSEpochTime;
[3222]297
[4753]298 // Default Update Interval
299 // -----------------------
[4754]300 int clkUpdInd = 2; // 5 sec
301 int ephUpdInd = clkUpdInd; // default
302 if (_samplRtcmEphCorr == 10.0) {
303 ephUpdInd = 3;
304 }
305 else if (_samplRtcmEphCorr == 15.0) {
306 ephUpdInd = 4;
307 }
308 else if (_samplRtcmEphCorr == 30.0) {
309 ephUpdInd = 5;
310 }
311 else if (_samplRtcmEphCorr == 60.0) {
312 ephUpdInd = 6;
313 }
314 else if (_samplRtcmEphCorr == 120.0) {
315 ephUpdInd = 7;
316 }
317 else if (_samplRtcmEphCorr == 240.0) {
318 ephUpdInd = 8;
319 }
320 else if (_samplRtcmEphCorr == 300.0) {
321 ephUpdInd = 9;
322 }
323 else if (_samplRtcmEphCorr == 600.0) {
324 ephUpdInd = 10;
325 }
326 else if (_samplRtcmEphCorr == 900.0) {
327 ephUpdInd = 11;
328 }
[4753]329
[4754]330 co.UpdateInterval = clkUpdInd;
331 bias.UpdateInterval = clkUpdInd;
[4753]332
[3226]333 for (int ii = 1; ii < lines.size(); ii++) {
334
[3222]335 QString prn;
[4991]336 ColumnVector rtnAPC;
337 ColumnVector rtnVel;
338 ColumnVector rtnCoM;
339 double rtnClk;
[3222]340
341 QTextStream in(lines[ii].toAscii());
342
343 in >> prn;
344
[3753]345 t_eph* eph = 0;
[3222]346 const bncEphUser::t_ephPair* ephPair = _ephUser->ephPair(prn);
347 if (ephPair) {
348
[3754]349 eph = ephPair->last;
350
[4098]351 // Use previous ephemeris if the last one is too recent
352 // ----------------------------------------------------
353 const int MINAGE = 60; // seconds
354 if (ephPair->prev && eph->receptDateTime().isValid() &&
355 eph->receptDateTime().secsTo(currentDateAndTimeGPS()) < MINAGE) {
356 eph = ephPair->prev;
357 }
[3754]358
[3753]359 // Make sure the clock messages refer to same IOD as orbit messages
360 // ----------------------------------------------------------------
361 if (_usedEph) {
[4174]362 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
[3753]363 (*_usedEph)[prn] = eph;
364 }
365 else {
366 eph = 0;
367 if (_usedEph->contains(prn)) {
368 t_eph* usedEph = _usedEph->value(prn);
369 if (usedEph == ephPair->last) {
370 eph = ephPair->last;
371 }
372 else if (usedEph == ephPair->prev) {
373 eph = ephPair->prev;
374 }
375 }
376 }
377 }
378 }
379
380 if (eph) {
381
[4991]382 while (true) {
383 QString key;
384 int numVal = 0;
385 in >> key >> numVal;
386 if (in.status() != QTextStream::Ok) {
387 break;
388 }
389 if (key == "APC") {
390 rtnAPC.ReSize(3);
391 in >> rtnAPC[0] >> rtnAPC[1] >> rtnAPC[2];
392 }
393 else if (key == "Clk") {
394 in >> rtnClk;
395 }
396 else if (key == "Vel") {
397 rtnVel.ReSize(3);
398 in >> rtnVel[0] >> rtnVel[1] >> rtnVel[2];
399 }
400 else if (key == "CoM") {
401 rtnCoM.ReSize(3);
402 in >> rtnCoM[0] >> rtnCoM[1] >> rtnCoM[2];
403 }
404 else {
405 for (int ii = 0; ii < numVal; ii++) {
406 double dummy;
407 in >> dummy;
408 }
409 }
410 }
[3222]411 struct ClockOrbit::SatData* sd = 0;
412 if (prn[0] == 'G') {
413 sd = co.Sat + co.NumberOfGPSSat;
414 ++co.NumberOfGPSSat;
415 }
416 else if (prn[0] == 'R') {
417 sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
418 ++co.NumberOfGLONASSSat;
419 }
420 if (sd) {
421 QString outLine;
[3226]422 processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prn,
[4991]423 rtnAPC, rtnClk, rtnVel, rtnCoM, sd, outLine);
[3222]424 }
425
426 struct Bias::BiasSat* biasSat = 0;
427 if (prn[0] == 'G') {
428 biasSat = bias.Sat + bias.NumberOfGPSSat;
429 ++bias.NumberOfGPSSat;
430 }
431 else if (prn[0] == 'R') {
432 biasSat = bias.Sat + CLOCKORBIT_NUMGPS + bias.NumberOfGLONASSSat;
433 ++bias.NumberOfGLONASSSat;
434 }
435
436 // Coefficient of Ionosphere-Free LC
437 // ---------------------------------
[4991]438 // const static double a_L1_GPS = 2.54572778;
439 // const static double a_L2_GPS = -1.54572778;
440 // const static double a_L1_Glo = 2.53125000;
441 // const static double a_L2_Glo = -1.53125000;
[3222]442
443 if (biasSat) {
444 biasSat->ID = prn.mid(1).toInt();
445 biasSat->NumberOfCodeBiases = 3;
446 if (prn[0] == 'G') {
447 biasSat->Biases[0].Type = CODETYPEGPS_L1_Z;
[4991]448 // biasSat->Biases[0].Bias = - a_L2_GPS * xx(10);
449 biasSat->Biases[0].Bias = 0.0;
[3222]450 biasSat->Biases[1].Type = CODETYPEGPS_L1_CA;
[4991]451 // biasSat->Biases[1].Bias = - a_L2_GPS * xx(10) + xx(9);
452 biasSat->Biases[1].Bias = 0.0;
[3222]453 biasSat->Biases[2].Type = CODETYPEGPS_L2_Z;
[4991]454 // biasSat->Biases[2].Bias = a_L1_GPS * xx(10);
455 biasSat->Biases[2].Bias = 0.0;
[3222]456 }
457 else if (prn[0] == 'R') {
458 biasSat->Biases[0].Type = CODETYPEGLONASS_L1_P;
[4991]459 // biasSat->Biases[0].Bias = - a_L2_Glo * xx(10);
460 biasSat->Biases[0].Bias = 0.0;
[3222]461 biasSat->Biases[1].Type = CODETYPEGLONASS_L1_CA;
[4991]462 // biasSat->Biases[1].Bias = - a_L2_Glo * xx(10) + xx(9);
463 biasSat->Biases[1].Bias = 0.0;
[3222]464 biasSat->Biases[2].Type = CODETYPEGLONASS_L2_P;
[4991]465 // biasSat->Biases[2].Bias = a_L1_Glo * xx(10);
466 biasSat->Biases[2].Bias = 0.0;
[3222]467 }
468 }
469 }
470 }
[3227]471
472 QByteArray hlpBufferCo;
[3493]473
474 // Orbit and Clock Corrections together
475 // ------------------------------------
[4174]476 if (_samplRtcmEphCorr == 0.0) {
[3493]477 if (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) {
478 char obuffer[CLOCKORBIT_BUFFERSIZE];
479 int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
480 if (len > 0) {
481 hlpBufferCo = QByteArray(obuffer, len);
482 }
[3222]483 }
484 }
[3493]485
486 // Orbit and Clock Corrections separately
487 // --------------------------------------
488 else {
489 if (co.NumberOfGPSSat > 0) {
490 char obuffer[CLOCKORBIT_BUFFERSIZE];
[4174]491 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
[4754]492 co.UpdateInterval = ephUpdInd;
[3591]493 int len1 = MakeClockOrbit(&co, COTYPE_GPSORBIT, 1, obuffer, sizeof(obuffer));
[4754]494 co.UpdateInterval = clkUpdInd;
[3493]495 if (len1 > 0) {
496 hlpBufferCo += QByteArray(obuffer, len1);
497 }
498 }
[3591]499 int mmsg = (co.NumberOfGLONASSSat > 0) ? 1 : 0;
500 int len2 = MakeClockOrbit(&co, COTYPE_GPSCLOCK, mmsg, obuffer, sizeof(obuffer));
[3493]501 if (len2 > 0) {
502 hlpBufferCo += QByteArray(obuffer, len2);
503 }
504 }
505 if (co.NumberOfGLONASSSat > 0) {
506 char obuffer[CLOCKORBIT_BUFFERSIZE];
[4174]507 if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
[4754]508 co.UpdateInterval = ephUpdInd;
[3591]509 int len1 = MakeClockOrbit(&co, COTYPE_GLONASSORBIT, 1, obuffer, sizeof(obuffer));
[4754]510 co.UpdateInterval = clkUpdInd;
[3493]511 if (len1 > 0) {
512 hlpBufferCo += QByteArray(obuffer, len1);
513 }
514 }
515 int len2 = MakeClockOrbit(&co, COTYPE_GLONASSCLOCK, 0, obuffer, sizeof(obuffer));
516 if (len2 > 0) {
517 hlpBufferCo += QByteArray(obuffer, len2);
518 }
519 }
520 }
[3222]521
[3493]522 // Biases
523 // ------
[3227]524 QByteArray hlpBufferBias;
[3222]525 if (bias.NumberOfGPSSat > 0 || bias.NumberOfGLONASSSat > 0) {
526 char obuffer[CLOCKORBIT_BUFFERSIZE];
527 int len = MakeBias(&bias, BTYPE_AUTO, 0, obuffer, sizeof(obuffer));
528 if (len > 0) {
[3227]529 hlpBufferBias = QByteArray(obuffer, len);
[3222]530 }
531 }
[3227]532
[4808]533 _outBuffer += hlpBufferCo + hlpBufferBias;
[3222]534}
535
536//
537////////////////////////////////////////////////////////////////////////////
[3224]538void bncRtnetUploadCaster::processSatellite(t_eph* eph, int GPSweek,
[4991]539 double GPSweeks, const QString& prn,
540 const ColumnVector& rtnAPC,
541 double rtnClk,
542 const ColumnVector& rtnVel,
543 const ColumnVector& rtnCoM,
544 struct ClockOrbit::SatData* sd,
545 QString& outLine) {
[3222]546
[4930]547 // Broadcast Position and Velocity
548 // -------------------------------
549 ColumnVector xB(4);
550 ColumnVector vB(3);
551 eph->position(GPSweek, GPSweeks, xB.data(), vB.data());
552
[4991]553 // Precise Position
554 // ----------------
555 ColumnVector xP = _CoM ? rtnCoM : rtnAPC;
[3222]556
[4930]557 double dc = 0.0;
558 if (_crdTrafo != "IGS08") {
559 crdTrafo(GPSweek, xP, dc);
560 }
561
562 // Difference in xyz
563 // -----------------
564 ColumnVector dx = xB.Rows(1,3) - xP;
[4991]565 ColumnVector dv = vB - rtnVel;
[4930]566
567 // Difference in RSW
568 // -----------------
[3222]569 ColumnVector rsw(3);
[4930]570 XYZ_to_RSW(xB.Rows(1,3), vB, dx, rsw);
[3222]571
[4930]572 ColumnVector dotRsw(3);
573 XYZ_to_RSW(xB.Rows(1,3), vB, dv, dotRsw);
[3222]574
[4930]575 // Clock Correction
576 // ----------------
[4991]577 double dClk = rtnClk - (xB(4) - dc) * t_CST::c;
[3222]578
579 if (sd) {
[4930]580 sd->ID = prn.mid(1).toInt();
581 sd->IOD = eph->IOD();
582 sd->Clock.DeltaA0 = dClk;
583 sd->Orbit.DeltaRadial = rsw(1);
584 sd->Orbit.DeltaAlongTrack = rsw(2);
585 sd->Orbit.DeltaCrossTrack = rsw(3);
586 sd->Orbit.DotDeltaRadial = dotRsw(1);
587 sd->Orbit.DotDeltaAlongTrack = dotRsw(2);
588 sd->Orbit.DotDeltaCrossTrack = dotRsw(3);
[3222]589 }
590
591 outLine.sprintf("%d %.1f %s %3d %10.3f %8.3f %8.3f %8.3f\n",
[3255]592 GPSweek, GPSweeks, eph->prn().toAscii().data(),
[3222]593 eph->IOD(), dClk, rsw(1), rsw(2), rsw(3));
594
[4991]595 double relativity = -2.0 * DotProduct(xP, rtnVel) / t_CST::c;
596 double sp3Clk = (rtnClk - relativity) / t_CST::c; // in seconds
597
[3222]598 if (_rnx) {
[4991]599 _rnx->write(GPSweek, GPSweeks, prn, sp3Clk);
[3222]600 }
601 if (_sp3) {
[4991]602 _sp3->write(GPSweek, GPSweeks, prn, rtnCoM, sp3Clk);
[3222]603 }
604}
605
606// Transform Coordinates
607////////////////////////////////////////////////////////////////////////////
[4803]608void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz,
609 double& dc) {
[3222]610
611 // Current epoch minus 2000.0 in years
612 // ------------------------------------
613 double dt = (GPSWeek - (1042.0+6.0/7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
614
615 ColumnVector dx(3);
616
617 dx(1) = _dx + dt * _dxr;
618 dx(2) = _dy + dt * _dyr;
619 dx(3) = _dz + dt * _dzr;
620
621 static const double arcSec = 180.0 * 3600.0 / M_PI;
622
623 double ox = (_ox + dt * _oxr) / arcSec;
624 double oy = (_oy + dt * _oyr) / arcSec;
625 double oz = (_oz + dt * _ozr) / arcSec;
626
627 double sc = 1.0 + _sc * 1e-9 + dt * _scr * 1e-9;
628
[4912]629 // Specify approximate center of area
630 // ----------------------------------
631 ColumnVector meanSta(3);
632
633 if (_crdTrafo == "ETRF2000") {
[4973]634 meanSta(1) = 3661090.0;
635 meanSta(2) = 845230.0;
636 meanSta(3) = 5136850.0;
[4908]637 }
[4912]638 else if (_crdTrafo == "NAD83") {
[4973]639 meanSta(1) = -1092950.0;
640 meanSta(2) = -4383600.0;
641 meanSta(3) = 4487420.0;
[4912]642 }
643 else if (_crdTrafo == "GDA94") {
[4973]644 meanSta(1) = -4052050.0;
645 meanSta(2) = 4212840.0;
646 meanSta(3) = -2545110.0;
[4912]647 }
648 else if (_crdTrafo == "SIRGAS2000") {
[4973]649 meanSta(1) = 3740860.0;
650 meanSta(2) = -4964290.0;
651 meanSta(3) = -1425420.0;
[4912]652 }
653 else if (_crdTrafo == "SIRGAS95") {
[4973]654 meanSta(1) = 3135390.0;
655 meanSta(2) = -5017670.0;
656 meanSta(3) = -2374440.0;
[4912]657 }
658 else if (_crdTrafo == "Custom") {
659 meanSta(1) = 0.0; // TODO
660 meanSta(2) = 0.0; // TODO
661 meanSta(3) = 0.0; // TODO
662 }
[4908]663
[4912]664 // Clock correction proportional to topocentric distance to satellites
665 // -------------------------------------------------------------------
666 double rho = (xyz - meanSta).norm_Frobenius();
[4913]667 dc = rho * (sc - 1.0) / sc / t_CST::c;
[4908]668
[3222]669 Matrix rMat(3,3);
670 rMat(1,1) = 1.0;
671 rMat(1,2) = -oz;
672 rMat(1,3) = oy;
673 rMat(2,1) = oz;
674 rMat(2,2) = 1.0;
675 rMat(2,3) = -ox;
676 rMat(3,1) = -oy;
677 rMat(3,2) = ox;
678 rMat(3,3) = 1.0;
679
680 xyz = sc * rMat * xyz + dx;
681}
682
Note: See TracBrowser for help on using the repository browser.