mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix: count every mapped installation in tool answers
The installation source keeps one named site per display cell for the map. Queries now ask for every site and the exact box, and report when the source returned only part of the mapped sites.
This commit is contained in:
1 parent
2e071b62d3
commit
7ddee426e7
5 files changed
+63
-14
No files matched your search
@@ -355,8 +355,12 @@ export const findMilitaryInstallations = defineTool({
|
||||
);
|
||||
const center = areaCenter(area);
|
||||
const result = await services.installations.getMappedSites(area, {
|
||||
exact: true,
|
||||
thinned: false,
|
||||
signal,
|
||||
});
|
||||
// A saturated source returned only part of the mapped sites.
|
||||
const complete = !result.saturated;
|
||||
const rows = (result.records || [])
|
||||
.map((site) => ({
|
||||
site,
|
||||
@@ -374,8 +378,14 @@ export const findMilitaryInstallations = defineTool({
|
||||
}))
|
||||
.sort((a, b) => a.distance_km - b.distance_km);
|
||||
return {
|
||||
summary: `${countNoun(rows.length, 'mapped military installation')} in ${area.label}.`,
|
||||
data: { ...capRows(rows, args.limit), source: result.source ?? null },
|
||||
summary:
|
||||
`${countNoun(rows.length, 'mapped military installation')} in ${area.label}` +
|
||||
(complete ? '.' : ' (partial: the source returned only some sites).'),
|
||||
data: {
|
||||
...capRows(rows, args.limit),
|
||||
complete,
|
||||
source: result.source ?? null,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -263,10 +263,14 @@ test('terrain heights are returned in request order', async () => {
|
||||
|
||||
test('military installations need a bounded area and are nearest first', async () => {
|
||||
const requested = [];
|
||||
const options = [];
|
||||
let saturated = false;
|
||||
const installations = {
|
||||
async getMappedSites(box) {
|
||||
async getMappedSites(box, { signal, ...rest } = {}) {
|
||||
requested.push(box);
|
||||
options.push(rest);
|
||||
return {
|
||||
saturated,
|
||||
source: 'OpenStreetMap',
|
||||
records: [
|
||||
{
|
||||
@@ -302,7 +306,18 @@ test('military installations need a bounded area and are nearest first', async (
|
||||
['osm:2', 'osm:1'],
|
||||
);
|
||||
assert.equal(result.data.source, 'OpenStreetMap');
|
||||
assert.equal(result.data.complete, true);
|
||||
assert.ok(requested[0].north - requested[0].south < 1);
|
||||
assert.deepEqual(options[0], { exact: true, thinned: false });
|
||||
saturated = true;
|
||||
const partial = await catalog.call('find_military_installations', {
|
||||
area: { lat: 32.7, lon: -117.2, radius_km: 20 },
|
||||
});
|
||||
assert.equal(partial.data.complete, false);
|
||||
assert.match(
|
||||
partial.summary,
|
||||
/\(partial: the source returned only some sites\)\.$/,
|
||||
);
|
||||
await assert.rejects(
|
||||
catalog.call('find_military_installations', {
|
||||
area: { bbox: [-130, 20, -100, 50] },
|
||||
|
||||
Reference in new issue
Block a user