Files
gods-eye-view/src/app/constructCatalog.js
T
German Khokhlov ea1e2f9c04 feat(localAdsb): render on Navara
Task 12b. src/layers/localAdsb/render/navara.js implements the Local
ADS-B renderer interface of 12a on Navara:
- markers: the shared aircraft renderer's glyph sets in magenta #ff4fd8
  (class silhouette and scale, ×3 near / ×0.5 far, always on top), drawn
  under every sprite layer as Cesium draws the entities; each frame writes
  what Cesium's CallbackProperties gave (position, screen rotation,
  visibility) and the 2,000 km display distance;
- the 978 MHz UAT ring: its own sprite set, a white ring atlas tinted
  #ffb3ef, Cesium's 24 px point plus its 1.5 px outline (27 px), the same
  distance scale and distance, pickable as its aircraft;
- models (the Flights GLBs, magenta MIX tint), trail and head: the shared
  aircraft renderer's; the camera never follows a local aircraft.
Registered by registerNavaraLayerRenderers (import()); the Navara catalog
now offers flights, military and local ADS-B.

- ?qaFeed=local-adsb:fixture: the local receivers' answer in the server's
  format (src/bench/w1Feeds syntheticLocalReceivers: 40 aircraft near JFK,
  10 on 978 MHz UAT) through the layer's own decoder-feed session
  (sources.localAdsbFeeds, null by default: the layer makes its own).
- qa-w1-layers --layer=local-adsb: a click selects a marker and shows its
  card with the receiver line, the camera does not follow, Escape leaves
  the selection (it never answered Escape), empty map releases it.

qa-w1-layers local-adsb: Cesium 12/12, Navara 13/13, --compare parity
(global pose: the 2.27 px camera offset only). qa-flights-engines
--layer=local-adsb: 14/14 (fills exact; UAT rings side by side in
docs/migration/phase3/localAdsb).
2026-10-17 06:50:15 +04:00

309 lines
10 KiB
JavaScript

