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