From 0db4c7baf389238b156ffb395feefb61e3eb651f Mon Sep 17 00:00:00 2001 From: Andre-John Mas Date: Fri, 13 Oct 2023 23:13:18 -0400 Subject: [PATCH] Issue #8 fix altitude display info --- src/hud/index.js | 19 +++++------ src/hud/search-box.js | 1 + src/viewer/index.js | 13 +++++-- src/viewer/sat-groups.js | 73 +--------------------------------------- 4 files changed, 20 insertions(+), 86 deletions(-) diff --git a/src/hud/index.js b/src/hud/index.js index 53dc00b..94a82ca 100644 --- a/src/hud/index.js +++ b/src/hud/index.js @@ -93,13 +93,13 @@ function initGroupsListeners (app) { const target = event.currentTarget; const groupName = target.dataset.group; - app.groups.selectGroup(app.groups.getGroup(groupName)); + app.groups.selectGroup(app.groups.getGroupById(groupName)); }); listItem.addEventListener('mouseout', () => { const selectedGroup = document.querySelector('#groups-display>li.selected'); if (selectedGroup) { - app.groups.selectGroup(app.groups.getGroup(selectedGroup.dataset.group)); + app.groups.selectGroup(app.groups.getGroupById(selectedGroup.dataset.group)); } else { app.groups.selectGroup(undefined); } @@ -129,8 +129,8 @@ function initGroupsListeners (app) { event.stopPropagation(); const satelliteGroups = app.viewer.getSatGroups(); app.viewer.setSelectedSatellite(-1); // clear selected sat - satelliteGroups.selectGroup(satelliteGroups.getGroup(groupName)); - searchBox.fillResultBox(satelliteGroups.getGroup(groupName).sats, ''); + satelliteGroups.selectGroup(satelliteGroups.getGroupById(groupName)); + searchBox.fillResultBox(satelliteGroups.getGroupById(groupName).sats, ''); windowManager.openWindow('search-window'); target.classList.add('selected'); } @@ -172,14 +172,11 @@ function initEventListeners () { setLoading(false); } -function onSatMovementChange () { - const { selectedSat } = app; - if (!selectedSat || selectedSat === -1) { - return; +function onSatMovementChange (event) { + if (event.satId) { + document.querySelector('#sat-altitude').innerHTML = `${event.altitude.toFixed(2)} km`; + document.querySelector('#sat-velocity').innerHTML = `${event.velocity.toFixed(2)} km/s`; } - const satData = app.satSet.getSat(selectedSat); - document.querySelector('#sat-altitude').innerHTML = `${satData.altitude.toFixed(2)} km`; - document.querySelector('#sat-velocity').innerHTML = `${satData.velocity.toFixed(2)} km/s`; } function onSatDataLoaded () { diff --git a/src/hud/search-box.js b/src/hud/search-box.js index e7b55e8..7d1a3a6 100644 --- a/src/hud/search-box.js +++ b/src/hud/search-box.js @@ -151,6 +151,7 @@ function doSearch (str) { const dispGroup = new SatGroup('idList', idList); lastResultGroup = dispGroup; + app.groups.selectGroup(dispGroup); fillResultBox(results, str); diff --git a/src/viewer/index.js b/src/viewer/index.js index c7740f8..bd87f76 100644 --- a/src/viewer/index.js +++ b/src/viewer/index.js @@ -446,8 +446,10 @@ function drawLoop () { const satData = app.satSet.getSat(selectedSat); if (satData) { eventManager.fireEvent(Events.satMovementChange, { - altitude: `${satData.altitude.toFixed(2)} km`, - velocity: `${satData.velocity.toFixed(2)} km/s` + satId: selectedSat, + satellite: satData, + altitude: satData.altitude, + velocity: satData.velocity }); } @@ -642,6 +644,10 @@ function getSatellite (satelliteId) { return satSet.getSat(satelliteId); } +function setSatelliteGroup (satelliteGroup) { + satGroups.selectGroup(satelliteGroup); +} + async function onSatSetLoaded ({ satData }) { app.satData = satData; satGroups.init(app, app.config.satelliteGroups); @@ -705,5 +711,6 @@ export default { getSatSet, setSelectedSatellite, getSelectedSatellite, - getSatellite + getSatellite, + setSatelliteGroup }; diff --git a/src/viewer/sat-groups.js b/src/viewer/sat-groups.js index 67bd02c..5394023 100644 --- a/src/viewer/sat-groups.js +++ b/src/viewer/sat-groups.js @@ -1,76 +1,6 @@ import { defaultColorScheme, groupColorScheme } from './color-scheme'; import SatGroup from './sat-group'; -// const gpSatellites = [ -// '90103A', -// '93068A', -// '96041A', -// '97035A', -// '99055A', -// '00025A', -// '00040A', -// '00071A', -// '01004A', -// '03005A', -// '03010A', -// '03058A', -// '04009A', -// '04023A', -// '04045A', -// '05038A', -// '06042A', -// '06052A', -// '07047A', -// '07062A', -// '08012A', -// '09043A', -// '10022A', -// '11036A', -// '12053A', -// '13023A', -// '14008A', -// '14026A', -// '14045A', -// '14068A', -// '15013A' -// ]; - -// const groupConfigs = [ -// { -// id: 'GPSGroup', name: 'GPS', groupType: 'intlDes', data: gpSatellites -// }, -// { -// id: 'IridiumGroup', name: 'Iridium Debris', groupType: 'nameRegex', data: /IRIDIUM(?!.*DEB)/ -// }, -// { -// id: 'Iridium33DebrisGroup', name: 'Iridium 33 Debris', groupType: 'nameRegex', data: /(COSMOS 2251|IRIDIUM 33) DEB/ -// }, -// { -// id: 'GlonassGroup', name: 'Glonass', groupType: 'nameRegex', data: /GLONASS/ -// }, -// { -// id: 'GalileoGroup', name: 'Galileo', groupType: 'nameRegex', data: /GALILEO/ -// }, -// { -// id: 'FunGroup', name: 'Fun', groupType: 'nameRegex', data: /SYLDA/ -// }, -// { -// id: 'WestfordNeedlesGroup', name: 'Westford Needles', groupType: 'nameRegex', data: /WESTFORD NEEDLES/ -// }, -// { -// id: 'SpaceXGroup', name: 'Space X', groupType: 'nameRegex', data: /FALCON [19]/ -// }, -// { -// id: 'DebrisGroup', name: 'Debris', groupType: 'objectType', data: 'DEBRIS' -// }, -// { -// id: 'Starlink', name: 'Starlink', groupType: 'nameRegex', data: /STARLINK/ -// }, -// { -// id: 'Unknown', name: 'Unknown Objects', groupType: 'objectType', data: 'UNKNOWN' -// } -// ]; - class SatGroups { constructor (appContext) { this.app = appContext; @@ -103,7 +33,7 @@ class SatGroups { this.app.satSet.setColorScheme(defaultColorScheme); } - getGroup (groupId) { + getGroupById (groupId) { return this.groups[groupId]; } @@ -125,7 +55,6 @@ class SatGroups { groupConfigs[i].data ); } - // this.reloadGroups(); } }