diff --git a/src/layers/localAdsb/motion.js b/src/layers/localAdsb/motion.js index 084f3aa7e..c7f66bbe1 100644 --- a/src/layers/localAdsb/motion.js +++ b/src/layers/localAdsb/motion.js @@ -1,4 +1,3 @@ -import * as Cesium from 'cesium'; import { COURSE_HOLD_SPEED_MPS, TURN_MIN_SPEED_MPS, @@ -21,6 +20,7 @@ import { COURSE_SLEW_DT_MAX_SEC, DR_CORRECTION_MS, } from '../flights/policy.js'; +import { fromDegreesInto } from '../../geo/ellipsoid.js'; /** Heard positions kept per aircraft for its trail: 10 minutes, 600 fixes. */ export const LOCAL_ADSB_HISTORY_MS = 10 * 60_000; @@ -38,8 +38,8 @@ const COAST_MAXIMUM_SEC = 60; const KT_TO_MPS = 1852 / 3600; const EARTH_RADIUS_M = 6_371_008.8; const DEG = Math.PI / 180; -const _chordFrom = new Cesium.Cartesian3(); -const _chordTo = new Cesium.Cartesian3(); +const _chordFrom = { x: 0, y: 0, z: 0 }; +const _chordTo = { x: 0, y: 0, z: 0 }; function finite(value) { return Number.isFinite(value) ? value : null; @@ -58,8 +58,8 @@ function telemetryTime(record) { } function chordCourse(from, to) { - Cesium.Cartesian3.fromDegrees(from.lon, from.lat, 0, undefined, _chordFrom); - Cesium.Cartesian3.fromDegrees(to.lon, to.lat, 0, undefined, _chordTo); + fromDegreesInto(from.lon, from.lat, 0, _chordFrom); + fromDegreesInto(to.lon, to.lat, 0, _chordTo); return courseBetweenCartesians(_chordFrom, _chordTo); } diff --git a/src/layers/localAdsb/motion.test.mjs b/src/layers/localAdsb/motion.test.mjs index d4096db8c..02561480c 100644 --- a/src/layers/localAdsb/motion.test.mjs +++ b/src/layers/localAdsb/motion.test.mjs @@ -207,3 +207,13 @@ test('a velocity/altitude-only update with the same position time still refreshe ); assert.ok(Math.abs(display.lat) < 1e-9, 'a stopped aircraft does not coast'); }); + +test('without a reported track the course follows the heard path', () => { + const motion = new LocalAdsbMotion(); + for (let second = 0; second <= 10; second += 1) { + const at = second * 1_000; + motion.observe(fix(at, 0, { lon: second * STEP, trackDeg: null }), at); + } + const course = motion.displayAt(10_000).courseDeg; + assert.ok(Math.abs(course - 90) < 0.5, `${course}`); +}); diff --git a/src/render/cesiumAllowList.json b/src/render/cesiumAllowList.json index 5a495f165..f0f6ff035 100644 --- a/src/render/cesiumAllowList.json +++ b/src/render/cesiumAllowList.json @@ -53,7 +53,6 @@ "src/layers/launches/rendering.js", "src/layers/localAdsb/index.js", "src/layers/localAdsb/models.js", - "src/layers/localAdsb/motion.js", "src/layers/military/lifecycle.js", "src/layers/military/motion.js", "src/layers/military/policy.js",