BasicTimeSystemConverter.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 
42 namespace gnsstk
43 {
46  const CommonTime& t, double& offs)
47  {
48  if (fromSys == toSys)
49  {
50  // nothing to do
51  offs = 0.;
52  return true;
53  }
54  // Make sure to do enum comparison first as that is much less
55  // expensive than time comparison.
56  if ((fromSys == fromSystem) && (toSys == toSystem) &&
57  (t >= fromTimeStamp) && (t <= toTimeStamp))
58  {
59  offs = toffs;
60  return true;
61  }
62  CivilTime civ(t);
63  try
64  {
65  offs = getTimeSystemCorrection(fromSys, toSys, civ.year, civ.month,
66  civ.day);
67  }
68  catch (gnsstk::Exception& exc)
69  {
70  std::cerr << exc << std::endl;
71  return false;
72  }
73  return true;
74  }
75 
76 
79  const CommonTime& fromTime, const CommonTime& toTime)
80  {
81  double offs1, offs2;
82  if (getOffset(fromSys, toSys, fromTime, offs1) &&
83  getOffset(fromSys, toSys, toTime, offs2))
84  {
85  if (offs1 == offs2)
86  {
87  fromSystem = fromSys;
88  toSystem = toSys;
89  fromTimeStamp = fromTime;
90  toTimeStamp = toTime;
91  toffs = offs1;
92  }
93  return true;
94  }
95  else
96  {
97  return false;
98  }
99  }
100 }
gnsstk::CivilTime::year
int year
Definition: CivilTime.hpp:198
gnsstk::CivilTime::day
int day
Definition: CivilTime.hpp:200
gnsstk::BasicTimeSystemConverter::explore
bool explore(TimeSystem fromSys, TimeSystem toSys, const CommonTime &fromTime, const CommonTime &toTime)
Definition: BasicTimeSystemConverter.cpp:78
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Exception
Definition: Exception.hpp:151
BasicTimeSystemConverter.hpp
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
CivilTime.hpp
gnsstk::BasicTimeSystemConverter::fromTimeStamp
CommonTime fromTimeStamp
First time that toffs is known to be valid.
Definition: BasicTimeSystemConverter.hpp:88
gnsstk::CivilTime
Definition: CivilTime.hpp:55
gnsstk::BasicTimeSystemConverter::toSystem
TimeSystem toSystem
Time system being converted to using toffs.
Definition: BasicTimeSystemConverter.hpp:86
gnsstk::BasicTimeSystemConverter::fromSystem
TimeSystem fromSystem
Time system being converted from using toffs.
Definition: BasicTimeSystemConverter.hpp:84
gnsstk::CivilTime::month
int month
Definition: CivilTime.hpp:199
gnsstk::BasicTimeSystemConverter::toTimeStamp
CommonTime toTimeStamp
Final time that toffs is known to be valid.
Definition: BasicTimeSystemConverter.hpp:90
gnsstk::BasicTimeSystemConverter::toffs
double toffs
Stored offset for time system conversion.
Definition: BasicTimeSystemConverter.hpp:92
gnsstk::getTimeSystemCorrection
double getTimeSystemCorrection(const TimeSystem inTS, const TimeSystem outTS, const int year, const int month, const double day)
Definition: TimeSystem.cpp:181
gnsstk::BasicTimeSystemConverter::getOffset
bool getOffset(TimeSystem fromSys, TimeSystem toSys, const CommonTime &t, double &offs) override
Definition: BasicTimeSystemConverter.cpp:45


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