RinexDatum.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 
43 #include "RinexDatum.hpp"
44 #include "Exception.hpp"
45 #include "StringUtils.hpp"
46 
47 namespace gnsstk
48 {
51  : data(0), lli(0), ssi(0),
52  dataBlank(false), lliBlank(false), ssiBlank(false)
53  {
54  // blanks are false by default for backwards compatibility
55  }
56 
57 
59  RinexDatum(const std::string& str)
60  {
61  fromString(str);
62  }
63 
64 
65  void RinexDatum ::
66  fromString(const std::string& str)
67  {
68  std::string tmpStr;
69  GNSSTK_ASSERT(str.length() == 16);
70  tmpStr = str.substr(0, 14);
71  if (tmpStr.find_last_not_of(" ") == std::string::npos)
72  {
73  data = 0.;
74  dataBlank = true;
75  }
76  else
77  {
78  data = StringUtils::asDouble(tmpStr);
79  dataBlank = false;
80  }
81  tmpStr = str.substr(14, 1);
82  if (tmpStr == " ")
83  {
84  lli = 0.;
85  lliBlank = true;
86  }
87  else
88  {
89  lli = StringUtils::asInt(tmpStr);
90  lliBlank = false;
91  }
92  tmpStr = str.substr(15, 1);
93  if (tmpStr == " ")
94  {
95  ssi = 0.;
96  ssiBlank = true;
97  }
98  else
99  {
100  ssi = StringUtils::asInt(tmpStr);
101  ssiBlank = false;
102  }
103  }
104 
105 
106  std::string RinexDatum ::
107  asString() const
108  {
109  std::string rv;
111 
112  if (!dataBlank)
113  {
114  // double 14.3
116  }
117  else
118  {
119  rv += std::string(14, ' ');
120  }
121  if ((lli != 0) || !lliBlank)
122  {
123  rv += rightJustify(gnsstk::StringUtils::asString<short>(lli),1);
124  }
125  else
126  {
127  rv += " ";
128  }
129  if ((ssi != 0) || !ssiBlank)
130  {
131  rv += rightJustify(gnsstk::StringUtils::asString<short>(ssi),1);
132  }
133  else
134  {
135  rv += " ";
136  }
137  return rv;
138  } // asString() const
139 
140 } // namespace gnsstk
gnsstk::StringUtils::asInt
long asInt(const std::string &s)
Definition: StringUtils.hpp:713
gnsstk::RinexDatum::lliBlank
bool lliBlank
True if the lli is blank in the file.
Definition: RinexDatum.hpp:79
gnsstk::RinexDatum::dataBlank
bool dataBlank
True if the data is blank in the file.
Definition: RinexDatum.hpp:77
StringUtils.hpp
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
gnsstk::RinexDatum::data
double data
The actual data point.
Definition: RinexDatum.hpp:76
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
RinexDatum.hpp
gnsstk::RinexDatum::fromString
void fromString(const std::string &str)
Definition: RinexDatum.cpp:66
gnsstk::RinexDatum::lli
short lli
See the RINEX Spec. for an explanation.
Definition: RinexDatum.hpp:78
gnsstk::RinexDatum::ssi
short ssi
See the RINEX Spec. for an explanation.
Definition: RinexDatum.hpp:80
gnsstk::RinexDatum::RinexDatum
RinexDatum()
Initialize data to default values.
Definition: RinexDatum.cpp:50
gnsstk::StringUtils::asDouble
double asDouble(const std::string &s)
Definition: StringUtils.hpp:705
example3.data
data
Definition: example3.py:22
example6.ssi
ssi
Definition: example6.py:124
GNSSTK_ASSERT
#define GNSSTK_ASSERT(CONDITION)
Provide an "ASSERT" type macro.
Definition: Exception.hpp:373
gnsstk::StringUtils::rightJustify
std::string & rightJustify(std::string &s, const std::string::size_type length, const char pad=' ')
Definition: StringUtils.hpp:1557
gnsstk::RinexDatum::asString
std::string asString() const
Turn this datum into a RINEX OBS formatted string.
Definition: RinexDatum.cpp:107
Exception.hpp
gnsstk::RinexDatum::ssiBlank
bool ssiBlank
True if the ssi is blank in the file.
Definition: RinexDatum.hpp:81
example6.lli
lli
Definition: example6.py:123


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