use alias when airport has no ICAO code

This commit is contained in:
Louis 2024-05-13 13:07:36 +02:00
parent 53afd1ee77
commit f3792db230

View file

@ -85,14 +85,23 @@
const features_nav = new Array(); const features_nav = new Array();
const features_local = new Array(); const features_local = new Array();
const airport_name_to_ident = {
"Norberg": "SE-0004"
};
for(const line of lines) { for(const line of lines) {
const [from, to] = line.split(','); const [from, to] = line.split(',');
const fromAirport = airportsData[from]; let fromAirport = airportsData[from];
const toAirport = airportsData[to]; let toAirport = airportsData[to];
if(!fromAirport) {
fromAirport = airportsData[airport_name_to_ident[from]];
if(!fromAirport) { alert(`Airport ${from} not found`); return; } 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; } if(!toAirport) { alert(`Airport ${to} not found`); return; }
}
const fromLongitude = parseFloat(fromAirport.longitude); const fromLongitude = parseFloat(fromAirport.longitude);
const fromLatitude = parseFloat(fromAirport.latitude); const fromLatitude = parseFloat(fromAirport.latitude);