source: ntrip/trunk/BNC/rnxnavfile.cpp@ 3659

Last change on this file since 3659 was 3659, checked in by mervart, 12 years ago
File size: 4.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_rnxNavFile
30 *
31 * Purpose: Reads RINEX Navigation File
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Jan-2012
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include "rnxnavfile.h"
43#include "bncutils.h"
44#include "RTCM3/ephemeris.h"
45
46using namespace std;
47
48// Constructor
49////////////////////////////////////////////////////////////////////////////
50t_rnxNavFile::t_rnxNavHeader::t_rnxNavHeader() {
51 _version = 0.0;
52 _glonass = false;
53}
54
55// Destructor
56////////////////////////////////////////////////////////////////////////////
57t_rnxNavFile::t_rnxNavHeader::~t_rnxNavHeader() {
58}
59
60// Read Header
61////////////////////////////////////////////////////////////////////////////
62t_irc t_rnxNavFile::t_rnxNavHeader::read(QTextStream* stream) {
63 while (stream->status() == QTextStream::Ok && !stream->atEnd()) {
64 QString line = stream->readLine();
65 if (line.isEmpty()) {
66 continue;
67 }
68 QString value = line.left(60).trimmed();
69 QString key = line.mid(60).trimmed();
70 if (key == "END OF HEADER") {
71 break;
72 }
73 else if (key == "RINEX VERSION / TYPE") {
74 QTextStream in(value.toAscii(), QIODevice::ReadOnly);
75 in >> _version;
76 if (value.indexOf("GLONASS") != -1) {
77 _glonass = true;
78 }
79 }
80 }
81
82 return success;
83}
84
85// Constructor
86////////////////////////////////////////////////////////////////////////////
87t_rnxNavFile::t_rnxNavFile(QString fileName) {
88 expandEnvVar(fileName);
89 _file = new QFile(fileName);
90 _file->open(QIODevice::ReadOnly | QIODevice::Text);
91 _stream = new QTextStream();
92 _stream->setDevice(_file);
93 _header.read(_stream);
94}
95
96// Destructor
97////////////////////////////////////////////////////////////////////////////
98t_rnxNavFile::~t_rnxNavFile() {
99 delete _stream;
100 delete _file;
101}
102
103// Read Next Ephemeris
104////////////////////////////////////////////////////////////////////////////
105t_irc t_rnxNavFile::getNextEph(t_eph* eph) {
106
107 while (_stream->status() == QTextStream::Ok && !_stream->atEnd()) {
108 QString line = _stream->readLine();
109 if (line.isEmpty()) {
110 continue;
111 }
112 QStringList hlp = line.split(QRegExp("\\s+"), QString::SkipEmptyParts);
113 QString prn;
114 if (version() >= 3.0) {
115 prn = hlp.at(0);
116 }
117 else {
118 if (glonass()) {
119 prn = 'R' + QString("%1").arg(hlp.at(0).toInt(), 2, QChar('0'));
120 }
121 else {
122 prn = 'G' + QString("%1").arg(hlp.at(0).toInt(), 2, QChar('0'));
123 }
124 }
125 QStringList lines; lines << line;
126 if (prn[0] == 'G') {
127 for (int ii = 1; ii < 8; ii++) {
128 lines << _stream->readLine();
129 }
130 eph = new t_ephGPS(version(), lines);
131 }
132 else if (prn[0] == 'R') {
133 for (int ii = 1; ii < 4; ii++) {
134 lines << _stream->readLine();
135 }
136 eph = new t_ephGlo(version(), lines);
137 }
138 else if (prn[0] == 'E') {
139 for (int ii = 1; ii < 8; ii++) {
140 lines << _stream->readLine();
141 }
142 eph = new t_ephGal(version(), lines);
143 }
144 else {
145 return failure;
146 }
147 if (!eph->ok()) {
148 delete eph;
149 eph = 0;
150 return failure;
151 }
152 }
153
154 return success;
155}
Note: See TracBrowser for help on using the repository browser.