import { resolveCatalogSources } from './sourceComposition.js';
import { createWeatherClock } from '../layers/weather/clock.js';
import { createWeatherLayer } from '../layers/weather/index.js';
import { createCyclonesLayer } from '../layers/cyclones/index.js';
import { createWindLayer } from '../layers/wind/index.js';
import { createLayerCatalog } from './catalog.js';
import { createLayerAvailability } from './layers/renderers.js';
import { APPLICATION_LAYER_DIRECTORY } from './layers/directory.js';
import { LAYER_STATE_REGISTRY } from '../data/layerState.js';
import { createMilitaryRegistry } from '../layers/aircraft/classification.js';
import { createApplicationFlights } from './layers/flights.js';
import { createApplicationMilitary } from './layers/militaryFlights.js';
import { createApplicationVessels } from './layers/aisLiveVessels.js';
import { createApplicationCctv } from './layers/cctv.js';
import { createApplicationRadio } from './layers/radio.js';
import { createApplicationTraffic } from './layers/traffic.js';
import { createApplicationBikeshare } from './layers/bikeshare.js';
import { createApplicationDirections } from './layers/directions.js';
import { createApplicationRecentImagery } from './layers/recentImagery.js';
import { createApplicationTransit } from './layers/transit.js';
import { createApplicationInstallations } from './layers/militaryInstallations.js';
import { createApplicationSatellites } from './layers/satellites.js';
import { createApplicationLaunches } from './layers/rocketLaunches.js';
import { createApplicationAlpr } from './layers/alprCameras.js';
import { createApplicationLocalAdsb } from './layers/localAdsb.js';
import { createApplicationAwareness } from './layers/militaryAwareness.js';
import { createApplicationFirms } from './layers/firms.js';
import { createApplicationEarthquakes } from './layers/earthquakes.js';
import { createApplicationFirePerimeters } from './layers/perimeters.js';
import { createApplicationCables } from './layers/submarineCables.js';
import { createApplicationStreetLevel } from './layers/streetLevel.js';
import { createInfrastructureLayers } from '../data/infrastructure.js';
import { localGeoJsonServices } from './localGeojsonServices.js';
import { createBhoteKoshiEventLayer } from '../data/bhoteKoshiEvent.js';
import { createBhoteKoshiLocatorLayer } from '../data/bhoteKoshiLocator.js';
/**
* Hardware-local layers are registered like any other but never enter share
* links or stored layer state: another browser cannot have this receiver.
*/
export const LOCAL_ONLY_LAYER_METADATA = Object.freeze([
Object.freeze({ id: 'local-adsb', disposition: 'local-only' }),
]);
/** Serialization metadata for every layer the application catalog constructs. */
export const APPLICATION_LAYER_METADATA = Object.freeze([
...LAYER_STATE_REGISTRY,
...LOCAL_ONLY_LAYER_METADATA,
]);
/** Construct the current catalog without choosing any source provider.
* `engineKind` ('cesium' | 'navara'): only the layers that engine can show
* (src/app/layers/renderers.js) are constructed, in the same order; the
* catalog keeps the others' metadata (`unavailableMetadata`) and carries
* the engine's `availability`.
* Scene engines remain page-owned; layers and classification have this app's lifetime.
* The manager owns layer destruction, while abort releases classification even if startup fails.
*/
export function createApplicationCatalog({
surface,
sources,
signal,
metadata = APPLICATION_LAYER_METADATA,
vesselOptions,
resolveAsset,
nepalBoundaryResolver,
streetLevelProviders,
engineKind = 'cesium',
availability = createLayerAvailability(engineKind),
}) {
if (!signal?.addEventListener)
throw new TypeError('An application lifetime signal is required');
signal.throwIfAborted();
if (!surface?.groundFloor || !surface?.terrain)
throw new TypeError('Application surface services are required');
const sourceComposition = resolveCatalogSources(sources);
sources = sourceComposition.sources;
const militaryRegistry = createMilitaryRegistry();
const weatherClock = createWeatherClock();
const dispose = () => {
signal.removeEventListener('abort', dispose);
militaryRegistry.dispose();
weatherClock.destroy();
};
signal.addEventListener('abort', dispose, { once: true });
try {
if (sourceComposition.isConfigured('military'))
militaryRegistry.configureSource(sources.military, { signal });
// Shared instances (awareness and launches read others) are made once,
// when the first layer that needs them is built.
const once = (create) => {
let value;
return () => (value ??= create());
};
const flights = once(() =>
createApplicationFlights({
surface,
source: sources.flights,
militaryRegistry,
resolveAsset,
}),
);
const military = once(() =>
createApplicationMilitary({
surface,
source: sources.military,
militaryRegistry,
resolveAsset,
}),
);
const vessels = once(() =>
createApplicationVessels({
source: sources.vessels,
options: vesselOptions,
}),
);
const installations = once(() =>
createApplicationInstallations({
surface,
source: sources.installations,
}),
);
const satellites = once(() =>
createApplicationSatellites({
source: sources.satellites,
}),
);
// Catalog order: [layer id(s), construction]. Only the layers the
// engine can show are constructed (renderers.js).
const entries = [
['bhote-koshi-2026', () => createBhoteKoshiEventLayer()],
[
'bhote-koshi-locator',
() =>
createBhoteKoshiLocatorLayer({
boundaryResolver: nepalBoundaryResolver,
}),
],
['flights', flights],
['military', military],
[
'local-adsb',
() =>
createApplicationLocalAdsb({
surface,
// QA fixture receivers (?qaFeed=local-adsb:fixture, dev only).
...(sources.localAdsbFeeds
? { feeds: sources.localAdsbFeeds }
: {}),
enrichment: sources.flights,
displayParams: () => flights().getParams(),
...(resolveAsset ? { resolveAsset } : {}),
}),
],
[
'earthquakes',
() => createApplicationEarthquakes({ source: sources.earthquakes }),
],
[
'fire-perimeters',
() =>
createApplicationFirePerimeters({
source: sources['fire-perimeters'],
}),
],
[
'alpr-cameras',
() => createApplicationAlpr({ surface, source: sources.alpr }),
],
[
'street-level',
() =>
createApplicationStreetLevel({
surface,
sources: { mapillary: sources.mapillary },
providers: streetLevelProviders,
}),
],
['satellites', satellites],
[
'rocket-launches',
() =>
createApplicationLaunches({
source: sources.launches,
satellites: satellites(),
}),
],
[
'traffic',
() => createApplicationTraffic({ source: sources.traffic, surface }),
],
['cctv', () => createApplicationCctv({ surface, source: sources.cctv })],
[
'radio',
() => createApplicationRadio({ surface, source: sources.radio }),
],
[
'transit',
() => createApplicationTransit({ surface, source: sources.transit }),
],
[
'bikeshare',
() => createApplicationBikeshare({ source: sources.bikeshare }),
],
[
'directions',
() => createApplicationDirections({ source: sources.directions }),
],
[
'recent-imagery',
() =>
createApplicationRecentImagery({
source: sources['recent-imagery'],
}),
],
['ais-live-vessels', vessels],
['military-installations', installations],
[
'military-awareness',
() =>
createApplicationAwareness({
flights: flights(),
military: military(),
vessels: vessels(),
installations: installations(),
}),
],
[
'wind',
() => createWindLayer({ feed: sources.wind, clock: weatherClock }),
],
...['weather-radar', 'weather-satellite', 'weather-lightning'].map(
(id) => [
id,
() =>
createWeatherLayer({
feed: sources.weather,
id,
clock: weatherClock,
}),
],
),
[
'weather-cyclones',
() => createCyclonesLayer({ feed: sources.cyclones }),
],
[
['local-datacenters', 'local-dams'],
() => createInfrastructureLayers(localGeoJsonServices),
],
[
'telegeography-submarine-cables',
() => createApplicationCables({ source: sources.cables }),
],
[
'local-firms',
() =>
createApplicationFirms({
surface,
id: 'local-firms',
name: 'FIRMS Active Fires',
icon: '▲',
source: 'NASA FIRMS · LIVE',
feed: sources.firms,
}),
],
];
const available = (id) => availability.isAvailable(id);
const layers = [];
for (const [ids, create] of entries) {
const wanted = [ids].flat().filter(available);
if (!wanted.length) continue;
for (const layer of [create()].flat())
if (wanted.includes(layer.id)) layers.push(layer);
}
const catalog = createLayerCatalog(
layers,
metadata.filter(({ id }) => available(id)),
);
return Object.freeze({
...catalog,
engineKind,
// Layers this engine cannot show: their metadata, so links keep their
// state (data.js), and the stable availability API (renderers.js).
unavailableMetadata: Object.freeze(
metadata.filter(({ id }) => !available(id)),
),
availability,
getSourceAvailability: sourceComposition.createAvailabilityLookup(
catalog.layers,
{
omitted: new Set(
APPLICATION_LAYER_DIRECTORY.map(({ id }) => id).filter(
(id) => !available(id),
),
),
},
),
militaryRegistry,
surface,
weatherClock,
});
} catch (error) {
dispose();
throw error;
}
}