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