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

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