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"
|
---|
43 | #include "bncapp.h"
|
---|
44 | #include "bncsettings.h"
|
---|
45 | #include "reqcedit.h"
|
---|
46 | #include "bncutils.h"
|
---|
47 | #include "bncpostprocess.h"
|
---|
48 |
|
---|
49 | using namespace std;
|
---|
50 |
|
---|
51 | // Constructor
|
---|
52 | ////////////////////////////////////////////////////////////////////////////
|
---|
53 | t_reqcAnalyze::t_reqcAnalyze(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 | _navFileNames = settings.value("reqcNavFile").toString().split(",", QString::SkipEmptyParts);
|
---|
62 |
|
---|
63 | _currEpo = 0;
|
---|
64 | }
|
---|
65 |
|
---|
66 | // Destructor
|
---|
67 | ////////////////////////////////////////////////////////////////////////////
|
---|
68 | t_reqcAnalyze::~t_reqcAnalyze() {
|
---|
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;
|
---|
77 | }
|
---|
78 |
|
---|
79 | //
|
---|
80 | ////////////////////////////////////////////////////////////////////////////
|
---|
81 | void t_reqcAnalyze::run() {
|
---|
82 |
|
---|
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 | // ----------------------------------
|
---|
92 | t_reqcEdit::initRnxObsFiles(_obsFileNames, _rnxObsFiles);
|
---|
93 |
|
---|
94 | // Read Ephemerides
|
---|
95 | // ----------------
|
---|
96 | t_reqcEdit::readEphemerides(_navFileNames, _ephs);
|
---|
97 |
|
---|
98 | // Loop over all RINEX Files
|
---|
99 | // -------------------------
|
---|
100 | for (int ii = 0; ii < _rnxObsFiles.size(); ii++) {
|
---|
101 | analyzeFile(_rnxObsFiles[ii]);
|
---|
102 | }
|
---|
103 |
|
---|
104 | // Exit
|
---|
105 | // ----
|
---|
106 | bncApp* app = (bncApp*) qApp;
|
---|
107 | if ( app->mode() != bncApp::interactive) {
|
---|
108 | app->exit(0);
|
---|
109 | }
|
---|
110 | else {
|
---|
111 | emit finished();
|
---|
112 | deleteLater();
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | //
|
---|
117 | ////////////////////////////////////////////////////////////////////////////
|
---|
118 | void t_reqcAnalyze::analyzeFile(t_rnxObsFile* obsFile) {
|
---|
119 |
|
---|
120 | *_log << "Analyze File\n"
|
---|
121 | << "------------\n"
|
---|
122 | << obsFile->fileName().toAscii().data() << endl << endl;
|
---|
123 |
|
---|
124 | // Loop over all Epochs
|
---|
125 | // --------------------
|
---|
126 | while ( (_currEpo = obsFile->nextEpoch()) != 0) {
|
---|
127 |
|
---|
128 | // Loop over all satellites
|
---|
129 | // ------------------------
|
---|
130 | for (unsigned iObs = 0; iObs < _currEpo->rnxSat.size(); iObs++) {
|
---|
131 | const t_rnxObsFile::t_rnxSat& rnxSat = _currEpo->rnxSat[iObs];
|
---|
132 | t_obs obs;
|
---|
133 | t_postProcessing::setObsFromRnx(obsFile, _currEpo, rnxSat, obs);
|
---|
134 |
|
---|
135 | if (obs.satSys == 'R') {
|
---|
136 | continue; // TODO: set channel number
|
---|
137 | }
|
---|
138 |
|
---|
139 | QString prn = QString("%1%2").arg(obs.satSys)
|
---|
140 | .arg(obs.satNum, 2, 10, QChar('0'));
|
---|
141 | _satStat[prn].addObs(obs);
|
---|
142 |
|
---|
143 | t_anaObs* anaObs = _satStat[prn].currObs;
|
---|
144 | *_log << prn << " " << anaObs->M1 << " " << anaObs->M2 << endl;
|
---|
145 | }
|
---|
146 |
|
---|
147 | } // while (_currEpo)
|
---|
148 |
|
---|
149 | _log->flush();
|
---|
150 | }
|
---|
151 |
|
---|
152 | //
|
---|
153 | ////////////////////////////////////////////////////////////////////////////
|
---|
154 | void t_reqcAnalyze::t_satStat::addObs(const t_obs& obs) {
|
---|
155 | if (currObs) {
|
---|
156 | delete prevObs;
|
---|
157 | prevObs = currObs;
|
---|
158 | }
|
---|
159 | currObs = new t_anaObs(obs);
|
---|
160 |
|
---|
161 | if (obs.p1() != 0.0 && obs.p2() != 0.0 &&
|
---|
162 | obs.l1() != 0.0 && obs.l2() != 0.0) {
|
---|
163 |
|
---|
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);
|
---|
175 | }
|
---|
176 | }
|
---|