source: ntrip/trunk/BNC/src/rinex/reqcedit.cpp@ 7574

Last change on this file since 7574 was 7474, checked in by stuerze, 9 years ago

in case of RINEX3 to RINEX 2 conversion now some comment lines are written into the RINEX header

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