ootk 6.0.2 → 6.0.4

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.
package/dist/main.cjs CHANGED
@@ -79,12 +79,14 @@ var AngularDistanceMethod = /* @__PURE__ */ ((AngularDistanceMethod2) => {
79
79
 
80
80
  // src/enums/CatalogSource.ts
81
81
  var CatalogSource = /* @__PURE__ */ ((CatalogSource2) => {
82
- CatalogSource2["USSF"] = "USSF";
83
- CatalogSource2["CELESTRAK"] = "Celestrak";
84
- CatalogSource2["UNIV_OF_MICH"] = "University of Michigan";
85
- CatalogSource2["CALPOLY"] = "CalPoly";
86
- CatalogSource2["NUSPACE"] = "NuSpace";
87
- CatalogSource2["VIMPEL"] = "JSC Vimpel";
82
+ CatalogSource2["USSF"] = "spacetrack";
83
+ CatalogSource2["CELESTRAK"] = "celestrak";
84
+ CatalogSource2["CELESTRAK_SUP"] = "celestrak-sup";
85
+ CatalogSource2["UNIV_OF_MICH"] = "univ-of-mich";
86
+ CatalogSource2["CALPOLY"] = "calpoly";
87
+ CatalogSource2["NUSPACE"] = "nuspace";
88
+ CatalogSource2["VIMPEL"] = "vimpel";
89
+ CatalogSource2["SATNOGS"] = "satnogs";
88
90
  CatalogSource2["TLE_TXT"] = "TLE.txt";
89
91
  CatalogSource2["EXTRA_JSON"] = "extra.json";
90
92
  return CatalogSource2;
@@ -271,8 +273,8 @@ var Epoch = class {
271
273
  */
272
274
  constructor(posix = Date.now() / 1e3) {
273
275
  this.posix = posix;
274
- if (posix < 0) {
275
- throw new ValidationError("Epoch posix time must be non-negative", "posix", posix);
276
+ if (Number.isNaN(posix)) {
277
+ throw new ValidationError("Epoch posix time must be a valid number", "posix", posix);
276
278
  }
277
279
  }
278
280
  toString() {
@@ -9849,7 +9851,7 @@ var FormatTle = class _FormatTle {
9849
9851
  const { inc, meanmo, rasc, argPe, meana, ecen, epochyr, epochday, intl } = tleParams;
9850
9852
  const scc = Tle.convert6DigitToA5(tleParams.scc);
9851
9853
  const epochYrStr = String(epochyr).padStart(2, "0");
9852
- const epochdayStr = parseFloat(String(epochday)).toFixed(8).padStart(12, "0");
9854
+ const epochdayStr = Number(epochday).toFixed(8).padStart(12, "0");
9853
9855
  const incStr = _FormatTle.inclination(inc);
9854
9856
  const meanmoStr = _FormatTle.meanMotion(meanmo);
9855
9857
  const rascStr = _FormatTle.rightAscension(rasc);
@@ -9870,9 +9872,6 @@ var FormatTle = class _FormatTle {
9870
9872
  const bstarStr = _FormatTle.formatTleExponential(tleParams.bstar ?? 0);
9871
9873
  TLE1Ending = ` ${mmDot} ${mmDdot} ${bstarStr} ${ephemerisType} ${elementSetNo}0`;
9872
9874
  }
9873
- TLE1Ending = TLE1Ending[1] === " " ? _FormatTle.setCharAt(TLE1Ending, 1, "+") : TLE1Ending;
9874
- TLE1Ending = TLE1Ending[12] === " " ? _FormatTle.setCharAt(TLE1Ending, 12, "+") : TLE1Ending;
9875
- TLE1Ending = TLE1Ending[21] === " " ? _FormatTle.setCharAt(TLE1Ending, 21, "+") : TLE1Ending;
9876
9875
  const tle1Pre = `1 ${scc}${classification} ${intlStr} ${epochYrStr}${epochdayStr}${TLE1Ending}`;
9877
9876
  const tle1 = _FormatTle.setCharAt(tle1Pre, 68, _FormatTle.tleChecksum(tle1Pre).toString());
9878
9877
  const tle2Pre = `2 ${scc} ${incStr} ${rascStr} ${ecenStr} ${argPeStr} ${meanaStr} ${meanmoStr}${revAtEpoch}0`;
@@ -9890,7 +9889,7 @@ var FormatTle = class _FormatTle {
9890
9889
  argPe = argPe.toString();
9891
9890
  }
9892
9891
  const argPeNum = parseFloat(argPe).toFixed(4);
9893
- const argPe0 = argPeNum.padStart(8, "0");
9892
+ const argPe0 = argPeNum.padStart(8, " ");
9894
9893
  if (argPe0.length !== 8) {
9895
9894
  throw new ValidationError("Argument of perigee must be 8 characters", "argPe", argPe0);
9896
9895
  }
@@ -9904,7 +9903,10 @@ var FormatTle = class _FormatTle {
9904
9903
  */
9905
9904
  static eccentricity(ecen) {
9906
9905
  if (typeof ecen === "number") {
9907
- ecen = ecen.toFixed(7);
9906
+ const ecenStr = ecen.toString();
9907
+ const dotIdx = ecenStr.indexOf(".");
9908
+ const afterDot = dotIdx >= 0 ? ecenStr.substring(dotIdx + 1) : "";
9909
+ ecen = `0.${afterDot.substring(0, 7).padEnd(7, "0")}`;
9908
9910
  }
9909
9911
  let ecen0 = ecen.padEnd(9, "0");
9910
9912
  if (ecen0[1] === ".") {
@@ -9928,7 +9930,7 @@ var FormatTle = class _FormatTle {
9928
9930
  inc = inc.toString();
9929
9931
  }
9930
9932
  const incNum = parseFloat(inc).toFixed(4);
9931
- const inc0 = incNum.padStart(8, "0");
9933
+ const inc0 = incNum.padStart(8, " ");
9932
9934
  if (inc0.length !== 8) {
9933
9935
  throw new ValidationError("Inclination must be 8 characters", "inclination", inc0);
9934
9936
  }
@@ -9945,7 +9947,7 @@ var FormatTle = class _FormatTle {
9945
9947
  meana = meana.toString();
9946
9948
  }
9947
9949
  const meanaNum = parseFloat(meana).toFixed(4);
9948
- const meana0 = meanaNum.padStart(8, "0");
9950
+ const meana0 = meanaNum.padStart(8, " ");
9949
9951
  if (meana0.length !== 8) {
9950
9952
  throw new ValidationError("Mean anomaly must be 8 characters", "meanAnomaly", meana0);
9951
9953
  }
@@ -9986,7 +9988,7 @@ var FormatTle = class _FormatTle {
9986
9988
  rasc = rasc.toString();
9987
9989
  }
9988
9990
  const rascNum = parseFloat(rasc).toFixed(4);
9989
- const rasc0 = rascNum.padStart(8, "0");
9991
+ const rasc0 = rascNum.padStart(8, " ");
9990
9992
  if (rasc0.length !== 8) {
9991
9993
  throw new ValidationError("Right ascension must be 8 characters", "rightAscension", rasc0);
9992
9994
  }
@@ -10024,7 +10026,7 @@ var FormatTle = class _FormatTle {
10024
10026
  */
10025
10027
  static formatTleExponential(value) {
10026
10028
  if (value === 0) {
10027
- return " 00000-0";
10029
+ return " 00000+0";
10028
10030
  }
10029
10031
  const sign2 = value >= 0 ? " " : "-";
10030
10032
  const absVal = Math.abs(value);
@@ -13255,13 +13257,28 @@ var ClassicalElements = class _ClassicalElements {
13255
13257
  const h = pos.cross(vel);
13256
13258
  const i = Math.acos(clamp(h.z / h.magnitude(), -1, 1));
13257
13259
  const n = Vector3D.zAxis.cross(h);
13258
- let o = Math.acos(clamp(n.x / n.magnitude(), -1, 1));
13259
- if (n.y < 0) {
13260
- o = TAU - o;
13261
- }
13262
- let w = n.angle(eVec);
13263
- if (eVec.z < 0) {
13264
- w = TAU - w;
13260
+ const nMag = n.magnitude();
13261
+ let o;
13262
+ let w;
13263
+ if (nMag < 1e-12) {
13264
+ o = 0;
13265
+ if (e > 1e-12) {
13266
+ w = Math.atan2(eVec.y, eVec.x);
13267
+ if (w < 0) {
13268
+ w = w + TAU;
13269
+ }
13270
+ } else {
13271
+ w = 0;
13272
+ }
13273
+ } else {
13274
+ o = Math.acos(clamp(n.x / nMag, -1, 1));
13275
+ if (n.y < 0) {
13276
+ o = TAU - o;
13277
+ }
13278
+ w = n.angle(eVec);
13279
+ if (eVec.z < 0) {
13280
+ w = TAU - w;
13281
+ }
13265
13282
  }
13266
13283
  let v = eVec.angle(pos);
13267
13284
  if (pos.dot(vel) < 0) {
@@ -14105,7 +14122,7 @@ ${this.line2}`;
14105
14122
  let exponent = parseInt(tleLine1.substring(BSTAR_PART_4, _Tle.bstar_.stop));
14106
14123
  if (exponentSymbol === "-") {
14107
14124
  exponent *= -1;
14108
- } else if (exponentSymbol !== "+") {
14125
+ } else if (exponentSymbol !== "+" && exponentSymbol !== " " && exponentSymbol !== "0") {
14109
14126
  throw new ParseError(`Invalid BSTAR exponent symbol: ${exponentSymbol}`, "TLE");
14110
14127
  }
14111
14128
  bstar1 *= 10 ** exponent;
@@ -16559,7 +16576,7 @@ var Satellite = class _Satellite extends SpaceObject {
16559
16576
  /** Operational status */
16560
16577
  status = "?" /* UNKNOWN */;
16561
16578
  constructor(info, options) {
16562
- if (info.source === "JSC Vimpel" /* VIMPEL */ && info.tle1 && info.tle2) {
16579
+ if (info.source === "vimpel" /* VIMPEL */ && info.tle1 && info.tle2) {
16563
16580
  info = _Satellite.setSccNumTo0_(info);
16564
16581
  }
16565
16582
  super(info);
package/dist/main.d.cts CHANGED
@@ -209,12 +209,14 @@ declare enum AngularDistanceMethod {
209
209
  }
210
210
 
211
211
  declare enum CatalogSource {
212
- USSF = "USSF",
213
- CELESTRAK = "Celestrak",
214
- UNIV_OF_MICH = "University of Michigan",
215
- CALPOLY = "CalPoly",
216
- NUSPACE = "NuSpace",
217
- VIMPEL = "JSC Vimpel",
212
+ USSF = "spacetrack",
213
+ CELESTRAK = "celestrak",
214
+ CELESTRAK_SUP = "celestrak-sup",
215
+ UNIV_OF_MICH = "univ-of-mich",
216
+ CALPOLY = "calpoly",
217
+ NUSPACE = "nuspace",
218
+ VIMPEL = "vimpel",
219
+ SATNOGS = "satnogs",
218
220
  TLE_TXT = "TLE.txt",
219
221
  EXTRA_JSON = "extra.json"
220
222
  }
package/dist/main.d.ts CHANGED
@@ -209,12 +209,14 @@ declare enum AngularDistanceMethod {
209
209
  }
210
210
 
211
211
  declare enum CatalogSource {
212
- USSF = "USSF",
213
- CELESTRAK = "Celestrak",
214
- UNIV_OF_MICH = "University of Michigan",
215
- CALPOLY = "CalPoly",
216
- NUSPACE = "NuSpace",
217
- VIMPEL = "JSC Vimpel",
212
+ USSF = "spacetrack",
213
+ CELESTRAK = "celestrak",
214
+ CELESTRAK_SUP = "celestrak-sup",
215
+ UNIV_OF_MICH = "univ-of-mich",
216
+ CALPOLY = "calpoly",
217
+ NUSPACE = "nuspace",
218
+ VIMPEL = "vimpel",
219
+ SATNOGS = "satnogs",
218
220
  TLE_TXT = "TLE.txt",
219
221
  EXTRA_JSON = "extra.json"
220
222
  }
package/dist/main.js CHANGED
@@ -77,12 +77,14 @@ var AngularDistanceMethod = /* @__PURE__ */ ((AngularDistanceMethod2) => {
77
77
 
78
78
  // src/enums/CatalogSource.ts
79
79
  var CatalogSource = /* @__PURE__ */ ((CatalogSource2) => {
80
- CatalogSource2["USSF"] = "USSF";
81
- CatalogSource2["CELESTRAK"] = "Celestrak";
82
- CatalogSource2["UNIV_OF_MICH"] = "University of Michigan";
83
- CatalogSource2["CALPOLY"] = "CalPoly";
84
- CatalogSource2["NUSPACE"] = "NuSpace";
85
- CatalogSource2["VIMPEL"] = "JSC Vimpel";
80
+ CatalogSource2["USSF"] = "spacetrack";
81
+ CatalogSource2["CELESTRAK"] = "celestrak";
82
+ CatalogSource2["CELESTRAK_SUP"] = "celestrak-sup";
83
+ CatalogSource2["UNIV_OF_MICH"] = "univ-of-mich";
84
+ CatalogSource2["CALPOLY"] = "calpoly";
85
+ CatalogSource2["NUSPACE"] = "nuspace";
86
+ CatalogSource2["VIMPEL"] = "vimpel";
87
+ CatalogSource2["SATNOGS"] = "satnogs";
86
88
  CatalogSource2["TLE_TXT"] = "TLE.txt";
87
89
  CatalogSource2["EXTRA_JSON"] = "extra.json";
88
90
  return CatalogSource2;
@@ -269,8 +271,8 @@ var Epoch = class {
269
271
  */
270
272
  constructor(posix = Date.now() / 1e3) {
271
273
  this.posix = posix;
272
- if (posix < 0) {
273
- throw new ValidationError("Epoch posix time must be non-negative", "posix", posix);
274
+ if (Number.isNaN(posix)) {
275
+ throw new ValidationError("Epoch posix time must be a valid number", "posix", posix);
274
276
  }
275
277
  }
276
278
  toString() {
@@ -9847,7 +9849,7 @@ var FormatTle = class _FormatTle {
9847
9849
  const { inc, meanmo, rasc, argPe, meana, ecen, epochyr, epochday, intl } = tleParams;
9848
9850
  const scc = Tle.convert6DigitToA5(tleParams.scc);
9849
9851
  const epochYrStr = String(epochyr).padStart(2, "0");
9850
- const epochdayStr = parseFloat(String(epochday)).toFixed(8).padStart(12, "0");
9852
+ const epochdayStr = Number(epochday).toFixed(8).padStart(12, "0");
9851
9853
  const incStr = _FormatTle.inclination(inc);
9852
9854
  const meanmoStr = _FormatTle.meanMotion(meanmo);
9853
9855
  const rascStr = _FormatTle.rightAscension(rasc);
@@ -9868,9 +9870,6 @@ var FormatTle = class _FormatTle {
9868
9870
  const bstarStr = _FormatTle.formatTleExponential(tleParams.bstar ?? 0);
9869
9871
  TLE1Ending = ` ${mmDot} ${mmDdot} ${bstarStr} ${ephemerisType} ${elementSetNo}0`;
9870
9872
  }
9871
- TLE1Ending = TLE1Ending[1] === " " ? _FormatTle.setCharAt(TLE1Ending, 1, "+") : TLE1Ending;
9872
- TLE1Ending = TLE1Ending[12] === " " ? _FormatTle.setCharAt(TLE1Ending, 12, "+") : TLE1Ending;
9873
- TLE1Ending = TLE1Ending[21] === " " ? _FormatTle.setCharAt(TLE1Ending, 21, "+") : TLE1Ending;
9874
9873
  const tle1Pre = `1 ${scc}${classification} ${intlStr} ${epochYrStr}${epochdayStr}${TLE1Ending}`;
9875
9874
  const tle1 = _FormatTle.setCharAt(tle1Pre, 68, _FormatTle.tleChecksum(tle1Pre).toString());
9876
9875
  const tle2Pre = `2 ${scc} ${incStr} ${rascStr} ${ecenStr} ${argPeStr} ${meanaStr} ${meanmoStr}${revAtEpoch}0`;
@@ -9888,7 +9887,7 @@ var FormatTle = class _FormatTle {
9888
9887
  argPe = argPe.toString();
9889
9888
  }
9890
9889
  const argPeNum = parseFloat(argPe).toFixed(4);
9891
- const argPe0 = argPeNum.padStart(8, "0");
9890
+ const argPe0 = argPeNum.padStart(8, " ");
9892
9891
  if (argPe0.length !== 8) {
9893
9892
  throw new ValidationError("Argument of perigee must be 8 characters", "argPe", argPe0);
9894
9893
  }
@@ -9902,7 +9901,10 @@ var FormatTle = class _FormatTle {
9902
9901
  */
9903
9902
  static eccentricity(ecen) {
9904
9903
  if (typeof ecen === "number") {
9905
- ecen = ecen.toFixed(7);
9904
+ const ecenStr = ecen.toString();
9905
+ const dotIdx = ecenStr.indexOf(".");
9906
+ const afterDot = dotIdx >= 0 ? ecenStr.substring(dotIdx + 1) : "";
9907
+ ecen = `0.${afterDot.substring(0, 7).padEnd(7, "0")}`;
9906
9908
  }
9907
9909
  let ecen0 = ecen.padEnd(9, "0");
9908
9910
  if (ecen0[1] === ".") {
@@ -9926,7 +9928,7 @@ var FormatTle = class _FormatTle {
9926
9928
  inc = inc.toString();
9927
9929
  }
9928
9930
  const incNum = parseFloat(inc).toFixed(4);
9929
- const inc0 = incNum.padStart(8, "0");
9931
+ const inc0 = incNum.padStart(8, " ");
9930
9932
  if (inc0.length !== 8) {
9931
9933
  throw new ValidationError("Inclination must be 8 characters", "inclination", inc0);
9932
9934
  }
@@ -9943,7 +9945,7 @@ var FormatTle = class _FormatTle {
9943
9945
  meana = meana.toString();
9944
9946
  }
9945
9947
  const meanaNum = parseFloat(meana).toFixed(4);
9946
- const meana0 = meanaNum.padStart(8, "0");
9948
+ const meana0 = meanaNum.padStart(8, " ");
9947
9949
  if (meana0.length !== 8) {
9948
9950
  throw new ValidationError("Mean anomaly must be 8 characters", "meanAnomaly", meana0);
9949
9951
  }
@@ -9984,7 +9986,7 @@ var FormatTle = class _FormatTle {
9984
9986
  rasc = rasc.toString();
9985
9987
  }
9986
9988
  const rascNum = parseFloat(rasc).toFixed(4);
9987
- const rasc0 = rascNum.padStart(8, "0");
9989
+ const rasc0 = rascNum.padStart(8, " ");
9988
9990
  if (rasc0.length !== 8) {
9989
9991
  throw new ValidationError("Right ascension must be 8 characters", "rightAscension", rasc0);
9990
9992
  }
@@ -10022,7 +10024,7 @@ var FormatTle = class _FormatTle {
10022
10024
  */
10023
10025
  static formatTleExponential(value) {
10024
10026
  if (value === 0) {
10025
- return " 00000-0";
10027
+ return " 00000+0";
10026
10028
  }
10027
10029
  const sign2 = value >= 0 ? " " : "-";
10028
10030
  const absVal = Math.abs(value);
@@ -13253,13 +13255,28 @@ var ClassicalElements = class _ClassicalElements {
13253
13255
  const h = pos.cross(vel);
13254
13256
  const i = Math.acos(clamp(h.z / h.magnitude(), -1, 1));
13255
13257
  const n = Vector3D.zAxis.cross(h);
13256
- let o = Math.acos(clamp(n.x / n.magnitude(), -1, 1));
13257
- if (n.y < 0) {
13258
- o = TAU - o;
13259
- }
13260
- let w = n.angle(eVec);
13261
- if (eVec.z < 0) {
13262
- w = TAU - w;
13258
+ const nMag = n.magnitude();
13259
+ let o;
13260
+ let w;
13261
+ if (nMag < 1e-12) {
13262
+ o = 0;
13263
+ if (e > 1e-12) {
13264
+ w = Math.atan2(eVec.y, eVec.x);
13265
+ if (w < 0) {
13266
+ w = w + TAU;
13267
+ }
13268
+ } else {
13269
+ w = 0;
13270
+ }
13271
+ } else {
13272
+ o = Math.acos(clamp(n.x / nMag, -1, 1));
13273
+ if (n.y < 0) {
13274
+ o = TAU - o;
13275
+ }
13276
+ w = n.angle(eVec);
13277
+ if (eVec.z < 0) {
13278
+ w = TAU - w;
13279
+ }
13263
13280
  }
13264
13281
  let v = eVec.angle(pos);
13265
13282
  if (pos.dot(vel) < 0) {
@@ -14103,7 +14120,7 @@ ${this.line2}`;
14103
14120
  let exponent = parseInt(tleLine1.substring(BSTAR_PART_4, _Tle.bstar_.stop));
14104
14121
  if (exponentSymbol === "-") {
14105
14122
  exponent *= -1;
14106
- } else if (exponentSymbol !== "+") {
14123
+ } else if (exponentSymbol !== "+" && exponentSymbol !== " " && exponentSymbol !== "0") {
14107
14124
  throw new ParseError(`Invalid BSTAR exponent symbol: ${exponentSymbol}`, "TLE");
14108
14125
  }
14109
14126
  bstar1 *= 10 ** exponent;
@@ -16557,7 +16574,7 @@ var Satellite = class _Satellite extends SpaceObject {
16557
16574
  /** Operational status */
16558
16575
  status = "?" /* UNKNOWN */;
16559
16576
  constructor(info, options) {
16560
- if (info.source === "JSC Vimpel" /* VIMPEL */ && info.tle1 && info.tle2) {
16577
+ if (info.source === "vimpel" /* VIMPEL */ && info.tle1 && info.tle2) {
16561
16578
  info = _Satellite.setSccNumTo0_(info);
16562
16579
  }
16563
16580
  super(info);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ootk",
3
- "version": "6.0.2",
3
+ "version": "6.0.4",
4
4
  "type": "module",
5
5
  "description": "Orbital Object Toolkit including Multiple Propagators, Initial Orbit Determination, and Maneuver Calculations.",
6
6
  "exports": {