Changeset 11248 in ntrip for trunk/BNC/src/rinex/reqcedit.cpp
- Timestamp:
- Dec 3, 2026, 10:30:57 PM (less than one hour ago)
- File:
-
- 1 edited
-
trunk/BNC/src/rinex/reqcedit.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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) {
Note:
See TracChangeset
for help on using the changeset viewer.
