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