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

Last change on this file since 7640 was 7474, checked in by stuerze, 9 years ago

in case of RINEX3 to RINEX 2 conversion now some comment lines are written into the RINEX header

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