Skip to content

Commit

Permalink
fix: 🐛 fix incorrect international designator formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Mar 30, 2024
1 parent 8aa5af9 commit 7da8317
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/coordinate/Tle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,12 @@ export class Tle {
* @returns The International Designator.
*/
static intlDes(tleLine1: TleLine1): string {
return tleLine1.substring(Tle.intlDes_.start, Tle.intlDes_.stop).trim();
const year2 = this.intlDesYear(tleLine1);
const year4 = year2 < 57 ? year2 + 2000 : year2 + 1900;
const launchNum = this.intlDesLaunchNum(tleLine1);
const launchPiece = this.intlDesLaunchPiece(tleLine1);

return `${year4}-${launchNum.toString().padStart(3, '0')}${launchPiece}`;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/objects/__snapshots__/Satellite.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Satellite {
"epochYear": 22,
"id": -1,
"inclination": 51.6415,
"intlDes": "98067A",
"intlDes": "1998-067A",
"meanAnomaly": 54.7009,
"meanMoDev1": 0.00003068,
"meanMoDev2": 0,
Expand Down
12 changes: 6 additions & 6 deletions test/tle/tleData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const tleData = [
satNum: 25544,
satNumRaw: '25544',
classification: 'U',
intlDes: '98067A',
intlDes: '1998-067A',
intlDesYear: 98,
intlDesLaunchNum: 67,
intlDesLaunchPiece: 'A',
Expand Down Expand Up @@ -42,7 +42,7 @@ export const tleData = [
satNum: 25544,
satNumRaw: '25544',
classification: 'U',
intlDes: '98067A',
intlDes: '1998-067A',
intlDesYear: 98,
intlDesLaunchNum: 67,
intlDesLaunchPiece: 'A',
Expand Down Expand Up @@ -76,7 +76,7 @@ export const tleData = [
satNum: 900,
satNumRaw: '00900',
classification: 'C',
intlDes: '64063C',
intlDes: '1964-063C',
intlDesYear: 64,
intlDesLaunchNum: 63,
intlDesLaunchPiece: 'C',
Expand All @@ -103,15 +103,15 @@ export const tleData = [
},
{
NOTE: 'This is not really secret information!',
line1: '1 A3712S 95060A 22206.53025105 -.00000022 00000+0 00000+0 0 9991' as TleLine1,
line1: '1 A3712S 05060A 22206.53025105 -.00000022 00000+0 00000+0 0 9991' as TleLine1,
line2: '2 A3712 13.5389 14.0082 0001997 133.0685 227.0577 1.00275623 18615' as TleLine2,
linenum1: 1,
linenum2: 2,
satNum: 103712,
satNumRaw: 'A3712',
classification: 'S',
intlDes: '95060A',
intlDesYear: 95,
intlDes: '2005-060A',
intlDesYear: 5,
intlDesLaunchNum: 60,
intlDesLaunchPiece: 'A',
epochYear: 22,
Expand Down

0 comments on commit 7da8317

Please sign in to comment.