Skip to content

Commit

Permalink
refactor: ♻️ migrate to storage.keeptrack.space
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Sep 7, 2024
1 parent babc3fc commit 00e30a7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
36 changes: 30 additions & 6 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { RADIUS_OF_EARTH } from '../lib/constants';
import { PersistenceManager, StorageKey } from '../singletons/persistence-manager';
import { ClassificationString } from '../static/classification';
import { isThisNode } from '../static/isThisNode';
import { darkClouds } from './presets/darkClouds';
import { SettingsPresets } from './presets/presets';

export class SettingsManager {
Expand Down Expand Up @@ -88,6 +89,8 @@ export class SettingsManager {

colors: ColorSchemeColorMap;

/** Ensures no html is injected into the page */
isPreventDefaultHtml = false;
/**
* Delay before advancing in Time Machine mode
*/
Expand Down Expand Up @@ -518,6 +521,18 @@ export class SettingsManager {
*/
hoverColor = <[number, number, number, number]>[1.0, 1.0, 0.0, 1.0]; // Yellow
installDirectory = '';
dataSources = {
/**
* This is where the TLEs are loaded from
*
* It was previously: ${settingsManager.installDirectory}tle/TLE2.json`
*
* It can be loaded from a local file or a remote source
*/
tle: 'https://storage.keeptrack.space/data/tle.json',
tleDebris: 'https://app.keeptrack.space/tle/TLEdebris.json',
vimpel: 'https://storage.keeptrack.space/data/vimpel.json',
};
/**
* Determines whether or not to hide the propogation rate text on the GUI.
*/
Expand Down Expand Up @@ -993,7 +1008,12 @@ export class SettingsManager {
* Indicates whether to show confidence levels when hovering over an object.
*/
isShowConfidenceLevels = true;
divContainer: HTMLDivElement;
/**
* The container root element for the application
* NOTE: This is for initializing it, but keepTrackApi will be reerenced throughout
* the application when looking for the container root element
*/
containerRoot: HTMLDivElement;
/**
* The initial zoom level for the camera.
* 0 = earth and 1 = max distance from earth
Expand Down Expand Up @@ -1144,7 +1164,7 @@ export class SettingsManager {
}
}

init(settingsOverride?: any) {
init(settingsOverride?: SettingsManagerOverride) {
this.pTime = [];

this.checkIfIframe_();
Expand Down Expand Up @@ -1392,10 +1412,7 @@ export class SettingsManager {
SettingsPresets.loadPresetDebris(this);
break;
case 'dark-clouds':
// load ./darkClouds.ts and then run it
import('./presets/darkClouds').then((module) => {
module.darkClouds();
});
darkClouds();
break;
case 'million-year':
SettingsPresets.loadPresetMillionYear(this);
Expand Down Expand Up @@ -1738,4 +1755,11 @@ export class SettingsManager {
}
}

// Create a type based on the parameters of SettingsManager (ignore methods)
export type SettingsManagerOverride = Partial<Omit<SettingsManager,
'exportSettingsToJSON' | 'loadOverridesFromUrl_' | 'loadLastMapTexture_' | 'setEmbedOverrides_' | 'setMobileSettings_' | 'setInstallDirectory_' | 'setColorSettings_' |
'checkIfIframe_' | 'initParseFromGETVariables_' | 'loadOverrides_' | 'setMobileSettings_' | 'setEmbedOverrides_' | 'loadLastMapTexture_' | 'setColorSettings_'>>;

// Export the settings manager instance

export const settingsManager = new SettingsManager();
18 changes: 9 additions & 9 deletions src/static/catalog-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ export class CatalogLoader {
* This function will load the catalog, additional catalogs, and merge them together.
*
* Primary Catalogs
* 1. TLE.json - this contains extended object information including launch location and RCS.
* 2. TLEdebris.json - this contains all non-payload data from TLE.json
* 1. tle.json - this contains extended object information including launch location and RCS.
* 2. tleDebris.json - this contains all non-payload data from TLE.json
* Secondary Catalogs
* 1. extra.json - this contains supplemental information about the catalog in json format.
* 2. TLE.txt - this contains a local ASCII TLE file.
* 3. externalTLEs - this contains an external TLE file.
* 4. jsc-orbits.json - this contains JSC Vimpel TLE data.
* 4. vimpel.json - this contains JSC Vimpel TLE data.
*
* The catalog is loaded in the above order appending/overwriting the information each step of the way.
*
Expand All @@ -205,7 +205,7 @@ export class CatalogLoader {

if (settingsManager.externalTLEsOnly) {
// Load our database for the extra information - the satellites will be filtered out
await fetch(`${settingsManager.installDirectory}tle/TLE2.json`)
await fetch(settingsManager.dataSources.tle)
.then((response) => response.json())
.then((data) => CatalogLoader.parse({
keepTrackTle: data,
Expand All @@ -216,7 +216,7 @@ export class CatalogLoader {
});
} else if (settingsManager.isUseDebrisCatalog) {
// Load the debris catalog
await fetch(`${settingsManager.installDirectory}tle/TLEdebris.json`)
await fetch(settingsManager.dataSources.tleDebris)
.then((response) => response.json())
.then((data) => CatalogLoader.parse({
keepTrackTle: data,
Expand All @@ -229,7 +229,7 @@ export class CatalogLoader {
});
} else {
// Load the primary catalog
await fetch(`${settingsManager.installDirectory}tle/TLE2.json`)
await fetch(settingsManager.dataSources.tle)
.then((response) => response.json())
.then((data) => CatalogLoader.parse({
keepTrackTle: data,
Expand Down Expand Up @@ -542,18 +542,18 @@ export class CatalogLoader {
*/
// eslint-disable-next-line require-await
private static async getJscCatalog_(settingsManager: SettingsManager): Promise<JsSat[]> {
return fetch(`${settingsManager.installDirectory}tle/jsc-orbits.json`)
return fetch(settingsManager.dataSources.vimpel)
.then((response) => {
if (response.ok) {
return response.json();
}
errorManagerInstance.warn('Error loading jsc-orbits.json');
errorManagerInstance.warn('Error loading vimpel.json');

return [];

})
.catch(() => {
errorManagerInstance.warn('Error loading jsc-orbits.json');
errorManagerInstance.warn('Error loading vimpel.json');
});
}

Expand Down

0 comments on commit 00e30a7

Please sign in to comment.