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

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