Skip to content

Commit 5d5a347

Browse files
LineNumber
1 parent d43a892 commit 5d5a347

File tree

3 files changed

+44
-46
lines changed

3 files changed

+44
-46
lines changed

dist/tle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Tle.ts

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,121 @@
1-
import {LineNumber} from "./LineNumber";
1+
import { LineNumber } from "./LineNumber"
22

33
export class Tle {
4-
public satelliteId: number;
5-
public name: string;
6-
public line1: string;
7-
public line2: string;
4+
public satelliteId: number
5+
public name: string
6+
public line1: string
7+
public line2: string
88

99
constructor(tleModel: any) {
10-
this.satelliteId = tleModel.satelliteId;
11-
this.name = tleModel.name;
12-
this.line1 = tleModel.line1;
13-
this.line2 = tleModel.line2;
10+
this.satelliteId = tleModel.satelliteId
11+
this.name = tleModel.name
12+
this.line1 = tleModel.line1
13+
this.line2 = tleModel.line2
1414
}
1515

1616
getLine(lineNumber: LineNumber): string {
1717
if (lineNumber === LineNumber.LINE1) {
18-
return this.line1;
18+
return this.line1
19+
} else if (lineNumber === LineNumber.LINE2) {
20+
return this.line2
1921
}
2022

21-
if (lineNumber === LineNumber.LINE2) {
22-
return this.line2;
23-
}
24-
25-
return '';
23+
return ''
2624
}
2725

2826
getLineNumberRaw(lineNumber: LineNumber): string {
29-
const line = this.getLine(lineNumber);
27+
const line = this.getLine(lineNumber)
3028

31-
return line.substring(0, 1);
29+
return line.substring(0, 1).trim()
3230
}
3331

3432
getLineChecksumRaw(lineNumber: LineNumber): string {
35-
const line = this.getLine(lineNumber);
33+
const line = this.getLine(lineNumber)
3634

37-
return line.substring(68, 69);
35+
return line.substring(68, 69).trim()
3836
}
3937

4038
getSatelliteIdRaw(lineNumber: LineNumber): string {
41-
const line = this.getLine(lineNumber);
39+
const line = this.getLine(lineNumber)
4240

43-
return line.substring(2, 7);
41+
return line.substring(2, 7).trim()
4442
}
4543

4644
/**
4745
* Line 1 Data
4846
*/
4947
getClassificationRaw(): string {
50-
return this.line1.substring(7, 8);
48+
return this.line1.substring(7, 8).trim()
5149
}
5250

5351
getLaunchYearRaw(fourDigits: boolean = false): string {
54-
return this.line1.substring(9, 11);
52+
return this.line1.substring(9, 11).trim()
5553
}
5654

5755
getLaunchNumberOfTheYearRaw(): string {
58-
return this.line1.substring(11, 14);
56+
return this.line1.substring(11, 14).trim()
5957
}
6058

6159
getLaunchPieceRaw(): string {
62-
return this.line1.substring(14, 17);
60+
return this.line1.substring(14, 17).trim()
6361
}
6462

6563
getEpochYearRaw(): string {
66-
return this.line1.substring(18, 20);
64+
return this.line1.substring(18, 20).trim()
6765
}
6866

6967
getEpochDayRaw(): string {
70-
return this.line1.substring(20, 32);
68+
return this.line1.substring(20, 32).trim()
7169
}
7270

7371
getFirstTimeDerivativeOfMeanMotionRaw(): string {
74-
return this.line1.substring(33, 43);
72+
return this.line1.substring(33, 43).trim()
7573
}
7674

7775
getSecondTimeDerivativeOfMeanMotionRaw(): string {
78-
return this.line1.substring(44, 52);
76+
return this.line1.substring(44, 52).trim()
7977
}
8078

8179
getBstarDragTermRaw(): string {
82-
return this.line1.substring(53, 61);
80+
return this.line1.substring(53, 61).trim()
8381
}
8482

8583
getEphemerisTypeRaw(): string {
86-
return this.line1.substring(62, 63);
84+
return this.line1.substring(62, 63).trim()
8785
}
8886

8987
getElementNumberRaw(): string {
90-
return this.line1.substring(64, 68);
88+
return this.line1.substring(64, 68).trim()
9189
}
9290

9391
/**
9492
* Line 2 Data
9593
*/
9694
getInclinationRaw(): string {
97-
return this.line2.substring(8, 16);
95+
return this.line2.substring(8, 16).trim()
9896
}
9997

10098
getRightAscensionOfAscendingNodeRaw(): string {
101-
return this.line2.substring(17, 25);
99+
return this.line2.substring(17, 25).trim()
102100
}
103101

104102
getEccentricityRaw(): string {
105-
return this.line2.substring(26, 33)
103+
return this.line2.substring(26, 33).trim()
106104
}
107105

108106
getArgumentOfPerigeeRaw(): string {
109-
return this.line2.substring(34, 42);
107+
return this.line2.substring(34, 42).trim()
110108
}
111109

112110
getMeanAnomalyRaw(): string {
113-
return this.line2.substring(43, 51);
111+
return this.line2.substring(43, 51).trim()
114112
}
115113

116114
getMeanMotionRaw(): string {
117-
return this.line2.substring(52, 63);
115+
return this.line2.substring(52, 63).trim()
118116
}
119117

120118
getRevolutionNumberRaw(): string {
121-
return this.line2.substring(63, 68);
119+
return this.line2.substring(63, 68).trim()
122120
}
123121
}

