[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());
|
---|
[3901] | 74 | }
|
---|
| 75 |
|
---|
| 76 | // Destructor
|
---|
| 77 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 78 | t_reqcEdit::~t_reqcEdit() {
|
---|
| 79 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 80 | delete _rnxObsFiles[ii];
|
---|
| 81 | }
|
---|
[4001] | 82 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 83 | delete _ephs[ii];
|
---|
| 84 | }
|
---|
[4516] | 85 | delete _log; _log = 0;
|
---|
| 86 | delete _logFile; _logFile = 0;
|
---|
[3901] | 87 | }
|
---|
| 88 |
|
---|
| 89 | //
|
---|
| 90 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 91 | void t_reqcEdit::run() {
|
---|
[3998] | 92 |
|
---|
[4516] | 93 | // Open Log File
|
---|
| 94 | // -------------
|
---|
| 95 | _logFile = new QFile(_logFileName);
|
---|
[4518] | 96 | if (_logFile->open(QIODevice::WriteOnly | QIODevice::Text)) {
|
---|
| 97 | _log = new QTextStream();
|
---|
| 98 | _log->setDevice(_logFile);
|
---|
| 99 | }
|
---|
[4516] | 100 |
|
---|
[4518] | 101 | // Log File Header
|
---|
| 102 | // ---------------
|
---|
| 103 | if (_log) {
|
---|
[4519] | 104 | *_log << QByteArray(78, '-') << endl;
|
---|
[4518] | 105 | *_log << "Concatenation of RINEX Observation and/or Navigation Files\n";
|
---|
[4519] | 106 | *_log << QByteArray(78, '-') << endl;
|
---|
[4520] | 107 |
|
---|
[4523] | 108 | *_log << QByteArray("Program").leftJustified(15) << ": "
|
---|
[5068] | 109 | << BNC_CORE->pgmName() << endl;
|
---|
[4523] | 110 | *_log << QByteArray("Run by").leftJustified(15) << ": "
|
---|
[5068] | 111 | << BNC_CORE->userName() << endl;
|
---|
[4523] | 112 | *_log << QByteArray("Date").leftJustified(15) << ": "
|
---|
[4521] | 113 | << QDateTime::currentDateTime().toUTC().toString("yyyy-MM-dd hh:mm:ss") << endl;
|
---|
[4523] | 114 | *_log << QByteArray("RINEX Version").leftJustified(15) << ": "
|
---|
[4522] | 115 | << _rnxVersion << endl;
|
---|
[4523] | 116 | *_log << QByteArray("Sampling").leftJustified(15) << ": "
|
---|
[4522] | 117 | << _samplingRate << endl;
|
---|
[4523] | 118 | *_log << QByteArray("Start time").leftJustified(15) << ": "
|
---|
[4522] | 119 | << _begTime.datestr().c_str() << ' '
|
---|
| 120 | << _begTime.timestr(0).c_str() << endl;
|
---|
[4523] | 121 | *_log << QByteArray("End time").leftJustified(15) << ": "
|
---|
[4522] | 122 | << _endTime.datestr().c_str() << ' '
|
---|
| 123 | << _endTime.timestr(0).c_str() << endl;
|
---|
[4523] | 124 | *_log << QByteArray("Input Obs Files").leftJustified(15) << ": "
|
---|
| 125 | << _obsFileNames.join(",") << endl;
|
---|
| 126 | *_log << QByteArray("Input Nav Files").leftJustified(15) << ": "
|
---|
| 127 | << _navFileNames.join(",") << endl;
|
---|
| 128 | *_log << QByteArray("Output Obs File").leftJustified(15) << ": "
|
---|
| 129 | << _outObsFileName << endl;
|
---|
| 130 | *_log << QByteArray("Output Nav File").leftJustified(15) << ": "
|
---|
| 131 | << _outNavFileName << endl;
|
---|
[4520] | 132 |
|
---|
| 133 | *_log << QByteArray(78, '-') << endl;
|
---|
[4518] | 134 | _log->flush();
|
---|
| 135 | }
|
---|
| 136 |
|
---|
[4516] | 137 | // Handle Observation Files
|
---|
| 138 | // ------------------------
|
---|
[3998] | 139 | editObservations();
|
---|
[3901] | 140 |
|
---|
[4516] | 141 | // Handle Navigations Files
|
---|
| 142 | // ------------------------
|
---|
[3998] | 143 | editEphemerides();
|
---|
| 144 |
|
---|
[4516] | 145 | // Exit (thread)
|
---|
| 146 | // -------------
|
---|
[5072] | 147 | if (BNC_CORE->mode() != t_bncCore::interactive) {
|
---|
[5066] | 148 | qApp->exit(0);
|
---|
[3998] | 149 | }
|
---|
| 150 | else {
|
---|
| 151 | emit finished();
|
---|
| 152 | deleteLater();
|
---|
| 153 | }
|
---|
| 154 | }
|
---|
| 155 |
|
---|
[4254] | 156 | // Initialize input observation files, sort them according to start time
|
---|
[3998] | 157 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4254] | 158 | void t_reqcEdit::initRnxObsFiles(const QStringList& obsFileNames,
|
---|
[4525] | 159 | QVector<t_rnxObsFile*>& rnxObsFiles,
|
---|
| 160 | QTextStream* log) {
|
---|
[3998] | 161 |
|
---|
[4254] | 162 | QStringListIterator it(obsFileNames);
|
---|
[3901] | 163 | while (it.hasNext()) {
|
---|
| 164 | QString fileName = it.next();
|
---|
[4080] | 165 | if (fileName.indexOf('*') != -1 || fileName.indexOf('?') != -1) {
|
---|
| 166 | QFileInfo fileInfo(fileName);
|
---|
| 167 | QDir dir = fileInfo.dir();
|
---|
| 168 | QStringList filters; filters << fileInfo.fileName();
|
---|
| 169 | QListIterator<QFileInfo> it(dir.entryInfoList(filters));
|
---|
| 170 | while (it.hasNext()) {
|
---|
| 171 | QString filePath = it.next().filePath();
|
---|
[4364] | 172 | t_rnxObsFile* rnxObsFile = 0;
|
---|
[4363] | 173 | try {
|
---|
[4364] | 174 | rnxObsFile = new t_rnxObsFile(filePath, t_rnxObsFile::input);
|
---|
[4363] | 175 | rnxObsFiles.append(rnxObsFile);
|
---|
| 176 | }
|
---|
| 177 | catch (...) {
|
---|
[4364] | 178 | delete rnxObsFile;
|
---|
[4525] | 179 | if (log) {
|
---|
| 180 | *log << "Error in rnxObsFile " << filePath.toAscii().data() << endl;
|
---|
| 181 | }
|
---|
[4363] | 182 | }
|
---|
[4080] | 183 | }
|
---|
| 184 | }
|
---|
| 185 | else {
|
---|
[4364] | 186 | t_rnxObsFile* rnxObsFile = 0;
|
---|
[4363] | 187 | try {
|
---|
[4364] | 188 | rnxObsFile = new t_rnxObsFile(fileName, t_rnxObsFile::input);
|
---|
[4363] | 189 | rnxObsFiles.append(rnxObsFile);
|
---|
| 190 | }
|
---|
| 191 | catch (...) {
|
---|
[4525] | 192 | if (log) {
|
---|
| 193 | *log << "Error in rnxObsFile " << fileName.toAscii().data() << endl;
|
---|
| 194 | }
|
---|
[4363] | 195 | }
|
---|
[4080] | 196 | }
|
---|
[3901] | 197 | }
|
---|
[4254] | 198 | qStableSort(rnxObsFiles.begin(), rnxObsFiles.end(),
|
---|
[3901] | 199 | t_rnxObsFile::earlierStartTime);
|
---|
[4254] | 200 | }
|
---|
[3901] | 201 |
|
---|
[4254] | 202 | //
|
---|
| 203 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 204 | void t_reqcEdit::editObservations() {
|
---|
| 205 |
|
---|
| 206 | // Easy Exit
|
---|
| 207 | // ---------
|
---|
| 208 | if (_obsFileNames.isEmpty() || _outObsFileName.isEmpty()) {
|
---|
| 209 | return;
|
---|
| 210 | }
|
---|
| 211 |
|
---|
[4525] | 212 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
|
---|
[4254] | 213 |
|
---|
[3901] | 214 | // Initialize output observation file
|
---|
| 215 | // ----------------------------------
|
---|
| 216 | t_rnxObsFile outObsFile(_outObsFileName, t_rnxObsFile::output);
|
---|
| 217 |
|
---|
| 218 | // Loop over all input observation files
|
---|
| 219 | // -------------------------------------
|
---|
| 220 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 221 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
[4524] | 222 | if (_log) {
|
---|
| 223 | *_log << "Processing File: " << obsFile->fileName() << " start: "
|
---|
| 224 | << obsFile->startTime().datestr().c_str() << ' '
|
---|
| 225 | << obsFile->startTime().timestr(0).c_str() << endl;
|
---|
| 226 | }
|
---|
[3901] | 227 | if (ii == 0) {
|
---|
[3956] | 228 | outObsFile.setHeader(obsFile->header(), _rnxVersion);
|
---|
[3992] | 229 | if (_begTime.valid() && _begTime > outObsFile.startTime()) {
|
---|
| 230 | outObsFile.setStartTime(_begTime);
|
---|
| 231 | }
|
---|
[4112] | 232 | if (_samplingRate > outObsFile.interval()) {
|
---|
| 233 | outObsFile.setInterval(_samplingRate);
|
---|
| 234 | }
|
---|
[3982] | 235 | editRnxObsHeader(outObsFile);
|
---|
[4117] | 236 | bncSettings settings;
|
---|
[4114] | 237 | QMap<QString, QString> txtMap;
|
---|
[4117] | 238 | QString runBy = settings.value("reqcRunBy").toString();
|
---|
| 239 | if (!runBy.isEmpty()) {
|
---|
| 240 | txtMap["RUN BY"] = runBy;
|
---|
| 241 | }
|
---|
| 242 | QString comment = settings.value("reqcComment").toString();
|
---|
| 243 | if (!comment.isEmpty()) {
|
---|
| 244 | txtMap["COMMENT"] = comment;
|
---|
| 245 | }
|
---|
[4514] | 246 | outObsFile.header().write(outObsFile.stream(), &txtMap);
|
---|
[3901] | 247 | }
|
---|
[4054] | 248 | else {
|
---|
| 249 | outObsFile.checkNewHeader(obsFile->header());
|
---|
| 250 | }
|
---|
[3994] | 251 | t_rnxObsFile::t_rnxEpo* epo = 0;
|
---|
[4541] | 252 | try {
|
---|
| 253 | while ( (epo = obsFile->nextEpoch()) != 0) {
|
---|
| 254 | if (_begTime.valid() && epo->tt < _begTime) {
|
---|
| 255 | continue;
|
---|
| 256 | }
|
---|
| 257 | if (_endTime.valid() && epo->tt > _endTime) {
|
---|
| 258 | break;
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | if (_samplingRate == 0 ||
|
---|
| 262 | fmod(round(epo->tt.gpssec()), _samplingRate) == 0) {
|
---|
| 263 | applyLLI(obsFile, epo);
|
---|
| 264 | outObsFile.writeEpoch(epo);
|
---|
| 265 | }
|
---|
| 266 | else {
|
---|
| 267 | rememberLLI(obsFile, epo);
|
---|
| 268 | }
|
---|
[3993] | 269 | }
|
---|
[4541] | 270 | }
|
---|
| 271 | catch (QString str) {
|
---|
| 272 | if (_log) {
|
---|
| 273 | *_log << "Exception " << str << endl;
|
---|
[3993] | 274 | }
|
---|
[3994] | 275 | else {
|
---|
[4541] | 276 | qDebug() << str;
|
---|
[3994] | 277 | }
|
---|
[4541] | 278 | return;
|
---|
[3901] | 279 | }
|
---|
| 280 | }
|
---|
| 281 | }
|
---|
[3982] | 282 |
|
---|
| 283 | // Change RINEX Header Content
|
---|
| 284 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3985] | 285 | void t_reqcEdit::editRnxObsHeader(t_rnxObsFile& obsFile) {
|
---|
[3982] | 286 |
|
---|
[3983] | 287 | bncSettings settings;
|
---|
| 288 |
|
---|
| 289 | QString oldMarkerName = settings.value("reqcOldMarkerName").toString();
|
---|
| 290 | QString newMarkerName = settings.value("reqcNewMarkerName").toString();
|
---|
[4090] | 291 | if (!newMarkerName.isEmpty()) {
|
---|
| 292 | if (oldMarkerName.isEmpty() ||
|
---|
| 293 | QRegExp(oldMarkerName).exactMatch(obsFile.markerName())) {
|
---|
| 294 | obsFile.setMarkerName(newMarkerName);
|
---|
| 295 | }
|
---|
[3985] | 296 | }
|
---|
| 297 |
|
---|
[3983] | 298 | QString oldAntennaName = settings.value("reqcOldAntennaName").toString();
|
---|
| 299 | QString newAntennaName = settings.value("reqcNewAntennaName").toString();
|
---|
[4090] | 300 | if (!newAntennaName.isEmpty()) {
|
---|
| 301 | if (oldAntennaName.isEmpty() ||
|
---|
| 302 | QRegExp(oldAntennaName).exactMatch(obsFile.antennaName())) {
|
---|
| 303 | obsFile.setAntennaName(newAntennaName);
|
---|
| 304 | }
|
---|
[3985] | 305 | }
|
---|
[3983] | 306 |
|
---|
[3985] | 307 | QString oldReceiverType = settings.value("reqcOldReceiverName").toString();
|
---|
| 308 | QString newReceiverType = settings.value("reqcNewReceiverName").toString();
|
---|
[4090] | 309 | if (!newReceiverType.isEmpty()) {
|
---|
| 310 | if (oldReceiverType.isEmpty() ||
|
---|
| 311 | QRegExp(oldReceiverType).exactMatch(obsFile.receiverType())) {
|
---|
| 312 | obsFile.setReceiverType(newReceiverType);
|
---|
| 313 | }
|
---|
[3985] | 314 | }
|
---|
[3982] | 315 | }
|
---|
[3994] | 316 |
|
---|
| 317 | //
|
---|
| 318 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3995] | 319 | void t_reqcEdit::rememberLLI(const t_rnxObsFile* obsFile,
|
---|
| 320 | const t_rnxObsFile::t_rnxEpo* epo) {
|
---|
[3994] | 321 |
|
---|
[3995] | 322 | if (_samplingRate == 0) {
|
---|
| 323 | return;
|
---|
| 324 | }
|
---|
| 325 |
|
---|
| 326 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 327 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
| 328 | char sys = rnxSat.satSys;
|
---|
[3997] | 329 | QString prn = QString("%1%2").arg(sys).arg(rnxSat.satNum,2,10,QChar('0'));
|
---|
| 330 |
|
---|
[3995] | 331 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
[3997] | 332 | if (!_lli[prn].contains(iType)) {
|
---|
| 333 | _lli[prn][iType] = 0;
|
---|
[3996] | 334 | }
|
---|
| 335 | if (rnxSat.lli[iType] & 1) {
|
---|
[3997] | 336 | _lli[prn][iType] |= 1;
|
---|
[3996] | 337 | }
|
---|
[3995] | 338 | }
|
---|
| 339 | }
|
---|
[3994] | 340 | }
|
---|
| 341 |
|
---|
| 342 | //
|
---|
| 343 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3995] | 344 | void t_reqcEdit::applyLLI(const t_rnxObsFile* obsFile,
|
---|
| 345 | t_rnxObsFile::t_rnxEpo* epo) {
|
---|
[3996] | 346 |
|
---|
| 347 | if (_samplingRate == 0) {
|
---|
[3995] | 348 | return;
|
---|
| 349 | }
|
---|
[3996] | 350 |
|
---|
| 351 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 352 | t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
| 353 | char sys = rnxSat.satSys;
|
---|
[3997] | 354 | QString prn = QString("%1%2").arg(sys).arg(rnxSat.satNum,2,10,QChar('0'));
|
---|
| 355 |
|
---|
[3996] | 356 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
[3997] | 357 | if (_lli[prn].contains(iType) && _lli[prn][iType] & 1) {
|
---|
[3996] | 358 | rnxSat.lli[iType] |= 1;
|
---|
| 359 | }
|
---|
| 360 | }
|
---|
| 361 | }
|
---|
| 362 |
|
---|
| 363 | _lli.clear();
|
---|
[3994] | 364 | }
|
---|
[3998] | 365 |
|
---|
[4256] | 366 | /// Read All Ephemerides
|
---|
[3998] | 367 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4256] | 368 | void t_reqcEdit::readEphemerides(const QStringList& navFileNames,
|
---|
| 369 | QVector<t_eph*>& ephs) {
|
---|
[3998] | 370 |
|
---|
[4256] | 371 | QStringListIterator it(navFileNames);
|
---|
[3999] | 372 | while (it.hasNext()) {
|
---|
| 373 | QString fileName = it.next();
|
---|
[4081] | 374 | if (fileName.indexOf('*') != -1 || fileName.indexOf('?') != -1) {
|
---|
| 375 | QFileInfo fileInfo(fileName);
|
---|
| 376 | QDir dir = fileInfo.dir();
|
---|
| 377 | QStringList filters; filters << fileInfo.fileName();
|
---|
| 378 | QListIterator<QFileInfo> it(dir.entryInfoList(filters));
|
---|
| 379 | while (it.hasNext()) {
|
---|
| 380 | QString filePath = it.next().filePath();
|
---|
[4256] | 381 | appendEphemerides(filePath, ephs);
|
---|
[4000] | 382 | }
|
---|
| 383 | }
|
---|
[4081] | 384 | else {
|
---|
[4256] | 385 | appendEphemerides(fileName, ephs);
|
---|
[4081] | 386 | }
|
---|
[3999] | 387 | }
|
---|
[4256] | 388 | qStableSort(ephs.begin(), ephs.end(), t_eph::earlierTime);
|
---|
| 389 | }
|
---|
[3999] | 390 |
|
---|
[4256] | 391 | //
|
---|
| 392 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 393 | void t_reqcEdit::editEphemerides() {
|
---|
| 394 |
|
---|
| 395 | // Easy Exit
|
---|
| 396 | // ---------
|
---|
| 397 | if (_navFileNames.isEmpty() || _outNavFileName.isEmpty()) {
|
---|
| 398 | return;
|
---|
| 399 | }
|
---|
| 400 |
|
---|
[4257] | 401 | // Read Ephemerides
|
---|
| 402 | // ----------------
|
---|
[4256] | 403 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
| 404 |
|
---|
[4229] | 405 | // Check Satellite Systems
|
---|
| 406 | // -----------------------
|
---|
| 407 | bool haveGPS = false;
|
---|
| 408 | bool haveGlonass = false;
|
---|
| 409 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 410 | const t_eph* eph = _ephs[ii];
|
---|
| 411 | if (eph->type() == t_eph::GPS) {
|
---|
| 412 | haveGPS = true;
|
---|
| 413 | }
|
---|
| 414 | else if (eph->type() == t_eph::GLONASS) {
|
---|
| 415 | haveGlonass = true;
|
---|
| 416 | }
|
---|
| 417 | }
|
---|
| 418 |
|
---|
[4007] | 419 | // Initialize output navigation file
|
---|
| 420 | // ---------------------------------
|
---|
[4004] | 421 | t_rnxNavFile outNavFile(_outNavFileName, t_rnxNavFile::output);
|
---|
[4229] | 422 |
|
---|
| 423 | outNavFile.setGlonass(haveGlonass);
|
---|
| 424 |
|
---|
[5378] | 425 | if ( (haveGPS && haveGlonass) || _rnxVersion >= 3.0) {
|
---|
| 426 | outNavFile.setVersion(t_rnxNavFile::defaultRnxNavVersion3);
|
---|
[4229] | 427 | }
|
---|
| 428 | else {
|
---|
[5378] | 429 | outNavFile.setVersion(t_rnxNavFile::defaultRnxNavVersion2);
|
---|
[4229] | 430 | }
|
---|
| 431 |
|
---|
[4221] | 432 | bncSettings settings;
|
---|
| 433 | QMap<QString, QString> txtMap;
|
---|
| 434 | QString runBy = settings.value("reqcRunBy").toString();
|
---|
| 435 | if (!runBy.isEmpty()) {
|
---|
| 436 | txtMap["RUN BY"] = runBy;
|
---|
| 437 | }
|
---|
| 438 | QString comment = settings.value("reqcComment").toString();
|
---|
| 439 | if (!comment.isEmpty()) {
|
---|
| 440 | txtMap["COMMENT"] = comment;
|
---|
| 441 | }
|
---|
[4229] | 442 |
|
---|
[4221] | 443 | outNavFile.writeHeader(&txtMap);
|
---|
[4009] | 444 |
|
---|
[4004] | 445 | // Loop over all ephemerides
|
---|
| 446 | // -------------------------
|
---|
| 447 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 448 | const t_eph* eph = _ephs[ii];
|
---|
[4229] | 449 | outNavFile.writeEph(eph);
|
---|
[4004] | 450 | }
|
---|
[3998] | 451 | }
|
---|
[4081] | 452 |
|
---|
| 453 | //
|
---|
| 454 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4256] | 455 | void t_reqcEdit::appendEphemerides(const QString& fileName,
|
---|
| 456 | QVector<t_eph*>& ephs) {
|
---|
[4081] | 457 |
|
---|
| 458 | t_rnxNavFile rnxNavFile(fileName, t_rnxNavFile::input);
|
---|
| 459 | for (unsigned ii = 0; ii < rnxNavFile.ephs().size(); ii++) {
|
---|
| 460 | t_eph* eph = rnxNavFile.ephs()[ii];
|
---|
| 461 | bool isNew = true;
|
---|
[4256] | 462 | for (int iOld = 0; iOld < ephs.size(); iOld++) {
|
---|
| 463 | const t_eph* ephOld = ephs[iOld];
|
---|
[4236] | 464 | if (ephOld->prn() == eph->prn() && ephOld->TOC() == eph->TOC()) {
|
---|
[4081] | 465 | isNew = false;
|
---|
| 466 | break;
|
---|
| 467 | }
|
---|
| 468 | }
|
---|
| 469 | if (isNew) {
|
---|
| 470 | if (eph->type() == t_eph::GPS) {
|
---|
[4256] | 471 | ephs.append(new t_ephGPS(*dynamic_cast<t_ephGPS*>(eph)));
|
---|
[4081] | 472 | }
|
---|
| 473 | else if (eph->type() == t_eph::GLONASS) {
|
---|
[4256] | 474 | ephs.append(new t_ephGlo(*dynamic_cast<t_ephGlo*>(eph)));
|
---|
[4081] | 475 | }
|
---|
| 476 | else if (eph->type() == t_eph::Galileo) {
|
---|
[4256] | 477 | ephs.append(new t_ephGal(*dynamic_cast<t_ephGal*>(eph)));
|
---|
[4081] | 478 | }
|
---|
| 479 | }
|
---|
| 480 | }
|
---|
| 481 | }
|
---|