mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
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:
1 parent
a4d3701c3c
commit
182e6ceddd
3 files changed
+62
No files matched your search
@@ -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}"` : '';
|
||||
|
||||
Reference in new issue
Block a user