feat(tools): count aircraft in an area by airline

OpenSky, the default civil feed, reports no operator, so group_by: operator
said "no operator reported". aircraft_in_area now also takes
group_by: 'airline', read from the ICAO designator in each callsign: three
letters followed by a flight number that starts with a digit (SWA1234,
UAL12A). Registrations used as callsigns (N123AB) count as unknown. Rows are
unchanged; the designator is derived for the breakdown only.

Live, Texas: "785 aircraft ...; most by airline: AAL (89), SWA (65), UAL (52);
283 unknown."

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
quanticsoul4772andClaude Opus 5.5 committed 2026-10-17 14:32:46 -07:00
1 parent db73c6908e
commit aec4f67ca9
5 files changed
+80 -13

No files matched your search

+5 -3
View File
@@ -28,13 +28,15 @@ export const MAX_GROUPS = 10;
/**
* Count rows by one text field over every row, not just those returned.
* Values group case-insensitively and keep their first spelling; rows
* without a value are counted as unknown.
* without a value are counted as unknown. `valueOf` derives the value when
* it is not a row field as it stands.
*/
export function breakdown(rows, field) {
export function breakdown(rows, field, valueOf = (row) => row[field]) {
const groups = new Map();
let unknown = 0;
for (const row of rows) {
const value = typeof row[field] === 'string' ? row[field].trim() : '';
const raw = valueOf(row);
const value = typeof raw === 'string' ? raw.trim() : '';
if (!value) {
unknown += 1;
continue;