GPSWeek.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 
41 #include "GPSWeek.hpp"
42 #include "TimeConstants.hpp"
43 
44 namespace gnsstk
45 {
47 
49  {
50  week = right.week;
51  timeSystem = right.timeSystem;
52  return *this;
53  }
54 
55  std::string GPSWeek::printf( const std::string& fmt ) const
56  {
57  try
58  {
60  std::string rv = fmt;
61 
62  rv = formattedPrint( rv, getFormatPrefixInt() + "E",
63  "Eu", getEpoch() );
64  rv = formattedPrint( rv, getFormatPrefixInt() + "F",
65  "Fu", week );
66  rv = formattedPrint( rv, getFormatPrefixInt() + "G",
67  "Gu", getWeek10() );
68  rv = formattedPrint( rv, getFormatPrefixInt() + "P",
69  "Ps", StringUtils::asString(timeSystem).c_str() );
70  return rv;
71  }
72  catch( gnsstk::StringUtils::StringException& exc )
73  {
74  GNSSTK_RETHROW( exc );
75  }
76  }
77 
78  std::string GPSWeek::printError( const std::string& fmt ) const
79  {
80  try
81  {
83  std::string rv = fmt;
84 
85  rv = formattedPrint( rv, getFormatPrefixInt() + "E",
86  "Es", getError().c_str() );
87  rv = formattedPrint( rv, getFormatPrefixInt() + "F",
88  "Fs", getError().c_str() );
89  rv = formattedPrint( rv, getFormatPrefixInt() + "G",
90  "Gs", getError().c_str() );
91  rv = formattedPrint( rv, getFormatPrefixInt() + "P",
92  "Ps", getError().c_str() );
93  return rv;
94  }
95  catch( gnsstk::StringUtils::StringException& exc )
96  {
97  GNSSTK_RETHROW( exc );
98  }
99  }
100 
107  bool GPSWeek::setFromInfo( const IdToValue& info )
108  {
109  using namespace gnsstk::StringUtils;
110 
111  for( IdToValue::const_iterator i = info.begin(); i != info.end(); i++ )
112  {
113  // based on the character, we know what to do...
114  switch ( i->first )
115  {
116  case 'E':
117  setEpoch( asInt( i->second ) );
118  break;
119  case 'F':
120  week = asInt( i->second );
121  break;
122  case 'G':
123  setWeek10( asInt( i->second ) );
124  break;
125  case 'P':
127  break;
128  default:
129  // do nothing
130  break;
131  };
132 
133  } // end of for loop
134 
135  return true;
136  }
137 
138 } // namespace
gnsstk::TimeTag::getFormatPrefixInt
static std::string getFormatPrefixInt()
Definition: TimeTag.hpp:152
gnsstk::StringUtils::asInt
long asInt(const std::string &s)
Definition: StringUtils.hpp:713
gnsstk::GPSWeek::setFromInfo
virtual bool setFromInfo(const IdToValue &info)
Definition: GPSWeek.cpp:107
TimeConstants.hpp
gnsstk::GPSWeek::operator=
GPSWeek & operator=(const GPSWeek &right)
Assignment Operator.
Definition: GPSWeek.cpp:48
GPSWeek.hpp
gnsstk::TimeTag::IdToValue
std::map< char, std::string > IdToValue
Definition: TimeTag.hpp:103
gnsstk::GPSWeek::getEpoch
virtual unsigned int getEpoch() const
Definition: GPSWeek.hpp:192
gnsstk::GPSWeek::setEpoch
virtual void setEpoch(unsigned int e)
Definition: GPSWeek.hpp:209
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
gnsstk::TimeTag::getError
static std::string getError()
This returns the default error string for the TimeTag classes.
Definition: TimeTag.hpp:161
gnsstk::MJD_JDAY
const long MJD_JDAY
'Julian day' offset from MJD
Definition: TimeConstants.hpp:53
gnsstk::GPSWeek::setWeek10
virtual void setWeek10(unsigned int w)
Definition: GPSWeek.hpp:215
gnsstk::GPSWeek::getWeek10
virtual unsigned int getWeek10() const
Definition: GPSWeek.hpp:197
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::TimeTag::timeSystem
TimeSystem timeSystem
time system (representation) of the data
Definition: TimeTag.hpp:204
gnsstk::GPSWeek::week
int week
Definition: GPSWeek.hpp:271
gnsstk::StringUtils::asTimeSystem
TimeSystem asTimeSystem(const std::string &s)
Convert a string representation of TimeSystem to an enum.
Definition: TimeSystem.cpp:324
gnsstk::GPSWeek::printError
virtual std::string printError(const std::string &fmt) const
Definition: GPSWeek.cpp:78
gnsstk::GPS_EPOCH_MJD
const long GPS_EPOCH_MJD
Modified Julian Date of GPS epoch (Jan. 6, 1980).
Definition: TimeConstants.hpp:83
gnsstk::GPSWeek::MAX_WEEK
static const GNSSTK_EXPORT int MAX_WEEK
Definition: GPSWeek.hpp:90
GNSSTK_RETHROW
#define GNSSTK_RETHROW(exc)
Definition: Exception.hpp:369
gnsstk::CommonTime::END_LIMIT_JDAY
static const GNSSTK_EXPORT long END_LIMIT_JDAY
Definition: CommonTime.hpp:99
gnsstk::StringUtils
Definition: IonexStoreStrategy.cpp:44
gnsstk::StringUtils::formattedPrint
std::string formattedPrint(const std::string &fmt, const std::string &pat, const std::string &rep, T to)
Definition: StringUtils.hpp:2020
gnsstk::GPSWeek::printf
virtual std::string printf(const std::string &fmt) const
Definition: GPSWeek.cpp:55
gnsstk::GPSWeek
Definition: GPSWeek.hpp:82


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