Skip to content

Commit

Permalink
feat: ✨ add space objects, sunMath, and moonMath
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Jul 27, 2022
1 parent e52fa7f commit e7e9fc3
Show file tree
Hide file tree
Showing 32 changed files with 1,292 additions and 106 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"brace-style": "error",
"callback-return": "error",
"camelcase": "error",
"capitalized-comments": "error",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
Expand Down Expand Up @@ -69,14 +69,14 @@
"linebreak-style": ["error", "unix"],
"lines-around-comment": "off",
"lines-around-directive": "error",
"lines-between-class-members": "error",
"lines-between-class-members": "off",
"max-classes-per-file": "error",
"max-depth": "error",
"max-len": ["error", { "code": 120 }],
"max-lines": ["error", { "max": 1000 }],
"max-lines-per-function": ["error", { "max": 300 }],
"max-nested-callbacks": "error",
"max-params": "error",
"max-params": ["error", { "max": 5 }],
"max-statements": ["error", { "max": 25 }],
"max-statements-per-line": "error",
"multiline-comment-style": "error",
Expand All @@ -85,7 +85,7 @@
"new-parens": "error",
"newline-after-var": "error",
"newline-before-return": "error",
"newline-per-chained-call": "error",
"newline-per-chained-call": "off",
"no-alert": "error",
"no-array-constructor": "error",
"no-await-in-loop": "error",
Expand Down
141 changes: 108 additions & 33 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"eslint": "^7.9.0",
"jest": "^26.4.2",
"node-fetch": "^2.6.7",
"prettier": "^2.7.1",
"typescript": "^4.1.3",
"webpack": "^5.11.1",
"webpack-cli": "^4.10.0"
Expand Down
102 changes: 102 additions & 0 deletions src/objects/base-object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { EciVec3, SpaceObjectType } from '../types/types';

interface ObjectInfo {
name?: string;
type?: SpaceObjectType;
position?: EciVec3;
time?: Date;
}

export class BaseObject {
public name: string;
public type: SpaceObjectType;
public position: EciVec3; // Where is the object
public time: Date; // When is the object

constructor(info: ObjectInfo) {
this.type = info.type || SpaceObjectType.UNKNOWN;
this.name = info.name || 'Unknown';

this.position = info.position || {
x: 0,
y: 0,
z: 0,
}; // Default to the center of the earth until position is calculated

this.time = info.time || new Date();
}

public getName(): string {
return this.name;
}

public getType(): SpaceObjectType {
return this.type;
}

// eslint-disable-next-line complexity
public getTypeString(): string {
switch (this.type) {
case SpaceObjectType.UNKNOWN:
return 'Unknown';
case SpaceObjectType.PAYLOAD:
return 'Payload';
case SpaceObjectType.ROCKET_BODY:
return 'Rocket Body';
case SpaceObjectType.DEBRIS:
return 'Debris';
case SpaceObjectType.SPECIAL:
return 'Special';
case SpaceObjectType.RADAR_MEASUREMENT:
return 'Radar Measurement';
case SpaceObjectType.RADAR_TRACK:
return 'Radar Track';
case SpaceObjectType.RADAR_OBJECT:
return 'Radar Object';
case SpaceObjectType.BALLISTIC_MISSILE:
return 'Ballistic Missile';
case SpaceObjectType.STAR:
return 'Star';
case SpaceObjectType.INTERGOVERNMENTAL_ORGANIZATION:
return 'Intergovernmental Organization';
case SpaceObjectType.SUBORBITAL_PAYLOAD_OPERATOR:
return 'Suborbital Payload Operator';
case SpaceObjectType.PAYLOAD_OWNER:
return 'Payload Owner';
case SpaceObjectType.METEOROLOGICAL_ROCKET_LAUNCH_AGENCY_OR_MANUFACTURER:
return 'Meteorological Rocket Launch Agency or Manufacturer';
case SpaceObjectType.PAYLOAD_MANUFACTURER:
return 'Payload Manufacturer';
case SpaceObjectType.LAUNCH_AGENCY:
return 'Launch Agency';
case SpaceObjectType.LAUNCH_SITE:
return 'Launch Site';
case SpaceObjectType.LAUNCH_POSITION:
return 'Launch Position';
case SpaceObjectType.LAUNCH_FACILITY:
return 'Launch Facility';
case SpaceObjectType.CONTROL_FACILITY:
return 'Control Facility';
case SpaceObjectType.GROUND_SENSOR_STATION:
return 'Ground Sensor Station';
case SpaceObjectType.OPTICAL:
return 'Optical';
case SpaceObjectType.MECHANICAL:
return 'Mechanical';
case SpaceObjectType.PHASED_ARRAY_RADAR:
return 'Phased Array Radar';
case SpaceObjectType.OBSERVER:
return 'Observer';
case SpaceObjectType.BISTATIC_RADIO_TELESCOPE:
return 'Bistatic Radio Telescope';
case SpaceObjectType.COUNTRY:
return 'Country';
case SpaceObjectType.LAUNCH_VEHICLE_MANUFACTURER:
return 'Launch Vehicle Manufacturer';
case SpaceObjectType.ENGINE_MANUFACTURER:
return 'Engine Manufacturer';
default:
return 'Unknown';
}
}
}
Loading

0 comments on commit e7e9fc3

Please sign in to comment.