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