Skip to content

Commit 46754a6

Browse files
committed
feat: implement TOCA/POCA plugin for satellite closest approach calculations
1 parent e135394 commit 46754a6

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

src/plugins/keeptrack-plugins-configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type KeepTrackPluginsConfiguration = {
6262
NextLaunchesPlugin?: PluginConfiguration;
6363
OrbitReferences?: PluginConfiguration;
6464
SatellitePhotos?: PluginConfiguration;
65-
SatelliteSelection?: PluginConfiguration;
65+
TocaPocaPlugin?: PluginConfiguration;
6666
Planetarium?: PluginConfiguration;
6767
EciPlot?: PluginConfiguration;
6868
EcfPlot?: PluginConfiguration;

src/plugins/plugins.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ import { SatInfoBoxSensor } from './sat-info-box-sensor/sat-info-box-sensor';
5555
import { SatInfoBox } from './sat-info-box/sat-info-box';
5656
import { SatelliteFov } from './satellite-fov/satellite-fov';
5757
import { SatellitePhotos } from './satellite-photos/satellite-photos';
58-
import { SatelliteSelection } from './satellite-selection/satellite-selection';
5958
import { ScenarioManagementPlugin } from './scenario-management/scenario-management';
6059
import { ScreenRecorder } from './screen-recorder/screen-recorder';
6160
import { Screenshot } from './screenshot/screenshot';
@@ -74,6 +73,7 @@ import { TimeMachine } from './time-machine/time-machine';
7473
import { TimeSlider } from './time-slider/time-slider';
7574
import { SatelliteTimeline } from './timeline-satellite/satellite-timeline';
7675
import { SensorTimeline } from './timeline-sensor/sensor-timeline';
76+
import { TocaPocaPlugin } from './toca-poca-plugin/toca-poca-plugin';
7777
import { TooltipsPlugin } from './tooltips/tooltips';
7878
import { TrackingImpactPredict } from './tracking-impact-predict/tracking-impact-predict';
7979
import { TransponderChannelData } from './transponder-channel-data/transponder-channel-data';
@@ -188,7 +188,7 @@ export class PluginManager {
188188
{ init: () => new ProximityOps().init(), config: plugins.ProximityOps },
189189
{ init: () => new OrbitReferences().init(), config: plugins.OrbitReferences },
190190
{ init: () => new Collisions().init(), config: plugins.Collisions },
191-
{ init: () => new SatelliteSelection().init(), config: plugins.SatelliteSelection },
191+
{ init: () => new TocaPocaPlugin().init(), config: plugins.TocaPocaPlugin },
192192
{ init: () => new OrbitGuardMenuPlugin().init(), config: plugins.OrbitGuardMenuPlugin },
193193
{ init: () => new TrackingImpactPredict().init(), config: plugins.TrackingImpactPredict },
194194
{ init: () => new Breakup().init(), config: plugins.Breakup },

src/plugins/satellite-selection/satellite-selection.ts renamed to src/plugins/toca-poca-plugin/toca-poca-plugin.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,22 @@
2121
* /////////////////////////////////////////////////////////////////////////////
2222
*/
2323

24+
import { OemSatellite } from '@app/app/objects/oem-satellite';
2425
import { MenuMode } from '@app/engine/core/interfaces';
2526
import { PluginRegistry } from '@app/engine/core/plugin-registry';
2627
import { ServiceLocator } from '@app/engine/core/service-locator';
2728
import { EventBus } from '@app/engine/events/event-bus';
2829
import { EventBusEvent } from '@app/engine/events/event-bus-events';
30+
import { dateFormat } from '@app/engine/utils/dateFormat';
2931
import { html } from '@app/engine/utils/development/formatter';
3032
import { errorManagerInstance } from '@app/engine/utils/errorManager';
3133
import { getEl } from '@app/engine/utils/get-el';
3234
import { showLoading } from '@app/engine/utils/showLoading';
33-
import { dateFormat } from '@app/engine/utils/dateFormat';
34-
import { DetailedSatellite, EciVec3, Kilometers, RIC } from '@ootk/src/main';
35+
import { BaseObject, DetailedSatellite, EciVec3, Kilometers, RIC } from '@ootk/src/main';
36+
import SatelliteSelectionPng from '@public/img/icons/satellite-selection.png';
3537
import { ClickDragOptions, KeepTrackPlugin } from '../../engine/plugins/base-plugin';
3638
import { SelectSatManager } from '../select-sat-manager/select-sat-manager';
37-
import SatelliteSelectionPng from '@public/img/icons/satellite-selection.png';
38-
import './satellite-selection.css';
39+
import './toca-poca-plugin.css';
3940

4041
export interface TocaPocaEvent {
4142
time: Date;
@@ -46,8 +47,8 @@ export interface TocaPocaEvent {
4647
relativeVelocity: number;
4748
}
4849

49-
export class SatelliteSelection extends KeepTrackPlugin {
50-
readonly id = 'SatelliteSelection';
50+
export class TocaPocaPlugin extends KeepTrackPlugin {
51+
readonly id = 'TocaPocaPlugin';
5152
dependencies_ = [SelectSatManager.name];
5253

5354
private selectSatManager_: SelectSatManager;
@@ -56,6 +57,8 @@ export class SatelliteSelection extends KeepTrackPlugin {
5657
private tocaPocaList_: TocaPocaEvent[] = [];
5758
private selectSatIdOnCruncher_: number | null = null;
5859

60+
menuMode: MenuMode[] = [MenuMode.EXPERIMENTAL, MenuMode.ALL];
61+
5962
// Configuration
6063
private readonly propagationDays_ = 7; // Look ahead 7 days
6164
private readonly timeStep_ = 60; // 60 second intervals
@@ -88,8 +91,6 @@ export class SatelliteSelection extends KeepTrackPlugin {
8891
maxWidth: 800,
8992
};
9093

91-
menuMode: MenuMode[] = [MenuMode.BASIC, MenuMode.ADVANCED, MenuMode.ALL];
92-
9394
constructor() {
9495
super();
9596
this.selectSatManager_ = PluginRegistry.getPlugin(SelectSatManager) as unknown as SelectSatManager;
@@ -109,8 +110,8 @@ export class SatelliteSelection extends KeepTrackPlugin {
109110

110111
EventBus.getInstance().on(EventBusEvent.uiManagerFinal, this.uiManagerFinal_.bind(this));
111112

112-
EventBus.getInstance().on(EventBusEvent.selectSatData, (sat: DetailedSatellite) => {
113-
if (sat.isSatellite()) {
113+
EventBus.getInstance().on(EventBusEvent.selectSatData, (sat: DetailedSatellite | BaseObject | OemSatellite) => {
114+
if (sat instanceof DetailedSatellite) {
114115
this.primarySatellite_ = sat;
115116
if (this.isMenuButtonActive) {
116117
this.updateSatelliteInfo_();
@@ -153,6 +154,7 @@ export class SatelliteSelection extends KeepTrackPlugin {
153154

154155
if (!selectedSat || !selectedSat.isSatellite()) {
155156
errorManagerInstance.warn('Please select a satellite first!');
157+
156158
return;
157159
}
158160

@@ -207,11 +209,12 @@ export class SatelliteSelection extends KeepTrackPlugin {
207209
private calculateTocaPoca_() {
208210
if (!this.primarySatellite_ || !this.targetSatellite_) {
209211
errorManagerInstance.warn('Please select both a primary and target satellite!');
212+
210213
return;
211214
}
212215

213216
try {
214-
const events: TocaPocaEvent[] = [];
217+
// const events: TocaPocaEvent[] = [];
215218
const timeManagerInstance = ServiceLocator.getTimeManager();
216219
const propagationSeconds = this.propagationDays_ * 24 * 60 * 60;
217220

@@ -245,7 +248,7 @@ export class SatelliteSelection extends KeepTrackPlugin {
245248
sat1Position: sat1J2000.position,
246249
sat2Position: sat2J2000.position,
247250
relativeVelocity: Math.sqrt(
248-
ric.velocity.x ** 2 + ric.velocity.y ** 2 + ric.velocity.z ** 2
251+
ric.velocity.x ** 2 + ric.velocity.y ** 2 + ric.velocity.z ** 2,
249252
),
250253
});
251254
}
@@ -271,14 +274,15 @@ export class SatelliteSelection extends KeepTrackPlugin {
271274
this.createTable_();
272275
}
273276
} catch (error) {
274-
errorManagerInstance.error(`Error calculating TOCA/POCA: ${error}`, 'satellite-selection.ts');
277+
errorManagerInstance.error(error, 'satellite-selection.ts', `Error calculating TOCA/POCA: ${error}`);
275278
this.clearTable_();
276279
}
277280
}
278281

279282
private createTable_(): void {
280283
try {
281284
const tbl = <HTMLTableElement>getEl(`${this.id}-table`);
285+
282286
tbl.innerHTML = '';
283287

284288
this.createHeaders_(tbl);
@@ -290,6 +294,7 @@ export class SatelliteSelection extends KeepTrackPlugin {
290294

291295
private clearTable_(): void {
292296
const tbl = <HTMLTableElement>getEl(`${this.id}-table`);
297+
293298
tbl.innerHTML = '';
294299
}
295300

@@ -299,6 +304,7 @@ export class SatelliteSelection extends KeepTrackPlugin {
299304

300305
for (const name of names) {
301306
const column = tr.insertCell();
307+
302308
column.appendChild(document.createTextNode(name));
303309
column.setAttribute('style', 'text-decoration: underline; font-weight: bold;');
304310
}
@@ -338,6 +344,7 @@ export class SatelliteSelection extends KeepTrackPlugin {
338344

339345
private createCell_(tr: HTMLTableRowElement, text: string): void {
340346
const cell = tr.insertCell();
347+
341348
cell.appendChild(document.createTextNode(text));
342349
}
343350
}

src/settings/default-plugins.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ export const defaultPlugins = <KeepTrackPluginsConfiguration>{
108108
enabled: true,
109109
order: 81,
110110
},
111+
TocaPocaPlugin: {
112+
enabled: true,
113+
order: 82,
114+
},
111115
Collisions: {
112116
enabled: true,
113117
order: 90,

0 commit comments

Comments
 (0)