SinexHeader.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 
44 #include "StringUtils.hpp"
45 #include "SinexStream.hpp"
46 #include "SinexHeader.hpp"
47 
48 namespace gnsstk
49 {
50 namespace Sinex
51 {
52 
53  using namespace gnsstk::StringUtils;
54  using namespace std;
55 
56  const size_t Header::MIN_LINE_LEN;
57  const size_t Header::MAX_LINE_LEN;
58 
59 
60  Header::operator std::string() const
61  {
62  try
63  {
64  ostringstream ss;
65  ss << FILE_BEGIN;
66  ss << ' ' << setw(4) << fixed << setprecision(2) << version;
67  ss << ' ' << setw(3) << creationAgency;
68  ss << ' ' << setw(12) << (std::string)creationTime;
69  ss << ' ' << setw(3) << dataAgency;
70  ss << ' ' << setw(12) << (std::string)dataTimeStart;
71  ss << ' ' << setw(12) << (std::string)dataTimeEnd;
72  ss << ' ' << obsCode;
73  ss << setfill('0');
74  ss << ' ' << setw(5) << setprecision(5) << paramCount;
75  ss << setfill(' ');
76  ss << ' ' << constraintCode;
77  ss << ' ' << setw(6) << solutionTypes;
78  return ss.str();
79  }
80  catch (Exception& exc)
81  {
82  GNSSTK_RETHROW(exc);
83  }
84  } // Header::operator std::string()
85 
86 
87  void Header::operator=(const std::string& line)
88  {
89  if (line.compare(0, FILE_BEGIN.size(), FILE_BEGIN) != 0)
90  {
91  Exception err("Invalid Sinex Header");
93  }
94  static int FIELD_DIVS[] = {5, 10, 14, 27, 31, 44, 57, 59, 65, -1};
95  try
96  {
98  version = asFloat(line.substr(6,4) );
99  creationAgency = line.substr(11,3);
100  creationTime = line.substr(15,12);
101  dataAgency = line.substr(28,3);
102  dataTimeStart = line.substr(32,12);
103  dataTimeEnd = line.substr(45,12);
104  obsCode = line[58];
105  isValidObsCode(obsCode);
106  paramCount = asInt(line.substr(60,5) );
107  constraintCode = line[66];
108  isValidConstraintCode(constraintCode);
109  if (line.size() > 67)
110  {
111  solutionTypes = line.substr(68,6);
112  for (size_t i = 0; i < solutionTypes.size(); ++i)
113  {
114  isValidSolutionType(solutionTypes[i]);
115  }
116  }
117  }
118  catch (Exception& exc)
119  {
120  GNSSTK_RETHROW(exc);
121  }
122  } // Header::operator=()
123 
124 
125  void Header::dump(ostream& s) const
126  {
127  s << "SINEX HEADER :" << endl;
128  s << " version=" << version << endl;
129  s << " creationAgency=" << creationAgency << endl;
130  s << " dataAgency=" << dataAgency << endl;
131  s << " creationTime=" << (std::string)creationTime << endl;
132  s << " dataTimeStart=" << (std::string)dataTimeStart << endl;
133  s << " dataEndTime=" << (std::string)dataTimeEnd << endl;
134  s << " obsCode=" << obsCode << endl;
135  s << " constraintCode=" << constraintCode << endl;
136  s << " paramCount=" << paramCount << endl;
137  s << " solutionTypes=" << solutionTypes << endl;
138 
139  } // Header::dump()
140 
141 } // namespace Sinex
142 
143 } // namespace gnsstk
gnsstk::StringUtils::asInt
long asInt(const std::string &s)
Definition: StringUtils.hpp:713
SinexStream.hpp
StringUtils.hpp
gnsstk::Sinex::isValidObsCode
bool isValidObsCode(char c, bool toss)
Definition: SinexBase.cpp:57
gnsstk::StringUtils::asFloat
float asFloat(const std::string &s)
Definition: StringUtils.hpp:1636
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::Sinex::Header::dump
void dump(std::ostream &s) const
Debug output operator.
Definition: SinexHeader.cpp:125
example4.err
err
Definition: example4.py:126
gnsstk::Sinex::MIN_LINE_LEN
const size_t MIN_LINE_LEN
Definition: SinexBase.hpp:66
gnsstk::Sinex::FILE_BEGIN
const std::string FILE_BEGIN("%=SNX")
gnsstk::Sinex::isValidLineStructure
bool isValidLineStructure(const std::string &line, size_t minLen, size_t maxLen, int divs[], bool toss)
Definition: SinexBase.cpp:111
version
string version(string("2.4 9/23/15 rev"))
GNSSTK_RETHROW
#define GNSSTK_RETHROW(exc)
Definition: Exception.hpp:369
gnsstk::Sinex::isValidConstraintCode
bool isValidConstraintCode(char c, bool toss)
Definition: SinexBase.cpp:75
gnsstk::Sinex::MAX_LINE_LEN
const size_t MAX_LINE_LEN
Definition: SinexBase.hpp:67
gnsstk::StringUtils
Definition: IonexStoreStrategy.cpp:44
gnsstk::Sinex::isValidSolutionType
bool isValidSolutionType(char c, bool toss)
Definition: SinexBase.cpp:93
std
Definition: Angle.hpp:142
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::Sinex::Header::MIN_LINE_LEN
static const size_t MIN_LINE_LEN
Definition: SinexHeader.hpp:67
gnsstk::Sinex::Header::MAX_LINE_LEN
static const size_t MAX_LINE_LEN
Definition: SinexHeader.hpp:68
SinexHeader.hpp
gnsstk::Sinex::Header::operator=
void operator=(const std::string &other)
Definition: SinexHeader.cpp:87


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