Merge remote-tracking branch 'origin/main' into fix/tle-catalog-matching

This commit is contained in:
VG31OP committed 2026-10-16 22:44:46 +05:30
commit b48f44f6e8
205 files changed
+20440 -1206

No files matched your search

+29 -1
View File
@@ -28,8 +28,36 @@ export function parseTleText(text) {
return result;
}
/**
* The catalog number an Alpha-5 field stands for, or null for any other field.
*
* Since the catalog passed 99999 (July 2026) a TLE writes the numbers above it
* in Alpha-5: a letter A–Z, skipping I and O, stands for 10–33 in the
* ten-thousands place, so 100000 is "A0000" and 339999 is "Z9999".
*/
function alpha5CatalogNumber(field) {
const letter = field[0];
if (
letter >= 'A' &&
letter <= 'Z' &&
letter !== 'I' &&
letter !== 'O' &&
/^\d{4}$/.test(field.slice(1))
) {
let tens = letter.charCodeAt(0) - 65 + 10;
if (letter > 'I') tens -= 1;
if (letter > 'O') tens -= 1;
return tens * 10000 + Number(field.slice(1));
}
return null;
}
/** The NORAD catalog number from a TLE line, or null. */
export function tleCatalogNumber(line) {
const number = Number.parseInt(String(line).slice(2, 7), 10);
const field = String(line).slice(2, 7);
const alpha5 = alpha5CatalogNumber(field);
if (alpha5 !== null) return alpha5;
const number = Number.parseInt(field, 10);
return Number.isInteger(number) ? number : null;
}