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

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