Changeset 11248 in ntrip for trunk/BNC/src
- Timestamp:
- Dec 3, 2026, 10:30:57 PM (less than one hour ago)
- Location:
- trunk/BNC/src
- Files:
-
- 8 edited
-
PPP/pppEphPool.cpp (modified) (1 diff)
-
bncephuser.cpp (modified) (12 diffs)
-
bncephuser.h (modified) (3 diffs)
-
bnchelp.html (modified) (4 diffs)
-
ephemeris.cpp (modified) (1 diff)
-
ephemeris.h (modified) (1 diff)
-
rinex/reqcedit.cpp (modified) (5 diffs)
-
rinex/reqcedit.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/PPP/pppEphPool.cpp
r11194 r11248 46 46 LOG << "bad ephemeris " << eph->prn().toString() << ' ' << string(eph->TOC()) 47 47 << " - implausible satellite distance, ignored" << endl; 48 delete eph; 49 } 50 else if (eph->checkState() == t_eph::unchecked && 51 dynamic_cast<const t_ephGPS*>(eph) && 52 dynamic_cast<const t_ephGPS*>(eph)->nineZeroPerturbations()) { 53 LOG << "bad ephemeris " << eph->prn().toString() << ' ' << string(eph->TOC()) 54 << " - all nine perturbation terms zero (non-genuine), ignored" << endl; 48 55 delete eph; 49 56 } -
trunk/BNC/src/bncephuser.cpp
r11218 r11248 50 50 // Constructor 51 51 //////////////////////////////////////////////////////////////////////////// 52 bncEphUser::bncEphUser(bool connectSlots, unsigned maxQueueSize) : _maxQueueSize(maxQueueSize), _voting(false) { 52 bncEphUser::bncEphUser(bool connectSlots, unsigned maxQueueSize) : _maxQueueSize(maxQueueSize), _voting(false), 53 _logMajority(!connectSlots) { 53 54 if (connectSlots) { 54 55 connect(BNC_CORE, SIGNAL(newGPSEph(t_ephGPS)), … … 92 93 } 93 94 qDeleteAll(_votes); 95 for (unsigned ii = 0; ii < _removedEph.size(); ii++) { 96 delete _removedEph[ii]; 97 } 98 QMapIterator<QString, QMap<QString, t_streamEph> > itSat(_streamEph); 99 while (itSat.hasNext()) { 100 itSat.next(); 101 QMapIterator<QString, t_streamEph> itStream(itSat.value()); 102 while (itStream.hasNext()) { 103 delete itStream.next().value()._eph; 104 } 105 } 94 106 } 95 107 … … 159 171 160 172 QString prn(newEph->prn().toInternalString().c_str()); 173 174 // majority check of the streams (real-time input only) 175 const bool majority = realTime && !eph->receptStaID().isEmpty(); 161 176 162 177 // data set received before, e.g. from a slower stream after a newer one … … 169 184 vote(prn, ii, eph); 170 185 } 186 if (majority) { 187 t_eph* copy = clone(eph); 188 if (basicChecks(copy, realTime) || copy->checkState() == t_eph::unhealthy) { 189 if (updateStreamEph(prn, copy)) { 190 removeOutvotedLast(prn); 191 } 192 } 193 delete copy; 194 } 171 195 return failure; 172 196 } 197 } 198 } 199 200 // checks of the data set itself 201 if (!basicChecks(eph, realTime)) { 202 if (eph->checkState() == t_eph::unhealthy) { 203 if (majority) { 204 updateStreamEph(prn, eph); // the stream abstains 205 } 206 } 207 else { 208 delete newEph; 209 return failure; 210 } 211 } 212 213 // majority of the streams 214 bool majorityOk = false; 215 if (majority && eph->checkState() != t_eph::unhealthy) { 216 bool contradictsLast = updateStreamEph(prn, eph); 217 int numFor = 0; 218 int numAgainst = 0; 219 QStringList against; 220 majorityCount(prn, eph, numFor, numAgainst, &against); 221 if (numAgainst > numFor) { 222 if (_logMajority) BNC_CORE->message(QString("ephemeris majority %1 %2 %3 from %4: inconsistent with %5 of %6 streams (%7), rejected") 223 .arg(eph->prn().toString().c_str()) 224 .arg(eph->TOC().datestr().c_str()) 225 .arg(eph->TOC().timestr(0).c_str()) 226 .arg(eph->receptStaID()) 227 .arg(numAgainst).arg(numFor + numAgainst) 228 .arg(against.join(" ")).toLatin1(), 229 false, "bce", t_logRecord::warning); 230 eph->setCheckState(t_eph::bad); 231 delete newEph; 232 return failure; 233 } 234 majorityOk = (numFor >= 2); 235 if (contradictsLast) { 236 removeOutvotedLast(prn); 173 237 } 174 238 } … … 183 247 184 248 if ( (ephOld == 0) || eph->isNewerThan(ephOld)) { 185 checkEphemeris(eph, realTime); 249 if (eph->checkState() != t_eph::unhealthy) { 250 checkEphemeris(eph, majorityOk); 251 } 186 252 } 187 253 else { … … 558 624 } 559 625 626 const double bncEphUser::MAJ_WINDOW = 7200.0; 627 const double bncEphUser::MAJ_MAXDIFF = 1000.0; 628 629 // Consistency of two data sets of a satellite (majority check) 630 //////////////////////////////////////////////////////////////////////////// 631 bncEphUser::e_consistency bncEphUser::compareDataSets(const t_eph* eph, const t_eph* other) { 632 if (!eph || !other || eph->prn().system() != other->prn().system() || 633 eph->prn().number() != other->prn().number()) { 634 return notComparable; 635 } 636 if (eph->system() == t_eph::SBAS || eph->system() == t_eph::NavIC) { 637 return notComparable; 638 } 639 if (std::fabs(other->TOC() - eph->TOC()) > MAJ_WINDOW) { 640 return notComparable; 641 } 642 if (eph->isUnhealthy() || other->isUnhealthy()) { 643 return notComparable; 644 } 645 ColumnVector x1(6), v1(3), x2(6), v2(3); 646 if (eph ->getCrd(eph->TOC(), x1, v1, false) != success || 647 other->getCrd(eph->TOC(), x2, v2, false) != success) { 648 return notComparable; 649 } 650 double dPos = (x1.Rows(1,3) - x2.Rows(1,3)).NormFrobenius(); 651 double dClk = std::fabs(x1(4) - x2(4)) * t_CST::c; 652 if (std::isnan(dPos) || std::isnan(dClk)) { 653 return notComparable; 654 } 655 return (dPos > MAJ_MAXDIFF || dClk > MAJ_MAXDIFF) ? inconsistent : consistent; 656 } 657 560 658 // 561 659 //////////////////////////////////////////////////////////////////////////// … … 578 676 // 579 677 //////////////////////////////////////////////////////////////////////////// 580 voidbncEphUser::checkEphemeris(t_eph* eph, bool realTime) {678 bool bncEphUser::basicChecks(t_eph* eph, bool realTime) { 581 679 582 680 if (!eph) { 583 return; 681 return false; 584 682 } 585 683 … … 591 689 if (outDatedBcep(eph, currentTime)) { 592 690 eph->setCheckState(t_eph::outdated); 593 return; 691 return false; 594 692 } 595 693 } … … 599 697 if (eph->isUnhealthy()) { 600 698 eph->setCheckState(t_eph::unhealthy); 601 return; 699 return false; 602 700 } 603 701 … … 607 705 if (ephGPS && !ephGPS->iodeIodcConsistent()) { 608 706 eph->setCheckState(t_eph::bad); 609 return; 707 return false; 708 } 709 710 // GPS LNAV: signature of non-genuine data sets 711 // -------------------------------------------- 712 if (ephGPS && ephGPS->nineZeroPerturbations()) { 713 eph->setCheckState(t_eph::bad); 714 return false; 610 715 } 611 716 … … 614 719 if (!radialDistanceOk(eph)) { 615 720 eph->setCheckState(t_eph::bad); 721 return false; 722 } 723 return true; 724 } 725 726 // Consistency with the last data set of the satellite; with majorityOk 727 // (at least 2 streams and more streams consistent with the data set than 728 // inconsistent) an inconsistency with the last data set does not reject it 729 //////////////////////////////////////////////////////////////////////////// 730 void bncEphUser::checkEphemeris(t_eph* eph, bool majorityOk) { 731 732 if (!eph) { 616 733 return; 617 734 } … … 705 822 } 706 823 else { 707 if (ephL->checkState() == t_eph::ok) { 824 if (majorityOk) { 825 eph->setCheckState(t_eph::ok); 826 } 827 else if (ephL->checkState() == t_eph::ok) { 708 828 eph->setCheckState(t_eph::bad); 709 829 } 710 830 } 711 831 } 712 } 713 832 if (majorityOk && eph->checkState() == t_eph::unchecked) { 833 eph->setCheckState(t_eph::ok); 834 } 835 } 836 837 // Latest data set of a stream for a satellite (majority check); true if 838 // it contradicts the last data set of the satellite (only then the removal 839 // of the last one has to be checked: the votes of the other streams did not 840 // change) 841 //////////////////////////////////////////////////////////////////////////// 842 bool bncEphUser::updateStreamEph(const QString& prn, const t_eph* eph) { 843 QMap<QString, t_streamEph>& streams = _streamEph[prn]; 844 if (streams.contains(eph->receptStaID())) { 845 delete streams[eph->receptStaID()]._eph; 846 } 847 t_streamEph& streamEph = streams[eph->receptStaID()]; 848 streamEph._eph = clone(eph); 849 streamEph._key = dataSetKey(eph); 850 const t_eph* last = ephLast(prn); 851 return last && compareDataSets(last, eph) == inconsistent; 852 } 853 854 // Identification of identical data sets: TOC, IOD and type, satellite 855 // position and clock at TOC (mm, ps) 856 //////////////////////////////////////////////////////////////////////////// 857 QByteArray bncEphUser::dataSetKey(const t_eph* eph) { 858 ColumnVector xc(6), vv(3); 859 if (eph->isUnhealthy() || eph->getCrd(eph->TOC(), xc, vv, false) != success) { 860 return QByteArray(); 861 } 862 return QString("%1 %2 %3 %4 %5 %6 %7 %8") 863 .arg(std::string(eph->TOC()).c_str()).arg(eph->IOD()).arg(int(eph->type())) 864 .arg(qRound64(xc(1) * 1000.0)).arg(qRound64(xc(2) * 1000.0)).arg(qRound64(xc(3) * 1000.0)) 865 .arg(qRound64(xc(4) * 1.e12)).arg(eph->isUnhealthy()).toLatin1(); 866 } 867 868 // Votes of the streams on a data set: consistent or inconsistent latest 869 // data set of each stream (not comparable ones abstain); identical data sets 870 // of several streams are compared once 871 //////////////////////////////////////////////////////////////////////////// 872 void bncEphUser::majorityCount(const QString& prn, const t_eph* eph, int& numFor, 873 int& numAgainst, QStringList* against) const { 874 numFor = 0; 875 numAgainst = 0; 876 QHash<QByteArray, e_consistency> known; 877 QMapIterator<QString, t_streamEph> it(_streamEph.value(prn)); 878 while (it.hasNext()) { 879 it.next(); 880 const t_streamEph& streamEph = it.value(); 881 e_consistency cons; 882 if (!streamEph._key.isEmpty() && known.contains(streamEph._key)) { 883 cons = known.value(streamEph._key); 884 } 885 else { 886 cons = compareDataSets(eph, streamEph._eph); 887 if (!streamEph._key.isEmpty()) { 888 known.insert(streamEph._key, cons); 889 } 890 } 891 if (cons == consistent) { 892 ++numFor; 893 } 894 else if (cons == inconsistent) { 895 ++numAgainst; 896 if (against) { 897 *against << it.key(); 898 } 899 } 900 } 901 } 902 903 // Removal of the last data set of a satellite if the majority of the 904 // streams (at least 2) contradicts it, e.g. a non-genuine first data set 905 // after the start 906 //////////////////////////////////////////////////////////////////////////// 907 void bncEphUser::removeOutvotedLast(const QString& prn) { 908 while (_eph.contains(prn) && !_eph[prn].empty()) { 909 deque<t_eph*>& qq = _eph[prn]; 910 t_eph* last = qq.back(); 911 int numFor = 0; 912 int numAgainst = 0; 913 QStringList against; 914 majorityCount(prn, last, numFor, numAgainst, &against); 915 if (numAgainst < 2 || numAgainst <= numFor) { 916 return; 917 } 918 if (_logMajority) BNC_CORE->message(QString("ephemeris majority %1 %2 %3 from %4: inconsistent with %5 of %6 streams (%7), removed") 919 .arg(last->prn().toString().c_str()) 920 .arg(last->TOC().datestr().c_str()) 921 .arg(last->TOC().timestr(0).c_str()) 922 .arg(last->receptStaID()) 923 .arg(numAgainst).arg(numFor + numAgainst) 924 .arg(against.join(" ")).toLatin1(), 925 false, "bce", t_logRecord::warning); 926 delete _votes.take(last); 927 // not deleted at once: users may still hold the pointer (e.g. the 928 // combination for the corrections of the current epoch) 929 last->setCheckState(t_eph::bad); 930 _removedEph.push_back(last); 931 if (_removedEph.size() > 100) { 932 delete _removedEph.front(); 933 _removedEph.pop_front(); 934 } 935 qq.pop_back(); 936 if (qq.empty()) { 937 _eph.remove(prn); 938 } 939 ephBufferChanged(); 940 } 941 } 942 -
trunk/BNC/src/bncephuser.h
r11218 r11248 85 85 static bool radialDistanceOk(const t_eph* eph); 86 86 87 // Majority check of the data sets of a satellite delivered by different 88 // sources (streams in real time, files in RINEX Edit/Concatenate): two data 89 // sets are compared at the TOC of the first one, if their TOCs differ by at 90 // most MAJ_WINDOW seconds; inconsistent if satellite position or clock 91 // differ by more than MAJ_MAXDIFF meters. Genuine data sets within 2 h 92 // (BRDC00IGS_R 1 Jan 2026): GPS 4 m, Galileo 26 m, BDS 34 m, GLONASS 153 m, 93 // clocks 4 m. Not comparable: SBAS and NavIC (their extrapolation differs 94 // by up to 45 km resp. 116 km within 2 h), unhealthy data sets. 95 enum e_consistency {notComparable, consistent, inconsistent}; 96 static const double MAJ_WINDOW; 97 static const double MAJ_MAXDIFF; 98 static e_consistency compareDataSets(const t_eph* eph, const t_eph* other); 99 87 100 t_eph* ephLast(const QString& prn) { 88 101 if (_eph.contains(prn)) { … … 139 152 static bool minorDifference(const QByteArray& content1, const QByteArray& content2); 140 153 void vote(const QString& prn, unsigned index, const t_eph* eph); 141 void checkEphemeris(t_eph* eph, bool realTime); 154 void checkEphemeris(t_eph* eph, bool majorityOk = false); 155 bool basicChecks(t_eph* eph, bool realTime); 156 // Majority check (real-time input): votes of the streams on a data set, 157 // i.e. the latest data set of each stream for the satellite compared with 158 // it (compareDataSets); removal of the last data set if contradicted by the 159 // majority of the streams (at least 2) 160 bool updateStreamEph(const QString& prn, const t_eph* eph); 161 static QByteArray dataSetKey(const t_eph* eph); 162 void majorityCount(const QString& prn, const t_eph* eph, int& numFor, int& numAgainst, 163 QStringList* against = 0) const; 164 void removeOutvotedLast(const QString& prn); 142 165 bool fromEphMount(const t_eph& eph) const { 143 166 return _ephMounts.isEmpty() || _ephMounts.contains(eph.receptStaID()); … … 148 171 QMap<QString, std::deque<t_eph*> > _eph; 149 172 bool _voting; 173 bool _logMajority; // instances fed by BNC_CORE don't log the majority check again 150 174 QHash<const t_eph*, t_votes*> _votes; // per buffered data set 175 struct t_streamEph { 176 t_eph* _eph; // latest data set of the stream 177 QByteArray _key; // identical data sets: compared once (dataSetKey) 178 }; 179 QMap<QString, QMap<QString, t_streamEph> > _streamEph; // satellite -> stream -> its latest data set 180 std::deque<t_eph*> _removedEph; // removed by the majority, deleted later 151 181 }; 152 182 -
trunk/BNC/src/bnchelp.html
r11240 r11248 3691 3691 significant bits of its IODC, i.e. assembled from subframes of two uploads, is ignored as wrong. 3692 3692 </p> 3693 <p> 3694 A GPS LNAV data set whose nine perturbation terms (Crs, Crc, Cus, Cuc, Cis, Cic, Delta n, IDOT, OMEGADOT) are all 3695 exactly zero is ignored as wrong: broadcast GPS data sets always contain non-zero values, such data sets are 3696 not genuine (e.g. generated by receivers or software from other data, with orbits deviating by kilometers or 3697 belonging to another satellite). BeiDou data sets are not checked this way, as they may contain genuine zero terms. 3698 </p> 3699 <p> 3700 If Broadcast Ephemeris are received from several streams, the streams vote on the consistency of the data sets 3701 of a satellite: each stream votes with the latest data set it delivered for the satellite. Two data sets are 3702 considered consistent if their TOCs differ by at most 2 hours and the satellite positions and clocks computed 3703 with both at the TOC of the first differ by at most 1 km. Genuine data sets agree much better (within 2 hours 3704 at most 4 m for GPS, 26 m for Galileo, 34 m for BeiDou and 153 m for GLONASS in a merged navigation file of 3705 one day), while non-genuine data sets, e.g. relabelled data sets of another satellite or 3706 another day, deviate by thousands of kilometers. SBAS and NavIC data sets as well as unhealthy data sets are 3707 not compared. Then 3708 </p> 3709 <ul> 3710 <li>a new data set is rejected if more streams contradict it than confirm it;</li> 3711 <li>a new data set confirmed by at least two streams is accepted even if it differs by more than 10 m from the 3712 preceding data set of the satellite (see section 'Ephemeris Check' of the RINEX quality check), so a 3713 non-genuine preceding data set cannot block the genuine ones;</li> 3714 <li>the latest data set of a satellite is removed again if at least two streams contradict it and these are 3715 more than the streams confirming it, e.g. a non-genuine data set received first after the start of BNC. Data 3716 sets already written to a RINEX Navigation file or passed on before (e.g. uploaded) cannot be taken back.</li> 3717 </ul> 3718 <p> 3719 With a single stream, or as many streams contradicting as confirming a data set, the vote cannot decide and the 3720 comparison with the preceding data set of the satellite applies as before. Rejections and removals are logged, 3721 e.g. 3722 </p> 3723 <pre> 3724 ephemeris majority G02 2026-10-23 03:00:16 from STRM00XXX0: inconsistent with 2 of 3 streams (STRM01XXX0 STRM02XXX0), removed 3725 ephemeris majority G02 2026-10-23 03:00:32 from STRM00XXX0: inconsistent with 3 of 4 streams (STRM01XXX0 STRM02XXX0 STRM03XXX0), rejected 3726 </pre> 3693 3727 3694 3728 <p><img src="IMG/Figure10.png" width=1000 /></p> … … 3917 3951 the RINEX header which fits to the whole file content. 3918 3952 </p> 3953 <p> 3954 RINEX Navigation input files, for 'Edit/Concatenate' as well as for 'Analyze', are screened for records which 3955 are not genuine before their contents are merged: 3956 </p> 3957 <ul> 3958 <li>'FAR DATE': the record's TOC is more than 2 days outside the period covered by the central 80 percent of the 3959 TOCs of the file (only for files with at least three records), e.g. records stamped years ahead or stale 3960 records of earlier years;</li> 3961 <li>'NINE ZERO': a GPS LNAV record with all nine perturbation terms exactly zero (see section 'RINEX Ephemeris');</li> 3962 <li>'MAJORITY': with at least three input files, each file votes once for or against each record of a satellite, 3963 using the consistency criterion described in section 'RINEX Ephemeris' (TOCs within 2 hours, position and 3964 clock within 1 km). A record is removed if more files contradict it than confirm it. With as many files 3965 against as for it, the record is removed if the group of files whose records of the satellite are 3966 consistent with each other over the day is larger on the opposing side.</li> 3967 </ul> 3968 <p> 3969 Removed records are listed in the logfile per input file and are not part of the output file; with 'Analyze' 3970 they are counted as 'WRONG'. Example: 3971 </p> 3972 <pre> 3973 Input Nav File : SITE00XXX_R_20263250000_01D_RN.rnx 3974 Removed Records : 11 (FAR DATE: TOC far from the file's epochs, NINE ZERO: GPS LNAV non-genuine, MAJORITY: inconsistent with most other files) 3975 : MAJORITY EPH R02 FDMA: 2026 11 21 07 15 00 3976 : MAJORITY EPH R03 FDMA: 2026 11 21 03 15 00 3977 ... 3978 </pre> 3979 <p> 3980 Without such a screening, the first input file containing a data set (same satellite and TOC) would win. Note 3981 that the majority check needs data sets of the same satellite from several files and is therefore most 3982 effective when merging navigation files of several stations. 3983 </p> 3919 3984 3920 3985 <p> … … 4095 4160 at TOC is not between 20,000 km and 60,000 km, or if satellite position or clock at its TOC differ by more than 4096 4161 10 m (100 m for BeiDou and SBAS) from those computed with the preceding data set of the same satellite, or if 4097 a data set only repeats the preceding one with a different TOC. Wrong data sets are listed in the logfile and 4098 ignored for the analysis.</li> 4162 a data set only repeats the preceding one with a different TOC, or if it is a GPS LNAV data set with all nine 4163 perturbation terms zero, or if it was removed when screening the input files (see section 'Input Files'). 4164 Wrong data sets are listed in the logfile and ignored for the analysis.</li> 4099 4165 </ul> 4100 4166 <p> … … 10271 10337 - RIO200ARG0, + BRAZ00BRA0 RGDG00ARG0; differing: Cn A Bn P3 NA N4) 10272 10338 </pre> 10339 <p> 10340 The vote on copies of the same data set is complemented by the vote of the streams on the consistency of 10341 different data sets of a satellite (see section 'RINEX Ephemeris'): a data set contradicted by the majority of 10342 the streams, e.g. a relabelled data set of another satellite with a TOC of its own, is not uploaded, and the 10343 previous data set of the satellite stays in the upload. 10344 </p> 10273 10345 <p> 10274 10346 A data set uploaded after 40 seconds without three agreeing streams is logged as well, e.g. -
trunk/BNC/src/ephemeris.cpp
r11195 r11248 1130 1130 } 1131 1131 1132 // Signature of non-genuine GPS LNAV data sets 1133 //////////////////////////////////////////////////////////////////////////// 1134 bool t_ephGPS::nineZeroPerturbations() const { 1135 return system() == t_eph::GPS && type() == t_eph::LNAV && 1136 _sqrt_A != 0.0 && // orbit present 1137 _Crs == 0.0 && _Crc == 0.0 && 1138 _Cus == 0.0 && _Cuc == 0.0 && 1139 _Cis == 0.0 && _Cic == 0.0 && 1140 _Delta_n == 0.0 && _IDOT == 0.0 && _OMEGADOT == 0.0; 1141 } 1142 1132 1143 // Health status of GPS Ephemeris (virtual) 1133 1144 //////////////////////////////////////////////////////////////////////////// -
trunk/BNC/src/ephemeris.h
r11195 r11248 176 176 (static_cast<int>(_IODE) == (static_cast<int>(_IODC) & 0xFF)); 177 177 } 178 // GPS LNAV with all nine perturbation terms (Crs, Crc, Cus, Cuc, Cis, Cic, 179 // Delta n, IDOT, OMEGADOT) exactly zero: never broadcast by the GPS control 180 // segment, a signature of generated (spoofed) navigation data; not 181 // applied to other systems (BDS has genuine data sets of this kind) 182 bool nineZeroPerturbations() const; 178 183 //virtual unsigned int isUnhealthy() const { return static_cast<unsigned int>(_health);} 179 184 virtual unsigned int isUnhealthy() const; -
trunk/BNC/src/rinex/reqcedit.cpp
r11200 r11248 41 41 #include <QRegularExpression> 42 42 #include <iostream> 43 #include <algorithm> 44 #include <cmath> 45 #include <vector> 43 46 #include "reqcedit.h" 44 47 #include "bnccore.h" … … 739 742 bool checkEph) { 740 743 741 QStringListIterator it(navFileNames); 744 // all files first: records to be removed are decided per file (FAR DATE, 745 // NINE ZERO) and by the majority of the files (MAJORITY) 746 QList<t_rnxNavFile*> navFiles; 747 QList<QVector<QString> > removed; 748 QStringListIterator it(expandFileNames(navFileNames)); 742 749 while (it.hasNext()) { 743 QString fileName = it.next(); 744 if (fileName.indexOf('*') != -1 || 745 fileName.indexOf('?') != -1) { 746 QFileInfo fileInfo(fileName); 747 QDir dir = fileInfo.dir(); 748 QStringList filters; filters << fileInfo.fileName(); 749 QListIterator<QFileInfo> it(dir.entryInfoList(filters)); 750 while (it.hasNext()) { 751 QString filePath = it.next().filePath(); 752 appendEphemerides(filePath, ephs, log, checkEph); 753 } 754 } 755 else { 756 appendEphemerides(fileName, ephs, log, checkEph); 757 } 758 } 750 navFiles << new t_rnxNavFile(it.next(), t_rnxNavFile::input); 751 removed << nonGenuineRecords(navFiles.last()->ephs()); 752 } 753 majorityCheck(navFiles, removed); 754 for (int iFile = 0; iFile < navFiles.size(); iFile++) { 755 appendEphemerides(*navFiles[iFile], removed[iFile], ephs, log, checkEph); 756 } 757 qDeleteAll(navFiles); 759 758 // TODO: enable user decision 760 759 std::stable_sort(ephs.begin(), ephs.end(), t_eph::earlierTime); … … 1399 1398 } 1400 1399 1400 // Records of a navigation file to be removed: the reason ("FAR DATE", 1401 // "NINE ZERO") for each record to be removed, an empty string otherwise. 1402 // - FAR DATE: TOC more than 2 days outside the central 80 % of the file's 1403 // TOCs (stale data sets of satellites out of service or in test, records 1404 // stamped 2028 in daily files of 2025/2026); not 1405 // decided for files with less than 3 records 1406 // - NINE ZERO: GPS LNAV with all nine perturbation terms exactly zero, 1407 // never broadcast by the GPS control segment (generated data) 1408 // A majority check of the orbits (records of a satellite disagreeing with 1409 // most records of other stations within some hours) is not done yet. 1410 //////////////////////////////////////////////////////////////////////////// 1411 QVector<QString> t_reqcEdit::nonGenuineRecords(const std::vector<t_eph*>& ephs) { 1412 const double MARGIN = 2.0 * 86400.0; 1413 const int nn = static_cast<int>(ephs.size()); 1414 QVector<QString> reason(nn); 1415 1416 double qLow = 0.0; 1417 double qHigh = 0.0; 1418 bool haveWindow = false; 1419 if (nn >= 3) { 1420 const bncTime t0 = ephs[0]->TOC(); 1421 std::vector<double> dt(nn); 1422 for (int ii = 0; ii < nn; ii++) { 1423 dt[ii] = ephs[ii]->TOC() - t0; 1424 } 1425 std::sort(dt.begin(), dt.end()); 1426 qLow = dt[static_cast<int>(std::floor(0.1 * (nn - 1)))]; 1427 qHigh = dt[static_cast<int>(std::ceil (0.9 * (nn - 1)))]; 1428 haveWindow = true; 1429 } 1430 1431 for (int ii = 0; ii < nn; ii++) { 1432 const t_eph* eph = ephs[ii]; 1433 if (haveWindow) { 1434 double dt = eph->TOC() - ephs[0]->TOC(); 1435 if (dt < qLow - MARGIN || dt > qHigh + MARGIN) { 1436 reason[ii] = "FAR DATE"; 1437 continue; 1438 } 1439 } 1440 const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph); 1441 if (ephGPS && ephGPS->nineZeroPerturbations()) { 1442 reason[ii] = "NINE ZERO"; 1443 } 1444 } 1445 return reason; 1446 } 1447 1448 // Majority check across the input files (at least 3): the records of a 1449 // satellite are grouped into data sets (same TOC, IOD and type, consistent 1450 // orbit and clock). A file supports a data set if it has a record within 1451 // bncEphUser::MAJ_WINDOW consistent with it, it contradicts it if it has 1452 // comparable records there, but none consistent. Data sets contradicted by 1453 // more files than supporting them (the files delivering them included) are 1454 // removed (MAJORITY). Each file counts once, however many records it has. 1455 // A tie is decided by the tracks of consistent data sets (see below). 1456 //////////////////////////////////////////////////////////////////////////// 1457 void t_reqcEdit::majorityCheck(const QList<t_rnxNavFile*>& navFiles, 1458 QList<QVector<QString> >& removed) { 1459 if (navFiles.size() < 3) { 1460 return; 1461 } 1462 struct t_group { 1463 const t_eph* rep; // first record 1464 QSet<int> files; 1465 QList<QPair<int,int> > members; // (file, record) 1466 }; 1467 QMap<QString, QVector<t_group> > groups; // per satellite 1468 for (int iFile = 0; iFile < navFiles.size(); iFile++) { 1469 const std::vector<t_eph*>& fileEphs = navFiles[iFile]->ephs(); 1470 for (int ii = 0; ii < int(fileEphs.size()); ii++) { 1471 if (!removed[iFile][ii].isEmpty()) { 1472 continue; 1473 } 1474 const t_eph* eph = fileEphs[ii]; 1475 QString sat = QString("%1%2").arg(eph->prn().system()).arg(eph->prn().number()); 1476 QVector<t_group>& gg = groups[sat]; 1477 int iGroup = -1; 1478 for (int ig = 0; ig < gg.size(); ig++) { 1479 if (gg[ig].rep->sameDataSet(eph) && gg[ig].rep->type() == eph->type() && 1480 bncEphUser::compareDataSets(gg[ig].rep, eph) == bncEphUser::consistent) { 1481 iGroup = ig; 1482 break; 1483 } 1484 } 1485 if (iGroup < 0) { 1486 t_group group; 1487 group.rep = eph; 1488 gg.append(group); 1489 iGroup = gg.size() - 1; 1490 } 1491 gg[iGroup].files.insert(iFile); 1492 gg[iGroup].members.append(QPair<int,int>(iFile, ii)); 1493 } 1494 } 1495 1496 QMapIterator<QString, QVector<t_group> > itSat(groups); 1497 while (itSat.hasNext()) { 1498 itSat.next(); 1499 const QVector<t_group>& gg = itSat.value(); 1500 const int nG = gg.size(); 1501 1502 // consistency of the data sets within the window (at the TOC of the first) 1503 QVector<QVector<bncEphUser::e_consistency> > cons(nG, QVector<bncEphUser::e_consistency>(nG)); 1504 for (int ig = 0; ig < nG; ig++) { 1505 for (int ih = 0; ih < nG; ih++) { 1506 cons[ig][ih] = bncEphUser::compareDataSets(gg[ig].rep, gg[ih].rep); 1507 } 1508 } 1509 1510 // tracks: data sets linked by consistency, with the files delivering them 1511 QVector<int> track(nG); 1512 for (int ig = 0; ig < nG; ig++) { 1513 track[ig] = ig; 1514 } 1515 bool changed = true; 1516 while (changed) { 1517 changed = false; 1518 for (int ig = 0; ig < nG; ig++) { 1519 for (int ih = 0; ih < nG; ih++) { 1520 if ((cons[ig][ih] == bncEphUser::consistent || cons[ih][ig] == bncEphUser::consistent) && 1521 track[ih] < track[ig]) { 1522 track[ig] = track[ih]; 1523 changed = true; 1524 } 1525 } 1526 } 1527 } 1528 QMap<int, QSet<int> > trackFiles; 1529 for (int ig = 0; ig < nG; ig++) { 1530 trackFiles[track[ig]].unite(gg[ig].files); 1531 } 1532 1533 for (int ig = 0; ig < nG; ig++) { 1534 QMap<int, bool> support; // file -> consistent record found 1535 int maxOpposing = 0; // files of the largest inconsistent track 1536 for (int ih = 0; ih < nG; ih++) { 1537 if (cons[ig][ih] == bncEphUser::notComparable) { 1538 continue; 1539 } 1540 QSetIterator<int> itFile(gg[ih].files); 1541 while (itFile.hasNext()) { 1542 int iFile = itFile.next(); 1543 support[iFile] = support.value(iFile, false) || cons[ig][ih] == bncEphUser::consistent; 1544 } 1545 if (cons[ig][ih] == bncEphUser::inconsistent && track[ih] != track[ig]) { 1546 maxOpposing = qMax(maxOpposing, int(trackFiles[track[ih]].size())); 1547 } 1548 } 1549 int numFor = 0; 1550 int numAgainst = 0; 1551 QMapIterator<int, bool> itSup(support); 1552 while (itSup.hasNext()) { 1553 itSup.next(); 1554 itSup.value() ? ++numFor : ++numAgainst; 1555 } 1556 // tie: decided by the files of the tracks (genuine data sets of a 1557 // satellite are consistent from one to the next over the whole file 1558 // period, delivered by all files observing it) 1559 if (numAgainst > numFor || 1560 (numAgainst > 0 && numAgainst == numFor && 1561 maxOpposing > int(trackFiles[track[ig]].size()))) { 1562 for (int im = 0; im < gg[ig].members.size(); im++) { 1563 removed[gg[ig].members[im].first][gg[ig].members[im].second] = "MAJORITY"; 1564 } 1565 } 1566 } 1567 } 1568 } 1569 1401 1570 // 1402 1571 //////////////////////////////////////////////////////////////////////////// 1403 void t_reqcEdit::appendEphemerides(const QString& fileName, 1572 void t_reqcEdit::appendEphemerides(const t_rnxNavFile& rnxNavFile, 1573 const QVector<QString>& nonGenuine, 1404 1574 QVector<t_eph*>& ephs, QTextStream* log, 1405 1575 bool checkEph) { 1406 t_rnxNavFile rnxNavFile(fileName, t_rnxNavFile::input);1407 1576 unsigned numOK = 0; 1408 1577 unsigned numBad = 0; … … 1418 1587 } 1419 1588 1589 // Records far from the file's epochs (stale data sets, or records stamped 1590 // years ahead), GPS records not broadcast by the satellites (generated 1591 // navigation data received by some stations) and records inconsistent with 1592 // most other files: removed before the duplicates, so that they can 1593 // neither replace a genuine record with the same TOC nor disable the 1594 // checks of the following records 1595 // --------------------------------------------------------------------- 1596 int numNonGenuine = 0; 1597 for (int ii = 0; ii < nonGenuine.size(); ii++) { 1598 if (!nonGenuine[ii].isEmpty()) { 1599 ++numNonGenuine; 1600 } 1601 } 1602 if (log && numNonGenuine > 0) { 1603 *log << "Removed Records : " << numNonGenuine 1604 << " (FAR DATE: TOC far from the file's epochs, NINE ZERO: GPS LNAV non-genuine," 1605 << " MAJORITY: inconsistent with most other files)" << Qt::endl; 1606 for (unsigned ii = 0; ii < rnxNavFile.ephs().size(); ii++) { 1607 if (!nonGenuine[ii].isEmpty()) { 1608 const t_eph* eph = rnxNavFile.ephs()[ii]; 1609 *log << " : " 1610 << QString("%1 %2:%3") 1611 .arg(nonGenuine[ii], -9) 1612 .arg(eph->typeStr(eph->type(), eph->prn(), 99.0)) 1613 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1() 1614 << Qt::endl; 1615 } 1616 } 1617 } 1618 1420 1619 for (unsigned ii = 0; ii < rnxNavFile.ephs().size(); ii++) { 1421 1620 t_eph* eph = rnxNavFile.ephs()[ii]; 1621 if (!nonGenuine[ii].isEmpty()) { 1622 if (checkEph) { 1623 eph->setCheckState(t_eph::bad); 1624 ++numBad; 1625 } 1626 continue; 1627 } 1422 1628 bool isNew = true; 1423 1629 for (int iOld = 0; iOld < ephs.size(); iOld++) { … … 1479 1685 for (unsigned ii = 0; ii < rnxNavFile.ephs().size(); ii++) { 1480 1686 t_eph* eph = rnxNavFile.ephs()[ii]; 1481 QFileInfo navFi(fileName);1482 1687 if (eph->checkState() == t_eph::bad) { 1483 1688 if (log) { -
trunk/BNC/src/rinex/reqcedit.h
r11200 r11248 54 54 QVector<t_eph*>& ephs, QTextStream* log, 55 55 bool checkEph); 56 static void appendEphemerides(const QString& fileName, 56 static QVector<QString> nonGenuineRecords(const std::vector<t_eph*>& ephs); 57 static void majorityCheck(const QList<t_rnxNavFile*>& navFiles, 58 QList<QVector<QString> >& removed); 59 static void appendEphemerides(const t_rnxNavFile& rnxNavFile, 60 const QVector<QString>& nonGenuine, 57 61 QVector<t_eph*>& ephs, 58 62 QTextStream* log, bool checkEph);
Note:
See TracChangeset
for help on using the changeset viewer.
