mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Show an aid to navigation's kind, not a speed or heading
A buoy's card, selected card and HUD readout showed "0.0KT · 135°" from
whatever its source reported. A fixed mark has neither, so they now show
its kind alone, whole ("CARDINAL MARK N", which the 14-character type cut
read as "CARDINAL MARK "), in the bone white of its disc.
isAidToNavigation now knows every kind an aid report names ("Light, with
sectors", "Fixed structure off shore" had no aid word), leaves out a
"Buoy Layer" as it does a tender, and matches each type text once: the
vessel layer asks per vessel on its rotation pass, which now skips the
aid discs it never turns.
Aid rows no longer cost ships their place: aisStreamRows lists every
vessel ahead of every aid, so the layer's 12,000-row request never drops
a ship for a buoy, and vessels_in_area (and the brief built on it)
counts ships only. An aid's name runs on into its NameExtension.
This commit is contained in:
1 parent
279aedb2f4
commit
6c7fe48f40
25 files changed
+289
-49
No files matched your search
@@ -21,7 +21,10 @@ import {
|
||||
thinEvenly,
|
||||
} from '../results.js';
|
||||
import { roundHeadingDegrees } from '../../data/headingDegrees.js';
|
||||
import { normalizeVesselType } from '../../data/vesselTypes.js';
|
||||
import {
|
||||
isAidToNavigation,
|
||||
normalizeVesselType,
|
||||
} from '../../data/vesselTypes.js';
|
||||
|
||||
const MMSI_SCHEMA = Object.freeze({
|
||||
type: 'string',
|
||||
@@ -116,7 +119,8 @@ export const vesselsInArea = defineTool({
|
||||
title: 'Vessels in an area',
|
||||
description:
|
||||
'Ships currently reported by AIS inside an area, nearest the center ' +
|
||||
'first, optionally filtered by vessel type. group_by counts every matched ' +
|
||||
'first, optionally filtered by vessel type. Buoys, beacons and other ' +
|
||||
'aids to navigation are not ships and are left out. group_by counts every matched ' +
|
||||
'ship by type or destination, and stats summarizes their speed; both ' +
|
||||
'cover all matches, not just the rows returned.',
|
||||
inputSchema: {
|
||||
@@ -152,6 +156,8 @@ export const vesselsInArea = defineTool({
|
||||
const rows = snapshot.records
|
||||
.filter(
|
||||
(record) =>
|
||||
// A buoy or beacon in the feed is not a ship to count.
|
||||
!isAidToNavigation(record) &&
|
||||
areaContains(area, { lat: record.latitude, lon: record.longitude }) &&
|
||||
(!wanted ||
|
||||
(vesselType(record.type) ?? '').toLowerCase().includes(wanted)),
|
||||
|
||||
@@ -467,3 +467,44 @@ test('vessels in an area can be counted by destination with a speed summary', as
|
||||
speed_mps: { count: 2, min: 6.2, median: 6.2, mean: 6.2, max: 6.2 },
|
||||
});
|
||||
});
|
||||
|
||||
test('vessels in an area leave out buoys and beacons', async () => {
|
||||
const withAids = {
|
||||
...vessels(),
|
||||
async getSnapshot() {
|
||||
return {
|
||||
records: [
|
||||
...records,
|
||||
vessel('993672001', 37.8, -122.42, {
|
||||
name: 'SF APPROACH N',
|
||||
type: 'Cardinal Mark N',
|
||||
speedMps: 0,
|
||||
headingDeg: 135,
|
||||
}),
|
||||
vessel('993672002', 37.79, -122.43, { type: '' }),
|
||||
],
|
||||
source: 'AISStream',
|
||||
observedAtMs: Date.UTC(2026, 0, 1),
|
||||
freshness: 'current',
|
||||
};
|
||||
},
|
||||
};
|
||||
const catalog = composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { vessels: withAids },
|
||||
});
|
||||
const all = await catalog.call('vessels_in_area', {
|
||||
area: bay,
|
||||
group_by: 'type',
|
||||
});
|
||||
assert.equal(all.data.total, 2);
|
||||
assert.equal(all.summary.split(' in ')[0], '2 vessels');
|
||||
assert.deepEqual(all.data.rows.map((row) => row.mmsi).sort(), [
|
||||
'366999712',
|
||||
'538001234',
|
||||
]);
|
||||
assert.equal(all.data.breakdown.unknown_count, 0);
|
||||
assert.ok(
|
||||
!all.data.breakdown.groups.some((group) => /mark/i.test(group.value)),
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user