Keep visible route endpoints across wrapped longitude views

This commit is contained in:
n30nex
2026-09-12 19:17:40 -04:00
parent bea11a6a52
commit 90d3a7d3b0
2 changed files with 3 additions and 1 deletions
+1
View File
@@ -9,6 +9,7 @@ describe('historical route WebGL geometry', () => {
expect(routeMayIntersectView([-179, 40], [-177, 41], [175, 39, 185, 42])).toBe(true);
expect(routeMayIntersectView([179, 40], [180, 41], [-185, 39, -175, 42])).toBe(true);
expect(routeMayIntersectView([0, 40], [1, 41], [175, 39, -175, 42])).toBe(false);
expect(routeMayIntersectView([10, 40], [-169, 40], [170, 39, -160, 41])).toBe(true);
});
it('keeps one exact line segment for every route', () => {
const routes: Feature<LineString>[] = [
+2 -1
View File
@@ -259,7 +259,8 @@ export function routeMayIntersectView(a: Coordinate, b: Coordinate, view: readon
const padX = Math.max(0.025, span * 0.15);
const padY = Math.max(0.025, (north - south) * 0.15);
if (Math.max(a[1], b[1]) < south - padY || Math.min(a[1], b[1]) > north + padY) return false;
return span >= 360 || !(Math.max(x1, x2) < west - padX || Math.min(x1, x2) > west + span + padX);
return span >= 360 || [-360, 0, 360].some(offset =>
!(Math.max(x1, x2) + offset < west - padX || Math.min(x1, x2) + offset > west + span + padX));
}
function strokeVertices(segments: readonly StrokeSegment[], origin: [number, number, number] = [0, 0, 0]): Float32Array {