Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

Merge remote-tracking branch 'origin/main' into fix-1056

quanticsoul4772d604b97a4d73
diff --cc docs/CURRENT-STATE.md
index f582d93e1,7f15631eb..3c4131e0d
--- a/docs/CURRENT-STATE.md
+++ b/docs/CURRENT-STATE.md
@@@ -97,15 -97,12 +97,18 @@@ perimeters, terrain height, military in
combined situation brief, military awareness around a point, the app's heads-up display caption, and a link that
opens the app over an area. Tools reuse the layers' portable source factories, take a
shared `area` argument (place name, bounding box, or point and radius) and cap
-lists at 25 rows by default. Voice offers the same queries next to its app
+lists at 25 rows by default. `aircraft_in_area` and `vessels_in_area` can also
+count every match by a field (`group_by`: operator, country or type for
+aircraft; type or destination for ships; the ten largest groups, then other and
+unknown counts; the summary says when a feed reports none of the field) and
+summarize airborne altitude and speed (`stats`: count, min, median, mean, max).
+Both cover all matches, not just the rows returned; voice leaves these two
+tools out, so they reach MCP clients only. Voice offers the same queries next to its app
actions: the session lists them, and the browser runs them through the same
catalog, loaded on first use. See [tools and the MCP server](TOOLS.md).
+ Aircraft altitude-band queries require a reported barometric or geometric altitude
+ for each match, so a grounded contact that reports none is left out of a band too.
+ Queries without an altitude band retain unknown-altitude contacts.
Catalog calls check their cancellation signal immediately before executing a
tool. Already-cancelled queries do not start; cancellation after execution starts
diff --cc src/tools/queries/aviation.test.mjs
index b6b6e3497,d0e979ed6..14b2e2d38
--- a/src/tools/queries/aviation.test.mjs
+++ b/src/tools/queries/aviation.test.mjs
@@@ -389,59 -389,61 +389,118 @@@ test('the real OpenSky source marks an
assert.match(result.summary, /may be stale\.$/);
});
+test('aircraft in an area can be counted by operator over every match', async () => {
+ const fleet = [
+ record('a1', 37.6, -122.3, { operator: 'United' }),
+ record('a2', 37.61, -122.3, { operator: 'Delta' }),
+ record('a3', 37.62, -122.3, { operator: 'United', baroAltitudeM: 3000 }),
+ record('a4', 37.63, -122.3, { onGround: true, baroAltitudeM: 0 }),
+ record('a5', 51.5, -0.1, { operator: 'British Airways' }),
+ ];
+ const catalog = composeCatalog({
+ tools: coreTools,
+ services: { aircraft: feed(fleet) },
+ });
+ const result = await catalog.call('aircraft_in_area', {
+ area: bay,
+ group_by: 'operator',
+ stats: true,
+ limit: 1,
+ });
+ assert.equal(
+ result.summary,
+ '4 aircraft in 60 km around 37.600, -122.300; most by operator: United (2), Delta (1); 1 unknown.',
+ );
+ assert.equal(result.data.returned, 1);
+ assert.deepEqual(result.data.breakdown, {
+ field: 'operator',
+ groups: [
+ { value: 'United', count: 2 },
+ { value: 'Delta', count: 1 },
+ ],
+ other_count: 0,
+ unknown_count: 1,
+ });
+ // Altitude covers airborne aircraft only; speed covers every match.
+ assert.deepEqual(result.data.stats.altitude_m, {
+ count: 3,
+ min: 3000,
+ median: 10000,
+ mean: 7666.7,
+ max: 10000,
+ });
+ assert.equal(result.data.stats.speed_mps.count, 4);
+});
+
+test('aircraft answers carry no breakdown or stats unless asked', async () => {
+ const catalog = composeCatalog({
+ tools: coreTools,
+ services: { aircraft: feed(civil) },
+ });
+ const result = await catalog.call('aircraft_in_area', { area: bay });
+ assert.equal('breakdown' in result.data, false);
+ assert.equal('stats' in result.data, false);
+ await assert.rejects(
+ catalog.call('aircraft_in_area', { area: bay, group_by: 'callsign' }),
+ /must be one of/,
+ );
+});
++
+ test('altitude bands require a reported altitude from normalized OpenSky records', async () => {
+ const { normalizeOpenSkyAircraft } =
+ await import('../../sources/live/aircraft.js');
+ const state = (id, baro, geometric) =>
+ normalizeOpenSkyAircraft([
+ id,
+ 'TEST',
+ 'Test',
+ 1767225600,
+ 1767225600,
+ 0,
+ 0,
+ baro,
+ false,
+ 10,
+ 90,
+ 0,
+ [],
+ geometric,
+ ]);
+ const records = [
+ state('abc001', null, null),
+ state('abc002', 0, null),
+ state('abc003', null, 50),
+ state('abc004', 500, null),
+ ];
+ const catalog = composeCatalog({
+ tools: coreTools,
+ services: {
+ aircraft: { getSnapshot: async () => ({ records }) },
+ },
+ });
+ const area = { bbox: [-1, -1, 1, 1] };
+ assert.equal(
+ (await catalog.call('aircraft_in_area', { area })).data.total,
+ 4,
+ 'unfiltered answers retain unknown altitude',
+ );
+ for (const band of [
+ { max_altitude_m: 100 },
+ { min_altitude_m: -500, max_altitude_m: 100 },
+ ]) {
+ const result = await catalog.call('aircraft_in_area', { area, ...band });
+ assert.deepEqual(
+ result.data.rows.map((row) => row.id),
+ ['abc002', 'abc003'],
+ );
+ assert.deepEqual(
+ result.data.rows.map((row) => row.altitude_m),
+ [0, 50],
+ );
+ }
+ const minimum = await catalog.call('aircraft_in_area', {
+ area,
+ min_altitude_m: -500,
+ });
+ assert.equal(minimum.data.total, 3);
+ });