Moved airfields database to public/database folder

This commit is contained in:
Pax1601
2023-08-15 12:26:05 +02:00
parent 3055378b86
commit e96cb2716d
24 changed files with 2462 additions and 2509 deletions

View File

@@ -344,7 +344,7 @@ class DemoDataGenerator {
airbases(req, res){ airbases(req, res){
var ret = {airbases: { var ret = {airbases: {
["0"]: { ["0"]: {
callsign: "Neutral", callsign: "Nellis",
latitude: 37.3, latitude: 37.3,
longitude: -115.8, longitude: -115.8,
coalition: "neutral" coalition: "neutral"

View File

@@ -1,466 +1,466 @@
{ {
"airfields": { "airfields": {
"Anapa-Vityazevo": { "Anapa-Vityazevo": {
"ICAO": "URKA", "ICAO": "URKA",
"elevation": "141", "elevation": "141",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"22": { "22": {
"magHeading": "214", "magHeading": "214",
"ILS": "" "ILS": ""
}, },
"04": { "04": {
"magHeading": "034", "magHeading": "034",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "9000" "length": "9000"
} }
] ]
}, },
"Batumi": { "Batumi": {
"ICAO": "UGSB", "ICAO": "UGSB",
"elevation": "33", "elevation": "33",
"TACAN": "16X", "TACAN": "16X",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"13": { "13": {
"magHeading": "119", "magHeading": "119",
"ILS": "" "ILS": ""
}, },
"31": { "31": {
"magHeading": "299", "magHeading": "299",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "7500" "length": "7500"
} }
] ]
}, },
"Beslan": { "Beslan": {
"ICAO": "URMO", "ICAO": "URMO",
"elevation": "1722", "elevation": "1722",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"10": { "10": {
"magHeading": "086", "magHeading": "086",
"ILS": "110.50" "ILS": "110.50"
}, },
"28": { "28": {
"magHeading": "266", "magHeading": "266",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "9600" "length": "9600"
} }
] ]
}, },
"Gelendzhik": { "Gelendzhik": {
"ICAO": "URKG", "ICAO": "URKG",
"elevation": "72", "elevation": "72",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"19": { "19": {
"magHeading": "212", "magHeading": "212",
"ILS": "" "ILS": ""
}, },
"01": { "01": {
"magHeading": "032", "magHeading": "032",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "5400" "length": "5400"
} }
] ]
}, },
"Gudauta": { "Gudauta": {
"ICAO": "UG23", "ICAO": "UG23",
"elevation": "69", "elevation": "69",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"15": { "15": {
"magHeading": "144", "magHeading": "144",
"ILS": "" "ILS": ""
}, },
"33": { "33": {
"magHeading": "324", "magHeading": "324",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "7700" "length": "7700"
} }
] ]
}, },
"Kobuleti": { "Kobuleti": {
"ICAO": "UG5X", "ICAO": "UG5X",
"elevation": "69", "elevation": "69",
"TACAN": "67X", "TACAN": "67X",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"25": { "25": {
"magHeading": "243", "magHeading": "243",
"ILS": "" "ILS": ""
}, },
"07": { "07": {
"magHeading": "063", "magHeading": "063",
"ILS": "111.50" "ILS": "111.50"
} }
} }
], ],
"length": "7400" "length": "7400"
} }
] ]
}, },
"Krasnodar-Center": { "Krasnodar-Center": {
"ICAO": "URKL", "ICAO": "URKL",
"elevation": "98", "elevation": "98",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"27": { "27": {
"magHeading": "259", "magHeading": "259",
"ILS": "" "ILS": ""
}, },
"09": { "09": {
"magHeading": "079", "magHeading": "079",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "7700" "length": "7700"
} }
] ]
}, },
"Krasnodar-Pashkovsky": { "Krasnodar-Pashkovsky": {
"ICAO": "URKK", "ICAO": "URKK",
"elevation": "112", "elevation": "112",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"23": { "23": {
"magHeading": "219", "magHeading": "219",
"ILS": "" "ILS": ""
}, },
"05": { "05": {
"magHeading": "039", "magHeading": "039",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "9600" "length": "9600"
} }
] ]
}, },
"Krymsk": { "Krymsk": {
"ICAO": "URKW", "ICAO": "URKW",
"elevation": "66", "elevation": "66",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"22": { "22": {
"magHeading": "212", "magHeading": "212",
"ILS": "" "ILS": ""
}, },
"04": { "04": {
"magHeading": "032", "magHeading": "032",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "8000" "length": "8000"
} }
] ]
}, },
"Kutaisi": { "Kutaisi": {
"ICAO": "UGKO", "ICAO": "UGKO",
"elevation": "148", "elevation": "148",
"TACAN": "44X", "TACAN": "44X",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"25": { "25": {
"magHeading": "247", "magHeading": "247",
"ILS": "" "ILS": ""
}, },
"07": { "07": {
"magHeading": "067'", "magHeading": "067'",
"ILS": "109.75" "ILS": "109.75"
} }
} }
], ],
"length": "7700" "length": "7700"
} }
] ]
}, },
"Maykop-Khanskaya": { "Maykop-Khanskaya": {
"ICAO": "URKH", "ICAO": "URKH",
"elevation": "591", "elevation": "591",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"22": { "22": {
"magHeading": "211", "magHeading": "211",
"ILS": "" "ILS": ""
}, },
"04": { "04": {
"magHeading": "031", "magHeading": "031",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "10100" "length": "10100"
} }
] ]
}, },
"Mineralnye Vody": { "Mineralnye Vody": {
"ICAO": "URMM", "ICAO": "URMM",
"elevation": "1050", "elevation": "1050",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"12": { "12": {
"magHeading": "108", "magHeading": "108",
"ILS": "111.70" "ILS": "111.70"
}, },
"30": { "30": {
"magHeading": "288", "magHeading": "288",
"ILS": "109.30" "ILS": "109.30"
} }
} }
], ],
"length": "12700" "length": "12700"
} }
] ]
}, },
"Mozdok": { "Mozdok": {
"ICAO": "XRMF", "ICAO": "XRMF",
"elevation": "507", "elevation": "507",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"26": { "26": {
"magHeading": "255", "magHeading": "255",
"ILS": "" "ILS": ""
}, },
"08": { "08": {
"magHeading": "075", "magHeading": "075",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "9400" "length": "9400"
} }
] ]
}, },
"Nalchik": { "Nalchik": {
"ICAO": "URMN", "ICAO": "URMN",
"elevation": "1411", "elevation": "1411",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"24": { "24": {
"magHeading": "228", "magHeading": "228",
"ILS": "110.50" "ILS": "110.50"
}, },
"06": { "06": {
"magHeading": "048'", "magHeading": "048'",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "7000" "length": "7000"
} }
] ]
}, },
"Novorossiysk": { "Novorossiysk": {
"ICAO": "URKN", "ICAO": "URKN",
"elevation": "131", "elevation": "131",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"22": { "22": {
"magHeading": "214", "magHeading": "214",
"ILS": "" "ILS": ""
}, },
"04": { "04": {
"magHeading": "034", "magHeading": "034",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "5400" "length": "5400"
} }
] ]
}, },
"Senaki-Kolkhi": { "Senaki-Kolkhi": {
"ICAO": "UGKS", "ICAO": "UGKS",
"elevation": "43", "elevation": "43",
"TACAN": "31X", "TACAN": "31X",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"27": { "27": {
"magHeading": "268", "magHeading": "268",
"ILS": "" "ILS": ""
}, },
"09": { "09": {
"magHeading": "088'", "magHeading": "088'",
"ILS": "108.90" "ILS": "108.90"
} }
} }
], ],
"length": "7400" "length": "7400"
} }
] ]
}, },
"Sochi-Adler": { "Sochi-Adler": {
"ICAO": "URSS", "ICAO": "URSS",
"elevation": "98", "elevation": "98",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"27": { "27": {
"magHeading": "235", "magHeading": "235",
"ILS": "" "ILS": ""
}, },
"06": { "06": {
"magHeading": "055", "magHeading": "055",
"ILS": "111.10" "ILS": "111.10"
} }
} }
], ],
"length": "9700" "length": "9700"
} }
] ]
}, },
"Tbilisi-Lochini": { "Tbilisi-Lochini": {
"ICAO": "UGTB", "ICAO": "UGTB",
"elevation": "1574", "elevation": "1574",
"TACAN": "25X", "TACAN": "25X",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"13": { "13": {
"magHeading": "121", "magHeading": "121",
"ILS": "110.30" "ILS": "110.30"
}, },
"31": { "31": {
"magHeading": "301", "magHeading": "301",
"ILS": "108.90" "ILS": "108.90"
} }
} }
], ],
"length": "9300" "length": "9300"
} }
] ]
}, },
"Soganlug": { "Soganlug": {
"ICAO": "UG24", "ICAO": "UG24",
"elevation": "1500", "elevation": "1500",
"TACAN": "25X", "TACAN": "25X",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"14": { "14": {
"magHeading": "125", "magHeading": "125",
"ILS": "" "ILS": ""
}, },
"32": { "32": {
"magHeading": "305", "magHeading": "305",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "6500" "length": "6500"
} }
] ]
}, },
"Sukhumi-Babushara": { "Sukhumi-Babushara": {
"ICAO": "UGSS", "ICAO": "UGSS",
"elevation": "43", "elevation": "43",
"TACAN": "", "TACAN": "",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"12": { "12": {
"magHeading": "109", "magHeading": "109",
"ILS": "" "ILS": ""
}, },
"30": { "30": {
"magHeading": "289", "magHeading": "289",
"ILS": "" "ILS": ""
} }
} }
], ],
"length": "11400" "length": "11400"
} }
] ]
}, },
"Vaziani": { "Vaziani": {
"ICAO": "UG27", "ICAO": "UG27",
"elevation": "1524", "elevation": "1524",
"TACAN": "22X", "TACAN": "22X",
"runways": [ "runways": [
{ {
"headings": [ "headings": [
{ {
"13": { "13": {
"magHeading": "129", "magHeading": "129",
"ILS": "108.75" "ILS": "108.75"
}, },
"31": { "31": {
"magHeading": "309", "magHeading": "309",
"ILS": "108.75" "ILS": "108.75"
} }
} }
], ],
"length": "7700" "length": "7700"
} }
] ]
} }
} }
} }

