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