diff --git a/server/src/adsb.mjs b/server/src/adsb.mjs index 47bfcff..288dc19 100644 --- a/server/src/adsb.mjs +++ b/server/src/adsb.mjs @@ -23,10 +23,10 @@ const AIRLINES_URL = 'https://raw.githubusercontent.com/jpatokal/openflights/mas const MILITARY_OPERATORS = ['air force', 'airforce', 'army', 'navy', 'marine', 'coast guard', 'military', 'defence', 'defense', 'law', 'luftwaffe', 'RAF', 'USAF', 'USN', 'USMC']; const CARGO_OPERATORS = ['fedex', 'ups', 'dhl', 'cargo', 'freight', 'logistic', 'atlas air', 'kalitta', 'air freight']; -const PASSENGER_OPERATOR_FALLBACKS = ['airlines', 'airways', 'jetblue', 'easyjet', 'ryanair', 'delta', 'united', 'american', 'avianca', 'southwest', 'lufthansa', 'emirates', 'british']; -const MILITARY_CLASSES = ['H1M', 'H2M', 'L1M', 'L2M', 'L4M', 'A0']; +const PASSENGER_OPERATORS = ['airlines', 'airways', 'jetblue', 'easyjet', 'ryanair', 'delta', 'united', 'american', 'avianca', 'southwest', 'lufthansa', 'emirates', 'british']; +// const MILITARY_CLASSES = ['H1M', 'H2M', 'L1M', 'L2M', 'L4M', 'A0']; -let passengerOperators = PASSENGER_OPERATOR_FALLBACKS; +let passengerOperators = PASSENGER_OPERATORS; let adsbCache = null; let adsbCacheTs = 0; @@ -65,12 +65,12 @@ async function syncAirlines() { if (normalized.length >= 3) names.add(normalized); } } - for (const value of PASSENGER_OPERATOR_FALLBACKS) names.add(normalizeAirlineName(value)); + for (const value of PASSENGER_OPERATORS) names.add(normalizeAirlineName(value)); passengerOperators = [...names].sort((a, b) => b.length - a.length); console.log(`✈️ Airline operators loaded: ${passengerOperators.length}`); } catch (e) { console.warn(`⚠️ Could not load airline database: ${e.message}`); - passengerOperators = PASSENGER_OPERATOR_FALLBACKS.map(normalizeAirlineName); + passengerOperators = PASSENGER_OPERATORS.map(normalizeAirlineName); } } @@ -224,8 +224,7 @@ export function classifyAircraft(row) { const ownerFields = [row.owner]; const allFields = [...operatorFields, ...ownerFields, row.categoryDescription]; - if (isIcaoInMilitaryRange(row.icao) || MILITARY_CLASSES.includes(row.class) || - matchesAny(allFields, MILITARY_OPERATORS)) { + if (isIcaoInMilitaryRange(row.icao) || matchesAny(allFields, MILITARY_OPERATORS)) { return 'military'; } @@ -259,7 +258,7 @@ async function scrapeHexDatabase(icao) { const tableMatch = html.match(//i); if (!tableMatch) return null; const $ = cheerio.load(tableMatch[0]); - const row = $('tr').filter((_, el) => $(el).text().toLowerCase().includes(icao.toLowerCase())).first(); + const row = $('tr').filter((_, el) => $(el).text()?.toLowerCase()?.includes(icao.toLowerCase())).first(); if (!row.length) return null; const cells = row.find('td'); return {