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