Skip to content

Commit

Permalink
refactor: 🚚 organize interfaces and enums
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Jan 11, 2024
1 parent 65a6782 commit 16c336b
Show file tree
Hide file tree
Showing 22 changed files with 116 additions and 102 deletions.
2 changes: 1 addition & 1 deletion src/coordinate/TLE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Earth } from '../body/Earth';
import { Vector3D } from '../operations/Vector3D';
import { Sgp4, Sgp4GravConstants } from '../sgp4/sgp4';
import { EpochUTC } from '../time/EpochUTC';
import { EciVec3, SatelliteRecord, StateVectorSgp4 } from '../types/types';
import { DEG2RAD, RAD2DEG, secondsPerDay, TAU } from '../utils/constants';
import { newtonNu } from '../utils/functions';
import { EciVec3, SatelliteRecord, StateVectorSgp4 } from './../types/types';
import { ClassicalElements } from './ClassicalElements';
import { FormatTle } from './FormatTle';
import { TEME } from './TEME';
Expand Down
7 changes: 7 additions & 0 deletions src/enums/AngularDiameterMethod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Enumeration representing different methods for calculating angular diameter.
*/
export enum AngularDiameterMethod {
Circle,
Sphere,
}
7 changes: 7 additions & 0 deletions src/enums/AngularDistanceMethod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Enumeration representing different methods for calculating angular distance.
*/
export enum AngularDistanceMethod {
Cosine,
Haversine,
}
6 changes: 6 additions & 0 deletions src/enums/PassType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum PassType {
OUT_OF_VIEW = -1,
ENTER = 0,
IN_VIEW = 1,
EXIT = 2,
}
3 changes: 3 additions & 0 deletions src/enums/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { AngularDiameterMethod } from './AngularDiameterMethod';
export { AngularDistanceMethod } from './AngularDistanceMethod';
export { PassType } from './PassType';
11 changes: 11 additions & 0 deletions src/interfaces/BaseObjectParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { EciVec3, SpaceObjectType } from '../types/types';

export interface BaseObjectParams {
id?: number;
name?: string;
type?: SpaceObjectType;
position?: EciVec3;
velocity?: EciVec3;
time?: Date;
active?: boolean;
}
2 changes: 1 addition & 1 deletion src/interfaces/GroundPositionParams.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Degrees, Kilometers } from './../types/types';
import { Degrees, Kilometers } from '../types/types';

export interface GroundPositionParams {
name?: string;
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/OptionsParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface OptionsParams {
notes: string;
}
22 changes: 22 additions & 0 deletions src/interfaces/SatelliteParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { EciVec3, SpaceObjectType, TleLine1, TleLine2 } from '../types/types';

/**
* TODO: Reduce unnecessary calls to calculateTimeVariables using optional
* parameters and caching.
*/
/**
* Information about a space object.
*/

export interface SatelliteParams {
name?: string;
rcs?: number;
tle1: TleLine1;
tle2: TleLine2;
type?: SpaceObjectType;
vmag?: number;
sccNum?: string;
intlDes?: string;
position?: EciVec3;
time?: Date;
}
21 changes: 21 additions & 0 deletions src/interfaces/SensorParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Degrees, Kilometers, SpaceObjectType } from '../types/types';

export interface SensorParams {
alt: Kilometers;
lat: Degrees;
lon: Degrees;
maxAz: Degrees;
maxAz2?: Degrees;
maxEl: Degrees;
maxEl2?: Degrees;
maxRng: Kilometers;
maxRng2?: Kilometers;
minAz: Degrees;
minAz2?: Degrees;
minEl: Degrees;
minEl2?: Degrees;
minRng: Kilometers;
minRng2?: Kilometers;
name?: string;
type?: SpaceObjectType;
}
11 changes: 11 additions & 0 deletions src/interfaces/StarObjectParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Radians } from '../types/types';

export interface StarObjectParams {
ra: Radians;
dec: Radians;
bf?: string;
h?: string;
name?: string;
pname?: string;
vmag?: number;
}
6 changes: 6 additions & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +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';
3 changes: 2 additions & 1 deletion src/objects/BaseObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
* DEALINGS IN THE SOFTWARE.
*/

import { BaseObjectParams, EciVec3, Kilometers, SpaceObjectType } from '../types/types';
import { BaseObjectParams } from 'src/interfaces/BaseObjectParams';
import { EciVec3, Kilometers, SpaceObjectType } from '../types/types';

