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

Last change on this file since 9034 was 8798, checked in by stuerze, 5 years ago

minor changes

File size: 23.2 KB
Line 
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"
43#include "bnccore.h"
44#include "bncsettings.h"
45#include "bncutils.h"
46#include "rnxobsfile.h"
47#include "rnxnavfile.h"
48
49using namespace std;
50
51// Constructor
52////////////////////////////////////////////////////////////////////////////
53t_reqcEdit::t_reqcEdit(QObject* parent) : QThread(parent) {
54
55 bncSettings settings;
56
57 _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
58 _logFile = 0;
59 _log = 0;
60 _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
61 _outObsFileName = settings.value("reqcOutObsFile").toString();
62 _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
63 _outNavFileName = settings.value("reqcOutNavFile").toString();
64 int version = settings.value("reqcRnxVersion").toInt();
65 if (version < 3) {
66 _rnxVersion = defaultRnxObsVersion2;
67 }
68 else {
69 _rnxVersion = defaultRnxObsVersion3;
70 }
71 _samplingRate = settings.value("reqcSampling").toString().split("sec").first().toDouble();
72 _begTime = bncTime(settings.value("reqcStartDateTime").toString().toLatin1().data());
73 _endTime = bncTime(settings.value("reqcEndDateTime").toString().toLatin1().data());
74
75}
76
77// Destructor
78////////////////////////////////////////////////////////////////////////////
79t_reqcEdit::~t_reqcEdit() {
80 for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
81 delete _rnxObsFiles[ii];
82 }
83 for (int ii = 0; ii < _ephs.size(); ii++) {
84 delete _ephs[ii];
85 }
86 delete _log; _log = 0;
87 delete _logFile; _logFile = 0;
88}
89
90//
91////////////////////////////////////////////////////////////////////////////
92void t_reqcEdit::run() {
93
94 // Open Log File
95 // -------------
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 }
102 }
103
104 // Log File Header
105 // ---------------
106 if (_log) {
107 *_log << QByteArray(78, '-') << endl;
108 *_log << "RINEX File Editing\n";
109 *_log << QByteArray(78, '-') << endl;
110
111 *_log << QByteArray("Program").leftJustified(15) << ": "
112 << BNC_CORE->pgmName() << endl;
113 *_log << QByteArray("Run by").leftJustified(15) << ": "
114 << BNC_CORE->userName() << endl;
115 *_log << QByteArray("Date").leftJustified(15) << ": "
116 << QDateTime::currentDateTime().toUTC().toString("yyyy-MM-dd hh:mm:ss") << endl;
117 *_log << QByteArray("RINEX Version").leftJustified(15) << ": "
118 << _rnxVersion << endl;
119 *_log << QByteArray("Sampling").leftJustified(15) << ": "
120 << _samplingRate << " sec" << endl;
121 *_log << QByteArray("Start time").leftJustified(15) << ": "
122 << _begTime.datestr().c_str() << ' '
123 << _begTime.timestr(0).c_str() << endl;
124 *_log << QByteArray("End time").leftJustified(15) << ": "
125 << _endTime.datestr().c_str() << ' '
126 << _endTime.timestr(0).c_str() << endl;
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;
135
136 *_log << QByteArray(78, '-') << endl;
137 _log->flush();
138 }
139
140 // Handle Observation Files
141 // ------------------------
142 editObservations();
143
144 // Handle Navigations Files
145 // ------------------------
146 editEphemerides();
147
148 // Exit (thread)
149 // -------------
150 if (BNC_CORE->mode() != t_bncCore::interactive) {
151 qApp->exit(0);
152 msleep(100); //sleep 0.1 sec
153 }
154 else {
155 emit finished();
156 deleteLater();
157 }
158
159}
160
161// Initialize input observation files, sort them according to start time
162////////////////////////////////////////////////////////////////////////////
163void t_reqcEdit::initRnxObsFiles(const QStringList& obsFileNames,
164 QVector<t_rnxObsFile*>& rnxObsFiles,
165 QTextStream* log) {
166
167 QStringListIterator it(obsFileNames);
168 while (it.hasNext()) {
169 QString fileName = it.next();
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()) {
176 QString filePath = it.next().filePath();
177 t_rnxObsFile* rnxObsFile = 0;
178 try {
179 rnxObsFile = new t_rnxObsFile(filePath, t_rnxObsFile::input);
180 rnxObsFiles.append(rnxObsFile);
181 }
182 catch (...) {
183 delete rnxObsFile;
184 if (log) {
185 *log << "Error in rnxObsFile " << filePath.toLatin1().data() << endl;
186 }
187 }
188 }
189 }
190 else {
191 t_rnxObsFile* rnxObsFile = 0;
192 try {
193 rnxObsFile = new t_rnxObsFile(fileName, t_rnxObsFile::input);
194 rnxObsFiles.append(rnxObsFile);
195 }
196 catch (...) {
197 if (log) {
198 *log << "Error in rnxObsFile " << fileName.toLatin1().data() << endl;
199 }
200 }
201 }
202 }
203 qStableSort(rnxObsFiles.begin(), rnxObsFiles.end(),
204 t_rnxObsFile::earlierStartTime);
205}
206
207//
208////////////////////////////////////////////////////////////////////////////
209void t_reqcEdit::editObservations() {
210
211 // Easy Exit
212 // ---------
213 if (_obsFileNames.isEmpty() || _outObsFileName.isEmpty()) {
214 return;
215 }
216
217 t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles, _log);
218
219 // Initialize output observation file
220 // ----------------------------------
221 t_rnxObsFile outObsFile(_outObsFileName, t_rnxObsFile::output);
222
223 // Select observation types
224 // ------------------------
225 bncSettings settings;
226 QStringList useObsTypes = settings.value("reqcUseObsTypes").toString().split(" ", QString::SkipEmptyParts);
227
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 != ' ') {
236 for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
237 QString type = obsFile->obsType(sys, iType);
238 if (_rnxVersion < 3.0) {
239 useObsTypes << type;
240 }
241 else {
242 useObsTypes << QString(sys) + ":" + type;
243 }
244 }
245 }
246 }
247 }
248 useObsTypes.removeDuplicates();
249 }
250
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
295 // Loop over all input observation files
296 // -------------------------------------
297 for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
298 t_rnxObsFile* obsFile = _rnxObsFiles[ii];
299 if (_log) {
300 *_log << "Processing File: " << obsFile->fileName() << " start: "
301 << obsFile->startTime().datestr().c_str() << ' '
302 << obsFile->startTime().timestr(0).c_str() << endl;
303 }
304 if (ii == 0) {
305 outObsFile.setHeader(obsFile->header(), int(_rnxVersion), &useObsTypes,
306 &phaseShifts, &gloBiases, &gloSlots);
307 if (_begTime.valid() && _begTime > outObsFile.startTime()) {
308 outObsFile.setStartTime(_begTime);
309 }
310 if (_samplingRate > outObsFile.interval()) {
311 outObsFile.setInterval(_samplingRate);
312 }
313 editRnxObsHeader(outObsFile);
314 bncSettings settings;
315 QMap<QString, QString> txtMap;
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 }
324 if (int(_rnxVersion) < int(obsFile->header().version())) {
325 addRnxConversionDetails(obsFile, txtMap);
326 }
327 outObsFile.header().write(outObsFile.stream(), &txtMap);
328 }
329 t_rnxObsFile::t_rnxEpo* epo = 0;
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 }
338
339 int sec = int(nint(epo->tt.gpssec()*10));
340 if (sec % (int(_samplingRate)*10) == 0) {
341 applyLLI(obsFile, epo);
342 outObsFile.writeEpoch(epo);
343 }
344 else {
345 rememberLLI(obsFile, epo);
346 }
347 }
348 }
349 catch (QString str) {
350 if (_log) {
351 *_log << "Exception " << str << endl;
352 }
353 else {
354 qDebug() << str;
355 }
356 return;
357 }
358 catch (...) {
359 if (_log) {
360 *_log << "Exception unknown" << endl;
361 }
362 else {
363 qDebug() << "Exception unknown";
364 }
365 return;
366 }
367 }
368}
369
370// Change RINEX Header Content
371////////////////////////////////////////////////////////////////////////////
372void t_reqcEdit::editRnxObsHeader(t_rnxObsFile& obsFile) {
373
374 bncSettings settings;
375
376 QString oldMarkerName = settings.value("reqcOldMarkerName").toString();
377 QString newMarkerName = settings.value("reqcNewMarkerName").toString();
378 if (!newMarkerName.isEmpty()) {
379 if (oldMarkerName.isEmpty() ||
380 QRegExp(oldMarkerName).exactMatch(obsFile.markerName())) {
381 obsFile.setMarkerName(newMarkerName);
382 }
383 }
384
385 QString oldAntennaName = settings.value("reqcOldAntennaName").toString();
386 QString newAntennaName = settings.value("reqcNewAntennaName").toString();
387 if (!newAntennaName.isEmpty()) {
388 if (oldAntennaName.isEmpty() ||
389 QRegExp(oldAntennaName).exactMatch(obsFile.antennaName())) {
390 obsFile.setAntennaName(newAntennaName);
391 }
392 }
393
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
430 QString oldReceiverType = settings.value("reqcOldReceiverName").toString();
431 QString newReceiverType = settings.value("reqcNewReceiverName").toString();
432 if (!newReceiverType.isEmpty()) {
433 if (oldReceiverType.isEmpty() ||
434 QRegExp(oldReceiverType).exactMatch(obsFile.receiverType())) {
435 obsFile.setReceiverType(newReceiverType);
436 }
437 }
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 }
447}
448
449//
450////////////////////////////////////////////////////////////////////////////
451void t_reqcEdit::rememberLLI(const t_rnxObsFile* obsFile,
452 const t_rnxObsFile::t_rnxEpo* epo) {
453
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];
460 char sys = rnxSat.prn.system();
461 QString prn(rnxSat.prn.toString().c_str());
462
463 for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
464 QString type = obsFile->obsType(sys, iType);
465 if (!_lli[prn].contains(iType)) {
466 _lli[prn][iType] = 0;
467 }
468 if (rnxSat.obs.contains(type) && rnxSat.obs[type].lli & 1) {
469 _lli[prn][iType] |= 1;
470 }
471 }
472 }
473}
474
475//
476////////////////////////////////////////////////////////////////////////////
477void t_reqcEdit::applyLLI(const t_rnxObsFile* obsFile,
478 t_rnxObsFile::t_rnxEpo* epo) {
479
480 if (_samplingRate == 0) {
481 return;
482 }
483
484 for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
485 t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
486 char sys = rnxSat.prn.system();
487 QString prn(rnxSat.prn.toString().c_str());
488
489 for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
490 QString type = obsFile->obsType(sys, iType);
491 if (_lli[prn].contains(iType) && _lli[prn][iType] & 1) {
492 if (rnxSat.obs.contains(type)) {
493 rnxSat.obs[type].lli |= 1;
494 }
495 }
496 }
497 }
498
499 _lli.clear();
500}
501
502/// Read All Ephemerides
503////////////////////////////////////////////////////////////////////////////
504void t_reqcEdit::readEphemerides(const QStringList& navFileNames,
505 QVector<t_eph*>& ephs) {
506
507 QStringListIterator it(navFileNames);
508 while (it.hasNext()) {
509 QString fileName = it.next();
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()) {
516 QString filePath = it.next().filePath();
517 appendEphemerides(filePath, ephs);
518 }
519 }
520 else {
521 appendEphemerides(fileName, ephs);
522 }
523 }
524 // TODO: enable user decision
525 qStableSort(ephs.begin(), ephs.end(), t_eph::earlierTime);
526 //qStableSort(ephs.begin(), ephs.end(), t_eph::prnSort);
527}
528
529//
530////////////////////////////////////////////////////////////////////////////
531void t_reqcEdit::editEphemerides() {
532
533 // Easy Exit
534 // ---------
535 if (_navFileNames.isEmpty() || _outNavFileName.isEmpty()) {
536 return;
537 }
538 // Concatenate all comments
539 // ------------------------
540 QStringList comments;
541 bncSettings settings;
542 QString comment = settings.value("reqcComment").toString();
543 if (!comment.isEmpty()) {
544 comments.append(comment);
545 }
546 QStringListIterator it(_navFileNames);
547 while (it.hasNext()) {
548 QString fileName = it.next();
549 t_rnxNavFile rnxNavFile(fileName, t_rnxNavFile::input);
550 QStringListIterator itCmnt(rnxNavFile.comments());
551 while (itCmnt.hasNext()) {
552 comments.append(itCmnt.next());
553 }
554 }
555 comments.removeDuplicates();
556
557 // Read Ephemerides
558 // ----------------
559 t_reqcEdit::readEphemerides(_navFileNames, _ephs);
560
561 // Check Satellite Systems
562 // -----------------------
563 bool haveGPS = false;
564 bool haveGlonass = false;
565 QMap<t_eph::e_type, bool> haveGnss;
566 for (int ii = 0; ii < _ephs.size(); ii++) {
567 const t_eph* eph = _ephs[ii];
568 switch (eph->type()) {
569 case t_eph::GPS:
570 haveGPS = true;
571 haveGnss[t_eph::GPS] = true;
572 break;
573 case t_eph::GLONASS:
574 haveGlonass = true;
575 haveGnss[t_eph::GLONASS] = true;
576 break;
577 case t_eph::Galileo:
578 haveGnss[t_eph::Galileo] = true;
579 break;
580 case t_eph::BDS:
581 haveGnss[t_eph::BDS] = true;
582 break;
583 case t_eph::QZSS:
584 haveGnss[t_eph::QZSS] = true;
585 break;
586 case t_eph::IRNSS:
587 haveGnss[t_eph::IRNSS] = true;
588 break;
589 case t_eph::SBAS:
590 haveGnss[t_eph::SBAS] = true;
591 break;
592 default:
593 haveGnss[t_eph::unknown] = true;
594 }
595 }
596
597 // Initialize output navigation file
598 // ---------------------------------
599 t_rnxNavFile outNavFile(_outNavFileName, t_rnxNavFile::output);
600
601 outNavFile.setGlonass(haveGlonass);
602
603 if ( (haveGPS && haveGlonass) || _rnxVersion >= 3.0) {
604 outNavFile.setVersion(defaultRnxNavVersion3);
605 }
606 else {
607 outNavFile.setVersion(defaultRnxNavVersion2);
608 }
609
610 if (outNavFile.version() > 3.0) {
611 if (haveGnss.size() > 1) {
612 outNavFile.setGnssTypeV3(t_eph::unknown);
613 }
614 else if (haveGnss.size() == 1){
615 outNavFile.setGnssTypeV3(haveGnss.keys().first());
616 }
617 }
618
619 QMap<QString, QString> txtMap;
620 QString runBy = settings.value("reqcRunBy").toString();
621 if (!runBy.isEmpty()) {
622 txtMap["RUN BY"] = runBy;
623 }
624 if (!comments.isEmpty()) {
625 txtMap["COMMENT"] = comments.join("\\n");
626 }
627
628 outNavFile.writeHeader(&txtMap);
629
630 // Loop over all ephemerides
631 // -------------------------
632 for (int ii = 0; ii < _ephs.size(); ii++) {
633 const t_eph* eph = _ephs[ii];
634 bncTime begTime = _begTime;
635 bncTime endTime = _endTime;
636 if (eph->type() == t_eph::BDS) {
637 begTime += 14;
638 endTime += 14;
639 }
640 if (begTime.valid() && eph->TOC() < begTime) {
641 continue;
642 }
643 if (endTime.valid() && eph->TOC() > endTime) {
644 break;
645 }
646 if (eph->checkState() == t_eph::bad) {
647 continue;
648 }
649 outNavFile.writeEph(eph);
650 }
651}
652
653//
654////////////////////////////////////////////////////////////////////////////
655void t_reqcEdit::appendEphemerides(const QString& fileName,
656 QVector<t_eph*>& ephs) {
657 t_rnxNavFile rnxNavFile(fileName, t_rnxNavFile::input);
658 for (unsigned ii = 0; ii < rnxNavFile.ephs().size(); ii++) {
659 t_eph* eph = rnxNavFile.ephs()[ii];
660 bool isNew = true;
661 for (int iOld = 0; iOld < ephs.size(); iOld++) {
662 const t_eph* ephOld = ephs[iOld];
663 if (ephOld->prn() == eph->prn() &&
664 ephOld->TOC() == eph->TOC()) {
665 isNew = false;
666 break;
667 }
668 }
669 if (isNew) {
670 if (eph->type() == t_eph::GPS) {
671 ephs.append(new t_ephGPS(*dynamic_cast<t_ephGPS*>(eph)));
672 }
673 else if (eph->type() == t_eph::GLONASS) {
674 ephs.append(new t_ephGlo(*dynamic_cast<t_ephGlo*>(eph)));
675 }
676 else if (eph->type() == t_eph::Galileo) {
677 ephs.append(new t_ephGal(*dynamic_cast<t_ephGal*>(eph)));
678 }
679 else if (eph->type() == t_eph::QZSS) {
680 ephs.append(new t_ephGPS(*dynamic_cast<t_ephGPS*>(eph)));
681 }
682 else if (eph->type() == t_eph::SBAS) {
683 ephs.append(new t_ephSBAS(*dynamic_cast<t_ephSBAS*>(eph)));
684 }
685 else if (eph->type() == t_eph::BDS) {
686 ephs.append(new t_ephBDS(*dynamic_cast<t_ephBDS*>(eph)));
687 }
688 else if (eph->type() == t_eph::IRNSS) {
689 ephs.append(new t_ephGPS(*dynamic_cast<t_ephGPS*>(eph)));
690 }
691 }
692 }
693}
694
695void t_reqcEdit::addRnxConversionDetails(const t_rnxObsFile* obsFile,
696 QMap<QString, QString>& txtMap) {
697
698 int key = 0;
699 QString systems = obsFile->header().usedSystems();
700 QString comment = QString("Signal priorities for RINEX 3 => 2 conversion:");
701 QString commentKey = QString("COMMENT %1").arg(key, 3, 10, QChar('0'));
702 txtMap.insert(commentKey, comment);
703
704 for(int ii = 0; ii < obsFile->numSys(); ii++) {
705 char sys = systems[ii].toLatin1();
706 txtMap.insert(commentKey, comment);
707 QMap <char, QString> signalPriorityMap;
708 QStringList preferredAttribListSys = obsFile->signalPriorities(sys);
709 QStringList types = obsFile->header().obsTypes(sys);
710 for (int jj = 0; jj < types.size(); jj++) {
711 QString inType = types[jj];
712 char band = inType[1].toLatin1();
713 for (int ii = 0; ii < preferredAttribListSys.size(); ii++) {
714 QString preferredAttrib;
715 if (preferredAttribListSys[ii].indexOf("&") != -1) {
716 QStringList hlp = preferredAttribListSys[ii].split("&", QString::SkipEmptyParts);
717 if (hlp.size() == 2 && hlp[0].contains(band)) {
718 preferredAttrib = hlp[1];
719 }
720 }
721 else {
722 preferredAttrib = preferredAttribListSys[ii];
723 }
724 if (!signalPriorityMap.contains(band) && !preferredAttrib.isEmpty()){
725 signalPriorityMap[band] = preferredAttrib;
726 }
727 }
728 }
729 QMapIterator<char, QString> it(signalPriorityMap);
730 while (it.hasNext()) {
731 it.next();
732 key++;
733 comment = QString("%1 band %2: %3").arg(sys).arg(it.key()).arg(it.value());
734 commentKey = QString("COMMENT %1").arg(key, 3, 10, QChar('0'));
735 txtMap.insert(commentKey, comment);
736 }
737 }
738}
Note: See TracBrowser for help on using the repository browser.