source: ntrip/trunk/BNC/src/RTCM3/ephemeris.cpp@ 5539

Last change on this file since 5539 was 5539, checked in by mervart, 10 years ago
File size: 37.7 KB
Line 
1#include <math.h>
2#include <sstream>
3#include <iostream>
4#include <iomanip>
5#include <cstring>
6
7#include <newmatio.h>
8
9#include "ephemeris.h"
10#include "bncutils.h"
11#include "timeutils.h"
12#include "bnctime.h"
13#include "bnccore.h"
14
15using namespace std;
16
17// Returns CRC24
18////////////////////////////////////////////////////////////////////////////
19static unsigned long CRC24(long size, const unsigned char *buf) {
20 unsigned long crc = 0;
21 int ii;
22 while (size--) {
23 crc ^= (*buf++) << (16);
24 for(ii = 0; ii < 8; ii++) {
25 crc <<= 1;
26 if (crc & 0x1000000) {
27 crc ^= 0x01864cfb;
28 }
29 }
30 }
31 return crc;
32}
33
34// Set GPS Satellite Position
35////////////////////////////////////////////////////////////////////////////
36void t_ephGPS::set(const gpsephemeris* ee) {
37
38 _receptDateTime = currentDateAndTimeGPS();
39
40 _prn = QString("G%1").arg(ee->satellite, 2, 10, QChar('0'));
41
42 _TOC.set(ee->GPSweek, ee->TOC);
43 _clock_bias = ee->clock_bias;
44 _clock_drift = ee->clock_drift;
45 _clock_driftrate = ee->clock_driftrate;
46
47 _IODE = ee->IODE;
48 _Crs = ee->Crs;
49 _Delta_n = ee->Delta_n;
50 _M0 = ee->M0;
51
52 _Cuc = ee->Cuc;
53 _e = ee->e;
54 _Cus = ee->Cus;
55 _sqrt_A = ee->sqrt_A;
56
57 _TOEsec = ee->TOE;
58 _Cic = ee->Cic;
59 _OMEGA0 = ee->OMEGA0;
60 _Cis = ee->Cis;
61
62 _i0 = ee->i0;
63 _Crc = ee->Crc;
64 _omega = ee->omega;
65 _OMEGADOT = ee->OMEGADOT;
66
67 _IDOT = ee->IDOT;
68 _L2Codes = 0.0;
69 _TOEweek = ee->GPSweek;
70 _L2PFlag = 0.0;
71
72 if (ee->URAindex <= 6) {
73 _ura = ceil(10.0*pow(2.0, 1.0+((double)ee->URAindex)/2.0))/10.0;
74 }
75 else {
76 _ura = ceil(10.0*pow(2.0, ((double)ee->URAindex)/2.0))/10.0;
77 }
78 _health = ee->SVhealth;
79 _TGD = ee->TGD;
80 _IODC = ee->IODC;
81
82 _TOT = 0.9999e9;
83 _fitInterval = 0.0;
84
85 _ok = true;
86}
87
88// Compute GPS Satellite Position (virtual)
89////////////////////////////////////////////////////////////////////////////
90void t_ephGPS::position(int GPSweek, double GPSweeks,
91 double* xc,
92 double* vv) const {
93
94
95 static const double omegaEarth = 7292115.1467e-11;
96 static const double gmGRS = 398.6005e12;
97
98 memset(xc, 0, 4*sizeof(double));
99 memset(vv, 0, 3*sizeof(double));
100
101 double a0 = _sqrt_A * _sqrt_A;
102 if (a0 == 0) {
103 return;
104 }
105
106 double n0 = sqrt(gmGRS/(a0*a0*a0));
107
108 bncTime tt(GPSweek, GPSweeks);
109 double tk = tt - bncTime(int(_TOEweek), _TOEsec);
110
111 double n = n0 + _Delta_n;
112 double M = _M0 + n*tk;
113 double E = M;
114 double E_last;
115 do {
116 E_last = E;
117 E = M + _e*sin(E);
118 } while ( fabs(E-E_last)*a0 > 0.001 );
119 double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
120 double u0 = v + _omega;
121 double sin2u0 = sin(2*u0);
122 double cos2u0 = cos(2*u0);
123 double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
124 double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
125 double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
126 double xp = r*cos(u);
127 double yp = r*sin(u);
128 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
129 omegaEarth*_TOEsec;
130
131 double sinom = sin(OM);
132 double cosom = cos(OM);
133 double sini = sin(i);
134 double cosi = cos(i);
135 xc[0] = xp*cosom - yp*cosi*sinom;
136 xc[1] = xp*sinom + yp*cosi*cosom;
137 xc[2] = yp*sini;
138
139 double tc = tt - _TOC;
140 xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
141
142 // Velocity
143 // --------
144 double tanv2 = tan(v/2);
145 double dEdM = 1 / (1 - _e*cos(E));
146 double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
147 * dEdM * n;
148 double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
149 double dotom = _OMEGADOT - omegaEarth;
150 double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
151 double dotr = a0 * _e*sin(E) * dEdM * n
152 + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
153 double dotx = dotr*cos(u) - r*sin(u)*dotu;
154 double doty = dotr*sin(u) + r*cos(u)*dotu;
155
156 vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
157 - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
158 + yp*sini*sinom*doti; // dX / di
159
160 vv[1] = sinom *dotx + cosi*cosom *doty
161 + xp*cosom*dotom - yp*cosi*sinom*dotom
162 - yp*sini*cosom*doti;
163
164 vv[2] = sini *doty + yp*cosi *doti;
165
166 // Relativistic Correction
167 // -----------------------
168 xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
169}
170
171// build up RTCM3 for GPS
172////////////////////////////////////////////////////////////////////////////
173#define GPSTOINT(type, value) static_cast<type>(round(value))
174
175#define GPSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
176 |(GPSTOINT(long long,b)&((1ULL<<a)-1)); \
177 numbits += (a); \
178 while(numbits >= 8) { \
179 buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
180
181#define GPSADDBITSFLOAT(a,b,c) {long long i = GPSTOINT(long long,(b)/(c)); \
182 GPSADDBITS(a,i)};
183
184int t_ephGPS::RTCM3(unsigned char *buffer) {
185
186 unsigned char *startbuffer = buffer;
187 buffer= buffer+3;
188 int size = 0;
189 int numbits = 0;
190 unsigned long long bitbuffer = 0;
191 if (_ura <= 2.40){
192 _ura = 0;
193 }
194 else if (_ura <= 3.40){
195 _ura = 1;
196 }
197 else if (_ura <= 6.85){
198 _ura = 2;
199 }
200 else if (_ura <= 9.65){
201 _ura = 3;
202 }
203 else if (_ura <= 13.65){
204 _ura = 4;
205 }
206 else if (_ura <= 24.00){
207 _ura = 5;
208 }
209 else if (_ura <= 48.00){
210 _ura = 6;
211 }
212 else if (_ura <= 96.00){
213 _ura = 7;
214 }
215 else if (_ura <= 192.00){
216 _ura = 8;
217 }
218 else if (_ura <= 384.00){
219 _ura = 9;
220 }
221 else if (_ura <= 768.00){
222 _ura = 10;
223 }
224 else if (_ura <= 1536.00){
225 _ura = 11;
226 }
227 else if (_ura <= 1536.00){
228 _ura = 12;
229 }
230 else if (_ura <= 2072.00){
231 _ura = 13;
232 }
233 else if (_ura <= 6144.00){
234 _ura = 14;
235 }
236 else{
237 _ura = 15;
238 }
239
240 GPSADDBITS(12, 1019)
241 GPSADDBITS(6,_prn.right((_prn.length()-1)).toInt())
242 GPSADDBITS(10, _TOC.gpsw())
243 GPSADDBITS(4, _ura)
244 GPSADDBITS(2,_L2Codes)
245 GPSADDBITSFLOAT(14, _IDOT, M_PI/static_cast<double>(1<<30)
246 /static_cast<double>(1<<13))
247 GPSADDBITS(8, _IODE)
248 GPSADDBITS(16, static_cast<int>(_TOC.gpssec())>>4)
249 GPSADDBITSFLOAT(8, _clock_driftrate, 1.0/static_cast<double>(1<<30)
250 /static_cast<double>(1<<25))
251 GPSADDBITSFLOAT(16, _clock_drift, 1.0/static_cast<double>(1<<30)
252 /static_cast<double>(1<<13))
253 GPSADDBITSFLOAT(22, _clock_bias, 1.0/static_cast<double>(1<<30)
254 /static_cast<double>(1<<1))
255 GPSADDBITS(10, _IODC)
256 GPSADDBITSFLOAT(16, _Crs, 1.0/static_cast<double>(1<<5))
257 GPSADDBITSFLOAT(16, _Delta_n, M_PI/static_cast<double>(1<<30)
258 /static_cast<double>(1<<13))
259 GPSADDBITSFLOAT(32, _M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
260 GPSADDBITSFLOAT(16, _Cuc, 1.0/static_cast<double>(1<<29))
261 GPSADDBITSFLOAT(32, _e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
262 GPSADDBITSFLOAT(16, _Cus, 1.0/static_cast<double>(1<<29))
263 GPSADDBITSFLOAT(32, _sqrt_A, 1.0/static_cast<double>(1<<19))
264 GPSADDBITS(16, static_cast<int>(_TOEsec)>>4)
265 GPSADDBITSFLOAT(16, _Cic, 1.0/static_cast<double>(1<<29))
266 GPSADDBITSFLOAT(32, _OMEGA0, M_PI/static_cast<double>(1<<30)
267 /static_cast<double>(1<<1))
268 GPSADDBITSFLOAT(16, _Cis, 1.0/static_cast<double>(1<<29))
269 GPSADDBITSFLOAT(32, _i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
270 GPSADDBITSFLOAT(16, _Crc, 1.0/static_cast<double>(1<<5))
271 GPSADDBITSFLOAT(32, _omega, M_PI/static_cast<double>(1<<30)
272 /static_cast<double>(1<<1))
273 GPSADDBITSFLOAT(24, _OMEGADOT, M_PI/static_cast<double>(1<<30)
274 /static_cast<double>(1<<13))
275 GPSADDBITSFLOAT(8, _TGD, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1))
276 GPSADDBITS(6, _health)
277 GPSADDBITS(1, _L2PFlag)
278 GPSADDBITS(1, 0) /* GPS fit interval */
279
280 startbuffer[0]=0xD3;
281 startbuffer[1]=(size >> 8);
282 startbuffer[2]=size;
283 unsigned long i = CRC24(size+3, startbuffer);
284 buffer[size++] = i >> 16;
285 buffer[size++] = i >> 8;
286 buffer[size++] = i;
287 size += 3;
288 return size;
289}
290
291// Derivative of the state vector using a simple force model (static)
292////////////////////////////////////////////////////////////////////////////
293ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector& xv,
294 double* acc) {
295
296 // State vector components
297 // -----------------------
298 ColumnVector rr = xv.rows(1,3);
299 ColumnVector vv = xv.rows(4,6);
300
301 // Acceleration
302 // ------------
303 static const double gmWGS = 398.60044e12;
304 static const double AE = 6378136.0;
305 static const double OMEGA = 7292115.e-11;
306 static const double C20 = -1082.6257e-6;
307
308 double rho = rr.norm_Frobenius();
309 double t1 = -gmWGS/(rho*rho*rho);
310 double t2 = 3.0/2.0 * C20 * (gmWGS*AE*AE) / (rho*rho*rho*rho*rho);
311 double t3 = OMEGA * OMEGA;
312 double t4 = 2.0 * OMEGA;
313 double z2 = rr(3) * rr(3);
314
315 // Vector of derivatives
316 // ---------------------
317 ColumnVector va(6);
318 va(1) = vv(1);
319 va(2) = vv(2);
320 va(3) = vv(3);
321 va(4) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(1) + t4*vv(2) + acc[0];
322 va(5) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(2) - t4*vv(1) + acc[1];
323 va(6) = (t1 + t2*(3.0-5.0*z2/(rho*rho)) ) * rr(3) + acc[2];
324
325 return va;
326}
327
328// Compute Glonass Satellite Position (virtual)
329////////////////////////////////////////////////////////////////////////////
330void t_ephGlo::position(int GPSweek, double GPSweeks,
331 double* xc, double* vv) const {
332
333 static const double nominalStep = 10.0;
334
335 memset(xc, 0, 4*sizeof(double));
336 memset(vv, 0, 3*sizeof(double));
337
338 double dtPos = bncTime(GPSweek, GPSweeks) - _tt;
339
340 int nSteps = int(fabs(dtPos) / nominalStep) + 1;
341 double step = dtPos / nSteps;
342
343 double acc[3];
344 acc[0] = _x_acceleration * 1.e3;
345 acc[1] = _y_acceleration * 1.e3;
346 acc[2] = _z_acceleration * 1.e3;
347 for (int ii = 1; ii <= nSteps; ii++) {
348 _xv = rungeKutta4(_tt.gpssec(), _xv, step, acc, glo_deriv);
349 _tt = _tt + step;
350 }
351
352 // Position and Velocity
353 // ---------------------
354 xc[0] = _xv(1);
355 xc[1] = _xv(2);
356 xc[2] = _xv(3);
357
358 vv[0] = _xv(4);
359 vv[1] = _xv(5);
360 vv[2] = _xv(6);
361
362 // Clock Correction
363 // ----------------
364 double dtClk = bncTime(GPSweek, GPSweeks) - _TOC;
365 xc[3] = -_tau + _gamma * dtClk;
366}
367
368// IOD of Glonass Ephemeris (virtual)
369////////////////////////////////////////////////////////////////////////////
370int t_ephGlo::IOD() const {
371 bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0;
372 return int(tMoscow.daysec() / 900);
373}
374
375// Set Glonass Ephemeris
376////////////////////////////////////////////////////////////////////////////
377void t_ephGlo::set(const glonassephemeris* ee) {
378
379 _receptDateTime = currentDateAndTimeGPS();
380
381 _prn = QString("R%1").arg(ee->almanac_number, 2, 10, QChar('0'));
382
383 int ww = ee->GPSWeek;
384 int tow = ee->GPSTOW;
385 updatetime(&ww, &tow, ee->tb*1000, 0); // Moscow -> GPS
386
387 // Check the day once more
388 // -----------------------
389 bool timeChanged = false;
390 {
391 const double secPerDay = 24 * 3600.0;
392 const double secPerWeek = 7 * secPerDay;
393 int ww_old = ww;
394 int tow_old = tow;
395 int currentWeek;
396 double currentSec;
397 currentGPSWeeks(currentWeek, currentSec);
398 bncTime currentTime(currentWeek, currentSec);
399 bncTime hTime(ww, (double) tow);
400
401 if (hTime - currentTime > secPerDay/2.0) {
402 timeChanged = true;
403 tow -= int(secPerDay);
404 if (tow < 0) {
405 tow += int(secPerWeek);
406 ww -= 1;
407 }
408 }
409 else if (hTime - currentTime < -secPerDay/2.0) {
410 timeChanged = true;
411 tow += int(secPerDay);
412 if (tow > secPerWeek) {
413 tow -= int(secPerWeek);
414 ww += 1;
415 }
416 }
417
418 if (false && timeChanged && BNC_CORE->mode() == t_bncCore::batchPostProcessing) {
419 bncTime newHTime(ww, (double) tow);
420 cout << "GLONASS " << ee->almanac_number << " Time Changed at "
421 << currentTime.datestr() << " " << currentTime.timestr()
422 << endl
423 << "old: " << hTime.datestr() << " " << hTime.timestr()
424 << endl
425 << "new: " << newHTime.datestr() << " " << newHTime.timestr()
426 << endl
427 << "eph: " << ee->GPSWeek << " " << ee->GPSTOW << " " << ee->tb
428 << endl
429 << "ww, tow (old): " << ww_old << " " << tow_old
430 << endl
431 << "ww, tow (new): " << ww << " " << tow
432 << endl << endl;
433 }
434 }
435
436 bncTime hlpTime(ww, (double) tow);
437 unsigned year, month, day;
438 hlpTime.civil_date(year, month, day);
439 _gps_utc = gnumleap(year, month, day);
440
441 _TOC.set(ww, tow);
442 _E = ee->E;
443 _tau = ee->tau;
444 _gamma = ee->gamma;
445 _x_pos = ee->x_pos;
446 _x_velocity = ee->x_velocity;
447 _x_acceleration = ee->x_acceleration;
448 _y_pos = ee->y_pos;
449 _y_velocity = ee->y_velocity;
450 _y_acceleration = ee->y_acceleration;
451 _z_pos = ee->z_pos;
452 _z_velocity = ee->z_velocity;
453 _z_acceleration = ee->z_acceleration;
454 _health = 0;
455 _frequency_number = ee->frequency_number;
456 _tki = ee->tk-3*60*60; if (_tki < 0) _tki += 86400;
457
458 // Initialize status vector
459 // ------------------------
460 _tt = _TOC;
461
462 _xv(1) = _x_pos * 1.e3;
463 _xv(2) = _y_pos * 1.e3;
464 _xv(3) = _z_pos * 1.e3;
465 _xv(4) = _x_velocity * 1.e3;
466 _xv(5) = _y_velocity * 1.e3;
467 _xv(6) = _z_velocity * 1.e3;
468
469 _ok = true;
470}
471
472// build up RTCM3 for GLONASS
473////////////////////////////////////////////////////////////////////////////
474#define GLONASSTOINT(type, value) static_cast<type>(round(value))
475
476#define GLONASSADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
477 |(GLONASSTOINT(long long,b)&((1ULL<<(a))-1)); \
478 numbits += (a); \
479 while(numbits >= 8) { \
480 buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
481#define GLONASSADDBITSFLOATM(a,b,c) {int s; long long i; \
482 if(b < 0.0) \
483 { \
484 s = 1; \
485 i = GLONASSTOINT(long long,(-b)/(c)); \
486 if(!i) s = 0; \
487 } \
488 else \
489 { \
490 s = 0; \
491 i = GLONASSTOINT(long long,(b)/(c)); \
492 } \
493 GLONASSADDBITS(1,s) \
494 GLONASSADDBITS(a-1,i)}
495
496int t_ephGlo::RTCM3(unsigned char *buffer)
497{
498
499 int size = 0;
500 int numbits = 0;
501 long long bitbuffer = 0;
502 unsigned char *startbuffer = buffer;
503 buffer= buffer+3;
504
505 GLONASSADDBITS(12, 1020)
506 GLONASSADDBITS(6, _prn.right((_prn.length()-1)).toInt())
507 GLONASSADDBITS(5, 7+_frequency_number)
508 GLONASSADDBITS(1, 0)
509 GLONASSADDBITS(1, 0)
510 GLONASSADDBITS(2, 0)
511 _tki=_tki+3*60*60;
512 GLONASSADDBITS(5, static_cast<int>(_tki)/(60*60))
513 GLONASSADDBITS(6, (static_cast<int>(_tki)/60)%60)
514 GLONASSADDBITS(1, (static_cast<int>(_tki)/30)%30)
515 GLONASSADDBITS(1, _health)
516 GLONASSADDBITS(1, 0)
517 unsigned long long timeofday = (static_cast<int>(_tt.gpssec()+3*60*60-_gps_utc)%86400);
518 GLONASSADDBITS(7, timeofday/60/15)
519 GLONASSADDBITSFLOATM(24, _x_velocity*1000, 1000.0/static_cast<double>(1<<20))
520 GLONASSADDBITSFLOATM(27, _x_pos*1000, 1000.0/static_cast<double>(1<<11))
521 GLONASSADDBITSFLOATM(5, _x_acceleration*1000, 1000.0/static_cast<double>(1<<30))
522 GLONASSADDBITSFLOATM(24, _y_velocity*1000, 1000.0/static_cast<double>(1<<20))
523 GLONASSADDBITSFLOATM(27, _y_pos*1000, 1000.0/static_cast<double>(1<<11))
524 GLONASSADDBITSFLOATM(5, _y_acceleration*1000, 1000.0/static_cast<double>(1<<30))
525 GLONASSADDBITSFLOATM(24, _z_velocity*1000, 1000.0/static_cast<double>(1<<20))
526 GLONASSADDBITSFLOATM(27,_z_pos*1000, 1000.0/static_cast<double>(1<<11))
527 GLONASSADDBITSFLOATM(5, _z_acceleration*1000, 1000.0/static_cast<double>(1<<30))
528 GLONASSADDBITS(1, 0)
529 GLONASSADDBITSFLOATM(11, _gamma, 1.0/static_cast<double>(1<<30)
530 /static_cast<double>(1<<10))
531 GLONASSADDBITS(2, 0) /* GLONASS-M P */
532 GLONASSADDBITS(1, 0) /* GLONASS-M ln(3) */
533 GLONASSADDBITSFLOATM(22, _tau, 1.0/static_cast<double>(1<<30))
534 GLONASSADDBITS(5, 0) /* GLONASS-M delta tau */
535 GLONASSADDBITS(5, _E)
536 GLONASSADDBITS(1, 0) /* GLONASS-M P4 */
537 GLONASSADDBITS(4, 0) /* GLONASS-M FT */
538 GLONASSADDBITS(11, 0) /* GLONASS-M NT */
539 GLONASSADDBITS(2, 0) /* GLONASS-M active? */
540 GLONASSADDBITS(1, 0) /* GLONASS additional data */
541 GLONASSADDBITS(11, 0) /* GLONASS NA */
542 GLONASSADDBITS(32, 0) /* GLONASS tau C */
543 GLONASSADDBITS(5, 0) /* GLONASS-M N4 */
544 GLONASSADDBITS(22, 0) /* GLONASS-M tau GPS */
545 GLONASSADDBITS(1, 0) /* GLONASS-M ln(5) */
546 GLONASSADDBITS(7, 0) /* Reserved */
547
548 startbuffer[0]=0xD3;
549 startbuffer[1]=(size >> 8);
550 startbuffer[2]=size;
551 unsigned long i = CRC24(size+3, startbuffer);
552 buffer[size++] = i >> 16;
553 buffer[size++] = i >> 8;
554 buffer[size++] = i;
555 size += 3;
556 return size;
557}
558
559// Set Galileo Satellite Position
560////////////////////////////////////////////////////////////////////////////
561void t_ephGal::set(const galileoephemeris* ee) {
562
563 _receptDateTime = currentDateAndTimeGPS();
564
565 _prn = QString("E%1").arg(ee->satellite, 2, 10, QChar('0'));
566
567 _TOC.set(ee->Week, ee->TOC);
568 _clock_bias = ee->clock_bias;
569 _clock_drift = ee->clock_drift;
570 _clock_driftrate = ee->clock_driftrate;
571
572 _IODnav = ee->IODnav;
573 _Crs = ee->Crs;
574 _Delta_n = ee->Delta_n;
575 _M0 = ee->M0;
576
577 _Cuc = ee->Cuc;
578 _e = ee->e;
579 _Cus = ee->Cus;
580 _sqrt_A = ee->sqrt_A;
581
582 _TOEsec = _TOC.gpssec();
583 //// _TOEsec = ee->TOE; //// TODO:
584 _Cic = ee->Cic;
585 _OMEGA0 = ee->OMEGA0;
586 _Cis = ee->Cis;
587
588 _i0 = ee->i0;
589 _Crc = ee->Crc;
590 _omega = ee->omega;
591 _OMEGADOT = ee->OMEGADOT;
592
593 _IDOT = ee->IDOT;
594 _TOEweek = ee->Week;
595
596 _SISA = ee->SISA;
597 _E5aHS = ee->E5aHS;
598 _BGD_1_5A = ee->BGD_1_5A;
599 _BGD_1_5B = ee->BGD_1_5B;
600
601 _TOT = 0.9999e9;
602
603 _flags = ee->flags;
604
605 _ok = true;
606}
607
608// Compute Galileo Satellite Position (virtual)
609////////////////////////////////////////////////////////////////////////////
610void t_ephGal::position(int GPSweek, double GPSweeks,
611 double* xc,
612 double* vv) const {
613
614 static const double omegaEarth = 7292115.1467e-11;
615 static const double gmWGS = 398.60044e12;
616
617 memset(xc, 0, 4*sizeof(double));
618 memset(vv, 0, 3*sizeof(double));
619
620 double a0 = _sqrt_A * _sqrt_A;
621 if (a0 == 0) {
622 return;
623 }
624
625 double n0 = sqrt(gmWGS/(a0*a0*a0));
626
627 bncTime tt(GPSweek, GPSweeks);
628 double tk = tt - bncTime(_TOC.gpsw(), _TOEsec);
629
630 double n = n0 + _Delta_n;
631 double M = _M0 + n*tk;
632 double E = M;
633 double E_last;
634 do {
635 E_last = E;
636 E = M + _e*sin(E);
637 } while ( fabs(E-E_last)*a0 > 0.001 );
638 double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) );
639 double u0 = v + _omega;
640 double sin2u0 = sin(2*u0);
641 double cos2u0 = cos(2*u0);
642 double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;
643 double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;
644 double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;
645 double xp = r*cos(u);
646 double yp = r*sin(u);
647 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk -
648 omegaEarth*_TOEsec;
649
650 double sinom = sin(OM);
651 double cosom = cos(OM);
652 double sini = sin(i);
653 double cosi = cos(i);
654 xc[0] = xp*cosom - yp*cosi*sinom;
655 xc[1] = xp*sinom + yp*cosi*cosom;
656 xc[2] = yp*sini;
657
658 double tc = tt - _TOC;
659 xc[3] = _clock_bias + _clock_drift*tc + _clock_driftrate*tc*tc;
660
661 // Velocity
662 // --------
663 double tanv2 = tan(v/2);
664 double dEdM = 1 / (1 - _e*cos(E));
665 double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)
666 * dEdM * n;
667 double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;
668 double dotom = _OMEGADOT - omegaEarth;
669 double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;
670 double dotr = a0 * _e*sin(E) * dEdM * n
671 + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;
672 double dotx = dotr*cos(u) - r*sin(u)*dotu;
673 double doty = dotr*sin(u) + r*cos(u)*dotu;
674
675 vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr
676 - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA
677 + yp*sini*sinom*doti; // dX / di
678
679 vv[1] = sinom *dotx + cosi*cosom *doty
680 + xp*cosom*dotom - yp*cosi*sinom*dotom
681 - yp*sini*cosom*doti;
682
683 vv[2] = sini *doty + yp*cosi *doti;
684
685 // Relativistic Correction
686 // -----------------------
687 // xc(4) -= 4.442807633e-10 * _e * sqrt(a0) *sin(E);
688 xc[3] -= 2.0 * (xc[0]*vv[0] + xc[1]*vv[1] + xc[2]*vv[2]) / t_CST::c / t_CST::c;
689}
690
691// build up RTCM3 for Galileo
692////////////////////////////////////////////////////////////////////////////
693#define GALILEOTOINT(type, value) static_cast<type>(round(value))
694
695#define GALILEOADDBITS(a, b) {bitbuffer = (bitbuffer<<(a)) \
696 |(GALILEOTOINT(long long,b)&((1LL<<a)-1)); \
697 numbits += (a); \
698 while(numbits >= 8) { \
699 buffer[size++] = bitbuffer>>(numbits-8);numbits -= 8;}}
700#define GALILEOADDBITSFLOAT(a,b,c) {long long i = GALILEOTOINT(long long,(b)/(c)); \
701 GALILEOADDBITS(a,i)};
702
703int t_ephGal::RTCM3(unsigned char *buffer) {
704 int size = 0;
705 int numbits = 0;
706 long long bitbuffer = 0;
707 unsigned char *startbuffer = buffer;
708 buffer= buffer+3;
709
710 GALILEOADDBITS(12, /*inav ? 1046 :*/ 1045)
711 GALILEOADDBITS(6, _prn.right((_prn.length()-1)).toInt())
712 GALILEOADDBITS(12, _TOC.gpsw())
713 GALILEOADDBITS(10, _IODnav)
714 GALILEOADDBITS(8, _SISA)
715 GALILEOADDBITSFLOAT(14, _IDOT, M_PI/static_cast<double>(1<<30)
716 /static_cast<double>(1<<13))
717 GALILEOADDBITS(14, _TOC.gpssec()/60)
718 GALILEOADDBITSFLOAT(6, _clock_driftrate, 1.0/static_cast<double>(1<<30)
719 /static_cast<double>(1<<29))
720 GALILEOADDBITSFLOAT(21, _clock_drift, 1.0/static_cast<double>(1<<30)
721 /static_cast<double>(1<<16))
722 GALILEOADDBITSFLOAT(31, _clock_bias, 1.0/static_cast<double>(1<<30)
723 /static_cast<double>(1<<4))
724 GALILEOADDBITSFLOAT(16, _Crs, 1.0/static_cast<double>(1<<5))
725 GALILEOADDBITSFLOAT(16, _Delta_n, M_PI/static_cast<double>(1<<30)
726 /static_cast<double>(1<<13))
727 GALILEOADDBITSFLOAT(32, _M0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
728 GALILEOADDBITSFLOAT(16, _Cuc, 1.0/static_cast<double>(1<<29))
729 GALILEOADDBITSFLOAT(32, _e, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<3))
730 GALILEOADDBITSFLOAT(16, _Cus, 1.0/static_cast<double>(1<<29))
731 GALILEOADDBITSFLOAT(32, _sqrt_A, 1.0/static_cast<double>(1<<19))
732 GALILEOADDBITS(14, _TOEsec/60)
733 GALILEOADDBITSFLOAT(16, _Cic, 1.0/static_cast<double>(1<<29))
734 GALILEOADDBITSFLOAT(32, _OMEGA0, M_PI/static_cast<double>(1<<30)
735 /static_cast<double>(1<<1))
736 GALILEOADDBITSFLOAT(16, _Cis, 1.0/static_cast<double>(1<<29))
737 GALILEOADDBITSFLOAT(32, _i0, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<1))
738 GALILEOADDBITSFLOAT(16, _Crc, 1.0/static_cast<double>(1<<5))
739 GALILEOADDBITSFLOAT(32, _omega, M_PI/static_cast<double>(1<<30)
740 /static_cast<double>(1<<1))
741 GALILEOADDBITSFLOAT(24, _OMEGADOT, M_PI/static_cast<double>(1<<30)
742 /static_cast<double>(1<<13))
743 GALILEOADDBITSFLOAT(10, _BGD_1_5A, 1.0/static_cast<double>(1<<30)
744 /static_cast<double>(1<<2))
745 /*if(inav)
746 {
747 GALILEOADDBITSFLOAT(10, _BGD_1_5B, 1.0/static_cast<double>(1<<30)
748 /static_cast<double>(1<<2))
749 GALILEOADDBITS(2, _E5bHS)
750 GALILEOADDBITS(1, flags & MNFGALEPHF_E5BDINVALID)
751 }
752 else*/
753 {
754 GALILEOADDBITS(2, _E5aHS)
755 GALILEOADDBITS(1, /*flags & MNFGALEPHF_E5ADINVALID*/0)
756 }
757 _TOEsec = 0.9999E9;
758 GALILEOADDBITS(20, _TOEsec)
759
760 GALILEOADDBITS(/*inav ? 1 :*/ 3, 0) /* fill up */
761
762 startbuffer[0]=0xD3;
763 startbuffer[1]=(size >> 8);
764 startbuffer[2]=size;
765 unsigned long i = CRC24(size+3, startbuffer);
766 buffer[size++] = i >> 16;
767 buffer[size++] = i >> 8;
768 buffer[size++] = i;
769 size += 3;
770 return size;
771}
772
773// Constructor
774//////////////////////////////////////////////////////////////////////////////
775t_ephGPS::t_ephGPS(float rnxVersion, const QStringList& lines) {
776
777 const int nLines = 8;
778
779 _ok = false;
780
781 if (lines.size() != nLines) {
782 return;
783 }
784
785 // RINEX Format
786 // ------------
787 int fieldLen = 19;
788
789 int pos[4];
790 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
791 pos[1] = pos[0] + fieldLen;
792 pos[2] = pos[1] + fieldLen;
793 pos[3] = pos[2] + fieldLen;
794
795 // Read eight lines
796 // ----------------
797 for (int iLine = 0; iLine < nLines; iLine++) {
798 QString line = lines[iLine];
799
800 if ( iLine == 0 ) {
801 QTextStream in(line.left(pos[1]).toAscii());
802
803 int year, month, day, hour, min;
804 double sec;
805
806 in >> _prn >> year >> month >> day >> hour >> min >> sec;
807
808 if (_prn.at(0) != 'G') {
809 _prn = QString("G%1").arg(_prn.toInt(), 2, 10, QLatin1Char('0'));
810 }
811
812 if (year < 80) {
813 year += 2000;
814 }
815 else if (year < 100) {
816 year += 1900;
817 }
818
819 _TOC.set(year, month, day, hour, min, sec);
820
821 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
822 readDbl(line, pos[2], fieldLen, _clock_drift ) ||
823 readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
824 return;
825 }
826 }
827
828 else if ( iLine == 1 ) {
829 if ( readDbl(line, pos[0], fieldLen, _IODE ) ||
830 readDbl(line, pos[1], fieldLen, _Crs ) ||
831 readDbl(line, pos[2], fieldLen, _Delta_n) ||
832 readDbl(line, pos[3], fieldLen, _M0 ) ) {
833 return;
834 }
835 }
836
837 else if ( iLine == 2 ) {
838 if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
839 readDbl(line, pos[1], fieldLen, _e ) ||
840 readDbl(line, pos[2], fieldLen, _Cus ) ||
841 readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
842 return;
843 }
844 }
845
846 else if ( iLine == 3 ) {
847 if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
848 readDbl(line, pos[1], fieldLen, _Cic ) ||
849 readDbl(line, pos[2], fieldLen, _OMEGA0) ||
850 readDbl(line, pos[3], fieldLen, _Cis ) ) {
851 return;
852 }
853 }
854
855 else if ( iLine == 4 ) {
856 if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
857 readDbl(line, pos[1], fieldLen, _Crc ) ||
858 readDbl(line, pos[2], fieldLen, _omega ) ||
859 readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
860 return;
861 }
862 }
863
864 else if ( iLine == 5 ) {
865 if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
866 readDbl(line, pos[1], fieldLen, _L2Codes) ||
867 readDbl(line, pos[2], fieldLen, _TOEweek ) ||
868 readDbl(line, pos[3], fieldLen, _L2PFlag) ) {
869 return;
870 }
871 }
872
873 else if ( iLine == 6 ) {
874 if ( readDbl(line, pos[0], fieldLen, _ura ) ||
875 readDbl(line, pos[1], fieldLen, _health) ||
876 readDbl(line, pos[2], fieldLen, _TGD ) ||
877 readDbl(line, pos[3], fieldLen, _IODC ) ) {
878 return;
879 }
880 }
881
882 else if ( iLine == 7 ) {
883 if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
884 return;
885 }
886 readDbl(line, pos[1], fieldLen, _fitInterval); // _fitInterval optional
887 }
888 }
889
890 _ok = true;
891}
892
893// Constructor
894//////////////////////////////////////////////////////////////////////////////
895t_ephGlo::t_ephGlo(float rnxVersion, const QStringList& lines) {
896
897 const int nLines = 4;
898
899 _ok = false;
900
901 if (lines.size() != nLines) {
902 return;
903 }
904
905 // RINEX Format
906 // ------------
907 int fieldLen = 19;
908
909 int pos[4];
910 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
911 pos[1] = pos[0] + fieldLen;
912 pos[2] = pos[1] + fieldLen;
913 pos[3] = pos[2] + fieldLen;
914
915 // Read four lines
916 // ---------------
917 for (int iLine = 0; iLine < nLines; iLine++) {
918 QString line = lines[iLine];
919
920 if ( iLine == 0 ) {
921 QTextStream in(line.left(pos[1]).toAscii());
922
923 int year, month, day, hour, min;
924 double sec;
925
926 in >> _prn >> year >> month >> day >> hour >> min >> sec;
927
928 if (_prn.at(0) != 'R') {
929 _prn = QString("R%1").arg(_prn.toInt(), 2, 10, QLatin1Char('0'));
930 }
931
932 if (year < 80) {
933 year += 2000;
934 }
935 else if (year < 100) {
936 year += 1900;
937 }
938
939 _gps_utc = gnumleap(year, month, day);
940
941 _TOC.set(year, month, day, hour, min, sec);
942 _TOC = _TOC + _gps_utc;
943
944 if ( readDbl(line, pos[1], fieldLen, _tau ) ||
945 readDbl(line, pos[2], fieldLen, _gamma) ||
946 readDbl(line, pos[3], fieldLen, _tki ) ) {
947 return;
948 }
949
950 _tau = -_tau;
951 }
952
953 else if ( iLine == 1 ) {
954 if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||
955 readDbl(line, pos[1], fieldLen, _x_velocity ) ||
956 readDbl(line, pos[2], fieldLen, _x_acceleration) ||
957 readDbl(line, pos[3], fieldLen, _health ) ) {
958 return;
959 }
960 }
961
962 else if ( iLine == 2 ) {
963 if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||
964 readDbl(line, pos[1], fieldLen, _y_velocity ) ||
965 readDbl(line, pos[2], fieldLen, _y_acceleration ) ||
966 readDbl(line, pos[3], fieldLen, _frequency_number) ) {
967 return;
968 }
969 }
970
971 else if ( iLine == 3 ) {
972 if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||
973 readDbl(line, pos[1], fieldLen, _z_velocity ) ||
974 readDbl(line, pos[2], fieldLen, _z_acceleration) ||
975 readDbl(line, pos[3], fieldLen, _E ) ) {
976 return;
977 }
978 }
979 }
980
981 // Initialize status vector
982 // ------------------------
983 _tt = _TOC;
984 _xv.ReSize(6);
985 _xv(1) = _x_pos * 1.e3;
986 _xv(2) = _y_pos * 1.e3;
987 _xv(3) = _z_pos * 1.e3;
988 _xv(4) = _x_velocity * 1.e3;
989 _xv(5) = _y_velocity * 1.e3;
990 _xv(6) = _z_velocity * 1.e3;
991
992 _ok = true;
993}
994
995// Constructor
996//////////////////////////////////////////////////////////////////////////////
997t_ephGal::t_ephGal(float rnxVersion, const QStringList& lines) {
998
999 const int nLines = 8;
1000
1001 _ok = false;
1002
1003 if (lines.size() != nLines) {
1004 return;
1005 }
1006
1007 // RINEX Format
1008 // ------------
1009 int fieldLen = 19;
1010
1011 int pos[4];
1012 pos[0] = (rnxVersion <= 2.12) ? 3 : 4;
1013 pos[1] = pos[0] + fieldLen;
1014 pos[2] = pos[1] + fieldLen;
1015 pos[3] = pos[2] + fieldLen;
1016
1017 // Read eight lines
1018 // ----------------
1019 for (int iLine = 0; iLine < nLines; iLine++) {
1020 QString line = lines[iLine];
1021
1022 if ( iLine == 0 ) {
1023 QTextStream in(line.left(pos[1]).toAscii());
1024
1025 int year, month, day, hour, min;
1026 double sec;
1027
1028 in >> _prn >> year >> month >> day >> hour >> min >> sec;
1029
1030 if (_prn.at(0) != 'E') {
1031 _prn = QString("E%1").arg(_prn.toInt(), 2, 10, QLatin1Char('0'));
1032 }
1033
1034 if (year < 80) {
1035 year += 2000;
1036 }
1037 else if (year < 100) {
1038 year += 1900;
1039 }
1040
1041 _TOC.set(year, month, day, hour, min, sec);
1042
1043 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||
1044 readDbl(line, pos[2], fieldLen, _clock_drift ) ||
1045 readDbl(line, pos[3], fieldLen, _clock_driftrate) ) {
1046 return;
1047 }
1048 }
1049
1050 else if ( iLine == 1 ) {
1051 if ( readDbl(line, pos[0], fieldLen, _IODnav ) ||
1052 readDbl(line, pos[1], fieldLen, _Crs ) ||
1053 readDbl(line, pos[2], fieldLen, _Delta_n) ||
1054 readDbl(line, pos[3], fieldLen, _M0 ) ) {
1055 return;
1056 }
1057 }
1058
1059 else if ( iLine == 2 ) {
1060 if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||
1061 readDbl(line, pos[1], fieldLen, _e ) ||
1062 readDbl(line, pos[2], fieldLen, _Cus ) ||
1063 readDbl(line, pos[3], fieldLen, _sqrt_A) ) {
1064 return;
1065 }
1066 }
1067
1068 else if ( iLine == 3 ) {
1069 if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||
1070 readDbl(line, pos[1], fieldLen, _Cic ) ||
1071 readDbl(line, pos[2], fieldLen, _OMEGA0) ||
1072 readDbl(line, pos[3], fieldLen, _Cis ) ) {
1073 return;
1074 }
1075 }
1076
1077 else if ( iLine == 4 ) {
1078 if ( readDbl(line, pos[0], fieldLen, _i0 ) ||
1079 readDbl(line, pos[1], fieldLen, _Crc ) ||
1080 readDbl(line, pos[2], fieldLen, _omega ) ||
1081 readDbl(line, pos[3], fieldLen, _OMEGADOT) ) {
1082 return;
1083 }
1084 }
1085
1086 else if ( iLine == 5 ) {
1087 if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||
1088 readDbl(line, pos[2], fieldLen, _TOEweek) ) {
1089 return;
1090 }
1091 }
1092
1093 else if ( iLine == 6 ) {
1094 if ( readDbl(line, pos[0], fieldLen, _SISA ) ||
1095 readDbl(line, pos[1], fieldLen, _E5aHS ) ||
1096 readDbl(line, pos[2], fieldLen, _BGD_1_5A) ||
1097 readDbl(line, pos[3], fieldLen, _BGD_1_5B) ) {
1098 return;
1099 }
1100 }
1101
1102 else if ( iLine == 7 ) {
1103 if ( readDbl(line, pos[0], fieldLen, _TOT) ) {
1104 return;
1105 }
1106 }
1107 }
1108
1109 _ok = true;
1110}
1111
1112//
1113//////////////////////////////////////////////////////////////////////////////
1114QString t_eph::rinexDateStr(const bncTime& tt, const QString& prn,
1115 double version) {
1116
1117 QString datStr;
1118
1119 unsigned year, month, day, hour, min;
1120 double sec;
1121 tt.civil_date(year, month, day);
1122 tt.civil_time(hour, min, sec);
1123
1124 QTextStream out(&datStr);
1125
1126 if (version < 3.0) {
1127 QString prnHlp = prn.mid(1,2); if (prnHlp[0] == '0') prnHlp[0] = ' ';
1128 out << prnHlp << QString(" %1 %2 %3 %4 %5%6")
1129 .arg(year % 100, 2, 10, QChar('0'))
1130 .arg(month, 2)
1131 .arg(day, 2)
1132 .arg(hour, 2)
1133 .arg(min, 2)
1134 .arg(sec, 5, 'f',1);
1135 }
1136 else {
1137 out << prn << QString(" %1 %2 %3 %4 %5 %6")
1138 .arg(year, 4)
1139 .arg(month, 2, 10, QChar('0'))
1140 .arg(day, 2, 10, QChar('0'))
1141 .arg(hour, 2, 10, QChar('0'))
1142 .arg(min, 2, 10, QChar('0'))
1143 .arg(int(sec), 2, 10, QChar('0'));
1144 }
1145
1146 return datStr;
1147}
1148
1149// RINEX Format String
1150//////////////////////////////////////////////////////////////////////////////
1151QString t_ephGPS::toString(double version) const {
1152
1153 QString rnxStr = rinexDateStr(_TOC, _prn, version);
1154
1155 QTextStream out(&rnxStr);
1156
1157 out << QString("%1%2%3\n")
1158 .arg(_clock_bias, 19, 'e', 12)
1159 .arg(_clock_drift, 19, 'e', 12)
1160 .arg(_clock_driftrate, 19, 'e', 12);
1161
1162 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
1163
1164 out << QString(fmt)
1165 .arg(_IODE, 19, 'e', 12)
1166 .arg(_Crs, 19, 'e', 12)
1167 .arg(_Delta_n, 19, 'e', 12)
1168 .arg(_M0, 19, 'e', 12);
1169
1170 out << QString(fmt)
1171 .arg(_Cuc, 19, 'e', 12)
1172 .arg(_e, 19, 'e', 12)
1173 .arg(_Cus, 19, 'e', 12)
1174 .arg(_sqrt_A, 19, 'e', 12);
1175
1176 out << QString(fmt)
1177 .arg(_TOEsec, 19, 'e', 12)
1178 .arg(_Cic, 19, 'e', 12)
1179 .arg(_OMEGA0, 19, 'e', 12)
1180 .arg(_Cis, 19, 'e', 12);
1181
1182 out << QString(fmt)
1183 .arg(_i0, 19, 'e', 12)
1184 .arg(_Crc, 19, 'e', 12)
1185 .arg(_omega, 19, 'e', 12)
1186 .arg(_OMEGADOT, 19, 'e', 12);
1187
1188 out << QString(fmt)
1189 .arg(_IDOT, 19, 'e', 12)
1190 .arg(_L2Codes, 19, 'e', 12)
1191 .arg(_TOEweek, 19, 'e', 12)
1192 .arg(_L2PFlag, 19, 'e', 12);
1193
1194 out << QString(fmt)
1195 .arg(_ura, 19, 'e', 12)
1196 .arg(_health, 19, 'e', 12)
1197 .arg(_TGD, 19, 'e', 12)
1198 .arg(_IODC, 19, 'e', 12);
1199
1200 out << QString(fmt)
1201 .arg(_TOT, 19, 'e', 12)
1202 .arg(_fitInterval, 19, 'e', 12)
1203 .arg("", 19, QChar(' '))
1204 .arg("", 19, QChar(' '));
1205
1206 return rnxStr;
1207}
1208
1209// RINEX Format String
1210//////////////////////////////////////////////////////////////////////////////
1211QString t_ephGlo::toString(double version) const {
1212
1213 QString rnxStr = rinexDateStr(_TOC-_gps_utc, _prn, version);
1214
1215 QTextStream out(&rnxStr);
1216
1217 out << QString("%1%2%3\n")
1218 .arg(-_tau, 19, 'e', 12)
1219 .arg(_gamma, 19, 'e', 12)
1220 .arg(_tki, 19, 'e', 12);
1221
1222 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
1223
1224 out << QString(fmt)
1225 .arg(_x_pos, 19, 'e', 12)
1226 .arg(_x_velocity, 19, 'e', 12)
1227 .arg(_x_acceleration, 19, 'e', 12)
1228 .arg(_health, 19, 'e', 12);
1229
1230 out << QString(fmt)
1231 .arg(_y_pos, 19, 'e', 12)
1232 .arg(_y_velocity, 19, 'e', 12)
1233 .arg(_y_acceleration, 19, 'e', 12)
1234 .arg(_frequency_number, 19, 'e', 12);
1235
1236 out << QString(fmt)
1237 .arg(_z_pos, 19, 'e', 12)
1238 .arg(_z_velocity, 19, 'e', 12)
1239 .arg(_z_acceleration, 19, 'e', 12)
1240 .arg(_E, 19, 'e', 12);
1241
1242 return rnxStr;
1243}
1244
1245// RINEX Format String
1246//////////////////////////////////////////////////////////////////////////////
1247QString t_ephGal::toString(double version) const {
1248
1249 QString rnxStr = rinexDateStr(_TOC, _prn, version);
1250
1251 QTextStream out(&rnxStr);
1252
1253 out << QString("%1%2%3\n")
1254 .arg(_clock_bias, 19, 'e', 12)
1255 .arg(_clock_drift, 19, 'e', 12)
1256 .arg(_clock_driftrate, 19, 'e', 12);
1257
1258 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n";
1259
1260 out << QString(fmt)
1261 .arg(_IODnav, 19, 'e', 12)
1262 .arg(_Crs, 19, 'e', 12)
1263 .arg(_Delta_n, 19, 'e', 12)
1264 .arg(_M0, 19, 'e', 12);
1265
1266 out << QString(fmt)
1267 .arg(_Cuc, 19, 'e', 12)
1268 .arg(_e, 19, 'e', 12)
1269 .arg(_Cus, 19, 'e', 12)
1270 .arg(_sqrt_A, 19, 'e', 12);
1271
1272 out << QString(fmt)
1273 .arg(_TOEsec, 19, 'e', 12)
1274 .arg(_Cic, 19, 'e', 12)
1275 .arg(_OMEGA0, 19, 'e', 12)
1276 .arg(_Cis, 19, 'e', 12);
1277
1278 out << QString(fmt)
1279 .arg(_i0, 19, 'e', 12)
1280 .arg(_Crc, 19, 'e', 12)
1281 .arg(_omega, 19, 'e', 12)
1282 .arg(_OMEGADOT, 19, 'e', 12);
1283
1284 int dataSource = 0;
1285 if ( (_flags & GALEPHF_INAV) == GALEPHF_INAV ) {
1286 dataSource |= (1<<0);
1287 }
1288 else if ( (_flags & GALEPHF_FNAV) == GALEPHF_FNAV ) {
1289 dataSource |= (1<<1);
1290 }
1291 out << QString(fmt)
1292 .arg(_IDOT, 19, 'e', 12)
1293 .arg(double(dataSource), 19, 'e', 12)
1294 .arg(_TOEweek, 19, 'e', 12)
1295 .arg(0.0, 19, 'e', 12);
1296
1297 out << QString(fmt)
1298 .arg(_SISA, 19, 'e', 12)
1299 .arg(_E5aHS, 19, 'e', 12)
1300 .arg(_BGD_1_5A, 19, 'e', 12)
1301 .arg(_BGD_1_5B, 19, 'e', 12);
1302
1303 out << QString(fmt)
1304 .arg(_TOT, 19, 'e', 12)
1305 .arg("", 19, QChar(' '))
1306 .arg("", 19, QChar(' '))
1307 .arg("", 19, QChar(' '));
1308
1309 return rnxStr;
1310}
1311
Note: See TracBrowser for help on using the repository browser.