route display: more config options

This commit is contained in:
Matthias Wirth
2025-08-04 15:01:53 +00:00
parent 80fb681986
commit 45b08ca7c5
5 changed files with 39 additions and 31 deletions

View File

@@ -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

View File

@@ -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";

View File

@@ -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";

View File

@@ -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) => {

View File

@@ -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;
}