mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 13:10:29 +00:00
fix(airports): refresh the bundled airports from OurAirports without dropping shipped codes
Logroño-Agoncillo (RJL) and fifteen other airports gained their IATA code in OurAirports after the bundled list was built, so the airport search and the code lookup of create_transport could not find them. The list is rebuilt from the current data. The build now keeps every code the previous list carried that upstream no longer lists (a scheduled-service flag flipped back, PBI moved to a new record), since bookings and MCP calls still name them. Refs #2897
This commit is contained in:
@@ -133,10 +133,21 @@ for (const a of airports) {
|
||||
if (existing.icao && !a.icao) continue;
|
||||
if (!existing.icao && a.icao) seen.set(a.iata, a);
|
||||
}
|
||||
// A code a release already shipped stays resolvable. OurAirports drops one when it
|
||||
// flips a scheduled-service flag back to "no" or moves the code to a new record, and
|
||||
// a booking import or an MCP call naming that code would stop resolving with the
|
||||
// next rebuild. Upstream wins for every code it still lists.
|
||||
const previous = fs.existsSync(OUT) ? JSON.parse(fs.readFileSync(OUT, 'utf8')) : [];
|
||||
let kept = 0;
|
||||
for (const a of previous) {
|
||||
if (seen.has(a.iata)) continue;
|
||||
seen.set(a.iata, a);
|
||||
kept++;
|
||||
}
|
||||
const unique = Array.from(seen.values()).sort((a, b) => a.iata.localeCompare(b.iata));
|
||||
|
||||
fs.writeFileSync(OUT, JSON.stringify(unique));
|
||||
const size = fs.statSync(OUT).size;
|
||||
console.log(
|
||||
`Wrote ${unique.length} airports to ${OUT} (${(size / 1024).toFixed(1)} KB); skipped ${skippedNoTz} without timezone`,
|
||||
`Wrote ${unique.length} airports to ${OUT} (${(size / 1024).toFixed(1)} KB); kept ${kept} no longer listed; skipped ${skippedNoTz} without timezone`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user