mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Take the vessel layer's state and queries off Cesium
The focus pass's screen scratch is a plain { x, y } (Cesium only writes x
and y into it), and getNearby measures distance with geo/vector, which
gives the same result for Cartesian3s. Both files leave the Cesium
allow-list.
This commit is contained in:
1 parent
db2c579265
commit
0a81c2e197
4 files changed
+13
-14
No files matched your search
@@ -1647,6 +1647,7 @@
|
||||
"src/layers/vessels/lifecycle.js",
|
||||
"src/layers/vessels/policy.js",
|
||||
"src/layers/vessels/queries.js",
|
||||
"src/geo/vector.js",
|
||||
"src/layers/vessels/rendering.js",
|
||||
"src/data/entityRecords.js",
|
||||
"src/data/iconSetPrimitive.js",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { distance } from '../../geo/vector.js';
|
||||
import { t, msg } from '../../i18n/index.js';
|
||||
|
||||
// ingestion.js is a portable export (package.json) and writes English labels
|
||||
@@ -165,7 +165,7 @@ export function createQueries({
|
||||
|
||||
/**
|
||||
* Map one internal vessel record to a plain JSON-safe analyst record
|
||||
* (analyst query engine seam). Pure — no Cesium types. Missing/unknown
|
||||
* (analyst query engine seam). Pure — no renderer types. Missing/unknown
|
||||
* fields are null, never NaN/undefined. navStatus is always null: the
|
||||
* /api/vessels proxy does not surface AIS NavigationalStatus, so it
|
||||
* cannot be derived client-side.
|
||||
@@ -271,7 +271,7 @@ export function createQueries({
|
||||
/**
|
||||
* Find a vessel by exact MMSI or case-insensitive name substring.
|
||||
* @param {string|number} query MMSI or partial vessel name.
|
||||
* @returns {{ mmsi: string, name: string, position: Cesium.Cartesian3, latitude: number, longitude: number, speedKt: number|null, course: number|null, type: string }|null}
|
||||
* @returns {{ mmsi: string, name: string, position: {x: number, y: number, z: number}, latitude: number, longitude: number, speedKt: number|null, course: number|null, type: string }|null}
|
||||
*/
|
||||
findByQuery(query) {
|
||||
if (query === null || query === undefined) return null;
|
||||
@@ -311,10 +311,10 @@ export function createQueries({
|
||||
|
||||
/**
|
||||
* Get vessels within a range of a point, sorted nearest-first.
|
||||
* @param {Cesium.Cartesian3} centerCartesian Center of the search.
|
||||
* @param {{x: number, y: number, z: number}} centerCartesian ECEF centre of the search.
|
||||
* @param {number} rangeM Max distance in meters (non-finite = unbounded).
|
||||
* @param {number} [maxCount=25] Maximum entries to return.
|
||||
* @returns {Array<{ mmsi: string, name: string, position: Cesium.Cartesian3, distanceM: number }>}
|
||||
* @returns {Array<{ mmsi: string, name: string, position: {x: number, y: number, z: number}, distanceM: number }>}
|
||||
*/
|
||||
getNearby(centerCartesian, rangeM, maxCount = 25) {
|
||||
const records = state.records.all;
|
||||
@@ -330,7 +330,7 @@ export function createQueries({
|
||||
continue;
|
||||
const position = components.rendering.iconPosition(record);
|
||||
if (!position) continue;
|
||||
const distanceM = Cesium.Cartesian3.distance(centerCartesian, position);
|
||||
const distanceM = distance(centerCartesian, position);
|
||||
if (!Number.isFinite(distanceM) || distanceM > range) continue;
|
||||
entries.push({
|
||||
mmsi: record.mmsi,
|
||||
@@ -346,7 +346,7 @@ export function createQueries({
|
||||
/**
|
||||
* Get positions of all currently loaded vessels.
|
||||
* @param {number} [maxCount=800] Maximum entries to return.
|
||||
* @returns {Array<{ id: string, label: string, position: Cesium.Cartesian3, latitude: number, longitude: number }>}
|
||||
* @returns {Array<{ id: string, label: string, position: {x: number, y: number, z: number}, latitude: number, longitude: number }>}
|
||||
*/
|
||||
/**
|
||||
* Whether this layer still carries a vessel, in O(1).
|
||||
@@ -465,7 +465,7 @@ export function createQueries({
|
||||
* @param {Object} [options={}] - Options from the detection system.
|
||||
* @param {number} [options.maxCount] - Maximum objects to return (defaults to all).
|
||||
* @param {number} [options.seed] - Seed offset for stride sampling.
|
||||
* @returns {Array<{position: Cesium.Cartesian3, id: string, type: string, skipLabel: boolean}>}
|
||||
* @returns {Array<{position: {x: number, y: number, z: number}, id: string, type: string, skipLabel: boolean}>}
|
||||
*/
|
||||
getDetectableObjects(options = {}) {
|
||||
if (!state.feed.enabled || !state.icons?.show) return [];
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { createVesselFeed } from './ingestion.js';
|
||||
import { VesselRecords } from './records.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { DEFAULT_AIS_RUNTIME } from './policy.js';
|
||||
|
||||
export function createVesselState({ source, services }) {
|
||||
@@ -18,7 +17,8 @@ export function createVesselState({ source, services }) {
|
||||
|
||||
vesselState._lastCamPoseSig = '';
|
||||
|
||||
vesselState._scratchFocusScreen = new Cesium.Cartesian2();
|
||||
/** Screen position the focus pass projects into, reused every pass. */
|
||||
vesselState._scratchFocusScreen = { x: 0, y: 0 };
|
||||
|
||||
vesselState.DEFAULT_VESSEL_OVERLAY_HOST = Object.freeze({
|
||||
setEntries: setOverlayEntries,
|
||||
@@ -64,7 +64,7 @@ export function createVesselState({ source, services }) {
|
||||
keyTarget: null,
|
||||
/** Exact callback registered on keyTarget. */
|
||||
keydownHandler: null,
|
||||
/** Cesium trackedEntityChanged listener disposer. */
|
||||
/** Follow-change listener disposer. */
|
||||
trackedEntityRemover: null,
|
||||
/** Test-only key target for enable-time interaction installation. */
|
||||
interactionKeyTarget: null,
|
||||
@@ -79,7 +79,7 @@ export function createVesselState({ source, services }) {
|
||||
selectedRecord: null,
|
||||
/** @type {{setPositions: Function, clear: Function, destroy: Function}|null} Selected-vessel fading trail */
|
||||
trail: null,
|
||||
/** @type {Cesium.Cartesian3[]} Chronological trail vertices (oldest first) */
|
||||
/** @type {{x: number, y: number, z: number}[]} Chronological ECEF trail vertices (oldest first) */
|
||||
trailPositions: [],
|
||||
/** @type {string|null} MMSI that owns the active selected-vessel trail. */
|
||||
trailMmsi: null,
|
||||
|
||||
@@ -131,9 +131,7 @@
|
||||
"src/layers/transit/testing.js",
|
||||
"src/layers/vessels/cameraArea.js",
|
||||
"src/layers/vessels/evidence.js",
|
||||
"src/layers/vessels/queries.js",
|
||||
"src/layers/vessels/rendering.js",
|
||||
"src/layers/vessels/state.js",
|
||||
"src/layers/vessels/tracking.js",
|
||||
"src/layers/weather/index.js",
|
||||
"src/layers/weather/shellRendering.js",
|
||||
|
||||
Reference in new issue
Block a user