1 | #include <sstream>
|
---|
2 | #include <iostream>
|
---|
3 | #include <iomanip>
|
---|
4 | #include <cstring>
|
---|
5 |
|
---|
6 | #include <newmatio.h>
|
---|
7 |
|
---|
8 | #include "ephemeris.h"
|
---|
9 | #include "bncutils.h"
|
---|
10 | #include "bnctime.h"
|
---|
11 | #include "bnccore.h"
|
---|
12 | #include "bncutils.h"
|
---|
13 | #include "satObs.h"
|
---|
14 | #include "pppInclude.h"
|
---|
15 | #include "pppModel.h"
|
---|
16 |
|
---|
17 | using namespace std;
|
---|
18 |
|
---|
19 | // Constructor
|
---|
20 | ////////////////////////////////////////////////////////////////////////////
|
---|
21 | t_eph::t_eph() {
|
---|
22 | _checkState = unchecked;
|
---|
23 | _navType = undefined;
|
---|
24 | _orbCorr = 0;
|
---|
25 | _clkCorr = 0;
|
---|
26 | }
|
---|
27 | // Destructor
|
---|
28 | ////////////////////////////////////////////////////////////////////////////
|
---|
29 | t_eph::~t_eph() {
|
---|
30 | if (_orbCorr)
|
---|
31 | delete _orbCorr;
|
---|
32 | if (_clkCorr)
|
---|
33 | delete _clkCorr;
|
---|
34 | }
|
---|
35 |
|
---|
36 | //
|
---|
37 | ////////////////////////////////////////////////////////////////////////////
|
---|
38 | void t_eph::setOrbCorr(const t_orbCorr* orbCorr) {
|
---|
39 | if (_orbCorr) {
|
---|
40 | delete _orbCorr;
|
---|
41 | _orbCorr = 0;
|
---|
42 | }
|
---|
43 | _orbCorr = new t_orbCorr(*orbCorr);
|
---|
44 | }
|
---|
45 |
|
---|
46 | //
|
---|
47 | ////////////////////////////////////////////////////////////////////////////
|
---|
48 | void t_eph::setClkCorr(const t_clkCorr* clkCorr) {
|
---|
49 | if (_clkCorr) {
|
---|
50 | delete _clkCorr;
|
---|
51 | _clkCorr = 0;
|
---|
52 | }
|
---|
53 | _clkCorr = new t_clkCorr(*clkCorr);
|
---|
54 | }
|
---|
55 |
|
---|
56 | //
|
---|
57 | ////////////////////////////////////////////////////////////////////////////
|
---|
58 | t_irc t_eph::getCrd(const bncTime& tt, ColumnVector& xc, ColumnVector& vv, bool useCorr) const {
|
---|
59 |
|
---|
60 | if (_checkState == bad ||
|
---|
61 | _checkState == unhealthy ||
|
---|
62 | _checkState == outdated) {
|
---|
63 | return failure;
|
---|
64 | }
|
---|
65 |
|
---|
66 | xc.ReSize(6);
|
---|
67 | vv.ReSize(3);
|
---|
68 | if (position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data()) != success) {
|
---|
69 | return failure;
|
---|
70 | }
|
---|
71 | if (useCorr) {
|
---|
72 | if (_orbCorr && _clkCorr) {
|
---|
73 | double dtO = tt - _orbCorr->_time;
|
---|
74 | if (_orbCorr->_updateInt) {
|
---|
75 | dtO -= (0.5 * ssrUpdateInt[_orbCorr->_updateInt]);
|
---|
76 | }
|
---|
77 | ColumnVector dx(3);
|
---|
78 | dx[0] = _orbCorr->_xr[0] + _orbCorr->_dotXr[0] * dtO;
|
---|
79 | dx[1] = _orbCorr->_xr[1] + _orbCorr->_dotXr[1] * dtO;
|
---|
80 | dx[2] = _orbCorr->_xr[2] + _orbCorr->_dotXr[2] * dtO;
|
---|
81 |
|
---|
82 | RSW_to_XYZ(xc.Rows(1,3), vv.Rows(1,3), dx, dx);
|
---|
83 |
|
---|
84 | xc[0] -= dx[0];
|
---|
85 | xc[1] -= dx[1];
|
---|
86 | xc[2] -= dx[2];
|
---|
87 |
|
---|
88 | ColumnVector dv(3);
|
---|
89 | RSW_to_XYZ(xc.Rows(1,3), vv.Rows(1,3), _orbCorr->_dotXr, dv);
|
---|
90 |
|
---|
91 | vv[0] -= dv[0];
|
---|
92 | vv[1] -= dv[1];
|
---|
93 | vv[2] -= dv[2];
|
---|
94 |
|
---|
95 | double dtC = tt - _clkCorr->_time;
|
---|
96 | if (_clkCorr->_updateInt) {
|
---|
97 | dtC -= (0.5 * ssrUpdateInt[_clkCorr->_updateInt]);
|
---|
98 | }
|
---|
99 | xc[3] += _clkCorr->_dClk + _clkCorr->_dotDClk * dtC + _clkCorr->_dotDotDClk * dtC * dtC;
|
---|
100 | }
|
---|
101 | else {
|
---|
102 | return failure;
|
---|
103 | }
|
---|
104 | }
|
---|
105 | return success;
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 | //
|
---|
110 | //////////////////////////////////////////////////////////////////////////////
|
---|
111 | t_irc t_eph::setNavType(QString navTypeStr) {
|
---|
112 | if (navTypeStr == "LNAV") {_navType = t_eph::LNAV;}
|
---|
113 | else if (navTypeStr == "FDMA") {_navType = t_eph::FDMA;}
|
---|
114 | else if (navTypeStr == "FNAV") {_navType = t_eph::FNAV;}
|
---|
115 | else if (navTypeStr == "INAF") {_navType = t_eph::INAF;}
|
---|
116 | else if (navTypeStr == "D1") {_navType = t_eph::D1;}
|
---|
117 | else if (navTypeStr == "D2") {_navType = t_eph::D2;}
|
---|
118 | else if (navTypeStr == "SBAS") {_navType = t_eph::SBASL1;}
|
---|
119 | else if (navTypeStr == "CNAV") {_navType = t_eph::CNAV;}
|
---|
120 | else if (navTypeStr == "CNV1") {_navType = t_eph::CNV1;}
|
---|
121 | else if (navTypeStr == "CNV2") {_navType = t_eph::CNV2;}
|
---|
122 | else if (navTypeStr == "CNV3") {_navType = t_eph::CNV3;}
|
---|
123 | else {_navType = t_eph::undefined; return failure;}
|
---|
124 |
|
---|
125 | return success;
|
---|
126 | }
|
---|
127 |
|
---|
128 | //
|
---|
129 | //////////////////////////////////////////////////////////////////////////////
|
---|
130 | QString t_eph::navTypeString(e_navType navType, const t_prn& prn, double version) {
|
---|
131 | QString navTypeString = "";
|
---|
132 | QString epochStart;
|
---|
133 | QString eolStr;
|
---|
134 |
|
---|
135 | if (version < 4.0) {
|
---|
136 | return navTypeString;
|
---|
137 | }
|
---|
138 |
|
---|
139 | if (version == 99.0) {
|
---|
140 | epochStart = "";
|
---|
141 | eolStr = "";
|
---|
142 | }
|
---|
143 | else {
|
---|
144 | epochStart = "> ";
|
---|
145 | eolStr = "\n";
|
---|
146 | }
|
---|
147 |
|
---|
148 | QString ephStr = QString("EPH %1 ").arg(prn.toString().c_str());
|
---|
149 | switch (navType) {
|
---|
150 | case undefined:
|
---|
151 | navTypeString = epochStart + ephStr + "unknown" + eolStr;
|
---|
152 | break;
|
---|
153 | case LNAV:
|
---|
154 | navTypeString = epochStart + ephStr + "LNAV" + eolStr;
|
---|
155 | break;
|
---|
156 | case FDMA:
|
---|
157 | navTypeString = epochStart + ephStr + "FDMA" + eolStr;
|
---|
158 | break;
|
---|
159 | case FNAV:
|
---|
160 | navTypeString = epochStart + ephStr + "FNAV" + eolStr;
|
---|
161 | break;
|
---|
162 | case INAF:
|
---|
163 | navTypeString = epochStart + ephStr + "INAV" + eolStr;
|
---|
164 | break;
|
---|
165 | case D1:
|
---|
166 | navTypeString = epochStart + ephStr + "D1 " + eolStr;
|
---|
167 | break;
|
---|
168 | case D2:
|
---|
169 | navTypeString = epochStart + ephStr + "D2 " + eolStr;
|
---|
170 | break;
|
---|
171 | case SBASL1:
|
---|
172 | navTypeString = epochStart + ephStr + "SBAS" + eolStr;
|
---|
173 | break;
|
---|
174 | case CNAV:
|
---|
175 | navTypeString = epochStart + ephStr + "CNAV" + eolStr;
|
---|
176 | break;
|
---|
177 | case CNV1:
|
---|
178 | navTypeString = epochStart + ephStr + "CNV1" + eolStr;
|
---|
179 | break;
|
---|
180 | case CNV2:
|
---|
181 | navTypeString = epochStart + ephStr + "CNV2" + eolStr;
|
---|
182 | break;
|
---|
183 | case CNV3:
|
---|
184 | navTypeString = epochStart + ephStr + "CNV3" + eolStr;
|
---|
185 | break;
|
---|
186 | }
|
---|
187 | return navTypeString;
|
---|
188 | }
|
---|
189 |
|
---|
190 | //
|
---|
191 | //////////////////////////////////////////////////////////////////////////////
|
---|
192 | QString t_eph::rinexDateStr(const bncTime& tt, const t_prn& prn, double version) {
|
---|
193 | QString prnStr(prn.toString().c_str());
|
---|
194 | return rinexDateStr(tt, prnStr, version);
|
---|
195 | }
|
---|
196 |
|
---|
197 | //
|
---|
198 | //////////////////////////////////////////////////////////////////////////////
|
---|
199 | QString t_eph::rinexDateStr(const bncTime& tt, const QString& prnStr, double version) {
|
---|
200 |
|
---|
201 | QString datStr;
|
---|
202 |
|
---|
203 | unsigned year, month, day, hour, min;
|
---|
204 | double sec;
|
---|
205 | tt.civil_date(year, month, day);
|
---|
206 | tt.civil_time(hour, min, sec);
|
---|
207 |
|
---|
208 | QTextStream out(&datStr);
|
---|
209 |
|
---|
210 | if (version < 3.0) {
|
---|
211 | QString prnHlp = prnStr.mid(1,2); if (prnHlp[0] == '0') prnHlp[0] = ' ';
|
---|
212 | out << prnHlp << QString(" %1 %2 %3 %4 %5%6")
|
---|
213 | .arg(year % 100, 2, 10, QChar('0'))
|
---|
214 | .arg(month, 2)
|
---|
215 | .arg(day, 2)
|
---|
216 | .arg(hour, 2)
|
---|
217 | .arg(min, 2)
|
---|
218 | .arg(sec, 5, 'f',1);
|
---|
219 | }
|
---|
220 | else if (version == 99) {
|
---|
221 | out << QString(" %1 %2 %3 %4 %5 %6")
|
---|
222 | .arg(year, 4)
|
---|
223 | .arg(month, 2, 10, QChar('0'))
|
---|
224 | .arg(day, 2, 10, QChar('0'))
|
---|
225 | .arg(hour, 2, 10, QChar('0'))
|
---|
226 | .arg(min, 2, 10, QChar('0'))
|
---|
227 | .arg(int(sec), 2, 10, QChar('0'));
|
---|
228 | }
|
---|
229 | else {
|
---|
230 | out << prnStr << QString(" %1 %2 %3 %4 %5 %6")
|
---|
231 | .arg(year, 4)
|
---|
232 | .arg(month, 2, 10, QChar('0'))
|
---|
233 | .arg(day, 2, 10, QChar('0'))
|
---|
234 | .arg(hour, 2, 10, QChar('0'))
|
---|
235 | .arg(min, 2, 10, QChar('0'))
|
---|
236 | .arg(int(sec), 2, 10, QChar('0'));
|
---|
237 | }
|
---|
238 |
|
---|
239 | return datStr;
|
---|
240 | }
|
---|
241 |
|
---|
242 | // Constructor
|
---|
243 | //////////////////////////////////////////////////////////////////////////////
|
---|
244 | t_ephGPS::t_ephGPS(double rnxVersion, const QStringList& lines) {
|
---|
245 |
|
---|
246 | const int nLines = 8;
|
---|
247 |
|
---|
248 | if (lines.size() != nLines) {
|
---|
249 | _checkState = bad;
|
---|
250 | return;
|
---|
251 | }
|
---|
252 |
|
---|
253 | // RINEX Format
|
---|
254 | // ------------
|
---|
255 | int fieldLen = 19;
|
---|
256 |
|
---|
257 | int pos[4];
|
---|
258 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
259 | pos[1] = pos[0] + fieldLen;
|
---|
260 | pos[2] = pos[1] + fieldLen;
|
---|
261 | pos[3] = pos[2] + fieldLen;
|
---|
262 |
|
---|
263 | // Read eight lines
|
---|
264 | // ----------------
|
---|
265 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
266 | QString line = lines[iLine];
|
---|
267 |
|
---|
268 | if ( iLine == 0 ) {
|
---|
269 | QTextStream in(line.left(pos[1]).toLatin1());
|
---|
270 | int year, month, day, hour, min;
|
---|
271 | double sec;
|
---|
272 |
|
---|
273 | QString prnStr, n;
|
---|
274 | in >> prnStr;
|
---|
275 |
|
---|
276 | if (prnStr.size() == 1 &&
|
---|
277 | (prnStr[0] == 'G' ||
|
---|
278 | prnStr[0] == 'J' ||
|
---|
279 | prnStr[0] == 'I')) {
|
---|
280 | in >> n;
|
---|
281 | prnStr.append(n);
|
---|
282 | }
|
---|
283 |
|
---|
284 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
285 | if (prnStr.at(0) == 'G') {
|
---|
286 | _prn.set('G', prnStr.mid(1).toInt());
|
---|
287 | }
|
---|
288 | else if (prnStr.at(0) == 'J') {
|
---|
289 | _prn.set('J', prnStr.mid(1).toInt());
|
---|
290 | }
|
---|
291 | else if (prnStr.at(0) == 'I') {
|
---|
292 | _prn.set('I', prnStr.mid(1).toInt());
|
---|
293 | }
|
---|
294 | else {
|
---|
295 | _prn.set('G', prnStr.toInt());
|
---|
296 | }
|
---|
297 |
|
---|
298 | if (year < 80) {
|
---|
299 | year += 2000;
|
---|
300 | }
|
---|
301 | else if (year < 100) {
|
---|
302 | year += 1900;
|
---|
303 | }
|
---|
304 |
|
---|
305 | _TOC.set(year, month, day, hour, min, sec);
|
---|
306 |
|
---|
307 | if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
|
---|
308 | readDbl(line, pos[2], fieldLen, _clock_drift ) ||
|
---|
309 | readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
|
---|
310 | _checkState = bad;
|
---|
311 | return;
|
---|
312 | }
|
---|
313 | }
|
---|
314 |
|
---|
315 | else if ( iLine == 1 ) {
|
---|
316 | if ( readDbl(line, pos[0], fieldLen, _IODE ) ||
|
---|
317 | readDbl(line, pos[1], fieldLen, _Crs ) ||
|
---|
318 | readDbl(line, pos[2], fieldLen, _Delta_n) ||
|
---|
319 | readDbl(line, pos[3], fieldLen, _M0 ) ) {
|
---|
320 | _checkState = bad;
|
---|
321 | return;
|
---|
322 | }
|
---|
323 | }
|
---|
324 |
|
---|
325 | else if ( iLine == 2 ) {
|
---|
326 | if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
|
---|
327 | readDbl(line, pos[1], fieldLen, _e ) ||
|
---|
328 | readDbl(line, pos[2], fieldLen, _Cus ) ||
|
---|
329 | readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
|
---|
330 | _checkState = bad;
|
---|
331 | return;
|
---|
332 | }
|
---|
333 | }
|
---|
334 |
|
---|
335 | else if ( iLine == 3 ) {
|
---|
336 | if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
|
---|
337 | readDbl(line, pos[1], fieldLen, _Cic ) ||
|
---|
338 | readDbl(line, pos[2], fieldLen, _OMEGA0) ||
|
---|
339 | readDbl(line, pos[3], fieldLen, _Cis ) ) {
|
---|
340 | _checkState = bad;
|
---|
341 | return;
|
---|
342 | }
|
---|
343 | }
|
---|
344 |
|
---|
345 | else if ( iLine == 4 ) {
|
---|
346 | if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
|
---|
347 | readDbl(line, pos[1], fieldLen, _Crc ) ||
|
---|
348 | readDbl(line, pos[2], fieldLen, _omega ) ||
|
---|
349 | readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
|
---|
350 | _checkState = bad;
|
---|
351 | return;
|
---|
352 | }
|
---|
353 | }
|
---|
354 |
|
---|
355 | else if ( iLine == 5 && type() != t_eph::IRNSS) {
|
---|
356 | if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
|
---|
357 | readDbl(line, pos[1], fieldLen, _L2Codes) ||
|
---|
358 | readDbl(line, pos[2], fieldLen, _TOEweek ) ||
|
---|
359 | readDbl(line, pos[3], fieldLen, _L2PFlag) ) {
|
---|
360 | _checkState = bad;
|
---|
361 | return;
|
---|
362 | }
|
---|
363 | }
|
---|
364 | else if ( iLine == 5 && type() == t_eph::IRNSS) {
|
---|
365 | if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
|
---|
366 | readDbl(line, pos[2], fieldLen, _TOEweek) ) {
|
---|
367 | _checkState = bad;
|
---|
368 | return;
|
---|
369 | }
|
---|
370 | }
|
---|
371 |
|
---|
372 | else if ( iLine == 6 && type() != t_eph::IRNSS) {
|
---|
373 | if ( readDbl(line, pos[0], fieldLen, _ura ) ||
|
---|
374 | readDbl(line, pos[1], fieldLen, _health) ||
|
---|
375 | readDbl(line, pos[2], fieldLen, _TGD ) ||
|
---|
376 | readDbl(line, pos[3], fieldLen, _IODC ) ) {
|
---|
377 | _checkState = bad;
|
---|
378 | return;
|
---|
379 | }
|
---|
380 | }
|
---|
381 | else if ( iLine == 6 && type() == t_eph::IRNSS) {
|
---|
382 | if ( readDbl(line, pos[0], fieldLen, _ura ) ||
|
---|
383 | readDbl(line, pos[1], fieldLen, _health) ||
|
---|
384 | readDbl(line, pos[2], fieldLen, _TGD ) ) {
|
---|
385 | _checkState = bad;
|
---|
386 | return;
|
---|
387 | }
|
---|
388 | }
|
---|
389 | else if ( iLine == 7 ) {
|
---|
390 | if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
|
---|
391 | _checkState = bad;
|
---|
392 | return;
|
---|
393 | }
|
---|
394 | // fitInterval is not valid for IRNSS
|
---|
395 | if (type() != t_eph::IRNSS) {
|
---|
396 | double fitIntervalRnx;
|
---|
397 | readDbl(line, pos[1], fieldLen, fitIntervalRnx);
|
---|
398 | if (type() == t_eph::GPS) { // in RINEX specified allways as time period for GPS
|
---|
399 | _fitInterval = fitIntervalRnx;
|
---|
400 | } else if (type() == t_eph::QZSS) { // specified as flag for QZSS
|
---|
401 | if (rnxVersion == 3.02) {
|
---|
402 | _fitInterval = fitIntervalRnx; // specified as time period
|
---|
403 | }
|
---|
404 | else {
|
---|
405 | _fitInterval = fitIntervalFromFlag(fitIntervalRnx, _IODC, t_eph::QZSS);
|
---|
406 | }
|
---|
407 | }
|
---|
408 | }
|
---|
409 | }
|
---|
410 | }
|
---|
411 | }
|
---|
412 |
|
---|
413 | // Compute GPS Satellite Position (virtual)
|
---|
414 | ////////////////////////////////////////////////////////////////////////////
|
---|
415 | t_irc t_ephGPS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
416 |
|
---|
417 | static const double omegaEarth = 7292115.1467e-11;
|
---|
418 | static const double gmGRS = 398.6005e12;
|
---|
419 |
|
---|
420 | memset(xc, 0, 6*sizeof(double));
|
---|
421 | memset(vv, 0, 3*sizeof(double));
|
---|
422 |
|
---|
423 | double a0 = _sqrt_A * _sqrt_A;
|
---|
424 | if (a0 == 0) {
|
---|
425 | return failure;
|
---|
426 | }
|
---|
427 |
|
---|
428 | double n0 = sqrt(gmGRS/(a0*a0*a0));
|
---|
429 |
|
---|
430 | bncTime tt(GPSweek, GPSweeks);
|
---|
431 | double tk = tt - bncTime(int(_TOEweek), _TOEsec);
|
---|
432 |
|
---|
433 | double n = n0 + _Delta_n;
|
---|
434 | double M = _M0 + n*tk;
|
---|
435 | double E = M;
|
---|
436 | double E_last;
|
---|
437 | int nLoop = 0;
|
---|
438 | do {
|
---|
439 | E_last = E;
|
---|
440 | E = M + _e*sin(E);
|
---|
441 |
|
---|
442 | if (++nLoop == 100) {
|
---|
443 | return failure;
|
---|
444 | }
|
---|
445 | } while ( fabs(E-E_last)*a0 > 0.001);
|
---|
446 | double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
|
---|
447 | double u0 = v + _omega;
|
---|
448 | double sin2u0 = sin(2*u0);
|
---|
449 | double cos2u0 = cos(2*u0);
|
---|
450 | double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
|
---|
451 | double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
|
---|
452 | double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
|
---|
453 | double xp = r*cos(u);
|
---|
454 | double yp = r*sin(u);
|
---|
455 | double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
|
---|
456 | omegaEarth*_TOEsec;
|
---|
457 |
|
---|
458 | double sinom = sin(OM);
|
---|
459 | double cosom = cos(OM);
|
---|
460 | double sini = sin(i);
|
---|
461 | double cosi = cos(i);
|
---|
462 | xc[0] = xp*cosom - yp*cosi*sinom;
|
---|
463 | xc[1] = xp*sinom + yp*cosi*cosom;
|
---|
464 | xc[2] = yp*sini;
|
---|
465 |
|
---|
466 | double tc = tt - _TOC;
|
---|
467 | xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
|
---|
468 |
|
---|
469 | // Velocity
|
---|
470 | // --------
|
---|
471 | double tanv2 = tan(v/2);
|
---|
472 | double dEdM = 1 / (1 - _e*cos(E));
|
---|
473 | double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
|
---|
474 | * dEdM * n;
|
---|
475 | double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
|
---|
476 | double dotom = _OMEGADOT - omegaEarth;
|
---|
477 | double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
|
---|
478 | double dotr = a0 * _e*sin(E) * dEdM * n
|
---|
479 | + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
|
---|
480 | double dotx = dotr*cos(u) - r*sin(u)*dotu;
|
---|
481 | double doty = dotr*sin(u) + r*cos(u)*dotu;
|
---|
482 |
|
---|
483 | vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
|
---|
484 | - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
|
---|
485 | + yp*sini*sinom*doti; // dX / di
|
---|
486 |
|
---|
487 | vv[1] = sinom *dotx + cosi*cosom *doty
|
---|
488 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
489 | - yp*sini*cosom*doti;
|
---|
490 |
|
---|
491 | vv[2] = sini *doty + yp*cosi *doti;
|
---|
492 |
|
---|
493 | // Relativistic Correction
|
---|
494 | // -----------------------
|
---|
495 | xc[3] -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
|
---|
496 |
|
---|
497 | xc[4] = _clock_drift + _clock_driftrate*tc;
|
---|
498 | xc[5] = _clock_driftrate;
|
---|
499 |
|
---|
500 | return success;
|
---|
501 | }
|
---|
502 |
|
---|
503 | // RINEX Format String
|
---|
504 | //////////////////////////////////////////////////////////////////////////////
|
---|
505 | QString t_ephGPS::toString(double version) const {
|
---|
506 |
|
---|
507 | QString navStr = navTypeString(_navType, _prn, version);
|
---|
508 | QString rnxStr = navStr + rinexDateStr(_TOC, _prn, version);
|
---|
509 |
|
---|
510 | QTextStream out(&rnxStr);
|
---|
511 |
|
---|
512 | out << QString("%1%2%3\n")
|
---|
513 | .arg(_clock_bias, 19, 'e', 12)
|
---|
514 | .arg(_clock_drift, 19, 'e', 12)
|
---|
515 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
516 |
|
---|
517 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
518 |
|
---|
519 | out << QString(fmt)
|
---|
520 | .arg(_IODE, 19, 'e', 12)
|
---|
521 | .arg(_Crs, 19, 'e', 12)
|
---|
522 | .arg(_Delta_n, 19, 'e', 12)
|
---|
523 | .arg(_M0, 19, 'e', 12);
|
---|
524 |
|
---|
525 | out << QString(fmt)
|
---|
526 | .arg(_Cuc, 19, 'e', 12)
|
---|
527 | .arg(_e, 19, 'e', 12)
|
---|
528 | .arg(_Cus, 19, 'e', 12)
|
---|
529 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
530 |
|
---|
531 | out << QString(fmt)
|
---|
532 | .arg(_TOEsec, 19, 'e', 12)
|
---|
533 | .arg(_Cic, 19, 'e', 12)
|
---|
534 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
535 | .arg(_Cis, 19, 'e', 12);
|
---|
536 |
|
---|
537 | out << QString(fmt)
|
---|
538 | .arg(_i0, 19, 'e', 12)
|
---|
539 | .arg(_Crc, 19, 'e', 12)
|
---|
540 | .arg(_omega, 19, 'e', 12)
|
---|
541 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
542 |
|
---|
543 | if (type() == t_eph::IRNSS) {
|
---|
544 | out << QString(fmt)
|
---|
545 | .arg(_IDOT, 19, 'e', 12)
|
---|
546 | .arg(0.0, 19, 'e', 12)
|
---|
547 | .arg(_TOEweek, 19, 'e', 12)
|
---|
548 | .arg(0.0, 19, 'e', 12);
|
---|
549 | }
|
---|
550 | else {
|
---|
551 | out << QString(fmt)
|
---|
552 | .arg(_IDOT, 19, 'e', 12)
|
---|
553 | .arg(_L2Codes, 19, 'e', 12)
|
---|
554 | .arg(_TOEweek, 19, 'e', 12)
|
---|
555 | .arg(_L2PFlag, 19, 'e', 12);
|
---|
556 | }
|
---|
557 |
|
---|
558 | if (type() == t_eph::IRNSS) {
|
---|
559 | out << QString(fmt)
|
---|
560 | .arg(_ura, 19, 'e', 12)
|
---|
561 | .arg(_health, 19, 'e', 12)
|
---|
562 | .arg(_TGD, 19, 'e', 12)
|
---|
563 | .arg(0.0, 19, 'e', 12);
|
---|
564 | }
|
---|
565 | else {
|
---|
566 | out << QString(fmt)
|
---|
567 | .arg(_ura, 19, 'e', 12)
|
---|
568 | .arg(_health, 19, 'e', 12)
|
---|
569 | .arg(_TGD, 19, 'e', 12)
|
---|
570 | .arg(_IODC, 19, 'e', 12);
|
---|
571 | }
|
---|
572 |
|
---|
573 | double tot = _TOT;
|
---|
574 | if (tot == 0.9999e9 && version < 3.0) {
|
---|
575 | tot = 0.0;
|
---|
576 | }
|
---|
577 | // fitInterval
|
---|
578 | if (type() == t_eph::IRNSS) {// not valid for IRNSS
|
---|
579 | out << QString(fmt)
|
---|
580 | .arg(tot, 19, 'e', 12)
|
---|
581 | .arg(0.0, 19, 'e', 12)
|
---|
582 | .arg("", 19, QChar(' '))
|
---|
583 | .arg("", 19, QChar(' '));
|
---|
584 | }
|
---|
585 | else {
|
---|
586 | // for GPS and QZSS in version 3.02 specified in hours
|
---|
587 | double fitIntervalRnx = _fitInterval;
|
---|
588 | // otherwise specified as flag
|
---|
589 | if (type() == t_eph::QZSS && version != 3.02) {
|
---|
590 | (_fitInterval == 2.0) ? fitIntervalRnx = 0.0 : fitIntervalRnx = 1.0;
|
---|
591 | }
|
---|
592 | out << QString(fmt)
|
---|
593 | .arg(tot, 19, 'e', 12)
|
---|
594 | .arg(fitIntervalRnx, 19, 'e', 12)
|
---|
595 | .arg("", 19, QChar(' '))
|
---|
596 | .arg("", 19, QChar(' '));
|
---|
597 | }
|
---|
598 | return rnxStr;
|
---|
599 | }
|
---|
600 |
|
---|
601 | // Constructor
|
---|
602 | //////////////////////////////////////////////////////////////////////////////
|
---|
603 | t_ephGlo::t_ephGlo(double rnxVersion, const QStringList& lines) {
|
---|
604 |
|
---|
605 | int nLines = 4;
|
---|
606 | if (rnxVersion >= 3.05) {
|
---|
607 | nLines += 1;
|
---|
608 | _flags_unknown = false;
|
---|
609 | }
|
---|
610 | else {
|
---|
611 | _M_delta_tau = 0.9999e9; // unknown
|
---|
612 | _M_FT = 1.5e1; // unknown
|
---|
613 | _flags_unknown = true;
|
---|
614 | }
|
---|
615 |
|
---|
616 | if (lines.size() != nLines) {
|
---|
617 | _checkState = bad;
|
---|
618 | return;
|
---|
619 | }
|
---|
620 |
|
---|
621 | // RINEX Format
|
---|
622 | // ------------
|
---|
623 | int fieldLen = 19;
|
---|
624 | double statusflags = 0.0;
|
---|
625 | double healthflags = 0.0;
|
---|
626 |
|
---|
627 | int pos[4];
|
---|
628 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
629 | pos[1] = pos[0] + fieldLen;
|
---|
630 | pos[2] = pos[1] + fieldLen;
|
---|
631 | pos[3] = pos[2] + fieldLen;
|
---|
632 |
|
---|
633 | // Read four lines
|
---|
634 | // ---------------
|
---|
635 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
636 | QString line = lines[iLine];
|
---|
637 |
|
---|
638 | if ( iLine == 0 ) {
|
---|
639 | QTextStream in(line.left(pos[1]).toLatin1());
|
---|
640 |
|
---|
641 | int year, month, day, hour, min;
|
---|
642 | double sec;
|
---|
643 |
|
---|
644 | QString prnStr, n;
|
---|
645 | in >> prnStr;
|
---|
646 | if (prnStr.size() == 1 && prnStr[0] == 'R') {
|
---|
647 | in >> n;
|
---|
648 | prnStr.append(n);
|
---|
649 | }
|
---|
650 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
651 | if (prnStr.at(0) == 'R') {
|
---|
652 | _prn.set('R', prnStr.mid(1).toInt());
|
---|
653 | }
|
---|
654 | else {
|
---|
655 | _prn.set('R', prnStr.toInt());
|
---|
656 | }
|
---|
657 |
|
---|
658 | if (year < 80) {
|
---|
659 | year += 2000;
|
---|
660 | }
|
---|
661 | else if (year < 100) {
|
---|
662 | year += 1900;
|
---|
663 | }
|
---|
664 |
|
---|
665 | _gps_utc = gnumleap(year, month, day);
|
---|
666 |
|
---|
667 | _TOC.set(year, month, day, hour, min, sec);
|
---|
668 | _TOC = _TOC + _gps_utc;
|
---|
669 | int nd = int((_TOC.gpssec())) / (24.0*60.0*60.0);
|
---|
670 | if ( readDbl(line, pos[1], fieldLen, _tau ) ||
|
---|
671 | readDbl(line, pos[2], fieldLen, _gamma) ||
|
---|
672 | readDbl(line, pos[3], fieldLen, _tki ) ) {
|
---|
673 | _checkState = bad;
|
---|
674 | return;
|
---|
675 | }
|
---|
676 | _tki -= nd * 86400.0;
|
---|
677 | _tau = -_tau;
|
---|
678 | }
|
---|
679 |
|
---|
680 | else if ( iLine == 1 ) {
|
---|
681 | if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
|
---|
682 | readDbl(line, pos[1], fieldLen, _x_velocity ) ||
|
---|
683 | readDbl(line, pos[2], fieldLen, _x_acceleration) ||
|
---|
684 | readDbl(line, pos[3], fieldLen, _health ) ) {
|
---|
685 | _checkState = bad;
|
---|
686 | return;
|
---|
687 | }
|
---|
688 | }
|
---|
689 |
|
---|
690 | else if ( iLine == 2 ) {
|
---|
691 | if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
|
---|
692 | readDbl(line, pos[1], fieldLen, _y_velocity ) ||
|
---|
693 | readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
|
---|
694 | readDbl(line, pos[3], fieldLen, _frequency_number) ) {
|
---|
695 | _checkState = bad;
|
---|
696 | return;
|
---|
697 | }
|
---|
698 | }
|
---|
699 |
|
---|
700 | else if ( iLine == 3 ) {
|
---|
701 | if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
|
---|
702 | readDbl(line, pos[1], fieldLen, _z_velocity ) ||
|
---|
703 | readDbl(line, pos[2], fieldLen, _z_acceleration) ||
|
---|
704 | readDbl(line, pos[3], fieldLen, _E ) ) {
|
---|
705 | _checkState = bad;
|
---|
706 | return;
|
---|
707 | }
|
---|
708 | }
|
---|
709 |
|
---|
710 | else if ( iLine == 4 ) {
|
---|
711 | if ( readDbl(line, pos[0], fieldLen, statusflags ) ||
|
---|
712 | readDbl(line, pos[1], fieldLen, _M_delta_tau ) ||
|
---|
713 | readDbl(line, pos[2], fieldLen, _M_FT ) ||
|
---|
714 | readDbl(line, pos[3], fieldLen, healthflags ) ) {
|
---|
715 | _checkState = bad;
|
---|
716 | return;
|
---|
717 | }
|
---|
718 | else {
|
---|
719 | // status flags
|
---|
720 | // ============
|
---|
721 | // bit 0-1
|
---|
722 | _M_P = double(bitExtracted(statusflags, 2, 0));
|
---|
723 | // bit 2-3
|
---|
724 | _P1 = double(bitExtracted(statusflags, 2, 2));
|
---|
725 | // bit 4
|
---|
726 | _P2 = double(bitExtracted(statusflags, 1, 4));
|
---|
727 | // bit 5
|
---|
728 | _P3 = double(bitExtracted(statusflags, 1, 5));
|
---|
729 | // bit 6
|
---|
730 | _M_P4 = double(bitExtracted(statusflags, 1, 6));
|
---|
731 | // bit 7-8
|
---|
732 | _M_M = double(bitExtracted(statusflags, 2, 7));
|
---|
733 | /// GLO M/K exclusive flags/values only valid if flag M is set to '01'
|
---|
734 | if (!_M_M) {
|
---|
735 | _M_P4 = 0.0;
|
---|
736 | _M_P = 0.0;
|
---|
737 | }
|
---|
738 | // health flags
|
---|
739 | // ============
|
---|
740 | // bit 0 (is to be ignored, if bit 1 is zero)
|
---|
741 | _almanac_health = double(bitExtracted(healthflags, 1, 0));
|
---|
742 | // bit 1
|
---|
743 | _almanac_health_availablility_indicator = double(bitExtracted(healthflags, 1, 1));
|
---|
744 | // bit 2
|
---|
745 | _M_l3 = double(bitExtracted(healthflags, 1, 2));
|
---|
746 | }
|
---|
747 | }
|
---|
748 | }
|
---|
749 |
|
---|
750 | // Initialize status vector
|
---|
751 | // ------------------------
|
---|
752 | _tt = _TOC;
|
---|
753 | _xv.ReSize(6); _xv = 0.0;
|
---|
754 | _xv(1) = _x_pos * 1.e3;
|
---|
755 | _xv(2) = _y_pos * 1.e3;
|
---|
756 | _xv(3) = _z_pos * 1.e3;
|
---|
757 | _xv(4) = _x_velocity * 1.e3;
|
---|
758 | _xv(5) = _y_velocity * 1.e3;
|
---|
759 | _xv(6) = _z_velocity * 1.e3;
|
---|
760 | }
|
---|
761 |
|
---|
762 | // Compute Glonass Satellite Position (virtual)
|
---|
763 | ////////////////////////////////////////////////////////////////////////////
|
---|
764 | t_irc t_ephGlo::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
765 |
|
---|
766 | static const double nominalStep = 10.0;
|
---|
767 |
|
---|
768 | memset(xc, 0, 6*sizeof(double));
|
---|
769 | memset(vv, 0, 3*sizeof(double));
|
---|
770 |
|
---|
771 | double dtPos = bncTime(GPSweek, GPSweeks) - _tt;
|
---|
772 |
|
---|
773 | if (fabs(dtPos) > 24 * 3600.0) {
|
---|
774 | return failure;
|
---|
775 | }
|
---|
776 |
|
---|
777 | int nSteps = int(fabs(dtPos) / nominalStep) + 1;
|
---|
778 | double step = dtPos / nSteps;
|
---|
779 |
|
---|
780 | double acc[3];
|
---|
781 | acc[0] = _x_acceleration * 1.e3;
|
---|
782 | acc[1] = _y_acceleration * 1.e3;
|
---|
783 | acc[2] = _z_acceleration * 1.e3;
|
---|
784 |
|
---|
785 | for (int ii = 1; ii <= nSteps; ii++) {
|
---|
786 | _xv = rungeKutta4(_tt.gpssec(), _xv, step, acc, glo_deriv);
|
---|
787 | _tt = _tt + step;
|
---|
788 | }
|
---|
789 |
|
---|
790 | // Position and Velocity
|
---|
791 | // ---------------------
|
---|
792 | xc[0] = _xv(1);
|
---|
793 | xc[1] = _xv(2);
|
---|
794 | xc[2] = _xv(3);
|
---|
795 |
|
---|
796 | vv[0] = _xv(4);
|
---|
797 | vv[1] = _xv(5);
|
---|
798 | vv[2] = _xv(6);
|
---|
799 |
|
---|
800 | // Clock Correction
|
---|
801 | // ----------------
|
---|
802 | double dtClk = bncTime(GPSweek, GPSweeks) - _TOC;
|
---|
803 | xc[3] = -_tau + _gamma * dtClk;
|
---|
804 |
|
---|
805 | xc[4] = _gamma;
|
---|
806 | xc[5] = 0.0;
|
---|
807 |
|
---|
808 | return success;
|
---|
809 | }
|
---|
810 |
|
---|
811 | // RINEX Format String
|
---|
812 | //////////////////////////////////////////////////////////////////////////////
|
---|
813 | QString t_ephGlo::toString(double version) const {
|
---|
814 |
|
---|
815 | QString navStr = navTypeString(_navType, _prn, version);
|
---|
816 | QString rnxStr = navStr + rinexDateStr(_TOC -_gps_utc, _prn, version);
|
---|
817 | int nd = int((_TOC - _gps_utc).gpssec()) / (24.0*60.0*60.0);
|
---|
818 | QTextStream out(&rnxStr);
|
---|
819 |
|
---|
820 | out << QString("%1%2%3\n")
|
---|
821 | .arg(-_tau, 19, 'e', 12)
|
---|
822 | .arg(_gamma, 19, 'e', 12)
|
---|
823 | .arg(_tki+nd*86400.0, 19, 'e', 12);
|
---|
824 |
|
---|
825 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
826 |
|
---|
827 | out << QString(fmt)
|
---|
828 | .arg(_x_pos, 19, 'e', 12)
|
---|
829 | .arg(_x_velocity, 19, 'e', 12)
|
---|
830 | .arg(_x_acceleration, 19, 'e', 12)
|
---|
831 | .arg(_health, 19, 'e', 12);
|
---|
832 |
|
---|
833 | out << QString(fmt)
|
---|
834 | .arg(_y_pos, 19, 'e', 12)
|
---|
835 | .arg(_y_velocity, 19, 'e', 12)
|
---|
836 | .arg(_y_acceleration, 19, 'e', 12)
|
---|
837 | .arg(_frequency_number, 19, 'e', 12);
|
---|
838 |
|
---|
839 | out << QString(fmt)
|
---|
840 | .arg(_z_pos, 19, 'e', 12)
|
---|
841 | .arg(_z_velocity, 19, 'e', 12)
|
---|
842 | .arg(_z_acceleration, 19, 'e', 12)
|
---|
843 | .arg(_E, 19, 'e', 12);
|
---|
844 |
|
---|
845 | if (version >= 3.05) {
|
---|
846 | // unknown (RINEX version < 3.05)
|
---|
847 | if (_flags_unknown) {
|
---|
848 | out << QString(fmt)
|
---|
849 | .arg("", 19, QChar(' ')) // statusflags blank if unknown
|
---|
850 | .arg(_M_delta_tau, 19, 'e', 12)
|
---|
851 | .arg(_M_FT, 19, 'e', 12)
|
---|
852 | .arg("", 19, QChar(' ')); // healthflags blank if unknown
|
---|
853 | }
|
---|
854 | else {
|
---|
855 | int statusflags = 0;
|
---|
856 | // bit 7-8
|
---|
857 | if (_M_M == 2.0) {
|
---|
858 | statusflags |= (1<<7);
|
---|
859 | }
|
---|
860 | // bit 6
|
---|
861 | if (_M_P4) {
|
---|
862 | statusflags |= (1<<6);
|
---|
863 | }
|
---|
864 | // bit 5
|
---|
865 | if (_P3) {
|
---|
866 | statusflags |= (1<<5);
|
---|
867 | }
|
---|
868 | // bit 4
|
---|
869 | if (_P2) {
|
---|
870 | statusflags |= (1<<4);
|
---|
871 | }
|
---|
872 | // bit 2-3
|
---|
873 | if (_P1 == 2.0) {
|
---|
874 | statusflags |= (1<<2);
|
---|
875 | }
|
---|
876 | else if (_P1 == 1.0) {
|
---|
877 | statusflags |= (1<<3);
|
---|
878 | }
|
---|
879 | else if (_P1 == 3.0) {
|
---|
880 | statusflags |= (1<<2);
|
---|
881 | statusflags |= (1<<3);
|
---|
882 | }
|
---|
883 | // bit 0-1
|
---|
884 | if (_M_P == 2.0) {
|
---|
885 | statusflags |= (1<<0);
|
---|
886 | }
|
---|
887 | else if (_M_P == 1.0) {
|
---|
888 | statusflags |= (1<<1);
|
---|
889 | }
|
---|
890 | else if (_M_P == 3.0) {
|
---|
891 | statusflags |= (1<<0);
|
---|
892 | statusflags |= (1<<1);
|
---|
893 | }
|
---|
894 | // health flags
|
---|
895 | // ============
|
---|
896 | int healthflags = 0;
|
---|
897 | // bit 0 (is to be ignored, if bit 1 is zero)
|
---|
898 | if (_almanac_health) {
|
---|
899 | healthflags |= (1<<0);
|
---|
900 | }
|
---|
901 | // bit 1
|
---|
902 | if (_almanac_health_availablility_indicator) {
|
---|
903 | healthflags |= (1<<1);
|
---|
904 | }
|
---|
905 | // bit 2
|
---|
906 | if (_M_l3) {
|
---|
907 | healthflags |= (1<<2);
|
---|
908 | }
|
---|
909 | out << QString(fmt)
|
---|
910 | .arg(double(statusflags), 19, 'e', 12)
|
---|
911 | .arg(_M_delta_tau, 19, 'e', 12)
|
---|
912 | .arg(_M_FT, 19, 'e', 12)
|
---|
913 | .arg(double(healthflags), 19, 'e', 12);
|
---|
914 | }
|
---|
915 | }
|
---|
916 |
|
---|
917 | return rnxStr;
|
---|
918 | }
|
---|
919 |
|
---|
920 | // Derivative of the state vector using a simple force model (static)
|
---|
921 | ////////////////////////////////////////////////////////////////////////////
|
---|
922 | ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector& xv,
|
---|
923 | double* acc) {
|
---|
924 |
|
---|
925 | // State vector components
|
---|
926 | // -----------------------
|
---|
927 | ColumnVector rr = xv.rows(1,3);
|
---|
928 | ColumnVector vv = xv.rows(4,6);
|
---|
929 |
|
---|
930 | // Acceleration
|
---|
931 | // ------------
|
---|
932 | static const double gmWGS = 398.60044e12;
|
---|
933 | static const double AE = 6378136.0;
|
---|
934 | static const double OMEGA = 7292115.e-11;
|
---|
935 | static const double C20 = -1082.6257e-6;
|
---|
936 |
|
---|
937 | double rho = rr.NormFrobenius();
|
---|
938 | double t1 = -gmWGS/(rho*rho*rho);
|
---|
939 | double t2 = 3.0/2.0 * C20 * (gmWGS*AE*AE) / (rho*rho*rho*rho*rho);
|
---|
940 | double t3 = OMEGA * OMEGA;
|
---|
941 | double t4 = 2.0 * OMEGA;
|
---|
942 | double z2 = rr(3) * rr(3);
|
---|
943 |
|
---|
944 | // Vector of derivatives
|
---|
945 | // ---------------------
|
---|
946 | ColumnVector va(6);
|
---|
947 | va(1) = vv(1);
|
---|
948 | va(2) = vv(2);
|
---|
949 | va(3) = vv(3);
|
---|
950 | va(4) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(1) + t4*vv(2) + acc[0];
|
---|
951 | va(5) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(2) - t4*vv(1) + acc[1];
|
---|
952 | va(6) = (t1 + t2*(3.0-5.0*z2/(rho*rho)) ) * rr(3) + acc[2];
|
---|
953 |
|
---|
954 | return va;
|
---|
955 | }
|
---|
956 |
|
---|
957 | // IOD of Glonass Ephemeris (virtual)
|
---|
958 | ////////////////////////////////////////////////////////////////////////////
|
---|
959 | unsigned int t_ephGlo::IOD() const {
|
---|
960 | bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0;
|
---|
961 | return (unsigned long)tMoscow.daysec() / 900;
|
---|
962 | }
|
---|
963 |
|
---|
964 | // Health status of Glonass Ephemeris (virtual)
|
---|
965 | ////////////////////////////////////////////////////////////////////////////
|
---|
966 | unsigned int t_ephGlo::isUnhealthy() const {
|
---|
967 |
|
---|
968 | if (_almanac_health_availablility_indicator) {
|
---|
969 | if ((_health == 0 && _almanac_health == 0) ||
|
---|
970 | (_health == 1 && _almanac_health == 0) ||
|
---|
971 | (_health == 1 && _almanac_health == 1)) {
|
---|
972 | return 1;
|
---|
973 | }
|
---|
974 | }
|
---|
975 | else if (!_almanac_health_availablility_indicator) {
|
---|
976 | if (_health) {
|
---|
977 | return 1;
|
---|
978 | }
|
---|
979 | }
|
---|
980 | return 0; /* (_health == 0 && _almanac_health == 1) or (_health == 0) */
|
---|
981 | }
|
---|
982 |
|
---|
983 | // Constructor
|
---|
984 | //////////////////////////////////////////////////////////////////////////////
|
---|
985 | t_ephGal::t_ephGal(double rnxVersion, const QStringList& lines) {
|
---|
986 | int year, month, day, hour, min;
|
---|
987 | double sec;
|
---|
988 | QString prnStr;
|
---|
989 | const int nLines = 8;
|
---|
990 | if (lines.size() != nLines) {
|
---|
991 | _checkState = bad;
|
---|
992 | return;
|
---|
993 | }
|
---|
994 |
|
---|
995 | // RINEX Format
|
---|
996 | // ------------
|
---|
997 | int fieldLen = 19;
|
---|
998 | double SVhealth = 0.0;
|
---|
999 | double datasource = 0.0;
|
---|
1000 |
|
---|
1001 | int pos[4];
|
---|
1002 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
1003 | pos[1] = pos[0] + fieldLen;
|
---|
1004 | pos[2] = pos[1] + fieldLen;
|
---|
1005 | pos[3] = pos[2] + fieldLen;
|
---|
1006 |
|
---|
1007 | // Read eight lines
|
---|
1008 | // ----------------
|
---|
1009 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
1010 | QString line = lines[iLine];
|
---|
1011 |
|
---|
1012 | if ( iLine == 0 ) {
|
---|
1013 | QTextStream in(line.left(pos[1]).toLatin1());
|
---|
1014 | QString n;
|
---|
1015 | in >> prnStr;
|
---|
1016 | if (prnStr.size() == 1 && prnStr[0] == 'E') {
|
---|
1017 | in >> n;
|
---|
1018 | prnStr.append(n);
|
---|
1019 | }
|
---|
1020 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
1021 | if (year < 80) {
|
---|
1022 | year += 2000;
|
---|
1023 | }
|
---|
1024 | else if (year < 100) {
|
---|
1025 | year += 1900;
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 | _TOC.set(year, month, day, hour, min, sec);
|
---|
1029 |
|
---|
1030 | if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
|
---|
1031 | readDbl(line, pos[2], fieldLen, _clock_drift ) ||
|
---|
1032 | readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
|
---|
1033 | _checkState = bad;
|
---|
1034 | return;
|
---|
1035 | }
|
---|
1036 | }
|
---|
1037 |
|
---|
1038 | else if ( iLine == 1 ) {
|
---|
1039 | if ( readDbl(line, pos[0], fieldLen, _IODnav ) ||
|
---|
1040 | readDbl(line, pos[1], fieldLen, _Crs ) ||
|
---|
1041 | readDbl(line, pos[2], fieldLen, _Delta_n) ||
|
---|
1042 | readDbl(line, pos[3], fieldLen, _M0 ) ) {
|
---|
1043 | _checkState = bad;
|
---|
1044 | return;
|
---|
1045 | }
|
---|
1046 | }
|
---|
1047 |
|
---|
1048 | else if ( iLine == 2 ) {
|
---|
1049 | if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
|
---|
1050 | readDbl(line, pos[1], fieldLen, _e ) ||
|
---|
1051 | readDbl(line, pos[2], fieldLen, _Cus ) ||
|
---|
1052 | readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
|
---|
1053 | _checkState = bad;
|
---|
1054 | return;
|
---|
1055 | }
|
---|
1056 | }
|
---|
1057 |
|
---|
1058 | else if ( iLine == 3 ) {
|
---|
1059 | if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
|
---|
1060 | readDbl(line, pos[1], fieldLen, _Cic ) ||
|
---|
1061 | readDbl(line, pos[2], fieldLen, _OMEGA0) ||
|
---|
1062 | readDbl(line, pos[3], fieldLen, _Cis ) ) {
|
---|
1063 | _checkState = bad;
|
---|
1064 | return;
|
---|
1065 | }
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 | else if ( iLine == 4 ) {
|
---|
1069 | if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
|
---|
1070 | readDbl(line, pos[1], fieldLen, _Crc ) ||
|
---|
1071 | readDbl(line, pos[2], fieldLen, _omega ) ||
|
---|
1072 | readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
|
---|
1073 | _checkState = bad;
|
---|
1074 | return;
|
---|
1075 | }
|
---|
1076 | }
|
---|
1077 |
|
---|
1078 | else if ( iLine == 5 ) {
|
---|
1079 | if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
|
---|
1080 | readDbl(line, pos[1], fieldLen, datasource) ||
|
---|
1081 | readDbl(line, pos[2], fieldLen, _TOEweek ) ) {
|
---|
1082 | _checkState = bad;
|
---|
1083 | return;
|
---|
1084 | } else {
|
---|
1085 | if (int(datasource) & (1<<8)) {
|
---|
1086 | _fnav = true;
|
---|
1087 | _inav = false;
|
---|
1088 | } else if (int(datasource) & (1<<9)) {
|
---|
1089 | _fnav = false;
|
---|
1090 | _inav = true;
|
---|
1091 | }
|
---|
1092 | _TOEweek -= 1024.0;
|
---|
1093 | }
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 | else if ( iLine == 6 ) {
|
---|
1097 | if ( readDbl(line, pos[0], fieldLen, _SISA ) ||
|
---|
1098 | readDbl(line, pos[1], fieldLen, SVhealth) ||
|
---|
1099 | readDbl(line, pos[2], fieldLen, _BGD_1_5A) ||
|
---|
1100 | readDbl(line, pos[3], fieldLen, _BGD_1_5B) ) {
|
---|
1101 | _checkState = bad;
|
---|
1102 | return;
|
---|
1103 | } else {
|
---|
1104 | // Bit 0
|
---|
1105 | _e1DataInValid = (int(SVhealth) & (1<<0));
|
---|
1106 | // Bit 1-2
|
---|
1107 | _E1_bHS = double((int(SVhealth) >> 1) & 0x3);
|
---|
1108 | // Bit 3
|
---|
1109 | _e5aDataInValid = (int(SVhealth) & (1<<3));
|
---|
1110 | // Bit 4-5
|
---|
1111 | _E5aHS = double((int(SVhealth) >> 4) & 0x3);
|
---|
1112 | // Bit 6
|
---|
1113 | _e5bDataInValid = (int(SVhealth) & (1<<6));
|
---|
1114 | // Bit 7-8
|
---|
1115 | _E5bHS = double((int(SVhealth) >> 7) & 0x3);
|
---|
1116 |
|
---|
1117 | if (prnStr.at(0) == 'E') {
|
---|
1118 | _prn.set('E', prnStr.mid(1).toInt(), _inav ? 1 : 0);
|
---|
1119 | }
|
---|
1120 | }
|
---|
1121 | }
|
---|
1122 |
|
---|
1123 | else if ( iLine == 7 ) {
|
---|
1124 | if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
|
---|
1125 | _checkState = bad;
|
---|
1126 | return;
|
---|
1127 | }
|
---|
1128 | }
|
---|
1129 | }
|
---|
1130 | }
|
---|
1131 |
|
---|
1132 | // Compute Galileo Satellite Position (virtual)
|
---|
1133 | ////////////////////////////////////////////////////////////////////////////
|
---|
1134 | t_irc t_ephGal::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
1135 |
|
---|
1136 | static const double omegaEarth = 7292115.1467e-11;
|
---|
1137 | static const double gmWGS = 398.6004418e12;
|
---|
1138 |
|
---|
1139 | memset(xc, 0, 6*sizeof(double));
|
---|
1140 | memset(vv, 0, 3*sizeof(double));
|
---|
1141 |
|
---|
1142 | double a0 = _sqrt_A * _sqrt_A;
|
---|
1143 | if (a0 == 0) {
|
---|
1144 | return failure;
|
---|
1145 | }
|
---|
1146 |
|
---|
1147 | double n0 = sqrt(gmWGS/(a0*a0*a0));
|
---|
1148 |
|
---|
1149 | bncTime tt(GPSweek, GPSweeks);
|
---|
1150 | double tk = tt - bncTime(_TOC.gpsw(), _TOEsec);
|
---|
1151 |
|
---|
1152 | double n = n0 + _Delta_n;
|
---|
1153 | double M = _M0 + n*tk;
|
---|
1154 | double E = M;
|
---|
1155 | double E_last;
|
---|
1156 | int nLoop = 0;
|
---|
1157 | do {
|
---|
1158 | E_last = E;
|
---|
1159 | E = M + _e*sin(E);
|
---|
1160 |
|
---|
1161 | if (++nLoop == 100) {
|
---|
1162 | return failure;
|
---|
1163 | }
|
---|
1164 | } while ( fabs(E-E_last)*a0 > 0.001 );
|
---|
1165 | double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
|
---|
1166 | double u0 = v + _omega;
|
---|
1167 | double sin2u0 = sin(2*u0);
|
---|
1168 | double cos2u0 = cos(2*u0);
|
---|
1169 | double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
|
---|
1170 | double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
|
---|
1171 | double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
|
---|
1172 | double xp = r*cos(u);
|
---|
1173 | double yp = r*sin(u);
|
---|
1174 | double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
|
---|
1175 | omegaEarth*_TOEsec;
|
---|
1176 |
|
---|
1177 | double sinom = sin(OM);
|
---|
1178 | double cosom = cos(OM);
|
---|
1179 | double sini = sin(i);
|
---|
1180 | double cosi = cos(i);
|
---|
1181 | xc[0] = xp*cosom - yp*cosi*sinom;
|
---|
1182 | xc[1] = xp*sinom + yp*cosi*cosom;
|
---|
1183 | xc[2] = yp*sini;
|
---|
1184 |
|
---|
1185 | double tc = tt - _TOC;
|
---|
1186 | xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
|
---|
1187 |
|
---|
1188 | // Velocity
|
---|
1189 | // --------
|
---|
1190 | double tanv2 = tan(v/2);
|
---|
1191 | double dEdM = 1 / (1 - _e*cos(E));
|
---|
1192 | double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
|
---|
1193 | * dEdM * n;
|
---|
1194 | double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
|
---|
1195 | double dotom = _OMEGADOT - omegaEarth;
|
---|
1196 | double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
|
---|
1197 | double dotr = a0 * _e*sin(E) * dEdM * n
|
---|
1198 | + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
|
---|
1199 | double dotx = dotr*cos(u) - r*sin(u)*dotu;
|
---|
1200 | double doty = dotr*sin(u) + r*cos(u)*dotu;
|
---|
1201 |
|
---|
1202 | vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
|
---|
1203 | - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
|
---|
1204 | + yp*sini*sinom*doti; // dX / di
|
---|
1205 |
|
---|
1206 | vv[1] = sinom *dotx + cosi*cosom *doty
|
---|
1207 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
1208 | - yp*sini*cosom*doti;
|
---|
1209 |
|
---|
1210 | vv[2] = sini *doty + yp*cosi *doti;
|
---|
1211 |
|
---|
1212 | // Relativistic Correction
|
---|
1213 | // -----------------------
|
---|
1214 | xc[3] -= 4.442807309e-10 * _e * sqrt(a0) *sin(E);
|
---|
1215 |
|
---|
1216 | xc[4] = _clock_drift + _clock_driftrate*tc;
|
---|
1217 | xc[5] = _clock_driftrate;
|
---|
1218 |
|
---|
1219 | return success;
|
---|
1220 | }
|
---|
1221 |
|
---|
1222 | // Health status of Galileo Ephemeris (virtual)
|
---|
1223 | ////////////////////////////////////////////////////////////////////////////
|
---|
1224 | unsigned int t_ephGal::isUnhealthy() const {
|
---|
1225 | if (_E5aHS && _E5bHS && _E1_bHS) {
|
---|
1226 | return 1;
|
---|
1227 | }
|
---|
1228 | return 0;
|
---|
1229 | }
|
---|
1230 |
|
---|
1231 | // RINEX Format String
|
---|
1232 | //////////////////////////////////////////////////////////////////////////////
|
---|
1233 | QString t_ephGal::toString(double version) const {
|
---|
1234 |
|
---|
1235 | QString navStr = navTypeString(_navType, _prn, version);
|
---|
1236 | QString rnxStr = navStr + rinexDateStr(_TOC, _prn, version);
|
---|
1237 |
|
---|
1238 | QTextStream out(&rnxStr);
|
---|
1239 |
|
---|
1240 | out << QString("%1%2%3\n")
|
---|
1241 | .arg(_clock_bias, 19, 'e', 12)
|
---|
1242 | .arg(_clock_drift, 19, 'e', 12)
|
---|
1243 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
1244 |
|
---|
1245 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
1246 |
|
---|
1247 | out << QString(fmt)
|
---|
1248 | .arg(_IODnav, 19, 'e', 12)
|
---|
1249 | .arg(_Crs, 19, 'e', 12)
|
---|
1250 | .arg(_Delta_n, 19, 'e', 12)
|
---|
1251 | .arg(_M0, 19, 'e', 12);
|
---|
1252 |
|
---|
1253 | out << QString(fmt)
|
---|
1254 | .arg(_Cuc, 19, 'e', 12)
|
---|
1255 | .arg(_e, 19, 'e', 12)
|
---|
1256 | .arg(_Cus, 19, 'e', 12)
|
---|
1257 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
1258 |
|
---|
1259 | out << QString(fmt)
|
---|
1260 | .arg(_TOEsec, 19, 'e', 12)
|
---|
1261 | .arg(_Cic, 19, 'e', 12)
|
---|
1262 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
1263 | .arg(_Cis, 19, 'e', 12);
|
---|
1264 |
|
---|
1265 | out << QString(fmt)
|
---|
1266 | .arg(_i0, 19, 'e', 12)
|
---|
1267 | .arg(_Crc, 19, 'e', 12)
|
---|
1268 | .arg(_omega, 19, 'e', 12)
|
---|
1269 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
1270 |
|
---|
1271 | int dataSource = 0;
|
---|
1272 | int SVhealth = 0;
|
---|
1273 | double BGD_1_5A = _BGD_1_5A;
|
---|
1274 | double BGD_1_5B = _BGD_1_5B;
|
---|
1275 | if (_fnav) {
|
---|
1276 | dataSource |= (1<<1);
|
---|
1277 | dataSource |= (1<<8);
|
---|
1278 | BGD_1_5B = 0.0;
|
---|
1279 | // SVhealth
|
---|
1280 | // Bit 3 : E5a DVS
|
---|
1281 | if (_e5aDataInValid) {
|
---|
1282 | SVhealth |= (1<<3);
|
---|
1283 | }
|
---|
1284 | // Bit 4-5: E5a HS
|
---|
1285 | if (_E5aHS == 1.0) {
|
---|
1286 | SVhealth |= (1<<4);
|
---|
1287 | }
|
---|
1288 | else if (_E5aHS == 2.0) {
|
---|
1289 | SVhealth |= (1<<5);
|
---|
1290 | }
|
---|
1291 | else if (_E5aHS == 3.0) {
|
---|
1292 | SVhealth |= (1<<4);
|
---|
1293 | SVhealth |= (1<<5);
|
---|
1294 | }
|
---|
1295 | }
|
---|
1296 | else if(_inav) {
|
---|
1297 | // Bit 2 and 0 are set because from MT1046 the data source cannot be determined
|
---|
1298 | // and RNXv3.03 says both can be set if the navigation messages were merged
|
---|
1299 | dataSource |= (1<<0);
|
---|
1300 | dataSource |= (1<<2);
|
---|
1301 | dataSource |= (1<<9);
|
---|
1302 | // SVhealth
|
---|
1303 | // Bit 0 : E1-B DVS
|
---|
1304 | if (_e1DataInValid) {
|
---|
1305 | SVhealth |= (1<<0);
|
---|
1306 | }
|
---|
1307 | // Bit 1-2: E1-B HS
|
---|
1308 | if (_E1_bHS == 1.0) {
|
---|
1309 | SVhealth |= (1<<1);
|
---|
1310 | }
|
---|
1311 | else if (_E1_bHS == 2.0) {
|
---|
1312 | SVhealth |= (1<<2);
|
---|
1313 | }
|
---|
1314 | else if (_E1_bHS == 3.0) {
|
---|
1315 | SVhealth |= (1<<1);
|
---|
1316 | SVhealth |= (1<<2);
|
---|
1317 | }
|
---|
1318 | // Bit 3 : E5a DVS
|
---|
1319 | if (_e5aDataInValid) {
|
---|
1320 | SVhealth |= (1<<3);
|
---|
1321 | }
|
---|
1322 | // Bit 4-5: E5a HS
|
---|
1323 | if (_E5aHS == 1.0) {
|
---|
1324 | SVhealth |= (1<<4);
|
---|
1325 | }
|
---|
1326 | else if (_E5aHS == 2.0) {
|
---|
1327 | SVhealth |= (1<<5);
|
---|
1328 | }
|
---|
1329 | else if (_E5aHS == 3.0) {
|
---|
1330 | SVhealth |= (1<<4);
|
---|
1331 | SVhealth |= (1<<5);
|
---|
1332 | }
|
---|
1333 | // Bit 6 : E5b DVS
|
---|
1334 | if (_e5bDataInValid) {
|
---|
1335 | SVhealth |= (1<<6);
|
---|
1336 | }
|
---|
1337 | // Bit 7-8: E5b HS
|
---|
1338 | if (_E5bHS == 1.0) {
|
---|
1339 | SVhealth |= (1<<7);
|
---|
1340 | }
|
---|
1341 | else if (_E5bHS == 2.0) {
|
---|
1342 | SVhealth |= (1<<8);
|
---|
1343 | }
|
---|
1344 | else if (_E5bHS == 3.0) {
|
---|
1345 | SVhealth |= (1<<7);
|
---|
1346 | SVhealth |= (1<<8);
|
---|
1347 | }
|
---|
1348 | }
|
---|
1349 |
|
---|
1350 | out << QString(fmt)
|
---|
1351 | .arg(_IDOT, 19, 'e', 12)
|
---|
1352 | .arg(double(dataSource), 19, 'e', 12)
|
---|
1353 | .arg(_TOEweek + 1024.0, 19, 'e', 12)
|
---|
1354 | .arg(0.0, 19, 'e', 12);
|
---|
1355 |
|
---|
1356 | out << QString(fmt)
|
---|
1357 | .arg(_SISA, 19, 'e', 12)
|
---|
1358 | .arg(double(SVhealth), 19, 'e', 12)
|
---|
1359 | .arg(BGD_1_5A, 19, 'e', 12)
|
---|
1360 | .arg(BGD_1_5B, 19, 'e', 12);
|
---|
1361 |
|
---|
1362 | double tot = _TOT;
|
---|
1363 | if (tot == 0.9999e9 && version < 3.0) {
|
---|
1364 | tot = 0.0;
|
---|
1365 | }
|
---|
1366 | out << QString(fmt)
|
---|
1367 | .arg(tot, 19, 'e', 12)
|
---|
1368 | .arg("", 19, QChar(' '))
|
---|
1369 | .arg("", 19, QChar(' '))
|
---|
1370 | .arg("", 19, QChar(' '));
|
---|
1371 |
|
---|
1372 | return rnxStr;
|
---|
1373 | }
|
---|
1374 |
|
---|
1375 | // Constructor
|
---|
1376 | //////////////////////////////////////////////////////////////////////////////
|
---|
1377 | t_ephSBAS::t_ephSBAS(double rnxVersion, const QStringList& lines) {
|
---|
1378 |
|
---|
1379 | const int nLines = 4;
|
---|
1380 |
|
---|
1381 | if (lines.size() != nLines) {
|
---|
1382 | _checkState = bad;
|
---|
1383 | return;
|
---|
1384 | }
|
---|
1385 |
|
---|
1386 | // RINEX Format
|
---|
1387 | // ------------
|
---|
1388 | int fieldLen = 19;
|
---|
1389 |
|
---|
1390 | int pos[4];
|
---|
1391 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
1392 | pos[1] = pos[0] + fieldLen;
|
---|
1393 | pos[2] = pos[1] + fieldLen;
|
---|
1394 | pos[3] = pos[2] + fieldLen;
|
---|
1395 |
|
---|
1396 | // Read four lines
|
---|
1397 | // ---------------
|
---|
1398 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
1399 | QString line = lines[iLine];
|
---|
1400 |
|
---|
1401 | if ( iLine == 0 ) {
|
---|
1402 | QTextStream in(line.left(pos[1]).toLatin1());
|
---|
1403 |
|
---|
1404 | int year, month, day, hour, min;
|
---|
1405 | double sec;
|
---|
1406 |
|
---|
1407 | QString prnStr, n;
|
---|
1408 | in >> prnStr;
|
---|
1409 | if (prnStr.size() == 1 && prnStr[0] == 'S') {
|
---|
1410 | in >> n;
|
---|
1411 | prnStr.append(n);
|
---|
1412 | }
|
---|
1413 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
1414 | if (prnStr.at(0) == 'S') {
|
---|
1415 | _prn.set('S', prnStr.mid(1).toInt());
|
---|
1416 | }
|
---|
1417 | else {
|
---|
1418 | _prn.set('S', prnStr.toInt());
|
---|
1419 | }
|
---|
1420 |
|
---|
1421 | if (year < 80) {
|
---|
1422 | year += 2000;
|
---|
1423 | }
|
---|
1424 | else if (year < 100) {
|
---|
1425 | year += 1900;
|
---|
1426 | }
|
---|
1427 |
|
---|
1428 | _TOC.set(year, month, day, hour, min, sec);
|
---|
1429 |
|
---|
1430 | if ( readDbl(line, pos[1], fieldLen, _agf0 ) ||
|
---|
1431 | readDbl(line, pos[2], fieldLen, _agf1 ) ||
|
---|
1432 | readDbl(line, pos[3], fieldLen, _TOT ) ) {
|
---|
1433 | _checkState = bad;
|
---|
1434 | return;
|
---|
1435 | }
|
---|
1436 | }
|
---|
1437 |
|
---|
1438 | else if ( iLine == 1 ) {
|
---|
1439 | if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
|
---|
1440 | readDbl(line, pos[1], fieldLen, _x_velocity ) ||
|
---|
1441 | readDbl(line, pos[2], fieldLen, _x_acceleration) ||
|
---|
1442 | readDbl(line, pos[3], fieldLen, _health ) ) {
|
---|
1443 | _checkState = bad;
|
---|
1444 | return;
|
---|
1445 | }
|
---|
1446 | }
|
---|
1447 |
|
---|
1448 | else if ( iLine == 2 ) {
|
---|
1449 | if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
|
---|
1450 | readDbl(line, pos[1], fieldLen, _y_velocity ) ||
|
---|
1451 | readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
|
---|
1452 | readDbl(line, pos[3], fieldLen, _ura ) ) {
|
---|
1453 | _checkState = bad;
|
---|
1454 | return;
|
---|
1455 | }
|
---|
1456 | }
|
---|
1457 |
|
---|
1458 | else if ( iLine == 3 ) {
|
---|
1459 | double iodn;
|
---|
1460 | if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
|
---|
1461 | readDbl(line, pos[1], fieldLen, _z_velocity ) ||
|
---|
1462 | readDbl(line, pos[2], fieldLen, _z_acceleration) ||
|
---|
1463 | readDbl(line, pos[3], fieldLen, iodn ) ) {
|
---|
1464 | _checkState = bad;
|
---|
1465 | return;
|
---|
1466 | } else {
|
---|
1467 | _IODN = int(iodn);
|
---|
1468 | }
|
---|
1469 | }
|
---|
1470 | }
|
---|
1471 |
|
---|
1472 | _x_pos *= 1.e3;
|
---|
1473 | _y_pos *= 1.e3;
|
---|
1474 | _z_pos *= 1.e3;
|
---|
1475 | _x_velocity *= 1.e3;
|
---|
1476 | _y_velocity *= 1.e3;
|
---|
1477 | _z_velocity *= 1.e3;
|
---|
1478 | _x_acceleration *= 1.e3;
|
---|
1479 | _y_acceleration *= 1.e3;
|
---|
1480 | _z_acceleration *= 1.e3;
|
---|
1481 | }
|
---|
1482 |
|
---|
1483 | // IOD of SBAS Ephemeris (virtual)
|
---|
1484 | ////////////////////////////////////////////////////////////////////////////
|
---|
1485 |
|
---|
1486 | unsigned int t_ephSBAS::IOD() const {
|
---|
1487 | unsigned char buffer[80];
|
---|
1488 | int size = 0;
|
---|
1489 | int numbits = 0;
|
---|
1490 | long long bitbuffer = 0;
|
---|
1491 | unsigned char *startbuffer = buffer;
|
---|
1492 |
|
---|
1493 | SBASADDBITSFLOAT(30, this->_x_pos, 0.08)
|
---|
1494 | SBASADDBITSFLOAT(30, this->_y_pos, 0.08)
|
---|
1495 | SBASADDBITSFLOAT(25, this->_z_pos, 0.4)
|
---|
1496 | SBASADDBITSFLOAT(17, this->_x_velocity, 0.000625)
|
---|
1497 | SBASADDBITSFLOAT(17, this->_y_velocity, 0.000625)
|
---|
1498 | SBASADDBITSFLOAT(18, this->_z_velocity, 0.004)
|
---|
1499 | SBASADDBITSFLOAT(10, this->_x_acceleration, 0.0000125)
|
---|
1500 | SBASADDBITSFLOAT(10, this->_y_acceleration, 0.0000125)
|
---|
1501 | SBASADDBITSFLOAT(10, this->_z_acceleration, 0.0000625)
|
---|
1502 | SBASADDBITSFLOAT(12, this->_agf0, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
|
---|
1503 | SBASADDBITSFLOAT(8, this->_agf1, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<10))
|
---|
1504 | SBASADDBITS(5,0); // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8
|
---|
1505 |
|
---|
1506 | return CRC24(size, startbuffer);
|
---|
1507 | }
|
---|
1508 |
|
---|
1509 | // Compute SBAS Satellite Position (virtual)
|
---|
1510 | ////////////////////////////////////////////////////////////////////////////
|
---|
1511 | t_irc t_ephSBAS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
1512 |
|
---|
1513 | bncTime tt(GPSweek, GPSweeks);
|
---|
1514 | double dt = tt - _TOC;
|
---|
1515 |
|
---|
1516 | xc[0] = _x_pos + _x_velocity * dt + _x_acceleration * dt * dt / 2.0;
|
---|
1517 | xc[1] = _y_pos + _y_velocity * dt + _y_acceleration * dt * dt / 2.0;
|
---|
1518 | xc[2] = _z_pos + _z_velocity * dt + _z_acceleration * dt * dt / 2.0;
|
---|
1519 |
|
---|
1520 | vv[0] = _x_velocity + _x_acceleration * dt;
|
---|
1521 | vv[1] = _y_velocity + _y_acceleration * dt;
|
---|
1522 | vv[2] = _z_velocity + _z_acceleration * dt;
|
---|
1523 |
|
---|
1524 | xc[3] = _agf0 + _agf1 * dt;
|
---|
1525 |
|
---|
1526 | xc[4] = _agf1;
|
---|
1527 | xc[5] = 0.0;
|
---|
1528 |
|
---|
1529 | return success;
|
---|
1530 | }
|
---|
1531 |
|
---|
1532 | // Health status of SBAS Ephemeris (virtual)
|
---|
1533 | ////////////////////////////////////////////////////////////////////////////
|
---|
1534 | unsigned int t_ephSBAS::isUnhealthy() const {
|
---|
1535 |
|
---|
1536 | // Bit 5
|
---|
1537 | bool URAindexIs15 = (int(_health) & (1<<5));
|
---|
1538 | if (URAindexIs15) {
|
---|
1539 | // in this case it is recommended
|
---|
1540 | // to set the bits 0,1,2,3 to 1 (MT17health = 15)
|
---|
1541 | return 1;
|
---|
1542 | }
|
---|
1543 |
|
---|
1544 | // Bit 0-3
|
---|
1545 | int MT17health = (int(_health)) & (0x0f);
|
---|
1546 | if (MT17health) {
|
---|
1547 | return 1;
|
---|
1548 | }
|
---|
1549 |
|
---|
1550 | // Bit 4
|
---|
1551 | // bool MT17HealthIsUnavailable = (int(_health) & (1<<4));
|
---|
1552 | // is not used because the MT17health bits can be independently set if URA index is 15
|
---|
1553 |
|
---|
1554 | return 0;
|
---|
1555 | }
|
---|
1556 |
|
---|
1557 |
|
---|
1558 | // RINEX Format String
|
---|
1559 | //////////////////////////////////////////////////////////////////////////////
|
---|
1560 | QString t_ephSBAS::toString(double version) const {
|
---|
1561 |
|
---|
1562 | QString navStr = navTypeString(_navType, _prn, version);
|
---|
1563 | QString rnxStr = navStr + rinexDateStr(_TOC, _prn, version);
|
---|
1564 |
|
---|
1565 | QTextStream out(&rnxStr);
|
---|
1566 |
|
---|
1567 | out << QString("%1%2%3\n")
|
---|
1568 | .arg(_agf0, 19, 'e', 12)
|
---|
1569 | .arg(_agf1, 19, 'e', 12)
|
---|
1570 | .arg(_TOT, 19, 'e', 12);
|
---|
1571 |
|
---|
1572 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
1573 |
|
---|
1574 | out << QString(fmt)
|
---|
1575 | .arg(1.e-3*_x_pos, 19, 'e', 12)
|
---|
1576 | .arg(1.e-3*_x_velocity, 19, 'e', 12)
|
---|
1577 | .arg(1.e-3*_x_acceleration, 19, 'e', 12)
|
---|
1578 | .arg(_health, 19, 'e', 12);
|
---|
1579 |
|
---|
1580 | out << QString(fmt)
|
---|
1581 | .arg(1.e-3*_y_pos, 19, 'e', 12)
|
---|
1582 | .arg(1.e-3*_y_velocity, 19, 'e', 12)
|
---|
1583 | .arg(1.e-3*_y_acceleration, 19, 'e', 12)
|
---|
1584 | .arg(_ura, 19, 'e', 12);
|
---|
1585 |
|
---|
1586 | out << QString(fmt)
|
---|
1587 | .arg(1.e-3*_z_pos, 19, 'e', 12)
|
---|
1588 | .arg(1.e-3*_z_velocity, 19, 'e', 12)
|
---|
1589 | .arg(1.e-3*_z_acceleration, 19, 'e', 12)
|
---|
1590 | .arg(double(_IODN), 19, 'e', 12);
|
---|
1591 |
|
---|
1592 | return rnxStr;
|
---|
1593 | }
|
---|
1594 |
|
---|
1595 | // Constructor
|
---|
1596 | //////////////////////////////////////////////////////////////////////////////
|
---|
1597 | t_ephBDS::t_ephBDS(double rnxVersion, const QStringList& lines) {
|
---|
1598 |
|
---|
1599 | const int nLines = 8;
|
---|
1600 |
|
---|
1601 | if (lines.size() != nLines) {
|
---|
1602 | _checkState = bad;
|
---|
1603 | return;
|
---|
1604 | }
|
---|
1605 |
|
---|
1606 | // RINEX Format
|
---|
1607 | // ------------
|
---|
1608 | int fieldLen = 19;
|
---|
1609 |
|
---|
1610 | int pos[4];
|
---|
1611 | pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
|
---|
1612 | pos[1] = pos[0] + fieldLen;
|
---|
1613 | pos[2] = pos[1] + fieldLen;
|
---|
1614 | pos[3] = pos[2] + fieldLen;
|
---|
1615 |
|
---|
1616 | // Read eight lines
|
---|
1617 | // ----------------
|
---|
1618 | for (int iLine = 0; iLine < nLines; iLine++) {
|
---|
1619 | QString line = lines[iLine];
|
---|
1620 |
|
---|
1621 | if ( iLine == 0 ) {
|
---|
1622 | QTextStream in(line.left(pos[1]).toLatin1());
|
---|
1623 |
|
---|
1624 | int year, month, day, hour, min;
|
---|
1625 | double sec;
|
---|
1626 |
|
---|
1627 | QString prnStr, n;
|
---|
1628 | in >> prnStr;
|
---|
1629 | if (prnStr.size() == 1 && prnStr[0] == 'C') {
|
---|
1630 | in >> n;
|
---|
1631 | prnStr.append(n);
|
---|
1632 | }
|
---|
1633 | in >> year >> month >> day >> hour >> min >> sec;
|
---|
1634 | if (prnStr.at(0) == 'C') {
|
---|
1635 | _prn.set('C', prnStr.mid(1).toInt());
|
---|
1636 | }
|
---|
1637 | else {
|
---|
1638 | _prn.set('C', prnStr.toInt());
|
---|
1639 | }
|
---|
1640 |
|
---|
1641 | if (year < 80) {
|
---|
1642 | year += 2000;
|
---|
1643 | }
|
---|
1644 | else if (year < 100) {
|
---|
1645 | year += 1900;
|
---|
1646 | }
|
---|
1647 |
|
---|
1648 | _TOC.setBDS(year, month, day, hour, min, sec);
|
---|
1649 |
|
---|
1650 | if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
|
---|
1651 | readDbl(line, pos[2], fieldLen, _clock_drift ) ||
|
---|
1652 | readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
|
---|
1653 | _checkState = bad;
|
---|
1654 | return;
|
---|
1655 | }
|
---|
1656 | }
|
---|
1657 |
|
---|
1658 | else if ( iLine == 1 ) {
|
---|
1659 | double aode;
|
---|
1660 | if ( readDbl(line, pos[0], fieldLen, aode ) ||
|
---|
1661 | readDbl(line, pos[1], fieldLen, _Crs ) ||
|
---|
1662 | readDbl(line, pos[2], fieldLen, _Delta_n) ||
|
---|
1663 | readDbl(line, pos[3], fieldLen, _M0 ) ) {
|
---|
1664 | _checkState = bad;
|
---|
1665 | return;
|
---|
1666 | }
|
---|
1667 | _AODE = int(aode);
|
---|
1668 | }
|
---|
1669 |
|
---|
1670 | else if ( iLine == 2 ) {
|
---|
1671 | if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
|
---|
1672 | readDbl(line, pos[1], fieldLen, _e ) ||
|
---|
1673 | readDbl(line, pos[2], fieldLen, _Cus ) ||
|
---|
1674 | readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
|
---|
1675 | _checkState = bad;
|
---|
1676 | return;
|
---|
1677 | }
|
---|
1678 | }
|
---|
1679 |
|
---|
1680 | else if ( iLine == 3 ) {
|
---|
1681 | if ( readDbl(line, pos[0], fieldLen, _TOEsec ) ||
|
---|
1682 | readDbl(line, pos[1], fieldLen, _Cic ) ||
|
---|
1683 | readDbl(line, pos[2], fieldLen, _OMEGA0) ||
|
---|
1684 | readDbl(line, pos[3], fieldLen, _Cis ) ) {
|
---|
1685 | _checkState = bad;
|
---|
1686 | return;
|
---|
1687 | }
|
---|
1688 | }
|
---|
1689 |
|
---|
1690 | else if ( iLine == 4 ) {
|
---|
1691 | if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
|
---|
1692 | readDbl(line, pos[1], fieldLen, _Crc ) ||
|
---|
1693 | readDbl(line, pos[2], fieldLen, _omega ) ||
|
---|
1694 | readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
|
---|
1695 | _checkState = bad;
|
---|
1696 | return;
|
---|
1697 | }
|
---|
1698 | }
|
---|
1699 |
|
---|
1700 | else if ( iLine == 5 ) {
|
---|
1701 | if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
|
---|
1702 | readDbl(line, pos[2], fieldLen, _BDTweek)) {
|
---|
1703 | _checkState = bad;
|
---|
1704 | return;
|
---|
1705 | }
|
---|
1706 | }
|
---|
1707 |
|
---|
1708 | else if ( iLine == 6 ) {
|
---|
1709 | double SatH1;
|
---|
1710 | if ( readDbl(line, pos[0], fieldLen, _URA ) ||
|
---|
1711 | readDbl(line, pos[1], fieldLen, SatH1) ||
|
---|
1712 | readDbl(line, pos[2], fieldLen, _TGD1) ||
|
---|
1713 | readDbl(line, pos[3], fieldLen, _TGD2) ) {
|
---|
1714 | _checkState = bad;
|
---|
1715 | return;
|
---|
1716 | }
|
---|
1717 | _SatH1 = int(SatH1);
|
---|
1718 | }
|
---|
1719 |
|
---|
1720 | else if ( iLine == 7 ) {
|
---|
1721 | double aodc;
|
---|
1722 | if ( readDbl(line, pos[0], fieldLen, _TOT) ||
|
---|
1723 | readDbl(line, pos[1], fieldLen, aodc) ) {
|
---|
1724 | _checkState = bad;
|
---|
1725 | return;
|
---|
1726 | }
|
---|
1727 | if (_TOT == 0.9999e9) { // 0.9999e9 means not known (RINEX standard)
|
---|
1728 | _TOT = _TOEsec;
|
---|
1729 | }
|
---|
1730 | _AODC = int(aodc);
|
---|
1731 | }
|
---|
1732 | }
|
---|
1733 |
|
---|
1734 | _TOE.setBDS(int(_BDTweek), _TOEsec);
|
---|
1735 |
|
---|
1736 | // remark: actually should be computed from second_tot
|
---|
1737 | // but it seems to be unreliable in RINEX files
|
---|
1738 | //_TOT = _TOC.bdssec();
|
---|
1739 | }
|
---|
1740 |
|
---|
1741 | // IOD of BDS Ephemeris (virtual)
|
---|
1742 | ////////////////////////////////////////////////////////////////////////////
|
---|
1743 | unsigned int t_ephBDS::IOD() const {
|
---|
1744 | return (int(_TOEsec)/720) % 240;
|
---|
1745 | }
|
---|
1746 |
|
---|
1747 | // Compute BDS Satellite Position (virtual)
|
---|
1748 | //////////////////////////////////////////////////////////////////////////////
|
---|
1749 | t_irc t_ephBDS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const {
|
---|
1750 |
|
---|
1751 | static const double gmBDS = 398.6004418e12;
|
---|
1752 | static const double omegaBDS = 7292115.0000e-11;
|
---|
1753 |
|
---|
1754 | xc[0] = xc[1] = xc[2] = xc[3] = 0.0;
|
---|
1755 | vv[0] = vv[1] = vv[2] = 0.0;
|
---|
1756 |
|
---|
1757 | bncTime tt(GPSweek, GPSweeks);
|
---|
1758 |
|
---|
1759 | if (_sqrt_A == 0) {
|
---|
1760 | return failure;
|
---|
1761 | }
|
---|
1762 | double a0 = _sqrt_A * _sqrt_A;
|
---|
1763 |
|
---|
1764 | double n0 = sqrt(gmBDS/(a0*a0*a0));
|
---|
1765 | double tk = tt - _TOE;
|
---|
1766 | double n = n0 + _Delta_n;
|
---|
1767 | double M = _M0 + n*tk;
|
---|
1768 | double E = M;
|
---|
1769 | double E_last;
|
---|
1770 | int nLoop = 0;
|
---|
1771 | do {
|
---|
1772 | E_last = E;
|
---|
1773 | E = M + _e*sin(E);
|
---|
1774 |
|
---|
1775 | if (++nLoop == 100) {
|
---|
1776 | return failure;
|
---|
1777 | }
|
---|
1778 | } while ( fabs(E-E_last)*a0 > 0.001 );
|
---|
1779 |
|
---|
1780 | double v = atan2(sqrt(1-_e*_e) * sin(E), cos(E) - _e);
|
---|
1781 | double u0 = v + _omega;
|
---|
1782 | double sin2u0 = sin(2*u0);
|
---|
1783 | double cos2u0 = cos(2*u0);
|
---|
1784 | double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
|
---|
1785 | double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
|
---|
1786 | double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
|
---|
1787 | double xp = r*cos(u);
|
---|
1788 | double yp = r*sin(u);
|
---|
1789 | double toesec = (_TOE.gpssec() - 14.0);
|
---|
1790 | double sinom = 0;
|
---|
1791 | double cosom = 0;
|
---|
1792 | double sini = 0;
|
---|
1793 | double cosi = 0;
|
---|
1794 |
|
---|
1795 | // Velocity
|
---|
1796 | // --------
|
---|
1797 | double tanv2 = tan(v/2);
|
---|
1798 | double dEdM = 1 / (1 - _e*cos(E));
|
---|
1799 | double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2)
|
---|
1800 | / (1 + tanv2*tanv2) * dEdM * n;
|
---|
1801 | double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
|
---|
1802 | double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
|
---|
1803 | double dotr = a0 * _e*sin(E) * dEdM * n
|
---|
1804 | + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
|
---|
1805 |
|
---|
1806 | double dotx = dotr*cos(u) - r*sin(u)*dotu;
|
---|
1807 | double doty = dotr*sin(u) + r*cos(u)*dotu;
|
---|
1808 |
|
---|
1809 | const double iMaxGEO = 10.0 / 180.0 * M_PI;
|
---|
1810 |
|
---|
1811 | // MEO/IGSO satellite
|
---|
1812 | // ------------------
|
---|
1813 | if (_i0 > iMaxGEO) {
|
---|
1814 | double OM = _OMEGA0 + (_OMEGADOT - omegaBDS)*tk - omegaBDS*toesec;
|
---|
1815 |
|
---|
1816 | sinom = sin(OM);
|
---|
1817 | cosom = cos(OM);
|
---|
1818 | sini = sin(i);
|
---|
1819 | cosi = cos(i);
|
---|
1820 |
|
---|
1821 | xc[0] = xp*cosom - yp*cosi*sinom;
|
---|
1822 | xc[1] = xp*sinom + yp*cosi*cosom;
|
---|
1823 | xc[2] = yp*sini;
|
---|
1824 |
|
---|
1825 | // Velocity
|
---|
1826 | // --------
|
---|
1827 |
|
---|
1828 | double dotom = _OMEGADOT - t_CST::omega;
|
---|
1829 |
|
---|
1830 | vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
|
---|
1831 | - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
|
---|
1832 | + yp*sini*sinom*doti; // dX / di
|
---|
1833 |
|
---|
1834 | vv[1] = sinom *dotx + cosi*cosom *doty
|
---|
1835 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
1836 | - yp*sini*cosom*doti;
|
---|
1837 |
|
---|
1838 | vv[2] = sini *doty + yp*cosi *doti;
|
---|
1839 |
|
---|
1840 | }
|
---|
1841 |
|
---|
1842 | // GEO satellite
|
---|
1843 | // -------------
|
---|
1844 | else {
|
---|
1845 | double OM = _OMEGA0 + _OMEGADOT*tk - omegaBDS*toesec;
|
---|
1846 | double ll = omegaBDS*tk;
|
---|
1847 |
|
---|
1848 | sinom = sin(OM);
|
---|
1849 | cosom = cos(OM);
|
---|
1850 | sini = sin(i);
|
---|
1851 | cosi = cos(i);
|
---|
1852 |
|
---|
1853 | double xx = xp*cosom - yp*cosi*sinom;
|
---|
1854 | double yy = xp*sinom + yp*cosi*cosom;
|
---|
1855 | double zz = yp*sini;
|
---|
1856 |
|
---|
1857 | Matrix RX = BNC_PPP::t_astro::rotX(-5.0 / 180.0 * M_PI);
|
---|
1858 | Matrix RZ = BNC_PPP::t_astro::rotZ(ll);
|
---|
1859 |
|
---|
1860 | ColumnVector X1(3); X1 << xx << yy << zz;
|
---|
1861 | ColumnVector X2 = RZ*RX*X1;
|
---|
1862 |
|
---|
1863 | xc[0] = X2(1);
|
---|
1864 | xc[1] = X2(2);
|
---|
1865 | xc[2] = X2(3);
|
---|
1866 |
|
---|
1867 | double dotom = _OMEGADOT;
|
---|
1868 |
|
---|
1869 | double vx = cosom *dotx - cosi*sinom *doty
|
---|
1870 | - xp*sinom*dotom - yp*cosi*cosom*dotom
|
---|
1871 | + yp*sini*sinom*doti;
|
---|
1872 |
|
---|
1873 | double vy = sinom *dotx + cosi*cosom *doty
|
---|
1874 | + xp*cosom*dotom - yp*cosi*sinom*dotom
|
---|
1875 | - yp*sini*cosom*doti;
|
---|
1876 |
|
---|
1877 | double vz = sini *doty + yp*cosi *doti;
|
---|
1878 |
|
---|
1879 | ColumnVector V(3); V << vx << vy << vz;
|
---|
1880 |
|
---|
1881 | Matrix RdotZ(3,3);
|
---|
1882 | double C = cos(ll);
|
---|
1883 | double S = sin(ll);
|
---|
1884 | Matrix UU(3,3);
|
---|
1885 | UU[0][0] = -S; UU[0][1] = +C; UU[0][2] = 0.0;
|
---|
1886 | UU[1][0] = -C; UU[1][1] = -S; UU[1][2] = 0.0;
|
---|
1887 | UU[2][0] = 0.0; UU[2][1] = 0.0; UU[2][2] = 0.0;
|
---|
1888 | RdotZ = omegaBDS * UU;
|
---|
1889 |
|
---|
1890 | ColumnVector VV(3);
|
---|
1891 | VV = RZ*RX*V + RdotZ*RX*X1;
|
---|
1892 |
|
---|
1893 | vv[0] = VV(1);
|
---|
1894 | vv[1] = VV(2);
|
---|
1895 | vv[2] = VV(3);
|
---|
1896 | }
|
---|
1897 |
|
---|
1898 | double tc = tt - _TOC;
|
---|
1899 | xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
|
---|
1900 |
|
---|
1901 | // dotC = _clock_drift + _clock_driftrate*tc
|
---|
1902 | // - 4.442807309e-10*_e * sqrt(a0) * cos(E) * dEdM * n;
|
---|
1903 |
|
---|
1904 | // Relativistic Correction
|
---|
1905 | // -----------------------
|
---|
1906 | xc[3] -= 4.442807309e-10 * _e * sqrt(a0) *sin(E);
|
---|
1907 |
|
---|
1908 | xc[4] = _clock_drift + _clock_driftrate*tc;
|
---|
1909 | xc[5] = _clock_driftrate;
|
---|
1910 |
|
---|
1911 | return success;
|
---|
1912 | }
|
---|
1913 |
|
---|
1914 | // RINEX Format String
|
---|
1915 | //////////////////////////////////////////////////////////////////////////////
|
---|
1916 | QString t_ephBDS::toString(double version) const {
|
---|
1917 |
|
---|
1918 | QString navStr = navTypeString(_navType, _prn, version);
|
---|
1919 | QString rnxStr = navStr + rinexDateStr(_TOC-14.0, _prn, version);
|
---|
1920 |
|
---|
1921 | QTextStream out(&rnxStr);
|
---|
1922 |
|
---|
1923 | out << QString("%1%2%3\n")
|
---|
1924 | .arg(_clock_bias, 19, 'e', 12)
|
---|
1925 | .arg(_clock_drift, 19, 'e', 12)
|
---|
1926 | .arg(_clock_driftrate, 19, 'e', 12);
|
---|
1927 |
|
---|
1928 | QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
|
---|
1929 |
|
---|
1930 | out << QString(fmt)
|
---|
1931 | .arg(double(_AODE), 19, 'e', 12)
|
---|
1932 | .arg(_Crs, 19, 'e', 12)
|
---|
1933 | .arg(_Delta_n, 19, 'e', 12)
|
---|
1934 | .arg(_M0, 19, 'e', 12);
|
---|
1935 |
|
---|
1936 | out << QString(fmt)
|
---|
1937 | .arg(_Cuc, 19, 'e', 12)
|
---|
1938 | .arg(_e, 19, 'e', 12)
|
---|
1939 | .arg(_Cus, 19, 'e', 12)
|
---|
1940 | .arg(_sqrt_A, 19, 'e', 12);
|
---|
1941 |
|
---|
1942 | out << QString(fmt)
|
---|
1943 | .arg(_TOEsec, 19, 'e', 12)
|
---|
1944 | .arg(_Cic, 19, 'e', 12)
|
---|
1945 | .arg(_OMEGA0, 19, 'e', 12)
|
---|
1946 | .arg(_Cis, 19, 'e', 12);
|
---|
1947 |
|
---|
1948 | out << QString(fmt)
|
---|
1949 | .arg(_i0, 19, 'e', 12)
|
---|
1950 | .arg(_Crc, 19, 'e', 12)
|
---|
1951 | .arg(_omega, 19, 'e', 12)
|
---|
1952 | .arg(_OMEGADOT, 19, 'e', 12);
|
---|
1953 |
|
---|
1954 | out << QString(fmt)
|
---|
1955 | .arg(_IDOT, 19, 'e', 12)
|
---|
1956 | .arg(0.0, 19, 'e', 12)
|
---|
1957 | .arg(_BDTweek, 19, 'e', 12)
|
---|
1958 | .arg(0.0, 19, 'e', 12);
|
---|
1959 |
|
---|
1960 | out << QString(fmt)
|
---|
1961 | .arg(_URA, 19, 'e', 12)
|
---|
1962 | .arg(double(_SatH1), 19, 'e', 12)
|
---|
1963 | .arg(_TGD1, 19, 'e', 12)
|
---|
1964 | .arg(_TGD2, 19, 'e', 12);
|
---|
1965 |
|
---|
1966 | double tots = 0.0;
|
---|
1967 | if (_receptDateTime.isValid()) {// RTCM stream input
|
---|
1968 | tots = _TOE.bdssec();
|
---|
1969 | }
|
---|
1970 | else { // RINEX input
|
---|
1971 | tots = _TOT;
|
---|
1972 | }
|
---|
1973 | out << QString(fmt)
|
---|
1974 | .arg(tots, 19, 'e', 12)
|
---|
1975 | .arg(double(_AODC), 19, 'e', 12)
|
---|
1976 | .arg("", 19, QChar(' '))
|
---|
1977 | .arg("", 19, QChar(' '));
|
---|
1978 | return rnxStr;
|
---|
1979 | }
|
---|