source: ntrip/trunk/BNC/src/rinex/rnxobsfile.h@ 6842

Last change on this file since 6842 was 6841, checked in by stuerze, 10 years ago

consideration of obs header etries for phase shifts, GLONASS slots and GLONASS biases during merging of RINEX files

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