From 0e422ec5a4db04d5a679b3d34d954194a6232025 Mon Sep 17 00:00:00 2001 From: Saschl Date: Mon, 30 Sep 2024 22:12:48 +0200 Subject: [PATCH] cleanup --- apps/server/src/terrain.ts | 44 ------------------- .../src/terrain/processing/maphandler.ts | 5 --- 2 files changed, 49 deletions(-) delete mode 100644 apps/server/src/terrain.ts diff --git a/apps/server/src/terrain.ts b/apps/server/src/terrain.ts deleted file mode 100644 index 071bfd29..00000000 --- a/apps/server/src/terrain.ts +++ /dev/null @@ -1,44 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; -import axios from 'axios'; - -import { getSimbridgeDir } from 'apps/server/src/utilities/pathUtil'; - -const SIMBRIDGE_FOLDER = getSimbridgeDir(); -const TERRAIN_MAP_FOLDER = path.join(SIMBRIDGE_FOLDER, 'terrain'); -const TERRAIN_MAP_PATH = path.join(TERRAIN_MAP_FOLDER, 'terrain.map'); - -const TERRAIN_MAP_CDN = 'https://cdn.flybywiresim.com/addons/simbridge/terrain-db-binaries/terrain.map'; - -const execute = async () => { - try { - // Create the folders if they don't exist - if (!fs.existsSync(TERRAIN_MAP_FOLDER)) fs.mkdirSync(TERRAIN_MAP_FOLDER); - - if (!fs.existsSync(TERRAIN_MAP_PATH)) { - console.log('Downloading terrain map'); - - const terrainResponse = await axios.get(TERRAIN_MAP_CDN, { responseType: 'stream' }); - - return new Promise((resolve, reject) => { - const writer = fs.createWriteStream(TERRAIN_MAP_PATH); - terrainResponse.data.pipe(writer); - let error: Error = null; - - writer.on('error', (err) => { - error = err; - writer.close(); - reject(err); - }); - - writer.on('close', () => { - if (!error) resolve(0); - }); - }); - } - } catch (error) { - console.error(error); - } -}; - -export default execute; diff --git a/apps/server/src/terrain/processing/maphandler.ts b/apps/server/src/terrain/processing/maphandler.ts index b276a90c..900c810f 100644 --- a/apps/server/src/terrain/processing/maphandler.ts +++ b/apps/server/src/terrain/processing/maphandler.ts @@ -22,8 +22,6 @@ import { bearingWgs84, normalizeHeading, projectWgs84, wgs84toPixelCoordinate } import { ElevationProfileConstants, LocalElevationMapConstants } from './gpu/interfaces'; import { uploadTextureData } from './gpu/upload'; import { Logger } from './logging/logger'; -import { copyFileSync, existsSync } from 'fs'; -import execute from '../../terrain'; // defines the maximum dimension length of the world map const GpuMaxPixelSize = 16384; @@ -148,9 +146,6 @@ export class MapHandler { private async readTerrainMap(): Promise { try { -/* if(!existsSync(join(getSimbridgeDir(), '/terrain/terrain.map'))){ - copyFileSync(join(getExecutablePath(), '/terrain/terrain.map'), join(getSimbridgeDir(), '/terrain/terrain.map')); - } */ // TODO shall we move this as well? Currently the installer downloads the terrain.map file const buffer = await readFile(join(getExecutablePath(), '/terrain/terrain.map')); this.logging.info(`Read MB of terrainmap: ${(Buffer.byteLength(buffer) / (1024 * 1024)).toFixed(2)}`);