From f3792db230d7a4312ed4c4037f417b77b7e95c64 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 13 May 2024 13:07:36 +0200 Subject: [PATCH] use alias when airport has no ICAO code --- index.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index e5fc7c7..7801a97 100644 --- a/index.html +++ b/index.html @@ -85,14 +85,23 @@ const features_nav = new Array(); const features_local = new Array(); + const airport_name_to_ident = { + "Norberg": "SE-0004" + }; for(const line of lines) { const [from, to] = line.split(','); - const fromAirport = airportsData[from]; - const toAirport = airportsData[to]; + let fromAirport = airportsData[from]; + let toAirport = airportsData[to]; - if(!fromAirport) { alert(`Airport ${from} not found`); return; } - if(!toAirport) { alert(`Airport ${to} not found`); return; } + if(!fromAirport) { + fromAirport = airportsData[airport_name_to_ident[from]]; + if(!fromAirport) { alert(`Airport ${from} not found`); return; } + } + if(!toAirport) { + toAirport = airportsData[airport_name_to_ident[to]]; + if(!toAirport) { alert(`Airport ${to} not found`); return; } + } const fromLongitude = parseFloat(fromAirport.longitude); const fromLatitude = parseFloat(fromAirport.latitude);