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