fix: find cables that cross an area between vertices

Cable searches only tested vertices, so a cable crossing an area with no
vertex inside it was missed. Lines now test each segment against the area's
bounds, across the antimeridian too, and against a radius area's great-circle
distance.
This commit is contained in:
Sameh Khamis committed 2026-10-02 15:21:36 -07:00
1 parent 5b73b70d19
commit 6f56c84b0b
4 files changed
+201 -5

No files matched your search

+7 -4
View File
@@ -1,7 +1,12 @@
/** Submarine cables and their landing points. */
import { defineTool, ToolError } from '../catalog.js';
import { AREA_SCHEMA, areaContains, resolveArea } from '../area.js';
import {
AREA_SCHEMA,
areaContains,
lineTouchesArea,
resolveArea,
} from '../area.js';
import { LIMIT_SCHEMA, capRows, countNoun } from '../results.js';
const ATTRIBUTION = '© TeleGeography — submarinecablemap.com (CC BY-NC-SA 3.0)';
@@ -58,9 +63,7 @@ export const findSubmarineCables = defineTool({
return false;
return (
!area ||
cableLines(feature).some((line) =>
line.some(([lon, lat]) => areaContains(area, { lat, lon })),
)
cableLines(feature).some((line) => lineTouchesArea(line, area))
);
})
.map((feature) => ({