Skip to content

Commit

Permalink
Issue #8 fix altitude display info
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmas committed Oct 14, 2023
1 parent a7929a0 commit 0db4c7b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 86 deletions.
19 changes: 8 additions & 11 deletions src/hud/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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 () {
Expand Down
1 change: 1 addition & 0 deletions src/hud/search-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function doSearch (str) {

const dispGroup = new SatGroup('idList', idList);
lastResultGroup = dispGroup;

app.groups.selectGroup(dispGroup);

fillResultBox(results, str);
Expand Down
13 changes: 10 additions & 3 deletions src/viewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -705,5 +711,6 @@ export default {
getSatSet,
setSelectedSatellite,
getSelectedSatellite,
getSatellite
getSatellite,
setSatelliteGroup
};
73 changes: 1 addition & 72 deletions src/viewer/sat-groups.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -103,7 +33,7 @@ class SatGroups {
this.app.satSet.setColorScheme(defaultColorScheme);
}

getGroup (groupId) {
getGroupById (groupId) {
return this.groups[groupId];
}

Expand All @@ -125,7 +55,6 @@ class SatGroups {
groupConfigs[i].data
);
}
// this.reloadGroups();
}
}

Expand Down

0 comments on commit 0db4c7b

Please sign in to comment.