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 | #ifndef RNXOBSFILE_H
|
---|
26 | #define RNXOBSFILE_H
|
---|
27 |
|
---|
28 | #include <QtCore>
|
---|
29 |
|
---|
30 | #include <fstream>
|
---|
31 | #include <vector>
|
---|
32 | #include <map>
|
---|
33 |
|
---|
34 | #include "newmat.h"
|
---|
35 | #include "bncconst.h"
|
---|
36 | #include "bnctime.h"
|
---|
37 | #include "t_prn.h"
|
---|
38 | #include "satObs.h"
|
---|
39 |
|
---|
40 | class t_rnxObsHeader {
|
---|
41 |
|
---|
42 | friend class t_rnxObsFile;
|
---|
43 |
|
---|
44 | public:
|
---|
45 | static constexpr double defaultRnxObsVersion2 = 2.11;
|
---|
46 | static constexpr double defaultRnxObsVersion3 = 3.03;
|
---|
47 |
|
---|
48 | t_rnxObsHeader();
|
---|
49 | ~t_rnxObsHeader();
|
---|
50 |
|
---|
51 | double version() const {return _version;}
|
---|
52 | t_irc read(QTextStream* stream, int maxLines = 0);
|
---|
53 | void setDefault(const QString& markerName, int version);
|
---|
54 | void set(const t_rnxObsHeader& header, int version,
|
---|
55 | const QStringList* useObsTypes = 0, const QStringList* phaseShifts = 0,
|
---|
56 | const QStringList* gloBiases = 0, const QStringList* gloSlots = 0);
|
---|
57 | int numSys() const;
|
---|
58 | char system(int iSys) const;
|
---|
59 | int nTypes(char sys) const;
|
---|
60 | int numGloBiases() const;
|
---|
61 | int numGloSlots() const;
|
---|
62 | QString obsType(char sys, int index, double version = 0.0) const;
|
---|
63 | QString usedSystems() const;
|
---|
64 | QStringList obsTypes(char sys) const;
|
---|
65 | QStringList phaseShifts() const;
|
---|
66 | QStringList gloBiases() const;
|
---|
67 | QStringList gloSlots() const;
|
---|
68 | void write(QTextStream* stream, const QMap<QString, QString>* txtMap = 0) const;
|
---|
69 | bncTime startTime() const {return _startTime;}
|
---|
70 | void setStartTime(const bncTime& startTime) {_startTime = startTime;}
|
---|
71 |
|
---|
72 | private:
|
---|
73 | QStringList obsTypesStrings() const;
|
---|
74 | QString _usedSystems;
|
---|
75 | double _version;
|
---|
76 | double _interval;
|
---|
77 | QString _antennaNumber;
|
---|
78 | QString _antennaName;
|
---|
79 | QString _markerName;
|
---|
80 | QString _markerNumber;
|
---|
81 | QString _markerType;
|
---|
82 | QString _observer;
|
---|
83 | QString _agency;
|
---|
84 | QString _receiverNumber;
|
---|
85 | QString _receiverType;
|
---|
86 | QString _receiverVersion;
|
---|
87 | QStringList _comments;
|
---|
88 | ColumnVector _antNEU;
|
---|
89 | ColumnVector _antXYZ;
|
---|
90 | ColumnVector _antBSG;
|
---|
91 | ColumnVector _xyz;
|
---|
92 | QMap<char, QStringList> _obsTypes;
|
---|
93 | QMap<t_prn, int> _gloSlots;
|
---|
94 | QMap<QString, double> _gloBiases;
|
---|
95 | int _wlFactorsL1[t_prn::MAXPRN_GPS+1];
|
---|
96 | int _wlFactorsL2[t_prn::MAXPRN_GPS+1];
|
---|
97 | bncTime _startTime;
|
---|
98 | bool _writeRinexOnlyWithSklObsTypes;
|
---|
99 |
|
---|
100 | QMap<QString, QPair<double, QStringList> > _phaseShifts;
|
---|
101 | };
|
---|
102 |
|
---|
103 | class t_rnxObsFile {
|
---|
104 | public:
|
---|
105 |
|
---|
106 | static bool earlierStartTime(const t_rnxObsFile* file1, const t_rnxObsFile* file2) {
|
---|
107 | return file1->startTime() < file2->startTime();
|
---|
108 | }
|
---|
109 |
|
---|
110 | class t_rnxObs {
|
---|
111 | public:
|
---|
112 | t_rnxObs() {
|
---|
113 | value = 0.0; lli = 0; snr = 0;
|
---|
114 | }
|
---|
115 | double value;
|
---|
116 | int lli;
|
---|
117 | int snr;
|
---|
118 | };
|
---|
119 |
|
---|
120 | class t_rnxSat {
|
---|
121 | public:
|
---|
122 | t_prn prn;
|
---|
123 | QMap<QString, t_rnxObs> obs;
|
---|
124 | };
|
---|
125 |
|
---|
126 | class t_rnxEpo {
|
---|
127 | public:
|
---|
128 | t_rnxEpo() {clear();}
|
---|
129 | void clear() {
|
---|
130 | tt.reset();
|
---|
131 | rnxSat.clear();
|
---|
132 | }
|
---|
133 | bncTime tt;
|
---|
134 | std::vector<t_rnxSat> rnxSat;
|
---|
135 | };
|
---|
136 |
|
---|
137 | enum e_inpOut {input, output};
|
---|
138 |
|
---|
139 | t_rnxObsFile(const QString& fileName, e_inpOut inpOut);
|
---|
140 | ~t_rnxObsFile();
|
---|
141 |
|
---|
142 | double version() const {return _header._version;}
|
---|
143 | double interval() const {return _header._interval;}
|
---|
144 | int numSys() const {return _header.numSys();}
|
---|
145 | char system(int iSys) const {return _header.system(iSys);}
|
---|
146 | int nTypes(char sys) const {return _header.nTypes(sys);}
|
---|
147 | int numGloBiases() const {return _header.numGloBiases();}
|
---|
148 | int numGloSlots() const {return _header.numGloSlots();}
|
---|
149 | const QString& fileName() const {return _fileName;}
|
---|
150 | QString obsType(char sys, int index, double version = 0.0) const {
|
---|
151 | return _header.obsType(sys, index, version);
|
---|
152 | }
|
---|
153 | QStringList phaseShifts() const {return _header.phaseShifts();}
|
---|
154 | QStringList gloBiases() const {return _header.gloBiases();}
|
---|
155 | QStringList gloSlots() const {return _header.gloSlots();}
|
---|
156 | const QString& antennaName() const {return _header._antennaName;}
|
---|
157 | const QString& antennaNumber() const {return _header._antennaNumber;}
|
---|
158 | const QString& markerName() const {return _header._markerName;}
|
---|
159 | const QString& markerNumber() const {return _header._markerNumber;}
|
---|
160 | const QString& receiverType() const {return _header._receiverType;}
|
---|
161 | const QString& receiverNumber() const {return _header._receiverNumber;}
|
---|
162 |
|
---|
163 | void setInterval(double interval) {_header._interval = interval;}
|
---|
164 | void setAntennaName(const QString& antennaName) {_header._antennaName = antennaName;}
|
---|
165 | void setAntennaNumber(const QString& antennaNumber) {_header._antennaNumber = antennaNumber;}
|
---|
166 | void setAntennaN(double antN) {_header._antNEU(1) = antN;}
|
---|
167 | void setAntennaE(double antE) {_header._antNEU(2) = antE;}
|
---|
168 | void setAntennaU(double antU) {_header._antNEU(3) = antU;}
|
---|
169 |
|
---|
170 | void setMarkerName(const QString& markerName) {_header._markerName = markerName;}
|
---|
171 | void setReceiverType(const QString& receiverType) {_header._receiverType = receiverType;}
|
---|
172 | void setReceiverNumber(const QString& receiverNumber) {_header._receiverNumber = receiverNumber;}
|
---|
173 |
|
---|
174 | const ColumnVector& xyz() const {return _header._xyz;}
|
---|
175 | const ColumnVector& antNEU() const {return _header._antNEU;}
|
---|
176 | const ColumnVector& antXYZ() const {return _header._antXYZ;}
|
---|
177 | const ColumnVector& antBSG() const {return _header._antBSG;}
|
---|
178 |
|
---|
179 | const bncTime& startTime() const {return _header._startTime;}
|
---|
180 | void setStartTime(const bncTime& startTime) {_header._startTime = startTime;}
|
---|
181 |
|
---|
182 | t_rnxEpo* nextEpoch();
|
---|
183 |
|
---|
184 | int wlFactorL1(unsigned iPrn) {
|
---|
185 | return iPrn <= t_prn::MAXPRN_GPS ? _header._wlFactorsL1[iPrn] : 1;
|
---|
186 | }
|
---|
187 | int wlFactorL2(unsigned iPrn) {
|
---|
188 | return iPrn <= t_prn::MAXPRN_GPS ? _header._wlFactorsL2[iPrn] : 1;
|
---|
189 | }
|
---|
190 |
|
---|
191 | const t_rnxObsHeader& header() const {return _header;}
|
---|
192 |
|
---|
193 | void setHeader(const t_rnxObsHeader& header, int version,
|
---|
194 | const QStringList* useObsTypes = 0, const QStringList* phaseShifts = 0,
|
---|
195 | const QStringList* gloBiases = 0, const QStringList* gloSlots = 0) {
|
---|
196 | _header.set(header, version, useObsTypes, phaseShifts, gloBiases, gloSlots);
|
---|
197 | }
|
---|
198 |
|
---|
199 | void writeEpoch(const t_rnxEpo* epo);
|
---|
200 |
|
---|
201 | QTextStream* stream() {return _stream;}
|
---|
202 |
|
---|
203 | static void setObsFromRnx(const t_rnxObsFile* rnxObsFile, const t_rnxObsFile::t_rnxEpo* epo,
|
---|
204 | const t_rnxObsFile::t_rnxSat& rnxSat, t_satObs& obs);
|
---|
205 |
|
---|
206 | static QString type2to3(char sys, const QString& typeV2);
|
---|
207 | static QString type3to2(char sys, const QString& typeV3);
|
---|
208 | static QStringList signalPriorities(char sys);
|
---|
209 |
|
---|
210 | static void writeEpoch(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo) {
|
---|
211 | if (epo == 0) {
|
---|
212 | return;
|
---|
213 | }
|
---|
214 | t_rnxEpo epoLocal;
|
---|
215 | epoLocal.tt = epo->tt;
|
---|
216 | for (unsigned ii = 0; ii < epo->rnxSat.size(); ii++) {
|
---|
217 | const t_rnxSat& rnxSat = epo->rnxSat[ii];
|
---|
218 | if (header._obsTypes[rnxSat.prn.system()].size() > 0) {
|
---|
219 | epoLocal.rnxSat.push_back(rnxSat);
|
---|
220 | }
|
---|
221 | }
|
---|
222 | if (header.version() >= 3.0) {
|
---|
223 | writeEpochV3(stream, header, &epoLocal);
|
---|
224 | }
|
---|
225 | else {
|
---|
226 | writeEpochV2(stream, header, &epoLocal);
|
---|
227 | }
|
---|
228 | }
|
---|
229 |
|
---|
230 | private:
|
---|
231 | static void writeEpochV2(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo);
|
---|
232 | static void writeEpochV3(QTextStream* stream, const t_rnxObsHeader& header, const t_rnxEpo* epo);
|
---|
233 | t_rnxObsFile() {};
|
---|
234 | void openRead(const QString& fileName);
|
---|
235 | void openWrite(const QString& fileName);
|
---|
236 | void close();
|
---|
237 | t_rnxEpo* nextEpochV2();
|
---|
238 | t_rnxEpo* nextEpochV3();
|
---|
239 | void handleEpochFlag(int flag, const QString& line, bool& headerReRead);
|
---|
240 |
|
---|
241 | e_inpOut _inpOut;
|
---|
242 | QFile* _file;
|
---|
243 | QString _fileName;
|
---|
244 | QTextStream* _stream;
|
---|
245 | t_rnxObsHeader _header;
|
---|
246 | t_rnxEpo _currEpo;
|
---|
247 | bool _flgPowerFail;
|
---|
248 | };
|
---|
249 |
|
---|
250 | #endif
|
---|