View File

@@ -1074,10 +1074,6 @@ dl.ol-data-grid {
row-gap: 4px; row-gap: 4px;
} }
dl.ol-data-grid dd {
width: 60%;
}
dl.ol-data-grid dt.icon { dl.ol-data-grid dt.icon {
text-indent: 10px; text-indent: 10px;
} }

View File

@@ -148,7 +148,7 @@
} }
#aircaft-loadout-list, #aircaft-loadout-list,
#helicopter-loadout-list { #helicopter-loadout-list {
align-content: center; align-content: center;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -156,7 +156,7 @@
} }
#aircraft-unit-image, #aircraft-unit-image,
#helicopter-unit-image { #helicopter-unit-image {
filter: invert(100%); filter: invert(100%);
height: 100px; height: 100px;
margin-bottom: 10px; margin-bottom: 10px;
@@ -210,10 +210,10 @@
} }
.ol-context-menu .ol-slider-value { .ol-context-menu .ol-slider-value {
color: var(--accent-light-blue); color: var(--accent-light-blue);
cursor: pointer; cursor: pointer;
font-size: 14px; font-size: 14px;
font-weight: bold; font-weight: bold;
} }
.ol-context-menu .ol-slider-container { .ol-context-menu .ol-slider-container {
@@ -449,36 +449,41 @@
} }
/* Airbase context menu */ /* Airbase context menu */
#airbase-contextmenu #airbase-runways { #airbase-chart-data dd {
display:flex; width: 60%;
flex-direction: column; font-weight: bold;
row-gap:4px;
} }
#airbase-contextmenu #airbase-runways > .runway { #airbase-runways {
border:1px solid #ccc; display: flex;
display:flex; flex-direction: column;
row-gap: 4px;
}
#airbase-runways>.runway {
border: 1px solid #ccc;
display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
} }
#airbase-contextmenu #airbase-runways > .runway abbr { #airbase-runways>.runway abbr {
cursor:help; cursor: help;
text-decoration: none; text-decoration: none;
} }
#airbase-contextmenu #airbase-runways > .runway > .heading { #airbase-runways>.runway>.heading {
align-items: center; align-items: center;
column-gap: 4px; column-gap: 4px;
display:flex; display: flex;
flex-direction: row; flex-direction: row;
} }
#airbase-contextmenu #airbase-runways > .runway > .heading > abbr { #airbase-runways>.runway>.heading>abbr {
font-weight: var( --font-weight-bolder ); font-weight: var(--font-weight-bolder);
padding:4px; padding: 4px;
} }
#airbase-contextmenu #airbase-runways > .runway > .heading:last-of-type { #airbase-runways>.runway>.heading:last-of-type {
flex-direction: row-reverse; flex-direction: row-reverse;
} }

