fix: v0.12.2 — ISS-003 route leg lines now follow the curved great-circle path (greatCircleArc, 25 sampled points via sim slerp) instead of a straight two-point chord; e2e asserts >2 coordinates in the routes source

This commit is contained in:
2026-09-18 14:06:38 +00:00
parent 7c51cadef7
commit 79cf5a05e2
6 changed files with 75 additions and 17 deletions
+21 -5
View File
@@ -1,5 +1,6 @@
import type { StateSnapshot } from './game/state';
import { formatFuel } from './format';
import { positionAt } from './sim/movement';
// Pure GeoJSON builders for the map's dynamic layers (v0.11.0, package model
// v0.12.0): one Point feature per plane, one LineString per FLYING plane's
@@ -67,9 +68,27 @@ export interface AirportCoord {
lon: number;
}
// Segments used to sample a route leg's great-circle arc (v0.12.2): 25 coordinates
// total — endpoints exact, 23 intermediate points so the drawn line matches the
// curved path the plane actually flies (same slerp as lib/sim/movement.ts).
export const ROUTE_ARC_SEGMENTS = 24;
// Great-circle arc between two airports as [lon, lat] coordinates: positionAt at
// t = i/SEGMENTS for i in 0..SEGMENTS. Pure — endpoints are exactly the airport
// coords (positionAt returns them verbatim at t=0 and t=1).
export function greatCircleArc(from: AirportCoord, to: AirportCoord): [number, number][] {
const coords: [number, number][] = [];
for (let i = 0; i <= ROUTE_ARC_SEGMENTS; i++) {
const pos = positionAt(from.lat, from.lon, to.lat, to.lon, i / ROUTE_ARC_SEGMENTS);
coords.push([pos.lon, pos.lat]);
}
return coords;
}
// One LineString per FLYING plane — its current leg from locationIcao to dest_icao.
// Grounded planes draw nothing; a flying plane missing either endpoint from the
// dataset is skipped, never guessed.
// dataset is skipped, never guessed. The line is sampled along the great circle
// (greatCircleArc) so it matches the curved flight path instead of a straight chord.
export function routesGeoJson(
state: StateSnapshot | null,
airportsByIcao: ReadonlyMap<string, AirportCoord>,
@@ -85,10 +104,7 @@ export function routesGeoJson(
type: 'Feature',
geometry: {
type: 'LineString',
coordinates: [
[from.lon, from.lat],
[to.lon, to.lat],
],
coordinates: greatCircleArc(from, to),
},
properties: { planeId: p.id },
});