export class BaseObject {
id: number; // Unique ID
Expand Down
4 changes: 2 additions & 2 deletions src/objects/Satellite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ import { dopplerFactor } from './../utils/functions';
* SOFTWARE.
*/

import { OptionsParams } from 'src/interfaces/OptionsParams';
import { SatelliteParams } from 'src/interfaces/SatelliteParams';
import {
Degrees,
EcfVec3,
EciVec3,
GreenwichMeanSiderealTime,
Kilometers,
LlaVec3,
OptionsParams,
PosVel,
Radians,
RaeVec3,
SatelliteParams,
SatelliteRecord,
SpaceObjectType,
TleLine1,
Expand Down
4 changes: 3 additions & 1 deletion src/objects/Sensor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Degrees, Kilometers, Lookangle, PassType, RaeVec3, SensorParams, SpaceObjectType } from '../types/types';
import { SensorParams } from 'src/interfaces/SensorParams';
import { PassType } from '../enums/PassType';
import { Degrees, Kilometers, Lookangle, RaeVec3, SpaceObjectType } from '../types/types';

import { GroundPosition } from './GroundPosition';
import { Satellite } from './Satellite';
Expand Down
2 changes: 1 addition & 1 deletion src/objects/Star.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* DEALINGS IN THE SOFTWARE.
*/

import { StarObjectParams } from 'src/interfaces/StarObjectParams';
import {
Degrees,
EciVec3,
Expand All @@ -35,7 +36,6 @@ import {
Radians,
RaeVec3,
SpaceObjectType,
StarObjectParams,
} from '../types/types';
import { MILLISECONDS_TO_DAYS } from '../utils/constants';

Expand Down
2 changes: 1 addition & 1 deletion src/observation/RAE.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable no-undefined */
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 { AngularDistanceMethod } from '../types/types';
import { DEG2RAD, halfPi, RAD2DEG, TAU } from '../utils/constants';
import { angularDistance } from '../utils/functions';

Expand Down
2 changes: 1 addition & 1 deletion src/observation/RadecGeocentric.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-undefined */
import { J2000 } from '../coordinate/J2000';
import { AngularDistanceMethod } from '../enums/AngularDistanceMethod';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { AngularDistanceMethod } from '../types/types';
import { DEG2RAD, RAD2DEG, TAU } from '../utils/constants';
import { angularDistance } from '../utils/functions';
import { radecToPosition, radecToVelocity } from './ObservationUtils';
Expand Down
2 changes: 1 addition & 1 deletion src/observation/RadecTopocentric.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-undefined */
import { J2000 } from '../coordinate/J2000';
import { AngularDistanceMethod } from '../enums/AngularDistanceMethod';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { AngularDistanceMethod } from '../types/types';
import { DEG2RAD, RAD2DEG, TAU } from '../utils/constants';
import { angularDistance } from '../utils/functions';
import { radecToPosition, radecToVelocity } from './ObservationUtils';
Expand Down
2 changes: 2 additions & 0 deletions src/ootk-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
export * from './body';
export * from './coordinate';
export * from './data/DataHandler';
export * from './enums';
export * from './interfaces';
export * from './objects';
export * from './observation';
export * from './operations/operations';
Expand Down
83 changes: 1 addition & 82 deletions src/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PassType } from '../enums/PassType';
import { Sensor } from '../objects';

/**
Expand Down Expand Up @@ -657,22 +658,6 @@ export type OperationsDetails = {
owner?: string;
country?: string;
};
/**
* Enumeration representing different methods for calculating angular diameter.
*/

export enum AngularDiameterMethod {
Circle,
Sphere,
}
/**
* Enumeration representing different methods for calculating angular distance.
*/

export enum AngularDistanceMethod {
Cosine,
Haversine,
}
/**
* Represents a function that calculates the Jacobian matrix.
* @param xs - The input values as a Float64Array.
Expand All @@ -687,72 +672,6 @@ export type JacobianFunction = (xs: Float64Array) => Float64Array;

export type DifferentiableFunction = (x: number) => number;

/**
* TODO: Reduce unnecessary calls to calculateTimeVariables using optional
* parameters and caching.
*/
/**
* Information about a space object.
*/
export interface SatelliteParams {
name?: string;
rcs?: number;
tle1: TleLine1;
tle2: TleLine2;
type?: SpaceObjectType;
vmag?: number;
sccNum?: string;
intlDes?: string;
position?: EciVec3;
time?: Date;
}
export interface OptionsParams {
notes: string;
}
export interface BaseObjectParams {
id?: number;
name?: string;
type?: SpaceObjectType;
position?: EciVec3;
velocity?: EciVec3;
time?: Date;
active?: boolean;
}
export interface StarObjectParams {
ra: Radians;
dec: Radians;
bf?: string;
h?: string;
name?: string;
pname?: string;
vmag?: number;
}
export interface SensorParams {
alt: Kilometers;
lat: Degrees;
lon: Degrees;
maxAz: Degrees;
maxAz2?: Degrees;
maxEl: Degrees;
maxEl2?: Degrees;
maxRng: Kilometers;
maxRng2?: Kilometers;
minAz: Degrees;
minAz2?: Degrees;
minEl: Degrees;
minEl2?: Degrees;
minRng: Kilometers;
minRng2?: Kilometers;
name?: string;
type?: SpaceObjectType;
}
export enum PassType {
OUT_OF_VIEW = -1,
ENTER = 0,
IN_VIEW = 1,
EXIT = 2,
}

export type Lookangle = {
type: PassType;
time: Date;
Expand Down
13 changes: 3 additions & 10 deletions src/utils/functions.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
/* eslint-disable require-jsdoc */
/* eslint-disable func-style */
import { AngularDiameterMethod } from '../enums/AngularDiameterMethod';
import { AngularDistanceMethod } from '../enums/AngularDistanceMethod';
import { Matrix } from '../operations/Matrix';
import { Vector } from '../operations/Vector';
import {
AngularDiameterMethod,
AngularDistanceMethod,
DifferentiableFunction,
EciVec3,
JacobianFunction,
Radians,
SpaceObjectType,
Vec3,
} from '../types/types';
import { DifferentiableFunction, EciVec3, JacobianFunction, Radians, SpaceObjectType, Vec3 } from '../types/types';

/**
* Calculates the factorial of a given number.
Expand Down

0 comments on commit 16c336b

Please sign in to comment.