NavTimeSystemConverter.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 
40 #include "CivilTime.hpp"
41 #include "DebugTrace.hpp"
42 
43 namespace gnsstk
44 {
47  const CommonTime& t, double& offs)
48  {
50  if (fromSys == toSys)
51  {
52  // nothing to do
53  offs = 0.;
54  DEBUGTRACE("same system, 0 offset");
55  return true;
56  }
57  if (navLib.get() == nullptr)
58  {
59  DEBUGTRACE("null navLib");
60  return false;
61  }
62  // try direct offset first
66  if (navLib->getOffset(fromSys, toSys, t, offs, SVHealth::Any))
67  {
68  DEBUGTRACE("successful direct conversion, offs="
69  << std::setprecision(15) << std::scientific << offs);
70  return true;
71  }
72  double offs1, offs2;
73  // that didn't work, try converting fromSys->UTC->toSys
74  if (navLib->getOffset(fromSys, TimeSystem::UTC, t, offs1,
76  navLib->getOffset(TimeSystem::UTC, toSys, t, offs2,
78  {
79  offs = offs1 + offs2;
80  DEBUGTRACE("successful indirect conversion, offs="
81  << std::setprecision(15) << std::scientific << offs);
82  return true;
83  }
84  DEBUGTRACE("unable to get time offset");
85  return false;
86  }
87 }
DEBUGTRACE
#define DEBUGTRACE(EXPR)
Definition: DebugTrace.hpp:119
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::SVHealth::Any
@ Any
Use in searches when you don't care about the SV health.
gnsstk::SVHealth::Healthy
@ Healthy
Satellite is in a healthy and useable state.
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
CivilTime.hpp
gnsstk::TimeSystem::UTC
@ UTC
Coordinated Universal Time (e.g., from NTP)
NavTimeSystemConverter.hpp
DebugTrace.hpp
gnsstk::NavTimeSystemConverter::navLib
std::shared_ptr< NavLibrary > navLib
Pointer to the nav library from which we will get time offset data.
Definition: NavTimeSystemConverter.hpp:102
gnsstk::NavTimeSystemConverter::getOffset
bool getOffset(TimeSystem fromSys, TimeSystem toSys, const CommonTime &t, double &offs) override
Definition: NavTimeSystemConverter.cpp:46
DEBUGTRACE_FUNCTION
#define DEBUGTRACE_FUNCTION()
Definition: DebugTrace.hpp:117


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