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

Last change on this file since 3285 was 3055, checked in by mervart, 13 years ago
File size: 7.7 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 {
[2883]112 newAntMap = new t_antMap();
[2882]113 }
114 }
[2881]115
[2883]116 // End of Antenna
117 // --------------
[2882]118 else if (line.indexOf("END OF ANTENNA") == 60) {
[2883]119 if (newAntMap) {
120 _maps[newAntMap->antName] = newAntMap;
121 newAntMap = 0;
[2882]122 }
123 else {
124 return failure;
125 }
126 }
[2883]127
128 // Antenna Reading in Progress
129 // ---------------------------
130 else if (newAntMap) {
131 if (line.indexOf("TYPE / SERIAL NO") == 60) {
[2889]132 if (line.indexOf("BLOCK I") == 0 ||
[2884]133 line.indexOf("GLONASS") == 0) {
134 newAntMap->antName = line.mid(20,3);
135 }
136 else {
137 newAntMap->antName = line.mid(0,20);
138 }
[2883]139 }
140 else if (line.indexOf("ZEN1 / ZEN2 / DZEN") == 60) {
[2884]141 QTextStream inLine(&line, QIODevice::ReadOnly);
142 inLine >> newAntMap->zen1 >> newAntMap->zen2 >> newAntMap->dZen;
[2883]143 }
144
[2885]145 // Start of Frequency
146 // ------------------
[2883]147 else if (line.indexOf("START OF FREQUENCY") == 60) {
148 if (newFrqMap) {
149 delete newFrqMap;
150 delete newAntMap;
151 return failure;
152 }
153 else {
154 newFrqMap = new t_frqMap();
155 }
156 }
157
[2885]158 // End of Frequency
159 // ----------------
[2888]160 else if (line.indexOf("END OF FREQUENCY") == 60) {
[2883]161 if (newFrqMap) {
[2891]162 if (line.indexOf("G01") == 3 || line.indexOf("R01") == 3) {
[2883]163 newAntMap->frqMapL1 = newFrqMap;
164 }
[2891]165 else if (line.indexOf("G02") == 3 || line.indexOf("R02") == 3) {
[2883]166 newAntMap->frqMapL2 = newFrqMap;
167 }
168 else {
169 delete newFrqMap;
170 }
171 newFrqMap = 0;
172 }
173 else {
174 delete newAntMap;
175 return failure;
176 }
177 }
178
[2885]179 // Frequency Reading in Progress
180 // -----------------------------
[2883]181 else if (newFrqMap) {
[2891]182 if (line.indexOf("NORTH / EAST / UP") == 60) {
[2885]183 QTextStream inLine(&line, QIODevice::ReadOnly);
184 inLine >> newFrqMap->neu[0] >> newFrqMap->neu[1] >> newFrqMap->neu[2];
[2894]185 newFrqMap->neu[0] *= 1e-3;
186 newFrqMap->neu[1] *= 1e-3;
187 newFrqMap->neu[2] *= 1e-3;
[2883]188 }
[2884]189 else if (line.indexOf("NOAZI") == 3) {
[2885]190 QTextStream inLine(&line, QIODevice::ReadOnly);
[2886]191 int nPat = int((newAntMap->zen2-newAntMap->zen1)/newAntMap->dZen) + 1;
192 newFrqMap->pattern.ReSize(nPat);
193 QString dummy;
194 inLine >> dummy;
195 for (int ii = 0; ii < nPat; ii++) {
196 inLine >> newFrqMap->pattern[ii];
197 }
[2894]198 newFrqMap->pattern *= 1e-3;
[2884]199 }
[2883]200 }
201 }
[2881]202 }
[2882]203
[3034]204 delete newFrqMap;
205 delete newAntMap;
206
[2882]207 return success;
[2880]208}
[2894]209
[3052]210// Satellite Antenna Offset
211////////////////////////////////////////////////////////////////////////////
[3055]212t_irc bncAntex::satCoMcorrection(const QString& prn, double Mjd,
213 const ColumnVector& xSat, ColumnVector& dx) {
214
[3052]215 QMap<QString, t_antMap*>::const_iterator it = _maps.find(prn);
216 if (it != _maps.end()) {
217 t_antMap* map = it.value();
[3055]218 double* neu = map->frqMapL1->neu;
219
220 // Unit Vectors sz, sy, sx
221 // -----------------------
222 ColumnVector sz = -xSat;
223 sz /= sqrt(DotProduct(sz,sz));
224
225 ColumnVector xSun = Sun(Mjd);
226 xSun /= sqrt(DotProduct(xSun,xSun));
227
228 ColumnVector sy = crossproduct(sz, xSun);
229 sy /= sqrt(DotProduct(sy,sy));
230
231 ColumnVector sx = crossproduct(sy, sz);
232
233 dx[0] = sx[0] * neu[0] + sy[0] * neu[1] + sz[0] * neu[2];
234 dx[1] = sx[1] * neu[0] + sy[1] * neu[1] + sz[1] * neu[2];
235 dx[2] = sx[2] * neu[0] + sy[2] * neu[1] + sz[2] * neu[2];
236
[3052]237 return success;
238 }
239 else {
240 return failure;
241 }
242}
243
[2894]244// Phase Center Offset (Receiver Antenna and GPS only)
245////////////////////////////////////////////////////////////////////////////
[2938]246double bncAntex::pco(const QString& antName, double eleSat, bool& found) {
[2894]247
248 static const double f1 = t_CST::freq1;
249 static const double f2 = t_CST::freq2;
250 static const double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
251 static const double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
252
253 QMap<QString, t_antMap*>::const_iterator it = _maps.find(antName);
254 if (it != _maps.end()) {
[2938]255 found = true;
[2894]256 t_antMap* map = it.value();
257 if (map->frqMapL1 && map->frqMapL2) {
258 double corr1 = -map->frqMapL1->neu[2] * sin(eleSat);
259 double corr2 = -map->frqMapL2->neu[2] * sin(eleSat);
260 return c1 * corr1 + c2 * corr2;
261 }
262 }
[2938]263 else {
264 found = false;
265 }
[2894]266
267 return 0.0;
268}
Note: See TracBrowser for help on using the repository browser.