Merge upstream/main into fix/drone-airspace

Move the share-link token to 6 (3 is gnss-integrity), build altitude
ranges from LOWER/UPPER VAL, UOM and CODE, mark card and legend strings
for translation, rename the layer to Prohibited & Restricted Airspace,
move the changelog entry to changelog.d, and keep the layer voice-off
while the Realtime prompt is at its budget.
This commit is contained in:
Matt Van Horn committed 2026-10-27 05:06:05 -07:00
commit 4c2159a70a
1387 files changed
+160157 -23954

No files matched your search

+11 -8
View File
@@ -1,5 +1,7 @@
/** Card model for one selected special-use airspace zone. Pure — no Cesium types. */
import { t } from '../../i18n/index.js';
export const DRONE_AIRSPACE_OVERLAY_SOURCE_ID = 'drone-airspace';
/** Fill/line CSS color for a zone by TYPE_CODE. */
@@ -46,11 +48,11 @@ export function droneAirspaceAnchorDegrees(polygons) {
}
function altitudeLine(row) {
const lower = row.lowerDesc;
const upper = row.upperDesc;
if (lower && upper) return `${lower} – ${upper}`;
if (upper) return `up to ${upper}`;
if (lower) return `from ${lower}`;
const lower = row.lowerAltitude;
const upper = row.upperAltitude;
if (lower && upper) return t('{lower} to {upper}', { lower, upper });
if (upper) return t('Up to {upper}', { upper });
if (lower) return t('From {lower}', { lower });
return null;
}
@@ -66,7 +68,7 @@ function placeLine(row) {
* @returns {Object} World-overlay entry without `position`.
*/
export function buildDroneAirspaceCard(row) {
const facts = [row.type || row.typeCode].filter(Boolean);
const facts = [row.type ? t(row.type) : row.typeCode].filter(Boolean);
const altitude = altitudeLine(row);
if (altitude) facts.push(altitude);
if (row.timesOfUse) facts.push(row.timesOfUse);
@@ -75,9 +77,10 @@ export function buildDroneAirspaceCard(row) {
const place = placeLine(row);
if (place) details.push(place);
if (row.agency) details.push(row.agency);
details.push('Informational only · not for flight planning');
details.push(t('Informational only · not for flight planning'));
const title = `${(row.type || 'SUA').toUpperCase()} · ${row.name || 'Unnamed zone'}`;
const type = row.type ? t(row.type) : 'SUA';
const title = `${type.toUpperCase()} · ${row.name || t('Unnamed zone')}`;
return {
id: `drone-airspace-card:${row.stableId}`,
selected: true,
+5 -5
View File
@@ -32,8 +32,8 @@ test('a prohibited zone card names the type, altitudes and the disclaimer', () =
name: 'P-56',
typeCode: 'P',
type: 'Prohibited',
lowerDesc: 'SFC',
upperDesc: 'TNI',
lowerAltitude: 'SFC',
upperAltitude: '18,000 ft MSL',
timesOfUse: 'CONTINUOUS',
agency: 'WASHINGTON CENTER',
city: 'WASHINGTON',
@@ -42,7 +42,7 @@ test('a prohibited zone card names the type, altitudes and the disclaimer', () =
assert.equal(card.id, 'drone-airspace-card:310');
assert.equal(card.title, 'PROHIBITED · P-56');
assert.deepEqual(card.details, [
'Prohibited · SFC – TNI · CONTINUOUS',
'Prohibited · SFC to 18,000 ft MSL · CONTINUOUS',
'WASHINGTON, DC',
'WASHINGTON CENTER',
'Informational only · not for flight planning',
@@ -58,8 +58,8 @@ test('missing attributes degrade to available facts instead of placeholders', ()
name: null,
typeCode: 'R',
type: 'Restricted',
lowerDesc: null,
upperDesc: null,
lowerAltitude: null,
upperAltitude: null,
timesOfUse: null,
agency: null,
city: null,
+9 -6
View File
@@ -1,4 +1,5 @@
import * as Cesium from 'cesium';
import { msg, t } from '../../i18n/index.js';
import {
DRONE_AIRSPACE_OVERLAY_SOURCE_ID,
droneAirspaceAnchorDegrees,
@@ -137,7 +138,7 @@ export function createDroneAirspaceLayer({
const layer = {
id: 'drone-airspace',
name: 'Drone Restrictions',
name: 'Prohibited & Restricted Airspace',
icon: '🚫',
source: 'FAA SUA',
updateInterval: 3600000,
@@ -248,7 +249,8 @@ export function createDroneAirspaceLayer({
if (request.signal.aborted || _request !== request || !_enabled)
return false;
console.warn('[Data:DroneAirspace] Fetch error:', e);
_lastError = e?.message || 'Drone airspace source unavailable';
_lastError =
e?.message || msg('Restricted airspace source unavailable');
return false;
} finally {
if (_request === request) _request = null;
@@ -294,8 +296,8 @@ export function createDroneAirspaceLayer({
getRowControls() {
const bands = [
{ label: 'Prohibited (P)', color: droneAirspaceAccent('P') },
{ label: 'Restricted (R)', color: droneAirspaceAccent('R') },
{ label: t('Prohibited (P)'), color: droneAirspaceAccent('P') },
{ label: t('Restricted (R)'), color: droneAirspaceAccent('R') },
];
return {
chips: [],
@@ -306,8 +308,9 @@ export function createDroneAirspaceLayer({
).length,
...(index === 0
? {
blurb:
'FAA special-use airspace. Informational only — not a substitute for official UAS flight-planning tools (B4UFLY / LAANC).',
blurb: t(
'FAA prohibited and restricted special-use airspace only, not the UAS Facility Map or UAS flight restrictions. Informational only — not a substitute for official UAS flight-planning tools (B4UFLY / LAANC).',
),
}
: {}),
})),
+2 -2
View File
@@ -66,8 +66,8 @@ const row = {
name: 'P-56',
typeCode: 'P',
type: 'Prohibited',
lowerDesc: 'SFC',
upperDesc: 'TNI',
lowerAltitude: 'SFC',
upperAltitude: '18,000 ft MSL',
timesOfUse: 'CONTINUOUS',
agency: null,
city: 'WASHINGTON',
+34 -4
View File
@@ -4,9 +4,11 @@
* the whole snapshot: a single degenerate polygon must never blank the layer.
*/
import { msg } from '../../i18n/marker.js';
const TYPE_LABELS = Object.freeze({
P: 'Prohibited',
R: 'Restricted',
P: msg('Prohibited'),
R: msg('Restricted'),
});
const finiteOrNull = (value) => (Number.isFinite(value) ? value : null);
@@ -46,6 +48,26 @@ function normalizePolygons(geometry) {
return result;
}
/**
* One SUA altitude limit from its VAL/UOM/CODE triple, in aviation notation:
* `SFC`, `500 ft AGL`, `5,000 ft MSL`, `FL180` or `Unlimited`. The *_DESC
* fields are inclusion qualifiers (TI/TNI/ANI), not altitudes. Returns null
* when the triple does not describe a limit.
*/
export function droneAirspaceAltitude(value, uom, code) {
const unit = textOrNull(uom)?.toUpperCase() ?? null;
const reference = textOrNull(code)?.toUpperCase() ?? null;
if (reference === 'UNLTD') return 'Unlimited';
const number = Number(value);
if (value == null || value === '' || !Number.isFinite(number) || number < 0)
return null;
if (unit === 'FL' || reference === 'STD') return `FL${Math.round(number)}`;
const feet = `${Math.round(number).toLocaleString('en-US')} ft`;
if (reference === 'SFC') return number === 0 ? 'SFC' : `${feet} AGL`;
if (reference === 'MSL') return `${feet} MSL`;
return unit === 'FT' || unit == null ? feet : null;
}
/** Human label for a TYPE_CODE, or null when the code is not in the pack. */
export function droneAirspaceTypeLabel(typeCode) {
return TYPE_LABELS[typeCode] || null;
@@ -84,8 +106,16 @@ export function normalizeDroneAirspaceSnapshot(geojson) {
name: textOrNull(properties.NAME),
typeCode,
type,
lowerDesc: textOrNull(properties.LOWER_DESC),
upperDesc: textOrNull(properties.UPPER_DESC),
lowerAltitude: droneAirspaceAltitude(
properties.LOWER_VAL,
properties.LOWER_UOM,
properties.LOWER_CODE,
),
upperAltitude: droneAirspaceAltitude(
properties.UPPER_VAL,
properties.UPPER_UOM,
properties.UPPER_CODE,
),
timesOfUse: textOrNull(properties.TIMESOFUSE),
agency: textOrNull(properties.CONT_AGENT),
city: textOrNull(properties.CITY),
+43 -3
View File
@@ -1,6 +1,7 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
droneAirspaceAltitude,
droneAirspaceTypeLabel,
normalizeDroneAirspaceSnapshot,
} from './records.js';
@@ -20,7 +21,13 @@ function feature(overrides = {}) {
NAME: 'P-56',
TYPE_CODE: 'P',
UPPER_DESC: 'TNI',
LOWER_DESC: 'SFC',
UPPER_VAL: '18000',
UPPER_UOM: 'FT',
UPPER_CODE: 'MSL',
LOWER_DESC: null,
LOWER_VAL: '0',
LOWER_UOM: 'FT',
LOWER_CODE: 'SFC',
TIMESOFUSE: 'CONTINUOUS',
CONT_AGENT: 'WASHINGTON CENTER',
CITY: 'WASHINGTON',
@@ -52,8 +59,8 @@ test('a valid snapshot yields one row per prohibited or restricted zone', () =>
name: 'P-56',
typeCode: 'P',
type: 'Prohibited',
lowerDesc: 'SFC',
upperDesc: 'TNI',
lowerAltitude: 'SFC',
upperAltitude: '18,000 ft MSL',
timesOfUse: 'CONTINUOUS',
agency: 'WASHINGTON CENTER',
city: 'WASHINGTON',
@@ -64,6 +71,39 @@ test('a valid snapshot yields one row per prohibited or restricted zone', () =>
assert.equal(rows[1].typeCode, 'R');
});
test('altitudes come from VAL/UOM/CODE, not the TI/TNI/ANI qualifiers', () => {
// P-40 and R-2508 as the FAA service publishes them.
assert.equal(droneAirspaceAltitude('0', 'FT', 'SFC'), 'SFC');
assert.equal(droneAirspaceAltitude('5000', 'FT', 'MSL'), '5,000 ft MSL');
assert.equal(droneAirspaceAltitude('20000', 'FT', 'MSL'), '20,000 ft MSL');
assert.equal(droneAirspaceAltitude('-9998', null, 'UNLTD'), 'Unlimited');
assert.equal(droneAirspaceAltitude('1500', 'FT', 'SFC'), '1,500 ft AGL');
assert.equal(droneAirspaceAltitude('180', 'FL', 'STD'), 'FL180');
assert.equal(droneAirspaceAltitude('10000', 'FT', null), '10,000 ft');
assert.equal(droneAirspaceAltitude(null, null, null), null);
assert.equal(droneAirspaceAltitude('-9998', 'FT', 'MSL'), null);
const [row] = normalizeDroneAirspaceSnapshot({
features: [
feature({
properties: {
NAME: 'R-2508',
TYPE_CODE: 'R',
OBJECTID: 400,
UPPER_DESC: null,
UPPER_VAL: '-9998',
UPPER_UOM: null,
UPPER_CODE: 'UNLTD',
LOWER_VAL: '20000',
LOWER_UOM: 'FT',
LOWER_CODE: 'MSL',
},
}),
],
});
assert.equal(row.lowerAltitude, '20,000 ft MSL');
assert.equal(row.upperAltitude, 'Unlimited');
});
test('MOA, warning and advisory codes are dropped, as are bad geometries', () => {
const rows = normalizeDroneAirspaceSnapshot({
features: [