mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
Merge remote-tracking branch 'origin/main' into german/hal-623-hud-summary-locale
# Conflicts: # src/voice/gevActions.test.mjs
This commit is contained in:
commit
33381c5981
484 files changed
+26543
-1086
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}"` : '';
|
||||
|
||||
@@ -89,6 +89,59 @@ test('cables are found by area and name, with landing points and attribution', a
|
||||
);
|
||||
});
|
||||
|
||||
test('a cable split into several features is listed once', async () => {
|
||||
// TeleGeography splits a few cables (2Africa, Echo, Hawaiki) into several
|
||||
// features under one id.
|
||||
const cable = (id, name, coordinates) => ({
|
||||
properties: { id, name },
|
||||
geometry: { type: 'MultiLineString', coordinates: [coordinates] },
|
||||
});
|
||||
const split = {
|
||||
async fetch() {
|
||||
return {
|
||||
cables: {
|
||||
features: [
|
||||
cable('2africa', '2Africa', [
|
||||
[60, 18],
|
||||
[57, 22],
|
||||
]),
|
||||
cable('equiano', 'Equiano', [
|
||||
[-10, 5],
|
||||
[3, 6],
|
||||
]),
|
||||
cable('2africa', '2Africa', [
|
||||
[-21, 16],
|
||||
[-17, 14],
|
||||
]),
|
||||
],
|
||||
},
|
||||
landingPoints: { features: [] },
|
||||
};
|
||||
},
|
||||
};
|
||||
const catalog = composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { cables: split },
|
||||
});
|
||||
const named = await catalog.call('find_submarine_cables', {
|
||||
name: '2africa',
|
||||
});
|
||||
assert.equal(named.summary, '1 submarine cable matching "2africa".');
|
||||
assert.deepEqual(named.data.rows, [{ id: '2africa', name: '2Africa' }]);
|
||||
const both = await catalog.call('find_submarine_cables', {
|
||||
area: { bbox: [-30, 0, 70, 30] },
|
||||
});
|
||||
assert.deepEqual(
|
||||
both.data.rows.map((row) => row.id),
|
||||
['2africa', 'equiano'],
|
||||
);
|
||||
// Only the second part crosses this box; the cable is still found.
|
||||
const west = await catalog.call('find_submarine_cables', {
|
||||
area: { bbox: [-25, 10, -10, 20] },
|
||||
});
|
||||
assert.deepEqual(west.data.rows, [{ id: '2africa', name: '2Africa' }]);
|
||||
});
|
||||
|
||||
test('the local fetch serves bundled data files and nothing outside them', async () => {
|
||||
const fetchImpl = createApiFetch({
|
||||
apiBase: 'http://127.0.0.1:1',
|
||||
|
||||
Reference in new issue
Block a user