From ea869178662085a081e1e6a044c9ee2b2d89f9ab Mon Sep 17 00:00:00 2001 From: Alex Harvey Date: Thu, 12 Nov 2026 18:27:46 -0700 Subject: [PATCH 1/3] Read channel data tiles from data.ferritefw.dev A reader for its columnar-1 tiles, Maidenhead tile names, and a client that fetches only the tiles a search around a point can reach, with real tiles from the site as test fixtures. --- src/services/ferrite/client.ts | 130 +++++++++++++++++++++++ src/services/ferrite/maidenhead.ts | 95 +++++++++++++++++ src/services/ferrite/tile.ts | 99 +++++++++++++++++ tests/fixtures/ferrite/README.md | 5 + tests/fixtures/ferrite/airports-GD.json | 1 + tests/fixtures/ferrite/repeaters-FJ.json | 1 + tests/fixtures/ferrite/tafl-BP91.json | 1 + tests/unit/ferriteData.test.ts | 126 ++++++++++++++++++++++ 8 files changed, 458 insertions(+) create mode 100644 src/services/ferrite/client.ts create mode 100644 src/services/ferrite/maidenhead.ts create mode 100644 src/services/ferrite/tile.ts create mode 100644 tests/fixtures/ferrite/README.md create mode 100644 tests/fixtures/ferrite/airports-GD.json create mode 100644 tests/fixtures/ferrite/repeaters-FJ.json create mode 100644 tests/fixtures/ferrite/tafl-BP91.json create mode 100644 tests/unit/ferriteData.test.ts diff --git a/src/services/ferrite/client.ts b/src/services/ferrite/client.ts new file mode 100644 index 00000000..9a9796e0 --- /dev/null +++ b/src/services/ferrite/client.ts @@ -0,0 +1,130 @@ +/** + * Channel data from data.ferritefw.dev: Canada's licensed sites (the TAFL), the + * US's (the FCC), the world's airport frequencies and amateur repeaters, rebuilt + * daily and split into map tiles so a search near a place downloads only the + * tiles around it. It sends `Access-Control-Allow-Origin: *`, so the site and + * every preview read it directly. + * + * Like the datasets it replaces, it needs the internet: the offline build has + * never carried them. + */ +import { calculateDistance } from '../repeaterFinder'; +import type { ProgressCallback } from '../jsonLoader'; +import { boxAround, cellOverlaps, locatorBounds, locatorsAround, type LocatorLevel } from './maidenhead'; +import { decodeFerriteTile, type FerriteRow, type FerriteTile } from './tile'; + +export const FERRITE_DATA_URL = 'https://data.ferritefw.dev'; + +export type FerriteSource = 'tafl' | 'fcc' | 'airports' | 'repeaters'; + +export interface FerriteSourceIndex { + source: string; + title: string; + source_date: string; + licence: string; + licence_url: string; + attribution: string; + format: string; + /** 2: tiles are fields (CN); 4: squares (CN89), with busy ones as subsquares. */ + level: 2 | 4; + rows: number; + /** Tile name → row count. Only tiles with rows exist. */ + tiles: Record; + /** Squares published only as their 6-character subsquares. */ + split: string[]; +} + +export type FerriteRowNear = FerriteRow & { distance: number; source: FerriteSource }; + +const TILE_FORMAT = 'columnar-1'; +const PARALLEL_FETCHES = 6; + +const indexCache = new Map>(); +const tileCache = new Map>(); + +async function fetchJson(path: string): Promise { + const url = `${FERRITE_DATA_URL}/${path}`; + let response: Response; + try { + response = await fetch(url); + } catch { + throw new Error(`Couldn't reach data.ferritefw.dev for ${path}. This search needs an internet connection.`); + } + if (!response.ok) throw new Error(`data.ferritefw.dev answered ${response.status} for ${path}.`); + return (await response.json()) as T; +} + +export function loadFerriteIndex(source: FerriteSource): Promise { + let index = indexCache.get(source); + if (!index) { + index = fetchJson(`${source}/index.json`).then((i) => { + if (i.format !== TILE_FORMAT) { + throw new Error(`data.ferritefw.dev's ${source} data is in format "${i.format}", which this version can't read.`); + } + return i; + }); + // A failure is not kept: the next search tries again. + index.catch(() => indexCache.delete(source)); + indexCache.set(source, index); + } + return index; +} + +function loadTile(source: FerriteSource, name: string): Promise { + const key = `${source}/${name}`; + let tile = tileCache.get(key); + if (!tile) { + tile = fetchJson(`${key}.json`).then(decodeFerriteTile); + tile.catch(() => tileCache.delete(key)); + tileCache.set(key, tile); + } + return tile; +} + +/** The tiles of a source that a circle can reach, by the index's own names. */ +export function tilesAround(index: FerriteSourceIndex, lat: number, lon: number, radiusMiles: number): string[] { + const box = boxAround(lat, lon, radiusMiles); + const names: string[] = []; + const split = new Set(index.split); + for (const cell of locatorsAround(lat, lon, radiusMiles, index.level as LocatorLevel)) { + if (split.has(cell)) { + for (const sub of Object.keys(index.tiles)) { + if (sub.length === 6 && sub.startsWith(cell) && cellOverlaps(locatorBounds(sub), box)) names.push(sub); + } + } else if (index.tiles[cell]) { + names.push(cell); + } + } + return names; +} + +/** Every row of a source within `radiusMiles` of a point, nearest first. */ +export async function findFerriteRowsNear( + source: FerriteSource, + lat: number, + lon: number, + radiusMiles: number, + onProgress?: ProgressCallback +): Promise { + const index = await loadFerriteIndex(source); + const names = tilesAround(index, lat, lon, radiusMiles); + const found: FerriteRowNear[] = []; + let done = 0; + const report = () => onProgress?.({ loaded: done, total: names.length, percent: names.length ? (done / names.length) * 100 : 100 }); + report(); + + const queue = [...names]; + const worker = async () => { + for (let name = queue.shift(); name !== undefined; name = queue.shift()) { + for (const row of await loadTile(source, name)) { + const distance = calculateDistance(lat, lon, row.lat, row.lon); + if (distance <= radiusMiles) found.push({ ...row, distance, source }); + } + done++; + report(); + } + }; + await Promise.all(Array.from({ length: Math.min(PARALLEL_FETCHES, names.length) }, worker)); + + return found.sort((a, b) => a.distance - b.distance); +} diff --git a/src/services/ferrite/maidenhead.ts b/src/services/ferrite/maidenhead.ts new file mode 100644 index 00000000..ccbcfcc3 --- /dev/null +++ b/src/services/ferrite/maidenhead.ts @@ -0,0 +1,95 @@ +/** + * Maidenhead grid locators, which name data.ferritefw.dev's tiles: a 2-character + * field (CN, 20° of longitude by 10° of latitude), a 4-character square (CN89, + * 2° by 1°), a 6-character subsquare (CN89kg, 5' by 2.5'). + */ + +const LEVEL_SIZE = { + 2: { lon: 20, lat: 10 }, + 4: { lon: 2, lat: 1 }, + 6: { lon: 2 / 24, lat: 1 / 24 }, +} as const; + +export type LocatorLevel = keyof typeof LEVEL_SIZE; + +/** The locator of the given length that contains a point. */ +export function locator(lat: number, lon: number, level: LocatorLevel): string { + // Clamp just inside the edges so the north pole and the antimeridian land in a cell. + const x = Math.min(Math.max(lon + 180, 0), 360 - 1e-9); + const y = Math.min(Math.max(lat + 90, 0), 180 - 1e-9); + let out = String.fromCharCode(65 + Math.floor(x / 20)) + String.fromCharCode(65 + Math.floor(y / 10)); + if (level >= 4) { + out += String(Math.floor((x % 20) / 2)) + String(Math.floor(y % 10)); + } + if (level >= 6) { + out += String.fromCharCode(97 + Math.floor(((x % 2) / 2) * 24)) + String.fromCharCode(97 + Math.floor((y % 1) * 24)); + } + return out; +} + +const MILES_PER_DEGREE_LAT = 69.0; + +export interface LatLonBox { + south: number; + north: number; + west: number; + east: number; +} + +/** The cell a 2-, 4- or 6-character locator names. */ +export function locatorBounds(loc: string): LatLonBox { + let west = (loc.charCodeAt(0) - 65) * 20 - 180; + let south = (loc.charCodeAt(1) - 65) * 10 - 90; + let w = 20; + let h = 10; + if (loc.length >= 4) { + west += Number(loc[2]) * 2; + south += Number(loc[3]); + w = 2; + h = 1; + } + if (loc.length >= 6) { + west += ((loc.charCodeAt(4) - 97) * 2) / 24; + south += (loc.charCodeAt(5) - 97) / 24; + w = 2 / 24; + h = 1 / 24; + } + return { south, north: south + h, west, east: west + w }; +} + +/** The box around a circle, in degrees. East and west may run past ±180. */ +export function boxAround(lat: number, lon: number, radiusMiles: number): LatLonBox { + const dLat = radiusMiles / MILES_PER_DEGREE_LAT; + const cosLat = Math.max(Math.cos((lat * Math.PI) / 180), 0.01); + const dLon = Math.min(radiusMiles / (MILES_PER_DEGREE_LAT * cosLat), 180); + return { south: lat - dLat, north: lat + dLat, west: lon - dLon, east: lon + dLon }; +} + +/** Whether a cell overlaps a box, with the box's longitudes taken around the globe. */ +export function cellOverlaps(cell: LatLonBox, box: LatLonBox): boolean { + if (cell.north < box.south || cell.south > box.north) return false; + return [-360, 0, 360].some((shift) => cell.east + shift >= box.west && cell.west + shift <= box.east); +} + +/** + * Every locator at `level` that a circle of `radiusMiles` around a point could + * touch: the cells overlapping its bounding box. Longitude wraps at ±180. + */ +export function locatorsAround(lat: number, lon: number, radiusMiles: number, level: LocatorLevel): string[] { + const { lon: cellLon, lat: cellLat } = LEVEL_SIZE[level]; + const dLat = radiusMiles / MILES_PER_DEGREE_LAT; + const cosLat = Math.max(Math.cos((lat * Math.PI) / 180), 0.01); + const dLon = Math.min(radiusMiles / (MILES_PER_DEGREE_LAT * cosLat), 180); + + const south = Math.max(lat - dLat, -90); + const north = Math.min(lat + dLat, 90); + const out = new Set(); + for (let y = Math.floor((south + 90) / cellLat); y * cellLat - 90 <= north; y++) { + const cellMidLat = Math.min(y * cellLat - 90 + cellLat / 2, 90); + for (let x = Math.floor((lon - dLon + 180) / cellLon); x * cellLon - 180 <= lon + dLon; x++) { + const wrapped = ((((x * cellLon + cellLon / 2) % 360) + 360) % 360) - 180; + out.add(locator(cellMidLat, wrapped, level)); + } + } + return [...out]; +} diff --git a/src/services/ferrite/tile.ts b/src/services/ferrite/tile.ts new file mode 100644 index 00000000..8ab3cbd2 --- /dev/null +++ b/src/services/ferrite/tile.ts @@ -0,0 +1,99 @@ +/** + * Reads one data.ferritefw.dev tile (format `columnar-1`). The format is in the + * data repository's README (github.com/FerriteFW/data): columns, one entry per + * row, with position and frequency stored as differences from the row before. + */ + +export interface FerriteTile { + /** Names, each once; `c` indexes it. */ + n: string[]; + c: number[]; + /** Latitude and longitude in 1/100,000 degree, as running differences. */ + a: number[]; + o: number[]; + /** Transmit frequency in half kHz, as running differences. */ + f: number[]; + /** 0: FM under 14 kHz, 1: FM 16-20 kHz, 3: unknown. Missing when all unknown. */ + m?: number[]; + /** 1: a mobile's frequency (often a repeater input). Missing when all 0. */ + s?: number[]; + /** Licensee category. Missing when all 0. */ + k?: number[]; + /** Repeaters: input minus output in half kHz, each row's own value. */ + d?: number[]; + /** Repeaters: tones once, then encode/decode indexes into them (-1 none). */ + pn?: string[]; + pe?: number[]; + pd?: number[]; + /** Airports: uses once (TWR, GND, ...), then an index per row (-1 none). */ + tn?: string[]; + t?: number[]; +} + +export type FerriteTone = { type: 'CTCSS'; hz: number } | { type: 'DCS'; code: number; inverted: boolean }; + +export interface FerriteRow { + name: string; + lat: number; + lon: number; + /** The frequency the station transmits on, in MHz. */ + mhz: number; + /** Narrow or wide FM, when the source says. */ + bandwidth?: '12.5kHz' | '25kHz'; + /** A mobile's frequency, not a base's or repeater's. */ + mobile: boolean; + category: number; + /** Repeaters: what the radio transmits on, minus `mhz`. */ + offsetMhz?: number; + /** Repeaters: the tone to send to open it, and the tone it sends. */ + encodeTone?: FerriteTone; + decodeTone?: FerriteTone; + /** Airports: TWR, GND, ATIS, CTAF, ... */ + use?: string; +} + +/** `100.0` → CTCSS 100 Hz; `D023` → DCS 23; `D023I` → DCS 23 inverted. */ +export function parseFerriteTone(tone: string | undefined): FerriteTone | undefined { + if (!tone) return undefined; + const dcs = /^D([0-7]{3})(I?)$/.exec(tone); + if (dcs) return { type: 'DCS', code: parseInt(dcs[1], 10), inverted: dcs[2] === 'I' }; + const hz = Number(tone); + return Number.isFinite(hz) && hz > 0 ? { type: 'CTCSS', hz } : undefined; +} + +function indexed(list: T[] | undefined, at: number | undefined): T | undefined { + return list && at !== undefined && at >= 0 ? list[at] : undefined; +} + +/** Every row of a tile, positions and frequencies summed back up. */ +export function decodeFerriteTile(tile: FerriteTile): FerriteRow[] { + const rows: FerriteRow[] = []; + let a = 0; + let o = 0; + let f = 0; + for (let i = 0; i < tile.c.length; i++) { + a += tile.a[i]; + o += tile.o[i]; + f += tile.f[i]; + const mode = tile.m?.[i]; + const row: FerriteRow = { + name: tile.n[tile.c[i]] ?? '', + lat: a / 1e5, + lon: o / 1e5, + mhz: f / 2000, + mobile: tile.s?.[i] === 1, + category: tile.k?.[i] ?? 0, + }; + if (mode === 0) row.bandwidth = '12.5kHz'; + else if (mode === 1) row.bandwidth = '25kHz'; + if (tile.d) row.offsetMhz = tile.d[i] / 2000; + const encode = parseFerriteTone(indexed(tile.pn, tile.pe?.[i])); + const decode = parseFerriteTone(indexed(tile.pn, tile.pd?.[i])); + if (encode) row.encodeTone = encode; + if (decode) row.decodeTone = decode; + const use = indexed(tile.tn, tile.t?.[i]); + if (use) row.use = use; + rows.push(row); + } + return rows; +} diff --git a/tests/fixtures/ferrite/README.md b/tests/fixtures/ferrite/README.md new file mode 100644 index 00000000..96411e92 --- /dev/null +++ b/tests/fixtures/ferrite/README.md @@ -0,0 +1,5 @@ +Tiles from https://data.ferritefw.dev, saved 2026-11-12, for `tests/unit/ferriteData.test.ts`. + +- `tafl-BP91.json`: contains information licensed under the Open Government Licence – Canada. Source: Innovation, Science and Economic Development Canada, Spectrum Management System authorization data extract. +- `airports-GD.json`: airport data from OurAirports (ourairports.com), public domain. +- `repeaters-FJ.json`: repeater data from HearHam.com (user-contributed). diff --git a/tests/fixtures/ferrite/airports-GD.json b/tests/fixtures/ferrite/airports-GD.json new file mode 100644 index 00000000..05264a01 --- /dev/null +++ b/tests/fixtures/ferrite/airports-GD.json @@ -0,0 +1 @@ +{"n":["EGYP","SFAL"],"c":[0,0,0,0,1],"a":[-5182264,0,0,0,13694],"o":[-5844578,0,0,0,66818],"f":[237000,23600,2400,3700,-30500],"tn":["APP","ARR","GND","TWR"],"t":[0,2,1,3,3]} \ No newline at end of file diff --git a/tests/fixtures/ferrite/repeaters-FJ.json b/tests/fixtures/ferrite/repeaters-FJ.json new file mode 100644 index 00000000..c5b737ae --- /dev/null +++ b/tests/fixtures/ferrite/repeaters-FJ.json @@ -0,0 +1 @@ +{"n":["HK3LRB2","HK4RAU","HK6REC","HP1GRE"],"c":[0,2,1,3],"a":[462893,19382,139608,277078],"o":[-7405111,-164053,10173,-391006],"f":[294180,-2120,1290,-2550],"d":[1200,-1200,-1200,0],"pn":["85.4","100.0","131.8","156.7"],"pe":[2,0,1,3],"pd":[2,-1,-1,-1]} \ No newline at end of file diff --git a/tests/fixtures/ferrite/tafl-BP91.json b/tests/fixtures/ferrite/tafl-BP91.json new file mode 100644 index 00000000..5bd189b8 --- /dev/null +++ b/tests/fixtures/ferrite/tafl-BP91.json @@ -0,0 +1 @@ +{"n":["northwestel"],"c":[0,0,0,0,0,0],"a":[6196722,0,1584,0,222,0],"o":[-14041361,0,-7222,0,-5778,0],"f":[825875,10000,-10300,10000,-10350,10000],"m":[1,1,1,1,1,1]} \ No newline at end of file diff --git a/tests/unit/ferriteData.test.ts b/tests/unit/ferriteData.test.ts new file mode 100644 index 00000000..4e599864 --- /dev/null +++ b/tests/unit/ferriteData.test.ts @@ -0,0 +1,126 @@ +import { describe, it, expect, vi, afterEach } from 'vitest'; +import { readFileSync } from 'fs'; +import { join } from 'path'; +import { decodeFerriteTile, parseFerriteTone, type FerriteTile } from '../../src/services/ferrite/tile'; +import { locator, locatorBounds, locatorsAround } from '../../src/services/ferrite/maidenhead'; +import { tilesAround, findFerriteRowsNear, type FerriteSourceIndex } from '../../src/services/ferrite/client'; + +// Real tiles from data.ferritefw.dev, 2026-11-12. See tests/fixtures/ferrite/README.md. +const fixture = (name: string) => + JSON.parse(readFileSync(join(__dirname, '../fixtures/ferrite', name), 'utf8')) as FerriteTile; + +describe('reading a columnar-1 tile', () => { + it('sums positions and frequencies back up (TAFL, Yukon)', () => { + const rows = decodeFerriteTile(fixture('tafl-BP91.json')); + expect(rows).toHaveLength(6); + expect(rows[0]).toMatchObject({ name: 'northwestel', lat: 61.96722, lon: -140.41361, mhz: 412.9375, bandwidth: '25kHz' }); + expect(rows[1].mhz).toBeCloseTo(417.9375, 6); + expect(rows[2]).toMatchObject({ lat: 61.98306, lon: -140.48583 }); + expect(rows[2].mhz).toBeCloseTo(412.7875, 6); + expect(rows.every((r) => !r.mobile && r.category === 0)).toBe(true); + }); + + it('reads a repeater offset and its tones', () => { + const rows = decodeFerriteTile(fixture('repeaters-FJ.json')); + expect(rows.map((r) => r.name)).toEqual(['HK3LRB2', 'HK6REC', 'HK4RAU', 'HP1GRE']); + expect(rows[0].mhz).toBeCloseTo(147.09, 6); + expect(rows[0].offsetMhz).toBeCloseTo(0.6, 6); + expect(rows[0].encodeTone).toEqual({ type: 'CTCSS', hz: 131.8 }); + expect(rows[0].decodeTone).toEqual({ type: 'CTCSS', hz: 131.8 }); + expect(rows[1].offsetMhz).toBeCloseTo(-0.6, 6); + expect(rows[1].decodeTone).toBeUndefined(); + expect(rows[3].offsetMhz).toBe(0); + // HearHam's FM does not say how wide, so no bandwidth is claimed. + expect(rows[0].bandwidth).toBeUndefined(); + }); + + it("reads an airport's uses", () => { + const rows = decodeFerriteTile(fixture('airports-GD.json')); + expect(rows.map((r) => [r.name, r.use])).toEqual([ + ['EGYP', 'APP'], + ['EGYP', 'GND'], + ['EGYP', 'ARR'], + ['EGYP', 'TWR'], + ['SFAL', 'TWR'], + ]); + expect(rows[0].mhz).toBeCloseTo(118.5, 6); + expect(rows[0].lat).toBeCloseTo(-51.82264, 6); + }); + + it('reads CTCSS and DCS tones in the forms the README gives', () => { + expect(parseFerriteTone('100.0')).toEqual({ type: 'CTCSS', hz: 100 }); + expect(parseFerriteTone('D023')).toEqual({ type: 'DCS', code: 23, inverted: false }); + expect(parseFerriteTone('D754I')).toEqual({ type: 'DCS', code: 754, inverted: true }); + expect(parseFerriteTone(undefined)).toBeUndefined(); + expect(parseFerriteTone('D089')).toBeUndefined(); + }); +}); + +describe('Maidenhead tiles', () => { + it('names the field, square and subsquare a point is in', () => { + // Vancouver. + expect(locator(49.2827, -123.1207, 2)).toBe('CN'); + expect(locator(49.2827, -123.1207, 4)).toBe('CN89'); + expect(locator(49.2827, -123.1207, 6)).toBe('CN89kg'); + expect(locator(61.96722, -140.41361, 4)).toBe('BP91'); + }); + + it('gives a locator back its cell', () => { + expect(locatorBounds('CN89')).toEqual({ south: 49, north: 50, west: -124, east: -122 }); + const sub = locatorBounds('CN89kg'); + expect(sub.south).toBeLessThanOrEqual(49.2827); + expect(sub.north).toBeGreaterThan(49.2827); + }); + + it('covers a circle that crosses square edges', () => { + // 50 miles round Vancouver reaches CN88 to the south, CN79 to the west and + // CO80 to the north, and stops just short of CN99's edge at 122° W. + const cells = locatorsAround(49.2827, -123.1207, 50, 4); + expect(cells.sort()).toEqual(['CN78', 'CN79', 'CN88', 'CN89', 'CO70', 'CO80']); + expect(locatorsAround(49.2827, -123.1207, 60, 4)).toContain('CN99'); + }); + + it('wraps at the antimeridian', () => { + const cells = locatorsAround(-17.7, 179.9, 50, 2); + expect(cells).toEqual(expect.arrayContaining(['RH', 'AH'])); + }); +}); + +describe('picking tiles from an index', () => { + const index: FerriteSourceIndex = { + source: 'tafl', title: '', source_date: '', licence: '', licence_url: '', attribution: '', + format: 'columnar-1', level: 4, rows: 0, + tiles: { CN89: 10, CN88: 4, FN35fm: 3, FN35fl: 2, FN35aa: 1 }, + split: ['FN35'], + }; + + it('only asks for tiles that exist', () => { + expect(tilesAround(index, 49.2827, -123.1207, 50).sort()).toEqual(['CN88', 'CN89']); + }); + + it('asks a split square for the subsquares near the point, not all of them', () => { + // Montreal is in FN35, which is published as subsquares. + const names = tilesAround(index, 45.5017, -73.5673, 5); + expect(names).toContain('FN35fm'); + expect(names).not.toContain('FN35aa'); + }); +}); + +describe('searching near a point', () => { + afterEach(() => vi.unstubAllGlobals()); + + it('keeps rows inside the radius, nearest first, and says which source', async () => { + const index = { source: 'tafl', format: 'columnar-1', level: 4, tiles: { BP91: 6 }, split: [] }; + const fetchMock = vi.fn(async (url: string) => ({ + ok: true, + status: 200, + json: async () => (url.endsWith('index.json') ? index : fixture('tafl-BP91.json')), + })); + vi.stubGlobal('fetch', fetchMock); + const rows = await findFerriteRowsNear('tafl', 61.9831, -140.4858, 1); + expect(rows.length).toBeGreaterThan(0); + expect(rows.every((r) => r.distance <= 1 && r.source === 'tafl')).toBe(true); + expect(rows[0].distance).toBeLessThanOrEqual(rows[rows.length - 1].distance); + expect(fetchMock).toHaveBeenCalledWith('https://data.ferritefw.dev/tafl/BP91.json'); + }); +}); From df72b7c61c3e3aac3bdc95756fcd6760299d47bb Mon Sep 17 00:00:00 2001 From: Alex Harvey Date: Thu, 12 Nov 2026 18:30:43 -0700 Subject: [PATCH 2/3] Take licensed sites and airports from data.ferritefw.dev The licensed-sites search reads Canada's TAFL and now the US FCC's ULS too, and airports read OurAirports, all rebuilt daily and fetched tile by tile around the search instead of as 12 MB of files we never refreshed. Channels take the licence's own width where it gives one. tafl_min.json and airports_min.json leave the repo. The site root keeps serving them, frozen at v2026.10.1, for older builds and offline copies that still ask neonplug.app for them; /dev/ and the previews no longer carry them. --- .github/workflows/deploy.yml | 9 +- CLAUDE.md | 14 ++- src/components/import/SmartImportTab.tsx | 14 +-- src/components/import/sources/TaflSource.tsx | 22 ++-- src/data/README.md | 25 +---- src/data/airportsData.ts | 101 +++++------------ src/data/airports_min.json | 1 - src/data/taflData.ts | 111 +++++++------------ src/data/tafl_min.json | 1 - src/services/jsonLoader.ts | 2 +- src/services/taflChannels.ts | 3 +- 11 files changed, 111 insertions(+), 192 deletions(-) delete mode 100644 src/data/airports_min.json delete mode 100644 src/data/tafl_min.json diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bf50a1cc..e9d64e6f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -67,7 +67,7 @@ jobs: set -euo pipefail dest="$1" mkdir -p "$dest" - for f in rptrs.json tafl_min.json airports_min.json radioid-users.csv; do + for f in rptrs.json radioid-users.csv; do cp "src/data/$f" "$dest/$f" done EOF @@ -137,6 +137,13 @@ jobs: run: | /tmp/copy-data.sh dist_root /tmp/copy-data.sh dist_dev + # Licensed sites and airports now come from data.ferritefw.dev. Builds up + # to 2026.10.1, including every offline copy of one, still fetch these + # two from https://neonplug.app/, so the root keeps serving them, frozen + # at that release. Only the root: /dev/ and the previews don't need them. + for f in tafl_min.json airports_min.json; do + git show "v2026.10.1:src/data/$f" > "dist_root/$f" + done - name: List open PRs and build previews env: diff --git a/CLAUDE.md b/CLAUDE.md index 9d42162a..4c8812c0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -61,7 +61,8 @@ the site wholesale): | `/` | the **latest release asset**, downloaded not rebuilt — falls back to `main` until the first tag | | `/dev/` | latest `main` | | `/test//` | every open PR | -| `/rptrs.json`, `/tafl_min.json`, `/airports_min.json`, `/radioid-users.csv` | always from `main` | +| `/rptrs.json`, `/radioid-users.csv` | always from `main` | +| `/tafl_min.json`, `/airports_min.json` | root only, frozen at `v2026.10.1`, for builds up to that release | Two deliberate decisions there. **The root is the published artifact, not a rebuild of the tag** — for software that writes to radios, the file users download offline and the file the site serves must be @@ -69,14 +70,19 @@ byte-identical. **Datasets are not pinned to a release** — every loader tries `https://neonplug.app/` *first*, so this data is already "latest from main" by design; pinning would freeze repeater/DMR-user data at tag time and add ~31 MB to every release. -**The dataset fallback chains are not symmetric** — `jsonLoader.ts` (`rptrs.json`, `tafl_min.json`, -`airports_min.json`) falls back through relative paths to `raw.githubusercontent.com` on `main`. +**Airports, licensed sites (TAFL + FCC) and amateur repeaters come from +[data.ferritefw.dev](https://data.ferritefw.dev)** (`services/ferrite/`), fetched tile by tile around +the search, straight from the browser (it sends `Access-Control-Allow-Origin: *`). Not in the repo, +not deployed, and like the datasets below they need the internet. + +**The dataset fallback chains are not symmetric** — `jsonLoader.ts` (`rptrs.json`) +falls back through relative paths to `raw.githubusercontent.com` on `main`. `ContactsTab.tsx` is the *only* loader for `radioid-users.csv` (16 MB, the largest) and has **no GitHub fallback at all** — `neonplug.app` plus four relative paths, then it throws. Don't assume the GitHub safety net covers contacts. Because the absolute `neonplug.app` URL always wins, the per-PR and `/dev/` dataset copies are -**unreadable dead weight** (~31 MB each, against Pages' 1 GB site limit) — see `TODO-RELEASE.md` D4. +**unreadable dead weight** (~19 MB each, against Pages' 1 GB site limit) — see `TODO-RELEASE.md` D4. **Two independent version numbers — don't conflate them:** diff --git a/src/components/import/SmartImportTab.tsx b/src/components/import/SmartImportTab.tsx index 298b2f4b..f589c431 100644 --- a/src/components/import/SmartImportTab.tsx +++ b/src/components/import/SmartImportTab.tsx @@ -69,8 +69,8 @@ export const SmartImportTab: React.FC = () => { : (searchAirports || searchTafl); if (!hasSearchType) { setError(supportsDigital - ? 'Please select at least one search type (Airports, TAFL, or DMR Repeaters)' - : 'Please select at least one search type (Airports or TAFL)'); + ? 'Please select at least one search type (Airports, Licensed sites, or DMR Repeaters)' + : 'Please select at least one search type (Airports or Licensed sites)'); return; } @@ -128,7 +128,7 @@ export const SmartImportTab: React.FC = () => { ); setTaflEntries(nearbyTafl); setIsSearchingTafl(false); - return ['TAFL entries', nearbyTafl.length]; + return ['licensed sites', nearbyTafl.length]; })() ); } @@ -192,8 +192,8 @@ export const SmartImportTab: React.FC = () => { Location-Based Search

{supportsDigital - ? 'Search for nearby airports, TAFL entries, and DMR repeaters based on your location' - : 'Search for nearby airports and TAFL entries based on your location'} + ? 'Search for nearby airports, licensed sites and DMR repeaters based on your location' + : 'Search for nearby airports and licensed sites based on your location'}

@@ -327,7 +327,7 @@ export const SmartImportTab: React.FC = () => { onChange={(e) => setSearchTafl(e.target.checked)} className="mr-2" /> - TAFL (Transport Canada) + Licensed sites (Canada TAFL, US FCC) {supportsDigital && (