ootk 4.0.9 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (583) hide show
  1. package/README.md +0 -15
  2. package/dist/body/Celestial.d.ts +96 -0
  3. package/dist/body/Celestial.js +124 -0
  4. package/dist/body/Celestial.js.map +1 -0
  5. package/dist/body/Earth.d.ts +68 -0
  6. package/dist/body/Earth.js +198 -0
  7. package/dist/body/Earth.js.map +1 -0
  8. package/dist/body/Moon.d.ts +137 -0
  9. package/dist/body/Moon.js +464 -0
  10. package/dist/body/Moon.js.map +1 -0
  11. package/dist/body/NutationAngles.d.ts +38 -0
  12. package/dist/body/NutationAngles.js +24 -0
  13. package/dist/body/NutationAngles.js.map +1 -0
  14. package/dist/body/PrecessionAngles.d.ts +29 -0
  15. package/dist/body/PrecessionAngles.js +24 -0
  16. package/dist/body/PrecessionAngles.js.map +1 -0
  17. package/dist/body/Sun.d.ts +301 -0
  18. package/dist/body/Sun.js +544 -0
  19. package/dist/body/Sun.js.map +1 -0
  20. package/dist/body/index.d.ts +26 -0
  21. package/dist/body/index.js +27 -0
  22. package/dist/body/index.js.map +1 -0
  23. package/dist/coordinate/ClassicalElements.d.ts +132 -0
  24. package/dist/coordinate/ClassicalElements.js +279 -0
  25. package/dist/coordinate/ClassicalElements.js.map +1 -0
  26. package/dist/coordinate/EquinoctialElements.d.ts +114 -0
  27. package/dist/coordinate/EquinoctialElements.js +172 -0
  28. package/dist/coordinate/EquinoctialElements.js.map +1 -0
  29. package/dist/coordinate/FormatTle.d.ts +95 -0
  30. package/dist/coordinate/FormatTle.js +184 -0
  31. package/dist/coordinate/FormatTle.js.map +1 -0
  32. package/dist/coordinate/Geodetic.d.ts +110 -0
  33. package/dist/coordinate/Geodetic.js +163 -0
  34. package/dist/coordinate/Geodetic.js.map +1 -0
  35. package/dist/coordinate/Hill.d.ts +2 -2
  36. package/dist/coordinate/Hill.js +2 -2
  37. package/dist/coordinate/Hill.js.map +1 -1
  38. package/dist/coordinate/ITRF.d.ts +75 -0
  39. package/dist/coordinate/ITRF.js +134 -0
  40. package/dist/coordinate/ITRF.js.map +1 -0
  41. package/dist/coordinate/J2000.d.ts +65 -0
  42. package/dist/coordinate/J2000.js +120 -0
  43. package/dist/coordinate/J2000.js.map +1 -0
  44. package/dist/coordinate/RIC.d.ts +64 -0
  45. package/dist/coordinate/RIC.js +79 -0
  46. package/dist/coordinate/RIC.js.map +1 -0
  47. package/dist/coordinate/RelativeState.d.ts +70 -0
  48. package/dist/coordinate/RelativeState.js +79 -0
  49. package/dist/coordinate/RelativeState.js.map +1 -0
  50. package/dist/coordinate/StateVector.d.ts +76 -0
  51. package/dist/coordinate/StateVector.js +97 -0
  52. package/dist/coordinate/StateVector.js.map +1 -0
  53. package/dist/coordinate/TEME.d.ts +57 -0
  54. package/dist/coordinate/TEME.js +89 -0
  55. package/dist/coordinate/TEME.js.map +1 -0
  56. package/dist/coordinate/Tle.d.ts +429 -0
  57. package/dist/coordinate/Tle.js +865 -0
  58. package/dist/coordinate/Tle.js.map +1 -0
  59. package/dist/coordinate/index.d.ts +11 -0
  60. package/dist/coordinate/index.js +11 -0
  61. package/dist/coordinate/index.js.map +1 -1
  62. package/dist/coordinate/tle-format-data.d.ts +41 -0
  63. package/dist/coordinate/tle-format-data.js +46 -0
  64. package/dist/coordinate/tle-format-data.js.map +1 -0
  65. package/dist/covariance/CovarianceSample.d.ts +9 -6
  66. package/dist/covariance/CovarianceSample.js +92 -18
  67. package/dist/covariance/CovarianceSample.js.map +1 -1
  68. package/dist/covariance/StateCovariance.d.ts +2 -2
  69. package/dist/covariance/StateCovariance.js +2 -2
  70. package/dist/covariance/StateCovariance.js.map +1 -1
  71. package/dist/covariance/index.d.ts +2 -0
  72. package/dist/covariance/index.js +3 -0
  73. package/dist/covariance/index.js.map +1 -0
  74. package/dist/data/DataHandler.d.ts +66 -0
  75. package/dist/data/DataHandler.js +80 -0
  76. package/dist/data/DataHandler.js.map +1 -0
  77. package/dist/data/values/Egm96Data.d.ts +37 -0
  78. package/dist/data/values/Egm96Data.js +63 -0
  79. package/dist/data/values/Egm96Data.js.map +1 -0
  80. package/dist/data/values/HpAtmosphereData.d.ts +33 -0
  81. package/dist/data/values/HpAtmosphereData.js +58 -0
  82. package/dist/data/values/HpAtmosphereData.js.map +1 -0
  83. package/dist/data/values/HpAtmosphereResult.d.ts +29 -0
  84. package/dist/data/values/HpAtmosphereResult.js +38 -0
  85. package/dist/data/values/HpAtmosphereResult.js.map +1 -0
  86. package/dist/data/values/Iau1980Data.d.ts +36 -0
  87. package/dist/data/values/Iau1980Data.js +52 -0
  88. package/dist/data/values/Iau1980Data.js.map +1 -0
  89. package/dist/data/values/LeapSecond.d.ts +27 -0
  90. package/dist/data/values/LeapSecond.js +35 -0
  91. package/dist/data/values/LeapSecond.js.map +1 -0
  92. package/dist/data/values/LeapSecondData.d.ts +41 -0
  93. package/dist/data/values/LeapSecondData.js +103 -0
  94. package/dist/data/values/LeapSecondData.js.map +1 -0
  95. package/dist/data/values/egm96.d.ts +24 -0
  96. package/dist/data/values/egm96.js +726 -0
  97. package/dist/data/values/egm96.js.map +1 -0
  98. package/dist/data/values/hpAtmosphere.d.ts +24 -0
  99. package/dist/data/values/hpAtmosphere.js +76 -0
  100. package/dist/data/values/hpAtmosphere.js.map +1 -0
  101. package/dist/data/values/iau1980.d.ts +24 -0
  102. package/dist/data/values/iau1980.js +30 -0
  103. package/dist/data/values/iau1980.js.map +1 -0
  104. package/dist/enums/AngularDiameterMethod.d.ts +27 -0
  105. package/dist/enums/AngularDiameterMethod.js +29 -0
  106. package/dist/enums/AngularDiameterMethod.js.map +1 -0
  107. package/dist/enums/AngularDistanceMethod.d.ts +27 -0
  108. package/dist/enums/AngularDistanceMethod.js +29 -0
  109. package/dist/enums/AngularDistanceMethod.js.map +1 -0
  110. package/dist/enums/OrbitRegime.d.ts +30 -0
  111. package/dist/enums/OrbitRegime.js +32 -0
  112. package/dist/enums/OrbitRegime.js.map +1 -0
  113. package/dist/enums/PassType.d.ts +28 -0
  114. package/dist/enums/PassType.js +30 -0
  115. package/dist/enums/PassType.js.map +1 -0
  116. package/dist/enums/Sgp4OpsMode.d.ts +26 -0
  117. package/dist/enums/Sgp4OpsMode.js +28 -0
  118. package/dist/enums/Sgp4OpsMode.js.map +1 -0
  119. package/dist/enums/index.d.ts +5 -0
  120. package/dist/enums/index.js +5 -0
  121. package/dist/enums/index.js.map +1 -1
  122. package/dist/force/AtmosphericDrag.d.ts +2 -2
  123. package/dist/force/AtmosphericDrag.js +3 -6
  124. package/dist/force/AtmosphericDrag.js.map +1 -1
  125. package/dist/force/EarthGravity.d.ts +2 -2
  126. package/dist/force/EarthGravity.js +2 -2
  127. package/dist/force/EarthGravity.js.map +1 -1
  128. package/dist/force/Force.d.ts +2 -2
  129. package/dist/force/Force.js +1 -1
  130. package/dist/force/ForceModel.d.ts +2 -2
  131. package/dist/force/ForceModel.js +2 -2
  132. package/dist/force/ForceModel.js.map +1 -1
  133. package/dist/force/Gravity.d.ts +2 -2
  134. package/dist/force/Gravity.js +2 -2
  135. package/dist/force/Gravity.js.map +1 -1
  136. package/dist/force/SolarRadiationPressure.d.ts +2 -2
  137. package/dist/force/SolarRadiationPressure.js +2 -2
  138. package/dist/force/SolarRadiationPressure.js.map +1 -1
  139. package/dist/force/ThirdBodyGravity.d.ts +2 -2
  140. package/dist/force/ThirdBodyGravity.js +2 -2
  141. package/dist/force/ThirdBodyGravity.js.map +1 -1
  142. package/dist/force/Thrust.d.ts +2 -2
  143. package/dist/force/Thrust.js +2 -2
  144. package/dist/force/Thrust.js.map +1 -1
  145. package/dist/interfaces/BaseObjectParams.d.ts +31 -0
  146. package/dist/interfaces/BaseObjectParams.js +24 -0
  147. package/dist/interfaces/BaseObjectParams.js.map +1 -0
  148. package/dist/interfaces/ClassicalElementsParams.d.ts +33 -0
  149. package/dist/interfaces/ClassicalElementsParams.js +24 -0
  150. package/dist/interfaces/ClassicalElementsParams.js.map +1 -0
  151. package/dist/interfaces/EquinoctialElementsParams.d.ts +35 -0
  152. package/dist/interfaces/EquinoctialElementsParams.js +24 -0
  153. package/dist/interfaces/EquinoctialElementsParams.js.map +1 -0
  154. package/dist/interfaces/GroundPositionParams.d.ts +28 -0
  155. package/dist/interfaces/GroundPositionParams.js +24 -0
  156. package/dist/interfaces/GroundPositionParams.js.map +1 -0
  157. package/dist/interfaces/OmmFormat.d.ts +62 -0
  158. package/dist/interfaces/OmmFormat.js +2 -0
  159. package/dist/interfaces/OmmFormat.js.map +1 -0
  160. package/dist/interfaces/OptionsParams.d.ts +3 -0
  161. package/dist/interfaces/OptionsParams.js +2 -0
  162. package/dist/interfaces/OptionsParams.js.map +1 -0
  163. package/dist/interfaces/RfSensorParams.d.ts +1 -1
  164. package/dist/interfaces/SatelliteParams.d.ts +18 -0
  165. package/dist/interfaces/SatelliteParams.js +2 -0
  166. package/dist/interfaces/SatelliteParams.js.map +1 -0
  167. package/dist/interfaces/SensorParams.d.ts +38 -0
  168. package/dist/interfaces/SensorParams.js +2 -0
  169. package/dist/interfaces/SensorParams.js.map +1 -0
  170. package/dist/interfaces/StarObjectParams.d.ts +10 -0
  171. package/dist/interfaces/StarObjectParams.js +2 -0
  172. package/dist/interfaces/StarObjectParams.js.map +1 -0
  173. package/dist/interfaces/TimeVariables.d.ts +6 -0
  174. package/dist/interfaces/TimeVariables.js +2 -0
  175. package/dist/interfaces/TimeVariables.js.map +1 -0
  176. package/dist/interfaces/index.d.ts +8 -0
  177. package/dist/interpolator/ChebyshevCoefficients.d.ts +5 -5
  178. package/dist/interpolator/ChebyshevCoefficients.js +2 -2
  179. package/dist/interpolator/ChebyshevCoefficients.js.map +1 -1
  180. package/dist/interpolator/ChebyshevInterpolator.d.ts +3 -3
  181. package/dist/interpolator/ChebyshevInterpolator.js +9 -9
  182. package/dist/interpolator/ChebyshevInterpolator.js.map +1 -1
  183. package/dist/interpolator/CubicSpline.d.ts +2 -2
  184. package/dist/interpolator/CubicSpline.js +1 -1
  185. package/dist/interpolator/CubicSplineInterpolator.d.ts +4 -4
  186. package/dist/interpolator/CubicSplineInterpolator.js +10 -10
  187. package/dist/interpolator/CubicSplineInterpolator.js.map +1 -1
  188. package/dist/interpolator/FieldInterpolator.d.ts +1 -1
  189. package/dist/interpolator/FieldInterpolator.js +1 -1
  190. package/dist/interpolator/Interpolator.d.ts +2 -2
  191. package/dist/interpolator/Interpolator.js +2 -2
  192. package/dist/interpolator/Interpolator.js.map +1 -1
  193. package/dist/interpolator/LagrangeInterpolator.d.ts +7 -7
  194. package/dist/interpolator/LagrangeInterpolator.js +2 -2
  195. package/dist/interpolator/LagrangeInterpolator.js.map +1 -1
  196. package/dist/interpolator/StateInterpolator.d.ts +2 -2
  197. package/dist/interpolator/StateInterpolator.js +1 -1
  198. package/dist/interpolator/VerletBlendInterpolator.d.ts +2 -2
  199. package/dist/interpolator/VerletBlendInterpolator.js +2 -2
  200. package/dist/interpolator/VerletBlendInterpolator.js.map +1 -1
  201. package/dist/main.d.ts +15 -5
  202. package/dist/main.js +15 -5
  203. package/dist/main.js.map +1 -1
  204. package/dist/maneuver/TwoBurnOrbitTransfer.d.ts +2 -2
  205. package/dist/maneuver/TwoBurnOrbitTransfer.js +2 -2
  206. package/dist/maneuver/TwoBurnOrbitTransfer.js.map +1 -1
  207. package/dist/maneuver/Waypoint.d.ts +2 -2
  208. package/dist/maneuver/Waypoint.js +2 -2
  209. package/dist/maneuver/Waypoint.js.map +1 -1
  210. package/dist/objects/BaseObject.d.ts +74 -0
  211. package/dist/objects/BaseObject.js +151 -0
  212. package/dist/objects/BaseObject.js.map +1 -0
  213. package/dist/objects/DetailedSatellite.d.ts +3 -2
  214. package/dist/objects/DetailedSatellite.js +6 -4
  215. package/dist/objects/DetailedSatellite.js.map +1 -1
  216. package/dist/objects/DetailedSensor.d.ts +3 -2
  217. package/dist/objects/DetailedSensor.js +2 -2
  218. package/dist/objects/DetailedSensor.js.map +1 -1
  219. package/dist/objects/GroundObject.d.ts +85 -0
  220. package/dist/objects/GroundObject.js +143 -0
  221. package/dist/objects/GroundObject.js.map +1 -0
  222. package/dist/objects/LandObject.d.ts +3 -2
  223. package/dist/objects/LandObject.js +2 -2
  224. package/dist/objects/LandObject.js.map +1 -1
  225. package/dist/objects/Marker.d.ts +2 -2
  226. package/dist/objects/Marker.js +2 -2
  227. package/dist/objects/Marker.js.map +1 -1
  228. package/dist/objects/RfSensor.d.ts +1 -2
  229. package/dist/objects/RfSensor.js +1 -2
  230. package/dist/objects/RfSensor.js.map +1 -1
  231. package/dist/objects/Satellite.d.ts +226 -0
  232. package/dist/objects/Satellite.js +443 -0
  233. package/dist/objects/Satellite.js.map +1 -0
  234. package/dist/objects/Sensor.d.ts +99 -0
  235. package/dist/objects/Sensor.js +238 -0
  236. package/dist/objects/Sensor.js.map +1 -0
  237. package/dist/objects/Star.d.ts +36 -0
  238. package/dist/objects/Star.js +59 -0
  239. package/dist/objects/Star.js.map +1 -0
  240. package/dist/objects/index.d.ts +5 -0
  241. package/dist/objects/index.js +5 -0
  242. package/dist/objects/index.js.map +1 -1
  243. package/dist/observation/Observation.d.ts +2 -2
  244. package/dist/observation/Observation.js +1 -1
  245. package/dist/observation/ObservationOptical.d.ts +6 -6
  246. package/dist/observation/ObservationOptical.js +9 -9
  247. package/dist/observation/ObservationOptical.js.map +1 -1
  248. package/dist/observation/ObservationRadar.d.ts +6 -6
  249. package/dist/observation/ObservationRadar.js +9 -9
  250. package/dist/observation/ObservationRadar.js.map +1 -1
  251. package/dist/observation/ObservationUtils.d.ts +4 -2
  252. package/dist/observation/ObservationUtils.js +16 -2
  253. package/dist/observation/ObservationUtils.js.map +1 -1
  254. package/dist/observation/PropagatorPairs.d.ts +4 -4
  255. package/dist/observation/PropagatorPairs.js +7 -7
  256. package/dist/observation/PropagatorPairs.js.map +1 -1
  257. package/dist/observation/RAE.d.ts +111 -0
  258. package/dist/observation/RAE.js +214 -0
  259. package/dist/observation/RAE.js.map +1 -0
  260. package/dist/observation/RadecGeocentric.d.ts +111 -0
  261. package/dist/observation/RadecGeocentric.js +169 -0
  262. package/dist/observation/RadecGeocentric.js.map +1 -0
  263. package/dist/observation/RadecTopocentric.d.ts +123 -0
  264. package/dist/observation/RadecTopocentric.js +196 -0
  265. package/dist/observation/RadecTopocentric.js.map +1 -0
  266. package/dist/observation/index.d.ts +26 -0
  267. package/dist/observation/index.js +27 -0
  268. package/dist/observation/index.js.map +1 -0
  269. package/dist/operations/BoxMuller.d.ts +2 -2
  270. package/dist/operations/BoxMuller.js +2 -2
  271. package/dist/operations/BoxMuller.js.map +1 -1
  272. package/dist/operations/EulerAngles.d.ts +2 -2
  273. package/dist/operations/EulerAngles.js +2 -2
  274. package/dist/operations/EulerAngles.js.map +1 -1
  275. package/dist/operations/Matrix.d.ts +170 -0
  276. package/dist/operations/Matrix.js +405 -0
  277. package/dist/operations/Matrix.js.map +1 -0
  278. package/dist/operations/Quaternion.d.ts +7 -7
  279. package/dist/operations/Quaternion.js +2 -2
  280. package/dist/operations/Quaternion.js.map +1 -1
  281. package/dist/operations/Random.d.ts +40 -0
  282. package/dist/operations/Random.js +50 -0
  283. package/dist/operations/Random.js.map +1 -0
  284. package/dist/operations/RandomGaussianSource.d.ts +3 -3
  285. package/dist/operations/RandomGaussianSource.js +5 -5
  286. package/dist/operations/RandomGaussianSource.js.map +1 -1
  287. package/dist/operations/Vector.d.ts +262 -0
  288. package/dist/operations/Vector.js +415 -0
  289. package/dist/operations/Vector.js.map +1 -0
  290. package/dist/operations/Vector3D.d.ts +86 -0
  291. package/dist/operations/Vector3D.js +241 -0
  292. package/dist/operations/Vector3D.js.map +1 -0
  293. package/dist/operations/operations.d.ts +26 -0
  294. package/dist/operations/operations.js +27 -0
  295. package/dist/operations/operations.js.map +1 -0
  296. package/dist/optimize/ChebyshevCompressor.d.ts +3 -3
  297. package/dist/optimize/ChebyshevCompressor.js +8 -8
  298. package/dist/optimize/ChebyshevCompressor.js.map +1 -1
  299. package/dist/optimize/DownhillSimplex.d.ts +1 -1
  300. package/dist/optimize/DownhillSimplex.js +1 -1
  301. package/dist/optimize/GoldenSection.d.ts +2 -2
  302. package/dist/optimize/GoldenSection.js +3 -3
  303. package/dist/optimize/PolynomialRegression.d.ts +1 -1
  304. package/dist/optimize/PolynomialRegression.js +2 -2
  305. package/dist/optimize/PolynomialRegression.js.map +1 -1
  306. package/dist/optimize/PolynomicalRegressionResult.d.ts +1 -1
  307. package/dist/optimize/PolynomicalRegressionResult.js +1 -1
  308. package/dist/optimize/SimpleLinearRegression.d.ts +1 -1
  309. package/dist/optimize/SimpleLinearRegression.js +1 -1
  310. package/dist/optimize/SimplexEntry.d.ts +4 -4
  311. package/dist/optimize/SimplexEntry.js +11 -11
  312. package/dist/optimize/SimplexEntry.js.map +1 -1
  313. package/dist/orbit_determination/BatchLeastSquaresOD.d.ts +11 -11
  314. package/dist/orbit_determination/BatchLeastSquaresOD.js +2 -2
  315. package/dist/orbit_determination/BatchLeastSquaresOD.js.map +1 -1
  316. package/dist/orbit_determination/BatchLeastSquaresResult.d.ts +2 -2
  317. package/dist/orbit_determination/BatchLeastSquaresResult.js +1 -1
  318. package/dist/orbit_determination/GibbsIOD.d.ts +2 -2
  319. package/dist/orbit_determination/GibbsIOD.js +2 -2
  320. package/dist/orbit_determination/GibbsIOD.js.map +1 -1
  321. package/dist/orbit_determination/GoodingIOD.d.ts +2 -2
  322. package/dist/orbit_determination/GoodingIOD.js +2 -2
  323. package/dist/orbit_determination/GoodingIOD.js.map +1 -1
  324. package/dist/orbit_determination/HerrickGibbsIOD.d.ts +2 -2
  325. package/dist/orbit_determination/HerrickGibbsIOD.js +2 -2
  326. package/dist/orbit_determination/HerrickGibbsIOD.js.map +1 -1
  327. package/dist/orbit_determination/LambertIOD.d.ts +2 -2
  328. package/dist/orbit_determination/LambertIOD.js +2 -2
  329. package/dist/orbit_determination/LambertIOD.js.map +1 -1
  330. package/dist/orbit_determination/ModifiedGoodingIOD.d.ts +4 -4
  331. package/dist/orbit_determination/ModifiedGoodingIOD.js +2 -2
  332. package/dist/orbit_determination/ModifiedGoodingIOD.js.map +1 -1
  333. package/dist/orbit_determination/index.d.ts +7 -0
  334. package/dist/orbit_determination/index.js +8 -0
  335. package/dist/orbit_determination/index.js.map +1 -0
  336. package/dist/propagator/DormandPrince54Propagator.d.ts +5 -5
  337. package/dist/propagator/DormandPrince54Propagator.js +9 -9
  338. package/dist/propagator/DormandPrince54Propagator.js.map +1 -1
  339. package/dist/propagator/KeplerPropagator.d.ts +6 -6
  340. package/dist/propagator/KeplerPropagator.js +31 -31
  341. package/dist/propagator/KeplerPropagator.js.map +1 -1
  342. package/dist/propagator/Propagator.d.ts +2 -2
  343. package/dist/propagator/Propagator.js +2 -2
  344. package/dist/propagator/Propagator.js.map +1 -1
  345. package/dist/propagator/RkCheckpoint.d.ts +2 -2
  346. package/dist/propagator/RkCheckpoint.js +1 -1
  347. package/dist/propagator/RkResult.d.ts +2 -2
  348. package/dist/propagator/RkResult.js +1 -1
  349. package/dist/propagator/RungeKutta4Propagator.d.ts +3 -3
  350. package/dist/propagator/RungeKutta4Propagator.js +2 -2
  351. package/dist/propagator/RungeKutta4Propagator.js.map +1 -1
  352. package/dist/propagator/RungeKutta89Propagator.d.ts +5 -5
  353. package/dist/propagator/RungeKutta89Propagator.js +1 -1
  354. package/dist/propagator/RungeKutta89Propagator.js.map +1 -1
  355. package/dist/propagator/RungeKuttaAdaptive.d.ts +4 -4
  356. package/dist/propagator/RungeKuttaAdaptive.js +2 -2
  357. package/dist/propagator/RungeKuttaAdaptive.js.map +1 -1
  358. package/dist/propagator/Sgp4Propagator.d.ts +6 -6
  359. package/dist/propagator/Sgp4Propagator.js +15 -15
  360. package/dist/propagator/Sgp4Propagator.js.map +1 -1
  361. package/dist/sgp4/index.d.ts +23 -0
  362. package/dist/sgp4/index.js +24 -0
  363. package/dist/sgp4/index.js.map +1 -0
  364. package/dist/sgp4/sgp4-error.d.ts +22 -0
  365. package/dist/sgp4/sgp4-error.js +44 -0
  366. package/dist/sgp4/sgp4-error.js.map +1 -0
  367. package/dist/sgp4/sgp4.d.ts +99 -0
  368. package/dist/sgp4/sgp4.js +3164 -0
  369. package/dist/sgp4/sgp4.js.map +1 -0
  370. package/dist/smoothing/ExponentialSmoothing.d.ts +2 -2
  371. package/dist/smoothing/ExponentialSmoothing.js +1 -1
  372. package/dist/time/Epoch.d.ts +44 -0
  373. package/dist/time/Epoch.js +109 -0
  374. package/dist/time/Epoch.js.map +1 -0
  375. package/dist/time/EpochGPS.d.ts +42 -0
  376. package/dist/time/EpochGPS.js +70 -0
  377. package/dist/time/EpochGPS.js.map +1 -0
  378. package/dist/time/EpochTAI.d.ts +26 -0
  379. package/dist/time/EpochTAI.js +27 -0
  380. package/dist/time/EpochTAI.js.map +1 -0
  381. package/dist/time/EpochTDB.d.ts +26 -0
  382. package/dist/time/EpochTDB.js +27 -0
  383. package/dist/time/EpochTDB.js.map +1 -0
  384. package/dist/time/EpochTT.d.ts +26 -0
  385. package/dist/time/EpochTT.js +27 -0
  386. package/dist/time/EpochTT.js.map +1 -0
  387. package/dist/time/EpochUTC.d.ts +59 -0
  388. package/dist/time/EpochUTC.js +137 -0
  389. package/dist/time/EpochUTC.js.map +1 -0
  390. package/dist/time/EpochWindow.d.ts +28 -0
  391. package/dist/time/EpochWindow.js +31 -0
  392. package/dist/time/EpochWindow.js.map +1 -0
  393. package/dist/time/TimeStamped.d.ts +39 -0
  394. package/dist/time/TimeStamped.js +42 -0
  395. package/dist/time/TimeStamped.js.map +1 -0
  396. package/dist/time/index.d.ts +8 -0
  397. package/dist/time/index.js +9 -0
  398. package/dist/time/index.js.map +1 -0
  399. package/dist/transforms/TransformCache.d.ts +27 -0
  400. package/dist/transforms/TransformCache.js +41 -0
  401. package/dist/transforms/TransformCache.js.map +1 -0
  402. package/dist/transforms/conversions.d.ts +63 -0
  403. package/dist/transforms/conversions.js +88 -0
  404. package/dist/transforms/conversions.js.map +1 -0
  405. package/dist/transforms/index.d.ts +1 -0
  406. package/dist/transforms/index.js +1 -0
  407. package/dist/transforms/index.js.map +1 -1
  408. package/dist/transforms/transforms.d.ts +166 -2
  409. package/dist/transforms/transforms.js +372 -1
  410. package/dist/transforms/transforms.js.map +1 -1
  411. package/dist/types/types.d.ts +675 -3
  412. package/dist/types/types.js +37 -1
  413. package/dist/types/types.js.map +1 -1
  414. package/dist/utils/constants.d.ts +80 -0
  415. package/dist/utils/constants.js +87 -0
  416. package/dist/utils/constants.js.map +1 -0
  417. package/dist/utils/create-covariance-from-tle.d.ts +18 -0
  418. package/dist/utils/create-covariance-from-tle.js +57 -0
  419. package/dist/utils/create-covariance-from-tle.js.map +1 -0
  420. package/dist/utils/functions.d.ts +228 -0
  421. package/dist/utils/functions.js +476 -0
  422. package/dist/utils/functions.js.map +1 -1
  423. package/dist/utils/index.d.ts +4 -1
  424. package/dist/utils/index.js +4 -1
  425. package/dist/utils/index.js.map +1 -1
  426. package/dist/utils/jacobian.d.ts +7 -1
  427. package/dist/utils/jacobian.js +7 -2
  428. package/dist/utils/jacobian.js.map +1 -1
  429. package/dist/utils/linearDistance.d.ts +8 -0
  430. package/dist/utils/linearDistance.js +10 -0
  431. package/dist/utils/linearDistance.js.map +1 -0
  432. package/package.json +5 -8
  433. package/src/body/Celestial.ts +134 -0
  434. package/src/body/Earth.ts +260 -0
  435. package/src/body/Moon.ts +556 -0
  436. package/src/body/NutationAngles.ts +40 -0
  437. package/src/body/PrecessionAngles.ts +31 -0
  438. package/src/body/Sun.ts +665 -0
  439. package/src/body/index.ts +27 -0
  440. package/src/body/suncalc.LICENSE.md +18 -0
  441. package/src/coordinate/ClassicalElements.ts +327 -0
  442. package/src/coordinate/EquinoctialElements.ts +189 -0
  443. package/src/coordinate/FormatTle.ts +214 -0
  444. package/src/coordinate/Geodetic.ts +186 -0
  445. package/src/coordinate/Hill.ts +2 -2
  446. package/src/coordinate/ITRF.ts +146 -0
  447. package/src/coordinate/J2000.ts +130 -0
  448. package/src/coordinate/RIC.ts +87 -0
  449. package/src/coordinate/RelativeState.ts +101 -0
  450. package/src/coordinate/StateVector.ts +123 -0
  451. package/src/coordinate/TEME.ts +97 -0
  452. package/src/coordinate/Tle.ts +1024 -0
  453. package/src/coordinate/index.ts +11 -0
  454. package/src/coordinate/tle-format-data.ts +47 -0
  455. package/src/covariance/CovarianceSample.ts +117 -19
  456. package/src/covariance/StateCovariance.ts +2 -2
  457. package/src/covariance/index.ts +2 -0
  458. package/src/data/DataHandler.ts +88 -0
  459. package/src/data/values/Egm96Data.ts +75 -0
  460. package/src/data/values/HpAtmosphereData.ts +76 -0
  461. package/src/data/values/HpAtmosphereResult.ts +41 -0
  462. package/src/data/values/Iau1980Data.ts +63 -0
  463. package/src/data/values/LeapSecond.ts +37 -0
  464. package/src/data/values/LeapSecondData.ts +113 -0
  465. package/src/data/values/egm96.ts +728 -0
  466. package/src/data/values/hpAtmosphere.ts +79 -0
  467. package/src/data/values/iau1980.ts +32 -0
  468. package/src/enums/AngularDiameterMethod.ts +28 -0
  469. package/src/enums/AngularDistanceMethod.ts +28 -0
  470. package/src/enums/OrbitRegime.ts +31 -0
  471. package/src/enums/PassType.ts +29 -0
  472. package/src/enums/Sgp4OpsMode.ts +27 -0
  473. package/src/enums/index.ts +5 -0
  474. package/src/force/AtmosphericDrag.ts +2 -4
  475. package/src/force/EarthGravity.ts +2 -2
  476. package/src/force/Force.ts +2 -2
  477. package/src/force/ForceModel.ts +2 -2
  478. package/src/force/Gravity.ts +2 -2
  479. package/src/force/SolarRadiationPressure.ts +2 -2
  480. package/src/force/ThirdBodyGravity.ts +2 -2
  481. package/src/force/Thrust.ts +2 -2
  482. package/src/interfaces/BaseObjectParams.ts +33 -0
  483. package/src/interfaces/ClassicalElementsParams.ts +35 -0
  484. package/src/interfaces/EquinoctialElementsParams.ts +37 -0
  485. package/src/interfaces/GroundPositionParams.ts +30 -0
  486. package/src/interfaces/OmmFormat.ts +63 -0
  487. package/src/interfaces/OptionsParams.ts +3 -0
  488. package/src/interfaces/RfSensorParams.ts +1 -1
  489. package/src/interfaces/SatelliteParams.ts +20 -0
  490. package/src/interfaces/SensorParams.ts +39 -0
  491. package/src/interfaces/StarObjectParams.ts +11 -0
  492. package/src/interfaces/TimeVariables.ts +7 -0
  493. package/src/interfaces/index.ts +8 -0
  494. package/src/interpolator/ChebyshevCoefficients.ts +5 -5
  495. package/src/interpolator/ChebyshevInterpolator.ts +10 -10
  496. package/src/interpolator/CubicSpline.ts +2 -2
  497. package/src/interpolator/CubicSplineInterpolator.ts +8 -8
  498. package/src/interpolator/FieldInterpolator.ts +1 -1
  499. package/src/interpolator/Interpolator.ts +2 -2
  500. package/src/interpolator/LagrangeInterpolator.ts +7 -7
  501. package/src/interpolator/StateInterpolator.ts +2 -2
  502. package/src/interpolator/VerletBlendInterpolator.ts +2 -2
  503. package/src/main.ts +15 -5
  504. package/src/maneuver/TwoBurnOrbitTransfer.ts +2 -2
  505. package/src/maneuver/Waypoint.ts +2 -2
  506. package/src/objects/BaseObject.ts +171 -0
  507. package/src/objects/DetailedSatellite.ts +5 -4
  508. package/src/objects/DetailedSensor.ts +3 -2
  509. package/src/objects/GroundObject.ts +176 -0
  510. package/src/objects/LandObject.ts +3 -2
  511. package/src/objects/Marker.ts +2 -2
  512. package/src/objects/RfSensor.ts +1 -2
  513. package/src/objects/Satellite.ts +552 -0
  514. package/src/objects/Sensor.ts +279 -0
  515. package/src/objects/Star.ts +96 -0
  516. package/src/objects/index.ts +5 -0
  517. package/src/observation/Observation.ts +2 -2
  518. package/src/observation/ObservationOptical.ts +7 -7
  519. package/src/observation/ObservationRadar.ts +10 -6
  520. package/src/observation/ObservationUtils.ts +31 -2
  521. package/src/observation/PropagatorPairs.ts +3 -3
  522. package/src/observation/RAE.ts +261 -0
  523. package/src/observation/RadecGeocentric.ts +206 -0
  524. package/src/observation/RadecTopocentric.ts +241 -0
  525. package/src/observation/index.ts +27 -0
  526. package/src/operations/BoxMuller.ts +2 -2
  527. package/src/operations/EulerAngles.ts +2 -2
  528. package/src/operations/Matrix.ts +473 -0
  529. package/src/operations/Quaternion.ts +7 -7
  530. package/src/operations/Random.ts +54 -0
  531. package/src/operations/RandomGaussianSource.ts +5 -5
  532. package/src/operations/Vector.ts +484 -0
  533. package/src/operations/Vector3D.ts +289 -0
  534. package/src/operations/operations.ts +27 -0
  535. package/src/optimize/ChebyshevCompressor.ts +6 -6
  536. package/src/optimize/DownhillSimplex.ts +1 -1
  537. package/src/optimize/GoldenSection.ts +3 -3
  538. package/src/optimize/PolynomialRegression.ts +2 -2
  539. package/src/optimize/PolynomicalRegressionResult.ts +1 -1
  540. package/src/optimize/SimpleLinearRegression.ts +1 -1
  541. package/src/optimize/SimplexEntry.ts +9 -9
  542. package/src/orbit_determination/BatchLeastSquaresOD.ts +11 -11
  543. package/src/orbit_determination/BatchLeastSquaresResult.ts +2 -2
  544. package/src/orbit_determination/GibbsIOD.ts +4 -2
  545. package/src/orbit_determination/GoodingIOD.ts +2 -2
  546. package/src/orbit_determination/HerrickGibbsIOD.ts +2 -2
  547. package/src/orbit_determination/LambertIOD.ts +2 -2
  548. package/src/orbit_determination/ModifiedGoodingIOD.ts +4 -4
  549. package/src/orbit_determination/index.ts +7 -0
  550. package/src/propagator/DormandPrince54Propagator.ts +9 -9
  551. package/src/propagator/KeplerPropagator.ts +31 -31
  552. package/src/propagator/Propagator.ts +2 -2
  553. package/src/propagator/RkCheckpoint.ts +2 -2
  554. package/src/propagator/RkResult.ts +2 -2
  555. package/src/propagator/RungeKutta4Propagator.ts +3 -3
  556. package/src/propagator/RungeKutta89Propagator.ts +5 -5
  557. package/src/propagator/RungeKuttaAdaptive.ts +4 -4
  558. package/src/propagator/Sgp4Propagator.ts +14 -14
  559. package/src/sgp4/index.ts +24 -0
  560. package/src/sgp4/sgp4-error.ts +53 -0
  561. package/src/sgp4/sgp4.LICENSE.md +28 -0
  562. package/src/sgp4/sgp4.ts +3983 -0
  563. package/src/smoothing/ExponentialSmoothing.ts +2 -2
  564. package/src/time/Epoch.ts +128 -0
  565. package/src/time/EpochGPS.ts +76 -0
  566. package/src/time/EpochTAI.ts +27 -0
  567. package/src/time/EpochTDB.ts +27 -0
  568. package/src/time/EpochTT.ts +27 -0
  569. package/src/time/EpochUTC.ts +188 -0
  570. package/src/time/EpochWindow.ts +33 -0
  571. package/src/time/TimeStamped.ts +46 -0
  572. package/src/time/index.ts +8 -0
  573. package/src/transforms/TransformCache.ts +46 -0
  574. package/src/transforms/conversions.ts +98 -0
  575. package/src/transforms/index.ts +1 -0
  576. package/src/transforms/transforms.ts +478 -2
  577. package/src/types/types.ts +722 -3
  578. package/src/utils/constants.ts +113 -0
  579. package/src/utils/create-covariance-from-tle.ts +75 -0
  580. package/src/utils/functions.ts +562 -0
  581. package/src/utils/index.ts +4 -1
  582. package/src/utils/jacobian.ts +7 -3
  583. package/src/utils/linearDistance.ts +11 -0
