[3901] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 2007
|
---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: t_reqcEdit
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Edit/Concatenate RINEX Files
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 11-Apr-2012
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iostream>
|
---|
| 42 | #include "reqcedit.h"
|
---|
[5070] | 43 | #include "bnccore.h"
|
---|
[3901] | 44 | #include "bncsettings.h"
|
---|
[4516] | 45 | #include "bncutils.h"
|
---|
[5378] | 46 | #include "rnxobsfile.h"
|
---|
| 47 | #include "rnxnavfile.h"
|
---|
[3901] | 48 |
|
---|
| 49 | using namespace std;
|
---|
| 50 |
|
---|
| 51 | // Constructor
|
---|
| 52 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 53 | t_reqcEdit::t_reqcEdit(QObject* parent) : QThread(parent) {
|
---|
| 54 |
|
---|
| 55 | bncSettings settings;
|
---|
| 56 |
|
---|
[4516] | 57 | _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
|
---|
| 58 | _logFile = 0;
|
---|
| 59 | _log = 0;
|
---|
[3901] | 60 | _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
|
---|
| 61 | _outObsFileName = settings.value("reqcOutObsFile").toString();
|
---|
[3999] | 62 | _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
|
---|
| 63 | _outNavFileName = settings.value("reqcOutNavFile").toString();
|
---|
[4010] | 64 | int version = settings.value("reqcRnxVersion").toInt();
|
---|
| 65 | if (version < 3) {
|
---|
[5378] | 66 | _rnxVersion = t_rnxObsHeader::defaultRnxObsVersion2;
|
---|
[4010] | 67 | }
|
---|
| 68 | else {
|
---|
[5378] | 69 | _rnxVersion = t_rnxObsHeader::defaultRnxObsVersion3;
|
---|
[4010] | 70 | }
|
---|
[3981] | 71 | _samplingRate = settings.value("reqcSampling").toInt();
|
---|
[3989] | 72 | _begTime = bncTime(settings.value("reqcStartDateTime").toString().toAscii().data());
|
---|
| 73 | _endTime = bncTime(settings.value("reqcEndDateTime").toString().toAscii().data());
|
---|
[6898] | 74 |
|
---|
[3901] | 75 | }
|
---|
| 76 |
|
---|
| 77 | // Destructor
|
---|
| 78 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 79 | t_reqcEdit::~t_reqcEdit() {
|
---|
| 80 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 81 | delete _rnxObsFiles[ii];
|
---|
| 82 | }
|
---|
[4001] | 83 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 84 | delete _ephs[ii];
|
---|
| 85 | }
|
---|
[4516] | 86 | delete _log; _log = 0;
|
---|
| 87 | delete _logFile; _logFile = 0;
|
---|
[3901] | 88 | }
|
---|
| 89 |
|
---|
| 90 | //
|
---|
| 91 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 92 | void t_reqcEdit::run() {
|
---|
[3998] | 93 |
|
---|
[4516] | 94 | // Open Log File
|
---|
| 95 | // -------------
|
---|
| 96 | _logFile = new QFile(_logFileName);
|
---|
[4518] | 97 | if (_logFile->open(QIODevice::WriteOnly | QIODevice::Text)) {
|
---|
| 98 | _log = new QTextStream();
|
---|
| 99 | _log->setDevice(_logFile);
|
---|
| 100 | }
|
---|
[4516] | 101 |
|
---|
[4518] | 102 | // Log File Header
|
---|
| 103 | // ---------------
|
---|
| 104 | if (_log) {
|
---|
[4519] | 105 | *_log << QByteArray(78, '-') << endl;
|
---|
[4518] | 106 | *_log << "Concatenation of RINEX Observation and/or Navigation Files\n";
|
---|
[4519] | 107 | *_log << QByteArray(78, '-') << endl;
|
---|
[4520] | 108 |
|
---|
[4523] | 109 | *_log << QByteArray("Program").leftJustified(15) << ": "
|
---|
[5068] | 110 | << BNC_CORE->pgmName() << endl;
|
---|
[4523] | 111 | *_log << QByteArray("Run by").leftJustified(15) << ": "
|
---|
[5068] | 112 | << BNC_CORE->userName() << endl;
|
---|
[4523] | 113 | *_log << QByteArray("Date").leftJustified(15) << ": "
|
---|
[4521] | 114 | << QDateTime::currentDateTime().toUTC().toString("yyyy-MM-dd hh:mm:ss") << endl;
|
---|
[4523] | 115 | *_log << QByteArray("RINEX Version").leftJustified(15) << ": "
|
---|
[4522] | 116 | << _rnxVersion << endl;
|
---|
[4523] | 117 | *_log << QByteArray("Sampling").leftJustified(15) << ": "
|
---|
[4522] | 118 | << _samplingRate << endl;
|
---|
[4523] | 119 | *_log << QByteArray("Start time").leftJustified(15) << ": "
|
---|
[4522] | 120 | << _begTime.datestr().c_str() << ' '
|
---|
| 121 | << _begTime.timestr(0).c_str() << endl;
|
---|
[4523] | 122 | *_log << QByteArray("End time").leftJustified(15) << ": "
|
---|
[4522] | 123 | << _endTime.datestr().c_str() << ' '
|
---|
| 124 | << _endTime.timestr(0).c_str() << endl;
|
---|
[4523] | 125 | *_log << QByteArray("Input Obs Files").leftJustified(15) << ": "
|
---|
| 126 | << _obsFileNames.join(",") << endl;
|
---|
| 127 | *_log << QByteArray("Input Nav Files").leftJustified(15) << ": "
|
---|
| 128 | << _navFileNames.join(",") << endl;
|
---|
| 129 | *_log << QByteArray("Output Obs File").leftJustified(15) << ": "
|
---|
| 130 | << _outObsFileName << endl;
|
---|
| 131 | *_log << QByteArray("Output Nav File").leftJustified(15) << ": "
|
---|
| 132 | << _outNavFileName << endl;
|
---|
[4520] | 133 |
|
---|
| 134 | *_log << QByteArray(78, '-') << endl;
|
---|
[4518] | 135 | _log->flush();
|
---|
| 136 | }
|
---|
| 137 |
|
---|
[4516] | 138 | // Handle Observation Files
|
---|
| 139 | // ------------------------
|
---|
[3998] | 140 | editObservations();
|
---|
[3901] | 141 |
|
---|
[4516] | 142 | // Handle Navigations Files
|
---|
| 143 | // ------------------------
|
---|
[3998] | 144 | editEphemerides();
|
---|
| 145 |
|
---|
[4516] | 146 | // Exit (thread)
|
---|
| 147 | // -------------
|
---|
[5072] | 148 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
[5066] | 149 | qApp->exit(0);
|
---|
[3998] | 150 | }
|
---|
| 151 | else {
|
---|
| 152 | emit finished();
|
---|
| 153 | deleteLater();
|
---|
| 154 | }
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[4254] | 157 | // Initialize input observation files, sort them according to start time
|
---|
[3998] | 158 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4254] | 159 | void t_reqcEdit::initRnxObsFiles(const QStringList& obsFileNames,
|
---|
[4525] | 160 | QVector<t_rnxObsFile*>& rnxObsFiles,
|
---|
| 161 | QTextStream* log) {
|
---|
[3998] | 162 |
|
---|
[4254] | 163 | QStringListIterator it(obsFileNames);
|
---|
[3901] | 164 | while (it.hasNext()) {
|
---|
| 165 | QString fileName = it.next();
|
---|
[4080] | 166 | if (fileName.indexOf('*') != -1 || fileName.indexOf('?') != -1) {
|
---|
| 167 | QFileInfo fileInfo(fileName);
|
---|
| 168 | QDir dir = fileInfo.dir();
|
---|
| 169 | QStringList filters; filters << fileInfo.fileName();
|
---|
| 170 | QListIterator<QFileInfo> it(dir.entryInfoList(filters));
|
---|
| 171 | while (it.hasNext()) {
|
---|
| 172 | QString filePath = it.next().filePath();
|
---|
[4364] | 173 | t_rnxObsFile* rnxObsFile = 0;
|
---|
[4363] | 174 | try {
|
---|
[4364] | 175 | rnxObsFile = new t_rnxObsFile(filePath, t_rnxObsFile::input);
|
---|
[4363] | 176 | rnxObsFiles.append(rnxObsFile);
|
---|
| 177 | }
|
---|
| 178 | catch (...) {
|
---|
[4364] | 179 | delete rnxObsFile;
|
---|
[4525] | 180 | if (log) {
|
---|
| 181 | *log << "Error in rnxObsFile " << filePath.toAscii().data() << endl;
|
---|
| 182 | }
|
---|
[4363] | 183 | }
|
---|
[4080] | 184 | }
|
---|
| 185 | }
|
---|
| 186 | else {
|
---|
[4364] | 187 | t_rnxObsFile* rnxObsFile = 0;
|
---|
[4363] | 188 | try {
|
---|
[4364] | 189 | rnxObsFile = new t_rnxObsFile(fileName, t_rnxObsFile::input);
|
---|
[4363] | 190 | rnxObsFiles.append(rnxObsFile);
|
---|
| 191 | }
|
---|
| 192 | catch (...) {
|
---|
[4525] | 193 | if (log) {
|
---|
| 194 | *log << "Error in rnxObsFile " << fileName.toAscii().data() << endl;
|
---|
| 195 | }
|
---|
[4363] | 196 | }
|
---|
[4080] | 197 | }
|
---|
[3901] | 198 | }
|
---|
[4254] | 199 | qStableSort(rnxObsFiles.begin(), rnxObsFiles.end(),
|
---|
[3901] | 200 | t_rnxObsFile::earlierStartTime);
|
---|
[4254] | 201 | }
|
---|
[3901] | 202 |
|
---|
[4254] | 203 | //
|
---|
| 204 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 205 | void t_reqcEdit::editObservations() {
|
---|
| 206 |
|
---|
| 207 | // Easy Exit
|
---|
| 208 | // ---------
|
---|
| 209 | if (_obsFileNames.isEmpty() || _outObsFileName.isEmpty()) {
|
---|
| 210 | return;
|
---|
| 211 | }
|
---|
| 212 |
|
---|
[4525] | 213 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
|
---|
[4254] | 214 |
|
---|
[3901] | 215 | // Initialize output observation file
|
---|
| 216 | // ----------------------------------
|
---|
| 217 | t_rnxObsFile outObsFile(_outObsFileName, t_rnxObsFile::output);
|
---|
| 218 |
|
---|
[6118] | 219 | // Select observation types
|
---|
| 220 | // ------------------------
|
---|
| 221 | bncSettings settings;
|
---|
| 222 | QStringList useObsTypes = settings.value("reqcUseObsTypes").toString().split(" ", QString::SkipEmptyParts);
|
---|
| 223 |
|
---|
[6130] | 224 | // Put together all observation types
|
---|
| 225 | // ----------------------------------
|
---|
| 226 | if (_rnxObsFiles.size() > 1 && useObsTypes.size() == 0) {
|
---|
| 227 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 228 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 229 | for (int iSys = 0; iSys < obsFile->numSys(); iSys++) {
|
---|
| 230 | char sys = obsFile->system(iSys);
|
---|
| 231 | if (sys != ' ') {
|
---|
[6131] | 232 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
| 233 | QString type = obsFile->obsType(sys, iType);
|
---|
[6132] | 234 | if (_rnxVersion < 3.0) {
|
---|
| 235 | useObsTypes << type;
|
---|
| 236 | }
|
---|
| 237 | else {
|
---|
| 238 | useObsTypes << QString(sys) + ":" + type;
|
---|
| 239 | }
|
---|
[6131] | 240 | }
|
---|
[6130] | 241 | }
|
---|
| 242 | }
|
---|
| 243 | }
|
---|
[6132] | 244 | useObsTypes.removeDuplicates();
|
---|
[6130] | 245 | }
|
---|
| 246 |
|
---|
[6841] | 247 | // Put together all phase shifts
|
---|
| 248 | // -----------------------------
|
---|
| 249 | QStringList phaseShifts;
|
---|
| 250 | if (_rnxVersion >= 3.0 && _rnxObsFiles.size() > 1) {
|
---|
| 251 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 252 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 253 | phaseShifts << obsFile->phaseShifts();
|
---|
| 254 | }
|
---|
| 255 | phaseShifts.removeDuplicates();
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | // Put together all GLONASS biases
|
---|
| 259 | // -------------------------------
|
---|
| 260 | QStringList gloBiases;
|
---|
| 261 | if (_rnxVersion >= 3.0 && _rnxObsFiles.size() > 1) {
|
---|
| 262 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 263 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 264 | if (ii == 0 && obsFile->numGloBiases() == 4) {
|
---|
| 265 | break;
|
---|
| 266 | }
|
---|
| 267 | else {
|
---|
| 268 | gloBiases << obsFile->gloBiases();
|
---|
| 269 | }
|
---|
| 270 | }
|
---|
| 271 | gloBiases.removeDuplicates();
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | // Put together all GLONASS slots
|
---|
| 275 | // -----------------------------
|
---|
| 276 | QStringList gloSlots;
|
---|
| 277 | if (_rnxVersion >= 3.0 && _rnxObsFiles.size() > 1) {
|
---|
| 278 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 279 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 280 | if (ii == 0 &&
|
---|
| 281 | obsFile->numGloSlots() == signed(t_prn::MAXPRN_GLONASS)) {
|
---|
| 282 | break;
|
---|
| 283 | }
|
---|
| 284 | else {
|
---|
| 285 | gloSlots << obsFile->gloSlots();
|
---|
| 286 | }
|
---|
| 287 | }
|
---|
| 288 | gloSlots.removeDuplicates();
|
---|
| 289 | }
|
---|
| 290 |
|
---|
[3901] | 291 | // Loop over all input observation files
|
---|
| 292 | // -------------------------------------
|
---|
| 293 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 294 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
[4524] | 295 | if (_log) {
|
---|
| 296 | *_log << "Processing File: " << obsFile->fileName() << " start: "
|
---|
| 297 | << obsFile->startTime().datestr().c_str() << ' '
|
---|
| 298 | << obsFile->startTime().timestr(0).c_str() << endl;
|
---|
| 299 | }
|
---|
[3901] | 300 | if (ii == 0) {
|
---|
[6841] | 301 | outObsFile.setHeader(obsFile->header(), int(_rnxVersion), &useObsTypes,
|
---|
| 302 | &phaseShifts, &gloBiases, &gloSlots);
|
---|
[3992] | 303 | if (_begTime.valid() && _begTime > outObsFile.startTime()) {
|
---|
| 304 | outObsFile.setStartTime(_begTime);
|
---|
| 305 | }
|
---|
[4112] | 306 | if (_samplingRate > outObsFile.interval()) {
|
---|
| 307 | outObsFile.setInterval(_samplingRate);
|
---|
| 308 | }
|
---|
[3982] | 309 | editRnxObsHeader(outObsFile);
|
---|
[4117] | 310 | bncSettings settings;
|
---|
[4114] | 311 | QMap<QString, QString> txtMap;
|
---|
[4117] | 312 | QString runBy = settings.value("reqcRunBy").toString();
|
---|
| 313 | if (!runBy.isEmpty()) {
|
---|
| 314 | txtMap["RUN BY"] = runBy;
|
---|
| 315 | }
|
---|
| 316 | QString comment = settings.value("reqcComment").toString();
|
---|
| 317 | if (!comment.isEmpty()) {
|
---|
| 318 | txtMap["COMMENT"] = comment;
|
---|
| 319 | }
|
---|
[4514] | 320 | outObsFile.header().write(outObsFile.stream(), &txtMap);
|
---|
[3901] | 321 | }
|
---|
[3994] | 322 | t_rnxObsFile::t_rnxEpo* epo = 0;
|
---|
[4541] | 323 | try {
|
---|
| 324 | while ( (epo = obsFile->nextEpoch()) != 0) {
|
---|
| 325 | if (_begTime.valid() && epo->tt < _begTime) {
|
---|
| 326 | continue;
|
---|
| 327 | }
|
---|
| 328 | if (_endTime.valid() && epo->tt > _endTime) {
|
---|
| 329 | break;
|
---|
| 330 | }
|
---|
| 331 |
|
---|
| 332 | if (_samplingRate == 0 ||
|
---|
| 333 | fmod(round(epo->tt.gpssec()), _samplingRate) == 0) {
|
---|
| 334 | applyLLI(obsFile, epo);
|
---|
| 335 | outObsFile.writeEpoch(epo);
|
---|
| 336 | }
|
---|
| 337 | else {
|
---|
| 338 | rememberLLI(obsFile, epo);
|
---|
| 339 | }
|
---|
[3993] | 340 | }
|
---|
[4541] | 341 | }
|
---|
| 342 | catch (QString str) {
|
---|
| 343 | if (_log) {
|
---|
| 344 | *_log << "Exception " << str << endl;
|
---|
[3993] | 345 | }
|
---|
[3994] | 346 | else {
|
---|
[4541] | 347 | qDebug() << str;
|
---|
[3994] | 348 | }
|
---|
[4541] | 349 | return;
|
---|
[3901] | 350 | }
|
---|
[6130] | 351 | catch (...) {
|
---|
| 352 | if (_log) {
|
---|
| 353 | *_log << "Exception unknown" << endl;
|
---|
| 354 | }
|
---|
| 355 | else {
|
---|
| 356 | qDebug() << "Exception unknown";
|
---|
| 357 | }
|
---|
| 358 | return;
|
---|
| 359 | }
|
---|
[3901] | 360 | }
|
---|
| 361 | }
|
---|
[3982] | 362 |
|
---|
| 363 | // Change RINEX Header Content
|
---|
| 364 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3985] | 365 | void t_reqcEdit::editRnxObsHeader(t_rnxObsFile& obsFile) {
|
---|
[3982] | 366 |
|
---|
[3983] | 367 | bncSettings settings;
|
---|
| 368 |
|
---|
| 369 | QString oldMarkerName = settings.value("reqcOldMarkerName").toString();
|
---|
| 370 | QString newMarkerName = settings.value("reqcNewMarkerName").toString();
|
---|
[4090] | 371 | if (!newMarkerName.isEmpty()) {
|
---|
| 372 | if (oldMarkerName.isEmpty() ||
|
---|
| 373 | QRegExp(oldMarkerName).exactMatch(obsFile.markerName())) {
|
---|
| 374 | obsFile.setMarkerName(newMarkerName);
|
---|
| 375 | }
|
---|
[3985] | 376 | }
|
---|
| 377 |
|
---|
[3983] | 378 | QString oldAntennaName = settings.value("reqcOldAntennaName").toString();
|
---|
| 379 | QString newAntennaName = settings.value("reqcNewAntennaName").toString();
|
---|
[4090] | 380 | if (!newAntennaName.isEmpty()) {
|
---|
| 381 | if (oldAntennaName.isEmpty() ||
|
---|
| 382 | QRegExp(oldAntennaName).exactMatch(obsFile.antennaName())) {
|
---|
| 383 | obsFile.setAntennaName(newAntennaName);
|
---|
| 384 | }
|
---|
[3985] | 385 | }
|
---|
[3983] | 386 |
|
---|
[6795] | 387 | QString oldAntennaNumber = settings.value("reqcOldAntennaNumber").toString();
|
---|
| 388 | QString newAntennaNumber = settings.value("reqcNewAntennaNumber").toString();
|
---|
| 389 | if (!newAntennaNumber.isEmpty()) {
|
---|
| 390 | if (oldAntennaNumber.isEmpty() ||
|
---|
| 391 | QRegExp(oldAntennaNumber).exactMatch(obsFile.antennaNumber())) {
|
---|
| 392 | obsFile.setAntennaNumber(newAntennaNumber);
|
---|
| 393 | }
|
---|
| 394 | }
|
---|
| 395 |
|
---|
| 396 |
|
---|
| 397 | const ColumnVector& obsFileAntNEU = obsFile.antNEU();
|
---|
| 398 | QString oldAntennadN = settings.value("reqcOldAntennadN").toString();
|
---|
| 399 | QString newAntennadN = settings.value("reqcNewAntennadN").toString();
|
---|
| 400 | if(!newAntennadN.isEmpty()) {
|
---|
| 401 | if (oldAntennadN.isEmpty() ||
|
---|
| 402 | oldAntennadN.toDouble() == obsFileAntNEU(1)) {
|
---|
| 403 | obsFile.setAntennaN(newAntennadN.toDouble());
|
---|
| 404 | }
|
---|
| 405 | }
|
---|
| 406 | QString oldAntennadE = settings.value("reqcOldAntennadE").toString();
|
---|
| 407 | QString newAntennadE = settings.value("reqcNewAntennadE").toString();
|
---|
| 408 | if(!newAntennadE.isEmpty()) {
|
---|
| 409 | if (oldAntennadE.isEmpty() ||
|
---|
| 410 | oldAntennadE.toDouble() == obsFileAntNEU(2)) {
|
---|
| 411 | obsFile.setAntennaE(newAntennadE.toDouble());
|
---|
| 412 | }
|
---|
| 413 | }
|
---|
| 414 | QString oldAntennadU = settings.value("reqcOldAntennadU").toString();
|
---|
| 415 | QString newAntennadU = settings.value("reqcNewAntennadU").toString();
|
---|
| 416 | if(!newAntennadU.isEmpty()) {
|
---|
| 417 | if (oldAntennadU.isEmpty() ||
|
---|
| 418 | oldAntennadU.toDouble() == obsFileAntNEU(3)) {
|
---|
| 419 | obsFile.setAntennaU(newAntennadU.toDouble());
|
---|
| 420 | }
|
---|
| 421 | }
|
---|
| 422 |
|
---|
[3985] | 423 | QString oldReceiverType = settings.value("reqcOldReceiverName").toString();
|
---|
| 424 | QString newReceiverType = settings.value("reqcNewReceiverName").toString();
|
---|
[4090] | 425 | if (!newReceiverType.isEmpty()) {
|
---|
| 426 | if (oldReceiverType.isEmpty() ||
|
---|
| 427 | QRegExp(oldReceiverType).exactMatch(obsFile.receiverType())) {
|
---|
| 428 | obsFile.setReceiverType(newReceiverType);
|
---|
| 429 | }
|
---|
[3985] | 430 | }
|
---|
[6795] | 431 |
|
---|
| 432 | QString oldReceiverNumber = settings.value("reqcOldReceiverNumber").toString();
|
---|
| 433 | QString newReceiverNumber = settings.value("reqcNewReceiverNumber").toString();
|
---|
| 434 | if (!newReceiverNumber.isEmpty()) {
|
---|
| 435 | if (oldReceiverNumber.isEmpty() ||
|
---|
| 436 | QRegExp(oldReceiverNumber).exactMatch(obsFile.receiverNumber())) {
|
---|
| 437 | obsFile.setReceiverNumber(newReceiverNumber);
|
---|
| 438 | }
|
---|
| 439 | }
|
---|
[3982] | 440 | }
|
---|
[3994] | 441 |
|
---|
| 442 | //
|
---|
| 443 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3995] | 444 | void t_reqcEdit::rememberLLI(const t_rnxObsFile* obsFile,
|
---|
| 445 | const t_rnxObsFile::t_rnxEpo* epo) {
|
---|
[3994] | 446 |
|
---|
[3995] | 447 | if (_samplingRate == 0) {
|
---|
| 448 | return;
|
---|
| 449 | }
|
---|
| 450 |
|
---|
| 451 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 452 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
[6121] | 453 | char sys = rnxSat.prn.system();
|
---|
| 454 | QString prn(rnxSat.prn.toString().c_str());
|
---|
[3997] | 455 |
|
---|
[3995] | 456 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
[6121] | 457 | QString type = obsFile->obsType(sys, iType);
|
---|
[3997] | 458 | if (!_lli[prn].contains(iType)) {
|
---|
| 459 | _lli[prn][iType] = 0;
|
---|
[3996] | 460 | }
|
---|
[6121] | 461 | if (rnxSat.obs.contains(type) && rnxSat.obs[type].lli & 1) {
|
---|
[3997] | 462 | _lli[prn][iType] |= 1;
|
---|
[3996] | 463 | }
|
---|
[3995] | 464 | }
|
---|
| 465 | }
|
---|
[3994] | 466 | }
|
---|
| 467 |
|
---|
| 468 | //
|
---|
| 469 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3995] | 470 | void t_reqcEdit::applyLLI(const t_rnxObsFile* obsFile,
|
---|
| 471 | t_rnxObsFile::t_rnxEpo* epo) {
|
---|
[3996] | 472 |
|
---|
| 473 | if (_samplingRate == 0) {
|
---|
[3995] | 474 | return;
|
---|
| 475 | }
|
---|
[3996] | 476 |
|
---|
| 477 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 478 | t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
[6121] | 479 | char sys = rnxSat.prn.system();
|
---|
| 480 | QString prn(rnxSat.prn.toString().c_str());
|
---|
[3997] | 481 |
|
---|
[3996] | 482 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
[6121] | 483 | QString type = obsFile->obsType(sys, iType);
|
---|
[3997] | 484 | if (_lli[prn].contains(iType) && _lli[prn][iType] & 1) {
|
---|
[6121] | 485 | if (rnxSat.obs.contains(type)) {
|
---|
| 486 | rnxSat.obs[type].lli |= 1;
|
---|
| 487 | }
|
---|
[3996] | 488 | }
|
---|
| 489 | }
|
---|
| 490 | }
|
---|
| 491 |
|
---|
| 492 | _lli.clear();
|
---|
[3994] | 493 | }
|
---|
[3998] | 494 |
|
---|
[4256] | 495 | /// Read All Ephemerides
|
---|
[3998] | 496 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4256] | 497 | void t_reqcEdit::readEphemerides(const QStringList& navFileNames,
|
---|
| 498 | QVector<t_eph*>& ephs) {
|
---|
[3998] | 499 |
|
---|
[4256] | 500 | QStringListIterator it(navFileNames);
|
---|
[3999] | 501 | while (it.hasNext()) {
|
---|
| 502 | QString fileName = it.next();
|
---|
[4081] | 503 | if (fileName.indexOf('*') != -1 || fileName.indexOf('?') != -1) {
|
---|
| 504 | QFileInfo fileInfo(fileName);
|
---|
| 505 | QDir dir = fileInfo.dir();
|
---|
| 506 | QStringList filters; filters << fileInfo.fileName();
|
---|
| 507 | QListIterator<QFileInfo> it(dir.entryInfoList(filters));
|
---|
| 508 | while (it.hasNext()) {
|
---|
| 509 | QString filePath = it.next().filePath();
|
---|
[4256] | 510 | appendEphemerides(filePath, ephs);
|
---|
[4000] | 511 | }
|
---|
| 512 | }
|
---|
[4081] | 513 | else {
|
---|
[4256] | 514 | appendEphemerides(fileName, ephs);
|
---|
[4081] | 515 | }
|
---|
[3999] | 516 | }
|
---|
[4256] | 517 | qStableSort(ephs.begin(), ephs.end(), t_eph::earlierTime);
|
---|
| 518 | }
|
---|
[3999] | 519 |
|
---|
[4256] | 520 | //
|
---|
| 521 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 522 | void t_reqcEdit::editEphemerides() {
|
---|
| 523 |
|
---|
| 524 | // Easy Exit
|
---|
| 525 | // ---------
|
---|
| 526 | if (_navFileNames.isEmpty() || _outNavFileName.isEmpty()) {
|
---|
| 527 | return;
|
---|
| 528 | }
|
---|
| 529 |
|
---|
[4257] | 530 | // Read Ephemerides
|
---|
| 531 | // ----------------
|
---|
[4256] | 532 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
| 533 |
|
---|
[4229] | 534 | // Check Satellite Systems
|
---|
| 535 | // -----------------------
|
---|
| 536 | bool haveGPS = false;
|
---|
| 537 | bool haveGlonass = false;
|
---|
| 538 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 539 | const t_eph* eph = _ephs[ii];
|
---|
| 540 | if (eph->type() == t_eph::GPS) {
|
---|
| 541 | haveGPS = true;
|
---|
| 542 | }
|
---|
| 543 | else if (eph->type() == t_eph::GLONASS) {
|
---|
| 544 | haveGlonass = true;
|
---|
| 545 | }
|
---|
| 546 | }
|
---|
| 547 |
|
---|
[4007] | 548 | // Initialize output navigation file
|
---|
| 549 | // ---------------------------------
|
---|
[4004] | 550 | t_rnxNavFile outNavFile(_outNavFileName, t_rnxNavFile::output);
|
---|
[4229] | 551 |
|
---|
| 552 | outNavFile.setGlonass(haveGlonass);
|
---|
| 553 |
|
---|
[5378] | 554 | if ( (haveGPS && haveGlonass) || _rnxVersion >= 3.0) {
|
---|
| 555 | outNavFile.setVersion(t_rnxNavFile::defaultRnxNavVersion3);
|
---|
[4229] | 556 | }
|
---|
| 557 | else {
|
---|
[5378] | 558 | outNavFile.setVersion(t_rnxNavFile::defaultRnxNavVersion2);
|
---|
[4229] | 559 | }
|
---|
| 560 |
|
---|
[4221] | 561 | bncSettings settings;
|
---|
| 562 | QMap<QString, QString> txtMap;
|
---|
| 563 | QString runBy = settings.value("reqcRunBy").toString();
|
---|
| 564 | if (!runBy.isEmpty()) {
|
---|
| 565 | txtMap["RUN BY"] = runBy;
|
---|
| 566 | }
|
---|
| 567 | QString comment = settings.value("reqcComment").toString();
|
---|
| 568 | if (!comment.isEmpty()) {
|
---|
| 569 | txtMap["COMMENT"] = comment;
|
---|
| 570 | }
|
---|
[4229] | 571 |
|
---|
[4221] | 572 | outNavFile.writeHeader(&txtMap);
|
---|
[4009] | 573 |
|
---|
[4004] | 574 | // Loop over all ephemerides
|
---|
| 575 | // -------------------------
|
---|
| 576 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 577 | const t_eph* eph = _ephs[ii];
|
---|
[6954] | 578 | bncTime begTime = _begTime;
|
---|
| 579 | bncTime endTime = _endTime;
|
---|
| 580 | if (eph->type() == t_eph::BDS) {
|
---|
| 581 | begTime += 14;
|
---|
| 582 | endTime += 14;
|
---|
| 583 | }
|
---|
| 584 | if (begTime.valid() && eph->TOC() < begTime) {
|
---|
[6898] | 585 | continue;
|
---|
| 586 | }
|
---|
[6954] | 587 | if (endTime.valid() && eph->TOC() > endTime) {
|
---|
[6898] | 588 | break;
|
---|
| 589 | }
|
---|
[4229] | 590 | outNavFile.writeEph(eph);
|
---|
[4004] | 591 | }
|
---|
[3998] | 592 | }
|
---|
[4081] | 593 |
|
---|
| 594 | //
|
---|
| 595 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4256] | 596 | void t_reqcEdit::appendEphemerides(const QString& fileName,
|
---|
| 597 | QVector<t_eph*>& ephs) {
|
---|
[4081] | 598 |
|
---|
| 599 | t_rnxNavFile rnxNavFile(fileName, t_rnxNavFile::input);
|
---|
| 600 | for (unsigned ii = 0; ii < rnxNavFile.ephs().size(); ii++) {
|
---|
| 601 | t_eph* eph = rnxNavFile.ephs()[ii];
|
---|
| 602 | bool isNew = true;
|
---|
[4256] | 603 | for (int iOld = 0; iOld < ephs.size(); iOld++) {
|
---|
| 604 | const t_eph* ephOld = ephs[iOld];
|
---|
[6804] | 605 | if (ephOld->prn() == eph->prn() &&
|
---|
[6809] | 606 | ephOld->TOC() == eph->TOC()) {
|
---|
[4081] | 607 | isNew = false;
|
---|
| 608 | break;
|
---|
| 609 | }
|
---|
| 610 | }
|
---|
| 611 | if (isNew) {
|
---|
| 612 | if (eph->type() == t_eph::GPS) {
|
---|
[4256] | 613 | ephs.append(new t_ephGPS(*dynamic_cast<t_ephGPS*>(eph)));
|
---|
[4081] | 614 | }
|
---|
| 615 | else if (eph->type() == t_eph::GLONASS) {
|
---|
[4256] | 616 | ephs.append(new t_ephGlo(*dynamic_cast<t_ephGlo*>(eph)));
|
---|
[4081] | 617 | }
|
---|
| 618 | else if (eph->type() == t_eph::Galileo) {
|
---|
[4256] | 619 | ephs.append(new t_ephGal(*dynamic_cast<t_ephGal*>(eph)));
|
---|
[4081] | 620 | }
|
---|
[6377] | 621 | else if (eph->type() == t_eph::QZSS) {
|
---|
| 622 | ephs.append(new t_ephGPS(*dynamic_cast<t_ephGPS*>(eph)));
|
---|
| 623 | }
|
---|
[6391] | 624 | else if (eph->type() == t_eph::SBAS) {
|
---|
| 625 | ephs.append(new t_ephSBAS(*dynamic_cast<t_ephSBAS*>(eph)));
|
---|
| 626 | }
|
---|
[6602] | 627 | else if (eph->type() == t_eph::BDS) {
|
---|
[6600] | 628 | ephs.append(new t_ephBDS(*dynamic_cast<t_ephBDS*>(eph)));
|
---|
[6402] | 629 | }
|
---|
[4081] | 630 | }
|
---|
| 631 | }
|
---|
| 632 | }
|
---|