core
lib
GNSSEph
SP3SatID.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 "
SP3SatID.hpp
"
40
47
namespace
gnsstk
48
{
49
char
SP3SatID::fillchar
=
'0'
;
50
51
SP3SatID ::
52
SP3SatID
(
int
p,
SatelliteSystem
s) noexcept
53
:
SatID
(p,s)
54
{
55
validate();
56
}
57
58
59
char
SP3SatID ::
60
systemChar
()
const
noexcept
61
{
62
switch
(
system
)
63
{
64
case
SatelliteSystem::GPS
:
return
'G'
;
65
case
SatelliteSystem::Galileo
:
return
'E'
;
66
case
SatelliteSystem::Glonass
:
return
'R'
;
67
case
SatelliteSystem::LEO
:
return
'L'
;
68
case
SatelliteSystem::BeiDou
:
return
'C'
;
69
case
SatelliteSystem::QZSS
:
return
'J'
;
70
case
SatelliteSystem::Mixed
:
return
'M'
;
71
// non-SP3
72
default
:
return
'?'
;
73
}
74
}
75
76
77
std::string
SP3SatID ::
78
systemString
()
const
noexcept
79
{
80
switch
(
system
)
81
{
82
case
SatelliteSystem::GPS
:
return
"GPS"
;
83
case
SatelliteSystem::Galileo
:
return
"Galileo"
;
84
case
SatelliteSystem::Glonass
:
return
"Glonass"
;
85
case
SatelliteSystem::LEO
:
return
"LEO"
;
86
case
SatelliteSystem::BeiDou
:
return
"BeiDou"
;
87
case
SatelliteSystem::QZSS
:
return
"QZSS"
;
88
case
SatelliteSystem::Mixed
:
return
"Mixed"
;
89
default
:
return
"Unknown"
;
90
}
91
}
92
93
94
void
SP3SatID ::
95
fromString
(
const
std::string s)
96
{
97
char
c;
98
std::istringstream iss(s);
99
100
id
= -1;
101
system
=
SatelliteSystem::GPS
;
// default
102
if
(s.find_first_not_of(std::string(
" \t\n"
), 0) == std::string::npos)
103
return
;
// all whitespace yields the default
104
105
iss >> c;
// read one character (non-whitespace)
106
switch
(c)
107
{
108
// no leading system character
109
case
'0'
:
case
'1'
:
case
'2'
:
case
'3'
:
case
'4'
:
110
case
'5'
:
case
'6'
:
case
'7'
:
case
'8'
:
case
'9'
:
111
iss.putback(c);
112
system
=
SatelliteSystem::GPS
;
113
break
;
114
case
' '
:
case
'G'
:
case
'g'
:
115
system
=
SatelliteSystem::GPS
;
116
break
;
117
case
'R'
:
case
'r'
:
118
system
=
SatelliteSystem::Glonass
;
119
break
;
120
case
'E'
:
case
'e'
:
121
system
=
SatelliteSystem::Galileo
;
122
break
;
123
case
'L'
:
case
'l'
:
124
system
=
SatelliteSystem::LEO
;
125
break
;
126
case
'C'
:
case
'c'
:
127
system
=
SatelliteSystem::BeiDou
;
128
break
;
129
case
'J'
:
case
'j'
:
130
system
=
SatelliteSystem::QZSS
;
131
break
;
132
case
'M'
:
case
'm'
:
133
system
=
SatelliteSystem::Mixed
;
134
break
;
135
default
:
// non-SP3 system character
136
Exception
e(std::string(
"Invalid system character \""
)
137
+ c + std::string(
"\""
));
138
GNSSTK_THROW
(e);
139
}
140
iss >>
id
;
141
if
(
id
<= 0)
142
{
143
id
= -1;
144
}
145
else
146
{
147
// do the kludging that SP3 does for PRNs > 99
148
switch
(
system
)
149
{
150
case
SatelliteSystem::QZSS
:
151
id
+= 192;
152
break
;
153
}
154
}
155
}
156
157
158
std::string
SP3SatID ::
159
toString
()
const
noexcept
160
{
161
std::ostringstream oss;
162
oss.fill(
fillchar
);
163
int
sp3ID =
id
;
164
// do the kludging that SP3 does for PRNs > 99
165
switch
(
system
)
166
{
167
case
SatelliteSystem::QZSS
:
168
sp3ID -=192;
169
break
;
170
}
171
oss <<
systemChar
()
172
<< std::setw(2) << sp3ID;
173
return
oss.str();
174
}
175
176
177
void
SP3SatID ::
178
validate
()
179
{
180
switch
(
system
)
181
{
182
case
SatelliteSystem::GPS
:
183
case
SatelliteSystem::Glonass
:
184
case
SatelliteSystem::Galileo
:
185
case
SatelliteSystem::LEO
:
186
case
SatelliteSystem::BeiDou
:
187
case
SatelliteSystem::QZSS
:
188
case
SatelliteSystem::Mixed
:
break
;
189
// invalidate anything non-SP3
190
default
:
191
system
=
SatelliteSystem::Unknown
;
192
id
= -1;
193
}
194
}
195
}
gnsstk::SatID::id
int id
Satellite identifier, e.g. PRN.
Definition:
SatID.hpp:154
const
#define const
Definition:
getopt.c:43
gnsstk::SP3SatID::fillchar
static GNSSTK_EXPORT char fillchar
fill character used during stream output
Definition:
SP3SatID.hpp:157
gnsstk::SatelliteSystem::LEO
@ LEO
gnsstk::SatelliteSystem
SatelliteSystem
Supported satellite systems.
Definition:
SatelliteSystem.hpp:55
gnsstk::SP3SatID::systemChar
char systemChar() const noexcept
Definition:
SP3SatID.cpp:60
gnsstk::SatID
Definition:
SatID.hpp:89
gnsstk
For Sinex::InputHistory.
Definition:
BasicFramework.cpp:50
gnsstk::SP3SatID::SP3SatID
SP3SatID()=default
empty constructor, creates an invalid object
gnsstk::SP3SatID::validate
void validate()
If an unsupported system is used, set to unknown and PRN -1.
Definition:
SP3SatID.cpp:178
gnsstk::Exception
Definition:
Exception.hpp:151
gnsstk::SatelliteSystem::GPS
@ GPS
gnsstk::SP3SatID::fromString
void fromString(const std::string s)
Definition:
SP3SatID.cpp:95
gnsstk::SatelliteSystem::Unknown
@ Unknown
gnsstk::SP3SatID::toString
std::string toString() const noexcept
convert to string
Definition:
SP3SatID.cpp:159
gnsstk::SatID::system
SatelliteSystem system
System for this satellite.
Definition:
SatID.hpp:156
gnsstk::SP3SatID::systemString
std::string systemString() const noexcept
Definition:
SP3SatID.cpp:78
gnsstk::SatelliteSystem::Mixed
@ Mixed
SP3SatID.hpp
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition:
Exception.hpp:366
gnsstk::SatelliteSystem::Glonass
@ Glonass
gnsstk::SatelliteSystem::BeiDou
@ BeiDou
aka Compass
gnsstk::SatelliteSystem::QZSS
@ QZSS
gnsstk::SatelliteSystem::Galileo
@ Galileo
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41