mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Keep tracked-entity state in app records instead of on Cesium entities
Flights, military, satellites, installations, local ADS-B and ALPR hung gevTrackedId, gevDisplayPosition, gevVisualPosition, gevSelectionOrigin and gevLabelModel on the Cesium entities they draw, and the tracked readout, follow camera, cockpit, share links and awareness read them back. They now live in src/data/entityRecords.js, an app-owned record per entity: layers write entityRecord(entity), readers use readEntityRecord(entity). Nothing changes on screen. This is the first slice of the renderer plan's state mirror (P1). The module is exported as ./data/entity-records so callers can read the same records, and window.__godsEyeView.entityRecords gives the QA scripts the same access from the page.
This commit is contained in:
1 parent
ea69bb4ce2
commit
65587f6c08
53 files changed
+408
-291
No files matched your search
@@ -35,6 +35,7 @@ import {
|
||||
LOCAL_ADSB_UAT_RING_COLOR,
|
||||
} from './policy.js';
|
||||
import { localAdsbStatus } from './status.js';
|
||||
import { entityRecord } from '../../data/entityRecords.js';
|
||||
|
||||
export { HEARD_BY_RECEIVER } from './policy.js';
|
||||
export { localAdsbCardModel, localAdsbReceiverLine } from './card.js';
|
||||
@@ -458,14 +459,14 @@ export function createLocalAdsbLayer({
|
||||
),
|
||||
},
|
||||
});
|
||||
marker.entity.gevTrackedId = id;
|
||||
marker.entity.gevDisplayPosition = () => marker.position;
|
||||
entityRecord(marker.entity).trackedId = id;
|
||||
entityRecord(marker.entity).displayPosition = () => marker.position;
|
||||
}
|
||||
refreshClass(marker);
|
||||
const uat = localAdsbIsUat(record);
|
||||
if (uat !== Boolean(marker.entity.point))
|
||||
marker.entity.point = uat ? uatRing(marker) : undefined;
|
||||
marker.entity.gevLabelModel = cardModel(marker, at);
|
||||
entityRecord(marker.entity).labelModel = cardModel(marker, at);
|
||||
registerEntityContext(marker.entity, contextMetadata(id, marker));
|
||||
if (newFix && id === selectedId) refreshTrail();
|
||||
return id;
|
||||
@@ -481,7 +482,7 @@ export function createLocalAdsbLayer({
|
||||
function refreshSelectedCard() {
|
||||
const marker = selectedId ? markers.get(selectedId) : null;
|
||||
if (!marker) return;
|
||||
marker.entity.gevLabelModel = cardModel(marker, now());
|
||||
entityRecord(marker.entity).labelModel = cardModel(marker, now());
|
||||
services.overlays?.refreshReadout?.(marker.entity);
|
||||
}
|
||||
|
||||
@@ -567,7 +568,7 @@ export function createLocalAdsbLayer({
|
||||
const reselect = id === selectedId && selectedTrail?.id === id;
|
||||
selectedId = id;
|
||||
enrichment.request(marker.record, { selected: true });
|
||||
marker.entity.gevLabelModel = cardModel(marker, now());
|
||||
entityRecord(marker.entity).labelModel = cardModel(marker, now());
|
||||
selectEntityContext(marker.entity);
|
||||
if (!reselect) startTrail(marker);
|
||||
governorRequestRender('local-adsb-selection');
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
localAdsbReceiverLine,
|
||||
localAdsbStatus,
|
||||
} from './index.js';
|
||||
import { readEntityRecord } from '../../data/entityRecords.js';
|
||||
|
||||
function fakeReceiver(initial = {}) {
|
||||
const state = {
|
||||
@@ -252,8 +253,8 @@ test('local aircraft use their class silhouette and scale in magenta', async (t)
|
||||
),
|
||||
);
|
||||
assert.equal(entity.billboard.rotation.getValue(), 0);
|
||||
assert.equal(entity.gevLabelModel.title, 'LOCAL1');
|
||||
assert.equal(typeof entity.gevDisplayPosition, 'function');
|
||||
assert.equal(readEntityRecord(entity)?.labelModel.title, 'LOCAL1');
|
||||
assert.equal(typeof readEntityRecord(entity)?.displayPosition, 'function');
|
||||
|
||||
const heli = sources[0].entities.getById('local-adsb:a0b702');
|
||||
assert.equal(heli.billboard.image.getValue(), aircraftIcon('helicopter'));
|
||||
@@ -265,7 +266,10 @@ test('local aircraft use their class silhouette and scale in magenta', async (t)
|
||||
),
|
||||
'the helicopter keeps the local magenta',
|
||||
);
|
||||
assert.equal(heli.gevLabelModel.details[1], 'Helicopter · A7');
|
||||
assert.equal(
|
||||
readEntityRecord(heli)?.labelModel.details[1],
|
||||
'Helicopter · A7',
|
||||
);
|
||||
|
||||
// On the ground the silhouette shrinks like a grounded public flight.
|
||||
receiver.set({
|
||||
@@ -479,14 +483,14 @@ test('adsbdb type, operator and route reach the card for the selected aircraft o
|
||||
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||
assert.deepEqual([...queries].sort(), ['route:EVC145', 'type:a0b702']);
|
||||
const entity = sources[0].entities.getById('local-adsb:a0b702');
|
||||
assert.deepEqual(entity.gevLabelModel.details.slice(0, 4), [
|
||||
assert.deepEqual(readEntityRecord(entity)?.labelModel.details.slice(0, 4), [
|
||||
'ICAO A0B702 · EVC145',
|
||||
'Helicopter · A7',
|
||||
'Air Evac · Bell 407',
|
||||
'AUS → SAT',
|
||||
]);
|
||||
assert.equal(
|
||||
entity.gevLabelModel.details.at(-1),
|
||||
readEntityRecord(entity)?.labelModel.details.at(-1),
|
||||
'Heard by your receiver · 1090 MHz · browser SDR',
|
||||
);
|
||||
layer.selectAircraft('a0b702');
|
||||
@@ -760,7 +764,7 @@ test('feed records merge with browser SDR records by ICAO and UAT-only aircraft
|
||||
);
|
||||
assert.equal(shared.point, undefined, 'heard on 1090 too: no UAT ring');
|
||||
assert.equal(
|
||||
shared.gevLabelModel.details.at(-1),
|
||||
readEntityRecord(shared)?.labelModel.details.at(-1),
|
||||
'Heard by your receiver · 1090 MHz + 978 MHz UAT · browser SDR + decoder feed',
|
||||
);
|
||||
assert.ok(uat.point, 'a UAT-only aircraft carries the ring');
|
||||
@@ -776,7 +780,7 @@ test('feed records merge with browser SDR records by ICAO and UAT-only aircraft
|
||||
'same magenta marker family',
|
||||
);
|
||||
assert.equal(
|
||||
uat.gevLabelModel.details.at(-1),
|
||||
readEntityRecord(uat)?.labelModel.details.at(-1),
|
||||
'Heard by your receiver · 978 MHz UAT · decoder feed',
|
||||
);
|
||||
const stats = layer.getStats();
|
||||
|
||||
Reference in new issue
Block a user