source: ntrip/branches/BNC_LM/bncantex.cpp@ 8005

Last change on this file since 8005 was 3571, checked in by mervart, 13 years ago
File size: 7.9 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"
[3055]45#include "bnctides.h"
[2880]46
47using namespace std;
48
49// Constructor
50////////////////////////////////////////////////////////////////////////////
51bncAntex::bncAntex() {
52}
53
54// Destructor
55////////////////////////////////////////////////////////////////////////////
56bncAntex::~bncAntex() {
[2882]57 QMapIterator<QString, t_antMap*> it(_maps);
58 while (it.hasNext()) {
59 it.next();
60 delete it.value();
61 }
[2880]62}
63
[2894]64// Print
[2880]65////////////////////////////////////////////////////////////////////////////
[2887]66void bncAntex::print() const {
67 QMapIterator<QString, t_antMap*> it(_maps);
68 while (it.hasNext()) {
69 it.next();
70 t_antMap* map = it.value();
71 cout << map->antName.toAscii().data() << endl;
[2890]72 cout << " " << map->zen1 << " " << map->zen2 << " " << map->dZen << endl;
73 if (map->frqMapL1) {
74 cout << " " << map->frqMapL1->neu[0] << " "
75 << map->frqMapL1->neu[1] << " "
76 << map->frqMapL1->neu[2] << endl;
77 cout << " " << map->frqMapL1->pattern.t();
78 }
79 if (map->frqMapL2) {
80 cout << " " << map->frqMapL2->neu[0] << " "
81 << map->frqMapL2->neu[1] << " "
82 << map->frqMapL2->neu[2] << endl;
83 cout << " " << map->frqMapL2->pattern.t();
84 }
85 cout << endl;
[2887]86 }
87}
88
[2894]89// Read ANTEX File
[2887]90////////////////////////////////////////////////////////////////////////////
[2882]91t_irc bncAntex::readFile(const QString& fileName) {
[2880]92
[2881]93 QFile inFile(fileName);
94 inFile.open(QIODevice::ReadOnly | QIODevice::Text);
95
96 QTextStream in(&inFile);
97
[2888]98 t_antMap* newAntMap = 0;
99 t_frqMap* newFrqMap = 0;
100
[2881]101 while ( !in.atEnd() ) {
102 QString line = in.readLine();
[2882]103
[2883]104 // Start of Antenna
105 // ----------------
[2882]106 if (line.indexOf("START OF ANTENNA") == 60) {
[2883]107 if (newAntMap) {
108 delete newAntMap;
[2882]109 return failure;
110 }
111 else {
[3295]112 delete newAntMap;
[2883]113 newAntMap = new t_antMap();
[2882]114 }
115 }
[2881]116
[2883]117 // End of Antenna
118 // --------------
[2882]119 else if (line.indexOf("END OF ANTENNA") == 60) {
[2883]120 if (newAntMap) {
[3571]121 if (_maps.contains(newAntMap->antName)) {
122 delete _maps[newAntMap->antName];
123 }
[2883]124 _maps[newAntMap->antName] = newAntMap;
125 newAntMap = 0;
[2882]126 }
127 else {
[3295]128 delete newAntMap;
[2882]129 return failure;
130 }
131 }
[2883]132
133 // Antenna Reading in Progress
134 // ---------------------------
135 else if (newAntMap) {
136 if (line.indexOf("TYPE / SERIAL NO") == 60) {
[2889]137 if (line.indexOf("BLOCK I") == 0 ||
[2884]138 line.indexOf("GLONASS") == 0) {
139 newAntMap->antName = line.mid(20,3);
140 }
141 else {
142 newAntMap->antName = line.mid(0,20);
143 }
[2883]144 }
145 else if (line.indexOf("ZEN1 / ZEN2 / DZEN") == 60) {
[2884]146 QTextStream inLine(&line, QIODevice::ReadOnly);
147 inLine >> newAntMap->zen1 >> newAntMap->zen2 >> newAntMap->dZen;
[2883]148 }
149
[2885]150 // Start of Frequency
151 // ------------------
[2883]152 else if (line.indexOf("START OF FREQUENCY") == 60) {
153 if (newFrqMap) {
154 delete newFrqMap;
155 delete newAntMap;
156 return failure;
157 }
158 else {
159 newFrqMap = new t_frqMap();
160 }
161 }
162
[2885]163 // End of Frequency
164 // ----------------
[2888]165 else if (line.indexOf("END OF FREQUENCY") == 60) {
[2883]166 if (newFrqMap) {
[2891]167 if (line.indexOf("G01") == 3 || line.indexOf("R01") == 3) {
[3571]168 delete newAntMap->frqMapL1;
[2883]169 newAntMap->frqMapL1 = newFrqMap;
170 }
[2891]171 else if (line.indexOf("G02") == 3 || line.indexOf("R02") == 3) {
[3571]172 delete newAntMap->frqMapL2;
[2883]173 newAntMap->frqMapL2 = newFrqMap;
174 }
175 else {
176 delete newFrqMap;
177 }
178 newFrqMap = 0;
179 }
180 else {
181 delete newAntMap;
182 return failure;
183 }
184 }
185
[2885]186 // Frequency Reading in Progress
187 // -----------------------------
[2883]188 else if (newFrqMap) {
[2891]189 if (line.indexOf("NORTH / EAST / UP") == 60) {
[2885]190 QTextStream inLine(&line, QIODevice::ReadOnly);
191 inLine >> newFrqMap->neu[0] >> newFrqMap->neu[1] >> newFrqMap->neu[2];
[2894]192 newFrqMap->neu[0] *= 1e-3;
193 newFrqMap->neu[1] *= 1e-3;
194 newFrqMap->neu[2] *= 1e-3;
[2883]195 }
[2884]196 else if (line.indexOf("NOAZI") == 3) {
[2885]197 QTextStream inLine(&line, QIODevice::ReadOnly);
[2886]198 int nPat = int((newAntMap->zen2-newAntMap->zen1)/newAntMap->dZen) + 1;
199 newFrqMap->pattern.ReSize(nPat);
200 QString dummy;
201 inLine >> dummy;
202 for (int ii = 0; ii < nPat; ii++) {
203 inLine >> newFrqMap->pattern[ii];
204 }
[2894]205 newFrqMap->pattern *= 1e-3;
[2884]206 }
[2883]207 }
208 }
[2881]209 }
[2882]210
[3034]211 delete newFrqMap;
212 delete newAntMap;
213
[2882]214 return success;
[2880]215}
[2894]216
[3052]217// Satellite Antenna Offset
218////////////////////////////////////////////////////////////////////////////
[3055]219t_irc bncAntex::satCoMcorrection(const QString& prn, double Mjd,
220 const ColumnVector& xSat, ColumnVector& dx) {
221
[3052]222 QMap<QString, t_antMap*>::const_iterator it = _maps.find(prn);
223 if (it != _maps.end()) {
224 t_antMap* map = it.value();
[3055]225 double* neu = map->frqMapL1->neu;
226
227 // Unit Vectors sz, sy, sx
228 // -----------------------
229 ColumnVector sz = -xSat;
230 sz /= sqrt(DotProduct(sz,sz));
231
232 ColumnVector xSun = Sun(Mjd);
233 xSun /= sqrt(DotProduct(xSun,xSun));
234
235 ColumnVector sy = crossproduct(sz, xSun);
236 sy /= sqrt(DotProduct(sy,sy));
237
238 ColumnVector sx = crossproduct(sy, sz);
239
240 dx[0] = sx[0] * neu[0] + sy[0] * neu[1] + sz[0] * neu[2];
241 dx[1] = sx[1] * neu[0] + sy[1] * neu[1] + sz[1] * neu[2];
242 dx[2] = sx[2] * neu[0] + sy[2] * neu[1] + sz[2] * neu[2];
243
[3052]244 return success;
245 }
246 else {
247 return failure;
248 }
249}
250
[2894]251// Phase Center Offset (Receiver Antenna and GPS only)
252////////////////////////////////////////////////////////////////////////////
[2938]253double bncAntex::pco(const QString& antName, double eleSat, bool& found) {
[2894]254
255 static const double f1 = t_CST::freq1;
256 static const double f2 = t_CST::freq2;
257 static const double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
258 static const double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
259
260 QMap<QString, t_antMap*>::const_iterator it = _maps.find(antName);
261 if (it != _maps.end()) {
[2938]262 found = true;
[2894]263 t_antMap* map = it.value();
264 if (map->frqMapL1 && map->frqMapL2) {
265 double corr1 = -map->frqMapL1->neu[2] * sin(eleSat);
266 double corr2 = -map->frqMapL2->neu[2] * sin(eleSat);
267 return c1 * corr1 + c2 * corr2;
268 }
269 }
[2938]270 else {
271 found = false;
272 }
[2894]273
274 return 0.0;
275}
Note: See TracBrowser for help on using the repository browser.