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

Last change on this file since 3031 was 2938, checked in by mervart, 14 years ago
File size: 6.6 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"
45
46using namespace std;
47
48// Constructor
49////////////////////////////////////////////////////////////////////////////
50bncAntex::bncAntex() {
51}
52
53// Destructor
54////////////////////////////////////////////////////////////////////////////
55bncAntex::~bncAntex() {
[2882]56 QMapIterator<QString, t_antMap*> it(_maps);
57 while (it.hasNext()) {
58 it.next();
59 delete it.value();
60 }
[2880]61}
62
[2894]63// Print
[2880]64////////////////////////////////////////////////////////////////////////////
[2887]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;
[2890]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;
[2887]85 }
86}
87
[2894]88// Read ANTEX File
[2887]89////////////////////////////////////////////////////////////////////////////
[2882]90t_irc bncAntex::readFile(const QString& fileName) {
[2880]91
[2881]92 QFile inFile(fileName);
93 inFile.open(QIODevice::ReadOnly | QIODevice::Text);
94
95 QTextStream in(&inFile);
96
[2888]97 t_antMap* newAntMap = 0;
98 t_frqMap* newFrqMap = 0;
99
[2881]100 while ( !in.atEnd() ) {
101 QString line = in.readLine();
[2882]102
[2883]103 // Start of Antenna
104 // ----------------
[2882]105 if (line.indexOf("START OF ANTENNA") == 60) {
[2883]106 if (newAntMap) {
107 delete newAntMap;
[2882]108 return failure;
109 }
110 else {
[2883]111 newAntMap = new t_antMap();
[2882]112 }
113 }
[2881]114
[2883]115 // End of Antenna
116 // --------------
[2882]117 else if (line.indexOf("END OF ANTENNA") == 60) {
[2883]118 if (newAntMap) {
119 _maps[newAntMap->antName] = newAntMap;
120 newAntMap = 0;
[2882]121 }
122 else {
123 return failure;
124 }
125 }
[2883]126
127 // Antenna Reading in Progress
128 // ---------------------------
129 else if (newAntMap) {
130 if (line.indexOf("TYPE / SERIAL NO") == 60) {
[2889]131 if (line.indexOf("BLOCK I") == 0 ||
[2884]132 line.indexOf("GLONASS") == 0) {
133 newAntMap->antName = line.mid(20,3);
134 }
135 else {
136 newAntMap->antName = line.mid(0,20);
137 }
[2883]138 }
139 else if (line.indexOf("ZEN1 / ZEN2 / DZEN") == 60) {
[2884]140 QTextStream inLine(&line, QIODevice::ReadOnly);
141 inLine >> newAntMap->zen1 >> newAntMap->zen2 >> newAntMap->dZen;
[2883]142 }
143
[2885]144 // Start of Frequency
145 // ------------------
[2883]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
[2885]157 // End of Frequency
158 // ----------------
[2888]159 else if (line.indexOf("END OF FREQUENCY") == 60) {
[2883]160 if (newFrqMap) {
[2891]161 if (line.indexOf("G01") == 3 || line.indexOf("R01") == 3) {
[2883]162 newAntMap->frqMapL1 = newFrqMap;
163 }
[2891]164 else if (line.indexOf("G02") == 3 || line.indexOf("R02") == 3) {
[2883]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
[2885]178 // Frequency Reading in Progress
179 // -----------------------------
[2883]180 else if (newFrqMap) {
[2891]181 if (line.indexOf("NORTH / EAST / UP") == 60) {
[2885]182 QTextStream inLine(&line, QIODevice::ReadOnly);
183 inLine >> newFrqMap->neu[0] >> newFrqMap->neu[1] >> newFrqMap->neu[2];
[2894]184 newFrqMap->neu[0] *= 1e-3;
185 newFrqMap->neu[1] *= 1e-3;
186 newFrqMap->neu[2] *= 1e-3;
[2883]187 }
[2884]188 else if (line.indexOf("NOAZI") == 3) {
[2885]189 QTextStream inLine(&line, QIODevice::ReadOnly);
[2886]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 }
[2894]197 newFrqMap->pattern *= 1e-3;
[2884]198 }
[2883]199 }
200 }
[2881]201 }
[2882]202
203 return success;
[2880]204}
[2894]205
206// Phase Center Offset (Receiver Antenna and GPS only)
207////////////////////////////////////////////////////////////////////////////
[2938]208double bncAntex::pco(const QString& antName, double eleSat, bool& found) {
[2894]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()) {
[2938]217 found = true;
[2894]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 }
[2938]225 else {
226 found = false;
227 }
[2894]228
229 return 0.0;
230}
Note: See TracBrowser for help on using the repository browser.