Skip to content

Commit

Permalink
refactor: ♻️ add default id
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Feb 19, 2024
1 parent ae8fa2a commit eae7a33
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/objects/BaseObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { BaseObjectParams } from '../interfaces/BaseObjectParams';
import { EciVec3, Kilometers, SpaceObjectType } from '../types/types';

export class BaseObject {
id?: number; // Unique ID
id: number;
name: string;
type: SpaceObjectType;
position: EciVec3; // Where is the object
Expand All @@ -36,7 +36,7 @@ export class BaseObject {
constructor(info: BaseObjectParams) {
this.type = info.type ?? SpaceObjectType.UNKNOWN;
this.name = info.name ?? 'Unknown';
this.id = info.id;
this.id = info.id ?? -1; // Default to -1 if no id is provided
this.active = info.active ?? true;

// Default to the center of the earth until position is calculated
Expand Down
2 changes: 1 addition & 1 deletion test/objects/__snapshots__/GroundObject.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports[`GroundObject should create from geodetic 1`] = `
GroundObject {
"active": true,
"alt": 0,
"id": undefined,
"id": -1,
"lat": 0,
"lon": 0,
"name": "Unknown Ground Object",
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 @@ -101,7 +101,7 @@ Satellite {
"eccentricity": 0.0005168,
"epochDay": 203.46960946,
"epochYear": 22,
"id": undefined,
"id": -1,
"inclination": 51.6415,
"intlDes": "98067A",
"meanAnomaly": 54.7009,
Expand Down

0 comments on commit eae7a33

Please sign in to comment.