RinexSatID.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 
39 #include "RinexSatID.hpp"
40 #include "GNSSconstants.hpp"
41 
48 namespace gnsstk
49 {
50  char RinexSatID::fillchar = '0';
51 
54  noexcept
55  : SatID(p, s)
56  {
57  validate();
58  }
59 
60 
61  char RinexSatID ::
63  noexcept
64  {
65  switch(system)
66  {
67  case SatelliteSystem::GPS: return 'G';
68  case SatelliteSystem::Galileo: return 'E';
69  case SatelliteSystem::Glonass: return 'R';
70  case SatelliteSystem::Geosync: return 'S';
71  case SatelliteSystem::Transit: return 'T';
72  case SatelliteSystem::QZSS: return 'J';
73  case SatelliteSystem::BeiDou: return 'C';
74  case SatelliteSystem::IRNSS: return 'I';
75  case SatelliteSystem::Mixed: return 'M';
76  default: return '?';
77  }
78  }
79 
80 
81  std::string RinexSatID ::
83  noexcept
84  {
85  switch(system)
86  {
87  case SatelliteSystem::GPS: return "GPS";
88  case SatelliteSystem::Galileo: return "Galileo";
89  case SatelliteSystem::Glonass: return "GLONASS";
90  case SatelliteSystem::Geosync: return "Geosync";
91  case SatelliteSystem::Transit: return "Transit";
92  case SatelliteSystem::QZSS: return "QZSS";
93  case SatelliteSystem::BeiDou: return "BeiDou";
94  case SatelliteSystem::IRNSS: return "IRNSS";
95  case SatelliteSystem::Mixed: return "Mixed";
96  default: return "Unknown";
97  }
98  }
99 
100 
101  std::string RinexSatID ::
103  noexcept
104  {
105  switch(system)
106  {
107  case SatelliteSystem::GPS: return "GPS";
108  case SatelliteSystem::Galileo: return "GAL";
109  case SatelliteSystem::Glonass: return "GLO";
110  case SatelliteSystem::Geosync: return "GEO";
111  case SatelliteSystem::Transit: return "TRN"; // RINEX ver 2
112  case SatelliteSystem::QZSS: return "QZS";
113  case SatelliteSystem::BeiDou: return "BDS";
114  case SatelliteSystem::IRNSS: return "IRN"; // RINEX ver 3.03
115  case SatelliteSystem::Mixed: return "Mix";
116  default: return "Unk";
117  }
118  }
119 
120 
121  void RinexSatID ::
122  fromString(const std::string& s)
123  {
124  char c;
125  std::istringstream iss(s);
126 
127  id = -1;
128  system = SatelliteSystem::GPS; // default
129  if(s.find_first_not_of(std::string(" \t\n"), 0) == std::string::npos)
130  return; // all whitespace yields the default
131 
132  iss >> c; // read one character (non-whitespace)
133  switch(c)
134  {
135  // no leading system character
136  case '0': case '1': case '2': case '3': case '4':
137  case '5': case '6': case '7': case '8': case '9':
138  iss.putback(c);
140  break;
141  case 'R': case 'r':
143  break;
144  case 'T': case 't':
146  break;
147  case 'S': case 's':
149  break;
150  case 'E': case 'e':
152  break;
153  case 'M': case 'm':
155  break;
156  case ' ': case 'G': case 'g':
158  break;
159  case 'J': case 'j':
161  break;
162  case 'I': case 'i':
164  break;
165  case 'C': case 'c':
167  break;
168  default: // non-RINEX system character
169  Exception e(std::string("Invalid system character \"")
170  + c + std::string("\""));
171  GNSSTK_THROW(e);
172  }
173  iss >> id;
174  if(id <= 0)
175  {
176  id = -1;
177  }
178  else
179  {
180  // do the kludging that RINEX does for PRNs > 99
181  switch (system)
182  {
184  id += 100;
185  break;
187  if (id < 83)
188  {
189  // PRN codes in the range of 193-197
190  id += MIN_PRN_QZS-1;
191  }
192  else
193  {
194  // PRN codes in the range of 183-187
195  id += 100;
196  }
197  break;
198  }
199  }
200  }
201 
202 
203  std::string RinexSatID ::
205  noexcept
206  {
207  std::ostringstream oss;
208  oss.fill(fillchar);
209  int rinexID = id;
210  // do the kludging that RINEX does for PRNs > 99
211  // id of -1 is a special case we use to represent "none"
212  if (id != -1)
213  {
214  switch (system)
215  {
217  rinexID -= 100;
218  break;
220  if (rinexID >= MIN_PRN_QZS)
221  {
222  // PRN codes in the range of 193-197
223  rinexID -= MIN_PRN_QZS-1;
224  }
225  else
226  {
227  // PRN codes in the range of 183-187
228  rinexID -= 100;
229  }
230  break;
231  }
232  }
233  oss << systemChar() << std::setw(2) << rinexID;
234  return oss.str();
235  }
236 
237 
238  void RinexSatID ::
240  {
241  switch(system)
242  {
252  break;
253  // Invalidate anything non-RINEX.
254  default:
256  id = -1;
257  }
258  }
259 }
gnsstk::SatelliteSystem::IRNSS
@ IRNSS
Official name changed from IRNSS to NavIC.
gnsstk::MIN_PRN_QZS
const int MIN_PRN_QZS
First assigned PRN in QZSS.
Definition: GNSSconstants.hpp:240
gnsstk::SatID::id
int id
Satellite identifier, e.g. PRN.
Definition: SatID.hpp:154
gnsstk::RinexSatID::fromString
void fromString(const std::string &s)
Definition: RinexSatID.cpp:122
const
#define const
Definition: getopt.c:43
gnsstk::RinexSatID::systemString
std::string systemString() const noexcept
Definition: RinexSatID.cpp:82
gnsstk::RinexSatID::systemString3
std::string systemString3() const noexcept
Definition: RinexSatID.cpp:102
gnsstk::SatelliteSystem
SatelliteSystem
Supported satellite systems.
Definition: SatelliteSystem.hpp:55
gnsstk::SatelliteSystem::Transit
@ Transit
gnsstk::SatID
Definition: SatID.hpp:89
gnsstk::SatelliteSystem::Geosync
@ Geosync
gnsstk::RinexSatID::fillchar
static GNSSTK_EXPORT char fillchar
Fill character used during stream output.
Definition: RinexSatID.hpp:138
GNSSconstants.hpp
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::SatelliteSystem::GPS
@ GPS
gnsstk::SatelliteSystem::Unknown
@ Unknown
gnsstk::RinexSatID::RinexSatID
RinexSatID()=default
Empty constructor; creates an invalid object (Unknown, ID = -1).
gnsstk::SatID::system
SatelliteSystem system
System for this satellite.
Definition: SatID.hpp:156
gnsstk::RinexSatID::toString
std::string toString() const noexcept
Definition: RinexSatID.cpp:204
gnsstk::SatelliteSystem::Mixed
@ Mixed
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::SatelliteSystem::Glonass
@ Glonass
RinexSatID.hpp
gnsstk::SatelliteSystem::BeiDou
@ BeiDou
aka Compass
gnsstk::RinexSatID::validate
void validate()
If an unsupported system is used, set to unknown and PRN -1.
Definition: RinexSatID.cpp:239
gnsstk::SatelliteSystem::QZSS
@ QZSS
gnsstk::SatelliteSystem::Galileo
@ Galileo
gnsstk::RinexSatID::systemChar
char systemChar() const noexcept
Definition: RinexSatID.cpp:62


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