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