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

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