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 |
|
---|
24 | using namespace std;
|
---|
25 |
|
---|
26 | // Constructor
|
---|
27 | ////////////////////////////////////////////////////////////////////////////
|
---|
28 | bncRtnetUploadCaster::bncRtnetUploadCaster(const QString& mountpoint,
|
---|
29 | const QString& outHost, int outPort,
|
---|
30 | const QString& password,
|
---|
31 | const QString& crdTrafo, bool CoM,
|
---|
32 | const QString& sp3FileName,
|
---|
33 | const QString& rnxFileName,
|
---|
34 | const QString& outFileName,
|
---|
35 | int PID, int SID, int IOD, int iRow) :
|
---|
36 | bncUploadCaster(mountpoint, outHost, outPort, password, iRow, 0) {
|
---|
37 |
|
---|
38 | _crdTrafo = crdTrafo;
|
---|
39 | _CoM = CoM;
|
---|
40 | _PID = PID;
|
---|
41 | _SID = SID;
|
---|
42 | _IOD = IOD;
|
---|
43 |
|
---|
44 | // Member that receives the ephemeris
|
---|
45 | // ----------------------------------
|
---|
46 | _ephUser = new bncEphUser();
|
---|
47 |
|
---|
48 | bncSettings settings;
|
---|
49 | QString intr = settings.value("uploadIntr").toString();
|
---|
50 | int sampl = settings.value("uploadSampl").toInt();
|
---|
51 | _samplOrb = settings.value("uploadSamplOrb").toDouble();
|
---|
52 | if (_samplOrb == 0.0) {
|
---|
53 | _usedEph = 0;
|
---|
54 | }
|
---|
55 | else {
|
---|
56 | _usedEph = new QMap<QString, t_eph*>;
|
---|
57 | }
|
---|
58 |
|
---|
59 | // Raw Output
|
---|
60 | // ----------
|
---|
61 | if (!outFileName.isEmpty()) {
|
---|
62 | _outFile = new bncoutf(outFileName, intr, sampl);
|
---|
63 | }
|
---|
64 | else {
|
---|
65 | _outFile = 0;
|
---|
66 | }
|
---|
67 |
|
---|
68 | // RINEX writer
|
---|
69 | // ------------
|
---|
70 | if (!rnxFileName.isEmpty()) {
|
---|
71 | _rnx = new bncClockRinex(rnxFileName, intr, sampl);
|
---|
72 | }
|
---|
73 | else {
|
---|
74 | _rnx = 0;
|
---|
75 | }
|
---|
76 |
|
---|
77 | // SP3 writer
|
---|
78 | // ----------
|
---|
79 | if (!sp3FileName.isEmpty()) {
|
---|
80 | _sp3 = new bncSP3(sp3FileName, intr, sampl);
|
---|
81 | }
|
---|
82 | else {
|
---|
83 | _sp3 = 0;
|
---|
84 | }
|
---|
85 |
|
---|
86 | // Set Transformation Parameters
|
---|
87 | // -----------------------------
|
---|
88 | if (_crdTrafo == "ETRF2000") {
|
---|
89 | _dx = 0.0521;
|
---|
90 | _dy = 0.0493;
|
---|
91 | _dz = -0.0585;
|
---|
92 | _dxr = 0.0001;
|
---|
93 | _dyr = 0.0001;
|
---|
94 | _dzr = -0.0018;
|
---|
95 | _ox = 0.000891;
|
---|
96 | _oy = 0.005390;
|
---|
97 | _oz = -0.008712;
|
---|
98 | _oxr = 0.000081;
|
---|
99 | _oyr = 0.000490;
|
---|
100 | _ozr = -0.000792;
|
---|
101 | _sc = 1.34;
|
---|
102 | _scr = 0.08;
|
---|
103 | _t0 = 2000.0;
|
---|
104 | }
|
---|
105 | else if (_crdTrafo == "NAD83") {
|
---|
106 | _dx = 0.9963;
|
---|
107 | _dy = -1.9024;
|
---|
108 | _dz = -0.5210;
|
---|
109 | _dxr = 0.0005;
|
---|
110 | _dyr = -0.0006;
|
---|
111 | _dzr = -0.0013;
|
---|
112 | _ox = -0.025915;
|
---|
113 | _oy = -0.009426;
|
---|
114 | _oz = -0.011599;
|
---|
115 | _oxr = -0.000067;
|
---|
116 | _oyr = 0.000757;
|
---|
117 | _ozr = 0.000051;
|
---|
118 | _sc = 0.78;
|
---|
119 | _scr = -0.10;
|
---|
120 | _t0 = 1997.0;
|
---|
121 | }
|
---|
122 | else if (_crdTrafo == "GDA94") {
|
---|
123 | _dx = -0.07973;
|
---|
124 | _dy = -0.00686;
|
---|
125 | _dz = 0.03803;
|
---|
126 | _dxr = 0.00225;
|
---|
127 | _dyr = -0.00062;
|
---|
128 | _dzr = -0.00056;
|
---|
129 | _ox = 0.0000351;
|
---|
130 | _oy = -0.0021211;
|
---|
131 | _oz = -0.0021411;
|
---|
132 | _oxr = -0.0014707;
|
---|
133 | _oyr = -0.0011443;
|
---|
134 | _ozr = -0.0011701;
|
---|
135 | _sc = 6.636;
|
---|
136 | _scr = 0.294;
|
---|
137 | _t0 = 1994.0;
|
---|
138 | }
|
---|
139 | else if (_crdTrafo == "SIRGAS2000") {
|
---|
140 | _dx = -0.0051;
|
---|
141 | _dy = -0.0065;
|
---|
142 | _dz = -0.0099;
|
---|
143 | _dxr = 0.0000;
|
---|
144 | _dyr = 0.0000;
|
---|
145 | _dzr = 0.0000;
|
---|
146 | _ox = 0.000150;
|
---|
147 | _oy = 0.000020;
|
---|
148 | _oz = 0.000021;
|
---|
149 | _oxr = 0.000000;
|
---|
150 | _oyr = 0.000000;
|
---|
151 | _ozr = 0.000000;
|
---|
152 | _sc = 0.000;
|
---|
153 | _scr = 0.000;
|
---|
154 | _t0 = 0000.0;
|
---|
155 | }
|
---|
156 | else if (_crdTrafo == "SIRGAS95") {
|
---|
157 | _dx = 0.0077;
|
---|
158 | _dy = 0.0058;
|
---|
159 | _dz = -0.0138;
|
---|
160 | _dxr = 0.0000;
|
---|
161 | _dyr = 0.0000;
|
---|
162 | _dzr = 0.0000;
|
---|
163 | _ox = 0.000000;
|
---|
164 | _oy = 0.000000;
|
---|
165 | _oz = -0.000030;
|
---|
166 | _oxr = 0.000000;
|
---|
167 | _oyr = 0.000000;
|
---|
168 | _ozr = 0.000000;
|
---|
169 | _sc = 1.570;
|
---|
170 | _scr = 0.000;
|
---|
171 | _t0 = 0000.0;
|
---|
172 | }
|
---|
173 | else if (_crdTrafo == "Custom") {
|
---|
174 | _dx = settings.value("trafo_dx").toDouble();
|
---|
175 | _dy = settings.value("trafo_dy").toDouble();
|
---|
176 | _dz = settings.value("trafo_dz").toDouble();
|
---|
177 | _dxr = settings.value("trafo_dxr").toDouble();
|
---|
178 | _dyr = settings.value("trafo_dyr").toDouble();
|
---|
179 | _dzr = settings.value("trafo_dzr").toDouble();
|
---|
180 | _ox = settings.value("trafo_ox").toDouble();
|
---|
181 | _oy = settings.value("trafo_oy").toDouble();
|
---|
182 | _oz = settings.value("trafo_oz").toDouble();
|
---|
183 | _oxr = settings.value("trafo_oxr").toDouble();
|
---|
184 | _oyr = settings.value("trafo_oyr").toDouble();
|
---|
185 | _ozr = settings.value("trafo_ozr").toDouble();
|
---|
186 | _sc = settings.value("trafo_sc").toDouble();
|
---|
187 | _scr = settings.value("trafo_scr").toDouble();
|
---|
188 | _t0 = settings.value("trafo_t0").toDouble();
|
---|
189 | }
|
---|
190 | }
|
---|
191 |
|
---|
192 | // Destructor
|
---|
193 | ////////////////////////////////////////////////////////////////////////////
|
---|
194 | bncRtnetUploadCaster::~bncRtnetUploadCaster() {
|
---|
195 | if (isRunning()) {
|
---|
196 | wait();
|
---|
197 | }
|
---|
198 | delete _outFile;
|
---|
199 | delete _rnx;
|
---|
200 | delete _sp3;
|
---|
201 | delete _ephUser;
|
---|
202 | delete _usedEph;
|
---|
203 | }
|
---|
204 |
|
---|
205 | //
|
---|
206 | ////////////////////////////////////////////////////////////////////////////
|
---|
207 | void bncRtnetUploadCaster::decodeRtnetStream(char* buffer, int bufLen) {
|
---|
208 |
|
---|
209 | QMutexLocker locker(&_mutex);
|
---|
210 |
|
---|
211 | // Append to internal buffer
|
---|
212 | // -------------------------
|
---|
213 | _rtnetStreamBuffer.append(QByteArray(buffer, bufLen));
|
---|
214 |
|
---|
215 | // Select buffer part that contains last epoch
|
---|
216 | // -------------------------------------------
|
---|
217 | QStringList lines;
|
---|
218 | int iEpoBeg = _rtnetStreamBuffer.lastIndexOf('*'); // begin of last epoch
|
---|
219 | if (iEpoBeg == -1) {
|
---|
220 | _rtnetStreamBuffer.clear();
|
---|
221 | return;
|
---|
222 | }
|
---|
223 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoBeg);
|
---|
224 |
|
---|
225 | int iEpoEnd = _rtnetStreamBuffer.lastIndexOf("EOE"); // end of last epoch
|
---|
226 | if (iEpoEnd == -1) {
|
---|
227 | return;
|
---|
228 | }
|
---|
229 | else {
|
---|
230 | lines = _rtnetStreamBuffer.left(iEpoEnd).split('\n', QString::SkipEmptyParts);
|
---|
231 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iEpoEnd+3);
|
---|
232 | }
|
---|
233 |
|
---|
234 | if (lines.size() < 2) {
|
---|
235 | return;
|
---|
236 | }
|
---|
237 |
|
---|
238 | // Keep the last unfinished line in buffer
|
---|
239 | // ---------------------------------------
|
---|
240 | int iLastEOL = _rtnetStreamBuffer.lastIndexOf('\n');
|
---|
241 | if (iLastEOL != -1) {
|
---|
242 | _rtnetStreamBuffer = _rtnetStreamBuffer.mid(iLastEOL+1);
|
---|
243 | }
|
---|
244 |
|
---|
245 | // Read first line (with epoch time)
|
---|
246 | // ---------------------------------
|
---|
247 | QTextStream in(lines[0].toAscii());
|
---|
248 | QString hlp;
|
---|
249 | int year, month, day, hour, min;
|
---|
250 | double sec;
|
---|
251 | in >> hlp >> year >> month >> day >> hour >> min >> sec;
|
---|
252 | bncTime epoTime; epoTime.set( year, month, day, hour, min, sec);
|
---|
253 |
|
---|
254 | struct ClockOrbit co;
|
---|
255 | memset(&co, 0, sizeof(co));
|
---|
256 | co.GPSEpochTime = static_cast<int>(epoTime.gpssec());
|
---|
257 | co.GLONASSEpochTime = static_cast<int>(fmod(epoTime.gpssec(), 86400.0))
|
---|
258 | + 3 * 3600 - gnumleap(year, month, day);
|
---|
259 | co.ClockDataSupplied = 1;
|
---|
260 | co.OrbitDataSupplied = 1;
|
---|
261 | co.SatRefDatum = DATUM_ITRF;
|
---|
262 | co.SSRIOD = _IOD;
|
---|
263 | co.SSRProviderID = _PID; // 256 .. BKG, 257 ... EUREF
|
---|
264 | co.SSRSolutionID = _SID;
|
---|
265 |
|
---|
266 | struct Bias bias;
|
---|
267 | memset(&bias, 0, sizeof(bias));
|
---|
268 | bias.GPSEpochTime = co.GPSEpochTime;
|
---|
269 | bias.GLONASSEpochTime = co.GLONASSEpochTime;
|
---|
270 |
|
---|
271 | for (int ii = 1; ii < lines.size(); ii++) {
|
---|
272 |
|
---|
273 | QString prn;
|
---|
274 | ColumnVector xx(14); xx = 0.0;
|
---|
275 |
|
---|
276 | QTextStream in(lines[ii].toAscii());
|
---|
277 |
|
---|
278 | in >> prn;
|
---|
279 | if (prn[0] == 'P') {
|
---|
280 | prn.remove(0,1);
|
---|
281 | }
|
---|
282 |
|
---|
283 | t_eph* eph = 0;
|
---|
284 | const bncEphUser::t_ephPair* ephPair = _ephUser->ephPair(prn);
|
---|
285 | if (ephPair) {
|
---|
286 |
|
---|
287 | eph = ephPair->last;
|
---|
288 |
|
---|
289 | // Use previous ephemeris if the last one is too recent
|
---|
290 | // ----------------------------------------------------
|
---|
291 | const int MINAGE = 60; // seconds
|
---|
292 | if (ephPair->prev && eph->receptDateTime().isValid() &&
|
---|
293 | eph->receptDateTime().secsTo(currentDateAndTimeGPS()) < MINAGE) {
|
---|
294 | eph = ephPair->prev;
|
---|
295 | }
|
---|
296 |
|
---|
297 | // Make sure the clock messages refer to same IOD as orbit messages
|
---|
298 | // ----------------------------------------------------------------
|
---|
299 | if (_usedEph) {
|
---|
300 | if (fmod(epoTime.gpssec(), _samplOrb) == 0.0) {
|
---|
301 | (*_usedEph)[prn] = eph;
|
---|
302 | }
|
---|
303 | else {
|
---|
304 | eph = 0;
|
---|
305 | if (_usedEph->contains(prn)) {
|
---|
306 | t_eph* usedEph = _usedEph->value(prn);
|
---|
307 | if (usedEph == ephPair->last) {
|
---|
308 | eph = ephPair->last;
|
---|
309 | }
|
---|
310 | else if (usedEph == ephPair->prev) {
|
---|
311 | eph = ephPair->prev;
|
---|
312 | }
|
---|
313 | }
|
---|
314 | }
|
---|
315 | }
|
---|
316 | }
|
---|
317 |
|
---|
318 | if (eph) {
|
---|
319 |
|
---|
320 | in >> xx(1) >> xx(2) >> xx(3) >> xx(4) >> xx(5)
|
---|
321 | >> xx(6) >> xx(7) >> xx(8) >> xx(9) >> xx(10)
|
---|
322 | >> xx(11) >> xx(12) >> xx(13) >> xx(14);
|
---|
323 | xx(1) *= 1e3; // x-crd
|
---|
324 | xx(2) *= 1e3; // y-crd
|
---|
325 | xx(3) *= 1e3; // z-crd
|
---|
326 | xx(4) *= 1e-6; // clk
|
---|
327 | xx(5) *= 1e-6; // rel. corr.
|
---|
328 | // xx(6), xx(7), xx(8) ... PhaseCent - CoM
|
---|
329 | // xx(9) ... P1-C1 DCB in meters
|
---|
330 | // xx(10) ... P1-P2 DCB in meters
|
---|
331 | // xx(11) ... dT
|
---|
332 | xx(12) *= 1e3; // x-crd at time + dT
|
---|
333 | xx(13) *= 1e3; // y-crd at time + dT
|
---|
334 | xx(14) *= 1e3; // z-crd at time + dT
|
---|
335 |
|
---|
336 | struct ClockOrbit::SatData* sd = 0;
|
---|
337 | if (prn[0] == 'G') {
|
---|
338 | sd = co.Sat + co.NumberOfGPSSat;
|
---|
339 | ++co.NumberOfGPSSat;
|
---|
340 | }
|
---|
341 | else if (prn[0] == 'R') {
|
---|
342 | sd = co.Sat + CLOCKORBIT_NUMGPS + co.NumberOfGLONASSSat;
|
---|
343 | ++co.NumberOfGLONASSSat;
|
---|
344 | }
|
---|
345 | if (sd) {
|
---|
346 | QString outLine;
|
---|
347 | processSatellite(eph, epoTime.gpsw(), epoTime.gpssec(), prn,
|
---|
348 | xx, sd, outLine);
|
---|
349 | if (_outFile) {
|
---|
350 | _outFile->write(epoTime.gpsw(), epoTime.gpssec(), outLine);
|
---|
351 | }
|
---|
352 | }
|
---|
353 |
|
---|
354 | struct Bias::BiasSat* biasSat = 0;
|
---|
355 | if (prn[0] == 'G') {
|
---|
356 | biasSat = bias.Sat + bias.NumberOfGPSSat;
|
---|
357 | ++bias.NumberOfGPSSat;
|
---|
358 | }
|
---|
359 | else if (prn[0] == 'R') {
|
---|
360 | biasSat = bias.Sat + CLOCKORBIT_NUMGPS + bias.NumberOfGLONASSSat;
|
---|
361 | ++bias.NumberOfGLONASSSat;
|
---|
362 | }
|
---|
363 |
|
---|
364 | // Coefficient of Ionosphere-Free LC
|
---|
365 | // ---------------------------------
|
---|
366 | const static double a_L1_GPS = 2.54572778;
|
---|
367 | const static double a_L2_GPS = -1.54572778;
|
---|
368 | const static double a_L1_Glo = 2.53125000;
|
---|
369 | const static double a_L2_Glo = -1.53125000;
|
---|
370 |
|
---|
371 | if (biasSat) {
|
---|
372 | biasSat->ID = prn.mid(1).toInt();
|
---|
373 | biasSat->NumberOfCodeBiases = 3;
|
---|
374 | if (prn[0] == 'G') {
|
---|
375 | biasSat->Biases[0].Type = CODETYPEGPS_L1_Z;
|
---|
376 | biasSat->Biases[0].Bias = - a_L2_GPS * xx(10);
|
---|
377 | biasSat->Biases[1].Type = CODETYPEGPS_L1_CA;
|
---|
378 | biasSat->Biases[1].Bias = - a_L2_GPS * xx(10) + xx(9);
|
---|
379 | biasSat->Biases[2].Type = CODETYPEGPS_L2_Z;
|
---|
380 | biasSat->Biases[2].Bias = a_L1_GPS * xx(10);
|
---|
381 | }
|
---|
382 | else if (prn[0] == 'R') {
|
---|
383 | biasSat->Biases[0].Type = CODETYPEGLONASS_L1_P;
|
---|
384 | biasSat->Biases[0].Bias = - a_L2_Glo * xx(10);
|
---|
385 | biasSat->Biases[1].Type = CODETYPEGLONASS_L1_CA;
|
---|
386 | biasSat->Biases[1].Bias = - a_L2_Glo * xx(10) + xx(9);
|
---|
387 | biasSat->Biases[2].Type = CODETYPEGLONASS_L2_P;
|
---|
388 | biasSat->Biases[2].Bias = a_L1_Glo * xx(10);
|
---|
389 | }
|
---|
390 | }
|
---|
391 | }
|
---|
392 | }
|
---|
393 |
|
---|
394 | QByteArray hlpBufferCo;
|
---|
395 |
|
---|
396 | // Orbit and Clock Corrections together
|
---|
397 | // ------------------------------------
|
---|
398 | if (_samplOrb == 0.0) {
|
---|
399 | if (co.NumberOfGPSSat > 0 || co.NumberOfGLONASSSat > 0) {
|
---|
400 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
401 | int len = MakeClockOrbit(&co, COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
---|
402 | if (len > 0) {
|
---|
403 | hlpBufferCo = QByteArray(obuffer, len);
|
---|
404 | }
|
---|
405 | }
|
---|
406 | }
|
---|
407 |
|
---|
408 | // Orbit and Clock Corrections separately
|
---|
409 | // --------------------------------------
|
---|
410 | else {
|
---|
411 | if (co.NumberOfGPSSat > 0) {
|
---|
412 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
413 | if (fmod(epoTime.gpssec(), _samplOrb) == 0.0) {
|
---|
414 | int len1 = MakeClockOrbit(&co, COTYPE_GPSORBIT, 1, obuffer, sizeof(obuffer));
|
---|
415 | if (len1 > 0) {
|
---|
416 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
417 | }
|
---|
418 | }
|
---|
419 | int mmsg = (co.NumberOfGLONASSSat > 0) ? 1 : 0;
|
---|
420 | int len2 = MakeClockOrbit(&co, COTYPE_GPSCLOCK, mmsg, obuffer, sizeof(obuffer));
|
---|
421 | if (len2 > 0) {
|
---|
422 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
423 | }
|
---|
424 | }
|
---|
425 | if (co.NumberOfGLONASSSat > 0) {
|
---|
426 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
427 | if (fmod(epoTime.gpssec(), _samplOrb) == 0.0) {
|
---|
428 | int len1 = MakeClockOrbit(&co, COTYPE_GLONASSORBIT, 1, obuffer, sizeof(obuffer));
|
---|
429 | if (len1 > 0) {
|
---|
430 | hlpBufferCo += QByteArray(obuffer, len1);
|
---|
431 | }
|
---|
432 | }
|
---|
433 | int len2 = MakeClockOrbit(&co, COTYPE_GLONASSCLOCK, 0, obuffer, sizeof(obuffer));
|
---|
434 | if (len2 > 0) {
|
---|
435 | hlpBufferCo += QByteArray(obuffer, len2);
|
---|
436 | }
|
---|
437 | }
|
---|
438 | }
|
---|
439 |
|
---|
440 | // Biases
|
---|
441 | // ------
|
---|
442 | QByteArray hlpBufferBias;
|
---|
443 | if (bias.NumberOfGPSSat > 0 || bias.NumberOfGLONASSSat > 0) {
|
---|
444 | char obuffer[CLOCKORBIT_BUFFERSIZE];
|
---|
445 | int len = MakeBias(&bias, BTYPE_AUTO, 0, obuffer, sizeof(obuffer));
|
---|
446 | if (len > 0) {
|
---|
447 | hlpBufferBias = QByteArray(obuffer, len);
|
---|
448 | }
|
---|
449 | }
|
---|
450 |
|
---|
451 | if (hlpBufferCo.size() > 0) {
|
---|
452 | _outBuffer = hlpBufferCo + hlpBufferBias;
|
---|
453 | }
|
---|
454 | }
|
---|
455 |
|
---|
456 | //
|
---|
457 | ////////////////////////////////////////////////////////////////////////////
|
---|
458 | void bncRtnetUploadCaster::processSatellite(t_eph* eph, int GPSweek,
|
---|
459 | double GPSweeks, const QString& prn,
|
---|
460 | const ColumnVector& xx,
|
---|
461 | struct ClockOrbit::SatData* sd,
|
---|
462 | QString& outLine) {
|
---|
463 |
|
---|
464 | const double secPerWeek = 7.0 * 86400.0;
|
---|
465 |
|
---|
466 | ColumnVector rsw(3);
|
---|
467 | ColumnVector rsw2(3);
|
---|
468 | double dClk;
|
---|
469 |
|
---|
470 | for (int ii = 1; ii <= 2; ++ii) {
|
---|
471 |
|
---|
472 | int GPSweek12 = GPSweek;
|
---|
473 | double GPSweeks12 = GPSweeks;
|
---|
474 | if (ii == 2) {
|
---|
475 | GPSweeks12 += xx(11);
|
---|
476 | if (GPSweeks12 > secPerWeek) {
|
---|
477 | GPSweek12 += 1;
|
---|
478 | GPSweeks12 -= secPerWeek;
|
---|
479 | }
|
---|
480 | }
|
---|
481 |
|
---|
482 | ColumnVector xB(4);
|
---|
483 | ColumnVector vv(3);
|
---|
484 |
|
---|
485 | eph->position(GPSweek12, GPSweeks12, xB.data(), vv.data());
|
---|
486 |
|
---|
487 | ColumnVector xyz;
|
---|
488 | if (ii == 1) {
|
---|
489 | xyz = xx.Rows(1,3);
|
---|
490 | }
|
---|
491 | else {
|
---|
492 | xyz = xx.Rows(12,14);
|
---|
493 | }
|
---|
494 |
|
---|
495 | // Correction Center of Mass -> Antenna Phase Center
|
---|
496 | // -------------------------------------------------
|
---|
497 | if (! _CoM) {
|
---|
498 | xyz(1) += xx(6);
|
---|
499 | xyz(2) += xx(7);
|
---|
500 | xyz(3) += xx(8);
|
---|
501 | }
|
---|
502 |
|
---|
503 | if (_crdTrafo != "IGS08") {
|
---|
504 | crdTrafo(GPSweek12, xyz);
|
---|
505 | }
|
---|
506 |
|
---|
507 | ColumnVector dx = xB.Rows(1,3) - xyz ;
|
---|
508 |
|
---|
509 | if (ii == 1) {
|
---|
510 | XYZ_to_RSW(xB.Rows(1,3), vv, dx, rsw);
|
---|
511 | dClk = (xx(4) + xx(5) - xB(4)) * 299792458.0;
|
---|
512 | }
|
---|
513 | else {
|
---|
514 | XYZ_to_RSW(xB.Rows(1,3), vv, dx, rsw2);
|
---|
515 | }
|
---|
516 | }
|
---|
517 |
|
---|
518 | if (sd) {
|
---|
519 | sd->ID = prn.mid(1).toInt();
|
---|
520 | sd->IOD = eph->IOD();
|
---|
521 | sd->Clock.DeltaA0 = dClk;
|
---|
522 | sd->Orbit.DeltaRadial = rsw(1);
|
---|
523 | sd->Orbit.DeltaAlongTrack = rsw(2);
|
---|
524 | sd->Orbit.DeltaCrossTrack = rsw(3);
|
---|
525 | sd->Orbit.DotDeltaRadial = (rsw2(1) - rsw(1)) / xx(11);
|
---|
526 | sd->Orbit.DotDeltaAlongTrack = (rsw2(2) - rsw(2)) / xx(11);
|
---|
527 | sd->Orbit.DotDeltaCrossTrack = (rsw2(3) - rsw(3)) / xx(11);
|
---|
528 | }
|
---|
529 |
|
---|
530 | outLine.sprintf("%d %.1f %s %3d %10.3f %8.3f %8.3f %8.3f\n",
|
---|
531 | GPSweek, GPSweeks, eph->prn().toAscii().data(),
|
---|
532 | eph->IOD(), dClk, rsw(1), rsw(2), rsw(3));
|
---|
533 |
|
---|
534 | if (_rnx) {
|
---|
535 | _rnx->write(GPSweek, GPSweeks, prn, xx);
|
---|
536 | }
|
---|
537 | if (_sp3) {
|
---|
538 | _sp3->write(GPSweek, GPSweeks, prn, xx);
|
---|
539 | }
|
---|
540 | }
|
---|
541 |
|
---|
542 | // Transform Coordinates
|
---|
543 | ////////////////////////////////////////////////////////////////////////////
|
---|
544 | void bncRtnetUploadCaster::crdTrafo(int GPSWeek, ColumnVector& xyz) {
|
---|
545 |
|
---|
546 | // Current epoch minus 2000.0 in years
|
---|
547 | // ------------------------------------
|
---|
548 | double dt = (GPSWeek - (1042.0+6.0/7.0)) / 365.2422 * 7.0 + 2000.0 - _t0;
|
---|
549 |
|
---|
550 | ColumnVector dx(3);
|
---|
551 |
|
---|
552 | dx(1) = _dx + dt * _dxr;
|
---|
553 | dx(2) = _dy + dt * _dyr;
|
---|
554 | dx(3) = _dz + dt * _dzr;
|
---|
555 |
|
---|
556 | static const double arcSec = 180.0 * 3600.0 / M_PI;
|
---|
557 |
|
---|
558 | double ox = (_ox + dt * _oxr) / arcSec;
|
---|
559 | double oy = (_oy + dt * _oyr) / arcSec;
|
---|
560 | double oz = (_oz + dt * _ozr) / arcSec;
|
---|
561 |
|
---|
562 | double sc = 1.0 + _sc * 1e-9 + dt * _scr * 1e-9;
|
---|
563 |
|
---|
564 | Matrix rMat(3,3);
|
---|
565 | rMat(1,1) = 1.0;
|
---|
566 | rMat(1,2) = -oz;
|
---|
567 | rMat(1,3) = oy;
|
---|
568 | rMat(2,1) = oz;
|
---|
569 | rMat(2,2) = 1.0;
|
---|
570 | rMat(2,3) = -ox;
|
---|
571 | rMat(3,1) = -oy;
|
---|
572 | rMat(3,2) = ox;
|
---|
573 | rMat(3,3) = 1.0;
|
---|
574 |
|
---|
575 | xyz = sc * rMat * xyz + dx;
|
---|
576 | }
|
---|
577 |
|
---|