View File

@@ -15,68 +15,46 @@ const allowedTheatres = [
"syria" "syria"
]; ];
function getAirbasesData( theatreName ) { function getAirbasesData( theatreName ) {
if ( !isValidTheatre( theatreName ) ) { if ( !isValidTheatre( theatreName ) ) {
return false; return false;
} }
return JSON.parse( fs.readFileSync( `src/airfields/${theatreName}.json` ) ).airfields return JSON.parse( fs.readFileSync( `public/databases/airbases/${theatreName}.json` ) ).airfields
} }
function isValidTheatre( theatre ) { function isValidTheatre( theatre ) {
return ( allowedTheatres.indexOf( theatre ) > -1 ) return ( allowedTheatres.indexOf( theatre ) > -1 )
} }
function sendInvalidTheatre( res ) { function sendInvalidTheatre( res ) {
res.status( 400 ).send( "Missing/invalid theatre name; must be one of:\n\t" + allowedTheatres.join( "\n\t" ) ); res.status( 400 ).send( "Missing/invalid theatre name; must be one of:\n\t" + allowedTheatres.join( "\n\t" ) );
} }
/**************************************************************************************************************/ /**************************************************************************************************************/
// Endpoints // Endpoints
/**************************************************************************************************************/ /**************************************************************************************************************/
app.get( "/", ( req, res ) => { app.get( "/", ( req, res ) => {
sendInvalidTheatre( res ); sendInvalidTheatre( res );
}); });
app.get( "/:theatreName/:airbaseName", ( req, res ) => { app.get( "/:theatreName/:airbaseName", ( req, res ) => {
const airbases = getAirbasesData( req.params.theatreName ); const airbases = getAirbasesData( req.params.theatreName );
if ( !airbases ) { if ( !airbases ) {
sendInvalidTheatre( res ); sendInvalidTheatre( res );
return; return;
} }
const airbaseName = req.params.airbaseName; const airbaseName = req.params.airbaseName;
if ( !airbases.hasOwnProperty( airbaseName ) ) { if ( !airbases.hasOwnProperty( airbaseName ) ) {
res.status( 404 ).send( `Unknown airbase name "${airbaseName}". Available options are:\n\t` + Object.keys( airbases ).join( "\n\t" ) ); res.status( 404 ).send( `Unknown airbase name "${airbaseName}". Available options are:\n\t` + Object.keys( airbases ).join( "\n\t" ) );
} else { } else {
res.status( 200 ).json( airbases[ airbaseName ] ); res.status( 200 ).json( airbases[ airbaseName ] );
} }
}); });
app.get( "/:theatreName", ( req, res ) => { app.get( "/:theatreName", ( req, res ) => {
const theatreName = req.params.theatreName.toLowerCase().replace( /\s*/g, "" ); const theatreName = req.params.theatreName.toLowerCase().replace( /\s*/g, "" );
const airbases = getAirbasesData( theatreName ); const airbases = getAirbasesData( theatreName );
@@ -86,9 +64,6 @@ app.get( "/:theatreName", ( req, res ) => {
} }
res.status( 200 ).json( airbases ); res.status( 200 ).json( airbases );
}); });
module.exports = app; module.exports = app;

