source: ntrip/trunk/BNC/src/bncantex.cpp@ 7324

Last change on this file since 7324 was 7145, checked in by stuerze, 9 years ago

some frequencies added in antex class

File size: 10.3 KB
RevLine 
[2880]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>
[2890]42#include <newmatio.h>
[2880]43
44#include "bncantex.h"
[6041]45#include "pppModel.h"
[2880]46
47using namespace std;
48
49// Constructor
50////////////////////////////////////////////////////////////////////////////
51bncAntex::bncAntex() {
52}
53
[5754]54// Constructor
55////////////////////////////////////////////////////////////////////////////
56bncAntex::bncAntex(const char* fileName) {
57 readFile(QString(fileName));
58}
59
[2880]60// Destructor
61////////////////////////////////////////////////////////////////////////////
62bncAntex::~bncAntex() {
[2882]63 QMapIterator<QString, t_antMap*> it(_maps);
64 while (it.hasNext()) {
65 it.next();
66 delete it.value();
67 }
[2880]68}
69
[2894]70// Print
[2880]71////////////////////////////////////////////////////////////////////////////
[2887]72void bncAntex::print() const {
[6405]73 QMapIterator<QString, t_antMap*> itAnt(_maps);
74 while (itAnt.hasNext()) {
75 itAnt.next();
76 t_antMap* map = itAnt.value();
[2887]77 cout << map->antName.toAscii().data() << endl;
[2890]78 cout << " " << map->zen1 << " " << map->zen2 << " " << map->dZen << endl;
[6405]79 QMapIterator<t_frequency::type, t_frqMap*> itFrq(map->frqMap);
80 while (itFrq.hasNext()) {
81 itFrq.next();
82 const t_frqMap* frqMap = itFrq.value();
83 cout << " " << frqMap->neu[0] << " "
84 << frqMap->neu[1] << " "
85 << frqMap->neu[2] << endl;
86 cout << " " << frqMap->pattern.t();
[2890]87 }
88 cout << endl;
[2887]89 }
90}
91
[2894]92// Read ANTEX File
[2887]93////////////////////////////////////////////////////////////////////////////
[2882]94t_irc bncAntex::readFile(const QString& fileName) {
[2880]95
[2881]96 QFile inFile(fileName);
97 inFile.open(QIODevice::ReadOnly | QIODevice::Text);
98
99 QTextStream in(&inFile);
100
[2888]101 t_antMap* newAntMap = 0;
102 t_frqMap* newFrqMap = 0;
103
[2881]104 while ( !in.atEnd() ) {
105 QString line = in.readLine();
[2882]106
[2883]107 // Start of Antenna
108 // ----------------
[2882]109 if (line.indexOf("START OF ANTENNA") == 60) {
[2883]110 if (newAntMap) {
111 delete newAntMap;
[2882]112 return failure;
113 }
114 else {
[3295]115 delete newAntMap;
[2883]116 newAntMap = new t_antMap();
[2882]117 }
118 }
[2881]119
[2883]120 // End of Antenna
121 // --------------
[2882]122 else if (line.indexOf("END OF ANTENNA") == 60) {
[2883]123 if (newAntMap) {
[3542]124 if (_maps.contains(newAntMap->antName)) {
125 delete _maps[newAntMap->antName];
126 }
[2883]127 _maps[newAntMap->antName] = newAntMap;
128 newAntMap = 0;
[2882]129 }
130 else {
[3295]131 delete newAntMap;
[2882]132 return failure;
133 }
134 }
[2883]135
136 // Antenna Reading in Progress
137 // ---------------------------
138 else if (newAntMap) {
139 if (line.indexOf("TYPE / SERIAL NO") == 60) {
[2889]140 if (line.indexOf("BLOCK I") == 0 ||
[7141]141 line.indexOf("GLONASS") == 0 ||
142 line.indexOf("QZSS") == 0 ||
143 line.indexOf("BEIDOU") == 0 ||
144 line.indexOf("GALILEO") == 0 ||
145 line.indexOf("IRNSS") == 0 ){
[2884]146 newAntMap->antName = line.mid(20,3);
147 }
148 else {
149 newAntMap->antName = line.mid(0,20);
150 }
[2883]151 }
152 else if (line.indexOf("ZEN1 / ZEN2 / DZEN") == 60) {
[2884]153 QTextStream inLine(&line, QIODevice::ReadOnly);
154 inLine >> newAntMap->zen1 >> newAntMap->zen2 >> newAntMap->dZen;
[2883]155 }
156
[2885]157 // Start of Frequency
158 // ------------------
[2883]159 else if (line.indexOf("START OF FREQUENCY") == 60) {
160 if (newFrqMap) {
161 delete newFrqMap;
162 delete newAntMap;
163 return failure;
164 }
165 else {
166 newFrqMap = new t_frqMap();
167 }
168 }
169
[2885]170 // End of Frequency
171 // ----------------
[2888]172 else if (line.indexOf("END OF FREQUENCY") == 60) {
[2883]173 if (newFrqMap) {
[6405]174 t_frequency::type frqType = t_frequency::dummy;
175 if (line.indexOf("G01") == 3) {
176 frqType = t_frequency::G1;
[2883]177 }
[6405]178 else if (line.indexOf("G02") == 3) {
179 frqType = t_frequency::G2;
[2883]180 }
[6405]181 else if (line.indexOf("R01") == 3) {
182 frqType = t_frequency::R1;
183 }
184 else if (line.indexOf("R02") == 3) {
185 frqType = t_frequency::R2;
186 }
[7144]187 else if (line.indexOf("E01") == 3) {
188 frqType = t_frequency::E1;
189 }
190 else if (line.indexOf("E05") == 3) {
191 frqType = t_frequency::E5;
192 }
193 else if (line.indexOf("E06") == 3) {
194 frqType = t_frequency::E6;
195 }
196 else if (line.indexOf("E07") == 3) {
197 frqType = t_frequency::E7;
198 }
199 else if (line.indexOf("E08") == 3) {
200 frqType = t_frequency::E8;
201 }
[7145]202 else if (line.indexOf("J01") == 3) {
203 frqType = t_frequency::J1;
204 }
205 else if (line.indexOf("J02") == 3) {
206 frqType = t_frequency::J2;
207 }
208 else if (line.indexOf("J05") == 3) {
209 frqType = t_frequency::J5;
210 }
211 else if (line.indexOf("J06") == 3) {
212 frqType = t_frequency::J6;
213 }
[7144]214 else if (line.indexOf("C02") == 3) {
215 frqType = t_frequency::C2;
216 }
217 else if (line.indexOf("C06") == 3) {
218 frqType = t_frequency::C6;
219 }
220 else if (line.indexOf("C07") == 3) {
221 frqType = t_frequency::C7;
222 }
[6405]223 if (frqType != t_frequency::dummy) {
224 if (newAntMap->frqMap.find(frqType) != newAntMap->frqMap.end()) {
225 delete newAntMap->frqMap[frqType];
226 }
227 newAntMap->frqMap[frqType] = newFrqMap;
228 }
[2883]229 else {
230 delete newFrqMap;
231 }
232 newFrqMap = 0;
233 }
234 else {
235 delete newAntMap;
236 return failure;
237 }
238 }
239
[2885]240 // Frequency Reading in Progress
241 // -----------------------------
[2883]242 else if (newFrqMap) {
[2891]243 if (line.indexOf("NORTH / EAST / UP") == 60) {
[2885]244 QTextStream inLine(&line, QIODevice::ReadOnly);
245 inLine >> newFrqMap->neu[0] >> newFrqMap->neu[1] >> newFrqMap->neu[2];
[2894]246 newFrqMap->neu[0] *= 1e-3;
247 newFrqMap->neu[1] *= 1e-3;
248 newFrqMap->neu[2] *= 1e-3;
[2883]249 }
[2884]250 else if (line.indexOf("NOAZI") == 3) {
[2885]251 QTextStream inLine(&line, QIODevice::ReadOnly);
[2886]252 int nPat = int((newAntMap->zen2-newAntMap->zen1)/newAntMap->dZen) + 1;
253 newFrqMap->pattern.ReSize(nPat);
254 QString dummy;
255 inLine >> dummy;
256 for (int ii = 0; ii < nPat; ii++) {
257 inLine >> newFrqMap->pattern[ii];
258 }
[2894]259 newFrqMap->pattern *= 1e-3;
[2884]260 }
[2883]261 }
262 }
[2881]263 }
[2882]264
[3034]265 delete newFrqMap;
266 delete newAntMap;
267
[2882]268 return success;
[2880]269}
[2894]270
[3052]271// Satellite Antenna Offset
272////////////////////////////////////////////////////////////////////////////
[3055]273t_irc bncAntex::satCoMcorrection(const QString& prn, double Mjd,
274 const ColumnVector& xSat, ColumnVector& dx) {
275
[6405]276 t_frequency::type frqType = t_frequency::dummy;
[7145]277
[6405]278 if (prn[0] == 'G') {
279 frqType = t_frequency::G1;
280 }
281 else if (prn[0] == 'R') {
282 frqType = t_frequency::R1;
283 }
284
[6971]285 QMap<QString, t_antMap*>::const_iterator it = _maps.find(prn.mid(0,3));
[3052]286 if (it != _maps.end()) {
287 t_antMap* map = it.value();
[6405]288 if (map->frqMap.find(frqType) != map->frqMap.end()) {
[3055]289
[6405]290 double* neu = map->frqMap[frqType]->neu;
[3055]291
[6405]292 // Unit Vectors sz, sy, sx
293 // -----------------------
294 ColumnVector sz = -xSat;
295 sz /= sqrt(DotProduct(sz,sz));
296
297 ColumnVector xSun = BNC_PPP::t_astro::Sun(Mjd);
298 xSun /= sqrt(DotProduct(xSun,xSun));
[3055]299
[6405]300 ColumnVector sy = crossproduct(sz, xSun);
301 sy /= sqrt(DotProduct(sy,sy));
[3055]302
[6405]303 ColumnVector sx = crossproduct(sy, sz);
[3055]304
[6405]305 dx[0] = sx[0] * neu[0] + sy[0] * neu[1] + sz[0] * neu[2];
306 dx[1] = sx[1] * neu[0] + sy[1] * neu[1] + sz[1] * neu[2];
307 dx[2] = sx[2] * neu[0] + sy[2] * neu[1] + sz[2] * neu[2];
[3055]308
[6405]309 return success;
310 }
[3052]311 }
[6405]312
313 return failure;
[3052]314}
315
[6405]316//
[2894]317////////////////////////////////////////////////////////////////////////////
[6405]318double bncAntex::rcvCorr(const string& antName, t_frequency::type frqType,
[6694]319 double eleSat, double azSat, bool& found) const {
[2894]320
[6405]321 if (antName.find("NULLANTENNA") != string::npos) {
[2938]322 found = true;
[6405]323 return 0.0;
[2894]324 }
[6405]325
326 QString antNameQ = antName.c_str();
327
328 if (_maps.find(antNameQ) == _maps.end()) {
[2938]329 found = false;
[6405]330 return 0.0;
[2938]331 }
[2894]332
[6405]333 t_antMap* map = _maps[antNameQ];
334 if (map->frqMap.find(frqType) == map->frqMap.end()) {
335 found = false;
336 return 0.0;
337 }
338
339 t_frqMap* frqMap = map->frqMap[frqType];
340
341 double var = 0.0;
342 if (frqMap->pattern.ncols() > 0) {
343 double zenDiff = 999.999;
344 double zenSat = 90.0 - eleSat * 180.0 / M_PI;
345 unsigned iZen = 0;
346 for (double zen = map->zen1; zen <= map->zen2; zen += map->dZen) {
347 iZen += 1;
348 double newZenDiff = fabs(zen - zenSat);
349 if (newZenDiff < zenDiff) {
350 zenDiff = newZenDiff;
351 var = frqMap->pattern(iZen);
352 }
353 }
354 }
355
356 found = true;
[6694]357 return var - frqMap->neu[0] * cos(azSat)*cos(eleSat)
358 - frqMap->neu[1] * sin(azSat)*cos(eleSat)
359 - frqMap->neu[2] * sin(eleSat);
360
[5755]361}
Note: See TracBrowser for help on using the repository browser.