mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
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:
1 parent
1b3aa8de8b
commit
4af15aa6a9
5 files changed
+137
-21
No files matched your search
+29
-13
@@ -21,7 +21,9 @@ const SECTIONS = [
|
||||
label: 'Weather',
|
||||
tool: 'get_weather',
|
||||
args: (area, center) => ({
|
||||
location: { lat: center.lat, lon: center.lon },
|
||||
location: area.argument.place
|
||||
? { place: area.argument.place }
|
||||
: { lat: center.lat, lon: center.lon },
|
||||
}),
|
||||
},
|
||||
{
|
||||
@@ -93,19 +95,30 @@ function sectionFeedState(section) {
|
||||
: 'nominal';
|
||||
}
|
||||
|
||||
/** The resolved area, plus the argument sections receive in its place. */
|
||||
function sectionArea(resolved) {
|
||||
/**
|
||||
* The resolved area, plus the argument sections receive. A named place is
|
||||
* passed by name, so sections resolve it to the same point and label as a
|
||||
* direct query does (place lookups are cached).
|
||||
*/
|
||||
function sectionArea(resolved, original) {
|
||||
return {
|
||||
...resolved,
|
||||
argument: resolved.center
|
||||
? {
|
||||
lat: resolved.center.lat,
|
||||
lon: resolved.center.lon,
|
||||
radius_km: resolved.center.radiusKm,
|
||||
}
|
||||
: {
|
||||
bbox: [resolved.west, resolved.south, resolved.east, resolved.north],
|
||||
},
|
||||
argument: original?.place
|
||||
? { place: original.place }
|
||||
: resolved.center
|
||||
? {
|
||||
lat: resolved.center.lat,
|
||||
lon: resolved.center.lon,
|
||||
radius_km: resolved.center.radiusKm,
|
||||
}
|
||||
: {
|
||||
bbox: [
|
||||
resolved.west,
|
||||
resolved.south,
|
||||
resolved.east,
|
||||
resolved.north,
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -143,7 +156,10 @@ async function runSections(all, area, { tools, signal }) {
|
||||
|
||||
async function buildBrief(args, { services, signal, tools }) {
|
||||
// Sections receive the resolved box so a place name is looked up once.
|
||||
const area = sectionArea(await resolveArea(args.area, { services, signal }));
|
||||
const area = sectionArea(
|
||||
await resolveArea(args.area, { services, signal }),
|
||||
args.area,
|
||||
);
|
||||
const { center, answers, lines } = await runSections(SECTIONS, area, {
|
||||
tools,
|
||||
signal,
|
||||
|
||||
Reference in new issue
Block a user