mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
fix(cyclones): cards leave the map with their storms; null advisory values are left out
The world overlay drew on desynchronized 2D contexts. After a frame that only clears, Chrome could present an earlier buffer, so storm cards and forecast lead-hour labels stayed on screen when a snapshot without storms (or an unavailable one) replaced them, although the overlay held no entries and cleared every frame. Both overlay surfaces now use ordinary contexts. The storm readout no longer prints "Unavailable" for a null value: an advisory without pressure shows only its maximum sustained wind, one without wind only its pressure, and one without either has no intensity line. The advisory link stays hidden when an advisory has no link.
This commit is contained in:
1 parent
9b8f45e62b
commit
7b4b4d4184
17 files changed
+128
-16
No files matched your search
@@ -1496,6 +1496,8 @@
|
||||
},
|
||||
"Position as of {time}": "الموضع عند {time}",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "أقصى سرعة للرياح المستمرة: {wind} · الضغط: {pressure}",
|
||||
"Maximum sustained wind: {wind}": "أقصى سرعة للرياح المستمرة: {wind}",
|
||||
"Pressure: {pressure}": "الضغط: {pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · النشرة رقم {number} · صدرت {time}",
|
||||
"No active NHC/CPHC systems": "لا توجد أنظمة مدارية نشطة لدى NHC/CPHC",
|
||||
"Advisories unavailable": "النشرات غير متاحة",
|
||||
|
||||
@@ -1432,6 +1432,8 @@
|
||||
},
|
||||
"Position as of {time}": "Position, Stand {time}",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "Maximaler Dauerwind: {wind} · Luftdruck: {pressure}",
|
||||
"Maximum sustained wind: {wind}": "Maximaler Dauerwind: {wind}",
|
||||
"Pressure: {pressure}": "Luftdruck: {pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · Lagebericht {number} · ausgegeben {time}",
|
||||
"No active NHC/CPHC systems": "Keine aktiven NHC/CPHC-Systeme",
|
||||
"Advisories unavailable": "Lageberichte nicht verfügbar",
|
||||
|
||||
@@ -1333,6 +1333,8 @@
|
||||
},
|
||||
"Position as of {time}": "Posición a las {time}",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "Viento máximo sostenido: {wind} · Presión: {pressure}",
|
||||
"Maximum sustained wind: {wind}": "Viento máximo sostenido: {wind}",
|
||||
"Pressure: {pressure}": "Presión: {pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · Aviso {number} · emitido {time}",
|
||||
"No active NHC/CPHC systems": "Sin sistemas activos del NHC/CPHC",
|
||||
"Advisories unavailable": "Avisos no disponibles",
|
||||
|
||||
@@ -648,6 +648,8 @@
|
||||
},
|
||||
"Position as of {time}": "Position au {time}",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "Vent maximal soutenu : {wind} · Pression : {pressure}",
|
||||
"Maximum sustained wind: {wind}": "Vent maximal soutenu : {wind}",
|
||||
"Pressure: {pressure}": "Pression : {pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · Bulletin {number} · émis le {time}",
|
||||
"No active NHC/CPHC systems": "Aucun système actif NHC/CPHC",
|
||||
"Advisories unavailable": "Bulletins indisponibles",
|
||||
|
||||
@@ -553,6 +553,8 @@
|
||||
},
|
||||
"Position as of {time}": "מיקום נכון ל-{time}",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "רוח מתמשכת מרבית: {wind} · לחץ: {pressure}",
|
||||
"Maximum sustained wind: {wind}": "רוח מתמשכת מרבית: {wind}",
|
||||
"Pressure: {pressure}": "לחץ: {pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · עדכון {number} · פורסם {time}",
|
||||
"No active NHC/CPHC systems": "אין מערכות NHC/CPHC פעילות",
|
||||
"Advisories unavailable": "עדכונים אינם זמינים",
|
||||
|
||||
@@ -648,6 +648,8 @@
|
||||
},
|
||||
"Position as of {time}": "Posizione aggiornata al {time}",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "Vento massimo sostenuto: {wind} · Pressione: {pressure}",
|
||||
"Maximum sustained wind: {wind}": "Vento massimo sostenuto: {wind}",
|
||||
"Pressure: {pressure}": "Pressione: {pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · Bollettino {number} · emesso {time}",
|
||||
"No active NHC/CPHC systems": "Nessun sistema NHC/CPHC attivo",
|
||||
"Advisories unavailable": "Bollettini non disponibili",
|
||||
|
||||
@@ -626,6 +626,8 @@
|
||||
},
|
||||
"Position as of {time}": "{time}時点の位置",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "最大持続風速:{wind} · 気圧:{pressure}",
|
||||
"Maximum sustained wind: {wind}": "最大持続風速:{wind}",
|
||||
"Pressure: {pressure}": "気圧:{pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · 第{number}報 · {time}発表",
|
||||
"No active NHC/CPHC systems": "NHC/CPHCが監視中のサイクロンはありません",
|
||||
"Advisories unavailable": "サイクロン情報を取得できません",
|
||||
|
||||
@@ -648,6 +648,8 @@
|
||||
},
|
||||
"Position as of {time}": "Posição em {time}",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "Vento máximo sustentado: {wind} · Pressão: {pressure}",
|
||||
"Maximum sustained wind: {wind}": "Vento máximo sustentado: {wind}",
|
||||
"Pressure: {pressure}": "Pressão: {pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · Boletim {number} · emitido em {time}",
|
||||
"No active NHC/CPHC systems": "Nenhum sistema ativo do NHC/CPHC",
|
||||
"Advisories unavailable": "Boletins indisponíveis",
|
||||
|
||||
@@ -1355,6 +1355,8 @@
|
||||
},
|
||||
"Position as of {time}": "Положение на {time}",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "Макс. устойчивый ветер: {wind} · Давление: {pressure}",
|
||||
"Maximum sustained wind: {wind}": "Макс. устойчивый ветер: {wind}",
|
||||
"Pressure: {pressure}": "Давление: {pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · Сводка № {number} · выпущена {time}",
|
||||
"No active NHC/CPHC systems": "Нет активных систем NHC/CPHC",
|
||||
"Advisories unavailable": "Сводки недоступны",
|
||||
|
||||
@@ -1354,6 +1354,8 @@
|
||||
},
|
||||
"Position as of {time}": "Position per {time}",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "Högsta medelvind: {wind} · Lufttryck: {pressure}",
|
||||
"Maximum sustained wind: {wind}": "Högsta medelvind: {wind}",
|
||||
"Pressure: {pressure}": "Lufttryck: {pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · Bulletin {number} · utfärdad {time}",
|
||||
"No active NHC/CPHC systems": "Inga aktiva NHC/CPHC-system",
|
||||
"Advisories unavailable": "Bulletiner otillgängliga",
|
||||
|
||||
@@ -659,6 +659,8 @@
|
||||
},
|
||||
"Position as of {time}": "Положення на {time}",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "Макс. середня швидкість вітру: {wind} · Тиск: {pressure}",
|
||||
"Maximum sustained wind: {wind}": "Макс. середня швидкість вітру: {wind}",
|
||||
"Pressure: {pressure}": "Тиск: {pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · Зведення № {number} · випущено {time}",
|
||||
"No active NHC/CPHC systems": "Немає активних систем NHC/CPHC",
|
||||
"Advisories unavailable": "Зведення недоступні",
|
||||
|
||||
@@ -625,6 +625,8 @@
|
||||
},
|
||||
"Position as of {time}": "位置(截至 {time})",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "最大持续风速:{wind} · 气压:{pressure}",
|
||||
"Maximum sustained wind: {wind}": "最大持续风速:{wind}",
|
||||
"Pressure: {pressure}": "气压:{pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · 第 {number} 号公告 · 发布于 {time}",
|
||||
"No active NHC/CPHC systems": "当前没有活跃的 NHC/CPHC 气旋",
|
||||
"Advisories unavailable": "公告不可用",
|
||||
|
||||
@@ -624,6 +624,8 @@
|
||||
},
|
||||
"Position as of {time}": "位置(截至 {time})",
|
||||
"Maximum sustained wind: {wind} · Pressure: {pressure}": "最大持續風速:{wind} · 氣壓:{pressure}",
|
||||
"Maximum sustained wind: {wind}": "最大持續風速:{wind}",
|
||||
"Pressure: {pressure}": "氣壓:{pressure}",
|
||||
"{name} · {classification} · Advisory {number} · issued {time}": "{name} · {classification} · 第 {number} 號公告 · 發布於 {time}",
|
||||
"No active NHC/CPHC systems": "當前沒有活躍的 NHC/CPHC 氣旋",
|
||||
"Advisories unavailable": "公告不可用",
|
||||
|
||||
@@ -59,8 +59,22 @@ const classificationName = (code) =>
|
||||
Object.hasOwn(CLASSIFICATION_NAMES, code)
|
||||
? t(CLASSIFICATION_NAMES[code])
|
||||
: code;
|
||||
const number = (value, unit) =>
|
||||
value === null ? t('Unavailable') : formatQuantity(value, unit);
|
||||
// A value the advisory leaves out (null) is left out of the line too.
|
||||
const intensityText = (storm) => {
|
||||
const has = (value) => value !== null && value !== undefined;
|
||||
const wind = has(storm.windKt) ? formatQuantity(storm.windKt, 'kt') : null;
|
||||
const pressure = has(storm.pressureHpa)
|
||||
? formatQuantity(storm.pressureHpa, 'hPa')
|
||||
: null;
|
||||
if (wind && pressure)
|
||||
return t('Maximum sustained wind: {wind} · Pressure: {pressure}', {
|
||||
wind,
|
||||
pressure,
|
||||
});
|
||||
if (wind) return t('Maximum sustained wind: {wind}', { wind });
|
||||
if (pressure) return t('Pressure: {pressure}', { pressure });
|
||||
return '';
|
||||
};
|
||||
|
||||
/** Advisory status and coherent forecast geometry; selected through the shared row list. */
|
||||
export function createCyclonesLayer({
|
||||
@@ -424,12 +438,7 @@ export function createCyclonesLayer({
|
||||
const position = storm
|
||||
? t('Position as of {time}', { time: utc(storm.positionAt) })
|
||||
: '';
|
||||
const intensity = storm
|
||||
? t('Maximum sustained wind: {wind} · Pressure: {pressure}', {
|
||||
wind: number(storm.windKt, 'kt'),
|
||||
pressure: number(storm.pressureHpa, 'hPa'),
|
||||
})
|
||||
: '';
|
||||
const intensity = storm ? intensityText(storm) : '';
|
||||
const detail = storm
|
||||
? t('{name} · {classification} · Advisory {number} · issued {time}', {
|
||||
name: storm.name,
|
||||
@@ -479,7 +488,7 @@ export function createCyclonesLayer({
|
||||
text: intensity,
|
||||
},
|
||||
{ id: 'geometry', text: geometry, muted: true },
|
||||
]
|
||||
].filter((line) => line.text)
|
||||
: [],
|
||||
detail,
|
||||
status,
|
||||
@@ -511,7 +520,7 @@ export function createCyclonesLayer({
|
||||
]
|
||||
: [],
|
||||
info: storm
|
||||
? `${detail}\n${position}\n${intensity}\n${geometry}${status && status !== geometry ? '\n' + status : ''}\n${coverageText(snapshot.coverage)}`
|
||||
? `${detail}\n${position}\n${intensity ? intensity + '\n' : ''}${geometry}${status && status !== geometry ? '\n' + status : ''}\n${coverageText(snapshot.coverage)}`
|
||||
: `${detail}${status ? '\n' + status : ''}\n${coverageText(snapshot?.coverage)}`,
|
||||
infoTitle: t(
|
||||
'Select a storm on the map, or choose a storm in the list to select it and move the camera. Click empty map space to clear the selection. NOAA NHC/CPHC advisory context. The cone describes forecast center-track uncertainty, not storm size or the full hazard area. Forecast point labels are source lead hours, not times computed from advisory issuance. Geometry follows the surface; height is not weather altitude. Consult the official advisory.',
|
||||
|
||||
@@ -824,6 +824,59 @@ test('classification display expands known codes without altering the source or
|
||||
}
|
||||
}
|
||||
});
|
||||
// Quantities join number and unit with a no-break space.
|
||||
const plain = (text) => text?.replace(/\u00a0/g, ' ') ?? null;
|
||||
test('an advisory without pressure, movement or link leaves those values out', async () => {
|
||||
const record = {
|
||||
...storm(),
|
||||
windKt: 85,
|
||||
pressureHpa: null,
|
||||
movement: { directionDegrees: null, speedKt: null },
|
||||
advisoryUrl: null,
|
||||
};
|
||||
const h = harness({ getSnapshot: async () => snapshot([record]) });
|
||||
try {
|
||||
h.layer.enable();
|
||||
await h.layer.update();
|
||||
const { summary, info } = h.layer.getRowControls();
|
||||
const intensity = summary.lines.find((line) => line.id === 'intensity');
|
||||
assert.equal(plain(intensity.text), 'Maximum sustained wind: 85 kt');
|
||||
assert.deepEqual(
|
||||
summary.lines.map((line) => line.id),
|
||||
['position', 'intensity', 'geometry'],
|
||||
);
|
||||
assert.deepEqual(summary.actions, [], 'no advisory link to open');
|
||||
assert.ok(plain(info).includes('Maximum sustained wind: 85 kt\n'));
|
||||
for (const text of [info, ...summary.lines.map((line) => line.text)])
|
||||
assert.doesNotMatch(text, /Unavailable|Pressure/);
|
||||
} finally {
|
||||
h.layer.destroy();
|
||||
}
|
||||
});
|
||||
test('an advisory with only one of wind and pressure shows that one alone', async () => {
|
||||
for (const [values, expected] of [
|
||||
[{ windKt: null, pressureHpa: 990 }, 'Pressure: 990 hPa'],
|
||||
[
|
||||
{ windKt: 60, pressureHpa: 990 },
|
||||
'Maximum sustained wind: 60 kt · Pressure: 990 hPa',
|
||||
],
|
||||
[{ windKt: null, pressureHpa: null }, null],
|
||||
]) {
|
||||
const h = harness({
|
||||
getSnapshot: async () => snapshot([{ ...storm(), ...values }]),
|
||||
});
|
||||
try {
|
||||
h.layer.enable();
|
||||
await h.layer.update();
|
||||
const { summary, info } = h.layer.getRowControls();
|
||||
const intensity = summary.lines.find((line) => line.id === 'intensity');
|
||||
assert.equal(plain(intensity?.text), expected);
|
||||
assert.doesNotMatch(info, /Unavailable|\n\n/);
|
||||
} finally {
|
||||
h.layer.destroy();
|
||||
}
|
||||
}
|
||||
});
|
||||
test('advisory selection uses accessible row descriptors and shared camera handoff', async () => {
|
||||
const h = harness(
|
||||
{ getSnapshot: async () => snapshot([storm(), storm('ep162026')]) },
|
||||
|
||||
@@ -1307,11 +1307,11 @@ function ensureOverlayDom() {
|
||||
// ignored.
|
||||
if (!_actions)
|
||||
presentActions({ owner: {}, items: [], status: '', announced: 0 });
|
||||
_ctx = _canvas.getContext('2d', { alpha: true, desynchronized: true });
|
||||
_detectionCtx = _detectionSurface.getContext('2d', {
|
||||
alpha: true,
|
||||
desynchronized: true,
|
||||
});
|
||||
// Synchronized contexts: on a desynchronized one Chrome can present an
|
||||
// earlier buffer after a frame that only clears, so cards that left stay
|
||||
// on screen until something paints over them.
|
||||
_ctx = _canvas.getContext('2d', { alpha: true });
|
||||
_detectionCtx = _detectionSurface.getContext('2d', { alpha: true });
|
||||
}
|
||||
|
||||
function sizeCanvasSurface(canvas, ctx, width, height, dpr) {
|
||||
|
||||
@@ -110,6 +110,7 @@ function installMockEnvironment({
|
||||
} = {}) {
|
||||
const byId = new Map();
|
||||
const paintTrace = [];
|
||||
const contextRequests = [];
|
||||
const ctx = mockContext('shared', paintTrace);
|
||||
const detectionCtx = mockContext('detection', paintTrace);
|
||||
const layoutReads = { canvasWidth: 0, canvasHeight: 0, boundingClientRect: 0 };
|
||||
@@ -184,8 +185,9 @@ function installMockEnvironment({
|
||||
return this._rect;
|
||||
}
|
||||
|
||||
getContext() {
|
||||
getContext(type, options) {
|
||||
if (this.tagName !== 'CANVAS') return null;
|
||||
contextRequests.push({ id: this.id, type, options });
|
||||
return this.id === 'world-overlay-detection-surface' ? detectionCtx : ctx;
|
||||
}
|
||||
|
||||
@@ -400,6 +402,7 @@ function installMockEnvironment({
|
||||
ctx,
|
||||
detectionCtx,
|
||||
paintTrace,
|
||||
contextRequests,
|
||||
document,
|
||||
window,
|
||||
postRender,
|
||||
@@ -2623,3 +2626,24 @@ test('the queued-card index stays bounded while card identities churn', () => {
|
||||
env.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('both overlay surfaces draw on synchronized 2D contexts', () => {
|
||||
// A desynchronized context can show an earlier buffer after a frame that
|
||||
// only clears: a card removed from its source stayed on screen until
|
||||
// something painted over it.
|
||||
const env = installMockEnvironment();
|
||||
try {
|
||||
initWorldOverlay(env.viewer);
|
||||
const ids = env.contextRequests.map((request) => request.id).sort();
|
||||
assert.deepEqual(ids, [
|
||||
'world-overlay-canvas',
|
||||
'world-overlay-detection-surface',
|
||||
]);
|
||||
for (const request of env.contextRequests) {
|
||||
assert.equal(request.type, '2d');
|
||||
assert.notEqual(request.options?.desynchronized, true, request.id);
|
||||
}
|
||||
} finally {
|
||||
env.cleanup();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user