[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 | *
|
---|
[7474] | 37 | * Changes:
|
---|
[3901] | 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 |
|
---|
[7474] | 90 | //
|
---|
[3901] | 91 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 92 | void t_reqcEdit::run() {
|
---|
[7474] | 93 |
|
---|
[4516] | 94 | // Open Log File
|
---|
| 95 | // -------------
|
---|
[7280] | 96 | if (!_logFileName.isEmpty()) {
|
---|
| 97 | _logFile = new QFile(_logFileName);
|
---|
| 98 | if (_logFile->open(QIODevice::WriteOnly | QIODevice::Text)) {
|
---|
| 99 | _log = new QTextStream();
|
---|
| 100 | _log->setDevice(_logFile);
|
---|
| 101 | }
|
---|
[4518] | 102 | }
|
---|
[4516] | 103 |
|
---|
[4518] | 104 | // Log File Header
|
---|
| 105 | // ---------------
|
---|
| 106 | if (_log) {
|
---|
[4519] | 107 | *_log << QByteArray(78, '-') << endl;
|
---|
[7993] | 108 | *_log << "RINEX File Editing\n";
|
---|
[4519] | 109 | *_log << QByteArray(78, '-') << endl;
|
---|
[4520] | 110 |
|
---|
[4523] | 111 | *_log << QByteArray("Program").leftJustified(15) << ": "
|
---|
[5068] | 112 | << BNC_CORE->pgmName() << endl;
|
---|
[4523] | 113 | *_log << QByteArray("Run by").leftJustified(15) << ": "
|
---|
[5068] | 114 | << BNC_CORE->userName() << endl;
|
---|
[4523] | 115 | *_log << QByteArray("Date").leftJustified(15) << ": "
|
---|
[4521] | 116 | << QDateTime::currentDateTime().toUTC().toString("yyyy-MM-dd hh:mm:ss") << endl;
|
---|
[4523] | 117 | *_log << QByteArray("RINEX Version").leftJustified(15) << ": "
|
---|
[4522] | 118 | << _rnxVersion << endl;
|
---|
[4523] | 119 | *_log << QByteArray("Sampling").leftJustified(15) << ": "
|
---|
[4522] | 120 | << _samplingRate << endl;
|
---|
[4523] | 121 | *_log << QByteArray("Start time").leftJustified(15) << ": "
|
---|
[7474] | 122 | << _begTime.datestr().c_str() << ' '
|
---|
[4522] | 123 | << _begTime.timestr(0).c_str() << endl;
|
---|
[4523] | 124 | *_log << QByteArray("End time").leftJustified(15) << ": "
|
---|
[7474] | 125 | << _endTime.datestr().c_str() << ' '
|
---|
[4522] | 126 | << _endTime.timestr(0).c_str() << endl;
|
---|
[4523] | 127 | *_log << QByteArray("Input Obs Files").leftJustified(15) << ": "
|
---|
| 128 | << _obsFileNames.join(",") << endl;
|
---|
| 129 | *_log << QByteArray("Input Nav Files").leftJustified(15) << ": "
|
---|
| 130 | << _navFileNames.join(",") << endl;
|
---|
| 131 | *_log << QByteArray("Output Obs File").leftJustified(15) << ": "
|
---|
| 132 | << _outObsFileName << endl;
|
---|
| 133 | *_log << QByteArray("Output Nav File").leftJustified(15) << ": "
|
---|
| 134 | << _outNavFileName << endl;
|
---|
[4520] | 135 |
|
---|
| 136 | *_log << QByteArray(78, '-') << endl;
|
---|
[4518] | 137 | _log->flush();
|
---|
| 138 | }
|
---|
| 139 |
|
---|
[4516] | 140 | // Handle Observation Files
|
---|
| 141 | // ------------------------
|
---|
[3998] | 142 | editObservations();
|
---|
[3901] | 143 |
|
---|
[4516] | 144 | // Handle Navigations Files
|
---|
| 145 | // ------------------------
|
---|
[3998] | 146 | editEphemerides();
|
---|
| 147 |
|
---|
[4516] | 148 | // Exit (thread)
|
---|
| 149 | // -------------
|
---|
[5072] | 150 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
[5066] | 151 | qApp->exit(0);
|
---|
[7941] | 152 | msleep(100); //sleep 0.1 sec
|
---|
[3998] | 153 | }
|
---|
| 154 | else {
|
---|
| 155 | emit finished();
|
---|
| 156 | deleteLater();
|
---|
| 157 | }
|
---|
| 158 | }
|
---|
| 159 |
|
---|
[4254] | 160 | // Initialize input observation files, sort them according to start time
|
---|
[3998] | 161 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7474] | 162 | void t_reqcEdit::initRnxObsFiles(const QStringList& obsFileNames,
|
---|
[4525] | 163 | QVector<t_rnxObsFile*>& rnxObsFiles,
|
---|
| 164 | QTextStream* log) {
|
---|
[3998] | 165 |
|
---|
[4254] | 166 | QStringListIterator it(obsFileNames);
|
---|
[3901] | 167 | while (it.hasNext()) {
|
---|
| 168 | QString fileName = it.next();
|
---|
[4080] | 169 | if (fileName.indexOf('*') != -1 || fileName.indexOf('?') != -1) {
|
---|
| 170 | QFileInfo fileInfo(fileName);
|
---|
| 171 | QDir dir = fileInfo.dir();
|
---|
| 172 | QStringList filters; filters << fileInfo.fileName();
|
---|
| 173 | QListIterator<QFileInfo> it(dir.entryInfoList(filters));
|
---|
| 174 | while (it.hasNext()) {
|
---|
[7474] | 175 | QString filePath = it.next().filePath();
|
---|
[4364] | 176 | t_rnxObsFile* rnxObsFile = 0;
|
---|
[4363] | 177 | try {
|
---|
[4364] | 178 | rnxObsFile = new t_rnxObsFile(filePath, t_rnxObsFile::input);
|
---|
[4363] | 179 | rnxObsFiles.append(rnxObsFile);
|
---|
| 180 | }
|
---|
| 181 | catch (...) {
|
---|
[4364] | 182 | delete rnxObsFile;
|
---|
[4525] | 183 | if (log) {
|
---|
| 184 | *log << "Error in rnxObsFile " << filePath.toAscii().data() << endl;
|
---|
| 185 | }
|
---|
[4363] | 186 | }
|
---|
[4080] | 187 | }
|
---|
| 188 | }
|
---|
| 189 | else {
|
---|
[4364] | 190 | t_rnxObsFile* rnxObsFile = 0;
|
---|
[4363] | 191 | try {
|
---|
[4364] | 192 | rnxObsFile = new t_rnxObsFile(fileName, t_rnxObsFile::input);
|
---|
[4363] | 193 | rnxObsFiles.append(rnxObsFile);
|
---|
| 194 | }
|
---|
| 195 | catch (...) {
|
---|
[4525] | 196 | if (log) {
|
---|
| 197 | *log << "Error in rnxObsFile " << fileName.toAscii().data() << endl;
|
---|
| 198 | }
|
---|
[4363] | 199 | }
|
---|
[4080] | 200 | }
|
---|
[3901] | 201 | }
|
---|
[7474] | 202 | qStableSort(rnxObsFiles.begin(), rnxObsFiles.end(),
|
---|
[3901] | 203 | t_rnxObsFile::earlierStartTime);
|
---|
[4254] | 204 | }
|
---|
[3901] | 205 |
|
---|
[7474] | 206 | //
|
---|
[4254] | 207 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 208 | void t_reqcEdit::editObservations() {
|
---|
| 209 |
|
---|
| 210 | // Easy Exit
|
---|
| 211 | // ---------
|
---|
| 212 | if (_obsFileNames.isEmpty() || _outObsFileName.isEmpty()) {
|
---|
| 213 | return;
|
---|
| 214 | }
|
---|
| 215 |
|
---|
[4525] | 216 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
|
---|
[4254] | 217 |
|
---|
[3901] | 218 | // Initialize output observation file
|
---|
| 219 | // ----------------------------------
|
---|
| 220 | t_rnxObsFile outObsFile(_outObsFileName, t_rnxObsFile::output);
|
---|
[7474] | 221 |
|
---|
[6118] | 222 | // Select observation types
|
---|
| 223 | // ------------------------
|
---|
| 224 | bncSettings settings;
|
---|
| 225 | QStringList useObsTypes = settings.value("reqcUseObsTypes").toString().split(" ", QString::SkipEmptyParts);
|
---|
| 226 |
|
---|
[6130] | 227 | // Put together all observation types
|
---|
| 228 | // ----------------------------------
|
---|
| 229 | if (_rnxObsFiles.size() > 1 && useObsTypes.size() == 0) {
|
---|
| 230 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 231 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 232 | for (int iSys = 0; iSys < obsFile->numSys(); iSys++) {
|
---|
| 233 | char sys = obsFile->system(iSys);
|
---|
| 234 | if (sys != ' ') {
|
---|
[6131] | 235 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
| 236 | QString type = obsFile->obsType(sys, iType);
|
---|
[6132] | 237 | if (_rnxVersion < 3.0) {
|
---|
| 238 | useObsTypes << type;
|
---|
| 239 | }
|
---|
| 240 | else {
|
---|
| 241 | useObsTypes << QString(sys) + ":" + type;
|
---|
| 242 | }
|
---|
[6131] | 243 | }
|
---|
[6130] | 244 | }
|
---|
| 245 | }
|
---|
| 246 | }
|
---|
[6132] | 247 | useObsTypes.removeDuplicates();
|
---|
[6130] | 248 | }
|
---|
| 249 |
|
---|
[6841] | 250 | // Put together all phase shifts
|
---|
| 251 | // -----------------------------
|
---|
| 252 | QStringList phaseShifts;
|
---|
| 253 | if (_rnxVersion >= 3.0 && _rnxObsFiles.size() > 1) {
|
---|
| 254 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 255 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 256 | phaseShifts << obsFile->phaseShifts();
|
---|
| 257 | }
|
---|
| 258 | phaseShifts.removeDuplicates();
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | // Put together all GLONASS biases
|
---|
| 262 | // -------------------------------
|
---|
| 263 | QStringList gloBiases;
|
---|
| 264 | if (_rnxVersion >= 3.0 && _rnxObsFiles.size() > 1) {
|
---|
| 265 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 266 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 267 | if (ii == 0 && obsFile->numGloBiases() == 4) {
|
---|
| 268 | break;
|
---|
| 269 | }
|
---|
| 270 | else {
|
---|
| 271 | gloBiases << obsFile->gloBiases();
|
---|
| 272 | }
|
---|
| 273 | }
|
---|
| 274 | gloBiases.removeDuplicates();
|
---|
| 275 | }
|
---|
| 276 |
|
---|
| 277 | // Put together all GLONASS slots
|
---|
| 278 | // -----------------------------
|
---|
| 279 | QStringList gloSlots;
|
---|
| 280 | if (_rnxVersion >= 3.0 && _rnxObsFiles.size() > 1) {
|
---|
| 281 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 282 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 283 | if (ii == 0 &&
|
---|
| 284 | obsFile->numGloSlots() == signed(t_prn::MAXPRN_GLONASS)) {
|
---|
| 285 | break;
|
---|
| 286 | }
|
---|
| 287 | else {
|
---|
| 288 | gloSlots << obsFile->gloSlots();
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 | gloSlots.removeDuplicates();
|
---|
| 292 | }
|
---|
| 293 |
|
---|
[3901] | 294 | // Loop over all input observation files
|
---|
| 295 | // -------------------------------------
|
---|
| 296 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 297 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
[4524] | 298 | if (_log) {
|
---|
[7474] | 299 | *_log << "Processing File: " << obsFile->fileName() << " start: "
|
---|
| 300 | << obsFile->startTime().datestr().c_str() << ' '
|
---|
[4524] | 301 | << obsFile->startTime().timestr(0).c_str() << endl;
|
---|
| 302 | }
|
---|
[3901] | 303 | if (ii == 0) {
|
---|
[6841] | 304 | outObsFile.setHeader(obsFile->header(), int(_rnxVersion), &useObsTypes,
|
---|
| 305 | &phaseShifts, &gloBiases, &gloSlots);
|
---|
[3992] | 306 | if (_begTime.valid() && _begTime > outObsFile.startTime()) {
|
---|
| 307 | outObsFile.setStartTime(_begTime);
|
---|
| 308 | }
|
---|
[4112] | 309 | if (_samplingRate > outObsFile.interval()) {
|
---|
| 310 | outObsFile.setInterval(_samplingRate);
|
---|
| 311 | }
|
---|
[3982] | 312 | editRnxObsHeader(outObsFile);
|
---|
[4117] | 313 | bncSettings settings;
|
---|
[4114] | 314 | QMap<QString, QString> txtMap;
|
---|
[4117] | 315 | QString runBy = settings.value("reqcRunBy").toString();
|
---|
| 316 | if (!runBy.isEmpty()) {
|
---|
| 317 | txtMap["RUN BY"] = runBy;
|
---|
| 318 | }
|
---|
| 319 | QString comment = settings.value("reqcComment").toString();
|
---|
| 320 | if (!comment.isEmpty()) {
|
---|
| 321 | txtMap["COMMENT"] = comment;
|
---|
| 322 | }
|
---|
[7474] | 323 | if (int(_rnxVersion) < int(obsFile->header().version())) {
|
---|
| 324 | addRnxConversionDetails(obsFile, txtMap);
|
---|
| 325 | }
|
---|
[4514] | 326 | outObsFile.header().write(outObsFile.stream(), &txtMap);
|
---|
[3901] | 327 | }
|
---|
[3994] | 328 | t_rnxObsFile::t_rnxEpo* epo = 0;
|
---|
[4541] | 329 | try {
|
---|
| 330 | while ( (epo = obsFile->nextEpoch()) != 0) {
|
---|
| 331 | if (_begTime.valid() && epo->tt < _begTime) {
|
---|
| 332 | continue;
|
---|
| 333 | }
|
---|
| 334 | if (_endTime.valid() && epo->tt > _endTime) {
|
---|
| 335 | break;
|
---|
| 336 | }
|
---|
[7474] | 337 |
|
---|
| 338 | if (_samplingRate == 0 ||
|
---|
[4541] | 339 | fmod(round(epo->tt.gpssec()), _samplingRate) == 0) {
|
---|
| 340 | applyLLI(obsFile, epo);
|
---|
| 341 | outObsFile.writeEpoch(epo);
|
---|
| 342 | }
|
---|
| 343 | else {
|
---|
| 344 | rememberLLI(obsFile, epo);
|
---|
| 345 | }
|
---|
[3993] | 346 | }
|
---|
[4541] | 347 | }
|
---|
| 348 | catch (QString str) {
|
---|
| 349 | if (_log) {
|
---|
| 350 | *_log << "Exception " << str << endl;
|
---|
[3993] | 351 | }
|
---|
[3994] | 352 | else {
|
---|
[7474] | 353 | qDebug() << str;
|
---|
[3994] | 354 | }
|
---|
[4541] | 355 | return;
|
---|
[3901] | 356 | }
|
---|
[6130] | 357 | catch (...) {
|
---|
| 358 | if (_log) {
|
---|
| 359 | *_log << "Exception unknown" << endl;
|
---|
| 360 | }
|
---|
| 361 | else {
|
---|
| 362 | qDebug() << "Exception unknown";
|
---|
| 363 | }
|
---|
| 364 | return;
|
---|
| 365 | }
|
---|
[3901] | 366 | }
|
---|
| 367 | }
|
---|
[3982] | 368 |
|
---|
[7474] | 369 | // Change RINEX Header Content
|
---|
[3982] | 370 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3985] | 371 | void t_reqcEdit::editRnxObsHeader(t_rnxObsFile& obsFile) {
|
---|
[3982] | 372 |
|
---|
[3983] | 373 | bncSettings settings;
|
---|
| 374 |
|
---|
| 375 | QString oldMarkerName = settings.value("reqcOldMarkerName").toString();
|
---|
| 376 | QString newMarkerName = settings.value("reqcNewMarkerName").toString();
|
---|
[4090] | 377 | if (!newMarkerName.isEmpty()) {
|
---|
[7474] | 378 | if (oldMarkerName.isEmpty() ||
|
---|
[4090] | 379 | QRegExp(oldMarkerName).exactMatch(obsFile.markerName())) {
|
---|
| 380 | obsFile.setMarkerName(newMarkerName);
|
---|
| 381 | }
|
---|
[3985] | 382 | }
|
---|
| 383 |
|
---|
[3983] | 384 | QString oldAntennaName = settings.value("reqcOldAntennaName").toString();
|
---|
| 385 | QString newAntennaName = settings.value("reqcNewAntennaName").toString();
|
---|
[4090] | 386 | if (!newAntennaName.isEmpty()) {
|
---|
[7474] | 387 | if (oldAntennaName.isEmpty() ||
|
---|
[4090] | 388 | QRegExp(oldAntennaName).exactMatch(obsFile.antennaName())) {
|
---|
| 389 | obsFile.setAntennaName(newAntennaName);
|
---|
| 390 | }
|
---|
[3985] | 391 | }
|
---|
[3983] | 392 |
|
---|
[6795] | 393 | QString oldAntennaNumber = settings.value("reqcOldAntennaNumber").toString();
|
---|
| 394 | QString newAntennaNumber = settings.value("reqcNewAntennaNumber").toString();
|
---|
| 395 | if (!newAntennaNumber.isEmpty()) {
|
---|
| 396 | if (oldAntennaNumber.isEmpty() ||
|
---|
| 397 | QRegExp(oldAntennaNumber).exactMatch(obsFile.antennaNumber())) {
|
---|
| 398 | obsFile.setAntennaNumber(newAntennaNumber);
|
---|
| 399 | }
|
---|
| 400 | }
|
---|
| 401 |
|
---|
| 402 |
|
---|
| 403 | const ColumnVector& obsFileAntNEU = obsFile.antNEU();
|
---|
| 404 | QString oldAntennadN = settings.value("reqcOldAntennadN").toString();
|
---|
| 405 | QString newAntennadN = settings.value("reqcNewAntennadN").toString();
|
---|
| 406 | if(!newAntennadN.isEmpty()) {
|
---|
| 407 | if (oldAntennadN.isEmpty() ||
|
---|
| 408 | oldAntennadN.toDouble() == obsFileAntNEU(1)) {
|
---|
| 409 | obsFile.setAntennaN(newAntennadN.toDouble());
|
---|
| 410 | }
|
---|
| 411 | }
|
---|
| 412 | QString oldAntennadE = settings.value("reqcOldAntennadE").toString();
|
---|
| 413 | QString newAntennadE = settings.value("reqcNewAntennadE").toString();
|
---|
| 414 | if(!newAntennadE.isEmpty()) {
|
---|
| 415 | if (oldAntennadE.isEmpty() ||
|
---|
| 416 | oldAntennadE.toDouble() == obsFileAntNEU(2)) {
|
---|
| 417 | obsFile.setAntennaE(newAntennadE.toDouble());
|
---|
| 418 | }
|
---|
| 419 | }
|
---|
| 420 | QString oldAntennadU = settings.value("reqcOldAntennadU").toString();
|
---|
| 421 | QString newAntennadU = settings.value("reqcNewAntennadU").toString();
|
---|
| 422 | if(!newAntennadU.isEmpty()) {
|
---|
| 423 | if (oldAntennadU.isEmpty() ||
|
---|
| 424 | oldAntennadU.toDouble() == obsFileAntNEU(3)) {
|
---|
| 425 | obsFile.setAntennaU(newAntennadU.toDouble());
|
---|
| 426 | }
|
---|
| 427 | }
|
---|
| 428 |
|
---|
[3985] | 429 | QString oldReceiverType = settings.value("reqcOldReceiverName").toString();
|
---|
| 430 | QString newReceiverType = settings.value("reqcNewReceiverName").toString();
|
---|
[4090] | 431 | if (!newReceiverType.isEmpty()) {
|
---|
[7474] | 432 | if (oldReceiverType.isEmpty() ||
|
---|
[4090] | 433 | QRegExp(oldReceiverType).exactMatch(obsFile.receiverType())) {
|
---|
| 434 | obsFile.setReceiverType(newReceiverType);
|
---|
| 435 | }
|
---|
[3985] | 436 | }
|
---|
[6795] | 437 |
|
---|
| 438 | QString oldReceiverNumber = settings.value("reqcOldReceiverNumber").toString();
|
---|
| 439 | QString newReceiverNumber = settings.value("reqcNewReceiverNumber").toString();
|
---|
| 440 | if (!newReceiverNumber.isEmpty()) {
|
---|
| 441 | if (oldReceiverNumber.isEmpty() ||
|
---|
| 442 | QRegExp(oldReceiverNumber).exactMatch(obsFile.receiverNumber())) {
|
---|
| 443 | obsFile.setReceiverNumber(newReceiverNumber);
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
[3982] | 446 | }
|
---|
[3994] | 447 |
|
---|
[7474] | 448 | //
|
---|
[3994] | 449 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7474] | 450 | void t_reqcEdit::rememberLLI(const t_rnxObsFile* obsFile,
|
---|
[3995] | 451 | const t_rnxObsFile::t_rnxEpo* epo) {
|
---|
[3994] | 452 |
|
---|
[3995] | 453 | if (_samplingRate == 0) {
|
---|
| 454 | return;
|
---|
| 455 | }
|
---|
| 456 |
|
---|
| 457 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 458 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
[6121] | 459 | char sys = rnxSat.prn.system();
|
---|
| 460 | QString prn(rnxSat.prn.toString().c_str());
|
---|
[3997] | 461 |
|
---|
[3995] | 462 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
[6121] | 463 | QString type = obsFile->obsType(sys, iType);
|
---|
[3997] | 464 | if (!_lli[prn].contains(iType)) {
|
---|
| 465 | _lli[prn][iType] = 0;
|
---|
[3996] | 466 | }
|
---|
[6121] | 467 | if (rnxSat.obs.contains(type) && rnxSat.obs[type].lli & 1) {
|
---|
[3997] | 468 | _lli[prn][iType] |= 1;
|
---|
[3996] | 469 | }
|
---|
[3995] | 470 | }
|
---|
| 471 | }
|
---|
[3994] | 472 | }
|
---|
[7474] | 473 |
|
---|
| 474 | //
|
---|
[3994] | 475 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7474] | 476 | void t_reqcEdit::applyLLI(const t_rnxObsFile* obsFile,
|
---|
[3995] | 477 | t_rnxObsFile::t_rnxEpo* epo) {
|
---|
[7474] | 478 |
|
---|
[3996] | 479 | if (_samplingRate == 0) {
|
---|
[3995] | 480 | return;
|
---|
| 481 | }
|
---|
[3996] | 482 |
|
---|
| 483 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 484 | t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
[6121] | 485 | char sys = rnxSat.prn.system();
|
---|
| 486 | QString prn(rnxSat.prn.toString().c_str());
|
---|
[3997] | 487 |
|
---|
[3996] | 488 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
[6121] | 489 | QString type = obsFile->obsType(sys, iType);
|
---|
[3997] | 490 | if (_lli[prn].contains(iType) && _lli[prn][iType] & 1) {
|
---|
[6121] | 491 | if (rnxSat.obs.contains(type)) {
|
---|
| 492 | rnxSat.obs[type].lli |= 1;
|
---|
| 493 | }
|
---|
[3996] | 494 | }
|
---|
| 495 | }
|
---|
| 496 | }
|
---|
| 497 |
|
---|
| 498 | _lli.clear();
|
---|
[3994] | 499 | }
|
---|
[3998] | 500 |
|
---|
[4256] | 501 | /// Read All Ephemerides
|
---|
[3998] | 502 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4256] | 503 | void t_reqcEdit::readEphemerides(const QStringList& navFileNames,
|
---|
| 504 | QVector<t_eph*>& ephs) {
|
---|
[3998] | 505 |
|
---|
[4256] | 506 | QStringListIterator it(navFileNames);
|
---|
[3999] | 507 | while (it.hasNext()) {
|
---|
| 508 | QString fileName = it.next();
|
---|
[4081] | 509 | if (fileName.indexOf('*') != -1 || fileName.indexOf('?') != -1) {
|
---|
| 510 | QFileInfo fileInfo(fileName);
|
---|
| 511 | QDir dir = fileInfo.dir();
|
---|
| 512 | QStringList filters; filters << fileInfo.fileName();
|
---|
| 513 | QListIterator<QFileInfo> it(dir.entryInfoList(filters));
|
---|
| 514 | while (it.hasNext()) {
|
---|
[7474] | 515 | QString filePath = it.next().filePath();
|
---|
[4256] | 516 | appendEphemerides(filePath, ephs);
|
---|
[4000] | 517 | }
|
---|
| 518 | }
|
---|
[4081] | 519 | else {
|
---|
[4256] | 520 | appendEphemerides(fileName, ephs);
|
---|
[4081] | 521 | }
|
---|
[3999] | 522 | }
|
---|
[4256] | 523 | qStableSort(ephs.begin(), ephs.end(), t_eph::earlierTime);
|
---|
| 524 | }
|
---|
[3999] | 525 |
|
---|
[7474] | 526 | //
|
---|
[4256] | 527 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 528 | void t_reqcEdit::editEphemerides() {
|
---|
| 529 |
|
---|
| 530 | // Easy Exit
|
---|
| 531 | // ---------
|
---|
| 532 | if (_navFileNames.isEmpty() || _outNavFileName.isEmpty()) {
|
---|
| 533 | return;
|
---|
| 534 | }
|
---|
[8000] | 535 |
|
---|
| 536 | // Concatenate all comments
|
---|
| 537 | // ------------------------
|
---|
| 538 | QStringList comments;
|
---|
| 539 | bncSettings settings;
|
---|
| 540 | QString comment = settings.value("reqcComment").toString();
|
---|
| 541 | if (!comment.isEmpty()) {
|
---|
| 542 | comments.append(comment);
|
---|
| 543 | }
|
---|
| 544 | QStringListIterator it(_navFileNames);
|
---|
| 545 | while (it.hasNext()) {
|
---|
| 546 | QString fileName = it.next();
|
---|
| 547 | t_rnxNavFile rnxNavFile(fileName, t_rnxNavFile::input);
|
---|
| 548 | QStringListIterator itCmnt(rnxNavFile.comments());
|
---|
| 549 | while (itCmnt.hasNext()) {
|
---|
| 550 | comments.append(itCmnt.next());
|
---|
| 551 | }
|
---|
| 552 | }
|
---|
| 553 | comments.removeDuplicates();
|
---|
| 554 |
|
---|
[4257] | 555 | // Read Ephemerides
|
---|
| 556 | // ----------------
|
---|
[4256] | 557 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
| 558 |
|
---|
[4229] | 559 | // Check Satellite Systems
|
---|
| 560 | // -----------------------
|
---|
| 561 | bool haveGPS = false;
|
---|
| 562 | bool haveGlonass = false;
|
---|
| 563 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 564 | const t_eph* eph = _ephs[ii];
|
---|
| 565 | if (eph->type() == t_eph::GPS) {
|
---|
| 566 | haveGPS = true;
|
---|
| 567 | }
|
---|
| 568 | else if (eph->type() == t_eph::GLONASS) {
|
---|
| 569 | haveGlonass = true;
|
---|
| 570 | }
|
---|
| 571 | }
|
---|
| 572 |
|
---|
[4007] | 573 | // Initialize output navigation file
|
---|
| 574 | // ---------------------------------
|
---|
[4004] | 575 | t_rnxNavFile outNavFile(_outNavFileName, t_rnxNavFile::output);
|
---|
[4229] | 576 |
|
---|
| 577 | outNavFile.setGlonass(haveGlonass);
|
---|
| 578 |
|
---|
[5378] | 579 | if ( (haveGPS && haveGlonass) || _rnxVersion >= 3.0) {
|
---|
| 580 | outNavFile.setVersion(t_rnxNavFile::defaultRnxNavVersion3);
|
---|
[4229] | 581 | }
|
---|
| 582 | else {
|
---|
[5378] | 583 | outNavFile.setVersion(t_rnxNavFile::defaultRnxNavVersion2);
|
---|
[4229] | 584 | }
|
---|
| 585 |
|
---|
[4221] | 586 | QMap<QString, QString> txtMap;
|
---|
| 587 | QString runBy = settings.value("reqcRunBy").toString();
|
---|
| 588 | if (!runBy.isEmpty()) {
|
---|
| 589 | txtMap["RUN BY"] = runBy;
|
---|
| 590 | }
|
---|
[8000] | 591 | if (!comments.isEmpty()) {
|
---|
| 592 | txtMap["COMMENT"] = comments.join("\\n");
|
---|
[4221] | 593 | }
|
---|
[4229] | 594 |
|
---|
[4221] | 595 | outNavFile.writeHeader(&txtMap);
|
---|
[4009] | 596 |
|
---|
[4004] | 597 | // Loop over all ephemerides
|
---|
| 598 | // -------------------------
|
---|
| 599 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 600 | const t_eph* eph = _ephs[ii];
|
---|
[6954] | 601 | bncTime begTime = _begTime;
|
---|
| 602 | bncTime endTime = _endTime;
|
---|
| 603 | if (eph->type() == t_eph::BDS) {
|
---|
| 604 | begTime += 14;
|
---|
| 605 | endTime += 14;
|
---|
| 606 | }
|
---|
| 607 | if (begTime.valid() && eph->TOC() < begTime) {
|
---|
[6898] | 608 | continue;
|
---|
| 609 | }
|
---|
[6954] | 610 | if (endTime.valid() && eph->TOC() > endTime) {
|
---|
[6898] | 611 | break;
|
---|
| 612 | }
|
---|
[4229] | 613 | outNavFile.writeEph(eph);
|
---|
[4004] | 614 | }
|
---|
[3998] | 615 | }
|
---|
[4081] | 616 |
|
---|
[7474] | 617 | //
|
---|
[4081] | 618 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4256] | 619 | void t_reqcEdit::appendEphemerides(const QString& fileName,
|
---|
| 620 | QVector<t_eph*>& ephs) {
|
---|
[4081] | 621 |
|
---|
| 622 | t_rnxNavFile rnxNavFile(fileName, t_rnxNavFile::input);
|
---|
| 623 | for (unsigned ii = 0; ii < rnxNavFile.ephs().size(); ii++) {
|
---|
| 624 | t_eph* eph = rnxNavFile.ephs()[ii];
|
---|
| 625 | bool isNew = true;
|
---|
[4256] | 626 | for (int iOld = 0; iOld < ephs.size(); iOld++) {
|
---|
| 627 | const t_eph* ephOld = ephs[iOld];
|
---|
[6804] | 628 | if (ephOld->prn() == eph->prn() &&
|
---|
[6809] | 629 | ephOld->TOC() == eph->TOC()) {
|
---|
[4081] | 630 | isNew = false;
|
---|
| 631 | break;
|
---|
| 632 | }
|
---|
| 633 | }
|
---|
| 634 | if (isNew) {
|
---|
| 635 | if (eph->type() == t_eph::GPS) {
|
---|
[4256] | 636 | ephs.append(new t_ephGPS(*dynamic_cast<t_ephGPS*>(eph)));
|
---|
[4081] | 637 | }
|
---|
| 638 | else if (eph->type() == t_eph::GLONASS) {
|
---|
[4256] | 639 | ephs.append(new t_ephGlo(*dynamic_cast<t_ephGlo*>(eph)));
|
---|
[4081] | 640 | }
|
---|
| 641 | else if (eph->type() == t_eph::Galileo) {
|
---|
[4256] | 642 | ephs.append(new t_ephGal(*dynamic_cast<t_ephGal*>(eph)));
|
---|
[4081] | 643 | }
|
---|
[6377] | 644 | else if (eph->type() == t_eph::QZSS) {
|
---|
| 645 | ephs.append(new t_ephGPS(*dynamic_cast<t_ephGPS*>(eph)));
|
---|
| 646 | }
|
---|
[6391] | 647 | else if (eph->type() == t_eph::SBAS) {
|
---|
| 648 | ephs.append(new t_ephSBAS(*dynamic_cast<t_ephSBAS*>(eph)));
|
---|
| 649 | }
|
---|
[6602] | 650 | else if (eph->type() == t_eph::BDS) {
|
---|
[6600] | 651 | ephs.append(new t_ephBDS(*dynamic_cast<t_ephBDS*>(eph)));
|
---|
[6402] | 652 | }
|
---|
[4081] | 653 | }
|
---|
| 654 | }
|
---|
| 655 | }
|
---|
[7474] | 656 |
|
---|
| 657 | void t_reqcEdit::addRnxConversionDetails(const t_rnxObsFile* obsFile,
|
---|
| 658 | QMap<QString, QString>& txtMap) {
|
---|
| 659 |
|
---|
| 660 | int key = 0;
|
---|
| 661 | QString systems = obsFile->header().usedSystems();
|
---|
[7983] | 662 | QString comment = QString("Signal priorities for RINEX 3 => 2 conversion:");
|
---|
[7474] | 663 | QString commentKey = QString("COMMENT %1").arg(key, 3, 10, QChar('0'));
|
---|
| 664 | txtMap.insert(commentKey, comment);
|
---|
| 665 |
|
---|
| 666 | for(int ii = 0; ii < obsFile->numSys(); ii++) {
|
---|
| 667 | char sys = systems[ii].toAscii();
|
---|
| 668 | txtMap.insert(commentKey, comment);
|
---|
[7983] | 669 | QMap <char, QString> signalPriorityMap;
|
---|
| 670 | QStringList preferredAttribListSys = obsFile->signalPriorities(sys);
|
---|
[7474] | 671 | QStringList types = obsFile->header().obsTypes(sys);
|
---|
| 672 | for (int jj = 0; jj < types.size(); jj++) {
|
---|
| 673 | QString inType = types[jj];
|
---|
[7983] | 674 | char band = inType[1].toAscii();
|
---|
| 675 | for (int ii = 0; ii < preferredAttribListSys.size(); ii++) {
|
---|
| 676 | QString preferredAttrib;
|
---|
| 677 | if (preferredAttribListSys[ii].indexOf("&") != -1) {
|
---|
| 678 | QStringList hlp = preferredAttribListSys[ii].split("&", QString::SkipEmptyParts);
|
---|
| 679 | if (hlp.size() == 2 && hlp[0].contains(band)) {
|
---|
| 680 | preferredAttrib = hlp[1];
|
---|
| 681 | }
|
---|
[7474] | 682 | }
|
---|
[7983] | 683 | else {
|
---|
| 684 | preferredAttrib = preferredAttribListSys[ii];
|
---|
| 685 | }
|
---|
| 686 | if (!signalPriorityMap.contains(band) && !preferredAttrib.isEmpty()){
|
---|
| 687 | signalPriorityMap[band] = preferredAttrib;
|
---|
| 688 | }
|
---|
[7474] | 689 | }
|
---|
| 690 | }
|
---|
[7983] | 691 | QMapIterator<char, QString> it(signalPriorityMap);
|
---|
| 692 | while (it.hasNext()) {
|
---|
| 693 | it.next();
|
---|
| 694 | key++;
|
---|
| 695 | comment = QString("%1 band %2: %3").arg(sys).arg(it.key()).arg(it.value());
|
---|
| 696 | commentKey = QString("COMMENT %1").arg(key, 3, 10, QChar('0'));
|
---|
| 697 | txtMap.insert(commentKey, comment);
|
---|
| 698 | }
|
---|
[7474] | 699 | }
|
---|
| 700 | }
|
---|