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 |
|
---|
39 | class t_rnxObsHeader {
|
---|
40 | public:
|
---|
41 | static const double defaultRnxObsVersion2 = 2.11;
|
---|
42 | static const double defaultRnxObsVersion3 = 3.02;
|
---|
43 |
|
---|
44 | t_rnxObsHeader();
|
---|
45 | ~t_rnxObsHeader();
|
---|
46 |
|
---|
47 | t_irc read(QTextStream* stream, int maxLines = 0);
|
---|
48 | int nTypes(char sys) const;
|
---|
49 | const QString& obsType(char sys, int index) const;
|
---|
50 | QStringList obsTypesStrings() const;
|
---|
51 | void write(QTextStream* stream,
|
---|
52 | const QMap<QString, QString>* txtMap = 0) const;
|
---|
53 |
|
---|
54 | static const QString _emptyStr;
|
---|
55 | float _version;
|
---|
56 | double _interval;
|
---|
57 | QString _antennaNumber;
|
---|
58 | QString _antennaName;
|
---|
59 | QString _markerName;
|
---|
60 | QString _markerNumber;
|
---|
61 | QString _observer;
|
---|
62 | QString _agency;
|
---|
63 | QString _receiverNumber;
|
---|
64 | QString _receiverType;
|
---|
65 | QString _receiverVersion;
|
---|
66 | QStringList _comments;
|
---|
67 | ColumnVector _antNEU;
|
---|
68 | ColumnVector _antXYZ;
|
---|
69 | ColumnVector _antBSG;
|
---|
70 | ColumnVector _xyz;
|
---|
71 | QVector<QString> _obsTypesV2;
|
---|
72 | QMap<char, QVector<QString> > _obsTypesV3;
|
---|
73 | int _wlFactorsL1[t_prn::MAXPRN_GPS+1];
|
---|
74 | int _wlFactorsL2[t_prn::MAXPRN_GPS+1];
|
---|
75 | bncTime _startTime;
|
---|
76 | };
|
---|
77 |
|
---|
78 | class t_rnxObsFile {
|
---|
79 | public:
|
---|
80 |
|
---|
81 | static bool earlierStartTime(const t_rnxObsFile* file1, const t_rnxObsFile* file2) {
|
---|
82 | return file1->startTime() < file2->startTime();
|
---|
83 | }
|
---|
84 |
|
---|
85 | class t_rnxSat {
|
---|
86 | public:
|
---|
87 | char satSys;
|
---|
88 | int satNum;
|
---|
89 | std::vector<double> obs;
|
---|
90 | std::vector<int> lli;
|
---|
91 | std::vector<int> snr;
|
---|
92 | };
|
---|
93 |
|
---|
94 | class t_rnxEpo {
|
---|
95 | public:
|
---|
96 | void clear() {
|
---|
97 | rnxSat.clear();
|
---|
98 | }
|
---|
99 | bncTime tt;
|
---|
100 | std::vector<t_rnxSat> rnxSat;
|
---|
101 | };
|
---|
102 |
|
---|
103 | enum e_inpOut {input, output};
|
---|
104 |
|
---|
105 | t_rnxObsFile(const QString& fileName, e_inpOut inpOut);
|
---|
106 | ~t_rnxObsFile();
|
---|
107 |
|
---|
108 | float version() const {return _header._version;}
|
---|
109 | double interval() const {return _header._interval;}
|
---|
110 | int nTypes(char sys) const {return _header.nTypes(sys);}
|
---|
111 | const QString& fileName() const {return _fileName;}
|
---|
112 | const QString& obsType(char sys, int index) const {return _header.obsType(sys, index);}
|
---|
113 |
|
---|
114 | const QString& antennaName() const {return _header._antennaName;}
|
---|
115 | const QString& markerName() const {return _header._markerName;}
|
---|
116 | const QString& receiverType() const {return _header._receiverType;}
|
---|
117 |
|
---|
118 | void setInterval(double interval) {_header._interval = interval;}
|
---|
119 | void setAntennaName(const QString& antennaName) {_header._antennaName = antennaName;}
|
---|
120 | void setMarkerName(const QString& markerName) {_header._markerName = markerName;}
|
---|
121 | void setReceiverType(const QString& receiverType) {_header._receiverType = receiverType;}
|
---|
122 |
|
---|
123 | const ColumnVector& xyz() const {return _header._xyz;}
|
---|
124 | const ColumnVector& antNEU() const {return _header._antNEU;}
|
---|
125 | const ColumnVector& antXYZ() const {return _header._antXYZ;}
|
---|
126 | const ColumnVector& antBSG() const {return _header._antBSG;}
|
---|
127 |
|
---|
128 | const bncTime& startTime() const {return _header._startTime;}
|
---|
129 | void setStartTime(const bncTime& startTime) {_header._startTime = startTime;}
|
---|
130 |
|
---|
131 | t_rnxEpo* nextEpoch();
|
---|
132 | int wlFactorL1(unsigned iPrn) {
|
---|
133 | return iPrn <= t_prn::MAXPRN_GPS ? _header._wlFactorsL1[iPrn] : 1;
|
---|
134 | }
|
---|
135 | int wlFactorL2(unsigned iPrn) {
|
---|
136 | return iPrn <= t_prn::MAXPRN_GPS ? _header._wlFactorsL2[iPrn] : 1;
|
---|
137 | }
|
---|
138 |
|
---|
139 | const t_rnxObsHeader& header() const {return _header;}
|
---|
140 | void setHeader(const t_rnxObsHeader& header, double version);
|
---|
141 | void checkNewHeader(const t_rnxObsHeader& header);
|
---|
142 | void writeEpoch(const t_rnxEpo* epo);
|
---|
143 |
|
---|
144 | QTextStream* stream() {return _stream;}
|
---|
145 |
|
---|
146 | private:
|
---|
147 | enum e_trafo {trafoNone, trafo2to3, trafo3to2};
|
---|
148 |
|
---|
149 | t_rnxObsFile() {};
|
---|
150 | void openRead(const QString& fileName);
|
---|
151 | void openWrite(const QString& fileName);
|
---|
152 | void close();
|
---|
153 | void writeEpochV2(const t_rnxEpo* epo);
|
---|
154 | void writeEpochV3(const t_rnxEpo* epo);
|
---|
155 | t_rnxEpo* nextEpochV2();
|
---|
156 | t_rnxEpo* nextEpochV3();
|
---|
157 | void handleEpochFlag(int flag, const QString& line, bool& headerReRead);
|
---|
158 |
|
---|
159 | QString type2to3(char sys, const QString& typeV2);
|
---|
160 | QString type3to2(const QString& typeV3);
|
---|
161 |
|
---|
162 | QMap<char, QMap<int, int> > _indexMap2to3;
|
---|
163 | QMap<char, QMap<int, int> > _indexMap3to2;
|
---|
164 |
|
---|
165 | e_inpOut _inpOut;
|
---|
166 | QFile* _file;
|
---|
167 | QString _fileName;
|
---|
168 | QTextStream* _stream;
|
---|
169 | t_rnxObsHeader _header;
|
---|
170 | t_rnxEpo _currEpo;
|
---|
171 | bool _flgPowerFail;
|
---|
172 | e_trafo _trafo;
|
---|
173 | };
|
---|
174 |
|
---|
175 | #endif
|
---|