-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ readd previous classes to provide incremental migration
- Loading branch information
Showing
33 changed files
with
1,488 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* @author @thkruz Theodore Kruczek | ||
* @license AGPL-3.0-or-later | ||
* @copyright (c) 2020-2024 Theodore Kruczek | ||
* | ||
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the | ||
* terms of the GNU Affero General Public License as published by the Free Software | ||
* Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along with | ||
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { EciVec3, SpaceObjectType } from '../types/types.js'; | ||
|
||
export interface BaseObjectParams { | ||
id?: number; | ||
name?: string; | ||
type?: SpaceObjectType; | ||
position?: EciVec3; | ||
velocity?: EciVec3; | ||
active?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @author Theodore Kruczek. | ||
* @license AGPL-3.0-or-later | ||
* @copyright (c) 2022-2024 Theodore Kruczek Permission is | ||
* hereby granted, free of charge, to any person obtaining a copy of this | ||
* software and associated documentation files (the "Software"), to deal in the | ||
* Software without restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
* the Software, and to permit persons to whom the Software is furnished to do | ||
* so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import { Degrees, DetailedSensorParams } from '../types/types.js'; | ||
|
||
export interface RfSensorParams extends DetailedSensorParams { | ||
/** The azimuth angles at boresight of the sensor */ | ||
boresightAz: Degrees[]; | ||
/** The elevation angles at boresight of the sensor */ | ||
boresightEl: Degrees[]; | ||
/** The width of the beam */ | ||
beamwidth: Degrees; | ||
/** The frequency this sensor operate in */ | ||
freqBand?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { EciVec3, SpaceObjectType, TleLine1, TleLine2 } from '../types/types.js'; | ||
|
||
/** | ||
* Information about a space object. | ||
*/ | ||
|
||
export interface SatelliteParams { | ||
name?: string; | ||
rcs?: number | null; | ||
tle1: TleLine1; | ||
tle2: TleLine2; | ||
type?: SpaceObjectType; | ||
vmag?: number | null; | ||
sccNum?: string; | ||
intlDes?: string; | ||
position?: EciVec3; | ||
time?: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Degrees, Kilometers, SpaceObjectType } from '../types/types.js'; | ||
import { BaseObjectParams } from './BaseObjectParams.js'; | ||
|
||
export interface SensorParams extends BaseObjectParams{ | ||
/** Altitude in Kilometers */ | ||
alt: Kilometers; | ||
/** Latitude in Degrees */ | ||
lat: Degrees; | ||
/** Longitude in Degrees */ | ||
lon: Degrees; | ||
/** Maximum Azimuth in Degrees */ | ||
maxAz: Degrees; | ||
/** Secondary Maximum Azimuth in Degrees */ | ||
maxAz2?: Degrees; | ||
/** Maximum Elevation in Degrees */ | ||
maxEl: Degrees; | ||
/** Secondary Maximum Elevation in Degrees */ | ||
maxEl2?: Degrees; | ||
/** Maximum Range in Kilometers */ | ||
maxRng: Kilometers; | ||
/** Secondary Maximum Range in Kilometers */ | ||
maxRng2?: Kilometers; | ||
/** Minimum Azimuth in Degrees */ | ||
minAz: Degrees; | ||
/** Secondary Minimum Azimuth in Degrees */ | ||
minAz2?: Degrees; | ||
/** Minimum Elevation in Degrees */ | ||
minEl: Degrees; | ||
/** Secondary Minimum Elevation in Degrees */ | ||
minEl2?: Degrees; | ||
/** Minimum Range in Kilometers */ | ||
minRng: Kilometers; | ||
/** Secondary Minimum Range in Kilometers */ | ||
minRng2?: Kilometers; | ||
/** Name as a string */ | ||
name?: string; | ||
/** Type of sensor */ | ||
type?: SpaceObjectType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/** | ||
* @author @thkruz Theodore Kruczek | ||
* @license AGPL-3.0-or-later | ||
* @copyright (c) 2020-2024 Theodore Kruczek | ||
* | ||
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the | ||
* terms of the GNU Affero General Public License as published by the Free Software | ||
* Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along with | ||
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { BaseObjectParams } from '../interfaces/BaseObjectParams.js'; | ||
import { EciVec3, Kilometers, SpaceObjectType } from '../types/types.js'; | ||
|
||
export class BaseObject { | ||
id: number; | ||
name: string; | ||
type: SpaceObjectType; | ||
position: EciVec3; // Where is the object | ||
totalVelocity: number; // How fast is the object moving | ||
velocity: EciVec3; // How fast is the object moving | ||
active = true; // Is the object active | ||
|
||
constructor(info: BaseObjectParams) { | ||
this.type = info.type ?? SpaceObjectType.UNKNOWN; | ||
this.name = info.name ?? 'Unknown'; | ||
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 | ||
this.position = info.position ?? { | ||
x: <Kilometers>0, | ||
y: <Kilometers>0, | ||
z: <Kilometers>0, | ||
}; | ||
|
||
// Default to 0 velocity until velocity is calculated | ||
this.velocity = info.velocity ?? { | ||
x: <Kilometers>0, | ||
y: <Kilometers>0, | ||
z: <Kilometers>0, | ||
}; | ||
this.totalVelocity = Math.sqrt(this.velocity.x ** 2 + this.velocity.y ** 2 + this.velocity.z ** 2); | ||
} | ||
|
||
/** | ||
* Checks if the object is a satellite. | ||
* @returns True if the object is a satellite, false otherwise. | ||
*/ | ||
isSatellite(): boolean { | ||
return false; | ||
} | ||
|
||
/** | ||
* Checks if the object is a ground object. | ||
* @returns True if the object is a ground object, false otherwise. | ||
*/ | ||
isGroundObject(): boolean { | ||
return false; | ||
} | ||
|
||
/** | ||
* Returns whether the object is a sensor. | ||
* @returns True if the object is a sensor, false otherwise. | ||
*/ | ||
isSensor(): boolean { | ||
return false; | ||
} | ||
|
||
/** | ||
* Checks if the object is a marker. | ||
* @returns True if the object is a marker, false otherwise. | ||
*/ | ||
isMarker(): boolean { | ||
return false; | ||
} | ||
|
||
/** | ||
* Returns whether the object's position is static. | ||
* @returns True if the object is static, false otherwise. | ||
*/ | ||
isStatic(): boolean { | ||
return this.velocity.x === 0 && this.velocity.y === 0 && this.velocity.z === 0; | ||
} | ||
|
||
isPayload(): boolean { | ||
return this.type === SpaceObjectType.PAYLOAD; | ||
} | ||
|
||
isRocketBody(): boolean { | ||
return this.type === SpaceObjectType.ROCKET_BODY; | ||
} | ||
|
||
isDebris(): boolean { | ||
return this.type === SpaceObjectType.DEBRIS; | ||
} | ||
|
||
isStar(): boolean { | ||
return this.type === SpaceObjectType.STAR; | ||
} | ||
|
||
isMissile(): boolean { | ||
return this.type === SpaceObjectType.BALLISTIC_MISSILE; | ||
} | ||
|
||
isNotional(): boolean { | ||
return this.type === SpaceObjectType.NOTIONAL; | ||
} | ||
|
||
getTypeString(): string { | ||
const typeToStringMap: { [key in SpaceObjectType]?: string } = { | ||
[SpaceObjectType.UNKNOWN]: 'Unknown', | ||
[SpaceObjectType.PAYLOAD]: 'Payload', | ||
[SpaceObjectType.ROCKET_BODY]: 'Rocket Body', | ||
[SpaceObjectType.DEBRIS]: 'Debris', | ||
[SpaceObjectType.SPECIAL]: 'Special', | ||
[SpaceObjectType.BALLISTIC_MISSILE]: 'Ballistic Missile', | ||
[SpaceObjectType.STAR]: 'Star', | ||
[SpaceObjectType.INTERGOVERNMENTAL_ORGANIZATION]: 'Intergovernmental Organization', | ||
[SpaceObjectType.SUBORBITAL_PAYLOAD_OPERATOR]: 'Suborbital Payload Operator', | ||
[SpaceObjectType.PAYLOAD_OWNER]: 'Payload Owner', | ||
[SpaceObjectType.METEOROLOGICAL_ROCKET_LAUNCH_AGENCY_OR_MANUFACTURER]: | ||
'Meteorological Rocket Launch Agency or Manufacturer', | ||
[SpaceObjectType.PAYLOAD_MANUFACTURER]: 'Payload Manufacturer', | ||
[SpaceObjectType.LAUNCH_AGENCY]: 'Launch Agency', | ||
[SpaceObjectType.LAUNCH_SITE]: 'Launch Site', | ||
[SpaceObjectType.LAUNCH_POSITION]: 'Launch Position', | ||
[SpaceObjectType.LAUNCH_FACILITY]: 'Launch Facility', | ||
[SpaceObjectType.CONTROL_FACILITY]: 'Control Facility', | ||
[SpaceObjectType.GROUND_SENSOR_STATION]: 'Ground Sensor Station', | ||
[SpaceObjectType.OPTICAL]: 'Optical', | ||
[SpaceObjectType.MECHANICAL]: 'Mechanical', | ||
[SpaceObjectType.PHASED_ARRAY_RADAR]: 'Phased Array Radar', | ||
[SpaceObjectType.OBSERVER]: 'Observer', | ||
[SpaceObjectType.BISTATIC_RADIO_TELESCOPE]: 'Bistatic Radio Telescope', | ||
[SpaceObjectType.COUNTRY]: 'Country', | ||
[SpaceObjectType.LAUNCH_VEHICLE_MANUFACTURER]: 'Launch Vehicle Manufacturer', | ||
[SpaceObjectType.ENGINE_MANUFACTURER]: 'Engine Manufacturer', | ||
}; | ||
|
||
return typeToStringMap[this.type] ?? 'Unknown'; | ||
} | ||
|
||
/** | ||
* Validates a parameter value against a minimum and maximum value. | ||
* @param value - The value to be validated. | ||
* @param minValue - The minimum allowed value. | ||
* @param maxValue - The maximum allowed value. | ||
* @param errorMessage - The error message to be thrown if the value is invalid. | ||
*/ | ||
validateParameter<T>(value: T, minValue: T, maxValue: T, errorMessage: string): void { | ||
if (typeof minValue !== 'undefined' && minValue !== null && (value as number) < (minValue as number)) { | ||
throw new Error(errorMessage); | ||
} | ||
if (typeof maxValue !== 'undefined' && maxValue !== null && (value as number) > (maxValue as number)) { | ||
throw new Error(errorMessage); | ||
} | ||
} | ||
} |
Oops, something went wrong.