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

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