tests/TleModelUnitTest.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ class TleModelUnitTest {
6868
}
6969

7070
@test 'should retrieve proper first time derivative of mean motion'() {
71-
_chai.expect(this.tle.getFirstTimeDerivativeOfMeanMotionRaw()).to.equal(' .00013513');
71+
_chai.expect(this.tle.getFirstTimeDerivativeOfMeanMotionRaw()).to.equal('.00013513');
7272
}
7373

7474
@test 'should retrieve proper second time derivative of mean motion'() {
75-
_chai.expect(this.tle.getSecondTimeDerivativeOfMeanMotionRaw()).to.equal(' 00000-0');
75+
_chai.expect(this.tle.getSecondTimeDerivativeOfMeanMotionRaw()).to.equal('00000-0');
7676
}
7777

7878
@test 'should retrieve proper bstar drag term'() {
79-
_chai.expect(this.tle.getBstarDragTermRaw()).to.equal(' 18402-3');
79+
_chai.expect(this.tle.getBstarDragTermRaw()).to.equal('18402-3');
8080
}
8181

8282
@test 'should retrieve ephemeris type'() {
@@ -91,7 +91,7 @@ class TleModelUnitTest {
9191
* Line 2 Tests
9292
*/
9393
@test 'should return orbital inclination'() {
94-
_chai.expect(this.tle.getInclinationRaw()).to.equal(' 51.6389');
94+
_chai.expect(this.tle.getInclinationRaw()).to.equal('51.6389');
9595
}
9696

9797
@test 'should return right ascensions of ascending node'() {
@@ -103,7 +103,7 @@ class TleModelUnitTest {
103103
}
104104

105105
@test 'should return argument of perigee'() {
106-
_chai.expect(this.tle.getArgumentOfPerigeeRaw()).to.equal(' 67.0956');
106+
_chai.expect(this.tle.getArgumentOfPerigeeRaw()).to.equal('67.0956');
107107
}
108108

109109
@test 'should return mean anomaly'() {
@@ -115,7 +115,7 @@ class TleModelUnitTest {
115115
}
116116

117117
@test 'should return revolution number'() {
118-
_chai.expect(this.tle.getRevolutionNumberRaw()).to.equal(' 1980');
118+
_chai.expect(this.tle.getRevolutionNumberRaw()).to.equal('1980');
119119
}
120120

121121
}

0 commit comments

Comments
 (0)