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