diff --git a/README-query.md b/README-query.md index 3e9835e..79afeca 100644 --- a/README-query.md +++ b/README-query.md @@ -70,6 +70,7 @@ See the main readme for more examples on how to use the filters - rangeRings=0,1 - 0 or 1 to enable or disable - altitudeChart=0,1 - 0 or 1 to enable or disable - SiteLat=45.0 SiteLon=10.0 - Override the receiver location for this visit +- routeDisplay=icao - Comma separated list of what shall be shown, valid values: iata, icao, city ## Toggles diff --git a/html/config.js b/html/config.js index 0075e8d..46b25c9 100644 --- a/html/config.js +++ b/html/config.js @@ -331,7 +331,8 @@ HideCols = [ // get flight route from routeApi service default setting (toggle via settings checkbox) // useRouteAPI = false; -// useIataAirportCodes = true; // use ICAO when false +// configure route display, possible values: iata, icao, city (can use multiple like this: iata+city) +// routeDisplay = 'iata'; // which routeApi service to use // routeApiUrl = "https://adsb.im/api/0/routeset"; // routeApiUrl = "https://api.adsb.lol/api/0/routeset"; diff --git a/html/defaults.js b/html/defaults.js index 29debac..1f79eb7 100644 --- a/html/defaults.js +++ b/html/defaults.js @@ -347,7 +347,9 @@ let planespottingAPI = false; // get flight route from routeApi service default setting (toggle via settings checkbox) let useRouteAPI = false; // show IATA airport codes instead of ICAO when using the route API -let useIataAirportCodes = true; +let useIataAirportCodes = true; // DEPRECATED, forces routeDisplay to icao when set to false +// configure route display, possible values: iata, icao, city (can use multiple like this: 'iata,city') +let routeDisplay = 'iata'; // which routeApi service to use let routeApiUrl = "https://adsb.im/api/0/routeset"; // alternative: "https://api.adsb.lol/api/0/routeset"; diff --git a/html/planeObject.js b/html/planeObject.js index 6339d7a..31bbd07 100644 --- a/html/planeObject.js +++ b/html/planeObject.js @@ -2925,26 +2925,35 @@ function routeDoLookup(currentTime) { console.log(routes); continue; } - // let's log just a little bit of what's happening - let codes = useIataAirportCodes ? route._airport_codes_iata : route.airport_codes; - if (debugRoute) { - var logText = `result for ${route.callsign}: `; - if (codes == 'unknown') { - logText += 'unknown to the API server'; - } else if (route.plausible == false) { - logText += `${codes} considered implausible`; - } else { - logText += `adding ${codes}`; - } - //console.log(logText); + if (!route.airport_codes) { + continue; } - if (codes != 'unknown') { - if (route.plausible == true) { - g.route_cache[route.callsign] = codes; - } else { - g.route_cache[route.callsign] = `?? ${codes}`; + let codes = ""; + + for (let airport of route._airports) { + if (codes) { + codes += " - " } + let aString = "" + for (let type of routeDisplay) { + if (aString) { + aString += '/'; + } + if (type == 'iata') { + aString += airport.iata; + } else if (type == 'icao') { + aString += airport.icao; + } else if (type == 'city') { + aString += airport.location; + } + } + codes += aString; } + + if (!route.plausible) { + codes = '?? ' + codes; + } + g.route_cache[route.callsign] = codes; } }) .fail((jqxhr, status, error) => { diff --git a/html/script.js b/html/script.js index a973ff6..3013633 100644 --- a/html/script.js +++ b/html/script.js @@ -1655,18 +1655,13 @@ jQuery('#selected_altitude_geom1') } } }); - - /* - new Toggle({ - key: "useIataAirportCodes", - display: "Show IATA airport codes", - container: "#settingsRight", - init: useIataAirportCodes, - setState: function(state) { - useIataAirportCodes = state; - } - }); - */ + if (useIataAirportCodes == false) { + routeDisplay = 'icao'; // cope with deprecated useIata var + } + if (usp.has('routeDisplay')) { + routeDisplay = usp.get('routeDisplay'); + } + routeDisplay = routeDisplay.split(','); } else { useRouteAPI = false; }