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