source: ntrip/branches/BNC_2.12/src/bncantex.cpp@ 8677

Last change on this file since 8677 was 8631, checked in by stuerze, 6 years ago

some updates to support RINEX Version 3.04

File size: 11.5 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 *
[7521]37 * Changes:
[2880]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
[7521]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
[7521]92// Print
93////////////////////////////////////////////////////////////////////////////
94QString bncAntex::pcoSinexString(const std::string& antName, t_frequency::type frqType) {
95
96 if (antName.find("NULLANTENNA") != string::npos) {
[7848]97 return QString(" ------ ------ ------");
[7521]98 }
99
100 QString antNameQ = antName.c_str();
101 if (_maps.find(antNameQ) == _maps.end()) {
[7848]102 return QString(" ------ ------ ------");
[7521]103 }
104
105 t_antMap* map = _maps[antNameQ];
106 if (map->frqMap.find(frqType) == map->frqMap.end()) {
[7848]107 return QString(" ------ ------ ------");
[7521]108 }
109
110 t_frqMap* frqMap = map->frqMap[frqType];
111
[7848]112 QString u, n,e;
113 u.sprintf("%+6.4f" ,frqMap->neu[2]); if (u.mid(1,1) == "0") {u.remove(1,1);}
114 n.sprintf("%+6.4f" ,frqMap->neu[0]); if (n.mid(1,1) == "0") {n.remove(1,1);}
115 e.sprintf("%+6.4f" ,frqMap->neu[1]); if (e.mid(1,1) == "0") {e.remove(1,1);}
116
117 return QString(" %1 %2 %3").arg(u).arg(n).arg(e);
[7521]118}
119
[2894]120// Read ANTEX File
[2887]121////////////////////////////////////////////////////////////////////////////
[2882]122t_irc bncAntex::readFile(const QString& fileName) {
[2880]123
[2881]124 QFile inFile(fileName);
125 inFile.open(QIODevice::ReadOnly | QIODevice::Text);
126
127 QTextStream in(&inFile);
128
[8079]129 t_antMap* newAntMap = 0;
130 t_frqMap* newFrqMap = 0;
[2888]131
[2881]132 while ( !in.atEnd() ) {
133 QString line = in.readLine();
[7521]134
[2883]135 // Start of Antenna
136 // ----------------
[2882]137 if (line.indexOf("START OF ANTENNA") == 60) {
[2883]138 if (newAntMap) {
139 delete newAntMap;
[2882]140 return failure;
141 }
142 else {
[3295]143 delete newAntMap;
[2883]144 newAntMap = new t_antMap();
[2882]145 }
[7521]146 }
[2881]147
[2883]148 // End of Antenna
149 // --------------
[2882]150 else if (line.indexOf("END OF ANTENNA") == 60) {
[2883]151 if (newAntMap) {
[3542]152 if (_maps.contains(newAntMap->antName)) {
153 delete _maps[newAntMap->antName];
154 }
[2883]155 _maps[newAntMap->antName] = newAntMap;
156 newAntMap = 0;
[2882]157 }
158 else {
[3295]159 delete newAntMap;
[2882]160 return failure;
161 }
162 }
[2883]163
164 // Antenna Reading in Progress
165 // ---------------------------
166 else if (newAntMap) {
167 if (line.indexOf("TYPE / SERIAL NO") == 60) {
[2889]168 if (line.indexOf("BLOCK I") == 0 ||
[7141]169 line.indexOf("GLONASS") == 0 ||
170 line.indexOf("QZSS") == 0 ||
171 line.indexOf("BEIDOU") == 0 ||
172 line.indexOf("GALILEO") == 0 ||
173 line.indexOf("IRNSS") == 0 ){
[2884]174 newAntMap->antName = line.mid(20,3);
175 }
176 else {
177 newAntMap->antName = line.mid(0,20);
178 }
[2883]179 }
180 else if (line.indexOf("ZEN1 / ZEN2 / DZEN") == 60) {
[2884]181 QTextStream inLine(&line, QIODevice::ReadOnly);
[7521]182 inLine >> newAntMap->zen1 >> newAntMap->zen2 >> newAntMap->dZen;
[2883]183 }
184
[2885]185 // Start of Frequency
186 // ------------------
[2883]187 else if (line.indexOf("START OF FREQUENCY") == 60) {
188 if (newFrqMap) {
189 delete newFrqMap;
190 delete newAntMap;
191 return failure;
192 }
193 else {
194 newFrqMap = new t_frqMap();
195 }
196 }
197
[8631]198 // End of Frequency
[2885]199 // ----------------
[2888]200 else if (line.indexOf("END OF FREQUENCY") == 60) {
[2883]201 if (newFrqMap) {
[6405]202 t_frequency::type frqType = t_frequency::dummy;
[8631]203 // GPS
[6405]204 if (line.indexOf("G01") == 3) {
205 frqType = t_frequency::G1;
[2883]206 }
[6405]207 else if (line.indexOf("G02") == 3) {
208 frqType = t_frequency::G2;
[2883]209 }
[8631]210 else if (line.indexOf("G05") == 3) {
211 frqType = t_frequency::G5;
212 }
213 // GLONASS
[6405]214 else if (line.indexOf("R01") == 3) {
215 frqType = t_frequency::R1;
216 }
217 else if (line.indexOf("R02") == 3) {
218 frqType = t_frequency::R2;
219 }
[8631]220 // Galileo
[7144]221 else if (line.indexOf("E01") == 3) {
222 frqType = t_frequency::E1;
223 }
224 else if (line.indexOf("E05") == 3) {
225 frqType = t_frequency::E5;
226 }
227 else if (line.indexOf("E06") == 3) {
228 frqType = t_frequency::E6;
229 }
230 else if (line.indexOf("E07") == 3) {
231 frqType = t_frequency::E7;
232 }
233 else if (line.indexOf("E08") == 3) {
234 frqType = t_frequency::E8;
235 }
[8631]236 // QZSS
[7145]237 else if (line.indexOf("J01") == 3) {
238 frqType = t_frequency::J1;
239 }
240 else if (line.indexOf("J02") == 3) {
241 frqType = t_frequency::J2;
242 }
243 else if (line.indexOf("J05") == 3) {
244 frqType = t_frequency::J5;
245 }
246 else if (line.indexOf("J06") == 3) {
247 frqType = t_frequency::J6;
248 }
[8631]249 // BDS
250 else if (line.indexOf("C01") == 3) {
251 frqType = t_frequency::C1;
252 }
[7144]253 else if (line.indexOf("C02") == 3) {
254 frqType = t_frequency::C2;
255 }
256 else if (line.indexOf("C06") == 3) {
257 frqType = t_frequency::C6;
258 }
259 else if (line.indexOf("C07") == 3) {
260 frqType = t_frequency::C7;
261 }
[6405]262 if (frqType != t_frequency::dummy) {
263 if (newAntMap->frqMap.find(frqType) != newAntMap->frqMap.end()) {
264 delete newAntMap->frqMap[frqType];
265 }
266 newAntMap->frqMap[frqType] = newFrqMap;
267 }
[2883]268 else {
269 delete newFrqMap;
270 }
271 newFrqMap = 0;
272 }
273 else {
274 delete newAntMap;
275 return failure;
276 }
277 }
278
[2885]279 // Frequency Reading in Progress
280 // -----------------------------
[2883]281 else if (newFrqMap) {
[2891]282 if (line.indexOf("NORTH / EAST / UP") == 60) {
[2885]283 QTextStream inLine(&line, QIODevice::ReadOnly);
284 inLine >> newFrqMap->neu[0] >> newFrqMap->neu[1] >> newFrqMap->neu[2];
[2894]285 newFrqMap->neu[0] *= 1e-3;
286 newFrqMap->neu[1] *= 1e-3;
287 newFrqMap->neu[2] *= 1e-3;
[2883]288 }
[2884]289 else if (line.indexOf("NOAZI") == 3) {
[2885]290 QTextStream inLine(&line, QIODevice::ReadOnly);
[2886]291 int nPat = int((newAntMap->zen2-newAntMap->zen1)/newAntMap->dZen) + 1;
292 newFrqMap->pattern.ReSize(nPat);
293 QString dummy;
294 inLine >> dummy;
295 for (int ii = 0; ii < nPat; ii++) {
296 inLine >> newFrqMap->pattern[ii];
297 }
[2894]298 newFrqMap->pattern *= 1e-3;
[2884]299 }
[2883]300 }
301 }
[2881]302 }
[7865]303 inFile.close();
[3034]304 delete newFrqMap;
305 delete newAntMap;
306
[2882]307 return success;
[2880]308}
[2894]309
[3052]310// Satellite Antenna Offset
311////////////////////////////////////////////////////////////////////////////
[7521]312t_irc bncAntex::satCoMcorrection(const QString& prn, double Mjd,
[3055]313 const ColumnVector& xSat, ColumnVector& dx) {
314
[6405]315 t_frequency::type frqType = t_frequency::dummy;
[7145]316
[6405]317 if (prn[0] == 'G') {
318 frqType = t_frequency::G1;
319 }
320 else if (prn[0] == 'R') {
321 frqType = t_frequency::R1;
322 }
323
[6971]324 QMap<QString, t_antMap*>::const_iterator it = _maps.find(prn.mid(0,3));
[3052]325 if (it != _maps.end()) {
326 t_antMap* map = it.value();
[6405]327 if (map->frqMap.find(frqType) != map->frqMap.end()) {
[3055]328
[6405]329 double* neu = map->frqMap[frqType]->neu;
[3055]330
[6405]331 // Unit Vectors sz, sy, sx
332 // -----------------------
333 ColumnVector sz = -xSat;
334 sz /= sqrt(DotProduct(sz,sz));
335
336 ColumnVector xSun = BNC_PPP::t_astro::Sun(Mjd);
337 xSun /= sqrt(DotProduct(xSun,xSun));
[7521]338
[6405]339 ColumnVector sy = crossproduct(sz, xSun);
340 sy /= sqrt(DotProduct(sy,sy));
[7521]341
[6405]342 ColumnVector sx = crossproduct(sy, sz);
[3055]343
[6405]344 dx[0] = sx[0] * neu[0] + sy[0] * neu[1] + sz[0] * neu[2];
345 dx[1] = sx[1] * neu[0] + sy[1] * neu[1] + sz[1] * neu[2];
346 dx[2] = sx[2] * neu[0] + sy[2] * neu[1] + sz[2] * neu[2];
[3055]347
[6405]348 return success;
349 }
[3052]350 }
[6405]351
352 return failure;
[3052]353}
354
[7521]355//
[2894]356////////////////////////////////////////////////////////////////////////////
[6405]357double bncAntex::rcvCorr(const string& antName, t_frequency::type frqType,
[6694]358 double eleSat, double azSat, bool& found) const {
[2894]359
[6405]360 if (antName.find("NULLANTENNA") != string::npos) {
[2938]361 found = true;
[6405]362 return 0.0;
[2894]363 }
[6405]364
365 QString antNameQ = antName.c_str();
366
367 if (_maps.find(antNameQ) == _maps.end()) {
[2938]368 found = false;
[6405]369 return 0.0;
[2938]370 }
[2894]371
[6405]372 t_antMap* map = _maps[antNameQ];
373 if (map->frqMap.find(frqType) == map->frqMap.end()) {
374 found = false;
375 return 0.0;
376 }
377
378 t_frqMap* frqMap = map->frqMap[frqType];
379
380 double var = 0.0;
381 if (frqMap->pattern.ncols() > 0) {
382 double zenDiff = 999.999;
383 double zenSat = 90.0 - eleSat * 180.0 / M_PI;
384 unsigned iZen = 0;
385 for (double zen = map->zen1; zen <= map->zen2; zen += map->dZen) {
386 iZen += 1;
387 double newZenDiff = fabs(zen - zenSat);
388 if (newZenDiff < zenDiff) {
389 zenDiff = newZenDiff;
390 var = frqMap->pattern(iZen);
391 }
392 }
393 }
394
395 found = true;
[6694]396 return var - frqMap->neu[0] * cos(azSat)*cos(eleSat)
397 - frqMap->neu[1] * sin(azSat)*cos(eleSat)
398 - frqMap->neu[2] * sin(eleSat);
399
[5755]400}
Note: See TracBrowser for help on using the repository browser.