[3899] | 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_reqcAnalyze
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Analyze RINEX Files
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 11-Apr-2012
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iostream>
|
---|
| 42 | #include "reqcanalyze.h"
|
---|
[3973] | 43 | #include "bncapp.h"
|
---|
[3899] | 44 | #include "bncsettings.h"
|
---|
[4254] | 45 | #include "reqcedit.h"
|
---|
[4255] | 46 | #include "bncutils.h"
|
---|
[4262] | 47 | #include "bncpostprocess.h"
|
---|
[3899] | 48 |
|
---|
| 49 | using namespace std;
|
---|
| 50 |
|
---|
| 51 | // Constructor
|
---|
| 52 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 53 | t_reqcAnalyze::t_reqcAnalyze(QObject* parent) : QThread(parent) {
|
---|
| 54 |
|
---|
| 55 | bncSettings settings;
|
---|
[4254] | 56 |
|
---|
[4257] | 57 | _logFileName = settings.value("reqcOutLogFile").toString(); expandEnvVar(_logFileName);
|
---|
| 58 | _logFile = 0;
|
---|
| 59 | _log = 0;
|
---|
[4254] | 60 | _obsFileNames = settings.value("reqcObsFile").toString().split(",", QString::SkipEmptyParts);
|
---|
[4257] | 61 | _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
|
---|
[4266] | 62 |
|
---|
| 63 | _currEpo = 0;
|
---|
[3899] | 64 | }
|
---|
| 65 |
|
---|
| 66 | // Destructor
|
---|
| 67 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 68 | t_reqcAnalyze::~t_reqcAnalyze() {
|
---|
[4255] | 69 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 70 | delete _rnxObsFiles[ii];
|
---|
| 71 | }
|
---|
| 72 | for (int ii = 0; ii < _ephs.size(); ii++) {
|
---|
| 73 | delete _ephs[ii];
|
---|
| 74 | }
|
---|
| 75 | delete _log; _log = 0;
|
---|
| 76 | delete _logFile; _logFile = 0;
|
---|
[3899] | 77 | }
|
---|
| 78 |
|
---|
| 79 | //
|
---|
| 80 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 81 | void t_reqcAnalyze::run() {
|
---|
| 82 |
|
---|
[4255] | 83 | // Open Log File
|
---|
| 84 | // -------------
|
---|
| 85 | _logFile = new QFile(_logFileName);
|
---|
| 86 | _logFile->open(QIODevice::WriteOnly | QIODevice::Text);
|
---|
| 87 | _log = new QTextStream();
|
---|
| 88 | _log->setDevice(_logFile);
|
---|
| 89 |
|
---|
| 90 | // Initialize RINEX Observation Files
|
---|
| 91 | // ----------------------------------
|
---|
[4254] | 92 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles);
|
---|
[3899] | 93 |
|
---|
[4257] | 94 | // Read Ephemerides
|
---|
| 95 | // ----------------
|
---|
| 96 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
| 97 |
|
---|
[4255] | 98 | // Loop over all RINEX Files
|
---|
| 99 | // -------------------------
|
---|
[4254] | 100 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
| 101 | analyzeFile(_rnxObsFiles[ii]);
|
---|
| 102 | }
|
---|
| 103 |
|
---|
[4255] | 104 | // Exit
|
---|
| 105 | // ----
|
---|
[3973] | 106 | bncApp* app = (bncApp*) qApp;
|
---|
| 107 | if ( app->mode() != bncApp::interactive) {
|
---|
| 108 | app->exit(0);
|
---|
| 109 | }
|
---|
| 110 | else {
|
---|
| 111 | emit finished();
|
---|
| 112 | deleteLater();
|
---|
| 113 | }
|
---|
[3899] | 114 | }
|
---|
[4254] | 115 |
|
---|
| 116 | //
|
---|
| 117 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4260] | 118 | void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
|
---|
[4259] | 119 |
|
---|
[4260] | 120 | *_log << "Analyze File\n"
|
---|
| 121 | << "------------\n"
|
---|
| 122 | << obsFile->fileName().toAscii().data() << endl << endl;
|
---|
| 123 |
|
---|
[4262] | 124 | // Loop over all Epochs
|
---|
| 125 | // --------------------
|
---|
[4266] | 126 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
---|
[4260] | 127 |
|
---|
[4262] | 128 | // Loop over all satellites
|
---|
| 129 | // ------------------------
|
---|
[4266] | 130 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
---|
| 131 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
---|
[4262] | 132 | t_obs obs;
|
---|
[4266] | 133 | t_postProcessing::setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
|
---|
[4260] | 134 |
|
---|
[4262] | 135 | if (obs.satSys == 'R') {
|
---|
[4266] | 136 | continue; // TODO: set channel number
|
---|
[4262] | 137 | }
|
---|
| 138 |
|
---|
[4263] | 139 | QString prn = QString("%1%2").arg(obs.satSys)
|
---|
| 140 | .arg(obs.satNum, 2, 10, QChar('0'));
|
---|
| 141 | _satStat[prn].addObs(obs);
|
---|
[4266] | 142 |
|
---|
| 143 | t_anaObs* anaObs = _satStat[prn].currObs;
|
---|
| 144 | *_log << prn << " " << anaObs->M1 << " " << anaObs->M2 << endl;
|
---|
[4262] | 145 | }
|
---|
| 146 |
|
---|
[4266] | 147 | } // while (_currEpo)
|
---|
[4262] | 148 |
|
---|
[4259] | 149 | _log->flush();
|
---|
[4254] | 150 | }
|
---|
[4263] | 151 |
|
---|
| 152 | //
|
---|
| 153 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 154 | void t_reqcAnalyze::t_satStat::addObs(const t_obs& obs) {
|
---|
| 155 | if (currObs) {
|
---|
| 156 | delete prevObs;
|
---|
| 157 | prevObs = currObs;
|
---|
| 158 | }
|
---|
[4266] | 159 | currObs = new t_anaObs(obs);
|
---|
[4265] | 160 |
|
---|
[4266] | 161 | if (obs.p1() != 0.0 && obs.p2() != 0.0 &&
|
---|
| 162 | obs.l1() != 0.0 && obs.l2() != 0.0) {
|
---|
[4265] | 163 |
|
---|
[4266] | 164 | double f1 = t_CST::f1(obs.satSys, obs.slotNum);
|
---|
| 165 | double f2 = t_CST::f2(obs.satSys, obs.slotNum);
|
---|
| 166 |
|
---|
| 167 | double L1 = obs.l1() * t_CST::c / f1;
|
---|
| 168 | double L2 = obs.l2() * t_CST::c / f2;
|
---|
| 169 |
|
---|
| 170 | // Multipath linear combinations
|
---|
| 171 | // -----------------------------
|
---|
| 172 | currObs->M1 = obs.p1() - L1 - 2.0*f2*f2/(f1*f1-f2*f2) * (L1 - L2);
|
---|
| 173 |
|
---|
| 174 | currObs->M2 = obs.p2() - L2 - 2.0*f1*f1/(f1*f1-f2*f2) * (L1 - L2);
|
---|
[4265] | 175 | }
|
---|
[4263] | 176 | }
|
---|