View File

@@ -9,7 +9,7 @@ interface ObjectIconOptions {
showFuel: boolean, showFuel: boolean,
showAmmo: boolean, showAmmo: boolean,
showSummary: boolean, showSummary: boolean,
showCallsign: boolean, showCallsign: boolean,
rotateToHeading: boolean rotateToHeading: boolean
} }
@@ -48,7 +48,7 @@ interface Contact {
} }
interface Offset { interface Offset {
x: number, x: number,
y: number, y: number,
z: number z: number
} }

View File

@@ -2,8 +2,7 @@ import { DivIcon } from 'leaflet';
import { CustomMarker } from '../map/custommarker'; import { CustomMarker } from '../map/custommarker';
import { SVGInjector } from '@tanem/svg-injector'; import { SVGInjector } from '@tanem/svg-injector';
export interface AirbaseOptions export interface AirbaseOptions {
{
name: string, name: string,
position: L.LatLng position: L.LatLng
} }
@@ -28,8 +27,7 @@ export interface AirbaseChartRunwayHeadingData {
} }
} }
export class Airbase extends CustomMarker export class Airbase extends CustomMarker {
{
#name: string = ""; #name: string = "";
#chartData: AirbaseChartData = { #chartData: AirbaseChartData = {
elevation: "", elevation: "",
@@ -38,12 +36,11 @@ export class Airbase extends CustomMarker
runways: [] runways: []
}; };
#coalition: string = ""; #coalition: string = "";
#hasChartDataBeenSet:boolean = false; #hasChartDataBeenSet: boolean = false;
#properties: string[] = []; #properties: string[] = [];
#parkings: string[] = []; #parkings: string[] = [];
constructor(options: AirbaseOptions) constructor(options: AirbaseOptions) {
{
super(options.position, { riseOnHover: true }); super(options.position, { riseOnHover: true });
this.#name = options.name; this.#name = options.name;
@@ -54,12 +51,12 @@ export class Airbase extends CustomMarker
} }
createIcon() { createIcon() {
var icon = new DivIcon({ var icon = new DivIcon({
className: 'leaflet-airbase-marker', className: 'leaflet-airbase-marker',
iconSize: [40, 40], iconSize: [40, 40],
iconAnchor: [20, 20] iconAnchor: [20, 20]
}); // Set the marker, className must be set to avoid white square }); // Set the marker, className must be set to avoid white square
this.setIcon(icon); this.setIcon(icon);
var el = document.createElement("div"); var el = document.createElement("div");
el.classList.add("airbase-icon"); el.classList.add("airbase-icon");
@@ -72,55 +69,45 @@ export class Airbase extends CustomMarker
el.dataset.coalition = this.#coalition; el.dataset.coalition = this.#coalition;
} }
setCoalition(coalition: string) setCoalition(coalition: string) {
{
this.#coalition = coalition; this.#coalition = coalition;
(<HTMLElement> this.getElement()?.querySelector(".airbase-icon")).dataset.coalition = this.#coalition; (<HTMLElement>this.getElement()?.querySelector(".airbase-icon")).dataset.coalition = this.#coalition;
} }
getChartData() getChartData() {
{
return this.#chartData; return this.#chartData;
} }
getCoalition() getCoalition() {
{
return this.#coalition; return this.#coalition;
} }
setName(name: string) setName(name: string) {
{
this.#name = name; this.#name = name;
} }
getName() getName() {
{
return this.#name; return this.#name;
} }
setChartData( chartData:AirbaseChartData ) setChartData(chartData: AirbaseChartData) {
{
this.#hasChartDataBeenSet = true; this.#hasChartDataBeenSet = true;
this.#chartData = chartData; this.#chartData = chartData;
} }
setProperties(properties: string[]) setProperties(properties: string[]) {
{
this.#properties = properties; this.#properties = properties;
} }
getProperties() getProperties() {
{
return this.#properties; return this.#properties;
} }
setParkings(parkings: string[]) setParkings(parkings: string[]) {
{
this.#parkings = parkings; this.#parkings = parkings;
} }
getParkings() getParkings() {
{
return this.#parkings; return this.#parkings;
} }
} }

