source: ntrip/trunk/BNC/rnxobsfile.cpp@ 3675

Last change on this file since 3675 was 3675, checked in by mervart, 12 years ago
File size: 5.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/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: t_rnxObsFile
30 *
31 * Purpose: Reads RINEX Observation File
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Jan-2012
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include "rnxobsfile.h"
43#include "bncutils.h"
44
45using namespace std;
46
47// Constructor
48////////////////////////////////////////////////////////////////////////////
49t_rnxObsFile::t_rnxObsHeader::t_rnxObsHeader() {
50 _antNEU.ReSize(3);
51 _xyz.ReSize(3);
52 _antNEU = 0.0;
53 _xyz = 0.0;
54 _version = 0.0;
55}
56
57// Destructor
58////////////////////////////////////////////////////////////////////////////
59t_rnxObsFile::t_rnxObsHeader::~t_rnxObsHeader() {
60}
61
62// Read Header
63////////////////////////////////////////////////////////////////////////////
64t_irc t_rnxObsFile::t_rnxObsHeader::read(QTextStream* stream) {
65 while (stream->status() == QTextStream::Ok && !stream->atEnd()) {
66 QString line = stream->readLine();
67 if (line.isEmpty()) {
68 continue;
69 }
70 QString value = line.left(60).trimmed();
71 QString key = line.mid(60).trimmed();
72 if (key == "END OF HEADER") {
73 break;
74 }
75 else if (key == "RINEX VERSION / TYPE") {
76 QTextStream in(value.toAscii(), QIODevice::ReadOnly);
77 in >> _version;
78 }
79 else if (key == "MARKER NAME") {
80 _markerName = value;
81 }
82 else if (key == "ANT # / TYPE") {
83 _antennaName = value.mid(20);
84 }
85 else if (key == "APPROX POSITION XYZ") {
86 QTextStream in(value.toAscii(), QIODevice::ReadOnly);
87 in >> _xyz[0] >> _xyz[1] >> _xyz[2];
88 }
89 else if (key == "ANTENNA: DELTA H/E/N") {
90 QTextStream in(value.toAscii(), QIODevice::ReadOnly);
91 in >> _antNEU[2] >> _antNEU[1] >> _antNEU[0];
92 }
93 else if (key == "# / TYPES OF OBSERV") {
94 QTextStream in(value.toAscii(), QIODevice::ReadOnly);
95 int nTypes;
96 in >> nTypes;
97 for (int ii = 0; ii < nTypes; ii++) {
98 QString hlp;
99 in >> hlp;
100 _obsTypes << hlp;
101 }
102 }
103 }
104
105 cout << "RINEX Version = " << _version << endl;
106 cout << "Antenna Name >" << _antennaName.toAscii().data() << "<\n";
107 cout << "Marker Name >" << _markerName.toAscii().data() << "<\n";
108
109 return success;
110}
111
112// Constructor
113////////////////////////////////////////////////////////////////////////////
114t_rnxObsFile::t_rnxObsFile(QString fileName) {
115 expandEnvVar(fileName);
116 _file = new QFile(fileName);
117 _file->open(QIODevice::ReadOnly | QIODevice::Text);
118 _stream = new QTextStream();
119 _stream->setDevice(_file);
120 _header.read(_stream);
121}
122
123// Destructor
124////////////////////////////////////////////////////////////////////////////
125t_rnxObsFile::~t_rnxObsFile() {
126 delete _stream;
127 delete _file;
128}
129
130// Retrieve single Epoch
131////////////////////////////////////////////////////////////////////////////
132const t_rnxObsFile::t_epo* t_rnxObsFile::nextEpoch() {
133 if (version() < 3.0) {
134 return nextEpochV2();
135 }
136 else {
137 return nextEpochV3();
138 }
139}
140
141// Retrieve single Epoch (RINEX Version 3)
142////////////////////////////////////////////////////////////////////////////
143const t_rnxObsFile::t_epo* t_rnxObsFile::nextEpochV3() {
144 return 0; // TODO
145}
146
147// Retrieve single Epoch (RINEX Version 2)
148////////////////////////////////////////////////////////////////////////////
149const t_rnxObsFile::t_epo* t_rnxObsFile::nextEpochV2() {
150 while (_stream->status() == QTextStream::Ok && !_stream->atEnd()) {
151 QString line = _stream->readLine();
152 if (line.isEmpty()) {
153 continue;
154 }
155 QTextStream in(line.toAscii());
156 int year, month, day, hour, min, flag;
157 double sec;
158 in >> year >> month >> day >> hour >> min >> sec >> flag;
159 if (year < 80) {
160 year += 2000;
161 }
162 else if (year < 100) {
163 year += 1900;
164 }
165
166 int numSat;
167 readInt(line, 29, 3, numSat);
168
169 int pos = 32;
170 for (int iSat = 0; iSat < numSat; iSat++) {
171 if (iSat > 0 && iSat % 12 == 0) {
172 line = _stream->readLine();
173 pos = 32;
174 }
175 QString prn = line.mid(pos, 3);
176
177 cout << "prn = " << prn.toAscii().data() << endl;
178 pos += 3;
179 }
180
181 //// beg test
182 return 0;
183 //// end test
184 }
185
186 return &_currEpo;
187}
Note: See TracBrowser for help on using the repository browser.