mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Compute local receiver path courses without Cesium
The local receiver motion model built its two chord points with Cesium's fromDegrees only to measure the course between them. It now uses the app's own ellipsoid conversion into plain scratch points, which gives the same bits, and leaves the allow-list. A test pins the path-derived course for a contact that reports no track.
This commit is contained in:
1 parent
b1333d8d93
commit
1cfa62c7ba
3 files changed
+15
-6
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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}`);
|
||||
});
|
||||
Reference in new issue
Block a user