[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"
|
---|
[3972] | 43 | #include "bncapp.h"
|
---|
[3901] | 44 | #include "bncsettings.h"
|
---|
| 45 |
|
---|
| 46 | using namespace std;
|
---|
| 47 |
|
---|
| 48 | // Constructor
|
---|
| 49 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 50 | t_reqcEdit::t_reqcEdit(QObject* parent) : QThread(parent) {
|
---|
| 51 |
|
---|
| 52 | bncSettings settings;
|
---|
| 53 |
|
---|
| 54 | _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
|
---|
| 55 | _outObsFileName = settings.value("reqcOutObsFile").toString();
|
---|
[3938] | 56 | _rnxVersion = settings.value("reqcRnxVersion").toDouble();
|
---|
[3981] | 57 | _samplingRate = settings.value("reqcSampling").toInt();
|
---|
[3989] | 58 | _begTime = bncTime(settings.value("reqcStartDateTime").toString().toAscii().data());
|
---|
| 59 | _endTime = bncTime(settings.value("reqcEndDateTime").toString().toAscii().data());
|
---|
[3901] | 60 | }
|
---|
| 61 |
|
---|
| 62 | // Destructor
|
---|
| 63 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 64 | t_reqcEdit::~t_reqcEdit() {
|
---|
| 65 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 66 | delete _rnxObsFiles[ii];
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | //
|
---|
| 71 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 72 | void t_reqcEdit::run() {
|
---|
| 73 |
|
---|
| 74 | // Initialize input observation files, sort them according to start time
|
---|
| 75 | // ---------------------------------------------------------------------
|
---|
| 76 | QStringListIterator it(_obsFileNames);
|
---|
| 77 | while (it.hasNext()) {
|
---|
| 78 | QString fileName = it.next();
|
---|
| 79 | t_rnxObsFile* rnxObsFile = new t_rnxObsFile(fileName, t_rnxObsFile::input);
|
---|
| 80 | _rnxObsFiles.append(rnxObsFile);
|
---|
| 81 | }
|
---|
| 82 | qStableSort(_rnxObsFiles.begin(), _rnxObsFiles.end(),
|
---|
| 83 | t_rnxObsFile::earlierStartTime);
|
---|
| 84 |
|
---|
| 85 | // Initialize output observation file
|
---|
| 86 | // ----------------------------------
|
---|
| 87 | t_rnxObsFile outObsFile(_outObsFileName, t_rnxObsFile::output);
|
---|
| 88 |
|
---|
| 89 | // Loop over all input observation files
|
---|
| 90 | // -------------------------------------
|
---|
| 91 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 92 | t_rnxObsFile* obsFile = _rnxObsFiles[ii];
|
---|
| 93 | if (ii == 0) {
|
---|
[3956] | 94 | outObsFile.setHeader(obsFile->header(), _rnxVersion);
|
---|
[3992] | 95 | if (_begTime.valid() && _begTime > outObsFile.startTime()) {
|
---|
| 96 | outObsFile.setStartTime(_begTime);
|
---|
| 97 | }
|
---|
[3982] | 98 | editRnxObsHeader(outObsFile);
|
---|
[3901] | 99 | outObsFile.writeHeader();
|
---|
| 100 | }
|
---|
[3994] | 101 | t_rnxObsFile::t_rnxEpo* epo = 0;
|
---|
[3901] | 102 | while ( (epo = obsFile->nextEpoch()) != 0) {
|
---|
[3993] | 103 | if (_begTime.valid() && epo->tt < _begTime) {
|
---|
| 104 | continue;
|
---|
| 105 | }
|
---|
| 106 | if (_endTime.valid() && epo->tt > _endTime) {
|
---|
| 107 | break;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | if (_samplingRate == 0 ||
|
---|
| 111 | fmod(round(epo->tt.gpssec()), _samplingRate) == 0) {
|
---|
[3995] | 112 | applyLLI(obsFile, epo);
|
---|
[3990] | 113 | outObsFile.writeEpoch(epo);
|
---|
| 114 | }
|
---|
[3994] | 115 | else {
|
---|
[3995] | 116 | rememberLLI(obsFile, epo);
|
---|
[3994] | 117 | }
|
---|
[3901] | 118 | }
|
---|
| 119 | }
|
---|
| 120 |
|
---|
[3972] | 121 | bncApp* app = (bncApp*) qApp;
|
---|
| 122 | if ( app->mode() != bncApp::interactive) {
|
---|
| 123 | app->exit(0);
|
---|
| 124 | }
|
---|
| 125 | else {
|
---|
| 126 | emit finished();
|
---|
| 127 | deleteLater();
|
---|
| 128 | }
|
---|
[3901] | 129 | }
|
---|
[3982] | 130 |
|
---|
| 131 | // Change RINEX Header Content
|
---|
| 132 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3985] | 133 | void t_reqcEdit::editRnxObsHeader(t_rnxObsFile& obsFile) {
|
---|
[3982] | 134 |
|
---|
[3983] | 135 | bncSettings settings;
|
---|
| 136 |
|
---|
| 137 | QString oldMarkerName = settings.value("reqcOldMarkerName").toString();
|
---|
| 138 | QString newMarkerName = settings.value("reqcNewMarkerName").toString();
|
---|
[3985] | 139 | if (oldMarkerName.isEmpty() ||
|
---|
| 140 | QRegExp(oldMarkerName).exactMatch(obsFile.markerName())) {
|
---|
| 141 | obsFile.setMarkerName(newMarkerName);
|
---|
| 142 | }
|
---|
| 143 |
|
---|
[3983] | 144 | QString oldAntennaName = settings.value("reqcOldAntennaName").toString();
|
---|
| 145 | QString newAntennaName = settings.value("reqcNewAntennaName").toString();
|
---|
[3985] | 146 | if (oldAntennaName.isEmpty() ||
|
---|
| 147 | QRegExp(oldAntennaName).exactMatch(obsFile.antennaName())) {
|
---|
| 148 | obsFile.setAntennaName(newAntennaName);
|
---|
| 149 | }
|
---|
[3983] | 150 |
|
---|
[3985] | 151 | QString oldReceiverType = settings.value("reqcOldReceiverName").toString();
|
---|
| 152 | QString newReceiverType = settings.value("reqcNewReceiverName").toString();
|
---|
| 153 | if (oldReceiverType.isEmpty() ||
|
---|
| 154 | QRegExp(oldReceiverType).exactMatch(obsFile.receiverType())) {
|
---|
| 155 | obsFile.setReceiverType(newReceiverType);
|
---|
| 156 | }
|
---|
[3982] | 157 | }
|
---|
[3994] | 158 |
|
---|
| 159 | //
|
---|
| 160 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3995] | 161 | void t_reqcEdit::rememberLLI(const t_rnxObsFile* obsFile,
|
---|
| 162 | const t_rnxObsFile::t_rnxEpo* epo) {
|
---|
[3994] | 163 |
|
---|
[3995] | 164 | if (_samplingRate == 0) {
|
---|
| 165 | return;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 169 | const t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
| 170 | char sys = rnxSat.satSys;
|
---|
[3997] | 171 | QString prn = QString("%1%2").arg(sys).arg(rnxSat.satNum,2,10,QChar('0'));
|
---|
| 172 |
|
---|
[3995] | 173 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
[3997] | 174 | if (!_lli[prn].contains(iType)) {
|
---|
| 175 | _lli[prn][iType] = 0;
|
---|
[3996] | 176 | }
|
---|
| 177 | if (rnxSat.lli[iType] & 1) {
|
---|
[3997] | 178 | _lli[prn][iType] |= 1;
|
---|
[3996] | 179 | }
|
---|
[3995] | 180 | }
|
---|
| 181 | }
|
---|
[3994] | 182 | }
|
---|
| 183 |
|
---|
| 184 | //
|
---|
| 185 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3995] | 186 | void t_reqcEdit::applyLLI(const t_rnxObsFile* obsFile,
|
---|
| 187 | t_rnxObsFile::t_rnxEpo* epo) {
|
---|
[3996] | 188 |
|
---|
| 189 | if (_samplingRate == 0) {
|
---|
[3995] | 190 | return;
|
---|
| 191 | }
|
---|
[3996] | 192 |
|
---|
| 193 | for (unsigned iSat = 0; iSat < epo->rnxSat.size(); iSat++) {
|
---|
| 194 | t_rnxObsFile::t_rnxSat& rnxSat = epo->rnxSat[iSat];
|
---|
| 195 | char sys = rnxSat.satSys;
|
---|
[3997] | 196 | QString prn = QString("%1%2").arg(sys).arg(rnxSat.satNum,2,10,QChar('0'));
|
---|
| 197 |
|
---|
[3996] | 198 | for (int iType = 0; iType < obsFile->nTypes(sys); iType++) {
|
---|
[3997] | 199 | if (_lli[prn].contains(iType) && _lli[prn][iType] & 1) {
|
---|
[3996] | 200 | rnxSat.lli[iType] |= 1;
|
---|
| 201 | }
|
---|
| 202 | }
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | _lli.clear();
|
---|
[3994] | 206 | }
|
---|