mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 18:34:02 +00:00
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]>
16 lines
655 B
JavaScript
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);
|
|
});
|