View File

@@ -49,17 +49,18 @@ export class MissionHandler {
updateAirbases(data: AirbasesData) { updateAirbases(data: AirbasesData) {
for (let idx in data.airbases) { for (let idx in data.airbases) {
var airbase = data.airbases[idx] var airbase = data.airbases[idx]
if (this.#airbases[idx] === undefined && airbase.callsign != '') { if (this.#airbases[airbase.callsign] === undefined && airbase.callsign != '') {
this.#airbases[idx] = new Airbase({ this.#airbases[airbase.callsign] = new Airbase({
position: new LatLng(airbase.latitude, airbase.longitude), position: new LatLng(airbase.latitude, airbase.longitude),
name: airbase.callsign name: airbase.callsign
}).addTo(getMap()); }).addTo(getMap());
this.#airbases[idx].on('contextmenu', (e) => this.#onAirbaseClick(e)); this.#airbases[airbase.callsign].on('contextmenu', (e) => this.#onAirbaseClick(e));
this.#loadAirbaseChartData(airbase.callsign);
} }
if (this.#airbases[idx] != undefined && airbase.latitude && airbase.longitude && airbase.coalition) { if (this.#airbases[airbase.callsign] != undefined && airbase.latitude && airbase.longitude && airbase.coalition) {
this.#airbases[idx].setLatLng(new LatLng(airbase.latitude, airbase.longitude)); this.#airbases[airbase.callsign].setLatLng(new LatLng(airbase.latitude, airbase.longitude));
this.#airbases[idx].setCoalition(airbase.coalition); this.#airbases[airbase.callsign].setCoalition(airbase.coalition);
} }
} }
} }
@@ -72,8 +73,6 @@ export class MissionHandler {
this.#theatre = data.mission.theatre; this.#theatre = data.mission.theatre;
getMap().setTheatre(this.#theatre); getMap().setTheatre(this.#theatre);
getInfoPopup().setText("Map set to " + this.#theatre); getInfoPopup().setText("Map set to " + this.#theatre);
this.#loadAirbaseChartData();
} }
/* Set the date and time data */ /* Set the date and time data */
@@ -235,32 +234,23 @@ export class MissionHandler {
getMap().showAirbaseContextMenu(e.originalEvent.x, e.originalEvent.y, e.latlng, e.sourceTarget); getMap().showAirbaseContextMenu(e.originalEvent.x, e.originalEvent.y, e.latlng, e.sourceTarget);
} }
#loadAirbaseChartData() { #loadAirbaseChartData(callsign: string) {
if ( !this.#theatre ) { if ( !this.#theatre ) {
return; return;
} }
fetch( '/api/airbases/' + this.#theatre , { var xhr = new XMLHttpRequest();
method: 'GET', xhr.open('GET', `api/airbases/${this.#theatre.toLowerCase()}/${callsign}`, true);
headers: { xhr.responseType = 'json';
'Accept': '*/*', xhr.onload = () => {
'Content-Type': 'application/json' var status = xhr.status;
if (status === 200) {
const data = xhr.response;
this.getAirbases()[callsign].setChartData(data);
} else {
console.error(`Error retrieving data for ${callsign} airbase`)
} }
}) };
.then( response => response.json() ) xhr.send();
.then( data => {
for ( const [ id, airbase ] of Object.entries( this.#airbases ) ) {
let airbaseName = airbase.getName();
if ( data.hasOwnProperty( airbaseName ) ) {
airbase.setChartData( data[ airbaseName ] );
} else {
console.error( `Airbase "${airbaseName}" not found in chart data.` );
}
}
});
} }
} }

