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