source: ntrip/trunk/BNC/bncantex.cpp@ 2957

Last change on this file since 2957 was 2938, checked in by mervart, 14 years ago
File size: 6.6 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: bncAntex
30 *
31 * Purpose: Antenna Phase Centers and Variations from ANTEX File
32 *
33 * Author: L. Mervart
34 *
35 * Created: 26-Jan-2011
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include <newmatio.h>
43
44#include "bncantex.h"
45
46using namespace std;
47
48// Constructor
49////////////////////////////////////////////////////////////////////////////
50bncAntex::bncAntex() {
51}
52
53// Destructor
54////////////////////////////////////////////////////////////////////////////
55bncAntex::~bncAntex() {
56 QMapIterator<QString, t_antMap*> it(_maps);
57 while (it.hasNext()) {
58 it.next();
59 delete it.value();
60 }
61}
62
63// Print
64////////////////////////////////////////////////////////////////////////////
65void bncAntex::print() const {
66 QMapIterator<QString, t_antMap*> it(_maps);
67 while (it.hasNext()) {
68 it.next();
69 t_antMap* map = it.value();
70 cout << map->antName.toAscii().data() << endl;
71 cout << " " << map->zen1 << " " << map->zen2 << " " << map->dZen << endl;
72 if (map->frqMapL1) {
73 cout << " " << map->frqMapL1->neu[0] << " "
74 << map->frqMapL1->neu[1] << " "
75 << map->frqMapL1->neu[2] << endl;
76 cout << " " << map->frqMapL1->pattern.t();
77 }
78 if (map->frqMapL2) {
79 cout << " " << map->frqMapL2->neu[0] << " "
80 << map->frqMapL2->neu[1] << " "
81 << map->frqMapL2->neu[2] << endl;
82 cout << " " << map->frqMapL2->pattern.t();
83 }
84 cout << endl;
85 }
86}
87
88// Read ANTEX File
89////////////////////////////////////////////////////////////////////////////
90t_irc bncAntex::readFile(const QString& fileName) {
91
92 QFile inFile(fileName);
93 inFile.open(QIODevice::ReadOnly | QIODevice::Text);
94
95 QTextStream in(&inFile);
96
97 t_antMap* newAntMap = 0;
98 t_frqMap* newFrqMap = 0;
99
100 while ( !in.atEnd() ) {
101 QString line = in.readLine();
102
103 // Start of Antenna
104 // ----------------
105 if (line.indexOf("START OF ANTENNA") == 60) {
106 if (newAntMap) {
107 delete newAntMap;
108 return failure;
109 }
110 else {
111 newAntMap = new t_antMap();
112 }
113 }
114
115 // End of Antenna
116 // --------------
117 else if (line.indexOf("END OF ANTENNA") == 60) {
118 if (newAntMap) {
119 _maps[newAntMap->antName] = newAntMap;
120 newAntMap = 0;
121 }
122 else {
123 return failure;
124 }
125 }
126
127 // Antenna Reading in Progress
128 // ---------------------------
129 else if (newAntMap) {
130 if (line.indexOf("TYPE / SERIAL NO") == 60) {
131 if (line.indexOf("BLOCK I") == 0 ||
132 line.indexOf("GLONASS") == 0) {
133 newAntMap->antName = line.mid(20,3);
134 }
135 else {
136 newAntMap->antName = line.mid(0,20);
137 }
138 }
139 else if (line.indexOf("ZEN1 / ZEN2 / DZEN") == 60) {
140 QTextStream inLine(&line, QIODevice::ReadOnly);
141 inLine >> newAntMap->zen1 >> newAntMap->zen2 >> newAntMap->dZen;
142 }
143
144 // Start of Frequency
145 // ------------------
146 else if (line.indexOf("START OF FREQUENCY") == 60) {
147 if (newFrqMap) {
148 delete newFrqMap;
149 delete newAntMap;
150 return failure;
151 }
152 else {
153 newFrqMap = new t_frqMap();
154 }
155 }
156
157 // End of Frequency
158 // ----------------
159 else if (line.indexOf("END OF FREQUENCY") == 60) {
160 if (newFrqMap) {
161 if (line.indexOf("G01") == 3 || line.indexOf("R01") == 3) {
162 newAntMap->frqMapL1 = newFrqMap;
163 }
164 else if (line.indexOf("G02") == 3 || line.indexOf("R02") == 3) {
165 newAntMap->frqMapL2 = newFrqMap;
166 }
167 else {
168 delete newFrqMap;
169 }
170 newFrqMap = 0;
171 }
172 else {
173 delete newAntMap;
174 return failure;
175 }
176 }
177
178 // Frequency Reading in Progress
179 // -----------------------------
180 else if (newFrqMap) {
181 if (line.indexOf("NORTH / EAST / UP") == 60) {
182 QTextStream inLine(&line, QIODevice::ReadOnly);
183 inLine >> newFrqMap->neu[0] >> newFrqMap->neu[1] >> newFrqMap->neu[2];
184 newFrqMap->neu[0] *= 1e-3;
185 newFrqMap->neu[1] *= 1e-3;
186 newFrqMap->neu[2] *= 1e-3;
187 }
188 else if (line.indexOf("NOAZI") == 3) {
189 QTextStream inLine(&line, QIODevice::ReadOnly);
190 int nPat = int((newAntMap->zen2-newAntMap->zen1)/newAntMap->dZen) + 1;
191 newFrqMap->pattern.ReSize(nPat);
192 QString dummy;
193 inLine >> dummy;
194 for (int ii = 0; ii < nPat; ii++) {
195 inLine >> newFrqMap->pattern[ii];
196 }
197 newFrqMap->pattern *= 1e-3;
198 }
199 }
200 }
201 }
202
203 return success;
204}
205
206// Phase Center Offset (Receiver Antenna and GPS only)
207////////////////////////////////////////////////////////////////////////////
208double bncAntex::pco(const QString& antName, double eleSat, bool& found) {
209
210 static const double f1 = t_CST::freq1;
211 static const double f2 = t_CST::freq2;
212 static const double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
213 static const double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
214
215 QMap<QString, t_antMap*>::const_iterator it = _maps.find(antName);
216 if (it != _maps.end()) {
217 found = true;
218 t_antMap* map = it.value();
219 if (map->frqMapL1 && map->frqMapL2) {
220 double corr1 = -map->frqMapL1->neu[2] * sin(eleSat);
221 double corr2 = -map->frqMapL2->neu[2] * sin(eleSat);
222 return c1 * corr1 + c2 * corr2;
223 }
224 }
225 else {
226 found = false;
227 }
228
229 return 0.0;
230}
Note: See TracBrowser for help on using the repository browser.