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