View File

@@ -4,7 +4,7 @@ import { UnitDatabase } from "./unitdatabase"
export class AircraftDatabase extends UnitDatabase { export class AircraftDatabase extends UnitDatabase {
constructor() { constructor() {
super('databases/aircraftdatabase.json'); super('databases/units/aircraftdatabase.json');
} }
getCategory() { getCategory() {

View File

@@ -4,7 +4,7 @@ import { UnitDatabase } from "./unitdatabase"
export class GroundUnitDatabase extends UnitDatabase { export class GroundUnitDatabase extends UnitDatabase {
constructor() { constructor() {
super('databases/groundunitdatabase.json'); super('databases/units/groundunitdatabase.json');
} }
getSpawnPointsByName(name: string) { getSpawnPointsByName(name: string) {

View File

@@ -4,7 +4,7 @@ import { UnitDatabase } from "./unitdatabase"
export class HelicopterDatabase extends UnitDatabase { export class HelicopterDatabase extends UnitDatabase {
constructor() { constructor() {
super('databases/helicopterdatabase.json'); super('databases/units/helicopterdatabase.json');
} }
getSpawnPointsByName(name: string) { getSpawnPointsByName(name: string) {

View File

@@ -4,7 +4,7 @@ import { UnitDatabase } from "./unitdatabase"
export class NavyUnitDatabase extends UnitDatabase { export class NavyUnitDatabase extends UnitDatabase {
constructor() { constructor() {
super('databases/navyunitdatabase.json'); super('databases/units/navyunitdatabase.json');
} }
getSpawnPointsByName(name: string) { getSpawnPointsByName(name: string) {