Skip to content

handle IATA callsigns from ADS-C - #6

Merged
jaluebbe merged 7 commits into
masterfrom
dev/handle_iata_callsigns_from_adsc
Jul 22, 2026
Merged

handle IATA callsigns from ADS-C#6
jaluebbe merged 7 commits into
masterfrom
dev/handle_iata_callsigns_from_adsc

Conversation

@jaluebbe

Copy link
Copy Markdown
Collaborator

Callsigns of flights from ADS-C have 2-letter IATA IDs in their callsigns and not the 3-letter ICAO IDs as being used in ADS-B callsigns. Therefore, the route lookup failed. Now, an airline database is taken from opentraveldata and will be cached in the browser. IATA callsigns arte converted to ICAO callsigns where possible on the map, in the table and for the route lookup. A special case is added for Lufthansa as LH may translate to DLH for passenger flights as well as GEC for cargo flights.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Not ready to approve

The new remote airline-table loader needs basic HTTP error handling and safer parsing/refresh behavior to avoid poisoning cached mappings and unintended side effects (e.g., altering callsign timestamps).

Pull request overview

This PR improves callsign handling for ADS-C flights by converting 2-character IATA airline prefixes to 3-character ICAO prefixes (when a mapping is known), so downstream display and route lookup logic works consistently with ADS-B-style callsigns.

Changes:

  • Add IATA→ICAO conversion logic to callsign normalization (including a Lufthansa passenger/cargo special-case).
  • Load the IATA→ICAO airline mapping from OpenTravelData at runtime and cache it in localStorage.
  • Wire the airline table loader into the page by adding airlines.js to index.html.
File summaries
File Description
html/planeObject.js Normalizes callsigns by converting IATA-prefixed flight IDs to ICAO where possible and uses normalized callsigns in setFlight().
html/index.html Loads airlines.js so the mapping is available to callsign normalization.
html/airlines.js Fetches/parses/caches the OpenTravelData airline table and refreshes tracked callsigns after load.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Low

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread html/airlines.js Outdated
Comment thread html/airlines.js
Comment thread html/airlines.js
Harden airlines.js: validate CSV fields, check fetch response status, preserve flightTs on refresh

- Validate iata2/icao3/type against expected formats before caching,
  since values come from a remote CSV and later feed into generated HTML
- Throw on non-2xx fetch responses instead of parsing error pages as CSV
- Preserve flightTs in refreshTrackedCallsigns() so re-normalizing an
  existing callsign doesn't reset the "no callsign" timeout

Addresses Copilot review feedback on the IATA->ICAO callsign PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Not ready to approve

The new cached mapping table path can leave iata_to_icao as an invalid value (e.g., null) and cause runtime errors during callsign normalization unless the cache data is validated/guarded.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Low

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.

Comment thread html/planeObject.js Outdated
Comment thread html/airlines.js
Guard against invalid iata_to_icao cache/state

- Validate cached.ts and cached.data before using the cache fast-path
  in loadAirlineTable(), so a corrupt/malformed localStorage entry
  (e.g. data: null) falls back to fetching instead of poisoning the
  in-memory table
- Guard iataToIcao() against iata_to_icao being null/non-object,
  as a defense-in-depth backstop for the same failure mode

Addresses further Copilot review feedback on the IATA->ICAO callsign PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Not ready to approve

There are reliability/correctness gaps in the airline table loading/caching path that should be addressed before approval.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Low

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.

Comment thread html/airlines.js
Comment thread html/airlines.js
Refresh tracked callsigns on cache-hit path too

Previously refreshTrackedCallsigns() was only called after a fresh
fetch, so aircraft already tracked at load time kept their unconverted
callsign whenever the airline table came from localStorage instead of
the network. Both paths now behave consistently.

Addresses further Copilot review feedback on the IATA->ICAO callsign PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Not ready to approve

There are a couple of confirmed edge-case bugs in callsign parsing/conversion (and a small avoidable exception path in caching) that should be fixed before merging.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Low

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.

Comment thread html/planeObject.js Outdated
Comment thread html/planeObject.js
Comment thread html/airlines.js
Require at least one digit after the airline prefix

A bare IATA/ICAO code without a flight number (e.g. "LH", "3K") is not
a valid callsign and shouldn't be run through IATA->ICAO conversion.
Changed the trailing digit group from "*" (zero or more) to "+" (one
or more) so such inputs fall through to the untouched fallback path
instead of being expanded to a 3-letter ICAO prefix with no number.

Note: the digit-digit IATA prefix concern from the same review round
was not addressed, since IATA airline codes are never purely numeric.
The suggested exact-JSON.parse-throws fix in airlines.js was also not
applied — localStorage.getItem() returning null does not make
JSON.parse() throw (JSON.parse(null) === null), so that code path was
already safe.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Not ready to approve

The current CSV parsing drops all cargo-only airlines (preventing conversion for many cargo callsigns) and iataToIcao() should defensively handle the airline table script being unavailable to avoid runtime ReferenceErrors.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Low

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.

Comment thread html/airlines.js
Comment thread html/planeObject.js Outdated
- parseAirlineCsv() no longer drops all cargo-type entries outright.
  Passenger entries are still preferred when both exist for an IATA
  code (e.g. LH -> DLH), but a cargo-only entry is now kept as a
  fallback when it's the only mapping available (e.g. CV -> CLX,
  CK -> CKK), instead of being dropped and left unconverted.
- Restored the typeof iata_to_icao !== 'undefined' guard in
  iataToIcao(). This protects against a different failure mode than
  the earlier null-check: if airlines.js fails to load entirely
  (404, blocked, etc.), iata_to_icao is never declared, and a plain
  reference to it throws ReferenceError. Both guards are needed.

Addresses further Copilot review feedback on the IATA->ICAO callsign PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Ready to approve

The changes are internally consistent (script load order, normalization usage, and caching/refresh behavior) and I did not find any verified correctness or safety issues in the modified regions.

Note: this review does not count toward required approvals for merging.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Low

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.

@jaluebbe
jaluebbe merged commit d439924 into master Jul 22, 2026
1 check passed
@jaluebbe
jaluebbe deleted the dev/handle_iata_callsigns_from_adsc branch July 22, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants