Files
gods-eye-view/src/sources/featureGeometry.test.mjs
T
quanticsoul4772 07318cc9a4 fix(geo): wrap longitude differences across the antimeridian in point distances (#1304)
Wrap longitude differences in annotation proximity checks and nearby-place distances so points across the antimeridian remain close.

Original contribution by quanticsoul4772.

Co-authored-by: quanticsoul4772 <[email protected]>
2026-10-24 08:19:21 -07:00

16 lines
655 B
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { approximateDistanceM } from './featureGeometry.js';
test('approximate distance takes the short way round 180°', () => {
// Lau Islands (-179.0) to Savusavu (179.33): about 178 km apart.
const across = approximateDistanceM(-17.5, -179.0, -16.78, 179.33);
assert.ok(across > 150_000 && across < 200_000, String(across));
assert.equal(
Math.round(approximateDistanceM(0, 179.9, 0, -179.9)),
Math.round(approximateDistanceM(0, -0.1, 0, 0.1)),
);
// Away from 180° nothing changes.
assert.equal(Math.round(approximateDistanceM(0, 0, 0, 1)), 111_320);
});