General Purpose Geodetic Library
SgEccRec.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 
24 #include <math.h>
25 
26 #include <SgEccRec.h>
27 #include <SgLogger.h>
28 
29 
30 /*=======================================================================================================
31 *
32 * METHODS:
33 *
34 *======================================================================================================*/
35 //
36 // static first:
37 const QString SgEccRec::className()
38 {
39  return "SgEccRec";
40 };
41 
42 
43 
44 //
45 bool SgEccRec::parseString(const QString& str)
46 {
47  bool isOk;
48  double r1, r2, r3;
49  isOk_ = false;
50  // 1 2 3 4 5 6 7 8 9
51  //0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
52  // AIRA 7348 1970.01.01-00:00 2050.01.01-00:00 0.0 0.0 0.0 XYZ
53  // PT.REYES 7251 1983.08.27-00:00 2050.01.01-00:00 0.3298 2.4913 4.4005 NEU
54 
55  siteName_ = str.mid(2,8);
56  cdpNumber_ = str.mid(11, 4);
57  nCDP_ = cdpNumber_.toInt(&isOk);
58  if (!isOk || nCDP_<999) // it can happend
59  {
61  ": parseString(): not a CDP number: " + qPrintable(cdpNumber_) );
62  nCDP_ = 0;
63  };
64 
65  if (!tSince_.fromString(SgMJD::F_ECCDAT, str.mid(17, 16)))
66  {
68  ": parseString(): cannot get tSince field from [" + qPrintable(str.mid(17, 16)) + "] string");
69  return isOk_;
70  };
71  if (!tTill_.fromString(SgMJD::F_ECCDAT, str.mid(35, 16)))
72  {
74  ": parseString(): cannot get tTill field from [" + qPrintable(str.mid(36, 16)) + "] string");
75  return isOk_;
76  };
77  if (tTill_<tSince_)
78  {
80  ": parseString(): wrong order of epochs: [" + qPrintable(str.mid(17, 34)) + "]");
81  return isOk_;
82  };
83 
84  // value of the eccentricity
85  r1 = str.mid(53,10).simplified().toDouble(&isOk);
86  if (!isOk)
87  {
89  ": parseString(): cannot get r1 field from [" + qPrintable(str.mid(53, 10)) + "] string");
90  return isOk_;
91  };
92  r2 = str.mid(64,10).simplified().toDouble(&isOk);
93  if (!isOk)
94  {
96  ": parseString(): cannot get r2 field from [" + qPrintable(str.mid(64, 10)) + "] string");
97  return isOk_;
98  };
99  r3 = str.mid(75,10).simplified().toDouble(&isOk);
100  if (!isOk)
101  {
103  ": parseString(): cannot get r3 field from [" + qPrintable(str.mid(75, 10)) + "] string");
104  return isOk_;
105  };
106  // type of the eccentricity:
107  if (str.mid(87,3) == "NEU")
108  {
109  dR_(VERTICAL) = r3;
110  dR_(EAST) = r2;
111  dR_(NORTH) = r1;
112  eccType_ = ET_NEU;
113  }
114  else if (str.mid(87,3) == "XYZ")
115  {
116  dR_(X_AXIS) = r1;
117  dR_(Y_AXIS) = r2;
118  dR_(Z_AXIS) = r3;
119  eccType_ = ET_XYZ;
120  }
121  else
122  {
124  ": parseString(): unknown type [" + qPrintable(str.mid(87, 3)) + "]");
125  return isOk_;
126  };
127  return (isOk_=true);
128 };
129 
130 
131 
132 
133 
134 /*=====================================================================================================*/
135 
136 
137 
138 /*=======================================================================================================
139 *
140 * FRIENDS:
141 *
142 *======================================================================================================*/
143 //
144 
145 
146 
147 /*=====================================================================================================*/
148 //
149 // aux functions:
150 //
151 
152 
153 // i/o:
154 
155 
156 /*=====================================================================================================*/
157 //
158 // constants:
159 //
160 /*=====================================================================================================*/
161 
162 
163 
164 
165 
166 
167 
168 
169 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
@ VERTICAL
Definition: SgMathSupport.h:81
@ Z_AXIS
Definition: SgMathSupport.h:81
@ X_AXIS
Definition: SgMathSupport.h:81
@ Y_AXIS
Definition: SgMathSupport.h:81
@ EAST
Definition: SgMathSupport.h:81
@ NORTH
Definition: SgMathSupport.h:81
QString siteName_
Definition: SgEccRec.h:114
SgMJD tTill_
Definition: SgEccRec.h:118
@ ET_NEU
Definition: SgEccRec.h:51
@ ET_XYZ
Definition: SgEccRec.h:52
SgMJD tSince_
Definition: SgEccRec.h:117
static const QString className()
Definition: SgEccRec.cpp:37
int nCDP_
Definition: SgEccRec.h:116
Sg3dVector dR_
Definition: SgEccRec.h:119
EccType eccType_
Definition: SgEccRec.h:120
bool parseString(const QString &)
Definition: SgEccRec.cpp:45
QString cdpNumber_
Definition: SgEccRec.h:115
bool isOk_
Definition: SgEccRec.h:113
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ IO_TXT
Definition: SgLogger.h:65
bool fromString(Format format, const QString &str, bool isReset=true)
Definition: SgMJD.cpp:268
@ F_ECCDAT
Digits, MJD and seconds : 055288:61363.6400.
Definition: SgMJD.h:73