diff --git a/.gitignore b/.gitignore index 405026c..3928069 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea .vscode coverage +commonjs lib node_modules *.log diff --git a/README.md b/README.md index b70fea6..b8061e9 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ console.log(sat.meanMoDev1); // Mean Motion Deviation 1 console.log(sat.meanMoDev2); // Mean Motion Deviation 2 console.log(sat.bstar); // Bstar (Drag Coefficient) console.log(sat.inclination); // inclination in degrees -console.log(sat.raan); // right ascension of the ascending node in degrees +console.log(sat.rightAscension); // right ascension of the ascending node in degrees console.log(sat.eccentricity); // eccentricity console.log(sat.argOfPerigee); // argument of perigee in degrees console.log(sat.meanAnomaly); // mean anomaly in degrees diff --git a/examples/typescript/tle.ts b/examples/typescript/tle.ts index 2fff466..77e8dc0 100644 --- a/examples/typescript/tle.ts +++ b/examples/typescript/tle.ts @@ -46,7 +46,7 @@ const tle = Tle.parse(tle1, tle2); // meanMoDev2: 0, // bstar: 0.000059442, // inclination: 51.6433, -// raan: 59.2583, +// rightAscension: 59.2583, // eccentricity: 0.0008217, // argOfPerigee: 16.4489, // meanAnomaly: 347.6017, @@ -76,7 +76,7 @@ const tleAll = Tle.parseAll(tle1, tle2); // checksum1: 2, // lineNumber2: 2, // inclination: 51.6433, -// raan: 59.2583, +// rightAscension: 59.2583, // eccentricity: 0.0008217, // argOfPerigee: 16.4489, // meanAnomaly: 347.6017, diff --git a/package.json b/package.json index 72ab9e3..c561987 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "1.0.0-0", "description": "Orbital Object Toolkit Core including SGP4 Propagator and Coordinate Transforms", "scripts": { - "mjs": "ttsc -p tsconfig.build.json && node ./scripts/moveMjs.mjs", - "cjs": "ttsc -p tsconfig.build.json -m commonjs", + "mjs": "ttsc -p tsconfig.build.json -m esnext", + "cjs": "ttsc -p tsconfig.c.json -m commonjs", "build": "node ./scripts/cleanup.mjs && npm run mjs && npm run cjs", "lint": "eslint src", "lint:fix": "eslint src --fix", @@ -13,11 +13,12 @@ "test:coverage": "jest --coverage", "version": "auto-changelog -p && git add CHANGELOG.md" }, - "main": "./lib/ootk-core.js", + "main": "./lib/index.js", "exports": { - "import": "./lib/ootk-core.js", - "require": "./lib/ootk-core.js" + "import": "./lib/index.js", + "require": "./commonjs/index.js" }, + "typings": "./lib/index.d.ts", "repository": { "type": "git", "url": "git://github.com/thkruz/ootk-core" @@ -56,4 +57,4 @@ "typescript-transform-paths": "^3.4.6" }, "homepage": "https://github.com/thkruz/ootk" -} +} \ No newline at end of file diff --git a/scripts/moveMjs.mjs b/scripts/moveMjs.mjs index 83e31bf..6be9a5f 100644 --- a/scripts/moveMjs.mjs +++ b/scripts/moveMjs.mjs @@ -1,4 +1,5 @@ -import { renameSync } from 'fs'; +import { cpSync, renameSync } from 'fs'; -renameSync('./lib/ootk-core.js', './lib/ootk-core.mjs'); -renameSync('./lib/ootk-core.js.map', './lib/ootk-core.mjs.map'); +renameSync('./lib/index.js', './lib/index.mjs'); +renameSync('./lib/index.js.map', './lib/index.mjs.map'); +cpSync('./lib/index.d.ts', './lib/index.d.mts'); diff --git a/src/body/Celestial.ts b/src/body/Celestial.ts index 51f37c3..7642722 100644 --- a/src/body/Celestial.ts +++ b/src/body/Celestial.ts @@ -1,4 +1,4 @@ -import { AzEl, Degrees, RaDec, Radians } from '../ootk-core'; +import { AzEl, Degrees, RaDec, Radians } from '..'; import { RAD2DEG } from '../utils/constants'; import { Sun } from './Sun'; diff --git a/src/body/Earth.ts b/src/body/Earth.ts index 5ce8bef..9765e0e 100644 --- a/src/body/Earth.ts +++ b/src/body/Earth.ts @@ -1,5 +1,5 @@ +import { AngularDiameterMethod, Kilometers, Radians } from '..'; import { DataHandler } from '../data/DataHandler'; -import { AngularDiameterMethod, Kilometers, Radians } from '../ootk-core'; import { Vector3D } from '../operations/Vector3D'; import { EpochUTC } from '../time/EpochUTC'; import { asec2rad, DEG2RAD, RAD2DEG, secondsPerDay, secondsPerSiderealDay, TAU, ttasec2rad } from '../utils/constants'; diff --git a/src/body/Moon.ts b/src/body/Moon.ts index 7823fa9..2f2ab9d 100644 --- a/src/body/Moon.ts +++ b/src/body/Moon.ts @@ -38,7 +38,7 @@ * DEALINGS IN THE SOFTWARE. */ -import { AngularDiameterMethod, Celestial, Degrees, Kilometers, RaDec, Radians } from '../ootk-core'; +import { AngularDiameterMethod, Celestial, Degrees, Kilometers, RaDec, Radians } from '..'; import { Vector3D } from '../operations/Vector3D'; import { EpochUTC } from '../time/EpochUTC'; import { DEG2RAD, MS_PER_DAY } from '../utils/constants'; diff --git a/src/body/NutationAngles.ts b/src/body/NutationAngles.ts index 4edb2c7..dce2cc3 100644 --- a/src/body/NutationAngles.ts +++ b/src/body/NutationAngles.ts @@ -1,4 +1,4 @@ -import { Radians } from '../ootk-core'; +import { Radians } from '..'; // / Earth nutation angles _(rad)_. export type NutationAngles = { diff --git a/src/body/PrecessionAngles.ts b/src/body/PrecessionAngles.ts index faf6d75..3a2ba27 100644 --- a/src/body/PrecessionAngles.ts +++ b/src/body/PrecessionAngles.ts @@ -1,4 +1,4 @@ -import { Radians } from '../ootk-core'; +import { Radians } from '..'; // / Earth precession angles _(rad)_. export type PrecessionAngles = { diff --git a/src/body/Sun.ts b/src/body/Sun.ts index 9a847a5..09d93ff 100644 --- a/src/body/Sun.ts +++ b/src/body/Sun.ts @@ -1,4 +1,4 @@ -import { AngularDiameterMethod, AzEl, Degrees, Kilometers, Meters, RaDec, Radians, SunTime } from '../ootk-core'; +import { AngularDiameterMethod, AzEl, Degrees, Kilometers, Meters, RaDec, Radians, SunTime } from '..'; import { Vector3D } from '../operations/Vector3D'; import { EpochUTC } from '../time/EpochUTC'; import { astronomicalUnit, cKmPerSec, DEG2RAD, MS_PER_DAY, RAD2DEG, TAU } from '../utils/constants'; diff --git a/src/coordinate/Geodetic.ts b/src/coordinate/Geodetic.ts index 64d52a7..390e703 100644 --- a/src/coordinate/Geodetic.ts +++ b/src/coordinate/Geodetic.ts @@ -1,5 +1,5 @@ +import { AngularDistanceMethod } from '..'; import { Earth } from '../body/Earth'; -import { AngularDistanceMethod } from '../ootk-core'; import { Vector3D } from '../operations/Vector3D'; import { EpochUTC } from '../time/EpochUTC'; import { DEG2RAD, RAD2DEG } from '../utils/constants'; diff --git a/src/coordinate/TLE.ts b/src/coordinate/TLE.ts index f399bcd..bf9a63f 100644 --- a/src/coordinate/TLE.ts +++ b/src/coordinate/TLE.ts @@ -25,16 +25,18 @@ * DEALINGS IN THE SOFTWARE. */ +import { Sgp4, Vector3D } from '..'; import { Earth } from '../body'; import { ClassicalElements, FormatTle, TEME } from '../coordinate'; import { Sgp4OpsMode } from '../enums/Sgp4OpsMode'; -import { Sgp4, Vector3D } from '../ootk-core'; import { Sgp4GravConstants } from '../sgp4/sgp4'; import { EpochUTC } from '../time/EpochUTC'; import { + Degrees, EciVec3, Line1Data, Line2Data, + Minutes, SatelliteRecord, StateVectorSgp4, TleData, @@ -123,7 +125,7 @@ export class Tle { /** The mean motion field. */ private static readonly meanMo_ = new TleFormatData(53, 63); /** The right ascension of the ascending node field. */ - private static readonly raan_ = new TleFormatData(18, 25); + private static readonly rightAscension_ = new TleFormatData(18, 25); /** The revolution number field. */ private static readonly revNum_ = new TleFormatData(64, 68); /** The satellite number field. */ @@ -274,16 +276,16 @@ export class Tle { * Example: 69.9862 * * @param {string} tleLine2 The second line of the Tle to parse. - * @returns {number} The argument of perigee in degrees. + * @returns {Degrees} The argument of perigee in degrees. */ - static argOfPerigee(tleLine2: TleLine2): number { + static argOfPerigee(tleLine2: TleLine2): Degrees { const argPe = parseFloat(tleLine2.substring(Tle.argPerigee_.start, Tle.argPerigee_.stop)); if (!(argPe >= 0 && argPe < 360)) { throw new Error(`Invalid argument of perigee: ${argPe}`); } - return toPrecision(argPe, 4); + return toPrecision(argPe, 4) as Degrees; } /** @@ -494,16 +496,16 @@ export class Tle { * Example: 51.6400 * * @param {string} tleLine2 The second line of the Tle to parse. - * @returns {number} The inclination of the satellite. + * @returns {Degrees} The inclination of the satellite. */ - static inclination(tleLine2: TleLine2): number { + static inclination(tleLine2: TleLine2): Degrees { const inc = parseFloat(tleLine2.substring(Tle.inclination_.start, Tle.inclination_.stop)); if (inc < 0 || inc > 180) { throw new Error(`Invalid inclination: ${inc}`); } - return toPrecision(inc, 4); + return toPrecision(inc, 4) as Degrees; } /** @@ -585,16 +587,16 @@ export class Tle { * Example: 25.2906 * * @param {string} tleLine2 The second line of the Tle to parse. - * @returns {number} The mean anomaly of the satellite. + * @returns {Degrees} The mean anomaly of the satellite. */ - static meanAnomaly(tleLine2: TleLine2): number { + static meanAnomaly(tleLine2: TleLine2): Degrees { const meanA = parseFloat(tleLine2.substring(Tle.meanAnom_.start, Tle.meanAnom_.stop)); if (!(meanA >= 0 && meanA <= 360)) { throw new Error(`Invalid mean anomaly: ${meanA}`); } - return toPrecision(meanA, 4); + return toPrecision(meanA, 4) as Degrees; } /** @@ -669,10 +671,10 @@ export class Tle { * @param tleLine2 The Tle line 2. * @returns The period of the satellite orbit in minutes. */ - static period(tleLine2: TleLine2): number { + static period(tleLine2: TleLine2): Minutes { const meanMo = Tle.meanMotion(tleLine2); - return 1440 / meanMo; + return (1440 / meanMo) as Minutes; } /** @@ -687,16 +689,16 @@ export class Tle { * Example: 208.9163 * * @param {string} tleLine2 The second line of the Tle to parse. - * @returns {number} The right ascension of the satellite. + * @returns {Degrees} The right ascension of the satellite. */ - static rightAscension(tleLine2: TleLine2): number { - const raan = parseFloat(tleLine2.substring(Tle.raan_.start, Tle.raan_.stop)); + static rightAscension(tleLine2: TleLine2): Degrees { + const rightAscension = parseFloat(tleLine2.substring(Tle.rightAscension_.start, Tle.rightAscension_.stop)); - if (!(raan >= 0 && raan <= 360)) { - throw new Error(`Invalid RAAN: ${raan}`); + if (!(rightAscension >= 0 && rightAscension <= 360)) { + throw new Error(`Invalid Right Ascension: ${rightAscension}`); } - return toPrecision(raan, 4); + return toPrecision(rightAscension, 4) as Degrees; } /** @@ -806,7 +808,7 @@ export class Tle { const satNum = Tle.satNum(tleLine2); const satNumRaw = Tle.rawSatNum(tleLine2); const inclination = Tle.inclination(tleLine2); - const raan = Tle.rightAscension(tleLine2); + const rightAscension = Tle.rightAscension(tleLine2); const eccentricity = Tle.eccentricity(tleLine2); const argOfPerigee = Tle.argOfPerigee(tleLine2); const meanAnomaly = Tle.meanAnomaly(tleLine2); @@ -820,7 +822,7 @@ export class Tle { satNum, satNumRaw, inclination, - raan, + rightAscension, eccentricity, argOfPerigee, meanAnomaly, @@ -868,7 +870,7 @@ export class Tle { meanMoDev2: line1.meanMoDev2, bstar: line1.bstar, inclination: line2.inclination, - raan: line2.raan, + rightAscension: line2.rightAscension, eccentricity: line2.eccentricity, argOfPerigee: line2.argOfPerigee, meanAnomaly: line2.meanAnomaly, diff --git a/src/ootk-core.ts b/src/index.ts similarity index 92% rename from src/ootk-core.ts rename to src/index.ts index d4d7b4f..10310cc 100644 --- a/src/ootk-core.ts +++ b/src/index.ts @@ -31,16 +31,16 @@ * SOFTWARE. */ -export * from './body'; +export { Celestial, Earth, Moon, Sun } from './body'; export * from './coordinate'; export { Tle } from './coordinate/Tle'; export * from './data/DataHandler'; export * from './enums'; export * from './interfaces'; -export * from './objects'; +export { BaseObject, GroundPosition, Satellite, Sensor, Star } from './objects'; export * from './observation'; export * from './operations/operations'; -export { Sgp4 } from './sgp4/sgp4'; +export * from './sgp4'; export * from './time/time'; export * from './transforms'; export * from './types/types'; diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index 4c9fb64..325ff92 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -1,6 +1,6 @@ -export { BaseObjectParams } from './BaseObjectParams'; -export { GroundPositionParams } from './GroundPositionParams'; -export { OptionsParams } from './OptionsParams'; -export { SatelliteParams } from './SatelliteParams'; -export { SensorParams } from './SensorParams'; -export { StarObjectParams } from './StarObjectParams'; +export type { BaseObjectParams } from './BaseObjectParams'; +export type { GroundPositionParams } from './GroundPositionParams'; +export type { OptionsParams } from './OptionsParams'; +export type { SatelliteParams } from './SatelliteParams'; +export type { SensorParams } from './SensorParams'; +export type { StarObjectParams } from './StarObjectParams'; diff --git a/src/objects/Satellite.ts b/src/objects/Satellite.ts index 6d29bc5..5e8d8a5 100644 --- a/src/objects/Satellite.ts +++ b/src/objects/Satellite.ts @@ -47,6 +47,7 @@ import { GreenwichMeanSiderealTime, Kilometers, LlaVec3, + Minutes, PosVel, Radians, RaeVec3, @@ -68,23 +69,23 @@ import { GroundPosition } from './GroundPosition'; * Represents a satellite object with orbital information and methods for calculating its position and other properties. */ export class Satellite extends BaseObject { - apogee: number; - argOfPerigee: number; + apogee: Kilometers; + argOfPerigee: Degrees; bstar: number; eccentricity: number; epochDay: number; epochYear: number; - inclination: number; + inclination: Degrees; intlDes: string; - meanAnomaly: number; + meanAnomaly: Degrees; meanMoDev1: number; meanMoDev2: number; meanMotion: number; // eslint-disable-next-line @typescript-eslint/no-explicit-any options: OptionsParams; - perigee: number; - period: number; - raan: number; + perigee: Kilometers; + period: Minutes; + rightAscension: Degrees; satrec: SatelliteRecord; /** * The satellite catalog number as listed in the TLE. @@ -100,6 +101,14 @@ export class Satellite extends BaseObject { sccNum6: string; tle1: TleLine1; tle2: TleLine2; + /** + * The semi-major axis of the satellite's orbit. + */ + semiMajorAxis: Kilometers; + /** + * The semi-minor axis of the satellite's orbit. + */ + semiMinorAxis: Kilometers; constructor(info: SatelliteParams, options?: OptionsParams) { super(info); @@ -109,26 +118,31 @@ export class Satellite extends BaseObject { this.tle1 = info.tle1; this.tle2 = info.tle2; - this.sccNum = info.sccNum || tleData.satNum.toString(); + this.sccNum = info.sccNum ?? tleData.satNum.toString(); this.sccNum5 = Tle.convert6DigitToA5(this.sccNum); this.sccNum6 = Tle.convertA5to6Digit(this.sccNum5); + this.intlDes = tleData.intlDes; this.epochYear = tleData.epochYear; this.epochDay = tleData.epochDay; this.meanMoDev1 = tleData.meanMoDev1; this.meanMoDev2 = tleData.meanMoDev2; this.bstar = tleData.bstar; this.inclination = tleData.inclination; - this.raan = tleData.raan; + this.rightAscension = tleData.rightAscension; this.eccentricity = tleData.eccentricity; this.argOfPerigee = tleData.argOfPerigee; this.meanAnomaly = tleData.meanAnomaly; this.meanMotion = tleData.meanMotion; this.period = tleData.period; + this.semiMajorAxis = ((8681663.653 / this.meanMotion) ** (2 / 3)) as Kilometers; + this.semiMinorAxis = (this.semiMajorAxis * Math.sqrt(1 - this.eccentricity ** 2)) as Kilometers; + this.apogee = (this.semiMajorAxis * (1 + this.eccentricity) - 6371) as Kilometers; + this.perigee = (this.semiMajorAxis * (1 - this.eccentricity) - 6371) as Kilometers; // NOTE: Calculate apogee and perigee this.satrec = Sgp4.createSatrec(info.tle1, info.tle2); - this.options = options || { + this.options = options ?? { notes: '', }; } @@ -203,6 +217,10 @@ export class Satellite extends BaseObject { */ eci(date: Date = this.time): PosVel { const { m } = Satellite.calculateTimeVariables(date, this.satrec); + + if (!m) { + throw new Error('Propagation failed!'); + } const pv = Sgp4.propagate(this.satrec, m); if (!pv) { @@ -221,6 +239,10 @@ export class Satellite extends BaseObject { */ getJ2000(date: Date = this.time): J2000 { const { m } = Satellite.calculateTimeVariables(date, this.satrec); + + if (!m) { + throw new Error('Propagation failed!'); + } const pv = Sgp4.propagate(this.satrec, m); if (!pv.position) { @@ -319,7 +341,7 @@ export class Satellite extends BaseObject { private static calculateTimeVariables( date: Date, satrec?: SatelliteRecord, - ): { gmst: GreenwichMeanSiderealTime; m: number; j: number } { + ): { gmst: GreenwichMeanSiderealTime; m: number | null; j: number } { const j = jday( date.getUTCFullYear(), diff --git a/src/observation/RAE.ts b/src/observation/RAE.ts index ccebf08..e661eb2 100644 --- a/src/observation/RAE.ts +++ b/src/observation/RAE.ts @@ -1,8 +1,8 @@ /* eslint-disable no-undefined */ +import { Radians } from '..'; import { ITRF } from '../coordinate/ITRF'; import { J2000 } from '../coordinate/J2000'; import { AngularDistanceMethod } from '../enums/AngularDistanceMethod'; -import { Radians } from '../ootk-core'; import { Vector3D } from '../operations/Vector3D'; import { EpochUTC } from '../time/EpochUTC'; import { DEG2RAD, halfPi, RAD2DEG, TAU } from '../utils/constants'; diff --git a/src/operations/Vector3D.ts b/src/operations/Vector3D.ts index 6bb7cc9..87f560b 100644 --- a/src/operations/Vector3D.ts +++ b/src/operations/Vector3D.ts @@ -1,4 +1,4 @@ -import { linearDistance } from '../ootk-core'; +import { linearDistance } from '..'; import { Matrix } from './Matrix'; import { Vector } from './Vector'; diff --git a/src/sgp4/index.ts b/src/sgp4/index.ts new file mode 100644 index 0000000..b54dc44 --- /dev/null +++ b/src/sgp4/index.ts @@ -0,0 +1 @@ +export { Sgp4 } from './sgp4'; diff --git a/src/sgp4/sgp4.ts b/src/sgp4/sgp4.ts index 2f448bb..5d148c5 100644 --- a/src/sgp4/sgp4.ts +++ b/src/sgp4/sgp4.ts @@ -110,7 +110,7 @@ export enum Sgp4GravConstants { * original baseline * ---------------------------------------------------------------- */ -class Sgp4 { +export class Sgp4 { // Dot /* @@ -238,7 +238,7 @@ class Sgp4 { let year = 0; const satrec = { - a: null, + a: null as number | null, am: null, alta: null, altp: null, @@ -263,7 +263,7 @@ class Sgp4 { em: null, epochdays: null, epochyr: null, - error: null, + error: null as number | null, eta: null, gsto: null, im: null, @@ -285,7 +285,7 @@ class Sgp4 { Om: null, omgcof: null, operationmode: null, - satnum: null, + satnum: null as string | null, sinmao: null, t: null, t2cof: null, @@ -4119,5 +4119,3 @@ class Sgp4 { * Invjday */ } - -export { Sgp4 }; diff --git a/src/transforms/conversions.ts b/src/transforms/conversions.ts index 2792ea9..2edf9c0 100644 --- a/src/transforms/conversions.ts +++ b/src/transforms/conversions.ts @@ -1,4 +1,4 @@ -import { Degrees, Radians } from '../ootk-core'; +import { Degrees, Radians } from '..'; import { DEG2RAD, PI, RAD2DEG } from '../utils/constants'; /** diff --git a/src/transforms/transforms.ts b/src/transforms/transforms.ts index d17fcc6..87d9b20 100644 --- a/src/transforms/transforms.ts +++ b/src/transforms/transforms.ts @@ -28,7 +28,7 @@ * DEALINGS IN THE SOFTWARE. */ -import { Earth, Sensor, Sgp4 } from '../ootk-core'; +import { Earth, Sensor, Sgp4 } from '..'; import { Degrees, EcefVec3, diff --git a/src/types/types.ts b/src/types/types.ts index b769aca..1fc7655 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -514,7 +514,7 @@ export type Line1Data = { * - satNum: The satellite number. * - satNumRaw: The raw string representation of the satellite number. * - inclination: The inclination of the satellite's orbit. - * - raan: The Right Ascension of the Ascending Node. + * - rightAscension: The Right Ascension of the Ascending Node. * - eccentricity: The eccentricity of the satellite's orbit. * - argOfPerigee: The argument of perigee. * - meanAnomaly: The mean anomaly of the satellite. @@ -529,15 +529,15 @@ export type Line2Data = { lineNumber2: number; satNum: number; satNumRaw: string; - inclination: number; - raan: number; + inclination: Degrees; + rightAscension: Degrees; eccentricity: number; - argOfPerigee: number; - meanAnomaly: number; + argOfPerigee: Degrees; + meanAnomaly: Degrees; meanMotion: number; revNum: number; checksum2: number; - period: number; + period: Minutes; }; /** @@ -693,13 +693,13 @@ export type TleData = { meanMoDev1: number; meanMoDev2: number; bstar: number; - inclination: number; - raan: number; + inclination: Degrees; + rightAscension: Degrees; eccentricity: number; - argOfPerigee: number; - meanAnomaly: number; + argOfPerigee: Degrees; + meanAnomaly: Degrees; meanMotion: number; - period: number; + period: Minutes; }; /** * Represents a set of data containing both Line 1 and Line 2 TLE information. diff --git a/test/sat/sat.test.ts b/test/sat/sat.test.ts index c63b32b..161ee6e 100644 --- a/test/sat/sat.test.ts +++ b/test/sat/sat.test.ts @@ -18,7 +18,7 @@ describe('Basic Satellite functionality', () => { expect(sat).toBeDefined(); expect(sat.inclination).toBe(51.6415); - expect(sat.raan).toBe(161.8339); + expect(sat.rightAscension).toBe(161.8339); expect(sat.satrec).toBeDefined(); }); diff --git a/test/tle/tle.test.ts b/test/tle/tle.test.ts index ce1560b..6fc4e4c 100644 --- a/test/tle/tle.test.ts +++ b/test/tle/tle.test.ts @@ -96,7 +96,7 @@ describe('Valid TLEs', () => { }); it('should parse right ascension of ascending node', () => { - expect(Tle.rightAscension(testCase.line2)).toBe(testCase.raan); + expect(Tle.rightAscension(testCase.line2)).toBe(testCase.rightAscension); }); it('should parse eccentricity', () => { @@ -129,7 +129,7 @@ describe('Valid TLEs', () => { satNum: testCase.satNum, satNumRaw: testCase.satNumRaw, inclination: testCase.inclination, - raan: testCase.raan, + rightAscension: testCase.rightAscension, eccentricity: testCase.eccentricity, argOfPerigee: testCase.argOfPerigee, meanAnomaly: testCase.meanAnomaly, @@ -152,7 +152,7 @@ describe('Valid TLEs', () => { meanMoDev2: testCase.meanMoDev2, bstar: testCase.bstar, inclination: testCase.inclination, - raan: testCase.raan, + rightAscension: testCase.rightAscension, eccentricity: testCase.eccentricity, argOfPerigee: testCase.argOfPerigee, meanAnomaly: testCase.meanAnomaly, @@ -183,7 +183,7 @@ describe('Valid TLEs', () => { ephemerisType: testCase.ephemerisType, elsetNum: testCase.elsetNum, inclination: testCase.inclination, - raan: testCase.raan, + rightAscension: testCase.rightAscension, eccentricity: testCase.eccentricity, argOfPerigee: testCase.argOfPerigee, meanAnomaly: testCase.meanAnomaly, diff --git a/test/tle/tleData.ts b/test/tle/tleData.ts index e4e75f6..c9751fa 100644 --- a/test/tle/tleData.ts +++ b/test/tle/tleData.ts @@ -25,7 +25,7 @@ export const tleData = [ satNum2: 25544, satNumRaw2: '25544', inclination: 51.6415, - raan: 161.8339, + rightAscension: 161.8339, eccentricity: 0.0005168, argOfPerigee: 35.9781, meanAnomaly: 54.7009, @@ -58,7 +58,7 @@ export const tleData = [ satNum2: 25544, satNumRaw2: '25544', inclination: 51.6416, - raan: 247.4627, + rightAscension: 247.4627, eccentricity: 0.0006703, argOfPerigee: 130.536, meanAnomaly: 325.0288, @@ -92,7 +92,7 @@ export const tleData = [ satNum2: 900, satNumRaw2: '00900', inclination: 90.1732, - raan: 41.6064, + rightAscension: 41.6064, eccentricity: 0.0024845, argOfPerigee: 267.8011, meanAnomaly: 122.0949, @@ -126,7 +126,7 @@ export const tleData = [ satNum2: 103712, satNumRaw2: 'A3712', inclination: 13.5389, - raan: 14.0082, + rightAscension: 14.0082, eccentricity: 0.0001997, argOfPerigee: 133.0685, meanAnomaly: 227.0577, diff --git a/tsconfig.build.json b/tsconfig.build.json index 8058585..db4cf6a 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -6,12 +6,12 @@ "compilerOptions": { "outDir": "./lib" /* Redirect output structure to the directory. */, "target": "ES2022", - "module": "ES2015", + "module": "ESNext", "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, - "plugins": [{ "transform": "typescript-transform-paths" }] + "plugins": [{ "transform": "typescript-transform-paths" }], + "declaration": true, + "isolatedModules": true }, "include": ["./src/**/*.ts"], - "filesGlob": ["./src/**/*.ts"], - "ignorePatterns": ["./src/sgp4/asc/**/*.ts"], - "exclude": ["./src/sgp4/asc/assembly/index.ts"] + "filesGlob": ["./src/**/*.ts"] } diff --git a/tsconfig.c.json b/tsconfig.c.json new file mode 100644 index 0000000..3c3a77c --- /dev/null +++ b/tsconfig.c.json @@ -0,0 +1,17 @@ +/** + * This is the tsconfig extension that only applies to webpack. + */ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "outDir": "./commonjs" /* Redirect output structure to the directory. */, + "target": "ES2022", + "module": "CommonJS", + "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, + "plugins": [{ "transform": "typescript-transform-paths" }], + "declaration": true, + "isolatedModules": true + }, + "include": ["./src/**/*.ts"], + "filesGlob": ["./src/**/*.ts"] +} diff --git a/tsconfig.json b/tsconfig.json index 55ef227..a874b52 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,8 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "noEmit": true + "noEmit": true, + "strict": true }, "include": ["./src/**/*.ts", "./test/**/*.ts"], "filesGlob": ["./src/**/*.ts", "./test/**/*.ts"],