@@ -0,0 +1,1024 @@
1
+ /* eslint-disable max-lines */
2
+ /**
3
+ * @author @thkruz Theodore Kruczek
4
+ * @description Orbital Object ToolKit (ootk) is a collection of tools for working
5
+ * with satellites and other orbital objects.
6
+ * @license AGPL-3.0-or-later
7
+ * @copyright (c) 2025 Kruczek Labs LLC
8
+ *
9
+ * Many of the classes are based off of the work of @david-rc-dayton and his
10
+ * Pious Squid library (https://github.com/david-rc-dayton/pious_squid) which
11
+ * is licensed under the MIT license.
12
+ *
13
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
14
+ * terms of the GNU Affero General Public License as published by the Free Software
15
+ * Foundation, either version 3 of the License, or (at your option) any later version.
16
+ *
17
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
+ * See the GNU Affero General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU Affero General Public License along with
22
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
23
+ */
24
+
25
+ import { ClassicalElements, FormatTle, TEME } from './index.js';
26
+ import { Sgp4OpsMode } from '../enums/Sgp4OpsMode.js';
27
+ import { Sgp4, Vector3D } from '../main.js';
28
+ import { Sgp4GravConstants } from '../sgp4/sgp4.js';
29
+ import { EpochUTC } from '../time/EpochUTC.js';
30
+ import {
31
+ Degrees,
32
+ EciVec3,
33
+ Kilometers,
34
+ KilometersPerSecond,
35
+ Line1Data,
36
+ Line2Data,
37
+ Minutes,
38
+ SatelliteRecord,
39
+ Seconds,
40
+ StateVectorSgp4,
41
+ TleData,
42
+ TleDataFull,
43
+ TleLine1,
44
+ TleLine2,
45
+ } from '../types/types.js';
46
+ import { DEG2RAD, earthGravityParam, RAD2DEG, secondsPerDay, TAU } from '../utils/constants.js';
47
+ import { getDayOfYear, newtonNu, toPrecision } from '../utils/functions.js';
48
+ import { TleFormatData } from './tle-format-data.js';
49
+
50
+ /**
51
+ * Tle is a static class with a collection of methods for working with TLEs.
52
+ */
53
+ export class Tle {
54
+ line1: TleLine1;
55
+ line2: TleLine2;
56
+ epoch: EpochUTC;
57
+ satnum: number;
58
+ private readonly satrec_: SatelliteRecord;
59
+ /**
60
+ * Mapping of alphabets to their corresponding numeric values.
61
+ */
62
+ private static readonly alpha5_ = {
63
+ A: '10',
64
+ B: '11',
65
+ C: '12',
66
+ D: '13',
67
+ E: '14',
68
+ F: '15',
69
+ G: '16',
70
+ H: '17',
71
+ // I is skipped on purpose
72
+ J: '18',
73
+ K: '19',
74
+ L: '20',
75
+ M: '21',
76
+ N: '22',
77
+ // O is skipped on purpose
78
+ P: '23',
79
+ Q: '24',
80
+ R: '25',
81
+ S: '26',
82
+ T: '27',
83
+ U: '28',
84
+ V: '29',
85
+ W: '30',
86
+ X: '31',
87
+ Y: '32',
88
+ Z: '33',
89
+ } as const;
90
+ /** The argument of perigee field. */
91
+ private static readonly argPerigee_ = new TleFormatData(35, 42);
92
+ /** The BSTAR drag term field. */
93
+ private static readonly bstar_ = new TleFormatData(54, 61);
94
+ /** The checksum field. */
95
+ private static readonly checksum_ = new TleFormatData(69, 69);
96
+ /** The classification field. */
97
+ private static readonly classification_ = new TleFormatData(8, 8);
98
+ /** The eccentricity field. */
99
+ private static readonly eccentricity_ = new TleFormatData(27, 33);
100
+ /** The element set number field. */
101
+ private static readonly elsetNum_ = new TleFormatData(65, 68);
102
+ /** The ephemeris type field. */
103
+ private static readonly ephemerisType_ = new TleFormatData(63, 63);
104
+ /** The epoch day field. */
105
+ private static readonly epochDay_ = new TleFormatData(21, 32);
106
+ /** The epoch year field. */
107
+ private static readonly epochYear_ = new TleFormatData(19, 20);
108
+ /** The inclination field. */
109
+ private static readonly inclination_ = new TleFormatData(9, 16);
110
+ /** The international designator launch number field. */
111
+ private static readonly intlDesLaunchNum_ = new TleFormatData(12, 14);
112
+ /** The international designator launch piece field. */
113
+ private static readonly intlDesLaunchPiece_ = new TleFormatData(15, 17);
114
+ /** The international designator year field. */
115
+ private static readonly intlDesYear_ = new TleFormatData(10, 11);
116
+ /** The line number field. */
117
+ private static readonly lineNumber_ = new TleFormatData(1, 1);
118
+ /** The mean anomaly field. */
119
+ private static readonly meanAnom_ = new TleFormatData(44, 51);
120
+ /** The first derivative of the mean motion field. */
121
+ private static readonly meanMoDev1_ = new TleFormatData(34, 43);
122
+ /** The second derivative of the mean motion field. */
123
+ private static readonly meanMoDev2_ = new TleFormatData(45, 52);
124
+ /** The mean motion field. */
125
+ private static readonly meanMo_ = new TleFormatData(53, 63);
126
+ /** The right ascension of the ascending node field. */
127
+ private static readonly rightAscension_ = new TleFormatData(18, 25);
128
+ /** The revolution number field. */
129
+ private static readonly revNum_ = new TleFormatData(64, 68);
130
+ /** The satellite number field. */
131
+ private static readonly satNum_ = new TleFormatData(3, 7);
132
+
133
+ constructor(
134
+ line1: string,
135
+ line2: string,
136
+ opsMode: Sgp4OpsMode = Sgp4OpsMode.AFSPC,
137
+ gravConst: Sgp4GravConstants = Sgp4GravConstants.wgs72,
138
+ ) {
139
+ this.line1 = line1 as TleLine1;
140
+ this.line2 = line2 as TleLine2;
141
+ this.epoch = Tle.parseEpoch_(line1.substring(18, 32));
142
+ this.satnum = parseInt(Tle.convertA5to6Digit(line1.substring(2, 7)));
143
+ this.satrec_ = Sgp4.createSatrec(line1, line2, gravConst, opsMode);
144
+ }
145
+
146
+ toString(): string {
147
+ return `${this.line1}\n${this.line2}`;
148
+ }
149
+
150
+ /**
151
+ * Gets the semimajor axis of the TLE.
152
+ * @returns The semimajor axis value.
153
+ */
154
+ get semimajorAxis(): number {
155
+ return Tle.tleSma_(this.line2);
156
+ }
157
+
158
+ /**
159
+ * Gets the eccentricity of the TLE.
160
+ * @returns The eccentricity value.
161
+ */
162
+ get eccentricity(): number {
163
+ return Tle.tleEcc_(this.line2);
164
+ }
165
+
166
+ /**
167
+ * Gets the inclination of the TLE.
168
+ * @returns The inclination in degrees.
169
+ */
170
+ get inclination(): number {
171
+ return Tle.tleInc_(this.line2);
172
+ }
173
+
174
+ /**
175
+ * Gets the inclination in degrees.
176
+ * @returns The inclination in degrees.
177
+ */
178
+ get inclinationDegrees(): number {
179
+ return Tle.tleInc_(this.line2) * RAD2DEG;
180
+ }
181
+
182
+ /**
183
+ * Gets the apogee of the TLE (Two-Line Elements) object.
184
+ * Apogee is the point in an orbit that is farthest from the Earth.
185
+ * It is calculated as the product of the semimajor axis and (1 + eccentricity).
186
+ * @returns The apogee value.
187
+ */
188
+ get apogee(): number {
189
+ return this.semimajorAxis * (1 + this.eccentricity);
190
+ }
191
+
192
+ /**
193
+ * Gets the perigee of the TLE (Two-Line Element Set).
194
+ * The perigee is the point in the orbit of a satellite or other celestial body where it is closest to the Earth.
195
+ * It is calculated as the product of the semimajor axis and the difference between 1 and the eccentricity.
196
+ * @returns The perigee value.
197
+ */
198
+ get perigee(): number {
199
+ return this.semimajorAxis * (1 - this.eccentricity);
200
+ }
201
+
202
+ /**
203
+ * Gets the period of the TLE in minutes.
204
+ * @returns The period of the TLE in minutes.
205
+ */
206
+ get period(): Minutes {
207
+ const periodSec = (TAU * Math.sqrt(this.semimajorAxis ** 3 / earthGravityParam)) as Seconds;
208
+
209
+ return (periodSec / 60) as Minutes;
210
+ }
211
+
212
+ /**
213
+ * Parses the epoch string and returns the corresponding EpochUTC object.
214
+ * @param epochStr - The epoch string to parse.
215
+ * @returns The parsed EpochUTC object.
216
+ */
217
+ private static parseEpoch_(epochStr: string): EpochUTC {
218
+ let year = parseInt(epochStr.substring(0, 2));
219
+
220
+ if (year >= 57) {
221
+ year += 1900;
222
+ } else {
223
+ year += 2000;
224
+ }
225
+ const days = parseFloat(epochStr.substring(2, 14)) - 1;
226
+
227
+ return EpochUTC.fromDateTimeString(`${year}-01-01T00:00:00.000Z`).roll(days * secondsPerDay as Seconds);
228
+ }
229
+
230
+ static calcElsetAge(
231
+ tle1: TleLine1,
232
+ nowInput?: Date,
233
+ outputUnits: 'days' | 'hours' | 'minutes' | 'seconds' = 'days',
234
+ ): number {
235
+ nowInput ??= new Date();
236
+ const currentYearFull = nowInput.getUTCFullYear();
237
+ const currentYearShort = currentYearFull % 100;
238
+
239
+ const epochYearShort = parseInt(tle1.substring(18, 20), 10);
240
+ const epochDayOfYear = parseFloat(tle1.substring(20, 32));
241
+
242
+ let epochYearFull: number;
243
+
244
+ if (epochYearShort <= currentYearShort) {
245
+ epochYearFull = 2000 + epochYearShort;
246
+ } else {
247
+ epochYearFull = 1900 + epochYearShort;
248
+ }
249
+
250
+ const epochJday = epochDayOfYear + (epochYearFull * 365);
251
+ const currentJday = getDayOfYear() + (currentYearFull * 365);
252
+ const currentTime = (nowInput.getUTCHours() * 3600 + nowInput.getUTCMinutes() * 60 +
253
+ nowInput.getUTCSeconds()) / 86400;
254
+ const daysOld = (currentJday + currentTime) - epochJday;
255
+
256
+ switch (outputUnits) {
257
+ case 'hours':
258
+ return daysOld * 24;
259
+ case 'minutes':
260
+ return daysOld * 1440;
261
+ case 'seconds':
262
+ return daysOld * 86400;
263
+ default:
264
+ return daysOld;
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Propagates the TLE (Two-Line Element Set) to a specific epoch and returns the TEME (True Equator Mean Equinox)
270
+ * coordinates.
271
+ * @param epoch The epoch to propagate the TLE to.
272
+ * @returns The TEME coordinates at the specified epoch.
273
+ * @throws Error if propagation fails.
274
+ */
275
+ propagate(epoch: EpochUTC): TEME {
276
+ const r = new Float64Array(3);
277
+ const v = new Float64Array(3);
278
+
279
+ const stateVector = Sgp4.propagate(this.satrec_, epoch.difference(this.epoch) / 60.0);
280
+
281
+ if (!stateVector) {
282
+ throw new Error('Propagation failed');
283
+ }
284
+
285
+ Tle.sv2rv_(stateVector, r, v);
286
+
287
+ return new TEME(
288
+ epoch,
289
+ new Vector3D(<Kilometers>r[0], <Kilometers>r[1], <Kilometers>r[2]),
290
+ new Vector3D(<KilometersPerSecond>v[0], <KilometersPerSecond>v[1], <KilometersPerSecond>v[2]),
291
+ );
292
+ }
293
+
294
+ /**
295
+ * Converts the state vector to position and velocity arrays.
296
+ * @param stateVector - The state vector containing position and velocity information.
297
+ * @param r - The array to store the position values.
298
+ * @param v - The array to store the velocity values.
299
+ */
300
+ private static sv2rv_(stateVector: StateVectorSgp4, r: Float64Array, v: Float64Array) {
301
+ const pos = stateVector.position as EciVec3;
302
+ const vel = stateVector.velocity as EciVec3<KilometersPerSecond>;
303
+
304
+ r[0] = pos.x;
305
+ r[1] = pos.y;
306
+ r[2] = pos.z;
307
+ v[0] = vel.x;
308
+ v[1] = vel.y;
309
+ v[2] = vel.z;
310
+ }
311
+
312
+ /**
313
+ * Returns the current state of the satellite in the TEME coordinate system.
314
+ * @returns The current state of the satellite.
315
+ */
316
+ private currentState_(): TEME {
317
+ const r = new Float64Array(3);
318
+ const v = new Float64Array(3);
319
+
320
+ const stateVector = Sgp4.propagate(this.satrec_, 0.0);
321
+
322
+ Tle.sv2rv_(stateVector, r, v);
323
+
324
+ return new TEME(
325
+ this.epoch,
326
+ new Vector3D(<Kilometers>r[0], <Kilometers>r[1], <Kilometers>r[2]),
327
+ new Vector3D(<KilometersPerSecond>v[0], <KilometersPerSecond>v[1], <KilometersPerSecond>v[2]),
328
+ );
329
+ }
330
+
331
+ /**
332
+ * Gets the state of the TLE in the TEME coordinate system.
333
+ * @returns The state of the TLE in the TEME coordinate system.
334
+ */
335
+ get state(): TEME {
336
+ return this.currentState_();
337
+ }
338
+
339
+ /**
340
+ * Calculates the Semi-Major Axis (SMA) from the second line of a TLE.
341
+ * @param line2 The second line of the TLE.
342
+ * @returns The Semi-Major Axis (SMA) in kilometers.
343
+ */
344
+ private static tleSma_(line2: string): number {
345
+ const n = parseFloat(line2.substring(52, 63));
346
+
347
+ return earthGravityParam ** (1 / 3) / ((TAU * n) / secondsPerDay) ** (2 / 3);
348
+ }
349
+
350
+ /**
351
+ * Parses the eccentricity value from the second line of a TLE.
352
+ * @param line2 The second line of the TLE.
353
+ * @returns The eccentricity value.
354
+ */
355
+ private static tleEcc_(line2: string): number {
356
+ return parseFloat(`0.${line2.substring(26, 33)}`);
357
+ }
358
+
359
+ /**
360
+ * Calculates the inclination angle from the second line of a TLE.
361
+ * @param line2 The second line of the TLE.
362
+ * @returns The inclination angle in radians.
363
+ */
364
+ private static tleInc_(line2: string): number {
365
+ return parseFloat(line2.substring(8, 16)) * DEG2RAD;
366
+ }
367
+
368
+ /**
369
+ * Creates a TLE (Two-Line Element) object from classical orbital elements.
370
+ * @param elements - The classical orbital elements.
371
+ * @returns A TLE object.
372
+ */
373
+ static fromClassicalElements(elements: ClassicalElements): Tle {
374
+ const { epochYr, epochDay } = elements.epoch.toEpochYearAndDay();
375
+ const intl = '58001A ';
376
+ const scc = '00001';
377
+
378
+ const tles = FormatTle.createTle({
379
+ inc: FormatTle.inclination(elements.inclinationDegrees),
380
+ meanmo: FormatTle.meanMotion(elements.revsPerDay),
381
+ ecen: FormatTle.eccentricity(elements.eccentricity.toFixed(7)),
382
+ argPe: FormatTle.argumentOfPerigee(elements.argPerigeeDegrees),
383
+ meana: FormatTle.meanAnomaly(newtonNu(elements.eccentricity, elements.trueAnomaly).m * RAD2DEG),
384
+ rasc: FormatTle.rightAscension(elements.rightAscensionDegrees),
385
+ epochday: epochDay,
386
+ epochyr: epochYr,
387
+ scc,
388
+ intl,
389
+ });
390
+
391
+ return new Tle(tles.tle1, tles.tle2);
392
+ }
393
+
394
+ /**
395
+ * Argument of perigee.
396
+ * @see https://en.wikipedia.org/wiki/Argument_of_perigee
397
+ * @example 69.9862
398
+ * @param tleLine2 The second line of the Tle to parse.
399
+ * @returns The argument of perigee in degrees (0 to 360).
400
+ */
401
+ static argOfPerigee(tleLine2: TleLine2): Degrees {
402
+ const argPe = parseFloat(tleLine2.substring(Tle.argPerigee_.start, Tle.argPerigee_.stop));
403
+
404
+ if (!(argPe >= 0 && argPe <= 360)) {
405
+ throw new Error(`Invalid argument of perigee: ${argPe}`);
406
+ }
407
+
408
+ return toPrecision(argPe, 4) as Degrees;
409
+ }
410
+
411
+ /**
412
+ * BSTAR drag term (decimal point assumed). Estimates the effects of atmospheric drag on the satellite's motion.
413
+ * @see https://en.wikipedia.org/wiki/BSTAR
414
+ * @example 0.000036771
415
+ * @description ('36771-4' in the original Tle or 0.36771 * 10 ^ -4)
416
+ * @param tleLine1 The first line of the Tle to parse.
417
+ * @returns The drag coefficient.
418
+ */
419
+ static bstar(tleLine1: TleLine1): number {
420
+ const BSTAR_PART_2 = Tle.bstar_.start + 1;
421
+ const BSTAR_PART_3 = Tle.bstar_.start + 6;
422
+ const BSTAR_PART_4 = Tle.bstar_.stop - 1;
423
+
424
+ const bstarSymbol = tleLine1.substring(Tle.bstar_.start, BSTAR_PART_2);
425
+ // Decimal place is assumed
426
+ let bstar1 = parseFloat(`0.${tleLine1.substring(BSTAR_PART_2, BSTAR_PART_3)}`);
427
+ const exponentSymbol = tleLine1.substring(BSTAR_PART_3, BSTAR_PART_4);
428
+ let exponent = parseInt(tleLine1.substring(BSTAR_PART_4, Tle.bstar_.stop));
429
+
430
+ if (exponentSymbol === '-') {
431
+ exponent *= -1;
432
+ } else if (exponentSymbol !== '+') {
433
+ throw new Error(`Invalid BSTAR symbol: ${bstarSymbol}`);
434
+ }
435
+
436
+ bstar1 *= 10 ** exponent;
437
+
438
+ if (bstarSymbol === '-') {
439
+ bstar1 *= -1;
440
+ } else if (bstarSymbol === '+' || bstarSymbol === ' ') {
441
+ // Do nothing
442
+ } else {
443
+ throw new Error(`Invalid BSTAR symbol: ${bstarSymbol}`);
444
+ }
445
+
446
+ return toPrecision(bstar1, 14);
447
+ }
448
+
449
+ /**
450
+ * Tle line 1 checksum (modulo 10), for verifying the integrity of this line of the Tle.
451
+ * @example 3
452
+ * @param tleLine The first line of the Tle to parse.
453
+ * @returns The checksum value (0 to 9)
454
+ */
455
+ static checksum(tleLine: TleLine1 | TleLine2): number {
456
+ return parseInt(tleLine.substring(Tle.checksum_.start, Tle.checksum_.stop));
457
+ }
458
+
459
+ /**
460
+ * Returns the satellite classification.
461
+ * Some websites like https://KeepTrack.space and Celestrak.org will embed
462
+ * information in this field about the source of the Tle.
463
+ * @example 'U'
464
+ * unclassified
465
+ * @example 'C'
466
+ * confidential
467
+ * @example 'S'
468
+ * secret
469
+ * @param tleLine1 The first line of the Tle to parse.
470
+ * @returns The satellite classification.
471
+ */
472
+ static classification(tleLine1: TleLine1): string {
473
+ return tleLine1.substring(Tle.classification_.start, Tle.classification_.stop);
474
+ }
475
+
476
+ /**
477
+ * Orbital eccentricity, decimal point assumed. All artificial Earth satellites have an eccentricity between 0
478
+ * (perfect circle) and 1 (parabolic orbit).
479
+ * @example 0.0006317
480
+ * (`0006317` in the original Tle)
481
+ * @param tleLine2 The second line of the Tle to parse.
482
+ * @returns The eccentricity of the satellite (0 to 1)
483
+ */
484
+ static eccentricity(tleLine2: TleLine2): number {
485
+ const ecc = parseFloat(`0.${tleLine2.substring(Tle.eccentricity_.start, Tle.eccentricity_.stop)}`);
486
+
487
+ if (!(ecc >= 0 && ecc <= 1)) {
488
+ throw new Error(`Invalid eccentricity: ${ecc}`);
489
+ }
490
+
491
+ return toPrecision(ecc, 7);
492
+ }
493
+
494
+ /**
495
+ * Tle element set number, incremented for each new Tle generated.
496
+ * @see https://en.wikipedia.org/wiki/Two-line_element_set
497
+ * @example 999
498
+ * @param tleLine1 The first line of the Tle to parse.
499
+ * @returns The element number (1 to 999)
500
+ */
501
+ static elsetNum(tleLine1: TleLine1): number {
502
+ return parseInt(tleLine1.substring(Tle.elsetNum_.start, Tle.elsetNum_.stop));
503
+ }
504
+
505
+ /**
506
+ * Private value - used by United States Space Force to reference the orbit model used to generate the Tle. Will
507
+ * always be seen as zero externally (e.g. by "us", unless you are "them" - in which case, hello!).
508
+ *
509
+ * Starting in 2024, this may contain a 4 if the Tle was generated using the new SGP4-XP model. Until the source code
510
+ * is released, there is no way to support that format in JavaScript or TypeScript.
511
+ * @example 0
512
+ * @param tleLine1 The first line of the Tle to parse.
513
+ * @returns The ephemeris type.
514
+ */
515
+ static ephemerisType(tleLine1: TleLine1): 0 {
516
+ const ephemerisType = parseInt(tleLine1.substring(Tle.ephemerisType_.start, Tle.ephemerisType_.stop));
517
+
518
+ if (ephemerisType !== 0 && ephemerisType !== 4) {
519
+ throw new Error('Invalid ephemeris type');
520
+ }
521
+
522
+ if (ephemerisType === 4) {
523
+ throw new Error('SGP4-XP is not supported');
524
+ }
525
+
526
+ return ephemerisType;
527
+ }
528
+
529
+ /**
530
+ * Fractional day of the year when the Tle was generated (Tle epoch).
531
+ * @example 206.18396726
532
+ * @param tleLine1 The first line of the Tle to parse.
533
+ * @returns The day of the year the Tle was generated. (1 to 365.99999999)
534
+ */
535
+ static epochDay(tleLine1: string): number {
536
+ const epochDay = parseFloat(tleLine1.substring(Tle.epochDay_.start, Tle.epochDay_.stop));
537
+
538
+ if (epochDay < 1 || epochDay > 366.99999999) {
539
+ throw new Error('Invalid epoch day');
540
+ }
541
+
542
+ return toPrecision(epochDay, 8);
543
+ }
544
+
545
+ /**
546
+ * Year when the Tle was generated (Tle epoch), last two digits.
547
+ * @example 17
548
+ * @param tleLine1 The first line of the Tle to parse.
549
+ * @returns The year the Tle was generated. (0 to 99)
550
+ */
551
+ static epochYear(tleLine1: TleLine1) {
552
+ const epochYear = parseInt(tleLine1.substring(Tle.epochYear_.start, Tle.epochYear_.stop));
553
+
554
+ if (epochYear < 0 || epochYear > 99) {
555
+ throw new Error('Invalid epoch year');
556
+ }
557
+
558
+ return epochYear;
559
+ }
560
+
561
+ /**
562
+ * Year when the Tle was generated (Tle epoch), four digits.
563
+ * @example 2008
564
+ * @param tleLine1 The first line of the Tle to parse.
565
+ * @returns The year the Tle was generated. (1957 to 2056)
566
+ */
567
+ static epochYearFull(tleLine1: TleLine1) {
568
+ const epochYear = parseInt(tleLine1.substring(Tle.epochYear_.start, Tle.epochYear_.stop));
569
+
570
+ if (epochYear < 0 || epochYear > 99) {
571
+ throw new Error('Invalid epoch year');
572
+ }
573
+
574
+ if (epochYear < 57) {
575
+ return epochYear + 2000;
576
+ }
577
+
578
+ return epochYear + 1900;
579
+ }
580
+
581
+ /**
582
+ * Inclination relative to the Earth's equatorial plane in degrees. 0 to 90 degrees is a prograde orbit and 90 to 180
583
+ * degrees is a retrograde orbit.
584
+ * @example 51.6400
585
+ * @param tleLine2 The second line of the Tle to parse.
586
+ * @returns The inclination of the satellite. (0 to 180)
587
+ */
588
+ static inclination(tleLine2: TleLine2): Degrees {
589
+ const inc = parseFloat(tleLine2.substring(Tle.inclination_.start, Tle.inclination_.stop));
590
+
591
+ if (inc < 0 || inc > 180) {
592
+ throw new Error(`Invalid inclination: ${inc}`);
593
+ }
594
+
595
+ return toPrecision(inc, 4) as Degrees;
596
+ }
597
+
598
+ /**
599
+ * International Designator (COSPAR ID)
600
+ * @see https://en.wikipedia.org/wiki/International_Designator
601
+ * @param tleLine1 The first line of the Tle to parse.
602
+ * @returns The International Designator.
603
+ */
604
+ static intlDes(tleLine1: TleLine1): string {
605
+ const year2 = this.intlDesYear(tleLine1);
606
+
607
+ // Some TLEs don't have a year, so we can't generate an IntlDes
608
+ if (isNaN(year2)) {
609
+ return '';
610
+ }
611
+
612
+ const year4 = year2 < 57 ? year2 + 2000 : year2 + 1900;
613
+ const launchNum = this.intlDesLaunchNum(tleLine1);
614
+ const launchPiece = this.intlDesLaunchPiece(tleLine1);
615
+
616
+ return `${year4}-${launchNum.toString().padStart(3, '0')}${launchPiece}`;
617
+ }
618
+
619
+ /**
620
+ * International Designator (COSPAR ID): Launch number of the year.
621
+ * @example 67
622
+ * @param tleLine1 The first line of the Tle to parse.
623
+ * @returns The launch number of the International Designator. (1 to 999)
624
+ */
625
+ static intlDesLaunchNum(tleLine1: string): number {
626
+ return parseInt(tleLine1.substring(Tle.intlDesLaunchNum_.start, Tle.intlDesLaunchNum_.stop));
627
+ }
628
+
629
+ /**
630
+ * International Designator (COSPAR ID): Piece of the launch.
631
+ * @example 'A'
632
+ * @param tleLine1 The first line of the Tle to parse.
633
+ * @returns The launch piece of the International Designator. (A to ZZZ)
634
+ */
635
+ static intlDesLaunchPiece(tleLine1: TleLine1): string {
636
+ return tleLine1.substring(Tle.intlDesLaunchPiece_.start, Tle.intlDesLaunchPiece_.stop).trim();
637
+ }
638
+
639
+ /**
640
+ * International Designator (COSPAR ID): Last 2 digits of launch year.
641
+ * @example 98
642
+ * @param tleLine1 The first line of the Tle to parse.
643
+ * @returns The year of the International Designator. (0 to 99)
644
+ */
645
+ static intlDesYear(tleLine1: TleLine1): number {
646
+ return parseInt(tleLine1.substring(Tle.intlDesYear_.start, Tle.intlDesYear_.stop));
647
+ }
648
+
649
+ /**
650
+ * This should always return a 1 or a 2.
651
+ * @example 1
652
+ * @param tleLine The first line of the Tle to parse.
653
+ * @returns The line number of the Tle. (1 or 2)
654
+ */
655
+ static lineNumber(tleLine: TleLine1 | TleLine2): 1 | 2 {
656
+ const lineNum = parseInt(tleLine.substring(Tle.lineNumber_.start, Tle.lineNumber_.stop));
657
+
658
+ if (lineNum !== 1 && lineNum !== 2) {
659
+ throw new Error('Invalid line number');
660
+ }
661
+
662
+ return lineNum;
663
+ }
664
+
665
+ /**
666
+ * Mean anomaly. Indicates where the satellite was located within its orbit at the time of the Tle epoch.
667
+ * @see https://en.wikipedia.org/wiki/Mean_Anomaly
668
+ * @example 25.2906
669
+ * @param tleLine2 The second line of the Tle to parse.
670
+ * @returns The mean anomaly of the satellite. (0 to 360)
671
+ */
672
+ static meanAnomaly(tleLine2: TleLine2): Degrees {
673
+ const meanA = parseFloat(tleLine2.substring(Tle.meanAnom_.start, Tle.meanAnom_.stop));
674
+
675
+ if (!(meanA >= 0 && meanA <= 360)) {
676
+ throw new Error(`Invalid mean anomaly: ${meanA}`);
677
+ }
678
+
679
+ return toPrecision(meanA, 4) as Degrees;
680
+ }
681
+
682
+ /**
683
+ * First Time Derivative of the Mean Motion divided by two. Defines how mean motion changes over time, so Tle
684
+ * propagators can still be used to make reasonable guesses when times are distant from the original Tle epoch. This
685
+ * is recorded in units of orbits per day per day.
686
+ * @example 0.00001961
687
+ * @param tleLine1 The first line of the Tle to parse.
688
+ * @returns The first derivative of the mean motion.
689
+ */
690
+ static meanMoDev1(tleLine1: TleLine1): number {
691
+ const meanMoDev1 = parseFloat(tleLine1.substring(Tle.meanMoDev1_.start, Tle.meanMoDev1_.stop));
692
+
693
+ if (isNaN(meanMoDev1)) {
694
+ throw new Error('Invalid first derivative of mean motion.');
695
+ }
696
+
697
+ return toPrecision(meanMoDev1, 8);
698
+ }
699
+
700
+ /**
701
+ * Second Time Derivative of Mean Motion divided by six (decimal point assumed). Measures rate of change in the Mean
702
+ * Motion Dot so software can make reasonable guesses when times are distant from the original Tle epoch. Usually
703
+ * zero, unless the satellite is manuevering or in a decaying orbit. This is recorded in units of orbits per day per
704
+ * day per day.
705
+ * @example 0
706
+ * '00000-0' in the original Tle or 0.00000 * 10 ^ 0
707
+ * @param tleLine1 The first line of the Tle to parse.
708
+ * @returns The second derivative of the mean motion.
709
+ */
710
+ static meanMoDev2(tleLine1: string): number {
711
+ const meanMoDev2 = parseFloat(tleLine1.substring(Tle.meanMoDev2_.start, Tle.meanMoDev2_.stop));
712
+
713
+ if (isNaN(meanMoDev2)) {
714
+ throw new Error('Invalid second derivative of mean motion.');
715
+ }
716
+
717
+ // NOTE: Should this limit to a specific number of decimals?
718
+ return meanMoDev2;
719
+ }
720
+
721
+ /**
722
+ * Revolutions around the Earth per day (mean motion).
723
+ * @see https://en.wikipedia.org/wiki/Mean_Motion
724
+ * @example 15.54225995
725
+ * @param tleLine2 The second line of the Tle to parse.
726
+ * @returns The mean motion of the satellite. (0 to 18)
727
+ */
728
+ static meanMotion(tleLine2: TleLine2): number {
729
+ const meanMo = parseFloat(tleLine2.substring(Tle.meanMo_.start, Tle.meanMo_.stop));
730
+
731
+ if (!(meanMo > 0 && meanMo <= 18)) {
732
+ throw new Error(`Invalid mean motion: ${meanMo}`);
733
+ }
734
+
735
+ return toPrecision(meanMo, 8);
736
+ }
737
+
738
+ /**
739
+ * Calculates the period of a satellite orbit based on the given Tle line 2.
740
+ * @example 92.53035747
741
+ * @param tleLine2 The Tle line 2.
742
+ * @returns The period of the satellite orbit in minutes.
743
+ */
744
+ static period(tleLine2: TleLine2): Minutes {
745
+ const meanMo = Tle.meanMotion(tleLine2);
746
+
747
+ return (1440 / meanMo) as Minutes;
748
+ }
749
+
750
+ /**
751
+ * Right ascension of the ascending node in degrees. Essentially, this is the angle of the satellite as it crosses
752
+ * northward (ascending) across the Earth's equator (equatorial plane).
753
+ * @example 208.9163
754
+ * @param tleLine2 The second line of the Tle to parse.
755
+ * @returns The right ascension of the satellite. (0 to 360)
756
+ */
757
+ static rightAscension(tleLine2: TleLine2): Degrees {
758
+ const rightAscension = parseFloat(tleLine2.substring(Tle.rightAscension_.start, Tle.rightAscension_.stop));
759
+
760
+ if (!(rightAscension >= 0 && rightAscension <= 360)) {
761
+ throw new Error(`Invalid Right Ascension: ${rightAscension}`);
762
+ }
763
+
764
+ return toPrecision(rightAscension, 4) as Degrees;
765
+ }
766
+
767
+ /**
768
+ * NORAD catalog number. To support Alpha-5, the first digit can be a letter. This will NOT be converted to a number.
769
+ * Use satNum() for that.
770
+ * @see https://en.wikipedia.org/wiki/Satellite_Catalog_Number
771
+ * @example 25544
772
+ * @example B1234
773
+ * @param tleLine The first line of the Tle to parse.
774
+ * @returns NORAD catalog number.
775
+ */
776
+ static rawSatNum(tleLine: TleLine1 | TleLine2): string {
777
+ return tleLine.substring(Tle.satNum_.start, Tle.satNum_.stop);
778
+ }
779
+
780
+ /**
781
+ * Total satellite revolutions when this Tle was generated. This number rolls over (e.g. 99999 -> 0).
782
+ * @example 6766
783
+ * @param tleLine2 The second line of the Tle to parse.
784
+ * @returns The revolutions around the Earth per day (mean motion). (0 to 99999)
785
+ */
786
+ static revNum(tleLine2: TleLine2): number {
787
+ return parseInt(tleLine2.substring(Tle.revNum_.start, Tle.revNum_.stop));
788
+ }
789
+
790
+ /**
791
+ * NORAD catalog number converted to a number.
792
+ * @see https://en.wikipedia.org/wiki/Satellite_Catalog_Number
793
+ * @example 25544
794
+ * @example 111234
795
+ * @param tleLine The first line of the Tle to parse.
796
+ * @returns NORAD catalog number. (0 to 339999)
797
+ */
798
+ static satNum(tleLine: TleLine1 | TleLine2): number {
799
+ const satNumStr = tleLine.substring(Tle.satNum_.start, Tle.satNum_.stop);
800
+ const sixDigitSatNum = Tle.convertA5to6Digit(satNumStr);
801
+
802
+ return parseInt(sixDigitSatNum);
803
+ }
804
+
805
+ /**
806
+ * Parse the first line of the Tle.
807
+ * @param tleLine1 The first line of the Tle to parse.
808
+ * @returns Returns the data from the first line of the Tle.
809
+ */
810
+ static parseLine1(tleLine1: TleLine1): Line1Data {
811
+ const lineNumber1 = Tle.lineNumber(tleLine1);
812
+ const satNum = Tle.satNum(tleLine1);
813
+ const satNumRaw = Tle.rawSatNum(tleLine1);
814
+ const classification = Tle.classification(tleLine1);
815
+ const intlDes = Tle.intlDes(tleLine1);
816
+ const intlDesYear = Tle.intlDesYear(tleLine1);
817
+ const intlDesLaunchNum = Tle.intlDesLaunchNum(tleLine1);
818
+ const intlDesLaunchPiece = Tle.intlDesLaunchPiece(tleLine1);
819
+ const epochYear = Tle.epochYear(tleLine1);
820
+ const epochYearFull = Tle.epochYearFull(tleLine1);
821
+ const epochDay = Tle.epochDay(tleLine1);
822
+ const meanMoDev1 = Tle.meanMoDev1(tleLine1);
823
+ const meanMoDev2 = Tle.meanMoDev2(tleLine1);
824
+ const bstar = Tle.bstar(tleLine1);
825
+ const ephemerisType = Tle.ephemerisType(tleLine1);
826
+ const elsetNum = Tle.elsetNum(tleLine1);
827
+ const checksum1 = Tle.checksum(tleLine1);
828
+
829
+ return {
830
+ lineNumber1,
831
+ satNum,
832
+ satNumRaw,
833
+ classification,
834
+ intlDes,
835
+ intlDesYear,
836
+ intlDesLaunchNum,
837
+ intlDesLaunchPiece,
838
+ epochYear,
839
+ epochYearFull,
840
+ epochDay,
841
+ meanMoDev1,
842
+ meanMoDev2,
843
+ bstar,
844
+ ephemerisType,
845
+ elsetNum,
846
+ checksum1,
847
+ };
848
+ }
849
+
850
+ /**
851
+ * Parse the second line of the Tle.
852
+ * @param tleLine2 The second line of the Tle to parse.
853
+ * @returns Returns the data from the second line of the Tle.
854
+ */
855
+ static parseLine2(tleLine2: TleLine2): Line2Data {
856
+ const lineNumber2 = Tle.lineNumber(tleLine2);
857
+ const satNum = Tle.satNum(tleLine2);
858
+ const satNumRaw = Tle.rawSatNum(tleLine2);
859
+ const inclination = Tle.inclination(tleLine2);
860
+ const rightAscension = Tle.rightAscension(tleLine2);
861
+ const eccentricity = Tle.eccentricity(tleLine2);
862
+ const argOfPerigee = Tle.argOfPerigee(tleLine2);
863
+ const meanAnomaly = Tle.meanAnomaly(tleLine2);
864
+ const meanMotion = Tle.meanMotion(tleLine2);
865
+ const revNum = Tle.revNum(tleLine2);
866
+ const checksum2 = Tle.checksum(tleLine2);
867
+ const period = Tle.period(tleLine2);
868
+
869
+ return {
870
+ lineNumber2,
871
+ satNum,
872
+ satNumRaw,
873
+ inclination,
874
+ rightAscension,
875
+ eccentricity,
876
+ argOfPerigee,
877
+ meanAnomaly,
878
+ meanMotion,
879
+ revNum,
880
+ checksum2,
881
+ period,
882
+ };
883
+ }
884
+
885
+ /**
886
+ * Parses the Tle into orbital data.
887
+ *
888
+ * If you want all of the data then use parseTleFull instead.
889
+ * @param tleLine1 Tle line 1
890
+ * @param tleLine2 Tle line 2
891
+ * @returns Returns most commonly used orbital data from Tle
892
+ */
893
+ static parse(tleLine1: TleLine1, tleLine2: TleLine2): TleData {
894
+ const line1 = Tle.parseLine1(tleLine1);
895
+ const line2 = Tle.parseLine2(tleLine2);
896
+
897
+ if (line1.satNum !== line2.satNum) {
898
+ throw new Error('Satellite numbers do not match');
899
+ }
900
+
901
+ if (line1.satNumRaw !== line2.satNumRaw) {
902
+ throw new Error('Raw satellite numbers do not match');
903
+ }
904
+
905
+ if (line1.lineNumber1 !== 1) {
906
+ throw new Error('First line number must be 1');
907
+ }
908
+
909
+ if (line2.lineNumber2 !== 2) {
910
+ throw new Error('Second line number must be 2');
911
+ }
912
+
913
+ return {
914
+ satNum: line1.satNum,
915
+ intlDes: line1.intlDes,
916
+ epochYear: line1.epochYear,
917
+ epochDay: line1.epochDay,
918
+ meanMoDev1: line1.meanMoDev1,
919
+ meanMoDev2: line1.meanMoDev2,
920
+ bstar: line1.bstar,
921
+ inclination: line2.inclination,
922
+ rightAscension: line2.rightAscension,
923
+ eccentricity: line2.eccentricity,
924
+ argOfPerigee: line2.argOfPerigee,
925
+ meanAnomaly: line2.meanAnomaly,
926
+ meanMotion: line2.meanMotion,
927
+ period: line2.period,
928
+ };
929
+ }
930
+
931
+ /**
932
+ * Parses all of the data contained in the Tle.
933
+ *
934
+ * If you only want the most commonly used data then use parseTle instead.
935
+ * @param tleLine1 The first line of the Tle to parse.
936
+ * @param tleLine2 The second line of the Tle to parse.
937
+ * @returns Returns all of the data from the Tle.
938
+ */
939
+ static parseAll(tleLine1: TleLine1, tleLine2: TleLine2): TleDataFull {
940
+ const line1 = Tle.parseLine1(tleLine1);
941
+ const line2 = Tle.parseLine2(tleLine2);
942
+
943
+ if (line1.satNum !== line2.satNum) {
944
+ throw new Error('Satellite numbers do not match');
945
+ }
946
+
947
+ if (line1.satNumRaw !== line2.satNumRaw) {
948
+ throw new Error('Raw satellite numbers do not match');
949
+ }
950
+
951
+ if (line1.lineNumber1 !== 1) {
952
+ throw new Error('First line number must be 1');
953
+ }
954
+
955
+ if (line2.lineNumber2 !== 2) {
956
+ throw new Error('Second line number must be 2');
957
+ }
958
+
959
+ return { ...line1, ...line2 };
960
+ }
961
+
962
+ /**
963
+ * Converts a 6 digit SCC number to a 5 digit SCC alpha 5 number
964
+ * @param sccNum The 6 digit SCC number
965
+ * @returns The 5 digit SCC alpha 5 number
966
+ */
967
+ static convert6DigitToA5(sccNum: string): string {
968
+ // Only applies to 6 digit numbers
969
+ if (sccNum.length < 6) {
970
+ return sccNum;
971
+ }
972
+
973
+ if (typeof sccNum[0] !== 'string') {
974
+ throw new Error('Invalid SCC number');
975
+ }
976
+
977
+ // Already an alpha 5 number
978
+ if (RegExp(/[A-Z]/iu, 'u').test(sccNum[0])) {
979
+ return sccNum;
980
+ }
981
+
982
+ // Extract the trailing 4 digits
983
+ const rest = sccNum.slice(2, 6);
984
+
985
+ /*
986
+ * Convert the first two digit numbers into a Letter. Skip I and O as they
987
+ * look too similar to 1 and 0 A=10, B=11, C=12, D=13, E=14, F=15, G=16,
988
+ * H=17, J=18, K=19, L=20, M=21, N=22, P=23, Q=24, R=25, S=26, T=27, U=28,
989
+ * V=29, W=30, X=31, Y=32, Z=33
990
+ */
991
+ let first = parseInt(`${sccNum[0]}${sccNum[1]}`);
992
+ const iPlus = first >= 18 ? 1 : 0;
993
+ const tPlus = first >= 24 ? 1 : 0;
994
+
995
+ first = first + iPlus + tPlus;
996
+
997
+ return `${String.fromCharCode(first + 55)}${rest}`;
998
+ }
999
+
1000
+ /**
1001
+ * Converts a 5-digit SCC number to a 6-digit SCC number.
1002
+ * @param sccNum - The 5-digit SCC number to convert.
1003
+ * @returns The converted 6-digit SCC number.
1004
+ */
1005
+ static convertA5to6Digit(sccNum: string): string {
1006
+ if (sccNum.length < 5) {
1007
+ return sccNum;
1008
+ }
1009
+
1010
+ const values = sccNum.toUpperCase().split('');
1011
+
1012
+ if (!values[0]) {
1013
+ throw new Error('Invalid SCC number');
1014
+ }
1015
+
1016
+ if (values[0] in Tle.alpha5_) {
1017
+ const firstLetter = values[0] as keyof typeof Tle.alpha5_;
1018
+
1019
+ values[0] = Tle.alpha5_[firstLetter];
1020
+ }
1021
+
1022
+ return values.join('');
1023
+ }
1024
+ }