feat(map): add synthetic moving target layer

This commit is contained in:
Codex
2026-07-29 18:28:54 +03:00
parent 65644a8609
commit 08a3c47391
6 changed files with 578 additions and 14 deletions
@@ -0,0 +1,32 @@
import assert from "node:assert/strict";
import test from "node:test";
import {
advanceGhostPins,
destinationPoint,
geodesicDistanceMeters,
} from "../dist/ghostPins.js";
test("destinationPoint advances a pin over the globe", () => {
const origin = { longitude: 37.618423, latitude: 55.751244 };
const destination = destinationPoint(origin, 90, 1_000);
assert.ok(destination.longitude > origin.longitude);
assert.ok(Math.abs(destination.latitude - origin.latitude) < 0.001);
assert.ok(Math.abs(geodesicDistanceMeters(origin, destination) - 1_000) < 0.01);
});
test("advanceGhostPins turns an escaping pin back toward its anchor", () => {
const anchor = { longitude: 37.618423, latitude: 55.751244 };
const edge = destinationPoint(anchor, 90, 990);
const [advanced] = advanceGhostPins([
{
id: "ghost-1",
label: "123456",
...edge,
heading_degrees: 90,
speed_meters_per_second: 20,
},
], anchor, 1_000, 1);
assert.ok(geodesicDistanceMeters(anchor, advanced) < 990);
assert.ok(advanced.heading_degrees > 260 && advanced.heading_degrees < 280);
});