fix: keep a named place's own point in situation briefs

Brief sections received a named place as its bounding box, so they centered
on the box's middle: Tokyo's aircraft were sorted from a point in the
Pacific. Sections now receive the place name and resolve it like a direct
query, and place lookups are cached briefly so a brief resolves it once.
This commit is contained in:
Sameh Khamis committed 2026-10-02 15:21:36 -07:00
1 parent 1b3aa8de8b
commit 4af15aa6a9
5 files changed
+137 -21

No files matched your search

+25 -2
View File
@@ -421,8 +421,8 @@ test('the situation brief combines available sections and marks failures', async
});
assert.equal(
result.summary,
'Situation in Austin, Texas: Weather at 30.3100, -97.7500: overcast, 26°C, wind 5 km/h. ' +
'1 earthquake of M2.5+ in the last 24 hours in the requested box; strongest M3.1 near Austin.',
'Situation in Austin, Texas: Weather at Austin, Texas: overcast, 26°C, wind 5 km/h. ' +
'1 earthquake of M2.5+ in the last 24 hours in Austin, Texas; strongest M3.1 near Austin.',
);
assert.deepEqual(Object.keys(result.data.sections), [
'weather',
@@ -642,3 +642,26 @@ test('the HUD caption context carries each section feed state', async () => {
assert.equal(sent[0].feedProvenance.overall, 'unavailable');
assert.match(sent[0].feedProvenance.note, /Aircraft is STALE/);
});
test('brief sections use a named place at its own point', async () => {
const tokyo = {
resolve: async () => ({
name: 'Tokyo, Japan',
point: { lat: 35.6769, lon: 139.7639 },
bounds: { west: 135, south: 20, east: 155, north: 36 },
}),
};
const queries = [];
const aircraft = {
getSnapshot: async (query) => {
queries.push(query);
return { records: [], complete: true, source: 'Test feed' };
},
};
const result = await catalogWith({ weather, places: tokyo, aircraft }).call(
'situation_brief',
{ area: { place: 'Tokyo' } },
);
assert.deepEqual(queries[0], { latitude: 35.6769, longitude: 139.7639 });
assert.match(result.data.sections.aircraft.summary, /in Tokyo, Japan\.$/);
});