Changeset 10577 in ntrip
- Timestamp:
- Nov 8, 2024, 2:13:26 PM (4 weeks ago)
- Location:
- trunk/BNC/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/RTCM3/RTCM3Decoder.cpp
r10555 r10577 1134 1134 eph._fitInterval = fitIntervalFromFlag(fitIntervalFalg, eph._IODC, eph.type()); 1135 1135 eph._TOT = 0.9999e9; 1136 eph._ navType = t_eph::LNAV;1136 eph._ephType = t_eph::LNAV; 1137 1137 1138 1138 emit newGPSEph(eph); … … 1315 1315 _gloFrq = QString("%1 %2").arg(eph._prn.toString().c_str()).arg(eph._frequency_number, 2, 'f', 0); 1316 1316 1317 eph._ navType = t_eph::FDMA;1317 eph._ephType = t_eph::FDMA; 1318 1318 1319 1319 emit newGlonassEph(eph); … … 1429 1429 1430 1430 GETBITS(i, 4) 1431 if (i <= 6) 1432 eph._ura = ceil(10.0 * pow(2.0, 1.0 + i / 2.0)) / 10.0; 1433 else 1434 eph._ura = ceil(10.0 * pow(2.0, i / 2.0)) / 10.0; 1431 eph._ura = accuracyFromIndex(i, eph.type()); 1435 1432 GETBITS(eph._health, 6) 1436 1433 GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 << 1)) … … 1439 1436 eph._fitInterval = fitIntervalFromFlag(fitIntervalFalg, eph._IODC, eph.type()); 1440 1437 eph._TOT = 0.9999e9; 1441 eph._ navType = t_eph::LNAV;1438 eph._ephType = t_eph::LNAV; 1442 1439 1443 1440 emit newGPSEph(eph); … … 1570 1567 SKIPBITS(2) 1571 1568 eph._TOT = 0.9999e9; 1572 eph._ navType = t_eph::LNAV;1569 eph._ephType = t_eph::LNAV; 1573 1570 1574 1571 emit newGPSEph(eph); … … 1645 1642 eph._TOT = 0.9999E9; 1646 1643 eph._health = 0; 1647 eph._ navType = t_eph::SBASL1;1644 eph._ephType = t_eph::SBASL1; 1648 1645 1649 1646 emit newSBASEph(eph); … … 1770 1767 return false; 1771 1768 } 1772 eph._ navType = t_eph::INAF;1769 eph._ephType = t_eph::INAF; 1773 1770 } 1774 1771 else { … … 1782 1779 GETBITS(eph._E5aHS, 2) 1783 1780 GETBITS(eph._e5aDataInValid, 1) 1784 eph._ navType = t_eph::FNAV;1781 eph._ephType = t_eph::FNAV; 1785 1782 } 1786 1783 eph._TOT = 0.9999e9; … … 1906 1903 eph._TOT = 0.9999E9; 1907 1904 if (eph._i0 > iMaxGEO) { 1908 eph._ navType = t_eph::D1;1905 eph._ephType = t_eph::D1; 1909 1906 } 1910 1907 else { 1911 eph._ navType = t_eph::D2;1908 eph._ephType = t_eph::D2; 1912 1909 } 1913 1910 -
trunk/BNC/src/bnccore.cpp
r10549 r10577 209 209 messagePrivate(QString("%1: UNHEALTHY %2:%3") 210 210 .arg(eph->receptStaID()) 211 .arg(eph-> navTypeString(eph->navType(), eph->prn(), 99.0))211 .arg(eph->ephTypeStr(eph->ephType(), eph->prn(), 99.0)) 212 212 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1()); 213 213 } … … 215 215 messagePrivate(QString("%1: WRONG %2:%3") 216 216 .arg(eph->receptStaID()) 217 .arg(eph-> navTypeString(eph->navType(), eph->prn(), 99.0))217 .arg(eph->ephTypeStr(eph->ephType(), eph->prn(), 99.0)) 218 218 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1()); 219 219 } … … 221 221 messagePrivate(QString("%1: OUTDATED %2:%3") 222 222 .arg(eph->receptStaID()) 223 .arg(eph-> navTypeString(eph->navType(), eph->prn(), 99.0))223 .arg(eph->ephTypeStr(eph->ephType(), eph->prn(), 99.0)) 224 224 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1()); 225 225 } -
trunk/BNC/src/bncutils.cpp
r10568 r10577 851 851 type == t_eph::BDS || 852 852 type == t_eph::SBAS|| 853 type == t_eph::QZSS) { 853 type == t_eph::QZSS|| 854 type == t_eph::IRNSS) { 854 855 if ((index >= 0) && (index <= 6)) { 855 856 if (index == 3) { … … 860 861 } 861 862 } 862 else if ((index > 6) && (index < =15)) {863 else if ((index > 6) && (index < 15)) { 863 864 accuracy = (10.0 * pow(2.0, (double(index) - 2.0))) / 10.0; 864 } 865 866 } // index = 15: absence of accuracy prediction => use SV on your own risk 865 867 else { 866 868 accuracy = 8192.0; … … 884 886 } 885 887 } 886 else if (type == t_eph::IRNSS) {887 if ((index >= 0) && (index <= 6)) {888 if (index == 1) {889 accuracy = 2.8;890 }891 else if (index == 3) {892 accuracy = 5.7;893 }894 else if (index == 5) {895 accuracy = 11.3;896 }897 else {898 accuracy = pow(2, 1 + index / 2);899 }900 }901 else if ((index > 6) && (index <= 15)) {902 accuracy = pow(2, index - 2);903 }904 }905 888 return accuracy; 906 889 } … … 913 896 type == t_eph::BDS || 914 897 type == t_eph::SBAS || 915 type == t_eph::QZSS) { 916 917 if (accuracy <= 2.40) { 898 type == t_eph::QZSS || 899 type == t_eph::IRNSS) { 900 901 if (accuracy <= 2.40) { 918 902 return 0; 919 903 } … … 966 950 967 951 if (type == t_eph::Galileo) { 968 969 if (accuracy <= 0.49) { 952 if (accuracy <= 0.49) { 970 953 return int(ceil(accuracy * 100.0)); 971 954 } -
trunk/BNC/src/ephemeris.cpp
r10575 r10577 22 22 t_eph::t_eph() { 23 23 _checkState = unchecked; 24 _ navType = undefined;25 _orbCorr 26 _clkCorr 24 _ephType = undefined; 25 _orbCorr = 0; 26 _clkCorr = 0; 27 27 } 28 28 // Destructor … … 37 37 // 38 38 //////////////////////////////////////////////////////////////////////////// 39 void t_eph::setOrbCorr(const t_orbCorr *orbCorr) {39 void t_eph::setOrbCorr(const t_orbCorr *orbCorr) { 40 40 if (_orbCorr) { 41 41 delete _orbCorr; … … 47 47 // 48 48 //////////////////////////////////////////////////////////////////////////// 49 void t_eph::setClkCorr(const t_clkCorr *clkCorr) {49 void t_eph::setClkCorr(const t_clkCorr *clkCorr) { 50 50 if (_clkCorr) { 51 51 delete _clkCorr; … … 57 57 // 58 58 //////////////////////////////////////////////////////////////////////////// 59 t_irc t_eph::getCrd(const bncTime & tt, ColumnVector& xc, ColumnVector& vv, bool useCorr) const {60 61 if (_checkState == bad || 62 _checkState == unhealthy ||63 _checkState == outdated) {59 t_irc t_eph::getCrd(const bncTime &tt, ColumnVector &xc, ColumnVector &vv, 60 bool useCorr) const { 61 62 if (_checkState == bad || _checkState == unhealthy 63 || _checkState == outdated) { 64 64 return failure; 65 65 } … … 81 81 dx[2] = _orbCorr->_xr[2] + _orbCorr->_dotXr[2] * dtO; 82 82 83 RSW_to_XYZ(xc.Rows(1, 3), vv.Rows(1,3), dx, dx);83 RSW_to_XYZ(xc.Rows(1, 3), vv.Rows(1, 3), dx, dx); 84 84 85 85 xc[0] -= dx[0]; … … 88 88 89 89 ColumnVector dv(3); 90 RSW_to_XYZ(xc.Rows(1, 3), vv.Rows(1,3), _orbCorr->_dotXr, dv);90 RSW_to_XYZ(xc.Rows(1, 3), vv.Rows(1, 3), _orbCorr->_dotXr, dv); 91 91 92 92 vv[0] -= dv[0]; … … 98 98 dtC -= (0.5 * ssrUpdateInt[_clkCorr->_updateInt]); 99 99 } 100 xc[3] += _clkCorr->_dClk + _clkCorr->_dotDClk * dtC + _clkCorr->_dotDotDClk * dtC * dtC;101 }102 else {100 xc[3] += _clkCorr->_dClk + _clkCorr->_dotDClk * dtC 101 + _clkCorr->_dotDotDClk * dtC * dtC; 102 } else { 103 103 return failure; 104 104 } … … 106 106 return success; 107 107 } 108 109 108 110 109 // 111 110 ////////////////////////////////////////////////////////////////////////////// 112 t_irc t_eph::setNavType(QString navTypeStr) { 113 114 if (navTypeStr == "LNAV") { 115 _navType = t_eph::LNAV; 116 } 117 else if (navTypeStr == "FDMA") { 118 _navType = t_eph::FDMA; 119 } 120 else if (navTypeStr == "FNAV") { 121 _navType = t_eph::FNAV; 122 } 123 else if (navTypeStr == "INAV") { 124 _navType = t_eph::INAF; 125 } 126 else if (navTypeStr == "D1") { 127 _navType = t_eph::D1; 128 } 129 else if (navTypeStr == "D2") { 130 _navType = t_eph::D2; 131 } 132 else if (navTypeStr == "SBAS") { 133 _navType = t_eph::SBASL1; 134 } 135 else if (navTypeStr == "CNAV") { 136 _navType = t_eph::CNAV; 137 } 138 else if (navTypeStr == "CNV1") { 139 _navType = t_eph::CNV1; 140 } 141 else if (navTypeStr == "CNV2") { 142 _navType = t_eph::CNV2; 143 } 144 else if (navTypeStr == "CNV3") { 145 _navType = t_eph::CNV3; 146 } 147 else { 148 _navType = t_eph::undefined; 111 t_irc t_eph::setEphType(QString ephTypeStr) { 112 113 if (ephTypeStr == "LNAV") { 114 _ephType = t_eph::LNAV; 115 } else if (ephTypeStr == "FDMA") { 116 _ephType = t_eph::FDMA; 117 } else if (ephTypeStr == "FNAV") { 118 _ephType = t_eph::FNAV; 119 } else if (ephTypeStr == "INAV") { 120 _ephType = t_eph::INAF; 121 } else if (ephTypeStr == "D1") { 122 _ephType = t_eph::D1; 123 } else if (ephTypeStr == "D2") { 124 _ephType = t_eph::D2; 125 } else if (ephTypeStr == "SBAS") { 126 _ephType = t_eph::SBASL1; 127 } else if (ephTypeStr == "CNAV") { 128 _ephType = t_eph::CNAV; 129 } else if (ephTypeStr == "CNV1") { 130 _ephType = t_eph::CNV1; 131 } else if (ephTypeStr == "CNV2") { 132 _ephType = t_eph::CNV2; 133 } else if (ephTypeStr == "CNV3") { 134 _ephType = t_eph::CNV3; 135 } else if (ephTypeStr == "L1NV") { 136 _ephType = t_eph::L1NV; 137 } else if (ephTypeStr == "L1OC") { 138 _ephType = t_eph::L1OC; 139 } else if (ephTypeStr == "L3OC") { 140 _ephType = t_eph::L3OC; 141 } else { 142 _ephType = t_eph::undefined; 149 143 return failure; 150 144 } … … 155 149 // 156 150 ////////////////////////////////////////////////////////////////////////////// 157 QString t_eph::navTypeString(e_navType navType, const t_prn& prn, double version) { 158 QString navTypeString = ""; 159 QString epochStart; 160 QString eolStr; 161 162 if (version < 4.0) { 163 return navTypeString; 164 } 165 166 if (version == 99.0) { 167 epochStart = ""; 168 eolStr = ""; 169 } 170 else { 171 epochStart = "> "; 172 eolStr = "\n"; 173 } 174 175 QString ephStr = QString("EPH %1 ").arg(prn.toString().c_str()); 176 switch (navType) { 177 case undefined: 178 navTypeString = epochStart + ephStr + "unknown" + eolStr; 179 break; 180 case LNAV: 181 navTypeString = epochStart + ephStr + "LNAV" + eolStr; 182 break; 183 case FDMA: 184 navTypeString = epochStart + ephStr + "FDMA" + eolStr; 185 break; 186 case FNAV: 187 navTypeString = epochStart + ephStr + "FNAV" + eolStr; 188 break; 189 case INAF: 190 navTypeString = epochStart + ephStr + "INAV" + eolStr; 191 break; 192 case D1: 193 navTypeString = epochStart + ephStr + "D1 " + eolStr; 194 break; 195 case D2: 196 navTypeString = epochStart + ephStr + "D2 " + eolStr; 197 break; 198 case SBASL1: 199 navTypeString = epochStart + ephStr + "SBAS" + eolStr; 200 break; 201 case CNAV: 202 navTypeString = epochStart + ephStr + "CNAV" + eolStr; 203 break; 204 case CNV1: 205 navTypeString = epochStart + ephStr + "CNV1" + eolStr; 206 break; 207 case CNV2: 208 navTypeString = epochStart + ephStr + "CNV2" + eolStr; 209 break; 210 case CNV3: 211 navTypeString = epochStart + ephStr + "CNV3" + eolStr; 212 break; 213 } 214 return navTypeString; 215 } 151 QString t_eph::ephTypeStr(e_ephType ephType, const t_prn &prn, double version) { 152 QString ephTypeStr = ""; 153 QString epochStart; 154 QString eolStr; 155 156 if (version < 4.0) { 157 return ephTypeStr; 158 } 159 160 if (version == 99.0) { 161 epochStart = ""; 162 eolStr = ""; 163 } else { 164 epochStart = "> "; 165 eolStr = "\n"; 166 } 167 168 QString ephStr = QString("EPH %1 ").arg(prn.toString().c_str()); 169 switch (ephType) { 170 case undefined: 171 ephTypeStr = epochStart + ephStr + "unknown" + eolStr; 172 break; 173 case LNAV: 174 ephTypeStr = epochStart + ephStr + "LNAV" + eolStr; 175 break; 176 case FDMA: 177 ephTypeStr = epochStart + ephStr + "FDMA" + eolStr; 178 break; 179 case FNAV: 180 ephTypeStr = epochStart + ephStr + "FNAV" + eolStr; 181 break; 182 case INAF: 183 ephTypeStr = epochStart + ephStr + "INAV" + eolStr; 184 break; 185 case D1: 186 ephTypeStr = epochStart + ephStr + "D1 " + eolStr; 187 break; 188 case D2: 189 ephTypeStr = epochStart + ephStr + "D2 " + eolStr; 190 break; 191 case SBASL1: 192 ephTypeStr = epochStart + ephStr + "SBAS" + eolStr; 193 break; 194 case CNAV: 195 ephTypeStr = epochStart + ephStr + "CNAV" + eolStr; 196 break; 197 case CNV1: 198 ephTypeStr = epochStart + ephStr + "CNV1" + eolStr; 199 break; 200 case CNV2: 201 ephTypeStr = epochStart + ephStr + "CNV2" + eolStr; 202 break; 203 case CNV3: 204 ephTypeStr = epochStart + ephStr + "CNV3" + eolStr; 205 break; 206 case L1NV: 207 ephTypeStr = epochStart + ephStr + "L1NV" + eolStr; 208 break; 209 case L1OC: 210 ephTypeStr = epochStart + ephStr + "L1OC" + eolStr; 211 break; 212 case L3OC: 213 ephTypeStr = epochStart + ephStr + "L3OC" + eolStr; 214 break; 215 } 216 return ephTypeStr; 217 } 216 218 217 219 // 218 220 ////////////////////////////////////////////////////////////////////////////// 219 QString t_eph::rinexDateStr(const bncTime& tt, const t_prn& prn, double version) { 221 QString t_eph::rinexDateStr(const bncTime &tt, const t_prn &prn, 222 double version) { 220 223 QString prnStr(prn.toString().c_str()); 221 224 return rinexDateStr(tt, prnStr, version); … … 224 227 // 225 228 ////////////////////////////////////////////////////////////////////////////// 226 QString t_eph::rinexDateStr(const bncTime& tt, const QString& prnStr, double version) { 229 QString t_eph::rinexDateStr(const bncTime &tt, const QString &prnStr, 230 double version) { 227 231 228 232 QString datStr; 229 233 230 234 unsigned year, month, day, hour, min; 231 double 235 double sec; 232 236 tt.civil_date(year, month, day); 233 237 tt.civil_time(hour, min, sec); … … 236 240 237 241 if (version < 3.0) { 238 QString prnHlp = prnStr.mid(1,2); if (prnHlp[0] == '0') prnHlp[0] = ' '; 239 out << prnHlp << QString(" %1 %2 %3 %4 %5%6") 240 .arg(year % 100, 2, 10, QChar('0')) 241 .arg(month, 2) 242 .arg(day, 2) 243 .arg(hour, 2) 244 .arg(min, 2) 245 .arg(sec, 5, 'f',1); 246 } 247 else if (version == 99) { 248 out << QString(" %1 %2 %3 %4 %5 %6") 249 .arg(year, 4) 250 .arg(month, 2, 10, QChar('0')) 251 .arg(day, 2, 10, QChar('0')) 252 .arg(hour, 2, 10, QChar('0')) 253 .arg(min, 2, 10, QChar('0')) 254 .arg(int(sec), 2, 10, QChar('0')); 255 } 256 else { 257 out << prnStr << QString(" %1 %2 %3 %4 %5 %6") 258 .arg(year, 4) 259 .arg(month, 2, 10, QChar('0')) 260 .arg(day, 2, 10, QChar('0')) 261 .arg(hour, 2, 10, QChar('0')) 262 .arg(min, 2, 10, QChar('0')) 263 .arg(int(sec), 2, 10, QChar('0')); 242 QString prnHlp = prnStr.mid(1, 2); 243 if (prnHlp[0] == '0') 244 prnHlp[0] = ' '; 245 out << prnHlp 246 << QString(" %1 %2 %3 %4 %5%6").arg(year % 100, 2, 10, QChar('0')).arg( 247 month, 2).arg(day, 2).arg(hour, 2).arg(min, 2).arg(sec, 5, 'f', 1); 248 } else if (version == 99) { 249 out 250 << QString(" %1 %2 %3 %4 %5 %6").arg(year, 4).arg(month, 2, 10, 251 QChar('0')).arg(day, 2, 10, QChar('0')).arg(hour, 2, 10, QChar('0')).arg( 252 min, 2, 10, QChar('0')).arg(int(sec), 2, 10, QChar('0')); 253 } else { 254 out << prnStr 255 << QString(" %1 %2 %3 %4 %5 %6").arg(year, 4).arg(month, 2, 10, 256 QChar('0')).arg(day, 2, 10, QChar('0')).arg(hour, 2, 10, QChar('0')).arg( 257 min, 2, 10, QChar('0')).arg(int(sec), 2, 10, QChar('0')); 264 258 } 265 259 … … 269 263 // Constructor 270 264 ////////////////////////////////////////////////////////////////////////////// 271 t_ephGPS::t_ephGPS(double rnxVersion, const QStringList& lines) { 272 273 int nLines = 8; 274 275 if (navType() == t_eph::CNAV) { 265 t_ephGPS::t_ephGPS(double rnxVersion, const QStringList &lines) { 266 267 int nLines = 8; // LNAV, 268 269 if (ephType() == t_eph::CNAV || 270 ephType() == t_eph::L1NV) { 276 271 nLines += 1; 277 272 } 278 if ( navType() == t_eph::CNV2) {273 if (ephType() == t_eph::CNV2) { 279 274 nLines += 2; 280 275 } … … 290 285 291 286 int pos[4]; 292 pos[0] = (rnxVersion <= 2.12) ? 3 :4;287 pos[0] = (rnxVersion <= 2.12) ? 3 : 4; 293 288 pos[1] = pos[0] + fieldLen; 294 289 pos[2] = pos[1] + fieldLen; … … 300 295 QString line = lines[iLine]; 301 296 302 if ( iLine == 0) {297 if (iLine == 0) { 303 298 QTextStream in(line.left(pos[1]).toLatin1()); 304 int 299 int year, month, day, hour, min; 305 300 double sec; 306 301 … … 308 303 in >> prnStr; 309 304 310 if (prnStr.size() == 1 && 311 (prnStr[0] == 'G' || 312 prnStr[0] == 'J' || 313 prnStr[0] == 'I')) { 305 if (prnStr.size() == 1 306 && (prnStr[0] == 'G' || prnStr[0] == 'J' || prnStr[0] == 'I')) { 314 307 in >> n; 315 308 prnStr.append(n); … … 317 310 318 311 in >> year >> month >> day >> hour >> min >> sec; 319 if 312 if (prnStr.at(0) == 'G') { 320 313 _prn.set('G', prnStr.mid(1).toInt()); 321 } 322 else if (prnStr.at(0) == 'J') { 314 } else if (prnStr.at(0) == 'J') { 323 315 _prn.set('J', prnStr.mid(1).toInt()); 324 } 325 else if (prnStr.at(0) == 'I') { 316 } else if (prnStr.at(0) == 'I') { 326 317 _prn.set('I', prnStr.mid(1).toInt()); 327 } 328 else { 318 } else { 329 319 _prn.set('G', prnStr.toInt()); 330 320 } 331 321 332 if (year <80) {322 if (year < 80) { 333 323 year += 2000; 334 } 335 else if (year < 100) { 324 } else if (year < 100) { 336 325 year += 1900; 337 326 } … … 339 328 _TOC.set(year, month, day, hour, min, sec); 340 329 341 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||342 readDbl(line, pos[2], fieldLen, _clock_drift ) ||343 readDbl(line, pos[3], fieldLen, _clock_driftrate)) {330 if ( readDbl(line, pos[1], fieldLen, _clock_bias) 331 || readDbl(line, pos[2], fieldLen, _clock_drift) 332 || readDbl(line, pos[3], fieldLen, _clock_driftrate)) { 344 333 _checkState = bad; 345 334 return; … … 349 338 // BROADCAST ORBIT - 1 350 339 // ===================== 351 else if ( iLine == 1) { 352 353 if (navType() == t_eph::CNAV || 354 navType() == t_eph::CNV2) { 355 if ( readDbl(line, pos[0], fieldLen, _ADOT ) || 356 readDbl(line, pos[1], fieldLen, _Crs ) || 357 readDbl(line, pos[2], fieldLen, _Delta_n) || 358 readDbl(line, pos[3], fieldLen, _M0 ) ) { 359 _checkState = bad; 360 return; 361 } 362 } 363 else { // LNAV, undefined 364 if ( readDbl(line, pos[0], fieldLen, _IODE ) || 365 readDbl(line, pos[1], fieldLen, _Crs ) || 366 readDbl(line, pos[2], fieldLen, _Delta_n) || 367 readDbl(line, pos[3], fieldLen, _M0 ) ) { 340 else if (iLine == 1) { 341 if (ephType() == t_eph::CNAV || 342 ephType() == t_eph::CNV2 || 343 ephType() == t_eph::L1NV) { 344 if ( readDbl(line, pos[0], fieldLen, _ADOT) 345 || readDbl(line, pos[1], fieldLen, _Crs) 346 || readDbl(line, pos[2], fieldLen, _Delta_n) 347 || readDbl(line, pos[3], fieldLen, _M0)) { 348 _checkState = bad; 349 return; 350 } 351 } else { // LNAV, undefined 352 if ( readDbl(line, pos[0], fieldLen, _IODE) 353 || readDbl(line, pos[1], fieldLen, _Crs) 354 || readDbl(line, pos[2], fieldLen, _Delta_n) 355 || readDbl(line, pos[3], fieldLen, _M0)) { 368 356 _checkState = bad; 369 357 return; … … 374 362 // BROADCAST ORBIT - 2 375 363 // ===================== 376 else if ( iLine == 2) {377 if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||378 readDbl(line, pos[1], fieldLen, _e ) ||379 readDbl(line, pos[2], fieldLen, _Cus ) ||380 readDbl(line, pos[3], fieldLen, _sqrt_A)) {364 else if (iLine == 2) { 365 if ( readDbl(line, pos[0], fieldLen, _Cuc) 366 || readDbl(line, pos[1], fieldLen, _e) 367 || readDbl(line, pos[2], fieldLen, _Cus) 368 || readDbl(line, pos[3], fieldLen, _sqrt_A)) { 381 369 _checkState = bad; 382 370 return; … … 386 374 // BROADCAST ORBIT - 3 387 375 // ===================== 388 else if ( iLine == 3 ) { 389 390 if (navType() == t_eph::CNAV || 391 navType() == t_eph::CNV2) { 392 if ( readDbl(line, pos[0], fieldLen, _top) || 393 readDbl(line, pos[1], fieldLen, _Cic ) || 394 readDbl(line, pos[2], fieldLen, _OMEGA0) || 395 readDbl(line, pos[3], fieldLen, _Cis ) ) { 396 _checkState = bad; 397 return; 398 } 399 } 400 else { // LNAV, undefined 401 if ( readDbl(line, pos[0], fieldLen, _TOEsec) || 402 readDbl(line, pos[1], fieldLen, _Cic ) || 403 readDbl(line, pos[2], fieldLen, _OMEGA0) || 404 readDbl(line, pos[3], fieldLen, _Cis ) ) { 376 else if (iLine == 3) { 377 if (ephType() == t_eph::CNAV || 378 ephType() == t_eph::CNV2) { 379 if ( readDbl(line, pos[0], fieldLen, _top) 380 || readDbl(line, pos[1], fieldLen, _Cic) 381 || readDbl(line, pos[2], fieldLen, _OMEGA0) 382 || readDbl(line, pos[3], fieldLen, _Cis)) { 383 _checkState = bad; 384 return; 385 } 386 } else if (ephType() == t_eph::L1NV) { 387 if ( readDbl(line, pos[0], fieldLen, _IODE) 388 || readDbl(line, pos[1], fieldLen, _Cic) 389 || readDbl(line, pos[2], fieldLen, _OMEGA0) 390 || readDbl(line, pos[3], fieldLen, _Cis)) { 391 _checkState = bad; 392 return; 393 } 394 } else { // LNAV, undefined 395 if ( readDbl(line, pos[0], fieldLen, _TOEsec) 396 || readDbl(line, pos[1], fieldLen, _Cic) 397 || readDbl(line, pos[2], fieldLen, _OMEGA0) 398 || readDbl(line, pos[3], fieldLen, _Cis)) { 405 399 _checkState = bad; 406 400 return; … … 411 405 // BROADCAST ORBIT - 4 412 406 // ===================== 413 else if ( iLine == 4) {414 if ( readDbl(line, pos[0], fieldLen, _i0 ) ||415 readDbl(line, pos[1], fieldLen, _Crc ) ||416 readDbl(line, pos[2], fieldLen, _omega ) ||417 readDbl(line, pos[3], fieldLen, _OMEGADOT)) {407 else if (iLine == 4) { 408 if ( readDbl(line, pos[0], fieldLen, _i0) 409 || readDbl(line, pos[1], fieldLen, _Crc) 410 || readDbl(line, pos[2], fieldLen, _omega) 411 || readDbl(line, pos[3], fieldLen, _OMEGADOT)) { 418 412 _checkState = bad; 419 413 return; … … 423 417 // BROADCAST ORBIT - 5 424 418 // ===================== 425 else if ( iLine == 5 && type() != t_eph::IRNSS) { 426 427 if (navType() == t_eph::CNAV || 428 navType() == t_eph::CNV2) { 429 if ( readDbl(line, pos[0], fieldLen, _IDOT ) || 430 readDbl(line, pos[1], fieldLen, _Delta_n_dot) || 431 readDbl(line, pos[2], fieldLen, _URAI_NED0 ) || 432 readDbl(line, pos[3], fieldLen, _URAI_NED1) ) { 419 else if (iLine == 5 && type() != t_eph::IRNSS) { 420 if (ephType() == t_eph::CNAV || 421 ephType() == t_eph::CNV2) { 422 if ( readDbl(line, pos[0], fieldLen, _IDOT) 423 || readDbl(line, pos[1], fieldLen, _Delta_n_dot) 424 || readDbl(line, pos[2], fieldLen, _URAI_NED0) 425 || readDbl(line, pos[3], fieldLen, _URAI_NED1)) { 433 426 _checkState = bad; 434 427 return; … … 436 429 } 437 430 else { // LNAV, undefined 438 if ( readDbl(line, pos[0], fieldLen, _IDOT ) || 439 readDbl(line, pos[1], fieldLen, _L2Codes) || 440 readDbl(line, pos[2], fieldLen, _TOEweek) || 441 readDbl(line, pos[3], fieldLen, _L2PFlag) ) { 442 _checkState = bad; 443 return; 444 } 445 } 446 } 447 else if ( iLine == 5 && type() == t_eph::IRNSS) { 448 if ( readDbl(line, pos[0], fieldLen, _IDOT ) || 449 readDbl(line, pos[2], fieldLen, _TOEweek) ) { 450 _checkState = bad; 451 return; 431 if ( readDbl(line, pos[0], fieldLen, _IDOT) 432 || readDbl(line, pos[1], fieldLen, _L2Codes) 433 || readDbl(line, pos[2], fieldLen, _TOEweek) 434 || readDbl(line, pos[3], fieldLen, _L2PFlag)) { 435 _checkState = bad; 436 return; 437 } 438 } 439 } else if (iLine == 5 && type() == t_eph::IRNSS) { 440 if (ephType() == t_eph::LNAV || 441 ephType() == t_eph::undefined) { 442 if ( readDbl(line, pos[0], fieldLen, _IDOT) 443 || readDbl(line, pos[2], fieldLen, _TOEweek)) { 444 _checkState = bad; 445 return; 446 } 447 } 448 else if (ephType() == t_eph::L1NV) { 449 if ( readDbl(line, pos[0], fieldLen, _IDOT) 450 || readDbl(line, pos[1], fieldLen, _Delta_n_dot) 451 || readDbl(line, pos[3], fieldLen, _RSF)) { 452 _checkState = bad; 453 return; 454 } 452 455 } 453 456 } … … 455 458 // BROADCAST ORBIT - 6 456 459 // ===================== 457 else if ( iLine == 6 && type() != t_eph::IRNSS) { 458 459 if (navType() == t_eph::CNAV || 460 navType() == t_eph::CNV2 ) { 461 if ( readDbl(line, pos[0], fieldLen, _URAI_ED) || 462 readDbl(line, pos[1], fieldLen, _health ) || 463 readDbl(line, pos[2], fieldLen, _TGD ) || 464 readDbl(line, pos[3], fieldLen, _URAI_NED2) ) { 465 _checkState = bad; 466 return; 467 } 468 } 469 else { // LNAV, undefined 470 if ( readDbl(line, pos[0], fieldLen, _ura ) || 471 readDbl(line, pos[1], fieldLen, _health) || 472 readDbl(line, pos[2], fieldLen, _TGD ) || 473 readDbl(line, pos[3], fieldLen, _IODC ) ) { 474 _checkState = bad; 475 return; 476 } 477 } 478 } 479 else if ( iLine == 6 && type() == t_eph::IRNSS) { 480 if ( readDbl(line, pos[0], fieldLen, _ura ) || 481 readDbl(line, pos[1], fieldLen, _health) || 482 readDbl(line, pos[2], fieldLen, _TGD ) ) { 483 _checkState = bad; 484 return; 460 else if (iLine == 6 && type() != t_eph::IRNSS) { 461 if (ephType() == t_eph::CNAV || 462 ephType() == t_eph::CNV2) { 463 if ( readDbl(line, pos[0], fieldLen, _URAI_ED) 464 || readDbl(line, pos[1], fieldLen, _health) 465 || readDbl(line, pos[2], fieldLen, _TGD) 466 || readDbl(line, pos[3], fieldLen, _URAI_NED2)) { 467 _checkState = bad; 468 return; 469 } 470 } else { // LNAV, undefined 471 if ( readDbl(line, pos[0], fieldLen, _ura) 472 || readDbl(line, pos[1], fieldLen, _health) 473 || readDbl(line, pos[2], fieldLen, _TGD) 474 || readDbl(line, pos[3], fieldLen, _IODC)) { 475 _checkState = bad; 476 return; 477 } 478 } 479 } 480 else if (iLine == 6 && type() == t_eph::IRNSS) { 481 if (ephType() == t_eph::LNAV || 482 ephType() == t_eph::undefined) { 483 if ( readDbl(line, pos[0], fieldLen, _ura) 484 || readDbl(line, pos[1], fieldLen, _health) 485 || readDbl(line, pos[2], fieldLen, _TGD)) { 486 _checkState = bad; 487 return; 488 } 489 } 490 else if (ephType() == t_eph::L1NV) { 491 int i = 0; 492 (!_RSF) ? i = 2 : i = 3; 493 if ( readDbl(line, pos[0], fieldLen, _URAI) 494 || readDbl(line, pos[1], fieldLen, _health) 495 || readDbl(line, pos[i], fieldLen, _TGD)) { 496 _checkState = bad; 497 return; 498 } 499 _ura = accuracyFromIndex(int(_URAI), type()); 485 500 } 486 501 } … … 488 503 // BROADCAST ORBIT - 7 489 504 // ===================== 490 else if ( iLine == 7 ) { 491 if (navType() == t_eph::LNAV || 492 navType() == t_eph::undefined) { 493 494 if ( readDbl(line, pos[0], fieldLen, _TOT) ) { 495 _checkState = bad; 496 return; 497 } 498 499 if (type() != t_eph::IRNSS) { 500 double fitIntervalRnx; 501 if ( readDbl(line, pos[1], fieldLen, fitIntervalRnx) ) { 505 else if (iLine == 7) { 506 if (ephType() == t_eph::LNAV || 507 ephType() == t_eph::undefined) { 508 if (readDbl(line, pos[0], fieldLen, _TOT)) { 509 _checkState = bad; 510 return; 511 if (type() != t_eph::IRNSS) { 512 double fitIntervalRnx; 513 if (readDbl(line, pos[1], fieldLen, fitIntervalRnx)) { 514 _checkState = bad; 515 return; 516 } 517 if (type() == t_eph::GPS) { // in RINEX specified always as time period for GPS 518 _fitInterval = fitIntervalRnx; 519 } 520 else if (type() == t_eph::QZSS) { // specified as flag for QZSS 521 if (rnxVersion == 3.02) { 522 _fitInterval = fitIntervalRnx; // specified as time period 523 } else { 524 _fitInterval = fitIntervalFromFlag(fitIntervalRnx, _IODC, t_eph::QZSS); 525 } 526 } 527 } 528 } 529 } 530 else if (ephType() == t_eph::CNAV || 531 ephType() == t_eph::CNV2) { 532 if ( readDbl(line, pos[0], fieldLen, _ISC_L1CA) 533 || readDbl(line, pos[1], fieldLen, _ISC_L2C) 534 || readDbl(line, pos[2], fieldLen, _ISC_L5I5) 535 || readDbl(line, pos[3], fieldLen, _ISC_L5Q5)) { 536 _checkState = bad; 537 return; 538 } 539 } 540 else if (ephType() == t_eph::L1NV) { 541 if (!_RSF) { 542 if ( readDbl(line, pos[0], fieldLen, _ISC_S) 543 || readDbl(line, pos[1], fieldLen, _ISC_L1D)) { 502 544 _checkState = bad; 503 545 return; 504 546 } 505 if (type() == t_eph::GPS) { // in RINEX specified always as time period for GPS 506 _fitInterval = fitIntervalRnx; 507 } else if (type() == t_eph::QZSS) { // specified as flag for QZSS 508 if (rnxVersion == 3.02) { 509 _fitInterval = fitIntervalRnx; // specified as time period 510 } 511 else { 512 _fitInterval = fitIntervalFromFlag(fitIntervalRnx, _IODC, t_eph::QZSS); 513 } 547 } else { 548 if ( readDbl(line, pos[2], fieldLen, _ISC_L1P) 549 || readDbl(line, pos[3], fieldLen, _ISC_L1D)) { 550 _checkState = bad; 551 return; 514 552 } 515 553 } 516 554 } 517 518 else if (navType() == t_eph::CNAV ||519 navType() == t_eph::CNV2) {520 if ( readDbl(line, pos[0], fieldLen, _ISC_L1CA) ||521 readDbl(line, pos[1], fieldLen, _ISC_L2C ) ||522 readDbl(line, pos[2], fieldLen, _ISC_L5I5) ||523 readDbl(line, pos[3], fieldLen, _ISC_L5Q5) ) {524 _checkState = bad;525 return;526 }527 }528 529 555 } 530 556 // ===================== 531 557 // BROADCAST ORBIT - 8 532 558 // ===================== 533 else if ( iLine == 8 ) { 534 if (navType() == t_eph::CNAV) { 535 if ( readDbl(line, pos[0], fieldLen, _TOT) || 536 readDbl(line, pos[1], fieldLen, _wnop) ) { 537 _checkState = bad; 538 return; 539 } 540 } 541 else if (navType() == t_eph::CNV2) { 542 if ( readDbl(line, pos[0], fieldLen, _ISC_L1Cd) || 543 readDbl(line, pos[1], fieldLen, _ISC_L1Cp)) { 559 else if (iLine == 8) { 560 if (ephType() == t_eph::CNAV) { 561 double intFlags = -1.0; // optional; blank if not provided 562 if ( readDbl(line, pos[0], fieldLen, _TOT) 563 || readDbl(line, pos[1], fieldLen, _wnop) 564 || readDbl(line, pos[2], fieldLen, intFlags)) { 565 _checkState = bad; 566 return; 567 } 568 if (intFlags > -1.0) { 569 // Bit 0: 570 _intSF = (int(intFlags) & (1 << 0)); 571 // Bit 1: 572 _L2Cphasing = (int(intFlags) & (1 << 1)); 573 // Bit 2: 574 _alert = (int(intFlags) & (1 << 2)); 575 } 576 } 577 else if (ephType() == t_eph::CNV2) { 578 if ( readDbl(line, pos[0], fieldLen, _ISC_L1Cd) 579 || readDbl(line, pos[1], fieldLen, _ISC_L1Cp)) { 580 _checkState = bad; 581 return; 582 } 583 } 584 else if (ephType() == t_eph::L1NV) { 585 if ( readDbl(line, pos[0], fieldLen, _TOT)) { 544 586 _checkState = bad; 545 587 return; … … 550 592 // BROADCAST ORBIT - 9 551 593 // ===================== 552 else if ( iLine == 9 ) { 553 if (navType() == t_eph::CNV2) { 554 if ( readDbl(line, pos[0], fieldLen, _TOT) || 555 readDbl(line, pos[1], fieldLen, _wnop) ) { 556 _checkState = bad; 557 return; 594 else if (iLine == 9) { 595 if (ephType() == t_eph::CNV2) { 596 double intFlags = -1.0; 597 if ( readDbl(line, pos[0], fieldLen, _TOT) 598 || readDbl(line, pos[1], fieldLen, _wnop) 599 || readDbl(line, pos[2], fieldLen, intFlags)) { 600 _checkState = bad; 601 return; 602 } 603 if (intFlags > -1.0) { 604 // Bit 0: 605 _intSF = (int(intFlags) & (1 << 0)); 606 if (type() == t_eph::QZSS) { 607 // Bit 1: 608 _ephSF = (int(intFlags) & (1 << 1)); 609 } 558 610 } 559 611 } … … 564 616 // Compute GPS Satellite Position (virtual) 565 617 //////////////////////////////////////////////////////////////////////////// 566 t_irc t_ephGPS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const { 618 t_irc t_ephGPS::position(int GPSweek, double GPSweeks, double *xc, 619 double *vv) const { 567 620 568 621 static const double omegaEarth = 7292115.1467e-11; 569 static const double gmGRS 570 571 memset(xc, 0, 6 *sizeof(double));572 memset(vv, 0, 3 *sizeof(double));622 static const double gmGRS = 398.6005e12; 623 624 memset(xc, 0, 6 * sizeof(double)); 625 memset(vv, 0, 3 * sizeof(double)); 573 626 574 627 double a0 = _sqrt_A * _sqrt_A; … … 577 630 } 578 631 579 double n0 = sqrt(gmGRS /(a0*a0*a0));632 double n0 = sqrt(gmGRS / (a0 * a0 * a0)); 580 633 581 634 bncTime tt(GPSweek, GPSweeks); 582 635 double tk = tt - bncTime(int(_TOEweek), _TOEsec); 583 636 584 double n 585 double M = _M0 + n*tk;586 double E 637 double n = n0 + _Delta_n; 638 double M = _M0 + n * tk; 639 double E = M; 587 640 double E_last; 588 int 641 int nLoop = 0; 589 642 do { 590 643 E_last = E; 591 E = M + _e *sin(E);644 E = M + _e * sin(E); 592 645 593 646 if (++nLoop == 100) { 594 647 return failure; 595 648 } 596 } while ( fabs(E-E_last)*a0 > 0.001); 597 double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) ); 598 double u0 = v + _omega; 599 double sin2u0 = sin(2*u0); 600 double cos2u0 = cos(2*u0); 601 double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0; 602 double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0; 603 double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0; 604 double xp = r*cos(u); 605 double yp = r*sin(u); 606 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk - 607 omegaEarth*_TOEsec; 649 } while (fabs(E - E_last) * a0 > 0.001); 650 double v = 2.0 * atan(sqrt((1.0 + _e) / (1.0 - _e)) * tan(E / 2)); 651 double u0 = v + _omega; 652 double sin2u0 = sin(2 * u0); 653 double cos2u0 = cos(2 * u0); 654 double r = a0 * (1 - _e * cos(E)) + _Crc * cos2u0 + _Crs * sin2u0; 655 double i = _i0 + _IDOT * tk + _Cic * cos2u0 + _Cis * sin2u0; 656 double u = u0 + _Cuc * cos2u0 + _Cus * sin2u0; 657 double xp = r * cos(u); 658 double yp = r * sin(u); 659 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth) * tk - omegaEarth * _TOEsec; 608 660 609 661 double sinom = sin(OM); 610 662 double cosom = cos(OM); 611 double sini 612 double cosi 613 xc[0] = xp *cosom - yp*cosi*sinom;614 xc[1] = xp *sinom + yp*cosi*cosom;615 xc[2] = yp *sini;663 double sini = sin(i); 664 double cosi = cos(i); 665 xc[0] = xp * cosom - yp * cosi * sinom; 666 xc[1] = xp * sinom + yp * cosi * cosom; 667 xc[2] = yp * sini; 616 668 617 669 double tc = tt - _TOC; 618 xc[3] = _clock_bias + _clock_drift *tc + _clock_driftrate*tc*tc;670 xc[3] = _clock_bias + _clock_drift * tc + _clock_driftrate * tc * tc; 619 671 620 672 // Velocity 621 673 // -------- 622 double tanv2 = tan(v /2);623 double dEdM = 1 / (1 - _e*cos(E));624 double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)625 626 double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;674 double tanv2 = tan(v / 2); 675 double dEdM = 1 / (1 - _e * cos(E)); 676 double dotv = sqrt((1.0 + _e) / (1.0 - _e)) / cos(E / 2) / cos(E / 2) 677 / (1 + tanv2 * tanv2) * dEdM * n; 678 double dotu = dotv + (-_Cuc * sin2u0 + _Cus * cos2u0) * 2 * dotv; 627 679 double dotom = _OMEGADOT - omegaEarth; 628 double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv; 629 double dotr = a0 * _e*sin(E) * dEdM * n 630 + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv; 631 double dotx = dotr*cos(u) - r*sin(u)*dotu; 632 double doty = dotr*sin(u) + r*cos(u)*dotu; 633 634 vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr 635 - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA 636 + yp*sini*sinom*doti; // dX / di 637 638 vv[1] = sinom *dotx + cosi*cosom *doty 639 + xp*cosom*dotom - yp*cosi*sinom*dotom 640 - yp*sini*cosom*doti; 641 642 vv[2] = sini *doty + yp*cosi *doti; 680 double doti = _IDOT + (-_Cic * sin2u0 + _Cis * cos2u0) * 2 * dotv; 681 double dotr = a0 * _e * sin(E) * dEdM * n 682 + (-_Crc * sin2u0 + _Crs * cos2u0) * 2 * dotv; 683 double dotx = dotr * cos(u) - r * sin(u) * dotu; 684 double doty = dotr * sin(u) + r * cos(u) * dotu; 685 686 vv[0] = cosom * dotx - cosi * sinom * doty // dX / dr 687 - xp * sinom * dotom - yp * cosi * cosom * dotom // dX / dOMEGA 688 + yp * sini * sinom * doti; // dX / di 689 690 vv[1] = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom 691 - yp * cosi * sinom * dotom - yp * sini * cosom * doti; 692 693 vv[2] = sini * doty + yp * cosi * doti; 643 694 644 695 // Relativistic Correction 645 696 // ----------------------- 646 xc[3] -= 4.442807633e-10 * _e * sqrt(a0) * sin(E);647 648 xc[4] = _clock_drift + _clock_driftrate *tc;697 xc[3] -= 4.442807633e-10 * _e * sqrt(a0) * sin(E); 698 699 xc[4] = _clock_drift + _clock_driftrate * tc; 649 700 xc[5] = _clock_driftrate; 650 701 … … 656 707 QString t_ephGPS::toString(double version) const { 657 708 658 QString navStr = navTypeString(_navType, _prn, version);659 QString rnxStr = navStr + rinexDateStr(_TOC, _prn, version);709 QString ephStr = ephTypeStr(_ephType, _prn, version); 710 QString rnxStr = ephStr + rinexDateStr(_TOC, _prn, version); 660 711 661 712 QTextStream out(&rnxStr); 662 713 663 out << QString("%1%2%3\n") 664 .arg(_clock_bias, 19, 'e', 12) 665 .arg(_clock_drift, 19, 'e', 12) 666 .arg(_clock_driftrate, 19, 'e', 12); 714 out 715 << QString("%1%2%3\n") 716 .arg(_clock_bias, 19, 'e', 12) 717 .arg(_clock_drift, 19, 'e', 12) 718 .arg(_clock_driftrate, 19, 'e', 12); 667 719 668 720 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n"; 669 721 670 671 722 // ===================== 672 723 // BROADCAST ORBIT - 1 673 724 // ===================== 674 if (navType() == t_eph::CNAV || 675 navType() == t_eph::CNV2) { 676 out << QString(fmt) 677 .arg(_ADOT, 19, 'e', 12) 678 .arg(_Crs, 19, 'e', 12) 679 .arg(_Delta_n, 19, 'e', 12) 680 .arg(_M0, 19, 'e', 12); 681 } 682 else { // LNAV, undefinded 683 out << QString(fmt) 684 .arg(_IODE, 19, 'e', 12) 685 .arg(_Crs, 19, 'e', 12) 686 .arg(_Delta_n, 19, 'e', 12) 687 .arg(_M0, 19, 'e', 12); 725 if (ephType() == t_eph::CNAV || 726 ephType() == t_eph::CNV2 || 727 ephType() == t_eph::L1NV) { 728 out 729 << QString(fmt) 730 .arg(_ADOT, 19, 'e', 12) 731 .arg(_Crs, 19, 'e', 12) 732 .arg(_Delta_n, 19, 'e', 12) 733 .arg(_M0, 19, 'e', 12); 734 } else { // LNAV, undefined 735 out 736 << QString(fmt) 737 .arg(_IODE, 19, 'e', 12) 738 .arg(_Crs, 19, 'e', 12) 739 .arg(_Delta_n, 19, 'e', 12) 740 .arg(_M0, 19, 'e', 12); 688 741 } 689 742 // ===================== 690 743 // BROADCAST ORBIT - 2 691 744 // ===================== 692 out << QString(fmt) 693 .arg(_Cuc, 19, 'e', 12) 694 .arg(_e, 19, 'e', 12) 695 .arg(_Cus, 19, 'e', 12) 696 .arg(_sqrt_A, 19, 'e', 12); 745 out 746 << QString(fmt) 747 .arg(_Cuc, 19, 'e', 12) 748 .arg(_e, 19, 'e', 12) 749 .arg(_Cus, 19, 'e', 12) 750 .arg(_sqrt_A, 19, 'e', 12); 697 751 // ===================== 698 752 // BROADCAST ORBIT - 3 699 753 // ===================== 700 if (navType() == t_eph::CNAV || 701 navType() == t_eph::CNV2) { 702 out << QString(fmt) 754 if (ephType() == t_eph::CNAV || 755 ephType() == t_eph::CNV2) { 756 out 757 << QString(fmt) 703 758 .arg(_top, 19, 'e', 12) 704 759 .arg(_Cic, 19, 'e', 12) … … 706 761 .arg(_Cis, 19, 'e', 12); 707 762 } 708 else { 709 out << QString(fmt) 763 else if (ephType() == t_eph::L1NV) { 764 out 765 << QString(fmt) 766 .arg(_IODE, 19, 'e', 12) 767 .arg(_Cic, 19, 'e', 12) 768 .arg(_OMEGA0, 19, 'e', 12) 769 .arg(_Cis, 19, 'e', 12); 770 } 771 else { // LNAV, undefined 772 out 773 << QString(fmt) 710 774 .arg(_TOEsec, 19, 'e', 12) 711 775 .arg(_Cic, 19, 'e', 12) … … 716 780 // BROADCAST ORBIT - 4 717 781 // ===================== 718 out << QString(fmt) 719 .arg(_i0, 19, 'e', 12) 720 .arg(_Crc, 19, 'e', 12) 721 .arg(_omega, 19, 'e', 12) 722 .arg(_OMEGADOT, 19, 'e', 12); 782 out 783 << QString(fmt) 784 .arg(_i0, 19, 'e', 12) 785 .arg(_Crc, 19, 'e', 12) 786 .arg(_omega, 19, 'e', 12) 787 .arg(_OMEGADOT, 19, 'e', 12); 723 788 // ===================== 724 789 // BROADCAST ORBIT - 5 725 790 // ===================== 726 if (type() == t_eph::IRNSS) { 727 out << QString(fmt) 791 if (type() != t_eph::IRNSS) { 792 if (ephType() == t_eph::CNAV || 793 ephType() == t_eph::CNV2) { 794 out 795 << QString(fmt) 796 .arg(_IDOT, 19, 'e', 12) 797 .arg(_Delta_n_dot, 19, 'e', 12) 798 .arg(_URAI_NED0, 19, 'e', 12) 799 .arg(_URAI_NED1, 19, 'e', 12); 800 } 801 else { // LNAV, undefined 802 out 803 << QString(fmt) 804 .arg(_IDOT, 19, 'e', 12) 805 .arg(_L2Codes, 19, 'e', 12) 806 .arg(_TOEweek, 19, 'e', 12) 807 .arg(_L2PFlag, 19, 'e', 12); 808 } 809 } 810 else { 811 if (ephType() == t_eph::LNAV || 812 ephType() == t_eph::undefined) { 813 out 814 << QString(fmt) 728 815 .arg(_IDOT, 19, 'e', 12) 729 .arg( 0.0, 19, 'e', 12)816 .arg("", 19, QChar(' ')) 730 817 .arg(_TOEweek, 19, 'e', 12) 731 .arg(0.0, 19, 'e', 12); 818 .arg("", 19, QChar(' ')); 819 } 820 else if (ephType() == t_eph::L1NV) { 821 out 822 << QString(fmt) 823 .arg(_IDOT, 19, 'e', 12) 824 .arg(_Delta_n_dot, 19, 'e', 12) 825 .arg("", 19, QChar(' ')) 826 .arg(_RSF, 19, 'e', 12); 827 } 828 } 829 // ===================== 830 // BROADCAST ORBIT - 6 831 // ===================== 832 if (type() != t_eph::IRNSS) { 833 if (ephType() == t_eph::CNAV || 834 ephType() == t_eph::CNV2) { 835 out 836 << QString(fmt) 837 .arg(_URAI_ED, 19, 'e', 12) 838 .arg(_health, 19, 'e', 12) 839 .arg(_TGD, 19, 'e', 12) 840 .arg(_URAI_NED2, 19, 'e', 12); 841 } 842 else { // LNAV, undefined 843 out 844 << QString(fmt) 845 .arg(_ura, 19, 'e', 12) 846 .arg(_health, 19, 'e', 12) 847 .arg(_TGD, 19, 'e', 12) 848 .arg(_IODC, 19, 'e', 12); 849 } 732 850 } 733 851 else { 734 if (navType() == t_eph::CNAV || 735 navType() == t_eph::CNV2) { 736 out << QString(fmt) 737 .arg(_IDOT, 19, 'e', 12) 738 .arg(_Delta_n_dot, 19, 'e', 12) 739 .arg(_URAI_NED0, 19, 'e', 12) 740 .arg(_URAI_NED1, 19, 'e', 12); 741 742 } 743 else { // LNAV, undefined 744 out << QString(fmt) 745 .arg(_IDOT, 19, 'e', 12) 746 .arg(_L2Codes, 19, 'e', 12) 747 .arg(_TOEweek, 19, 'e', 12) 748 .arg(_L2PFlag, 19, 'e', 12); 749 750 } 751 } 752 // ===================== 753 // BROADCAST ORBIT - 6 754 // ===================== 755 if (type() == t_eph::IRNSS) { 756 out << QString(fmt) 757 .arg(_ura, 19, 'e', 12) 758 .arg(_health, 19, 'e', 12) 759 .arg(_TGD, 19, 'e', 12) 760 .arg(0.0, 19, 'e', 12); 761 } 762 else { 763 if (navType() == t_eph::CNAV || 764 navType() == t_eph::CNV2) { 765 out << QString(fmt) 766 .arg(_URAI_ED, 19, 'e', 12) 767 .arg(_health, 19, 'e', 12) 768 .arg(_TGD, 19, 'e', 12) 769 .arg(_URAI_NED2,19, 'e', 12); 770 771 } 772 else { // LNAV, undefined 773 out << QString(fmt) 774 .arg(_ura, 19, 'e', 12) 775 .arg(_health, 19, 'e', 12) 776 .arg(_TGD, 19, 'e', 12) 777 .arg(_IODC, 19, 'e', 12); 852 if (ephType() == t_eph::LNAV || 853 ephType() == t_eph::undefined) { 854 out 855 << QString(fmt) 856 .arg(_ura, 19, 'e', 12) 857 .arg(_health, 19, 'e', 12) 858 .arg(_TGD, 19, 'e', 12); 859 } 860 else if (ephType() == t_eph::L1NV) { 861 int i = 0; (!_RSF) ? i = 2 : i = 3; 862 if (i == 2) { 863 out 864 << QString(fmt) 865 .arg(_URAI, 19, 'e', 12) 866 .arg(_health, 19, 'e', 12) 867 .arg(_TGD, 19, 'e', 12) 868 .arg("", 19, QChar(' ')); 869 } 870 else { 871 out 872 << QString(fmt) 873 .arg(_URAI, 19, 'e', 12) 874 .arg(_health, 19, 'e', 12) 875 .arg("", 19, QChar(' ')) 876 .arg(_TGD, 19, 'e', 12); 877 } 778 878 } 779 879 } … … 781 881 // BROADCAST ORBIT - 7 782 882 // ===================== 783 if (navType() == t_eph::LNAV || 784 navType() == t_eph::undefined) { 883 /* 884 out 885 << QString(fmt) 886 .arg(, 19, 'e', 12) 887 .arg(, 19, 'e', 12) 888 .arg(, 19, 'e', 12) 889 .arg(, 19, 'e', 12); 890 891 */ 892 893 if (ephType() == t_eph::LNAV || 894 ephType() == t_eph::undefined) { 785 895 786 896 double tot = _TOT; … … 789 899 } 790 900 // fitInterval 791 if (type() == t_eph::IRNSS) {// not valid for IRNSS 792 out << QString(fmt) 793 .arg(tot, 19, 'e', 12) 794 .arg(0.0, 19, 'e', 12) 795 .arg("", 19, QChar(' ')) 796 .arg("", 19, QChar(' ')); 901 if (type() == t_eph::IRNSS) { 902 out 903 << QString(fmt) 904 .arg(tot, 19, 'e', 12) 905 .arg("", 19, QChar(' ')) 906 .arg("", 19, QChar(' ')) 907 .arg("", 19, QChar(' ')); 797 908 } 798 909 else { … … 803 914 (_fitInterval == 2.0) ? fitIntervalRnx = 0.0 : fitIntervalRnx = 1.0; 804 915 } 805 out << QString(fmt) 806 .arg(tot, 19, 'e', 12) 807 .arg(fitIntervalRnx, 19, 'e', 12) 808 .arg("", 19, QChar(' ')) 809 .arg("", 19, QChar(' ')); 810 } 811 } 812 else if (navType() == t_eph::CNAV || 813 navType() == t_eph::CNV2) { 814 out << QString(fmt) 815 .arg(_ISC_L1CA, 19, 'e', 12) 816 .arg(_ISC_L2C, 19, 'e', 12) 817 .arg(_ISC_L5I5, 19, 'e', 12) 818 .arg(_ISC_L5Q5, 19, 'e', 12); 916 out 917 << QString(fmt) 918 .arg(tot, 19, 'e', 12) 919 .arg(fitIntervalRnx, 19, 'e', 12) 920 .arg("", 19, QChar(' ')) 921 .arg("", 19, QChar(' ')); 922 } 923 } 924 else if (ephType() == t_eph::CNAV || 925 ephType() == t_eph::CNV2) { 926 out 927 << QString(fmt) 928 .arg(_ISC_L1CA, 19, 'e', 12) 929 .arg(_ISC_L2C, 19, 'e', 12) 930 .arg(_ISC_L5I5, 19, 'e', 12) 931 .arg(_ISC_L5Q5, 19, 'e', 12); 932 } 933 else if (ephType() == t_eph::L1NV) { 934 if (_RSF) { 935 out 936 << QString(fmt) 937 .arg(_ISC_S, 19, 'e', 12) 938 .arg(_ISC_L1D, 19, 'e', 12) 939 .arg("", 19, QChar(' ')) 940 .arg("", 19, QChar(' ')); 941 } 942 else { 943 out 944 << QString(fmt) 945 .arg("", 19, QChar(' ')) 946 .arg("", 19, QChar(' ')) 947 .arg(_ISC_L1P, 19, 'e', 12) 948 .arg(_ISC_L1D, 19, 'e', 12); 949 } 819 950 } 820 951 // ===================== 821 952 // BROADCAST ORBIT - 8 822 953 // ===================== 823 if (navType() == t_eph::CNAV) { 824 out << QString(fmt) 825 .arg(_TOT, 19, 'e', 12) 826 .arg(_wnop, 19, 'e', 12) 827 .arg("", 19, QChar(' ')) 828 .arg("", 19, QChar(' ')); 829 } 830 else if (navType() == t_eph::CNV2) { 831 out << QString(fmt) 832 .arg(_ISC_L1Cd, 19, 'e', 12) 833 .arg(_ISC_L1Cp, 19, 'e', 12) 834 .arg("", 19, QChar(' ')) 835 .arg("", 19, QChar(' ')); 836 } 837 954 if (ephType() == t_eph::CNAV) { 955 double intFlags; 956 if (_intSF !=-1 ) { 957 intFlags |= (1 << 0); 958 intFlags |= (1 << 1); 959 intFlags |= (1 << 2); 960 out 961 << QString(fmt) 962 .arg(_TOT, 19, 'e', 12) 963 .arg(_wnop, 19, 'e', 12) 964 .arg(intFlags, 19, 'e', 12) 965 .arg("", 19, QChar(' ')); 966 } 967 else { 968 out 969 << QString(fmt) 970 .arg(_TOT, 19, 'e', 12) 971 .arg(_wnop, 19, 'e', 12) 972 .arg("", 19, QChar(' ')) 973 .arg("", 19, QChar(' ')); 974 } 975 } 976 else if (ephType() == t_eph::CNV2) { 977 out 978 << QString(fmt) 979 .arg(_ISC_L1Cd, 19, 'e', 12) 980 .arg(_ISC_L1Cp, 19, 'e', 12) 981 .arg("", 19, QChar(' ')) 982 .arg("", 19, QChar(' ')); 983 } 984 else if (ephType() == t_eph::L1NV) { 985 out 986 << QString(fmt) 987 .arg(_TOT, 19, 'e', 12) 988 .arg("", 19, QChar(' ')) 989 .arg("", 19, QChar(' ')) 990 .arg("", 19, QChar(' ')); 991 } 838 992 // ===================== 839 993 // BROADCAST ORBIT - 9 840 994 // ===================== 841 if (navType() == t_eph::CNV2) { 842 out << QString(fmt) 843 .arg(_TOT, 19, 'e', 12) 844 .arg(_wnop, 19, 'e', 12) 845 .arg("", 19, QChar(' ')) 846 .arg("", 19, QChar(' ')); 995 if (ephType() == t_eph::CNV2) { 996 double intFlags; 997 if (_intSF !=-1 ) { 998 intFlags |= (1 << 0); 999 out 1000 << QString(fmt) 1001 .arg(_TOT, 19, 'e', 12) 1002 .arg(_wnop, 19, 'e', 12) 1003 .arg(intFlags, 19, 'e', 12) 1004 .arg("", 19, QChar(' ')); 1005 } 1006 else { 1007 out 1008 << QString(fmt) 1009 .arg(_TOT, 19, 'e', 12) 1010 .arg(_wnop, 19, 'e', 12) 1011 .arg("", 19, QChar(' ')) 1012 .arg("", 19, QChar(' ')); 1013 } 847 1014 } 848 1015 … … 852 1019 // Constructor 853 1020 ////////////////////////////////////////////////////////////////////////////// 854 t_ephGlo::t_ephGlo(double rnxVersion, const QStringList &lines) {1021 t_ephGlo::t_ephGlo(double rnxVersion, const QStringList &lines) { 855 1022 856 1023 int nLines = 4; 857 1024 if (rnxVersion >= 3.05) { 858 1025 nLines += 1; 859 } 860 else { 1026 } else { 861 1027 _M_delta_tau = 0.9999e9; // unknown 862 1028 _M_FT = 1.5e1; // unknown … … 875 1041 876 1042 int pos[4]; 877 pos[0] = (rnxVersion <= 2.12) ? 3 :4;1043 pos[0] = (rnxVersion <= 2.12) ? 3 : 4; 878 1044 pos[1] = pos[0] + fieldLen; 879 1045 pos[2] = pos[1] + fieldLen; … … 885 1051 QString line = lines[iLine]; 886 1052 887 if ( iLine == 0) {1053 if (iLine == 0) { 888 1054 QTextStream in(line.left(pos[1]).toLatin1()); 889 1055 890 int 1056 int year, month, day, hour, min; 891 1057 double sec; 892 1058 … … 900 1066 if (prnStr.at(0) == 'R') { 901 1067 _prn.set('R', prnStr.mid(1).toInt()); 902 } 903 else { 1068 } else { 904 1069 _prn.set('R', prnStr.toInt()); 905 1070 } 906 1071 907 if (year <80) {1072 if (year < 80) { 908 1073 year += 2000; 909 } 910 else if (year < 100) { 1074 } else if (year < 100) { 911 1075 year += 1900; 912 1076 } … … 915 1079 916 1080 _TOC.set(year, month, day, hour, min, sec); 917 _TOC 918 int nd = int((_TOC.gpssec())) / (24.0 *60.0*60.0);919 if ( readDbl(line, pos[1], fieldLen, _tau ) ||920 readDbl(line, pos[2], fieldLen, _gamma) ||921 readDbl(line, pos[3], fieldLen, _tki )) {1081 _TOC = _TOC + _gps_utc; 1082 int nd = int((_TOC.gpssec())) / (24.0 * 60.0 * 60.0); 1083 if (readDbl(line, pos[1], fieldLen, _tau) 1084 || readDbl(line, pos[2], fieldLen, _gamma) 1085 || readDbl(line, pos[3], fieldLen, _tki)) { 922 1086 _checkState = bad; 923 1087 return; 924 1088 } 925 1089 _tki -= nd * 86400.0; 926 _tau 1090 _tau = -_tau; 927 1091 } 928 1092 // ===================== 929 1093 // BROADCAST ORBIT - 1 930 1094 // ===================== 931 else if ( iLine == 1) {932 if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||933 readDbl(line, pos[1], fieldLen, _x_velocity ) ||934 readDbl(line, pos[2], fieldLen, _x_acceleration) ||935 readDbl(line, pos[3], fieldLen, _health )) {1095 else if (iLine == 1) { 1096 if (readDbl(line, pos[0], fieldLen, _x_pos) 1097 || readDbl(line, pos[1], fieldLen, _x_velocity) 1098 || readDbl(line, pos[2], fieldLen, _x_acceleration) 1099 || readDbl(line, pos[3], fieldLen, _health)) { 936 1100 _checkState = bad; 937 1101 return; … … 941 1105 // BROADCAST ORBIT - 2 942 1106 // ===================== 943 else if ( iLine == 2) {944 if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||945 readDbl(line, pos[1], fieldLen, _y_velocity ) ||946 readDbl(line, pos[2], fieldLen, _y_acceleration ) ||947 readDbl(line, pos[3], fieldLen, _frequency_number)) {1107 else if (iLine == 2) { 1108 if (readDbl(line, pos[0], fieldLen, _y_pos) 1109 || readDbl(line, pos[1], fieldLen, _y_velocity) 1110 || readDbl(line, pos[2], fieldLen, _y_acceleration) 1111 || readDbl(line, pos[3], fieldLen, _frequency_number)) { 948 1112 _checkState = bad; 949 1113 return; … … 953 1117 // BROADCAST ORBIT - 3 954 1118 // ===================== 955 else if ( iLine == 3) {956 if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||957 readDbl(line, pos[1], fieldLen, _z_velocity ) ||958 readDbl(line, pos[2], fieldLen, _z_acceleration) ||959 readDbl(line, pos[3], fieldLen, _E )) {1119 else if (iLine == 3) { 1120 if (readDbl(line, pos[0], fieldLen, _z_pos) 1121 || readDbl(line, pos[1], fieldLen, _z_velocity) 1122 || readDbl(line, pos[2], fieldLen, _z_acceleration) 1123 || readDbl(line, pos[3], fieldLen, _E)) { 960 1124 _checkState = bad; 961 1125 return; … … 965 1129 // BROADCAST ORBIT - 4 966 1130 // ===================== 967 else if ( iLine == 4) {968 if (readDbl(line, pos[0], fieldLen, statusflags )) {1131 else if (iLine == 4) { 1132 if (readDbl(line, pos[0], fieldLen, statusflags)) { 969 1133 //statusflags BLK, do nothing 970 1134 _flags_unknown = true; 971 } 972 else { 1135 } else { 973 1136 _flags_unknown = false; 974 1137 // status flags 975 1138 // ============ 976 1139 // bit 0-1 977 _M_P 1140 _M_P = double(bitExtracted(statusflags, 2, 0)); 978 1141 // bit 2-3 979 _P1 1142 _P1 = double(bitExtracted(statusflags, 2, 2)); 980 1143 // bit 4 981 _P2 1144 _P2 = double(bitExtracted(statusflags, 1, 4)); 982 1145 // bit 5 983 _P3 1146 _P3 = double(bitExtracted(statusflags, 1, 5)); 984 1147 // bit 6 985 1148 _M_P4 = double(bitExtracted(statusflags, 1, 6)); 986 1149 // bit 7-8 987 _M_M 1150 _M_M = double(bitExtracted(statusflags, 2, 7)); 988 1151 /// GLO M/K exclusive flags/values only valid if flag M is set to '01' 989 1152 if (!_M_M) { 990 1153 _M_P4 = 0.0; 991 _M_P 992 } 993 } 994 if ( readDbl(line, pos[1], fieldLen, _M_delta_tau ) ||995 readDbl(line, pos[2], fieldLen, _M_FT )) {1154 _M_P = 0.0; 1155 } 1156 } 1157 if (readDbl(line, pos[1], fieldLen, _M_delta_tau) 1158 || readDbl(line, pos[2], fieldLen, _M_FT)) { 996 1159 _checkState = bad; 997 1160 return; 998 1161 } 999 if (readDbl(line, pos[3], fieldLen, healthflags )) {1162 if (readDbl(line, pos[3], fieldLen, healthflags)) { 1000 1163 // healthflags BLK 1001 1164 _flags_unknown = true; 1002 } 1003 else { 1165 } else { 1004 1166 _flags_unknown = false; 1005 1167 // health flags … … 1008 1170 _almanac_health = double(bitExtracted(healthflags, 1, 0)); 1009 1171 // bit 1 1010 _almanac_health_availablility_indicator = double(bitExtracted(healthflags, 1, 1)); 1172 _almanac_health_availablility_indicator = double( 1173 bitExtracted(healthflags, 1, 1)); 1011 1174 // bit 2 1012 1175 _M_l3 = double(bitExtracted(healthflags, 1, 2)); … … 1018 1181 // ------------------------ 1019 1182 _tt = _TOC; 1020 _xv.ReSize(6); _xv = 0.0; 1183 _xv.ReSize(6); 1184 _xv = 0.0; 1021 1185 _xv(1) = _x_pos * 1.e3; 1022 1186 _xv(2) = _y_pos * 1.e3; … … 1029 1193 // Compute Glonass Satellite Position (virtual) 1030 1194 //////////////////////////////////////////////////////////////////////////// 1031 t_irc t_ephGlo::position(int GPSweek, double GPSweeks, double* xc, double* vv) const { 1195 t_irc t_ephGlo::position(int GPSweek, double GPSweeks, double *xc, 1196 double *vv) const { 1032 1197 1033 1198 static const double nominalStep = 10.0; 1034 1199 1035 memset(xc, 0, 6 *sizeof(double));1036 memset(vv, 0, 3 *sizeof(double));1200 memset(xc, 0, 6 * sizeof(double)); 1201 memset(vv, 0, 3 * sizeof(double)); 1037 1202 1038 1203 double dtPos = bncTime(GPSweek, GPSweeks) - _tt; … … 1042 1207 } 1043 1208 1044 int nSteps 1209 int nSteps = int(fabs(dtPos) / nominalStep) + 1; 1045 1210 double step = dtPos / nSteps; 1046 1211 … … 1080 1245 QString t_ephGlo::toString(double version) const { 1081 1246 1082 QString navStr = navTypeString(_navType, _prn, version);1083 QString rnxStr = navStr + rinexDateStr(_TOC -_gps_utc, _prn, version);1084 int nd = int((_TOC - _gps_utc).gpssec()) / (24.0 *60.0*60.0);1247 QString ephStr = ephTypeStr(_ephType, _prn, version); 1248 QString rnxStr = ephStr + rinexDateStr(_TOC - _gps_utc, _prn, version); 1249 int nd = int((_TOC - _gps_utc).gpssec()) / (24.0 * 60.0 * 60.0); 1085 1250 QTextStream out(&rnxStr); 1086 1251 1087 out << QString("%1%2%3\n") 1088 .arg(-_tau, 19, 'e', 12) 1089 .arg(_gamma, 19, 'e', 12) 1090 .arg(_tki+nd*86400.0, 19, 'e', 12); 1252 out 1253 << QString("%1%2%3\n").arg(-_tau, 19, 'e', 12).arg(_gamma, 19, 'e', 12).arg( 1254 _tki + nd * 86400.0, 19, 'e', 12); 1091 1255 1092 1256 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n"; … … 1094 1258 // BROADCAST ORBIT - 1 1095 1259 // ===================== 1096 out << QString(fmt) 1097 .arg(_x_pos, 19, 'e', 12) 1098 .arg(_x_velocity, 19, 'e', 12) 1099 .arg(_x_acceleration, 19, 'e', 12) 1100 .arg(_health, 19, 'e', 12); 1260 out 1261 << QString(fmt).arg(_x_pos, 19, 'e', 12).arg(_x_velocity, 19, 'e', 12).arg( 1262 _x_acceleration, 19, 'e', 12).arg(_health, 19, 'e', 12); 1101 1263 // ===================== 1102 1264 // BROADCAST ORBIT - 2 1103 1265 // ===================== 1104 out << QString(fmt) 1105 .arg(_y_pos, 19, 'e', 12) 1106 .arg(_y_velocity, 19, 'e', 12) 1107 .arg(_y_acceleration, 19, 'e', 12) 1108 .arg(_frequency_number, 19, 'e', 12); 1266 out 1267 << QString(fmt).arg(_y_pos, 19, 'e', 12).arg(_y_velocity, 19, 'e', 12).arg( 1268 _y_acceleration, 19, 'e', 12).arg(_frequency_number, 19, 'e', 12); 1109 1269 // ===================== 1110 1270 // BROADCAST ORBIT - 3 1111 1271 // ===================== 1112 out << QString(fmt) 1113 .arg(_z_pos, 19, 'e', 12) 1114 .arg(_z_velocity, 19, 'e', 12) 1115 .arg(_z_acceleration, 19, 'e', 12) 1116 .arg(_E, 19, 'e', 12); 1272 out 1273 << QString(fmt).arg(_z_pos, 19, 'e', 12).arg(_z_velocity, 19, 'e', 12).arg( 1274 _z_acceleration, 19, 'e', 12).arg(_E, 19, 'e', 12); 1117 1275 // ===================== 1118 1276 // BROADCAST ORBIT - 4 … … 1121 1279 // unknown (RINEX version < 3.05) 1122 1280 if (_flags_unknown) { 1123 out << QString(fmt) 1124 .arg("", 19, QChar(' ')) // statusflags blank if unknown 1125 .arg(_M_delta_tau, 19, 'e', 12) 1126 .arg(_M_FT, 19, 'e', 12) 1127 .arg("", 19, QChar(' ')); // healthflags blank if unknown 1128 } 1129 else { 1281 out 1282 << QString(fmt).arg("", 19, QChar(' ')) // statusflags blank if unknown 1283 .arg(_M_delta_tau, 19, 'e', 12).arg(_M_FT, 19, 'e', 12).arg("", 19, 1284 QChar(' ')); // healthflags blank if unknown 1285 } else { 1130 1286 int statusflags = 0; 1131 1287 // bit 7-8 1132 1288 if (_M_M == 2.0) { 1133 statusflags |= (1 <<7);1289 statusflags |= (1 << 7); 1134 1290 } 1135 1291 // bit 6 1136 1292 if (_M_P4) { 1137 statusflags |= (1 <<6);1293 statusflags |= (1 << 6); 1138 1294 } 1139 1295 // bit 5 1140 1296 if (_P3) { 1141 statusflags |= (1 <<5);1297 statusflags |= (1 << 5); 1142 1298 } 1143 1299 // bit 4 1144 1300 if (_P2) { 1145 statusflags |= (1 <<4);1301 statusflags |= (1 << 4); 1146 1302 } 1147 1303 // bit 2-3 1148 if (_P1 == 2.0) { 1149 statusflags |= (1<<2); 1150 } 1151 else if (_P1 == 1.0) { 1152 statusflags |= (1<<3); 1153 } 1154 else if (_P1 == 3.0) { 1155 statusflags |= (1<<2); 1156 statusflags |= (1<<3); 1304 if (_P1 == 2.0) { 1305 statusflags |= (1 << 2); 1306 } else if (_P1 == 1.0) { 1307 statusflags |= (1 << 3); 1308 } else if (_P1 == 3.0) { 1309 statusflags |= (1 << 2); 1310 statusflags |= (1 << 3); 1157 1311 } 1158 1312 // bit 0-1 1159 if (_M_P == 2.0) { 1160 statusflags |= (1<<0); 1161 } 1162 else if (_M_P == 1.0) { 1163 statusflags |= (1<<1); 1164 } 1165 else if (_M_P == 3.0) { 1166 statusflags |= (1<<0); 1167 statusflags |= (1<<1); 1313 if (_M_P == 2.0) { 1314 statusflags |= (1 << 0); 1315 } else if (_M_P == 1.0) { 1316 statusflags |= (1 << 1); 1317 } else if (_M_P == 3.0) { 1318 statusflags |= (1 << 0); 1319 statusflags |= (1 << 1); 1168 1320 } 1169 1321 // health flags … … 1172 1324 // bit 0 (is to be ignored, if bit 1 is zero) 1173 1325 if (_almanac_health) { 1174 healthflags |= (1 <<0);1326 healthflags |= (1 << 0); 1175 1327 } 1176 1328 // bit 1 1177 1329 if (_almanac_health_availablility_indicator) { 1178 healthflags |= (1 <<1);1330 healthflags |= (1 << 1); 1179 1331 } 1180 1332 // bit 2 1181 1333 if (_M_l3) { 1182 healthflags |= (1<<2); 1183 } 1184 out << QString(fmt) 1185 .arg(double(statusflags), 19, 'e', 12) 1186 .arg(_M_delta_tau, 19, 'e', 12) 1187 .arg(_M_FT, 19, 'e', 12) 1188 .arg(double(healthflags), 19, 'e', 12); 1334 healthflags |= (1 << 2); 1335 } 1336 out 1337 << QString(fmt).arg(double(statusflags), 19, 'e', 12).arg( 1338 _M_delta_tau, 19, 'e', 12).arg(_M_FT, 19, 'e', 12).arg( 1339 double(healthflags), 19, 'e', 12); 1189 1340 } 1190 1341 } … … 1195 1346 // Derivative of the state vector using a simple force model (static) 1196 1347 //////////////////////////////////////////////////////////////////////////// 1197 ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector &xv,1198 double*acc) {1348 ColumnVector t_ephGlo::glo_deriv(double /* tt */, const ColumnVector &xv, 1349 double *acc) { 1199 1350 1200 1351 // State vector components 1201 1352 // ----------------------- 1202 ColumnVector rr = xv.rows(1, 3);1203 ColumnVector vv = xv.rows(4, 6);1353 ColumnVector rr = xv.rows(1, 3); 1354 ColumnVector vv = xv.rows(4, 6); 1204 1355 1205 1356 // Acceleration 1206 1357 // ------------ 1207 1358 static const double gmWGS = 398.60044e12; 1208 static const double AE 1359 static const double AE = 6378136.0; 1209 1360 static const double OMEGA = 7292115.e-11; 1210 static const double C20 1361 static const double C20 = -1082.6257e-6; 1211 1362 1212 1363 double rho = rr.NormFrobenius(); 1213 double t1 = -gmWGS/(rho*rho*rho); 1214 double t2 = 3.0/2.0 * C20 * (gmWGS*AE*AE) / (rho*rho*rho*rho*rho); 1215 double t3 = OMEGA * OMEGA; 1216 double t4 = 2.0 * OMEGA; 1217 double z2 = rr(3) * rr(3); 1364 double t1 = -gmWGS / (rho * rho * rho); 1365 double t2 = 3.0 / 2.0 * C20 * (gmWGS * AE * AE) 1366 / (rho * rho * rho * rho * rho); 1367 double t3 = OMEGA * OMEGA; 1368 double t4 = 2.0 * OMEGA; 1369 double z2 = rr(3) * rr(3); 1218 1370 1219 1371 // Vector of derivatives … … 1223 1375 va(2) = vv(2); 1224 1376 va(3) = vv(3); 1225 va(4) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(1) + t4*vv(2) + acc[0]; 1226 va(5) = (t1 + t2*(1.0-5.0*z2/(rho*rho)) + t3) * rr(2) - t4*vv(1) + acc[1]; 1227 va(6) = (t1 + t2*(3.0-5.0*z2/(rho*rho)) ) * rr(3) + acc[2]; 1377 va(4) = (t1 + t2 * (1.0 - 5.0 * z2 / (rho * rho)) + t3) * rr(1) + t4 * vv(2) 1378 + acc[0]; 1379 va(5) = (t1 + t2 * (1.0 - 5.0 * z2 / (rho * rho)) + t3) * rr(2) - t4 * vv(1) 1380 + acc[1]; 1381 va(6) = (t1 + t2 * (3.0 - 5.0 * z2 / (rho * rho))) * rr(3) + acc[2]; 1228 1382 1229 1383 return va; … … 1234 1388 unsigned int t_ephGlo::IOD() const { 1235 1389 bncTime tMoscow = _TOC - _gps_utc + 3 * 3600.0; 1236 return (unsigned long) tMoscow.daysec() / 900;1390 return (unsigned long) tMoscow.daysec() / 900; 1237 1391 } 1238 1392 … … 1242 1396 1243 1397 if (_almanac_health_availablility_indicator) { 1244 if ((_health == 0 && _almanac_health == 0) || 1245 (_health == 1 && _almanac_health == 0) || 1246 (_health == 1 && _almanac_health == 1)) { 1247 return 1; 1248 } 1249 } 1250 else if (!_almanac_health_availablility_indicator) { 1398 if ((_health == 0 && _almanac_health == 0) 1399 || (_health == 1 && _almanac_health == 0) 1400 || (_health == 1 && _almanac_health == 1)) { 1401 return 1; 1402 } 1403 } else if (!_almanac_health_availablility_indicator) { 1251 1404 if (_health) { 1252 1405 return 1; … … 1258 1411 // Constructor 1259 1412 ////////////////////////////////////////////////////////////////////////////// 1260 t_ephGal::t_ephGal(double rnxVersion, const QStringList &lines) {1261 int 1262 double 1263 QString 1413 t_ephGal::t_ephGal(double rnxVersion, const QStringList &lines) { 1414 int year, month, day, hour, min; 1415 double sec; 1416 QString prnStr; 1264 1417 const int nLines = 8; 1265 1418 if (lines.size() != nLines) { … … 1275 1428 1276 1429 int pos[4]; 1277 pos[0] = (rnxVersion <= 2.12) ? 3 :4;1430 pos[0] = (rnxVersion <= 2.12) ? 3 : 4; 1278 1431 pos[1] = pos[0] + fieldLen; 1279 1432 pos[2] = pos[1] + fieldLen; … … 1285 1438 QString line = lines[iLine]; 1286 1439 1287 if ( iLine == 0) {1440 if (iLine == 0) { 1288 1441 QTextStream in(line.left(pos[1]).toLatin1()); 1289 1442 QString n; … … 1294 1447 } 1295 1448 in >> year >> month >> day >> hour >> min >> sec; 1296 if (year <80) {1449 if (year < 80) { 1297 1450 year += 2000; 1298 } 1299 else if (year < 100) { 1451 } else if (year < 100) { 1300 1452 year += 1900; 1301 1453 } … … 1303 1455 _TOC.set(year, month, day, hour, min, sec); 1304 1456 1305 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||1306 readDbl(line, pos[2], fieldLen, _clock_drift ) ||1307 readDbl(line, pos[3], fieldLen, _clock_driftrate)) {1457 if (readDbl(line, pos[1], fieldLen, _clock_bias) 1458 || readDbl(line, pos[2], fieldLen, _clock_drift) 1459 || readDbl(line, pos[3], fieldLen, _clock_driftrate)) { 1308 1460 _checkState = bad; 1309 1461 return; … … 1313 1465 // BROADCAST ORBIT - 1 1314 1466 // ===================== 1315 else if ( iLine == 1) {1316 if ( readDbl(line, pos[0], fieldLen, _IODnav ) ||1317 readDbl(line, pos[1], fieldLen, _Crs ) ||1318 readDbl(line, pos[2], fieldLen, _Delta_n) ||1319 readDbl(line, pos[3], fieldLen, _M0 )) {1467 else if (iLine == 1) { 1468 if (readDbl(line, pos[0], fieldLen, _IODnav) 1469 || readDbl(line, pos[1], fieldLen, _Crs) 1470 || readDbl(line, pos[2], fieldLen, _Delta_n) 1471 || readDbl(line, pos[3], fieldLen, _M0)) { 1320 1472 _checkState = bad; 1321 1473 return; … … 1325 1477 // BROADCAST ORBIT - 2 1326 1478 // ===================== 1327 else if ( iLine == 2) {1328 if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||1329 readDbl(line, pos[1], fieldLen, _e ) ||1330 readDbl(line, pos[2], fieldLen, _Cus ) ||1331 readDbl(line, pos[3], fieldLen, _sqrt_A)) {1479 else if (iLine == 2) { 1480 if (readDbl(line, pos[0], fieldLen, _Cuc) 1481 || readDbl(line, pos[1], fieldLen, _e) 1482 || readDbl(line, pos[2], fieldLen, _Cus) 1483 || readDbl(line, pos[3], fieldLen, _sqrt_A)) { 1332 1484 _checkState = bad; 1333 1485 return; … … 1337 1489 // BROADCAST ORBIT - 3 1338 1490 // ===================== 1339 else if ( iLine == 3) {1340 if ( readDbl(line, pos[0], fieldLen, _TOEsec) ||1341 readDbl(line, pos[1], fieldLen, _Cic ) ||1342 readDbl(line, pos[2], fieldLen, _OMEGA0) ||1343 readDbl(line, pos[3], fieldLen, _Cis )) {1491 else if (iLine == 3) { 1492 if (readDbl(line, pos[0], fieldLen, _TOEsec) 1493 || readDbl(line, pos[1], fieldLen, _Cic) 1494 || readDbl(line, pos[2], fieldLen, _OMEGA0) 1495 || readDbl(line, pos[3], fieldLen, _Cis)) { 1344 1496 _checkState = bad; 1345 1497 return; … … 1349 1501 // BROADCAST ORBIT - 4 1350 1502 // ===================== 1351 else if ( iLine == 4) {1352 if ( readDbl(line, pos[0], fieldLen, _i0 ) ||1353 readDbl(line, pos[1], fieldLen, _Crc ) ||1354 readDbl(line, pos[2], fieldLen, _omega ) ||1355 readDbl(line, pos[3], fieldLen, _OMEGADOT)) {1503 else if (iLine == 4) { 1504 if (readDbl(line, pos[0], fieldLen, _i0) 1505 || readDbl(line, pos[1], fieldLen, _Crc) 1506 || readDbl(line, pos[2], fieldLen, _omega) 1507 || readDbl(line, pos[3], fieldLen, _OMEGADOT)) { 1356 1508 _checkState = bad; 1357 1509 return; … … 1361 1513 // BROADCAST ORBIT - 5 1362 1514 // ===================== 1363 else if ( iLine == 5) {1364 if ( readDbl(line, pos[0], fieldLen, _IDOT ) ||1365 readDbl(line, pos[1], fieldLen, datasource) ||1366 readDbl(line, pos[2], fieldLen, _TOEweek )) {1515 else if (iLine == 5) { 1516 if (readDbl(line, pos[0], fieldLen, _IDOT) 1517 || readDbl(line, pos[1], fieldLen, datasource) 1518 || readDbl(line, pos[2], fieldLen, _TOEweek)) { 1367 1519 _checkState = bad; 1368 1520 return; 1369 1521 } else { 1370 if (int(datasource) & (1<<8)) {1522 if (int(datasource) & (1 << 8)) { 1371 1523 _fnav = true; 1372 1524 _inav = false; 1373 } else if (int(datasource) & (1 <<9)) {1525 } else if (int(datasource) & (1 << 9)) { 1374 1526 _fnav = false; 1375 1527 _inav = true; … … 1381 1533 // BROADCAST ORBIT - 6 1382 1534 // ===================== 1383 else if ( iLine == 6) {1384 if ( readDbl(line, pos[0], fieldLen, _SISA ) ||1385 readDbl(line, pos[1], fieldLen, SVhealth) ||1386 readDbl(line, pos[2], fieldLen, _BGD_1_5A) ||1387 readDbl(line, pos[3], fieldLen, _BGD_1_5B)) {1535 else if (iLine == 6) { 1536 if (readDbl(line, pos[0], fieldLen, _SISA) 1537 || readDbl(line, pos[1], fieldLen, SVhealth) 1538 || readDbl(line, pos[2], fieldLen, _BGD_1_5A) 1539 || readDbl(line, pos[3], fieldLen, _BGD_1_5B)) { 1388 1540 _checkState = bad; 1389 1541 return; 1390 1542 } else { 1391 1543 // Bit 0 1392 _e1DataInValid = (int(SVhealth) & (1<<0));1544 _e1DataInValid = (int(SVhealth) & (1 << 0)); 1393 1545 // Bit 1-2 1394 _E1_bHS 1546 _E1_bHS = double((int(SVhealth) >> 1) & 0x3); 1395 1547 // Bit 3 1396 _e5aDataInValid = (int(SVhealth) & (1 <<3));1548 _e5aDataInValid = (int(SVhealth) & (1 << 3)); 1397 1549 // Bit 4-5 1398 _E5aHS 1550 _E5aHS = double((int(SVhealth) >> 4) & 0x3); 1399 1551 // Bit 6 1400 _e5bDataInValid = (int(SVhealth) & (1 <<6));1552 _e5bDataInValid = (int(SVhealth) & (1 << 6)); 1401 1553 // Bit 7-8 1402 _E5bHS 1554 _E5bHS = double((int(SVhealth) >> 7) & 0x3); 1403 1555 1404 1556 if (prnStr.at(0) == 'E') { … … 1410 1562 // BROADCAST ORBIT - 7 1411 1563 // ===================== 1412 else if ( iLine == 7) {1413 if ( readDbl(line, pos[0], fieldLen, _TOT)) {1564 else if (iLine == 7) { 1565 if (readDbl(line, pos[0], fieldLen, _TOT)) { 1414 1566 _checkState = bad; 1415 1567 return; … … 1421 1573 // Compute Galileo Satellite Position (virtual) 1422 1574 //////////////////////////////////////////////////////////////////////////// 1423 t_irc t_ephGal::position(int GPSweek, double GPSweeks, double* xc, double* vv) const { 1575 t_irc t_ephGal::position(int GPSweek, double GPSweeks, double *xc, 1576 double *vv) const { 1424 1577 1425 1578 static const double omegaEarth = 7292115.1467e-11; 1426 1579 static const double gmWGS = 398.6004418e12; 1427 1580 1428 memset(xc, 0, 6 *sizeof(double));1429 memset(vv, 0, 3 *sizeof(double));1581 memset(xc, 0, 6 * sizeof(double)); 1582 memset(vv, 0, 3 * sizeof(double)); 1430 1583 1431 1584 double a0 = _sqrt_A * _sqrt_A; … … 1434 1587 } 1435 1588 1436 double n0 = sqrt(gmWGS /(a0*a0*a0));1589 double n0 = sqrt(gmWGS / (a0 * a0 * a0)); 1437 1590 1438 1591 bncTime tt(GPSweek, GPSweeks); 1439 1592 double tk = tt - bncTime(_TOC.gpsw(), _TOEsec); 1440 1593 1441 double n 1442 double M = _M0 + n*tk;1443 double E 1594 double n = n0 + _Delta_n; 1595 double M = _M0 + n * tk; 1596 double E = M; 1444 1597 double E_last; 1445 int 1598 int nLoop = 0; 1446 1599 do { 1447 1600 E_last = E; 1448 E = M + _e *sin(E);1601 E = M + _e * sin(E); 1449 1602 1450 1603 if (++nLoop == 100) { 1451 1604 return failure; 1452 1605 } 1453 } while ( fabs(E-E_last)*a0 > 0.001 ); 1454 double v = 2.0*atan( sqrt( (1.0 + _e)/(1.0 - _e) )*tan( E/2 ) ); 1455 double u0 = v + _omega; 1456 double sin2u0 = sin(2*u0); 1457 double cos2u0 = cos(2*u0); 1458 double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0; 1459 double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0; 1460 double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0; 1461 double xp = r*cos(u); 1462 double yp = r*sin(u); 1463 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth)*tk - 1464 omegaEarth*_TOEsec; 1606 } while (fabs(E - E_last) * a0 > 0.001); 1607 double v = 2.0 * atan(sqrt((1.0 + _e) / (1.0 - _e)) * tan(E / 2)); 1608 double u0 = v + _omega; 1609 double sin2u0 = sin(2 * u0); 1610 double cos2u0 = cos(2 * u0); 1611 double r = a0 * (1 - _e * cos(E)) + _Crc * cos2u0 + _Crs * sin2u0; 1612 double i = _i0 + _IDOT * tk + _Cic * cos2u0 + _Cis * sin2u0; 1613 double u = u0 + _Cuc * cos2u0 + _Cus * sin2u0; 1614 double xp = r * cos(u); 1615 double yp = r * sin(u); 1616 double OM = _OMEGA0 + (_OMEGADOT - omegaEarth) * tk - omegaEarth * _TOEsec; 1465 1617 1466 1618 double sinom = sin(OM); 1467 1619 double cosom = cos(OM); 1468 double sini 1469 double cosi 1470 xc[0] = xp *cosom - yp*cosi*sinom;1471 xc[1] = xp *sinom + yp*cosi*cosom;1472 xc[2] = yp *sini;1620 double sini = sin(i); 1621 double cosi = cos(i); 1622 xc[0] = xp * cosom - yp * cosi * sinom; 1623 xc[1] = xp * sinom + yp * cosi * cosom; 1624 xc[2] = yp * sini; 1473 1625 1474 1626 double tc = tt - _TOC; 1475 xc[3] = _clock_bias + _clock_drift *tc + _clock_driftrate*tc*tc;1627 xc[3] = _clock_bias + _clock_drift * tc + _clock_driftrate * tc * tc; 1476 1628 1477 1629 // Velocity 1478 1630 // -------- 1479 double tanv2 = tan(v /2);1480 double dEdM = 1 / (1 - _e*cos(E));1481 double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2) / (1 + tanv2*tanv2)1482 1483 double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;1631 double tanv2 = tan(v / 2); 1632 double dEdM = 1 / (1 - _e * cos(E)); 1633 double dotv = sqrt((1.0 + _e) / (1.0 - _e)) / cos(E / 2) / cos(E / 2) 1634 / (1 + tanv2 * tanv2) * dEdM * n; 1635 double dotu = dotv + (-_Cuc * sin2u0 + _Cus * cos2u0) * 2 * dotv; 1484 1636 double dotom = _OMEGADOT - omegaEarth; 1485 double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv; 1486 double dotr = a0 * _e*sin(E) * dEdM * n 1487 + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv; 1488 double dotx = dotr*cos(u) - r*sin(u)*dotu; 1489 double doty = dotr*sin(u) + r*cos(u)*dotu; 1490 1491 vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr 1492 - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA 1493 + yp*sini*sinom*doti; // dX / di 1494 1495 vv[1] = sinom *dotx + cosi*cosom *doty 1496 + xp*cosom*dotom - yp*cosi*sinom*dotom 1497 - yp*sini*cosom*doti; 1498 1499 vv[2] = sini *doty + yp*cosi *doti; 1637 double doti = _IDOT + (-_Cic * sin2u0 + _Cis * cos2u0) * 2 * dotv; 1638 double dotr = a0 * _e * sin(E) * dEdM * n 1639 + (-_Crc * sin2u0 + _Crs * cos2u0) * 2 * dotv; 1640 double dotx = dotr * cos(u) - r * sin(u) * dotu; 1641 double doty = dotr * sin(u) + r * cos(u) * dotu; 1642 1643 vv[0] = cosom * dotx - cosi * sinom * doty // dX / dr 1644 - xp * sinom * dotom - yp * cosi * cosom * dotom // dX / dOMEGA 1645 + yp * sini * sinom * doti; // dX / di 1646 1647 vv[1] = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom 1648 - yp * cosi * sinom * dotom - yp * sini * cosom * doti; 1649 1650 vv[2] = sini * doty + yp * cosi * doti; 1500 1651 1501 1652 // Relativistic Correction 1502 1653 // ----------------------- 1503 xc[3] -= 4.442807309e-10 * _e * sqrt(a0) * sin(E);1504 1505 xc[4] = _clock_drift + _clock_driftrate *tc;1654 xc[3] -= 4.442807309e-10 * _e * sqrt(a0) * sin(E); 1655 1656 xc[4] = _clock_drift + _clock_driftrate * tc; 1506 1657 xc[5] = _clock_driftrate; 1507 1658 … … 1512 1663 //////////////////////////////////////////////////////////////////////////// 1513 1664 unsigned int t_ephGal::isUnhealthy() const { 1514 if (_E5aHS == 1 || _E5aHS == 3 || 1515 _E5bHS == 1 || _E5bHS == 3 || 1516 _E1_bHS == 1 || _E1_bHS == 3 ) { 1665 if (_E5aHS == 1 || _E5aHS == 3 || _E5bHS == 1 || _E5bHS == 3 || _E1_bHS == 1 1666 || _E1_bHS == 3) { 1517 1667 return 1; 1518 1668 } 1519 if (_e5aDataInValid || 1520 _e5bDataInValid || 1521 _e1DataInValid) { 1669 if (_e5aDataInValid || _e5bDataInValid || _e1DataInValid) { 1522 1670 return 1; 1523 1671 } … … 1528 1676 * SDD v1.3: SHS=2 leads to a newly-defined "EOM" status. 1529 1677 * It also means that the satellite signal may be used for PNT. 1530 if (_E5aHS == 2 ||1531 1532 1533 1534 }1535 */1678 if (_E5aHS == 2 || 1679 _E5bHS == 2 || 1680 _E1_bHS == 2 ) { 1681 return 1; 1682 } 1683 */ 1536 1684 return 0; 1537 1685 } … … 1541 1689 QString t_ephGal::toString(double version) const { 1542 1690 1543 QString navStr = navTypeString(_navType, _prn, version);1544 QString rnxStr = navStr + rinexDateStr(_TOC, _prn, version);1691 QString ephStr = ephTypeStr(_ephType, _prn, version); 1692 QString rnxStr = ephStr + rinexDateStr(_TOC, _prn, version); 1545 1693 1546 1694 QTextStream out(&rnxStr); 1547 1695 1548 out << QString("%1%2%3\n") 1549 .arg(_clock_bias, 19, 'e', 12) 1550 .arg(_clock_drift, 19, 'e', 12) 1551 .arg(_clock_driftrate, 19, 'e', 12); 1696 out 1697 << QString("%1%2%3\n").arg(_clock_bias, 19, 'e', 12).arg(_clock_drift, 19, 1698 'e', 12).arg(_clock_driftrate, 19, 'e', 12); 1552 1699 1553 1700 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n"; … … 1555 1702 // BROADCAST ORBIT - 1 1556 1703 // ===================== 1557 out << QString(fmt) 1558 .arg(_IODnav, 19, 'e', 12) 1559 .arg(_Crs, 19, 'e', 12) 1560 .arg(_Delta_n, 19, 'e', 12) 1561 .arg(_M0, 19, 'e', 12); 1704 out 1705 << QString(fmt).arg(_IODnav, 19, 'e', 12).arg(_Crs, 19, 'e', 12).arg( 1706 _Delta_n, 19, 'e', 12).arg(_M0, 19, 'e', 12); 1562 1707 // ===================== 1563 1708 // BROADCAST ORBIT - 2 1564 1709 // ===================== 1565 out << QString(fmt) 1566 .arg(_Cuc, 19, 'e', 12) 1567 .arg(_e, 19, 'e', 12) 1568 .arg(_Cus, 19, 'e', 12) 1569 .arg(_sqrt_A, 19, 'e', 12); 1710 out 1711 << QString(fmt).arg(_Cuc, 19, 'e', 12).arg(_e, 19, 'e', 12).arg(_Cus, 19, 1712 'e', 12).arg(_sqrt_A, 19, 'e', 12); 1570 1713 // ===================== 1571 1714 // BROADCAST ORBIT - 3 1572 1715 // ===================== 1573 out << QString(fmt) 1574 .arg(_TOEsec, 19, 'e', 12) 1575 .arg(_Cic, 19, 'e', 12) 1576 .arg(_OMEGA0, 19, 'e', 12) 1577 .arg(_Cis, 19, 'e', 12); 1716 out 1717 << QString(fmt).arg(_TOEsec, 19, 'e', 12).arg(_Cic, 19, 'e', 12).arg( 1718 _OMEGA0, 19, 'e', 12).arg(_Cis, 19, 'e', 12); 1578 1719 // ===================== 1579 1720 // BROADCAST ORBIT - 4 1580 1721 // ===================== 1581 out << QString(fmt) 1582 .arg(_i0, 19, 'e', 12) 1583 .arg(_Crc, 19, 'e', 12) 1584 .arg(_omega, 19, 'e', 12) 1585 .arg(_OMEGADOT, 19, 'e', 12); 1722 out 1723 << QString(fmt).arg(_i0, 19, 'e', 12).arg(_Crc, 19, 'e', 12).arg(_omega, 1724 19, 'e', 12).arg(_OMEGADOT, 19, 'e', 12); 1586 1725 // ===================== 1587 1726 // BROADCAST ORBIT - 5 1588 1727 // ===================== 1589 int 1590 int SVhealth= 0;1591 double BGD_1_5A 1592 double BGD_1_5B 1728 int dataSource = 0; 1729 int SVhealth = 0; 1730 double BGD_1_5A = _BGD_1_5A; 1731 double BGD_1_5B = _BGD_1_5B; 1593 1732 if (_fnav) { 1594 dataSource |= (1 <<1);1595 dataSource |= (1 <<8);1733 dataSource |= (1 << 1); 1734 dataSource |= (1 << 8); 1596 1735 BGD_1_5B = 0.0; 1597 1736 // SVhealth 1598 1737 // Bit 3 : E5a DVS 1599 1738 if (_e5aDataInValid) { 1600 SVhealth |= (1 <<3);1739 SVhealth |= (1 << 3); 1601 1740 } 1602 1741 // Bit 4-5: E5a HS 1603 1742 if (_E5aHS == 1.0) { 1604 SVhealth |= (1<<4); 1605 } 1606 else if (_E5aHS == 2.0) { 1607 SVhealth |= (1<<5); 1608 } 1609 else if (_E5aHS == 3.0) { 1610 SVhealth |= (1<<4); 1611 SVhealth |= (1<<5); 1612 } 1613 } 1614 else if(_inav) { 1743 SVhealth |= (1 << 4); 1744 } else if (_E5aHS == 2.0) { 1745 SVhealth |= (1 << 5); 1746 } else if (_E5aHS == 3.0) { 1747 SVhealth |= (1 << 4); 1748 SVhealth |= (1 << 5); 1749 } 1750 } else if (_inav) { 1615 1751 // Bit 2 and 0 are set because from MT1046 the data source cannot be determined 1616 1752 // and RNXv3.03 says both can be set if the navigation messages were merged 1617 dataSource |= (1 <<0);1618 dataSource |= (1 <<2);1619 dataSource |= (1 <<9);1753 dataSource |= (1 << 0); 1754 dataSource |= (1 << 2); 1755 dataSource |= (1 << 9); 1620 1756 // SVhealth 1621 1757 // Bit 0 : E1-B DVS 1622 1758 if (_e1DataInValid) { 1623 SVhealth |= (1 <<0);1759 SVhealth |= (1 << 0); 1624 1760 } 1625 1761 // Bit 1-2: E1-B HS 1626 if (_E1_bHS == 1.0) { 1627 SVhealth |= (1<<1); 1628 } 1629 else if (_E1_bHS == 2.0) { 1630 SVhealth |= (1<<2); 1631 } 1632 else if (_E1_bHS == 3.0) { 1633 SVhealth |= (1<<1); 1634 SVhealth |= (1<<2); 1762 if (_E1_bHS == 1.0) { 1763 SVhealth |= (1 << 1); 1764 } else if (_E1_bHS == 2.0) { 1765 SVhealth |= (1 << 2); 1766 } else if (_E1_bHS == 3.0) { 1767 SVhealth |= (1 << 1); 1768 SVhealth |= (1 << 2); 1635 1769 } 1636 1770 // Bit 3 : E5a DVS 1637 1771 if (_e5aDataInValid) { 1638 SVhealth |= (1 <<3);1772 SVhealth |= (1 << 3); 1639 1773 } 1640 1774 // Bit 4-5: E5a HS 1641 if (_E5aHS == 1.0) { 1642 SVhealth |= (1<<4); 1643 } 1644 else if (_E5aHS == 2.0) { 1645 SVhealth |= (1<<5); 1646 } 1647 else if (_E5aHS == 3.0) { 1648 SVhealth |= (1<<4); 1649 SVhealth |= (1<<5); 1775 if (_E5aHS == 1.0) { 1776 SVhealth |= (1 << 4); 1777 } else if (_E5aHS == 2.0) { 1778 SVhealth |= (1 << 5); 1779 } else if (_E5aHS == 3.0) { 1780 SVhealth |= (1 << 4); 1781 SVhealth |= (1 << 5); 1650 1782 } 1651 1783 // Bit 6 : E5b DVS 1652 1784 if (_e5bDataInValid) { 1653 SVhealth |= (1 <<6);1785 SVhealth |= (1 << 6); 1654 1786 } 1655 1787 // Bit 7-8: E5b HS 1656 if (_E5bHS == 1.0) { 1657 SVhealth |= (1<<7); 1658 } 1659 else if (_E5bHS == 2.0) { 1660 SVhealth |= (1<<8); 1661 } 1662 else if (_E5bHS == 3.0) { 1663 SVhealth |= (1<<7); 1664 SVhealth |= (1<<8); 1665 } 1666 } 1667 1668 out << QString(fmt) 1669 .arg(_IDOT, 19, 'e', 12) 1670 .arg(double(dataSource), 19, 'e', 12) 1671 .arg(_TOEweek + 1024.0, 19, 'e', 12) 1672 .arg(0.0, 19, 'e', 12); 1788 if (_E5bHS == 1.0) { 1789 SVhealth |= (1 << 7); 1790 } else if (_E5bHS == 2.0) { 1791 SVhealth |= (1 << 8); 1792 } else if (_E5bHS == 3.0) { 1793 SVhealth |= (1 << 7); 1794 SVhealth |= (1 << 8); 1795 } 1796 } 1797 1798 out 1799 << QString(fmt).arg(_IDOT, 19, 'e', 12).arg(double(dataSource), 19, 'e', 1800 12).arg(_TOEweek + 1024.0, 19, 'e', 12).arg(0.0, 19, 'e', 12); 1673 1801 // ===================== 1674 1802 // BROADCAST ORBIT - 6 1675 1803 // ===================== 1676 out << QString(fmt) 1677 .arg(_SISA, 19, 'e', 12) 1678 .arg(double(SVhealth), 19, 'e', 12) 1679 .arg(BGD_1_5A, 19, 'e', 12) 1680 .arg(BGD_1_5B, 19, 'e', 12); 1804 out 1805 << QString(fmt).arg(_SISA, 19, 'e', 12).arg(double(SVhealth), 19, 'e', 12).arg( 1806 BGD_1_5A, 19, 'e', 12).arg(BGD_1_5B, 19, 'e', 12); 1681 1807 // ===================== 1682 1808 // BROADCAST ORBIT - 7 … … 1686 1812 tot = 0.0; 1687 1813 } 1688 out << QString(fmt) 1689 .arg(tot, 19, 'e', 12) 1690 .arg("", 19, QChar(' ')) 1691 .arg("", 19, QChar(' ')) 1692 .arg("", 19, QChar(' ')); 1814 out 1815 << QString(fmt).arg(tot, 19, 'e', 12).arg("", 19, QChar(' ')).arg("", 19, 1816 QChar(' ')).arg("", 19, QChar(' ')); 1693 1817 1694 1818 return rnxStr; … … 1697 1821 // Constructor 1698 1822 ////////////////////////////////////////////////////////////////////////////// 1699 t_ephSBAS::t_ephSBAS(double rnxVersion, const QStringList &lines) {1823 t_ephSBAS::t_ephSBAS(double rnxVersion, const QStringList &lines) { 1700 1824 1701 1825 const int nLines = 4; … … 1711 1835 1712 1836 int pos[4]; 1713 pos[0] = (rnxVersion <= 2.12) ? 3 :4;1837 pos[0] = (rnxVersion <= 2.12) ? 3 : 4; 1714 1838 pos[1] = pos[0] + fieldLen; 1715 1839 pos[2] = pos[1] + fieldLen; … … 1721 1845 QString line = lines[iLine]; 1722 1846 1723 if ( iLine == 0) {1847 if (iLine == 0) { 1724 1848 QTextStream in(line.left(pos[1]).toLatin1()); 1725 1849 1726 int 1850 int year, month, day, hour, min; 1727 1851 double sec; 1728 1852 … … 1736 1860 if (prnStr.at(0) == 'S') { 1737 1861 _prn.set('S', prnStr.mid(1).toInt()); 1738 } 1739 else { 1862 } else { 1740 1863 _prn.set('S', prnStr.toInt()); 1741 1864 } 1742 1865 1743 if (year <80) {1866 if (year < 80) { 1744 1867 year += 2000; 1745 } 1746 else if (year < 100) { 1868 } else if (year < 100) { 1747 1869 year += 1900; 1748 1870 } … … 1750 1872 _TOC.set(year, month, day, hour, min, sec); 1751 1873 1752 if ( readDbl(line, pos[1], fieldLen, _agf0 ) ||1753 readDbl(line, pos[2], fieldLen, _agf1 ) ||1754 readDbl(line, pos[3], fieldLen, _TOT )) {1874 if (readDbl(line, pos[1], fieldLen, _agf0) 1875 || readDbl(line, pos[2], fieldLen, _agf1) 1876 || readDbl(line, pos[3], fieldLen, _TOT)) { 1755 1877 _checkState = bad; 1756 1878 return; … … 1760 1882 // BROADCAST ORBIT - 1 1761 1883 // ===================== 1762 else if ( iLine == 1) {1763 if ( readDbl(line, pos[0], fieldLen, _x_pos ) ||1764 readDbl(line, pos[1], fieldLen, _x_velocity ) ||1765 readDbl(line, pos[2], fieldLen, _x_acceleration) ||1766 readDbl(line, pos[3], fieldLen, _health )) {1884 else if (iLine == 1) { 1885 if (readDbl(line, pos[0], fieldLen, _x_pos) 1886 || readDbl(line, pos[1], fieldLen, _x_velocity) 1887 || readDbl(line, pos[2], fieldLen, _x_acceleration) 1888 || readDbl(line, pos[3], fieldLen, _health)) { 1767 1889 _checkState = bad; 1768 1890 return; … … 1772 1894 // BROADCAST ORBIT - 2 1773 1895 // ===================== 1774 else if ( iLine == 2) {1775 if ( readDbl(line, pos[0], fieldLen, _y_pos ) ||1776 readDbl(line, pos[1], fieldLen, _y_velocity ) ||1777 readDbl(line, pos[2], fieldLen, _y_acceleration ) ||1778 readDbl(line, pos[3], fieldLen, _ura )) {1896 else if (iLine == 2) { 1897 if (readDbl(line, pos[0], fieldLen, _y_pos) 1898 || readDbl(line, pos[1], fieldLen, _y_velocity) 1899 || readDbl(line, pos[2], fieldLen, _y_acceleration) 1900 || readDbl(line, pos[3], fieldLen, _ura)) { 1779 1901 _checkState = bad; 1780 1902 return; … … 1784 1906 // BROADCAST ORBIT - 3 1785 1907 // ===================== 1786 else if ( iLine == 3) {1908 else if (iLine == 3) { 1787 1909 double iodn; 1788 if ( readDbl(line, pos[0], fieldLen, _z_pos ) ||1789 readDbl(line, pos[1], fieldLen, _z_velocity ) ||1790 readDbl(line, pos[2], fieldLen, _z_acceleration) ||1791 readDbl(line, pos[3], fieldLen, iodn )) {1910 if (readDbl(line, pos[0], fieldLen, _z_pos) 1911 || readDbl(line, pos[1], fieldLen, _z_velocity) 1912 || readDbl(line, pos[2], fieldLen, _z_acceleration) 1913 || readDbl(line, pos[3], fieldLen, iodn)) { 1792 1914 _checkState = bad; 1793 1915 return; … … 1798 1920 } 1799 1921 1800 _x_pos 1801 _y_pos 1802 _z_pos 1803 _x_velocity 1804 _y_velocity 1805 _z_velocity 1922 _x_pos *= 1.e3; 1923 _y_pos *= 1.e3; 1924 _z_pos *= 1.e3; 1925 _x_velocity *= 1.e3; 1926 _y_velocity *= 1.e3; 1927 _z_velocity *= 1.e3; 1806 1928 _x_acceleration *= 1.e3; 1807 1929 _y_acceleration *= 1.e3; … … 1828 1950 SBASADDBITSFLOAT(10, this->_y_acceleration, 0.0000125) 1829 1951 SBASADDBITSFLOAT(10, this->_z_acceleration, 0.0000625) 1830 SBASADDBITSFLOAT(12, this->_agf0, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<1)) 1831 SBASADDBITSFLOAT(8, this->_agf1, 1.0/static_cast<double>(1<<30)/static_cast<double>(1<<10)) 1832 SBASADDBITS(5,0); // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8 1952 SBASADDBITSFLOAT(12, this->_agf0, 1953 1.0 / static_cast<double>(1 << 30) / static_cast<double>(1 << 1)) 1954 SBASADDBITSFLOAT(8, this->_agf1, 1955 1.0 / static_cast<double>(1 << 30) / static_cast<double>(1 << 10)) 1956 SBASADDBITS(5, 0); // the last byte is filled by 0-bits to obtain a length of an integer multiple of 8 1833 1957 1834 1958 return CRC24(size, startbuffer); … … 1837 1961 // Compute SBAS Satellite Position (virtual) 1838 1962 //////////////////////////////////////////////////////////////////////////// 1839 t_irc t_ephSBAS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const { 1963 t_irc t_ephSBAS::position(int GPSweek, double GPSweeks, double *xc, 1964 double *vv) const { 1840 1965 1841 1966 bncTime tt(GPSweek, GPSweeks); 1842 double 1967 double dt = tt - _TOC; 1843 1968 1844 1969 xc[0] = _x_pos + _x_velocity * dt + _x_acceleration * dt * dt / 2.0; … … 1863 1988 1864 1989 // Bit 5 1865 bool URAindexIs15 = (int(_health) & (1 <<5));1990 bool URAindexIs15 = (int(_health) & (1 << 5)); 1866 1991 if (URAindexIs15) { 1867 1992 // in this case it is recommended … … 1871 1996 1872 1997 // Bit 0-3 1873 int 1998 int MT17health = (int(_health)) & (0x0f); 1874 1999 if (MT17health) { 1875 2000 return 1; … … 1883 2008 } 1884 2009 1885 1886 2010 // RINEX Format String 1887 2011 ////////////////////////////////////////////////////////////////////////////// 1888 2012 QString t_ephSBAS::toString(double version) const { 1889 2013 1890 QString navStr = navTypeString(_navType, _prn, version);1891 QString rnxStr = navStr + rinexDateStr(_TOC, _prn, version);2014 QString ephStr = ephTypeStr(_ephType, _prn, version); 2015 QString rnxStr = ephStr + rinexDateStr(_TOC, _prn, version); 1892 2016 1893 2017 QTextStream out(&rnxStr); 1894 2018 1895 out << QString("%1%2%3\n") 1896 .arg(_agf0, 19, 'e', 12) 1897 .arg(_agf1, 19, 'e', 12) 1898 .arg(_TOT, 19, 'e', 12); 2019 out 2020 << QString("%1%2%3\n").arg(_agf0, 19, 'e', 12).arg(_agf1, 19, 'e', 12).arg( 2021 _TOT, 19, 'e', 12); 1899 2022 1900 2023 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n"; … … 1902 2025 // BROADCAST ORBIT - 1 1903 2026 // ===================== 1904 out << QString(fmt) 1905 .arg(1.e-3*_x_pos, 19, 'e', 12) 1906 .arg(1.e-3*_x_velocity, 19, 'e', 12) 1907 .arg(1.e-3*_x_acceleration, 19, 'e', 12) 1908 .arg(_health, 19, 'e', 12); 2027 out 2028 << QString(fmt).arg(1.e-3 * _x_pos, 19, 'e', 12).arg(1.e-3 * _x_velocity, 2029 19, 'e', 12).arg(1.e-3 * _x_acceleration, 19, 'e', 12).arg(_health, 2030 19, 'e', 12); 1909 2031 // ===================== 1910 2032 // BROADCAST ORBIT - 2 1911 2033 // ===================== 1912 out << QString(fmt) 1913 .arg(1.e-3*_y_pos, 19, 'e', 12) 1914 .arg(1.e-3*_y_velocity, 19, 'e', 12) 1915 .arg(1.e-3*_y_acceleration, 19, 'e', 12) 1916 .arg(_ura, 19, 'e', 12); 2034 out 2035 << QString(fmt).arg(1.e-3 * _y_pos, 19, 'e', 12).arg(1.e-3 * _y_velocity, 2036 19, 'e', 12).arg(1.e-3 * _y_acceleration, 19, 'e', 12).arg(_ura, 19, 2037 'e', 12); 1917 2038 // ===================== 1918 2039 // BROADCAST ORBIT - 3 1919 2040 // ===================== 1920 out << QString(fmt) 1921 .arg(1.e-3*_z_pos, 19, 'e', 12) 1922 .arg(1.e-3*_z_velocity, 19, 'e', 12) 1923 .arg(1.e-3*_z_acceleration, 19, 'e', 12) 1924 .arg(double(_IODN), 19, 'e', 12); 2041 out 2042 << QString(fmt).arg(1.e-3 * _z_pos, 19, 'e', 12).arg(1.e-3 * _z_velocity, 2043 19, 'e', 12).arg(1.e-3 * _z_acceleration, 19, 'e', 12).arg( 2044 double(_IODN), 19, 'e', 12); 1925 2045 1926 2046 return rnxStr; … … 1929 2049 // Constructor 1930 2050 ////////////////////////////////////////////////////////////////////////////// 1931 t_ephBDS::t_ephBDS(double rnxVersion, const QStringList &lines) {2051 t_ephBDS::t_ephBDS(double rnxVersion, const QStringList &lines) { 1932 2052 1933 2053 int nLines = 8; 1934 2054 1935 if (navType() == t_eph::CNV1 || 1936 navType() == t_eph::CNV2) { 2055 if (ephType() == t_eph::CNV1 || ephType() == t_eph::CNV2) { 1937 2056 nLines += 2; 1938 2057 } 1939 if ( navType() == t_eph::CNV3) {2058 if (ephType() == t_eph::CNV3) { 1940 2059 nLines += 1; 1941 2060 } … … 1951 2070 1952 2071 int pos[4]; 1953 pos[0] = (rnxVersion <= 2.12) ? 3 :4;2072 pos[0] = (rnxVersion <= 2.12) ? 3 : 4; 1954 2073 pos[1] = pos[0] + fieldLen; 1955 2074 pos[2] = pos[1] + fieldLen; … … 1961 2080 QString line = lines[iLine]; 1962 2081 1963 if ( iLine == 0) {2082 if (iLine == 0) { 1964 2083 QTextStream in(line.left(pos[1]).toLatin1()); 1965 2084 1966 int 2085 int year, month, day, hour, min; 1967 2086 double sec; 1968 2087 … … 1976 2095 if (prnStr.at(0) == 'C') { 1977 2096 _prn.set('C', prnStr.mid(1).toInt()); 1978 } 1979 else { 2097 } else { 1980 2098 _prn.set('C', prnStr.toInt()); 1981 2099 } 1982 2100 1983 if (year <80) {2101 if (year < 80) { 1984 2102 year += 2000; 1985 } 1986 else if (year < 100) { 2103 } else if (year < 100) { 1987 2104 year += 1900; 1988 2105 } … … 1990 2107 _TOC.setBDS(year, month, day, hour, min, sec); 1991 2108 1992 if ( readDbl(line, pos[1], fieldLen, _clock_bias ) ||1993 readDbl(line, pos[2], fieldLen, _clock_drift ) ||1994 readDbl(line, pos[3], fieldLen, _clock_driftrate)) {2109 if (readDbl(line, pos[1], fieldLen, _clock_bias) 2110 || readDbl(line, pos[2], fieldLen, _clock_drift) 2111 || readDbl(line, pos[3], fieldLen, _clock_driftrate)) { 1995 2112 _checkState = bad; 1996 2113 return; … … 2000 2117 // BROADCAST ORBIT - 1 2001 2118 // ===================== 2002 else if ( iLine == 1) {2119 else if (iLine == 1) { 2003 2120 double aode; 2004 if ( readDbl(line, pos[0], fieldLen, aode ) ||2005 readDbl(line, pos[1], fieldLen, _Crs ) ||2006 readDbl(line, pos[2], fieldLen, _Delta_n) ||2007 readDbl(line, pos[3], fieldLen, _M0 )) {2121 if (readDbl(line, pos[0], fieldLen, aode) 2122 || readDbl(line, pos[1], fieldLen, _Crs) 2123 || readDbl(line, pos[2], fieldLen, _Delta_n) 2124 || readDbl(line, pos[3], fieldLen, _M0)) { 2008 2125 _checkState = bad; 2009 2126 return; … … 2014 2131 // BROADCAST ORBIT - 2 2015 2132 // ===================== 2016 else if ( iLine == 2) {2017 if ( readDbl(line, pos[0], fieldLen, _Cuc ) ||2018 readDbl(line, pos[1], fieldLen, _e ) ||2019 readDbl(line, pos[2], fieldLen, _Cus ) ||2020 readDbl(line, pos[3], fieldLen, _sqrt_A)) {2133 else if (iLine == 2) { 2134 if (readDbl(line, pos[0], fieldLen, _Cuc) 2135 || readDbl(line, pos[1], fieldLen, _e) 2136 || readDbl(line, pos[2], fieldLen, _Cus) 2137 || readDbl(line, pos[3], fieldLen, _sqrt_A)) { 2021 2138 _checkState = bad; 2022 2139 return; … … 2026 2143 // BROADCAST ORBIT - 3 2027 2144 // ===================== 2028 else if ( iLine == 3) {2029 if ( readDbl(line, pos[0], fieldLen, _TOEsec ) ||2030 readDbl(line, pos[1], fieldLen, _Cic ) ||2031 readDbl(line, pos[2], fieldLen, _OMEGA0) ||2032 readDbl(line, pos[3], fieldLen, _Cis )) {2145 else if (iLine == 3) { 2146 if (readDbl(line, pos[0], fieldLen, _TOEsec) 2147 || readDbl(line, pos[1], fieldLen, _Cic) 2148 || readDbl(line, pos[2], fieldLen, _OMEGA0) 2149 || readDbl(line, pos[3], fieldLen, _Cis)) { 2033 2150 _checkState = bad; 2034 2151 return; … … 2038 2155 // BROADCAST ORBIT - 4 2039 2156 // ===================== 2040 else if ( iLine == 4) {2041 if ( readDbl(line, pos[0], fieldLen, _i0 ) ||2042 readDbl(line, pos[1], fieldLen, _Crc ) ||2043 readDbl(line, pos[2], fieldLen, _omega ) ||2044 readDbl(line, pos[3], fieldLen, _OMEGADOT)) {2157 else if (iLine == 4) { 2158 if (readDbl(line, pos[0], fieldLen, _i0) 2159 || readDbl(line, pos[1], fieldLen, _Crc) 2160 || readDbl(line, pos[2], fieldLen, _omega) 2161 || readDbl(line, pos[3], fieldLen, _OMEGADOT)) { 2045 2162 _checkState = bad; 2046 2163 return; … … 2050 2167 // BROADCAST ORBIT - 5 2051 2168 // ===================== 2052 else if ( iLine == 5 ) { 2053 2054 if (navType() == t_eph::CNV1 || 2055 navType() == t_eph::CNV2 || 2056 navType() == t_eph::CNV3 ) { 2057 if ( readDbl(line, pos[0], fieldLen, _IDOT ) || 2058 readDbl(line, pos[1], fieldLen, _Delta_n_dot) || 2059 readDbl(line, pos[2], fieldLen, _satType ) || 2060 readDbl(line, pos[3], fieldLen, _top ) ) { 2061 _checkState = bad; 2062 return; 2063 } 2064 } 2065 else { // D1, D2, undefined 2066 if ( readDbl(line, pos[0], fieldLen, _IDOT ) || 2067 readDbl(line, pos[2], fieldLen, _BDTweek)) { 2169 else if (iLine == 5) { 2170 2171 if (ephType() == t_eph::CNV1 || ephType() == t_eph::CNV2 2172 || ephType() == t_eph::CNV3) { 2173 if (readDbl(line, pos[0], fieldLen, _IDOT) 2174 || readDbl(line, pos[1], fieldLen, _Delta_n_dot) 2175 || readDbl(line, pos[2], fieldLen, _satType) 2176 || readDbl(line, pos[3], fieldLen, _top)) { 2177 _checkState = bad; 2178 return; 2179 } 2180 } else { // D1, D2, undefined 2181 if (readDbl(line, pos[0], fieldLen, _IDOT) 2182 || readDbl(line, pos[2], fieldLen, _BDTweek)) { 2068 2183 _checkState = bad; 2069 2184 return; … … 2074 2189 // BROADCAST ORBIT - 6 2075 2190 // ===================== 2076 else if ( iLine == 6 ) { 2077 if (navType() == t_eph::CNV1 || 2078 navType() == t_eph::CNV2 || 2079 navType() == t_eph::CNV3 ) { 2080 if ( readDbl(line, pos[0], fieldLen, _SISAI_oe ) || 2081 readDbl(line, pos[1], fieldLen, _SISAI_ocb ) || 2082 readDbl(line, pos[2], fieldLen, _SISAI_oc1 ) || 2083 readDbl(line, pos[3], fieldLen, _SISAI_oc2 ) ) { 2084 _checkState = bad; 2085 return; 2086 } 2087 } 2088 else { // D1, D2, undefined 2191 else if (iLine == 6) { 2192 if (ephType() == t_eph::CNV1 || ephType() == t_eph::CNV2 2193 || ephType() == t_eph::CNV3) { 2194 if (readDbl(line, pos[0], fieldLen, _SISAI_oe) 2195 || readDbl(line, pos[1], fieldLen, _SISAI_ocb) 2196 || readDbl(line, pos[2], fieldLen, _SISAI_oc1) 2197 || readDbl(line, pos[3], fieldLen, _SISAI_oc2)) { 2198 _checkState = bad; 2199 return; 2200 } 2201 } else { // D1, D2, undefined 2089 2202 double SatH1; 2090 if ( readDbl(line, pos[0], fieldLen, _URA ) ||2091 readDbl(line, pos[1], fieldLen, SatH1) ||2092 readDbl(line, pos[2], fieldLen, _TGD1) ||2093 readDbl(line, pos[3], fieldLen, _TGD2)) {2203 if (readDbl(line, pos[0], fieldLen, _URA) 2204 || readDbl(line, pos[1], fieldLen, SatH1) 2205 || readDbl(line, pos[2], fieldLen, _TGD1) 2206 || readDbl(line, pos[3], fieldLen, _TGD2)) { 2094 2207 _checkState = bad; 2095 2208 return; … … 2101 2214 // BROADCAST ORBIT - 7 2102 2215 // ===================== 2103 else if ( iLine == 7 ) { 2104 if (navType() == t_eph::CNV1) { 2105 if ( readDbl(line, pos[0], fieldLen, _ISC_B1Cd) || 2106 readDbl(line, pos[2], fieldLen, _TGD_B1Cp) || 2107 readDbl(line, pos[3], fieldLen, _TGD_B2ap) ) { 2108 _checkState = bad; 2109 return; 2110 } 2111 } 2112 else if (navType() == t_eph::CNV2) { 2113 if ( readDbl(line, pos[1], fieldLen, _ISC_B2ad) || 2114 readDbl(line, pos[2], fieldLen, _TGD_B1Cp) || 2115 readDbl(line, pos[3], fieldLen, _TGD_B2ap) ) { 2116 _checkState = bad; 2117 return; 2118 } 2119 } 2120 else if (navType() == t_eph::CNV3) { 2216 else if (iLine == 7) { 2217 if (ephType() == t_eph::CNV1) { 2218 if (readDbl(line, pos[0], fieldLen, _ISC_B1Cd) 2219 || readDbl(line, pos[2], fieldLen, _TGD_B1Cp) 2220 || readDbl(line, pos[3], fieldLen, _TGD_B2ap)) { 2221 _checkState = bad; 2222 return; 2223 } 2224 } else if (ephType() == t_eph::CNV2) { 2225 if (readDbl(line, pos[1], fieldLen, _ISC_B2ad) 2226 || readDbl(line, pos[2], fieldLen, _TGD_B1Cp) 2227 || readDbl(line, pos[3], fieldLen, _TGD_B2ap)) { 2228 _checkState = bad; 2229 return; 2230 } 2231 } else if (ephType() == t_eph::CNV3) { 2121 2232 double health; 2122 if ( readDbl(line, pos[0], fieldLen, _SISMAI ) ||2123 readDbl(line, pos[1], fieldLen, health ) ||2124 readDbl(line, pos[2], fieldLen, _INTEGRITYF_B2b) ||2125 readDbl(line, pos[3], fieldLen, _TGD_B2bI) ){2233 if (readDbl(line, pos[0], fieldLen, _SISMAI) 2234 || readDbl(line, pos[1], fieldLen, health) 2235 || readDbl(line, pos[2], fieldLen, _INTEGRITYF_B2b) 2236 || readDbl(line, pos[3], fieldLen, _TGD_B2bI)) { 2126 2237 _checkState = bad; 2127 2238 return; 2128 2239 } 2129 2240 _health = int(health); 2130 } 2131 else { // D1, D2 or undefined 2241 } else { // D1, D2 or undefined 2132 2242 double aodc; 2133 if ( readDbl(line, pos[0], fieldLen, _TOT) ||2134 readDbl(line, pos[1], fieldLen, aodc)) {2243 if (readDbl(line, pos[0], fieldLen, _TOT) 2244 || readDbl(line, pos[1], fieldLen, aodc)) { 2135 2245 _checkState = bad; 2136 2246 return; … … 2145 2255 // BROADCAST ORBIT - 8 2146 2256 // ===================== 2147 else if ( iLine == 8) {2257 else if (iLine == 8) { 2148 2258 double health; 2149 if (navType() == t_eph::CNV1) {2150 if ( readDbl(line, pos[0], fieldLen, _SISMAI ) ||2151 readDbl(line, pos[1], fieldLen, health ) ||2152 readDbl(line, pos[2], fieldLen, _INTEGRITYF_B1C) ||2153 readDbl(line, pos[3], fieldLen, _IODC) ){2259 if (ephType() == t_eph::CNV1) { 2260 if (readDbl(line, pos[0], fieldLen, _SISMAI) 2261 || readDbl(line, pos[1], fieldLen, health) 2262 || readDbl(line, pos[2], fieldLen, _INTEGRITYF_B1C) 2263 || readDbl(line, pos[3], fieldLen, _IODC)) { 2154 2264 _checkState = bad; 2155 2265 return; 2156 2266 } 2157 2267 _health = int(health); 2158 } 2159 else if (navType() == t_eph::CNV2) { 2160 if ( readDbl(line, pos[0], fieldLen, _SISMAI ) || 2161 readDbl(line, pos[1], fieldLen, health ) || 2162 readDbl(line, pos[2], fieldLen, _INTEGRITYF_B2aB1C) || 2163 readDbl(line, pos[3], fieldLen, _IODC) ) { 2268 } else if (ephType() == t_eph::CNV2) { 2269 if (readDbl(line, pos[0], fieldLen, _SISMAI) 2270 || readDbl(line, pos[1], fieldLen, health) 2271 || readDbl(line, pos[2], fieldLen, _INTEGRITYF_B2aB1C) 2272 || readDbl(line, pos[3], fieldLen, _IODC)) { 2164 2273 _checkState = bad; 2165 2274 return; 2166 2275 } 2167 2276 _health = int(health); 2168 } 2169 else if (navType() == t_eph::CNV3) { 2170 if ( readDbl(line, pos[0], fieldLen, _TOT)) { 2277 } else if (ephType() == t_eph::CNV3) { 2278 if (readDbl(line, pos[0], fieldLen, _TOT)) { 2171 2279 _checkState = bad; 2172 2280 return; … … 2178 2286 // BROADCAST ORBIT - 9 2179 2287 // ===================== 2180 else if ( iLine == 9 ) { 2181 2182 if (navType() == t_eph::CNV1 || 2183 navType() == t_eph::CNV2) { 2184 if ( readDbl(line, pos[0], fieldLen, _TOT) || 2185 readDbl(line, pos[3], fieldLen, _IODE) ) { 2186 _checkState = bad; 2187 return; 2188 } 2189 } 2190 2191 } 2192 } 2193 2194 _TOE.setBDS(int(_BDTweek), _TOEsec); 2288 else if (iLine == 9) { 2289 2290 if (ephType() == t_eph::CNV1 || ephType() == t_eph::CNV2) { 2291 if (readDbl(line, pos[0], fieldLen, _TOT) 2292 || readDbl(line, pos[3], fieldLen, _IODE)) { 2293 _checkState = bad; 2294 return; 2295 } 2296 } 2297 2298 } 2299 } 2300 2301 _TOE.setBDS(int(_BDTweek), _TOEsec); 2195 2302 // remark: actually should be computed from second_tot 2196 2303 // but it seems to be unreliable in RINEX files … … 2201 2308 //////////////////////////////////////////////////////////////////////////// 2202 2309 unsigned int t_ephBDS::IOD() const { 2203 return (int(_TOC.gpssec()) /720) % 240; //return (int(_TOEsec)/720) % 240;2310 return (int(_TOC.gpssec()) / 720) % 240; //return (int(_TOEsec)/720) % 240; 2204 2311 } 2205 2312 2206 2313 // Compute BDS Satellite Position (virtual) 2207 2314 ////////////////////////////////////////////////////////////////////////////// 2208 t_irc t_ephBDS::position(int GPSweek, double GPSweeks, double* xc, double* vv) const { 2209 2210 static const double gmBDS = 398.6004418e12; 2315 t_irc t_ephBDS::position(int GPSweek, double GPSweeks, double *xc, 2316 double *vv) const { 2317 2318 static const double gmBDS = 398.6004418e12; 2211 2319 static const double omegaBDS = 7292115.0000e-11; 2212 2320 … … 2221 2329 double a0 = _sqrt_A * _sqrt_A; 2222 2330 2223 double n0 = sqrt(gmBDS /(a0*a0*a0));2331 double n0 = sqrt(gmBDS / (a0 * a0 * a0)); 2224 2332 double tk = tt - _TOE; 2225 double n 2226 double M = _M0 + n*tk;2227 double E 2333 double n = n0 + _Delta_n; 2334 double M = _M0 + n * tk; 2335 double E = M; 2228 2336 double E_last; 2229 int 2337 int nLoop = 0; 2230 2338 do { 2231 2339 E_last = E; 2232 E = M + _e *sin(E);2340 E = M + _e * sin(E); 2233 2341 2234 2342 if (++nLoop == 100) { 2235 2343 return failure; 2236 2344 } 2237 } while ( fabs(E-E_last)*a0 > 0.001);2238 2239 double v = atan2(sqrt(1-_e*_e) * sin(E), cos(E) - _e);2240 double u0 2241 double sin2u0 = sin(2 *u0);2242 double cos2u0 = cos(2 *u0);2243 double r = a0*(1 - _e*cos(E)) + _Crc*cos2u0 + _Crs*sin2u0;2244 double i = _i0 + _IDOT*tk + _Cic*cos2u0 + _Cis*sin2u0;2245 double u = u0 + _Cuc*cos2u0 + _Cus*sin2u0;2246 double xp = r*cos(u);2247 double yp = r*sin(u);2345 } while (fabs(E - E_last) * a0 > 0.001); 2346 2347 double v = atan2(sqrt(1 - _e * _e) * sin(E), cos(E) - _e); 2348 double u0 = v + _omega; 2349 double sin2u0 = sin(2 * u0); 2350 double cos2u0 = cos(2 * u0); 2351 double r = a0 * (1 - _e * cos(E)) + _Crc * cos2u0 + _Crs * sin2u0; 2352 double i = _i0 + _IDOT * tk + _Cic * cos2u0 + _Cis * sin2u0; 2353 double u = u0 + _Cuc * cos2u0 + _Cus * sin2u0; 2354 double xp = r * cos(u); 2355 double yp = r * sin(u); 2248 2356 double toesec = (_TOE.gpssec() - 14.0); 2249 2357 double sinom = 0; 2250 2358 double cosom = 0; 2251 double sini 2252 double cosi 2359 double sini = 0; 2360 double cosi = 0; 2253 2361 2254 2362 // Velocity 2255 2363 // -------- 2256 double tanv2 = tan(v /2);2257 double dEdM = 1 / (1 - _e*cos(E));2258 double dotv = sqrt((1.0 + _e)/(1.0 - _e)) / cos(E/2)/cos(E/2)2259 / (1 + tanv2*tanv2) * dEdM * n;2260 double dotu = dotv + (-_Cuc*sin2u0 + _Cus*cos2u0)*2*dotv;2261 double doti = _IDOT + (-_Cic*sin2u0 + _Cis*cos2u0)*2*dotv;2262 double dotr = a0 * _e*sin(E) * dEdM * n2263 + (-_Crc*sin2u0 + _Crs*cos2u0)*2*dotv;2264 2265 double dotx = dotr*cos(u) - r*sin(u)*dotu;2266 double doty = dotr*sin(u) + r*cos(u)*dotu;2364 double tanv2 = tan(v / 2); 2365 double dEdM = 1 / (1 - _e * cos(E)); 2366 double dotv = sqrt((1.0 + _e) / (1.0 - _e)) / cos(E / 2) / cos(E / 2) 2367 / (1 + tanv2 * tanv2) * dEdM * n; 2368 double dotu = dotv + (-_Cuc * sin2u0 + _Cus * cos2u0) * 2 * dotv; 2369 double doti = _IDOT + (-_Cic * sin2u0 + _Cis * cos2u0) * 2 * dotv; 2370 double dotr = a0 * _e * sin(E) * dEdM * n 2371 + (-_Crc * sin2u0 + _Crs * cos2u0) * 2 * dotv; 2372 2373 double dotx = dotr * cos(u) - r * sin(u) * dotu; 2374 double doty = dotr * sin(u) + r * cos(u) * dotu; 2267 2375 2268 2376 const double iMaxGEO = 10.0 / 180.0 * M_PI; … … 2271 2379 // ------------------ 2272 2380 if (_i0 > iMaxGEO) { 2273 double OM = _OMEGA0 + (_OMEGADOT - omegaBDS) *tk - omegaBDS*toesec;2381 double OM = _OMEGA0 + (_OMEGADOT - omegaBDS) * tk - omegaBDS * toesec; 2274 2382 2275 2383 sinom = sin(OM); 2276 2384 cosom = cos(OM); 2277 sini 2278 cosi 2279 2280 xc[0] = xp *cosom - yp*cosi*sinom;2281 xc[1] = xp *sinom + yp*cosi*cosom;2282 xc[2] = yp *sini;2385 sini = sin(i); 2386 cosi = cos(i); 2387 2388 xc[0] = xp * cosom - yp * cosi * sinom; 2389 xc[1] = xp * sinom + yp * cosi * cosom; 2390 xc[2] = yp * sini; 2283 2391 2284 2392 // Velocity … … 2287 2395 double dotom = _OMEGADOT - t_CST::omega; 2288 2396 2289 vv[0] = cosom *dotx - cosi*sinom *doty // dX / dr 2290 - xp*sinom*dotom - yp*cosi*cosom*dotom // dX / dOMEGA 2291 + yp*sini*sinom*doti; // dX / di 2292 2293 vv[1] = sinom *dotx + cosi*cosom *doty 2294 + xp*cosom*dotom - yp*cosi*sinom*dotom 2295 - yp*sini*cosom*doti; 2296 2297 vv[2] = sini *doty + yp*cosi *doti; 2397 vv[0] = cosom * dotx - cosi * sinom * doty // dX / dr 2398 - xp * sinom * dotom - yp * cosi * cosom * dotom // dX / dOMEGA 2399 + yp * sini * sinom * doti; // dX / di 2400 2401 vv[1] = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom 2402 - yp * cosi * sinom * dotom - yp * sini * cosom * doti; 2403 2404 vv[2] = sini * doty + yp * cosi * doti; 2298 2405 2299 2406 } … … 2302 2409 // ------------- 2303 2410 else { 2304 double OM = _OMEGA0 + _OMEGADOT*tk - omegaBDS*toesec;2305 double ll = omegaBDS*tk;2411 double OM = _OMEGA0 + _OMEGADOT * tk - omegaBDS * toesec; 2412 double ll = omegaBDS * tk; 2306 2413 2307 2414 sinom = sin(OM); 2308 2415 cosom = cos(OM); 2309 sini 2310 cosi 2311 2312 double xx = xp *cosom - yp*cosi*sinom;2313 double yy = xp *sinom + yp*cosi*cosom;2314 double zz = yp *sini;2416 sini = sin(i); 2417 cosi = cos(i); 2418 2419 double xx = xp * cosom - yp * cosi * sinom; 2420 double yy = xp * sinom + yp * cosi * cosom; 2421 double zz = yp * sini; 2315 2422 2316 2423 Matrix RX = BNC_PPP::t_astro::rotX(-5.0 / 180.0 * M_PI); 2317 2424 Matrix RZ = BNC_PPP::t_astro::rotZ(ll); 2318 2425 2319 ColumnVector X1(3); X1 << xx << yy << zz; 2320 ColumnVector X2 = RZ*RX*X1; 2426 ColumnVector X1(3); 2427 X1 << xx << yy << zz; 2428 ColumnVector X2 = RZ * RX * X1; 2321 2429 2322 2430 xc[0] = X2(1); … … 2326 2434 double dotom = _OMEGADOT; 2327 2435 2328 double vx = cosom *dotx - cosi*sinom *doty 2329 - xp*sinom*dotom - yp*cosi*cosom*dotom 2330 + yp*sini*sinom*doti; 2331 2332 double vy = sinom *dotx + cosi*cosom *doty 2333 + xp*cosom*dotom - yp*cosi*sinom*dotom 2334 - yp*sini*cosom*doti; 2335 2336 double vz = sini *doty + yp*cosi *doti; 2337 2338 ColumnVector V(3); V << vx << vy << vz; 2339 2340 Matrix RdotZ(3,3); 2436 double vx = cosom * dotx - cosi * sinom * doty - xp * sinom * dotom 2437 - yp * cosi * cosom * dotom + yp * sini * sinom * doti; 2438 2439 double vy = sinom * dotx + cosi * cosom * doty + xp * cosom * dotom 2440 - yp * cosi * sinom * dotom - yp * sini * cosom * doti; 2441 2442 double vz = sini * doty + yp * cosi * doti; 2443 2444 ColumnVector V(3); 2445 V << vx << vy << vz; 2446 2447 Matrix RdotZ(3, 3); 2341 2448 double C = cos(ll); 2342 2449 double S = sin(ll); 2343 Matrix UU(3,3); 2344 UU[0][0] = -S; UU[0][1] = +C; UU[0][2] = 0.0; 2345 UU[1][0] = -C; UU[1][1] = -S; UU[1][2] = 0.0; 2346 UU[2][0] = 0.0; UU[2][1] = 0.0; UU[2][2] = 0.0; 2450 Matrix UU(3, 3); 2451 UU[0][0] = -S; 2452 UU[0][1] = +C; 2453 UU[0][2] = 0.0; 2454 UU[1][0] = -C; 2455 UU[1][1] = -S; 2456 UU[1][2] = 0.0; 2457 UU[2][0] = 0.0; 2458 UU[2][1] = 0.0; 2459 UU[2][2] = 0.0; 2347 2460 RdotZ = omegaBDS * UU; 2348 2461 2349 2462 ColumnVector VV(3); 2350 VV = RZ *RX*V + RdotZ*RX*X1;2463 VV = RZ * RX * V + RdotZ * RX * X1; 2351 2464 2352 2465 vv[0] = VV(1); … … 2356 2469 2357 2470 double tc = tt - _TOC; 2358 xc[3] = _clock_bias + _clock_drift *tc + _clock_driftrate*tc*tc;2471 xc[3] = _clock_bias + _clock_drift * tc + _clock_driftrate * tc * tc; 2359 2472 2360 2473 // dotC = _clock_drift + _clock_driftrate*tc … … 2363 2476 // Relativistic Correction 2364 2477 // ----------------------- 2365 xc[3] -= 4.442807309e-10 * _e * sqrt(a0) * sin(E);2366 2367 xc[4] = _clock_drift + _clock_driftrate *tc;2478 xc[3] -= 4.442807309e-10 * _e * sqrt(a0) * sin(E); 2479 2480 xc[4] = _clock_drift + _clock_driftrate * tc; 2368 2481 xc[5] = _clock_driftrate; 2369 2482 2370 2483 return success; 2371 2484 } 2372 2373 2485 2374 2486 // Health status of SBAS Ephemeris (virtual) … … 2376 2488 unsigned int t_ephBDS::isUnhealthy() const { 2377 2489 2378 if (navType() == t_eph::CNV1 || 2379 navType() == t_eph::CNV2 || 2380 navType() == t_eph::CNV3) { 2490 if (ephType() == t_eph::CNV1 || ephType() == t_eph::CNV2 2491 || ephType() == t_eph::CNV3) { 2381 2492 return static_cast<unsigned int>(_health); 2382 2493 } … … 2385 2496 2386 2497 } 2387 2388 2498 2389 2499 // RINEX Format String … … 2391 2501 QString t_ephBDS::toString(double version) const { 2392 2502 2393 QString navStr = navTypeString(_navType, _prn, version);2394 QString rnxStr = navStr + rinexDateStr(_TOC-14.0, _prn, version);2503 QString ephStr = ephTypeStr(_ephType, _prn, version); 2504 QString rnxStr = ephStr + rinexDateStr(_TOC - 14.0, _prn, version); 2395 2505 2396 2506 QTextStream out(&rnxStr); 2397 2507 2398 out << QString("%1%2%3\n") 2399 .arg(_clock_bias, 19, 'e', 12) 2400 .arg(_clock_drift, 19, 'e', 12) 2401 .arg(_clock_driftrate, 19, 'e', 12); 2508 out 2509 << QString("%1%2%3\n").arg(_clock_bias, 19, 'e', 12).arg(_clock_drift, 19, 2510 'e', 12).arg(_clock_driftrate, 19, 'e', 12); 2402 2511 2403 2512 QString fmt = version < 3.0 ? " %1%2%3%4\n" : " %1%2%3%4\n"; … … 2405 2514 // BROADCAST ORBIT - 1 2406 2515 // ===================== 2407 out << QString(fmt) 2408 .arg(double(_AODE), 19, 'e', 12) 2409 .arg(_Crs, 19, 'e', 12) 2410 .arg(_Delta_n, 19, 'e', 12) 2411 .arg(_M0, 19, 'e', 12); 2516 out 2517 << QString(fmt).arg(double(_AODE), 19, 'e', 12).arg(_Crs, 19, 'e', 12).arg( 2518 _Delta_n, 19, 'e', 12).arg(_M0, 19, 'e', 12); 2412 2519 // ===================== 2413 2520 // BROADCAST ORBIT - 2 2414 2521 // ===================== 2415 out << QString(fmt) 2416 .arg(_Cuc, 19, 'e', 12) 2417 .arg(_e, 19, 'e', 12) 2418 .arg(_Cus, 19, 'e', 12) 2419 .arg(_sqrt_A, 19, 'e', 12); 2522 out 2523 << QString(fmt).arg(_Cuc, 19, 'e', 12).arg(_e, 19, 'e', 12).arg(_Cus, 19, 2524 'e', 12).arg(_sqrt_A, 19, 'e', 12); 2420 2525 // ===================== 2421 2526 // BROADCAST ORBIT - 3 2422 2527 // ===================== 2423 out << QString(fmt) 2424 .arg(_TOEsec, 19, 'e', 12) 2425 .arg(_Cic, 19, 'e', 12) 2426 .arg(_OMEGA0, 19, 'e', 12) 2427 .arg(_Cis, 19, 'e', 12); 2528 out 2529 << QString(fmt).arg(_TOEsec, 19, 'e', 12).arg(_Cic, 19, 'e', 12).arg( 2530 _OMEGA0, 19, 'e', 12).arg(_Cis, 19, 'e', 12); 2428 2531 // ===================== 2429 2532 // BROADCAST ORBIT - 4 2430 2533 // ===================== 2431 out << QString(fmt) 2432 .arg(_i0, 19, 'e', 12) 2433 .arg(_Crc, 19, 'e', 12) 2434 .arg(_omega, 19, 'e', 12) 2435 .arg(_OMEGADOT, 19, 'e', 12); 2534 out 2535 << QString(fmt).arg(_i0, 19, 'e', 12).arg(_Crc, 19, 'e', 12).arg(_omega, 2536 19, 'e', 12).arg(_OMEGADOT, 19, 'e', 12); 2436 2537 // ===================== 2437 2538 // BROADCAST ORBIT - 5 2438 2539 // ===================== 2439 if (navType() == t_eph::CNV1 || 2440 navType() == t_eph::CNV2 || 2441 navType() == t_eph::CNV3 ) { 2442 out << QString(fmt) 2443 .arg(_IDOT, 19, 'e', 12) 2444 .arg(_Delta_n_dot, 19, 'e', 12) 2445 .arg(_satType, 19, 'e', 12) 2446 .arg(_top, 19, 'e', 12); 2447 } 2448 else { // D1, D2, undefined 2449 out << QString(fmt) 2450 .arg(_IDOT, 19, 'e', 12) 2451 .arg("", 19, QChar(' ')) 2452 .arg(_BDTweek, 19, 'e', 12) 2453 .arg("", 19, QChar(' ')); 2540 if (ephType() == t_eph::CNV1 || ephType() == t_eph::CNV2 2541 || ephType() == t_eph::CNV3) { 2542 out 2543 << QString(fmt).arg(_IDOT, 19, 'e', 12).arg(_Delta_n_dot, 19, 'e', 12).arg( 2544 _satType, 19, 'e', 12).arg(_top, 19, 'e', 12); 2545 } else { // D1, D2, undefined 2546 out 2547 << QString(fmt).arg(_IDOT, 19, 'e', 12).arg("", 19, QChar(' ')).arg( 2548 _BDTweek, 19, 'e', 12).arg("", 19, QChar(' ')); 2454 2549 } 2455 2550 // ===================== 2456 2551 // BROADCAST ORBIT - 6 2457 2552 // ===================== 2458 if (navType() == t_eph::CNV1 || 2459 navType() == t_eph::CNV2 || 2460 navType() == t_eph::CNV3 ) { 2461 out << QString(fmt) 2462 .arg(_SISAI_oe, 19, 'e', 12) 2463 .arg(_SISAI_ocb, 19, 'e', 12) 2464 .arg(_SISAI_oc1, 19, 'e', 12) 2465 .arg(_SISAI_oc2, 19, 'e', 12); 2466 } 2467 else { // D1, D2, undefined 2468 out << QString(fmt) 2469 .arg(_URA, 19, 'e', 12) 2470 .arg(double(_SatH1), 19, 'e', 12) 2471 .arg(_TGD1, 19, 'e', 12) 2472 .arg(_TGD2, 19, 'e', 12); 2553 if (ephType() == t_eph::CNV1 || ephType() == t_eph::CNV2 2554 || ephType() == t_eph::CNV3) { 2555 out 2556 << QString(fmt).arg(_SISAI_oe, 19, 'e', 12).arg(_SISAI_ocb, 19, 'e', 12).arg( 2557 _SISAI_oc1, 19, 'e', 12).arg(_SISAI_oc2, 19, 'e', 12); 2558 } else { // D1, D2, undefined 2559 out 2560 << QString(fmt).arg(_URA, 19, 'e', 12).arg(double(_SatH1), 19, 'e', 12).arg( 2561 _TGD1, 19, 'e', 12).arg(_TGD2, 19, 'e', 12); 2473 2562 } 2474 2563 // ===================== 2475 2564 // BROADCAST ORBIT - 7 2476 2565 // ===================== 2477 if (navType() == t_eph::CNV1) { 2478 out << QString(fmt) 2479 .arg(_ISC_B1Cd, 19, 'e', 12) 2480 .arg("", 19, QChar(' ')) 2481 .arg(_TGD_B1Cp, 19, 'e', 12) 2482 .arg(_TGD_B2ap, 19, 'e', 12); 2483 } 2484 else if (navType() == t_eph::CNV2) { 2485 out << QString(fmt) 2486 .arg("", 19, QChar(' ')) 2487 .arg(_ISC_B2ad, 19, 'e', 12) 2488 .arg(_TGD_B1Cp, 19, 'e', 12) 2489 .arg(_TGD_B2ap, 19, 'e', 12); 2490 } 2491 else if (navType() == t_eph::CNV3) { 2492 out << QString(fmt) 2493 .arg(_SISMAI, 19, 'e', 12) 2494 .arg(double(_health), 19, 'e', 12) 2495 .arg(_INTEGRITYF_B2b, 19, 'e', 12) 2496 .arg(_TGD_B2bI, 19, 'e', 12); 2497 } 2498 else { // D1, D2, undefined 2566 if (ephType() == t_eph::CNV1) { 2567 out 2568 << QString(fmt).arg(_ISC_B1Cd, 19, 'e', 12).arg("", 19, QChar(' ')).arg( 2569 _TGD_B1Cp, 19, 'e', 12).arg(_TGD_B2ap, 19, 'e', 12); 2570 } else if (ephType() == t_eph::CNV2) { 2571 out 2572 << QString(fmt).arg("", 19, QChar(' ')).arg(_ISC_B2ad, 19, 'e', 12).arg( 2573 _TGD_B1Cp, 19, 'e', 12).arg(_TGD_B2ap, 19, 'e', 12); 2574 } else if (ephType() == t_eph::CNV3) { 2575 out 2576 << QString(fmt).arg(_SISMAI, 19, 'e', 12).arg(double(_health), 19, 'e', 2577 12).arg(_INTEGRITYF_B2b, 19, 'e', 12).arg(_TGD_B2bI, 19, 'e', 12); 2578 } else { // D1, D2, undefined 2499 2579 double tots = 0.0; 2500 if (_receptDateTime.isValid()) { // RTCM stream input2580 if (_receptDateTime.isValid()) { // RTCM stream input 2501 2581 tots = _TOE.bdssec(); 2502 } 2503 else { // RINEX input 2582 } else { // RINEX input 2504 2583 tots = _TOT; 2505 2584 } 2506 out << QString(fmt) 2507 .arg(tots, 19, 'e', 12) 2508 .arg(double(_AODC), 19, 'e', 12) 2509 .arg("", 19, QChar(' ')) 2510 .arg("", 19, QChar(' ')); 2585 out 2586 << QString(fmt).arg(tots, 19, 'e', 12).arg(double(_AODC), 19, 'e', 12).arg( 2587 "", 19, QChar(' ')).arg("", 19, QChar(' ')); 2511 2588 } 2512 2589 … … 2514 2591 // BROADCAST ORBIT - 8 2515 2592 // ===================== 2516 if (navType() == t_eph::CNV1) { 2517 out << QString(fmt) 2518 .arg(_SISMAI, 19, 'e', 12) 2519 .arg(double(_health), 19, 'e', 12) 2520 .arg(_INTEGRITYF_B1C, 19, 'e', 12) 2521 .arg(_IODC, 19, 'e', 12); 2522 } 2523 else if (navType() == t_eph::CNV2) { 2524 out << QString(fmt) 2525 .arg(_SISMAI, 19, 'e', 12) 2526 .arg(double(_health), 19, 'e', 12) 2527 .arg(_INTEGRITYF_B2aB1C, 19, 'e', 12) 2528 .arg(_IODC, 19, 'e', 12); 2529 } 2530 else if (navType() == t_eph::CNV3) { 2531 out << QString(fmt) 2532 .arg(_TOT, 19, 'e', 12) 2533 .arg("", 19, QChar(' ')) 2534 .arg("", 19, QChar(' ')) 2535 .arg("", 19, QChar(' ')); 2593 if (ephType() == t_eph::CNV1) { 2594 out 2595 << QString(fmt).arg(_SISMAI, 19, 'e', 12).arg(double(_health), 19, 'e', 2596 12).arg(_INTEGRITYF_B1C, 19, 'e', 12).arg(_IODC, 19, 'e', 12); 2597 } else if (ephType() == t_eph::CNV2) { 2598 out 2599 << QString(fmt).arg(_SISMAI, 19, 'e', 12).arg(double(_health), 19, 'e', 2600 12).arg(_INTEGRITYF_B2aB1C, 19, 'e', 12).arg(_IODC, 19, 'e', 12); 2601 } else if (ephType() == t_eph::CNV3) { 2602 out 2603 << QString(fmt).arg(_TOT, 19, 'e', 12).arg("", 19, QChar(' ')).arg("", 2604 19, QChar(' ')).arg("", 19, QChar(' ')); 2536 2605 } 2537 2606 … … 2539 2608 // BROADCAST ORBIT - 9 2540 2609 // ===================== 2541 if (navType() == t_eph::CNV1 || 2542 navType() == t_eph::CNV2) { 2543 out << QString(fmt) 2544 .arg(_TOT, 19, 'e', 12) 2545 .arg("", 19, QChar(' ')) 2546 .arg("", 19, QChar(' ')) 2547 .arg(_IODE, 19, 'e', 12); 2548 } 2549 2610 if (ephType() == t_eph::CNV1 || ephType() == t_eph::CNV2) { 2611 out 2612 << QString(fmt).arg(_TOT, 19, 'e', 12).arg("", 19, QChar(' ')).arg("", 2613 19, QChar(' ')).arg(_IODE, 19, 'e', 12); 2614 } 2550 2615 2551 2616 return rnxStr; -
trunk/BNC/src/ephemeris.h
r10533 r10577 13 13 class t_orbCorr; 14 14 class t_clkCorr; 15 // enum e_navType {EPH, STO, EOP, ION}; 15 16 16 17 class t_eph { … … 18 19 enum e_type {unknown, GPS, QZSS, GLONASS, Galileo, SBAS, BDS, IRNSS}; 19 20 enum e_checkState {unchecked, ok, bad, outdated, unhealthy}; 20 enum e_ navType {undefined, LNAV, FDMA, FNAV, INAF, D1, D2, SBASL1, CNAV, CNV1, CNV2, CNV3};21 enum e_ephType {undefined, LNAV, FDMA, FNAV, INAF, D1, D2, SBASL1, CNAV, CNV1, CNV2, CNV3, L1NV, L1OC, L3OC}; 21 22 22 23 t_eph(); … … 27 28 virtual unsigned int IOD() const = 0; 28 29 virtual unsigned int isUnhealthy() const = 0; 29 virtual int 30 virtual int slotNum() const {return 0;} 30 31 bncTime TOC() const {return _TOC;} 31 32 bool isNewerThan(const t_eph* eph) const {return earlierTime(eph, this);} 32 void setCheckState(e_checkState checkState) {_checkState = checkState;}33 void setCheckState(e_checkState checkState) {_checkState = checkState;} 33 34 e_checkState checkState() const {return _checkState;} 34 35 QString checkStateToString() { … … 42 43 } 43 44 } 44 e_ navType navType() const {return _navType;}45 t_irc set NavType(QString navTypeStr);46 47 t_prn 48 t_irc 49 void 50 void 45 e_ephType ephType() const {return _ephType;} 46 t_irc setEphType(QString ephTypeStr); 47 48 t_prn prn() const {return _prn;} 49 t_irc getCrd(const bncTime& tt, ColumnVector& xc, ColumnVector& vv, bool useCorr) const; 50 void setOrbCorr(const t_orbCorr* orbCorr); 51 void setClkCorr(const t_clkCorr* clkCorr); 51 52 const QDateTime& receptDateTime() const {return _receptDateTime;} 52 53 const QString receptStaID() const {return _receptStaID;} 53 54 static QString rinexDateStr(const bncTime& tt, const t_prn& prn, double version); 54 55 static QString rinexDateStr(const bncTime& tt, const QString& prnStr, double version); 55 static QString navTypeString(e_navType navType, const t_prn& prn, double version);56 static QString ephTypeStr(e_ephType ephType, const t_prn& prn, double version); 56 57 static bool earlierTime(const t_eph* eph1, const t_eph* eph2) {return eph1->_TOC < eph2->_TOC;} 57 58 static bool prnSort(const t_eph* eph1, const t_eph* eph2) {return eph1->prn() < eph2->prn();} … … 64 65 QString _receptStaID; 65 66 e_checkState _checkState; 66 e_ navType _navType; // defined in RINEX 467 e_ephType _ephType; // defined in RINEX 4 67 68 t_orbCorr* _orbCorr; 68 69 t_clkCorr* _clkCorr; … … 106 107 _top = 0.0; 107 108 _Delta_n_dot = 0.0; 108 _URAI_NED0 = 0.0; 109 _URAI_NED1 = 0.0; 110 _URAI_NED2 = 0.0; 111 _URAI_ED = 0.0; 112 _ISC_L1CA = 0.0; 113 _ISC_L2C = 0.0; 114 _ISC_L5I5 = 0.0; 115 _ISC_L5Q5 = 0.0; 116 _ISC_L1Cd = 0.0; 117 _ISC_L1Cp = 0.0; 118 _wnop = 0.0; 109 _URAI = 0.0; 110 _URAI_NED0 = 0.0; 111 _URAI_NED1 = 0.0; 112 _URAI_NED2 = 0.0; 113 _URAI_ED = 0.0; 114 _ISC_L1CA = 0.0; 115 _ISC_L2C = 0.0; 116 _ISC_L5I5 = 0.0; 117 _ISC_L5Q5 = 0.0; 118 _ISC_L1Cd = 0.0; 119 _ISC_L1Cp = 0.0; 120 _RSF = 0.0; 121 _ISC_S = 0.0; 122 _ISC_L1D = 0.0; 123 _ISC_L1P = 0.0; 124 _wnop = 0.0; 125 _intSF = -1; 126 _ephSF = -1; 127 _L2Cphasing = -1; 128 _alert = -1; 119 129 _receptStaID = ""; 120 130 } … … 180 190 double _Delta_n_dot; // [rad/s^2] 181 191 192 double _URAI; // [] user range accuracy index 182 193 double _URAI_NED0; // [] 183 194 double _URAI_NED1; // [] … … 185 196 double _URAI_ED; // [] 186 197 187 double _ISC_L1CA; // [s] 198 double _ISC_L1CA; // [s] inter signal correction 188 199 double _ISC_L2C; // [s] 189 200 double _ISC_L5I5; // [s] … … 192 203 double _ISC_L1Cp; // [s] 193 204 194 double _wnop; // GPS continuous week number with the ambiguity resolved 205 double _RSF; // [-] Reference Signal Flag for IRNSS 206 double _ISC_S; // [s] 207 double _ISC_L1D; // [s] 208 double _ISC_L1P; // [s] 209 210 bool _intSF; // [-] integrity status flag 211 bool _ephSF; // [-] ephemeris status flag (QZSS) 212 bool _L2Cphasing; // [-] L2C phasing flag 213 bool _alert; // [-] alert flag 214 215 double _wnop; // GPS continuous week number with the ambiguity resolved (same as _TOEweek?) 195 216 }; 196 217 … … 330 351 _BGD_1_5B = 0.0; 331 352 _TOT = 0.0; 353 bool _inav; 354 /** Data comes from F/NAV when <code>true</code> */ 355 bool _fnav; 356 bool _e1DataInValid; 357 bool _e5aDataInValid; 358 bool _e5bDataInValid; 332 359 _receptStaID = ""; 333 360 }; -
trunk/BNC/src/rinex/reqcanalyze.cpp
r10561 r10577 1019 1019 *_log << " " 1020 1020 << navFi.fileName() << ' ' << QString(": WRONG %2:%3\n") 1021 .arg(eph-> navTypeString(eph->navType(), eph->prn(), 99.0))1021 .arg(eph->ephTypeStr(eph->ephType(), eph->prn(), 99.0)) 1022 1022 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1(); 1023 1023 } -
trunk/BNC/src/rinex/reqcedit.cpp
r10561 r10577 704 704 705 705 if (outNavFile.version() < 4.0) { 706 if (eph-> navType() == t_eph::CNAV ||707 eph-> navType() == t_eph::CNV1 ||708 eph-> navType() == t_eph::CNV2 ||709 eph-> navType() == t_eph::CNV3) {706 if (eph->ephType() == t_eph::CNAV || 707 eph->ephType() == t_eph::CNV1 || 708 eph->ephType() == t_eph::CNV2 || 709 eph->ephType() == t_eph::CNV3) { 710 710 continue; 711 711 } … … 713 713 714 714 if (outNavFile.version() >= 4.0 && 715 eph-> navType() == t_eph::undefined) { // input files < version 4.0715 eph->ephType() == t_eph::undefined) { // input files < version 4.0 716 716 continue; 717 717 } -
trunk/BNC/src/rinex/rnxnavfile.cpp
r10574 r10577 149 149 //////////////////////////////////////////////////////////////////////////// 150 150 void t_rnxNavFile::read(QTextStream* stream) { 151 QString navType;151 QString ephType; 152 152 153 153 while (stream->status() == QTextStream::Ok && !stream->atEnd()) { … … 171 171 prn = hlp.at(2); 172 172 sys = prn[0].toLatin1(); 173 navType = hlp.at(3);173 ephType = hlp.at(3); 174 174 175 175 // ALL Non-EPH messages are currently ignored … … 194 194 sys == 'J' || sys == 'I') { 195 195 lines2skip = 3; 196 if ( sys == 'I' && navType == "L1NV"|| // I: KLOB, NEQN197 sys == 'J' && navType == "CNVX") { // J: WIDE, JAPN196 if ((sys == 'I' && ephType == "L1NV") || // I: KLOB, NEQN 197 (sys == 'J' && ephType == "CNVX")) { // J: WIDE, JAPN 198 198 navSubType = hlp.at(4); 199 199 if (navSubType == "KLOB") { … … 273 273 274 274 if (version() >= 4.0 && key == "EPH") { 275 if (eph->set NavType(navType) != success) {275 if (eph->setEphType(ephType) != success) { 276 276 delete eph; 277 277 continue;
Note:
See TracChangeset
for help on using the changeset viewer.