TransformLibrary.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 "TransformLibrary.hpp"
40 #include "GNSSconstants.hpp"
41 #include "HelmertTransformer.hpp"
42 #include "YDSTime.hpp"
43 
44 namespace gnsstk
45 {
48  {
50  const CommonTime PZ90Epoch(YDSTime(2007,263,61200.0,ts));
51 
52  addTransform(std::make_shared<HelmertTransformer>(
53  RefFrame(RefFrameSys::WGS84, YDSTime(2001,305,0,ts)),
54  RefFrame(RefFrameSys::ITRF, YDSTime(2001,305,0,ts)),
55  0, 0, 0, 0.0, 0.0, 0.0, 0,
56  "WGS84 to ITRF identity transform, a default value\n"
57  " (\"...since 1997, the WGS84 GPS broadcast ...\n"
58  " is consistent with the ITRS at better than 5-cm"
59  " level.\"\n"
60  " Boucher & Altamimi 2001)",
61  YDSTime(1997,1,0.0,ts)));
62 
63  // PZ90 WGS84
64  addTransform(std::make_shared<HelmertTransformer>(
65  RefFrame(RefFrameSys::PZ90, YDSTime(2001,305,0,ts)),
66  RefFrame(RefFrameSys::WGS84, YDSTime(2001,305,0,ts)),
67  -19*DEG_PER_MAS, -4*DEG_PER_MAS, 353*DEG_PER_MAS,
68  0.07, 0.0, -0.77,
69  -3*PPB,
70  "PZ90 to WGS84, determined by IGEX-98, reference\n"
71  " \"ITRS, PZ-90 and WGS 84: current realizations\n"
72  " and the related transformation parameters,\"\n"
73  " Journal Geodesy (2001), 75:613, by Boucher and"
74  " Altamimi.\n"
75  " Use before 20 Sept 2007 17:00 UTC (ICD-2008 v5.1"
76  " table 3.2).",
77  YDSTime(-4713,1,0.0,ts)));
78 
100  // PZ90 ITRF
101  addTransform(std::make_shared<HelmertTransformer>(
104  -19*DEG_PER_MAS, -4*DEG_PER_MAS, 353*DEG_PER_MAS,
105  0.07, 0.0, -0.77,
106  -3*PPB,
107  "PZ90 to ITRF(WGS84), determined by IGEX-98, reference\n"
108  " \"ITRS, PZ-90 and WGS 84: current realizations\n"
109  " and the related transformation parameters,\"\n"
110  " Journal Geodesy (2001), 75:613, by Boucher and"
111  " Altamimi.\n"
112  " Use before 20 Sept 2007 17:00 UTC (ICD-2008 v5.1"
113  " table 3.2).",
114  YDSTime(-4713,1,0.0,ts)));
115 
116  /* see the note above.
117  addTransform(std::make_shared<HelmertTransformer>(
118  RefFrame(RefFrameRlz::PZ90Y2007),
119  RefFrame(RefFrameRlz::ITRF2000),
120  0, 0, 0, -0.36, 0.08, 0.18, 0,
121  "PZ90.02 to ITRF2000, from Sergey Revnivykh, GLONASS PNT\n"
122  " Information Analysis Center, 47th CGSIC Meeting"
123  " and ION\n"
124  " GNSS 2007, Fort Worth, Texas, implemented by"
125  " GLONASS\n"
126  " 20 Sept 2007 17:00 UTC (ICD-2008 v5.1 table 3.2).",
127  PZ90Epoch));
128  */
129  }
130 
131 
134  {
135  // Insert the Transformer into the map with keys representing
136  // both forward and reverse transformations.
137  RefFramePair keyFwd(ptr->getFromFrame(), ptr->getToFrame());
138  RefFramePair keyBwd(ptr->getToFrame(), ptr->getFromFrame());
139  transformers[keyFwd][ptr->getEpoch()] = ptr;
140  transformers[keyBwd][ptr->getEpoch()] = ptr;
141  }
142 
143 
145  getTransform(const RefFrame& fromFrame, const RefFrame& toFrame,
146  TransformerPtr& ptr, const CommonTime& when)
147  const
148  {
149  // All Transformers should have been added for both forward
150  // and reverse direction so no need to search for both here.
151  RefFramePair key(fromFrame, toFrame);
152  const auto& p = transformers.find(key);
153  if (p != transformers.end())
154  {
155  const auto& t = p->second.upper_bound(when);
156  const auto& pt = std::prev(t);
157  if (pt == p->second.end())
158  {
159  return false;
160  }
161  ptr = pt->second;
162  return true;
163  }
164  return false;
165  }
166 
167 
169  transform(const Position& fromPos, Position& toPos, const CommonTime& when)
170  const noexcept
171  {
172  TransformerPtr xform;
173  if (!getTransform(fromPos.getReferenceFrame(), toPos.getReferenceFrame(),
174  xform, when))
175  {
176  return false;
177  }
178  return xform->transform(fromPos, toPos);
179  }
180 
181 
183  transform(const Xvt& fromPos, Xvt& toPos, const CommonTime& when)
184  const noexcept
185  {
186  TransformerPtr xform;
187  if (!getTransform(fromPos.frame, toPos.frame, xform, when))
188  {
189  return false;
190  }
191  return xform->transform(fromPos, toPos);
192  }
193 
194 
196  transform(const Vector<double>& fromPos,
197  const RefFrame& srcFrame,
198  Vector<double>& toPos,
199  const RefFrame& tgtFrame,
200  const CommonTime& when)
201  const noexcept
202  {
203  TransformerPtr xform;
204  if (!getTransform(srcFrame, tgtFrame, xform, when))
205  {
206  return false;
207  }
208  return xform->transform(fromPos, srcFrame, toPos);
209  }
210 
211 
213  transform(const Triple& fromPos,
214  const RefFrame& srcFrame,
215  Triple& toPos,
216  const RefFrame& tgtFrame,
217  const CommonTime& when)
218  const noexcept
219  {
220  TransformerPtr xform;
221  if (!getTransform(srcFrame, tgtFrame, xform, when))
222  {
223  return false;
224  }
225  return xform->transform(fromPos, srcFrame, toPos);
226  }
227 
228 
230  transform(double fx, double fy, double fz,
231  const RefFrame& srcFrame,
232  double& tx, double& ty, double& tz,
233  const RefFrame& tgtFrame,
234  const CommonTime& when)
235  const noexcept
236  {
237  TransformerPtr xform;
238  if (!getTransform(srcFrame, tgtFrame, xform, when))
239  {
240  return false;
241  }
242  return xform->transform(fx, fy, fz, srcFrame, tx, ty, tz);
243  }
244 
245 } // namespace gnsstk
gnsstk::TransformLibrary::transform
bool transform(const Position &fromPos, Position &toPos, const CommonTime &when=gnsstk::CommonTime::END_OF_TIME) const noexcept
Definition: TransformLibrary.cpp:169
YDSTime.hpp
gnsstk::RefFrameSys::PZ90
@ PZ90
The reference frame used by Glonass.
gnsstk::TransformLibrary::addTransform
void addTransform(const TransformerPtr &ptr)
Definition: TransformLibrary.cpp:133
gnsstk::RefFrameSys::ITRF
@ ITRF
The reference frame used by Galileo.
gnsstk::YDSTime
Definition: YDSTime.hpp:58
gnsstk::TransformLibrary::TransformLibrary
TransformLibrary()
Fill the library with a default set of transformation parameters.
Definition: TransformLibrary.cpp:47
gnsstk::PPB
static const double PPB
parts per billion
Definition: GNSSconstants.hpp:84
GNSSconstants.hpp
gnsstk::RefFrame
Definition: RefFrame.hpp:53
gnsstk::Triple
Definition: Triple.hpp:68
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::TransformLibrary::transformers
TransformerMap transformers
More than meets the eye.
Definition: TransformLibrary.hpp:208
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::RefFrameSys::WGS84
@ WGS84
The reference frame used by GPS.
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
gnsstk::Xvt
Definition: Xvt.hpp:60
gnsstk::Vector< double >
gnsstk::TimeSystem::UTC
@ UTC
Coordinated Universal Time (e.g., from NTP)
gnsstk::DEG_PER_MAS
static const double DEG_PER_MAS
degrees per milliarcsecond (1e-3/3600.)
Definition: GNSSconstants.hpp:80
gnsstk::RefFrameRlz::PZ90KGS
@ PZ90KGS
PZ90 the "original".
gnsstk::Position
Definition: Position.hpp:136
gnsstk::RefFramePair
std::pair< RefFrame, RefFrame > RefFramePair
A little something to use for TransformerMap.
Definition: RefFrame.hpp:117
gnsstk::TransformerPtr
std::shared_ptr< Transformer > TransformerPtr
Shared pointer to Transformer object.
Definition: Transformer.hpp:163
HelmertTransformer.hpp
TransformLibrary.hpp
gnsstk::TransformLibrary::getTransform
bool getTransform(const RefFrame &fromFrame, const RefFrame &toFrame, TransformerPtr &ptr, const CommonTime &when=gnsstk::CommonTime::END_OF_TIME) const
Definition: TransformLibrary.cpp:145
gnsstk::RefFrameRlz::ITRF2000
@ ITRF2000
ITRF, 2000 version.


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