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