RefFrameRlz.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #include "RefFrameRlz.hpp"
40 #include "YDSTime.hpp"
41 #include "GPSWeekSecond.hpp"
43 
44 using namespace std;
45 
46 namespace gnsstk
47 {
49  noexcept
50  {
51  switch (rlz)
52  {
53  case RefFrameRlz::Unknown: return RefFrameSys::Unknown;
54  case RefFrameRlz::WGS84G0: return RefFrameSys::WGS84;
55  case RefFrameRlz::WGS84G730: return RefFrameSys::WGS84;
56  case RefFrameRlz::WGS84G873: return RefFrameSys::WGS84;
57  case RefFrameRlz::WGS84G1150: return RefFrameSys::WGS84;
58  case RefFrameRlz::WGS84G1674: return RefFrameSys::WGS84;
59  case RefFrameRlz::WGS84G1762: return RefFrameSys::WGS84;
60  case RefFrameRlz::WGS84G2139: return RefFrameSys::WGS84;
61  case RefFrameRlz::ITRF94: return RefFrameSys::ITRF;
62  case RefFrameRlz::ITRF96: return RefFrameSys::ITRF;
63  case RefFrameRlz::ITRF97: return RefFrameSys::ITRF;
64  case RefFrameRlz::ITRF2000: return RefFrameSys::ITRF;
65  case RefFrameRlz::ITRF2005: return RefFrameSys::ITRF;
66  case RefFrameRlz::ITRF2008: return RefFrameSys::ITRF;
67  case RefFrameRlz::ITRF2014: return RefFrameSys::ITRF;
68  case RefFrameRlz::ITRF2020: return RefFrameSys::ITRF;
69  case RefFrameRlz::PZ90Y2007: return RefFrameSys::PZ90;
70  case RefFrameRlz::PZ90KGS: return RefFrameSys::PZ90;
71  case RefFrameRlz::CGCS2000Y2008: return RefFrameSys::CGCS2000;
72  default: return RefFrameSys::Unknown;
73  }
74  }
75 
76 
78  {
79  CommonTime whenUTC(when);
80  if (whenUTC.getTimeSystem() != TimeSystem::UTC)
81  {
83  // time isn't in UTC, do a rough (1s precision) conversion
84  if (!whenUTC.changeTimeSystem(TimeSystem::UTC, &btsc))
85  {
86  // Can't convert for whatever reason, change it to Any
87  // and hope for the best. This will usually be okay as
88  // the supported time systems are generally only a few
89  // seconds apart, except for GLO.
90  whenUTC.setTimeSystem(TimeSystem::Any);
91  }
92  }
93  switch (sys)
94  {
95  case RefFrameSys::WGS84:
98  if (whenUTC >= GPSWeekSecond(2139, 0, TimeSystem::UTC))
99  {
100  return RefFrameRlz::WGS84G2139;
101  }
102  else if (whenUTC >= GPSWeekSecond(1762, 0, TimeSystem::UTC))
103  {
104  return RefFrameRlz::WGS84G1762;
105  }
106  else if (whenUTC >= GPSWeekSecond(1674, 0, TimeSystem::UTC))
107  {
108  return RefFrameRlz::WGS84G1674;
109  }
110  else if (whenUTC >= GPSWeekSecond(1150, 0, TimeSystem::UTC))
111  {
112  return RefFrameRlz::WGS84G1150;
113  }
114  else if (whenUTC >= GPSWeekSecond(873, 0, TimeSystem::UTC))
115  {
116  return RefFrameRlz::WGS84G873;
117  }
118  else if (whenUTC >= GPSWeekSecond(730, 0, TimeSystem::UTC))
119  {
120  return RefFrameRlz::WGS84G730;
121  }
122  else
123  {
124  return RefFrameRlz::WGS84G0;
125  }
126  case RefFrameSys::ITRF:
129  if (whenUTC >= YDSTime(2020, 1, 0, TimeSystem::UTC))
130  {
131  return RefFrameRlz::ITRF2020;
132  }
133  else if (whenUTC >= YDSTime(2014, 1, 0, TimeSystem::UTC))
134  {
135  return RefFrameRlz::ITRF2014;
136  }
137  else if (whenUTC >= YDSTime(2008, 1, 0, TimeSystem::UTC))
138  {
139  return RefFrameRlz::ITRF2008;
140  }
141  else if (whenUTC >= YDSTime(2005, 1, 0, TimeSystem::UTC))
142  {
143  return RefFrameRlz::ITRF2005;
144  }
145  else if (whenUTC >= YDSTime(2000, 1, 0, TimeSystem::UTC))
146  {
147  return RefFrameRlz::ITRF2000;
148  }
149  else if (whenUTC >= YDSTime(1997, 1, 0, TimeSystem::UTC))
150  {
151  return RefFrameRlz::ITRF97;
152  }
153  else if (whenUTC >= YDSTime(1996, 1, 0, TimeSystem::UTC))
154  {
155  return RefFrameRlz::ITRF96;
156  }
157  else
158  {
159  return RefFrameRlz::ITRF94;
160  }
161  case RefFrameSys::PZ90:
162  if (whenUTC >= YDSTime(2007,263,61200.0,TimeSystem::UTC))
163  {
164  return RefFrameRlz::PZ90Y2007;
165  }
166  else
167  {
168  return RefFrameRlz::PZ90KGS;
169  }
170  break;
171  case RefFrameSys::CGCS2000:
172  // only one realization so far
173  return RefFrameRlz::CGCS2000Y2008;
174  default:
175  return RefFrameRlz::Unknown;
176  }
177  }
178 
179  namespace StringUtils
180  {
181  std::string asString(RefFrameRlz e)
182  noexcept
183  {
184  switch (e)
185  {
186  case RefFrameRlz::Unknown: return "Unknown";
187  case RefFrameRlz::WGS84G0: return "WGS84(G0)";
188  case RefFrameRlz::WGS84G730: return "WGS84(G730)";
189  case RefFrameRlz::WGS84G873: return "WGS84(G873)";
190  case RefFrameRlz::WGS84G1150: return "WGS84(G1150)";
191  case RefFrameRlz::WGS84G1674: return "WGS84(G1674)";
192  case RefFrameRlz::WGS84G1762: return "WGS84(G1762)";
193  case RefFrameRlz::WGS84G2139: return "WGS84(G2139)";
194  case RefFrameRlz::ITRF94: return "ITRF(1994)";
195  case RefFrameRlz::ITRF96: return "ITRF(1996)";
196  case RefFrameRlz::ITRF97: return "ITRF(1997)";
197  case RefFrameRlz::ITRF2000: return "ITRF(2000)";
198  case RefFrameRlz::ITRF2005: return "ITRF(2005)";
199  case RefFrameRlz::ITRF2008: return "ITRF(2008)";
200  case RefFrameRlz::ITRF2014: return "ITRF(2014)";
201  case RefFrameRlz::ITRF2020: return "ITRF(2020)";
202  case RefFrameRlz::PZ90Y2007: return "PZ90(2007)";
203  case RefFrameRlz::PZ90KGS: return "PZ90KGS";
204  case RefFrameRlz::CGCS2000Y2008: return "CGCS2000(2008)";
205  default: return "???";
206  }
207  }
208 
209 
210  RefFrameRlz asRefFrameRlz(const std::string& s)
211  noexcept
212  {
213  if (s == "Unknown") return RefFrameRlz::Unknown;
214  if (s == "WGS84(G0)") return RefFrameRlz::WGS84G0;
215  if (s == "WGS84(G730)") return RefFrameRlz::WGS84G730;
216  if (s == "WGS84(G873)") return RefFrameRlz::WGS84G873;
217  if (s == "WGS84(G1150)") return RefFrameRlz::WGS84G1150;
218  if (s == "WGS84(G1674)") return RefFrameRlz::WGS84G1674;
219  if (s == "WGS84(G1762)") return RefFrameRlz::WGS84G1762;
220  if (s == "WGS84(G2139)") return RefFrameRlz::WGS84G2139;
221  if (s == "ITRF(1994)") return RefFrameRlz::ITRF94;
222  if (s == "ITRF(1996)") return RefFrameRlz::ITRF96;
223  if (s == "ITRF(1997)") return RefFrameRlz::ITRF97;
224  if (s == "ITRF(2000)") return RefFrameRlz::ITRF2000;
225  if (s == "ITRF(2005)") return RefFrameRlz::ITRF2005;
226  if (s == "ITRF(2008)") return RefFrameRlz::ITRF2008;
227  if (s == "ITRF(2014)") return RefFrameRlz::ITRF2014;
228  if (s == "ITRF(2020)") return RefFrameRlz::ITRF2020;
229  if (s == "PZ90(2007)") return RefFrameRlz::PZ90Y2007;
230  if (s == "PZ90KGS") return RefFrameRlz::PZ90KGS;
231  if (s == "CGCS2000(2008)") return RefFrameRlz::CGCS2000Y2008;
232  // strings as they (probably) appear in SP3
233  if (s == "ITR94") return RefFrameRlz::ITRF94;
234  if (s == "ITR96") return RefFrameRlz::ITRF96;
235  if (s == "ITR97") return RefFrameRlz::ITRF97;
236  return RefFrameRlz::Unknown;
237  }
238  } // namespace StringUtils
239 } // end namespace
RefFrameRlz.hpp
YDSTime.hpp
gnsstk::StringUtils::asRefFrameRlz
RefFrameRlz asRefFrameRlz(const std::string &s) noexcept
Convert a string name to an RefFrameRlz.
Definition: RefFrameRlz.cpp:210
gnsstk::StringUtils::asString
std::string asString(RefFrameRlz e) noexcept
Convert a RefFrameRlz to a whitespace-free string name.
Definition: RefFrameRlz.cpp:181
gnsstk::YDSTime
Definition: YDSTime.hpp:58
gnsstk::RefFrameRlz
RefFrameRlz
Reference frame realizations. For general systems, see RefFrameSys.
Definition: RefFrameRlz.hpp:51
gnsstk::CommonTime::setTimeSystem
CommonTime & setTimeSystem(TimeSystem timeSystem)
Definition: CommonTime.hpp:195
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::GPSWeekSecond
Definition: GPSWeekSecond.hpp:56
BasicTimeSystemConverter.hpp
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::RefFrameSys
RefFrameSys
Reference frame systems. For specific realizations, see RefFrameRlz.
Definition: RefFrameSys.hpp:51
GPSWeekSecond.hpp
gnsstk::CommonTime::getTimeSystem
TimeSystem getTimeSystem() const
Obtain time system info (enum).
Definition: CommonTime.cpp:288
gnsstk::BasicTimeSystemConverter
Definition: BasicTimeSystemConverter.hpp:51
std
Definition: Angle.hpp:142
gnsstk::getRefFrameSys
RefFrameSys getRefFrameSys(RefFrameRlz rlz) noexcept
Definition: RefFrameRlz.cpp:48
gnsstk::CommonTime::changeTimeSystem
bool changeTimeSystem(TimeSystem timeSystem, TimeSystemConverter *conv)
Definition: CommonTime.cpp:190
gnsstk::getRefFrameRlz
RefFrameRlz getRefFrameRlz(RefFrameSys sys, const CommonTime &when)
Definition: RefFrameRlz.cpp:77


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:40