[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;
|
---|
[7992] | 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);
|
---|
[7942] | 152 | msleep(100); //sleep 0.1 sec
|
---|
[3998] | 153 | }
|
---|
| 154 | else {
|
---|
| 155 | emit finished();
|
---|
| 156 | deleteLater();
|
---|
| 157 | }
|
---|
[7980] | 158 |
|
---|
[3998] | 159 | }
|
---|
| 160 |
|
---|
[4254] | 161 | // Initialize input observation files, sort them according to start time
|
---|
[3998] | 162 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7474] | 163 | void t_reqcEdit::initRnxObsFiles(const QStringList& obsFileNames,
|
---|
[4525] | 164 | QVector<t_rnxObsFile*>& rnxObsFiles,
|
---|
| 165 | QTextStream* log) {
|
---|
[3998] | 166 |
|
---|
[4254] | 167 | QStringListIterator it(obsFileNames);
|
---|
[3901] | 168 | while (it.hasNext()) {
|
---|
| 169 | QString fileName = it.next();
|
---|
[4080] | 170 | if (fileName.indexOf('*') != -1 || fileName.indexOf('?') != -1) {
|
---|
| 171 | QFileInfo fileInfo(fileName);
|
---|
| 172 | QDir dir = fileInfo.dir();
|
---|
| 173 | QStringList filters; filters << fileInfo.fileName();
|
---|
| 174 | QListIterator<QFileInfo> it(dir.entryInfoList(filters));
|
---|
| 175 | while (it.hasNext()) {
|
---|
[7474] | 176 | QString filePath = it.next().filePath();
|
---|
[4364] | 177 | t_rnxObsFile* rnxObsFile = 0;
|
---|
[4363] | 178 | try {
|
---|
[4364] | 179 | rnxObsFile = new t_rnxObsFile(filePath, t_rnxObsFile::input);
|
---|
[4363] | 180 | rnxObsFiles.append(rnxObsFile);
|
---|
| 181 | }
|
---|
| 182 | catch (...) {
|
---|
[4364] | 183 | delete rnxObsFile;
|
---|
[4525] | 184 | if (log) {
|
---|
| 185 | *log << "Error in rnxObsFile " << filePath.toAscii().data() << endl;
|
---|
| 186 | }
|
---|
[4363] | 187 | }
|
---|
[4080] | 188 | }
|
---|
| 189 | }
|
---|
| 190 | else {
|
---|
[4364] | 191 | t_rnxObsFile* rnxObsFile = 0;
|
---|
[4363] | 192 | try {
|
---|
[4364] | 193 | rnxObsFile = new t_rnxObsFile(fileName, t_rnxObsFile::input);
|
---|
[4363] | 194 | rnxObsFiles.append(rnxObsFile);
|
---|
| 195 | }
|
---|
| 196 | catch (...) {
|
---|
[4525] | 197 | if (log) {
|
---|
| 198 | *log << "Error in rnxObsFile " << fileName.toAscii().data() << endl;
|
---|
| 199 | }
|
---|
[4363] | 200 | }
|
---|
[4080] | 201 | }
|
---|
[3901] | 202 | }
|
---|
[7474] | 203 | qStableSort(rnxObsFiles.begin(), rnxObsFiles.end(),
|
---|
[3901] | 204 | t_rnxObsFile::earlierStartTime);
|
---|
[4254] | 205 | }
|
---|
[3901] | 206 |
|
---|
[7474] | 207 | //
|
---|
[4254] | 208 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 209 | void t_reqcEdit::editObservations() {
|
---|
| 210 |
|
---|
| 211 | // Easy Exit
|
---|
| 212 | // ---------
|
---|
| 213 | if (_obsFileNames.isEmpty() || _outObsFileName.isEmpty()) {
|
---|
| 214 | return;
|
---|
| 215 | }
|
---|
| 216 |
|
---|
[4525] | 217 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
|
---|
[4254] | 218 |
|
---|
[3901] | 219 | // Initialize output observation file
|
---|
| 220 | // ----------------------------------
|
---|
| 221 | t_rnxObsFile outObsFile(_outObsFileName, t_rnxObsFile::output);
|
---|
[7474] | 222 |
|
---|
[6118] | 223 | // Select observation types
|
---|
| 224 | // ------------------------
|
---|
| 225 | bncSettings settings;
|
---|
| 226 | QStringList useObsTypes = settings.value("reqcUseObsTypes").toString().split(" ", QString::SkipEmptyParts);
|
---|
| 227 |
|
---|
[6130] | 228 | // Put together all observation types
|
---|
| 229 | // ----------------------------------
|
---|
| 230 | if (_rnxObsFiles.size() > 1 && useObsTypes.size() == 0) {
|
---|
| 231 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 232 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 233 | for (int iSys = 0; iSys < obsFile->numSys(); iSys++) {
|
---|
| 234 | char sys = obsFile->system(iSys);
|
---|
| 235 | if (sys != ' ') {
|
---|
[6131] | 236 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
| 237 | QString type = obsFile->obsType(sys, iType);
|
---|
[6132] | 238 | if (_rnxVersion < 3.0) {
|
---|
| 239 | useObsTypes << type;
|
---|
| 240 | }
|
---|
| 241 | else {
|
---|
| 242 | useObsTypes << QString(sys) + ":" + type;
|
---|
| 243 | }
|
---|
[6131] | 244 | }
|
---|
[6130] | 245 | }
|
---|
| 246 | }
|
---|
| 247 | }
|
---|
[6132] | 248 | useObsTypes.removeDuplicates();
|
---|
[6130] | 249 | }
|
---|
| 250 |
|
---|
[6841] | 251 | // Put together all phase shifts
|
---|
| 252 | // -----------------------------
|
---|
| 253 | QStringList phaseShifts;
|
---|
| 254 | if (_rnxVersion >= 3.0 && _rnxObsFiles.size() > 1) {
|
---|
| 255 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 256 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 257 | phaseShifts << obsFile->phaseShifts();
|
---|
| 258 | }
|
---|
| 259 | phaseShifts.removeDuplicates();
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | // Put together all GLONASS biases
|
---|
| 263 | // -------------------------------
|
---|
| 264 | QStringList gloBiases;
|
---|
| 265 | if (_rnxVersion >= 3.0 && _rnxObsFiles.size() > 1) {
|
---|
| 266 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 267 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 268 | if (ii == 0 && obsFile->numGloBiases() == 4) {
|
---|
| 269 | break;
|
---|
| 270 | }
|
---|
| 271 | else {
|
---|
| 272 | gloBiases << obsFile->gloBiases();
|
---|
| 273 | }
|
---|
| 274 | }
|
---|
| 275 | gloBiases.removeDuplicates();
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 | // Put together all GLONASS slots
|
---|
| 279 | // -----------------------------
|
---|
| 280 | QStringList gloSlots;
|
---|
| 281 | if (_rnxVersion >= 3.0 && _rnxObsFiles.size() > 1) {
|
---|
| 282 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 283 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 284 | if (ii == 0 &&
|
---|
| 285 | obsFile->numGloSlots() == signed(t_prn::MAXPRN_GLONASS)) {
|
---|
| 286 | break;
|
---|
| 287 | }
|
---|
| 288 | else {
|
---|
| 289 | gloSlots << obsFile->gloSlots();
|
---|
| 290 | }
|
---|
| 291 | }
|
---|
| 292 | gloSlots.removeDuplicates();
|
---|
| 293 | }
|
---|
| 294 |
|
---|
[3901] | 295 | // Loop over all input observation files
|
---|
| 296 | // -------------------------------------
|
---|
| 297 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 298 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
[4524] | 299 | if (_log) {
|
---|
[7474] | 300 | *_log << "Processing File: " << obsFile->fileName() << " start: "
|
---|
| 301 | << obsFile->startTime().datestr().c_str() << ' '
|
---|
[4524] | 302 | << obsFile->startTime().timestr(0).c_str() << endl;
|
---|
| 303 | }
|
---|
[3901] | 304 | if (ii == 0) {
|
---|
[6841] | 305 | outObsFile.setHeader(obsFile->header(), int(_rnxVersion), &useObsTypes,
|
---|
| 306 | &phaseShifts, &gloBiases, &gloSlots);
|
---|
[3992] | 307 | if (_begTime.valid() && _begTime > outObsFile.startTime()) {
|
---|
| 308 | outObsFile.setStartTime(_begTime);
|
---|
| 309 | }
|
---|
[4112] | 310 | if (_samplingRate > outObsFile.interval()) {
|
---|
| 311 | outObsFile.setInterval(_samplingRate);
|
---|
| 312 | }
|
---|
[3982] | 313 | editRnxObsHeader(outObsFile);
|
---|
[4117] | 314 | bncSettings settings;
|
---|
[4114] | 315 | QMap<QString, QString> txtMap;
|
---|
[4117] | 316 | QString runBy = settings.value("reqcRunBy").toString();
|
---|
| 317 | if (!runBy.isEmpty()) {
|
---|
| 318 | txtMap["RUN BY"] = runBy;
|
---|
| 319 | }
|
---|
| 320 | QString comment = settings.value("reqcComment").toString();
|
---|
| 321 | if (!comment.isEmpty()) {
|
---|
| 322 | txtMap["COMMENT"] = comment;
|
---|
| 323 | }
|
---|
[7474] | 324 | if (int(_rnxVersion) < int(obsFile->header().version())) {
|
---|
| 325 | addRnxConversionDetails(obsFile, txtMap);
|
---|
| 326 | }
|
---|
[4514] | 327 | outObsFile.header().write(outObsFile.stream(), &txtMap);
|
---|
[3901] | 328 | }
|
---|
[3994] | 329 | t_rnxObsFile::t_rnxEpo* epo = 0;
|
---|
[4541] | 330 | try {
|
---|
| 331 | while ( (epo = obsFile->nextEpoch()) != 0) {
|
---|
| 332 | if (_begTime.valid() && epo->tt < _begTime) {
|
---|
| 333 | continue;
|
---|
| 334 | }
|
---|
| 335 | if (_endTime.valid() && epo->tt > _endTime) {
|
---|
| 336 | break;
|
---|
| 337 | }
|
---|
[7474] | 338 |
|
---|
| 339 | if (_samplingRate == 0 ||
|
---|
[4541] | 340 | fmod(round(epo->tt.gpssec()), _samplingRate) == 0) {
|
---|
| 341 | applyLLI(obsFile, epo);
|
---|
| 342 | outObsFile.writeEpoch(epo);
|
---|
| 343 | }
|
---|
| 344 | else {
|
---|
| 345 | rememberLLI(obsFile, epo);
|
---|
| 346 | }
|
---|
[3993] | 347 | }
|
---|
[4541] | 348 | }
|
---|
| 349 | catch (QString str) {
|
---|
| 350 | if (_log) {
|
---|
| 351 | *_log << "Exception " << str << endl;
|
---|
[3993] | 352 | }
|
---|
[3994] | 353 | else {
|
---|
[7474] | 354 | qDebug() << str;
|
---|
[3994] | 355 | }
|
---|
[4541] | 356 | return;
|
---|
[3901] | 357 | }
|
---|
[6130] | 358 | catch (...) {
|
---|
| 359 | if (_log) {
|
---|
| 360 | *_log << "Exception unknown" << endl;
|
---|
| 361 | }
|
---|
| 362 | else {
|
---|
| 363 | qDebug() << "Exception unknown";
|
---|
| 364 | }
|
---|
| 365 | return;
|
---|
| 366 | }
|
---|
[3901] | 367 | }
|
---|
| 368 | }
|
---|
[3982] | 369 |
|
---|
[7474] | 370 | // Change RINEX Header Content
|
---|
[3982] | 371 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3985] | 372 | void t_reqcEdit::editRnxObsHeader(t_rnxObsFile& obsFile) {
|
---|
[3982] | 373 |
|
---|
[3983] | 374 | bncSettings settings;
|
---|
| 375 |
|
---|
| 376 | QString oldMarkerName = settings.value("reqcOldMarkerName").toString();
|
---|
| 377 | QString newMarkerName = settings.value("reqcNewMarkerName").toString();
|
---|
[4090] | 378 | if (!newMarkerName.isEmpty()) {
|
---|
[7474] | 379 | if (oldMarkerName.isEmpty() ||
|
---|
[4090] | 380 | QRegExp(oldMarkerName).exactMatch(obsFile.markerName())) {
|
---|
| 381 | obsFile.setMarkerName(newMarkerName);
|
---|
| 382 | }
|
---|
[3985] | 383 | }
|
---|
| 384 |
|
---|
[3983] | 385 | QString oldAntennaName = settings.value("reqcOldAntennaName").toString();
|
---|
| 386 | QString newAntennaName = settings.value("reqcNewAntennaName").toString();
|
---|
[4090] | 387 | if (!newAntennaName.isEmpty()) {
|
---|
[7474] | 388 | if (oldAntennaName.isEmpty() ||
|
---|
[4090] | 389 | QRegExp(oldAntennaName).exactMatch(obsFile.antennaName())) {
|
---|
| 390 | obsFile.setAntennaName(newAntennaName);
|
---|
| 391 | }
|
---|
[3985] | 392 | }
|
---|
[3983] | 393 |
|
---|
[6795] | 394 | QString oldAntennaNumber = settings.value("reqcOldAntennaNumber").toString();
|
---|
| 395 | QString newAntennaNumber = settings.value("reqcNewAntennaNumber").toString();
|
---|
| 396 | if (!newAntennaNumber.isEmpty()) {
|
---|
| 397 | if (oldAntennaNumber.isEmpty() ||
|
---|
| 398 | QRegExp(oldAntennaNumber).exactMatch(obsFile.antennaNumber())) {
|
---|
| 399 | obsFile.setAntennaNumber(newAntennaNumber);
|
---|
| 400 | }
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 |
|
---|
| 404 | const ColumnVector& obsFileAntNEU = obsFile.antNEU();
|
---|
| 405 | QString oldAntennadN = settings.value("reqcOldAntennadN").toString();
|
---|
| 406 | QString newAntennadN = settings.value("reqcNewAntennadN").toString();
|
---|
| 407 | if(!newAntennadN.isEmpty()) {
|
---|
| 408 | if (oldAntennadN.isEmpty() ||
|
---|
| 409 | oldAntennadN.toDouble() == obsFileAntNEU(1)) {
|
---|
| 410 | obsFile.setAntennaN(newAntennadN.toDouble());
|
---|
| 411 | }
|
---|
| 412 | }
|
---|
| 413 | QString oldAntennadE = settings.value("reqcOldAntennadE").toString();
|
---|
| 414 | QString newAntennadE = settings.value("reqcNewAntennadE").toString();
|
---|
| 415 | if(!newAntennadE.isEmpty()) {
|
---|
| 416 | if (oldAntennadE.isEmpty() ||
|
---|
| 417 | oldAntennadE.toDouble() == obsFileAntNEU(2)) {
|
---|
| 418 | obsFile.setAntennaE(newAntennadE.toDouble());
|
---|
| 419 | }
|
---|
| 420 | }
|
---|
| 421 | QString oldAntennadU = settings.value("reqcOldAntennadU").toString();
|
---|
| 422 | QString newAntennadU = settings.value("reqcNewAntennadU").toString();
|
---|
| 423 | if(!newAntennadU.isEmpty()) {
|
---|
| 424 | if (oldAntennadU.isEmpty() ||
|
---|
| 425 | oldAntennadU.toDouble() == obsFileAntNEU(3)) {
|
---|
| 426 | obsFile.setAntennaU(newAntennadU.toDouble());
|
---|
| 427 | }
|
---|
| 428 | }
|
---|
| 429 |
|
---|
[3985] | 430 | QString oldReceiverType = settings.value("reqcOldReceiverName").toString();
|
---|
| 431 | QString newReceiverType = settings.value("reqcNewReceiverName").toString();
|
---|
[4090] | 432 | if (!newReceiverType.isEmpty()) {
|
---|
[7474] | 433 | if (oldReceiverType.isEmpty() ||
|
---|
[4090] | 434 | QRegExp(oldReceiverType).exactMatch(obsFile.receiverType())) {
|
---|
| 435 | obsFile.setReceiverType(newReceiverType);
|
---|
| 436 | }
|
---|
[3985] | 437 | }
|
---|
[6795] | 438 |
|
---|
| 439 | QString oldReceiverNumber = settings.value("reqcOldReceiverNumber").toString();
|
---|
| 440 | QString newReceiverNumber = settings.value("reqcNewReceiverNumber").toString();
|
---|
| 441 | if (!newReceiverNumber.isEmpty()) {
|
---|
| 442 | if (oldReceiverNumber.isEmpty() ||
|
---|
| 443 | QRegExp(oldReceiverNumber).exactMatch(obsFile.receiverNumber())) {
|
---|
| 444 | obsFile.setReceiverNumber(newReceiverNumber);
|
---|
| 445 | }
|
---|
| 446 | }
|
---|
[3982] | 447 | }
|
---|
[3994] | 448 |
|
---|
[7474] | 449 | //
|
---|
[3994] | 450 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7474] | 451 | void t_reqcEdit::rememberLLI(const t_rnxObsFile* obsFile,
|
---|
[3995] | 452 | const t_rnxObsFile::t_rnxEpo* epo) {
|
---|
[3994] | 453 |
|
---|
[3995] | 454 | if (_samplingRate == 0) {
|
---|
| 455 | return;
|
---|
| 456 | }
|
---|
| 457 |
|
---|
| 458 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 459 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
[6121] | 460 | char sys = rnxSat.prn.system();
|
---|
| 461 | QString prn(rnxSat.prn.toString().c_str());
|
---|
[3997] | 462 |
|
---|
[3995] | 463 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
[6121] | 464 | QString type = obsFile->obsType(sys, iType);
|
---|
[3997] | 465 | if (!_lli[prn].contains(iType)) {
|
---|
| 466 | _lli[prn][iType] = 0;
|
---|
[3996] | 467 | }
|
---|
[6121] | 468 | if (rnxSat.obs.contains(type) && rnxSat.obs[type].lli & 1) {
|
---|
[3997] | 469 | _lli[prn][iType] |= 1;
|
---|
[3996] | 470 | }
|
---|
[3995] | 471 | }
|
---|
| 472 | }
|
---|
[3994] | 473 | }
|
---|
[7474] | 474 |
|
---|
| 475 | //
|
---|
[3994] | 476 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7474] | 477 | void t_reqcEdit::applyLLI(const t_rnxObsFile* obsFile,
|
---|
[3995] | 478 | t_rnxObsFile::t_rnxEpo* epo) {
|
---|
[7474] | 479 |
|
---|
[3996] | 480 | if (_samplingRate == 0) {
|
---|
[3995] | 481 | return;
|
---|
| 482 | }
|
---|
[3996] | 483 |
|
---|
| 484 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 485 | t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
[6121] | 486 | char sys = rnxSat.prn.system();
|
---|
| 487 | QString prn(rnxSat.prn.toString().c_str());
|
---|
[3997] | 488 |
|
---|
[3996] | 489 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
[6121] | 490 | QString type = obsFile->obsType(sys, iType);
|
---|
[3997] | 491 | if (_lli[prn].contains(iType) && _lli[prn][iType] & 1) {
|
---|
[6121] | 492 | if (rnxSat.obs.contains(type)) {
|
---|
| 493 | rnxSat.obs[type].lli |= 1;
|
---|
| 494 | }
|
---|
[3996] | 495 | }
|
---|
| 496 | }
|
---|
| 497 | }
|
---|
| 498 |
|
---|
| 499 | _lli.clear();
|
---|
[3994] | 500 | }
|
---|
[3998] | 501 |
|
---|
[4256] | 502 | /// Read All Ephemerides
|
---|
[3998] | 503 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4256] | 504 | void t_reqcEdit::readEphemerides(const QStringList& navFileNames,
|
---|
| 505 | QVector<t_eph*>& ephs) {
|
---|
[3998] | 506 |
|
---|
[4256] | 507 | QStringListIterator it(navFileNames);
|
---|
[3999] | 508 | while (it.hasNext()) {
|
---|
| 509 | QString fileName = it.next();
|
---|
[4081] | 510 | if (fileName.indexOf('*') != -1 || fileName.indexOf('?') != -1) {
|
---|
| 511 | QFileInfo fileInfo(fileName);
|
---|
| 512 | QDir dir = fileInfo.dir();
|
---|
| 513 | QStringList filters; filters << fileInfo.fileName();
|
---|
| 514 | QListIterator<QFileInfo> it(dir.entryInfoList(filters));
|
---|
| 515 | while (it.hasNext()) {
|
---|
[7474] | 516 | QString filePath = it.next().filePath();
|
---|
[4256] | 517 | appendEphemerides(filePath, ephs);
|
---|
[4000] | 518 | }
|
---|
| 519 | }
|
---|
[4081] | 520 | else {
|
---|
[4256] | 521 | appendEphemerides(fileName, ephs);
|
---|
[4081] | 522 | }
|
---|
[3999] | 523 | }
|
---|
[4256] | 524 | qStableSort(ephs.begin(), ephs.end(), t_eph::earlierTime);
|
---|
| 525 | }
|
---|
[3999] | 526 |
|
---|
[7474] | 527 | //
|
---|
[4256] | 528 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 529 | void t_reqcEdit::editEphemerides() {
|
---|
| 530 |
|
---|
| 531 | // Easy Exit
|
---|
| 532 | // ---------
|
---|
| 533 | if (_navFileNames.isEmpty() || _outNavFileName.isEmpty()) {
|
---|
| 534 | return;
|
---|
| 535 | }
|
---|
[7999] | 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();
|
---|
[4256] | 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 | }
|
---|
[7999] | 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();
|
---|
[7980] | 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);
|
---|
[7980] | 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];
|
---|
[7980] | 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 | }
|
---|
[7980] | 683 | else {
|
---|
| 684 | preferredAttrib = preferredAttribListSys[ii];
|
---|
| 685 | }
|
---|
| 686 | if (!signalPriorityMap.contains(band) && !preferredAttrib.isEmpty()){
|
---|
| 687 | signalPriorityMap[band] = preferredAttrib;
|
---|
| 688 | }
|
---|
[7474] | 689 | }
|
---|
| 690 | }
|
---|
[7980] | 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 | }
|
---|