🛰️航天仿真算法库 SpaceAST 0.4.0
载入中...
搜索中...
未找到
TLE.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "AstCore/TimePoint.hpp"
25#include "AstCore/TLELines.hpp"
26
27AST_NAMESPACE_BEGIN
28
35enum class ETLESource
36{
37 eFile,
38 eEdited,
39 eServer,
40};
41
42enum class ESwitchMethod
43{
44 eEpoch,
45};
46
47
48
51class AST_CORE_API TLE
52{
53public:
54 TLE() = default;
55 ~TLE() = default;
56
57 TLE(const TLE&) = default;
58 TLE& operator=(const TLE&) = default;
59 TLE(TLE&&) = default;
60 TLE& operator=(TLE&&) = default;
61
66 static TLE FromLines(const TLELines& lines);
67 static TLE FromLines(StringView l1, StringView l2);
68
69 // -- 元数据访问 --
70
71 bool enabled() const { return enabled_; }
72 void setEnabled(bool v) { enabled_ = v; }
73
74 ETLESource source() const { return source_; }
75 void setSource(ETLESource v) { source_ = v; }
76
77 ESwitchMethod switchMethod() const { return switch_method_; }
78 void setSwitchMethod(ESwitchMethod v) { switch_method_ = v; }
79
80 const TimePoint& switchEpoch() const { return switchEpoch_; }
81 void setSwitchEpoch(const TimePoint& v) { switchEpoch_ = v; }
82
83 const std::string& name() const {return name_;}
84 void setName(StringView v) { name_ = std::string(v); }
85
86 const TimePoint& epochTime() const { return epochTime_; }
87 void setEpochTime(const TimePoint& v) { epochTime_ = v; }
88
89 // -- 轨道根数访问 --
90
91 double meanMotionDot() const { return meanMotionDotTime_; }
92 void setMeanMotionDot(double v) { meanMotionDotTime_ = v; }
93
94 double motionDotDot() const { return motionDotDot_; }
95 void setMotionDotDot(double v) { motionDotDot_ = v; }
96
97 double bstar() const { return bstar_; }
98 void setBstar(double v) { bstar_ = v; }
99
100 double inclination() const { return inclination_; }
101 void setInclination(double v) { inclination_ = v; }
102
103 double rightAscenOfNode() const { return rightAscenOfNode_; }
104 void setRightAscenOfNode(double v) { rightAscenOfNode_ = v; }
105
106 double eccentricity() const { return eccentricity_; }
107 void setEccentricity(double v) { eccentricity_ = v; }
108
109 double argOfPerigee() const { return argOfPerigee_; }
110 void setArgOfPerigee(double v) { argOfPerigee_ = v; }
111
112 double meanAnomaly() const { return meanAnomaly_; }
113 void setMeanAnomaly(double v) { meanAnomaly_ = v; }
114
115 double meanMotion() const { return meanMotion_; }
116 void setMeanMotion(double v) { meanMotion_ = v; }
117
118 int revNumber() const { return revNumber_; }
119 void setRevNumber(int v) { revNumber_ = v; }
120
121 int ephType() const { return ephType_; }
122 void setEphType(int v) { ephType_ = v; }
123
124 int noradId() const { return noradId_; }
125 void setNoradId(int v) { noradId_ = v; }
126
128 std::string alpha5() const;
129 void setAlpha5(StringView v);
130
131 const std::string& intlDesignation() const { return intlDesignation_; }
132 void setIntlDesignation(StringView v) { intlDesignation_ = std::string(v); }
133
134 int elementNumber() const { return elementNumber_; }
135 void setElementNumber(int v) { elementNumber_ = v; }
136
137 char classification() const { return classification_; }
138 void setClassification(char v) { classification_ = v; }
139public:
142 TLELines toLines() const;
143private:
144 bool enabled_{true};
145 ETLESource source_
146 {ETLESource::eFile};
147 ESwitchMethod switch_method_
148 {ESwitchMethod::eEpoch};
149 std::string name_{};
150 TimePoint switchEpoch_{};
151 TimePoint epochTime_{};
152 double meanMotionDotTime_{0.0};
153 double motionDotDot_{0.0};
154 double bstar_{0.0};
155 double inclination_{0.0};
156 double rightAscenOfNode_{0.0};
157 double eccentricity_{0.0};
158 double argOfPerigee_{0.0};
159 double meanAnomaly_{0.0};
160 double meanMotion_{0.0};
161 int revNumber_{0};
162 int ephType_{0};
163 int elementNumber_{0};
164 int noradId_{0};
165 std::string intlDesignation_{};
166 char classification_{'U'};
167};
168
169
177AST_CORE_CAPI int aParseNoradId(StringView str);
178
185AST_CORE_API errc_t aTLEToString(const TLE& tle, std::string& line1, std::string& line2);
186
191AST_CORE_API errc_t aFormatTLEEpoch(const TimePoint& time, std::string& out);
192
197AST_CORE_API int aTLEChecksum(StringView line);
198
203AST_CORE_API void aTLEToOrbElem(const TLE& tle, double gm, OrbElem& elem);
204AST_CORE_API OrbElem aTLEToOrbElem(const TLE& tle, double gm);
205
210AST_CORE_API void aTLEToModOrbElem(const TLE& tle, double gm, ModOrbElem& elem);
211AST_CORE_API ModOrbElem aTLEToModOrbElem(const TLE& tle, double gm);
212
213
214/*
215参考:https://celestrak.org/NORAD/documentation/tle-fmt.php
216
217NORAD 两行轨道根数格式
218每颗卫星的数据由三行组成,格式如下:
219AAAAAAAAAAAAAAAAAAAAAAAA
2201 NNNNNU NNNNNAAA NNNNN.NNNNNNNN +.NNNNNNNN +NNNNN-N +NNNNN-N N NNNNN
2212 NNNNN NNN.NNNN NNN.NNNN NNNNNNN NNN.NNNN NNN.NNNN NN.NNNNNNNNNNNNNN
222列号索引:
223123456789111111111122222222223333333333444444444455555555556666666666
224 012345678901234567890123456789012345678901234567890123456789
225
226第0行是24个字符的卫星名称(与NORAD卫星目录中的名称长度一致)。
227
228第1行和第2行是标准两行轨道根数格式,与NORAD和NASA使用的格式相同。格式说明如下:
229
230第1行
231列 说明
23201 轨道根数行号
23303-07 卫星编号
23408 密级分类(U=非保密)
23510-11 国际编号(发射年份后两位)
23612-14 国际编号(当年发射序号)
23715-17 国际编号(此次发射的部件编号)
23819-20 历元年份(年份后两位)
23921-32 历元(一年中的第几天及小数部分)
24034-43 平均运动的一阶时间导数
24145-52 平均运动的二阶时间导数(假设前导小数点)
24254-61 BSTAR阻力项(假设前导小数点)
24363 星历表类型
24465-68 轨道根数编号
24569 校验和(模10)
246(字母、空格、句点、加号 = 0;减号 = 1)
247
248第2行
249列 说明
25001 轨道根数行号
25103-07 卫星编号
25209-16 轨道倾角 [度]
25318-25 升交点赤经 [度]
25427-33 偏心率(假设前导小数点)
25535-42 近地点幅角 [度]
25644-51 平近点角 [度]
25753-63 平均运动 [圈/天]
25864-68 历元时刻的已转圈数 [圈]
25969 校验和(模10)
260
261其余各列均为空白或固定值。
262
263示例:
264123456789111111111122222222223333333333444444444455555555556666666666
265 012345678901234567890123456789012345678901234567890123456789
266NOAA 14
2671 23455U 94089A 97320.90946019 .00000140 00000-0 10191-3 0 2621
2682 23455 99.0090 272.6745 0008546 223.1686 136.8816 14.11711747148495
269NOAA 6
2701 11416U 86 50.28438588 0.00000140 67960-4 0 5293
2712 11416 98.5105 69.3305 0012788 63.2828 296.9658 14.24899292346978
272
273*/
274
275
278AST_NAMESPACE_END
修正轨道根数
定义 OrbitElement.hpp:154
经典轨道根数
定义 OrbitElement.hpp:111
TLE 原始行文本
定义 TLELines.hpp:41
两行根数(TLE)
定义 TLE.hpp:52
绝对时间点
定义 TimePoint.hpp:109
int aParseNoradId(StringView str)
解析 5 位 NORAD 目录编号(支持 Alpha-5 字母扩展)
定义 TLE.cpp:212
int aTLEChecksum(StringView line)
计算一行 TLE 的模 10 校验和
定义 TLE.cpp:351
void aTLEToModOrbElem(const TLE &tle, double gm, ModOrbElem &elem)
将 TLE 转换为修改后的轨道根数
定义 TLE.cpp:532
errc_t aTLEToString(const TLE &tle, Span< char, 70 > line1, Span< char, 70 > line2)
将 TLE 格式化为两行文本(写入固定长度缓冲区)
定义 TLE.cpp:371
ETLESource
定义 TLE.hpp:36
@ eFile
来自文件
@ eServer
来自服务器
@ eEdited
来自编辑
errc_t aFormatTLEEpoch(const TimePoint &time, std::string &out)
将时间格式化为 TLE 历元 YYDDD.DDDDDDDD(UTC)
定义 TLE.cpp:341
void aTLEToOrbElem(const TLE &tle, double gm, OrbElem &elem)
将 TLE 转换为经典轨道根数
定义 TLE.cpp:515