Skip to content

Commit

Permalink
LineNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Stanojevic committed Feb 27, 2021
1 parent d43a892 commit 5d5a347
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion dist/tle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 37 additions & 39 deletions src/Tle.ts
Original file line number Diff line number Diff line change
@@ -1,123 +1,121 @@
import {LineNumber} from "./LineNumber";
import { LineNumber } from "./LineNumber"

export class Tle {
public satelliteId: number;
public name: string;
public line1: string;
public line2: string;
public satelliteId: number
public name: string
public line1: string
public line2: string

constructor(tleModel: any) {
this.satelliteId = tleModel.satelliteId;
this.name = tleModel.name;
this.line1 = tleModel.line1;
this.line2 = tleModel.line2;
this.satelliteId = tleModel.satelliteId
this.name = tleModel.name
this.line1 = tleModel.line1
this.line2 = tleModel.line2
}

getLine(lineNumber: LineNumber): string {
if (lineNumber === LineNumber.LINE1) {
return this.line1;
return this.line1
} else if (lineNumber === LineNumber.LINE2) {
return this.line2
}

if (lineNumber === LineNumber.LINE2) {
return this.line2;
}

return '';
return ''
}

getLineNumberRaw(lineNumber: LineNumber): string {
const line = this.getLine(lineNumber);
const line = this.getLine(lineNumber)

return line.substring(0, 1);
return line.substring(0, 1).trim()
}

getLineChecksumRaw(lineNumber: LineNumber): string {
const line = this.getLine(lineNumber);
const line = this.getLine(lineNumber)

return line.substring(68, 69);
return line.substring(68, 69).trim()
}

getSatelliteIdRaw(lineNumber: LineNumber): string {
const line = this.getLine(lineNumber);
const line = this.getLine(lineNumber)

return line.substring(2, 7);
return line.substring(2, 7).trim()
}

/**
* Line 1 Data
*/
getClassificationRaw(): string {
return this.line1.substring(7, 8);
return this.line1.substring(7, 8).trim()
}

getLaunchYearRaw(fourDigits: boolean = false): string {
return this.line1.substring(9, 11);
return this.line1.substring(9, 11).trim()
}

getLaunchNumberOfTheYearRaw(): string {
return this.line1.substring(11, 14);
return this.line1.substring(11, 14).trim()
}

getLaunchPieceRaw(): string {
return this.line1.substring(14, 17);
return this.line1.substring(14, 17).trim()
}

getEpochYearRaw(): string {
return this.line1.substring(18, 20);
return this.line1.substring(18, 20).trim()
}

getEpochDayRaw(): string {
return this.line1.substring(20, 32);
return this.line1.substring(20, 32).trim()
}

getFirstTimeDerivativeOfMeanMotionRaw(): string {
return this.line1.substring(33, 43);
return this.line1.substring(33, 43).trim()
}

getSecondTimeDerivativeOfMeanMotionRaw(): string {
return this.line1.substring(44, 52);
return this.line1.substring(44, 52).trim()
}

getBstarDragTermRaw(): string {
return this.line1.substring(53, 61);
return this.line1.substring(53, 61).trim()
}

getEphemerisTypeRaw(): string {
return this.line1.substring(62, 63);
return this.line1.substring(62, 63).trim()
}

getElementNumberRaw(): string {
return this.line1.substring(64, 68);
return this.line1.substring(64, 68).trim()
}

/**
* Line 2 Data
*/
getInclinationRaw(): string {
return this.line2.substring(8, 16);
return this.line2.substring(8, 16).trim()
}

getRightAscensionOfAscendingNodeRaw(): string {
return this.line2.substring(17, 25);
return this.line2.substring(17, 25).trim()
}

getEccentricityRaw(): string {
return this.line2.substring(26, 33)
return this.line2.substring(26, 33).trim()
}

getArgumentOfPerigeeRaw(): string {
return this.line2.substring(34, 42);
return this.line2.substring(34, 42).trim()
}

getMeanAnomalyRaw(): string {
return this.line2.substring(43, 51);
return this.line2.substring(43, 51).trim()
}

getMeanMotionRaw(): string {
return this.line2.substring(52, 63);
return this.line2.substring(52, 63).trim()
}

getRevolutionNumberRaw(): string {
return this.line2.substring(63, 68);
return this.line2.substring(63, 68).trim()
}
}
12 changes: 6 additions & 6 deletions tests/TleModelUnitTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ class TleModelUnitTest {
}

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

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

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

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

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

@test 'should return argument of perigee'() {
_chai.expect(this.tle.getArgumentOfPerigeeRaw()).to.equal(' 67.0956');
_chai.expect(this.tle.getArgumentOfPerigeeRaw()).to.equal('67.0956');
}

@test 'should return mean anomaly'() {
Expand All @@ -115,7 +115,7 @@ class TleModelUnitTest {
}

@test 'should return revolution number'() {
_chai.expect(this.tle.getRevolutionNumberRaw()).to.equal(' 1980');
_chai.expect(this.tle.getRevolutionNumberRaw()).to.equal('1980');
}

}

0 comments on commit 5d5a347

Please sign in to comment.