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

Last change on this file since 9765 was 9765, checked in by stuerze, 2 months ago

some more changes to consider RINEX Version 4 nav file (EPH key only)

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