fix(tools): list a split submarine cable once in find_submarine_cables

TeleGeography stores 17 cables (2Africa, Echo, Hawaiki...) as several
features under one id, and the tool made a row per feature, so "Echo"
read "3 submarine cables" and area counts ran high. Rows are now unique
by cable id, and a cable still matches when any of its parts does.
This commit is contained in:
Aditya committed 2026-10-28 15:13:15 +05:30
1 parent a4d3701c3c
commit 182e6ceddd
3 files changed
+62

No files matched your search

+6
View File
@@ -57,6 +57,7 @@ export const findSubmarineCables = defineTool({
Number.isFinite(point.lat) &&
(!area || areaContains(area, point)),
);
const seen = new Set();
const rows = (cables?.features || [])
.filter((feature) => {
const name = String(feature.properties?.name || '');
@@ -71,6 +72,11 @@ export const findSubmarineCables = defineTool({
id: feature.properties.id ?? null,
name: feature.properties.name,
}))
// TeleGeography splits some cables into several features under one id.
.filter((row) => {
const key = row.id ?? row.name;
return !seen.has(key) && seen.add(key);
})
.sort((a, b) => a.name.localeCompare(b.name));
const where = area ? ` in ${area.label}` : '';
const what = wanted ? ` matching "${args.name}"` : '';