Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

Merge branch 'main' into feat/aqhi

Sameh Khamis046126eb36ca
diff --cc CHANGELOG.md
index 10a525546,b31cb8475..f905cb369
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -598,19 -1041,8 +1041,21 @@@ Launch payloads with missing records no
This changelog records public product changes. For the authoritative description
of current runtime behavior, see [`docs/CURRENT-STATE.md`](docs/CURRENT-STATE.md).
+## [Unreleased]
+
+- Add a keyless Air quality layer to the Weather group, with Environment and
+ Climate Change Canada's AQHI as the first registered provider. Readings carry
+ `{ provider, scale, value, band }` so another network can be added without
+ inventing a shared numeric meaning across indices that do not share one; the
+ row and readout both state that coverage is Canada only. The WEATHER card
+ shows the band legend and the highest readings currently in view. AQHI is
+ reported as an integer from 1 with an open-ended "10+", so readings round to
+ that published form rather than the decimal precision the API returns.
+ Readings older than six hours are dropped, and the layer reports `stale`
+ through `getStats()` so feed provenance cannot describe an aged feed as live.
+
+ ### Other changes
+
- Add ECMWF IFS model selection to Wind (#464, thanks @beneduzi), with model-scoped forecast-step caches, cancellation of replaced requests, and separate issue/valid timestamps.
- Add bounded Director feature actions with accessible controls, explicit camera/layer admission and cancellation; restore pack geometry on same-shot seek. Preserve existing scenes and content attribution.
diff --cc README.md
index 9f69fdbd6,554f9b57f..68da35027
--- a/README.md
+++ b/README.md
@@@ -291,10 -309,10 +309,11 @@@ Twenty layers and map sources. **Eighte
| 🚒 **Live Vessels** | Thousands of ships worldwide | AISStream | 🟑 |
| πŸ›°οΈ **Satellites** | 838-object catalog, color-coded by class with a live legend β€” the **DENSE** chip drops in the whole Starlink shell | CelesTrak | 🟒 |
| 🌍 **Earthquakes** | Global seismic activity, last 24h | USGS | 🟒 |
+| ◍ **Air quality** | Live AQHI on the published 1–10+ health-risk scale, with a Weather-panel card showing the band legend and the highest readings in view. **Canada only** β€” ECCC is the first registered provider | ECCC MSC GeoMet | 🟒 |
| πŸš— **Traffic** | Simulated vehicles on OSM roads. With TomTom, live flow speeds drive the simulation and congestion colors below ~8 km; individual vehicle positions are not live observations | TomTom + OSM | 🟒 simulation Β· 🟑 live flow speeds |
- | πŸ“Ή **CCTV Mesh** | ~3,600 public cameras projected _into_ the 3D space β€” Austin Β· Texas (TxDOT) Β· California (Caltrans) Β· London (TfL) Β· Ontario (511) Β· Finland (Fintraffic) Β· British Columbia (DriveBC) Β· Estonia (Tallinn, Tarktee) Β· Delaware (DelDOT live video) Β· New South Wales (Live Traffic NSW) Β· Calgary. Positions are published; poses are estimated priors **you calibrate by dragging a gizmo on the camera itself** | City APIs | 🟒 |
+ | πŸ“Ή **CCTV Mesh** | ~3,900 public cameras projected _into_ the 3D space β€” Austin Β· Texas (TxDOT) Β· California (Caltrans) Β· London (TfL) Β· Ontario (511) Β· Finland (Fintraffic) Β· British Columbia (DriveBC) Β· Estonia (Tallinn, Tarktee) Β· Delaware (DelDOT live video) Β· New South Wales (Live Traffic NSW) Β· Calgary Β· Norway (Statens vegvesen), plus opt-in New York City (NYC DOT TMC, needs your own NYC DOT agreement). Positions are published; poses are estimated priors **you calibrate by dragging a gizmo on the camera itself** | City APIs | 🟒 |
| πŸ“· **Mapped ALPR Cameras** | License-plate-reader camera locations tagged by OpenStreetMap contributors, loaded one city-sized view at a time, with **SHOW NEAREST**. Locations and tags only: no plate data, no video | OpenStreetMap (incl. DeFlock mapping) | 🟒 |
+ | πŸ“· **Street Level** | Street-level photos behind one panel, one chip per provider: coverage on the streets, image cones, an embedded viewer and **FOLLOW**. Mapillary, Google Street View, KartaView and Panoramax | Mapillary Β· Google Β· KartaView Β· Panoramax | 🟒 KartaView, Panoramax Β· 🟑 Mapillary token Β· πŸ”΄ Google Maps key |
| πŸ“» **Radio** | Geolocated world radio with an **analog tuner** β€” drag the needle across up to 750 stations and the globe flies to each broadcaster | Radio Browser / broadcasters | 🟒 |
| 🚌 **Transit** | Live buses, trams, metros, trains and ferries with delayed playback between reports, selected-vehicle trails, and mode-coloured DETECT labels β€” Boston, Austin, Minneapolis, Helsinki, the Netherlands, Norway, South East Queensland | Operator GTFS-Realtime feeds | 🟒 |
| 🚲 **Bikeshare** | Live station availability | GBFS | 🟒 |
diff --cc docs/CURRENT-STATE.md
index cdaa687b8,eea578427..c77d042c0
--- a/docs/CURRENT-STATE.md
+++ b/docs/CURRENT-STATE.md
@@@ -2843,12 -3161,11 +3161,12 @@@ its criteria cannot be silently ignored
| Layer | Source | File | Proxy | Update Interval |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | -------------------------------------------------------- | --------------------------------------------------------------------------------- |
- | Live Flights ✈️ | OpenSky Network; bounded adsb.lol regional fallback | `src/data/flights.js` | `/api/opensky` (OAuth + fallback) | 30s |
- | Military Flights πŸŽ–οΈ | adsb.lol /v2/mil | `src/data/militaryFlights.js` | `/api/adsblol/mil` | 15s |
- | Live AIS Vessels 🚒 | AISStream websocket | `src/data/aisLiveVessels.js` | `/api/ais-live` | 60s (+800ms visibility pass) |
+ | Live Flights ✈️ | OpenSky Network; bounded adsb.lol regional fallback | `src/data/flights.js` | `/api/flights` (OAuth + fallback) | 30s |
+ | Military Flights πŸŽ–οΈ | adsb.lol /v2/mil | `src/data/militaryFlights.js` | `/api/military` | 15s |
+ | Live AIS Vessels 🚒 | AISStream websocket | `src/data/aisLiveVessels.js` | `/api/vessels` | 60s (+800ms visibility pass) |
| Mapped Installations βŒ– | OpenFreeMap military areas; optional configured Overpass names and Google Places search | `src/data/militaryInstallations.js` | OpenFreeMap tiles, `/api/military-installations`, `/api/google/text-search` | viewport-driven; transient errors back off, missing capability switches to tiles |
| Earthquakes | USGS | `src/data/earthquakes.js` | β€” | 60s |
+| Air quality | ECCC MSC GeoMet OGC API (AQHI, Canada only) | `src/layers/airQuality/` | β€” | 20 min readings, 12 h station catalog |
| Satellites | CelesTrak | `src/data/satellites.js` | `/api/celestrak` | 120s |
| Space Missions (30d) | Launch Library 2 + CelesTrak | `src/data/rocketLaunches.js` | `/api/launches` + `/api/celestrak/active` | 5 min |
| Traffic | Selectable TomTom / OpenStreetMap / Hybrid roads; optional TomTom flow (BYOK) | `src/data/traffic.js` | browser-direct OpenFreeMap tiles; `/api/tomtom` for flow | viewport-driven; capped tile cache |
diff --cc package.json
index eca8aa8b7,d5c900cbd..c46fa6670
--- a/package.json
+++ b/package.json
@@@ -167,8 -175,8 +175,9 @@@
"./layers/traffic": "./src/layers/traffic/index.js",
"./layers/bikeshare": "./src/layers/bikeshare/index.js",
"./layers/directions": "./src/layers/directions/index.js",
+ "./layers/directions/source": "./src/layers/directions/source.js",
"./layers/cctv": "./src/layers/cctv/index.js",
+ "./layers/air-quality": "./src/layers/airQuality/index.js",
"./layers/alpr": "./src/layers/alpr/index.js",
"./layers/radio": "./src/layers/radio/index.js",
"./layers/submarine-cables": "./src/layers/submarineCables/index.js",
@@@ -229,9 -237,9 +238,10 @@@
"./layers/alpr/source": "./src/layers/alpr/source.js",
"./layers/bikeshare/source": "./src/layers/bikeshare/source.js",
"./layers/cctv/source": "./src/layers/cctv/source.js",
+ "./layers/air-quality/source": "./src/layers/airQuality/source.js",
"./layers/earthquakes/source": "./src/layers/earthquakes/source.js",
"./layers/perimeters/source": "./src/layers/perimeters/source.js",
+ "./layers/gnss/source": "./src/layers/gnss/source.js",
"./layers/firms/source": "./src/layers/firms/source.js",
"./layers/installations/source": "./src/layers/installations/source.js",
"./layers/launches/source": "./src/layers/launches/source.js",
diff --cc scripts/package-boundaries.json
index 67f304f3f,2fa53ac8e..9739b1e66
--- a/scripts/package-boundaries.json
+++ b/scripts/package-boundaries.json
@@@ -2028,10 -2250,14 +2250,18 @@@
"src/data/local_data/osm_military_names/names.json",
"src/layers/installations/namedMarkers.js",
"src/data/infrastructureOverlayEntry.js",
+ "src/sources/infrastructureData.js",
+ "src/tools/functions.js",
+ "src/voice/actionSchemas.js",
+ "src/view/index.js",
+ "src/app/embed.js",
+ "src/data/cameraFraming.js",
+ "src/data/geoImportPins.js",
- "src/data/geoImportImages.js"
++ "src/data/geoImportImages.js",
+ "src/app/layers/airQuality.js",
+ "src/layers/airQuality/index.js",
+ "src/layers/airQuality/model.js",
+ "src/layers/airQuality/source.js"
],
"external": [
"hls.js",
@@@ -2516,10 -2806,8 +2810,12 @@@
"src/data/local_data/osm_military_names/names.json",
"src/layers/installations/namedMarkers.js",
"src/data/infrastructureOverlayEntry.js",
+ "src/sources/infrastructureData.js",
- "src/data/cameraFraming.js"
++ "src/data/cameraFraming.js",
+ "src/app/layers/airQuality.js",
+ "src/layers/airQuality/index.js",
+ "src/layers/airQuality/model.js",
+ "src/layers/airQuality/source.js"
],
"external": [
"hls.js",
@@@ -2862,8 -3188,7 +3196,9 @@@
"src/layers/perimeters/source.js",
"src/layers/perimeters/records.js",
"src/layers/submarineCables/bundledSource.js",
- "src/layers/gnss/source.js"
++ "src/layers/gnss/source.js",
+ "src/layers/airQuality/model.js",
+ "src/layers/airQuality/source.js"
],
"external": []
},
@@@ -3083,21 -3423,153 +3433,170 @@@
],
"external": []
},
+ "tools": {
+ "exports": ["./tools"],
+ "modules": [
+ "src/tools/index.js",
+ "src/tools/catalog.js",
+ "src/tools/schema.js",
+ "src/tools/area.js",
+ "src/tools/results.js",
+ "src/tools/places.js",
+ "src/tools/queries/hazards.js",
+ "src/tools/queries/space.js",
+ "src/tools/queries/aviation.js",
+ "src/tools/queries/media.js",
+ "src/tools/queries/places.js",
+ "src/tools/queries/mobility.js",
+ "src/tools/queries/environment.js",
+ "src/tools/queries/brief.js",
+ "src/tools/queries/maritime.js",
+ "src/tools/queries/share.js",
+ "src/data/idSwitches.js",
+ "src/data/layerState.js",
+ "src/data/layerStateTokenReservations.json",
+ "src/sources/gbfsStations.js",
+ "src/sources/tle.js",
+ "src/data/satellitePass.js",
+ "src/tools/queries/atmosphere.js",
+ "src/layers/wind/inspection.js",
+ "src/layers/wind/model.js",
+ "src/layers/wind/fields.js",
+ "src/tools/queries/imagery.js",
+ "src/tools/queries/cables.js",
+ "src/tools/queries/surveillance.js",
+ "src/tools/queries/infrastructure.js",
+ "src/tools/queries/events.js",
+ "src/data/bhoteKoshiFloodPath.js",
+ "src/tools/functions.js",
+ "src/tools/surfaces.js",
+ "src/layers/transit/policy.js",
+ "src/data/transitFeeds.js",
+ "src/layers/transit/movement.js",
+ "src/data/contactPlayback.js",
+ "src/data/layerSnapshot.js",
+ "src/data/feedState.js",
+ "src/loadingFeedback.js",
+ "src/data/installationFeedback.js",
+ "src/view/index.js",
+ "src/tools/views.js",
+ "src/tools/globePanel.js",
+ "src/tools/queries/panelRequest.js"
+ ],
+ "external": ["satellite.js"]
+ },
+ "tools-mcp": {
+ "exports": ["./tools/mcp"],
+ "modules": [
+ "src/tools/mcp/index.js",
+ "src/tools/mcp/protocol.js",
+ "src/tools/mcp/http.js",
+ "src/tools/catalog.js",
+ "src/tools/schema.js"
+ ],
+ "external": []
+ },
+ "tools-panel": {
+ "exports": ["./tools/panel"],
+ "modules": [
+ "src/tools/panel.js",
+ "src/tools/globePanel.js",
+ "src/app/globePanelRuntime.js"
+ ],
+ "external": []
+ },
+ "tools-services": {
+ "exports": ["./tools/services"],
+ "modules": [
+ "src/tools/services.js",
+ "src/layers/bikeshare/registry.js",
+ "src/layers/bikeshare/source.js",
+ "src/layers/cctv/source.js",
+ "src/layers/cctv/sourcePolicy.js",
+ "src/layers/cyclones/source.js",
+ "src/sources/httpBody.js",
+ "src/layers/earthquakes/source.js",
+ "src/layers/earthquakes/records.js",
+ "src/layers/firms/source.js",
+ "src/layers/installations/source.js",
+ "src/sources/requestDeadline.js",
+ "src/data/militaryNames.js",
+ "src/sources/militaryTileGeometry.js",
+ "src/data/bundledJson.js",
+ "src/data/retryableLoad.js",
+ "src/data/local_data/osm_military_names/names.json",
+ "src/sources/openFreeMap.js",
+ "src/sources/vectorTiles.js",
+ "src/sources/phaseTiming.js",
+ "src/data/tomtomTiles.js",
+ "src/sources/capability.js",
+ "src/data/militaryInstallationData.js",
+ "src/layers/launches/source.js",
+ "src/layers/perimeters/source.js",
+ "src/layers/radio/source.js",
+ "src/layers/radio/policy.js",
+ "src/layers/satellites/source.js",
+ "src/layers/traffic/source.js",
+ "src/layers/traffic/roadModes.js",
+ "src/data/flowMatch.js",
+ "src/layers/traffic/flowSource.js",
+ "src/layers/traffic/flowDecode.js",
+ "src/sources/overpassRoads.js",
+ "src/layers/transit/source.js",
+ "src/sources/transitHistory.js",
+ "src/services/requests.js",
+ "src/sources/overpassFeatures.js",
+ "src/sources/featureSource.js",
+ "src/sources/overpassFeaturesRecords.js",
+ "src/sources/featureGeometry.js",
+ "src/sources/live/standalone.js",
+ "src/sources/live/contract.js",
+ "src/data/aircraftEmergency.js",
+ "src/sources/live/aircraft.js",
+ "src/sources/live/vessels.js",
+ "src/tools/places.js",
+ "src/tools/catalog.js",
+ "src/tools/schema.js",
+ "src/layers/weather/source.js",
+ "src/layers/wind/source.js",
+ "src/sources/windBody.js",
+ "src/layers/recentImagery/catalog.js",
+ "src/layers/recentImagery/model.js",
+ "src/layers/submarineCables/bundledSource.js",
+ "src/layers/alpr/source.js",
+ "src/layers/alpr/policy.js",
+ "src/layers/alpr/records.js",
+ "src/layers/alpr/tileRecords.js",
+ "src/sources/infrastructureData.js",
+ "src/sources/eventPacks.js"
+ ],
+ "external": ["@mapbox/vector-tile", "pbf"]
+ },
+ "view": {
+ "exports": ["./view"],
+ "modules": [
+ "src/view/index.js",
+ "src/data/idSwitches.js",
+ "src/data/layerState.js",
+ "src/data/layerStateTokenReservations.json"
+ ],
+ "external": []
++ },
+ "air-quality": {
+ "exports": ["./layers/air-quality"],
+ "modules": [
+ "src/layers/airQuality/index.js",
+ "src/layers/airQuality/model.js",
+ "src/layers/airQuality/source.js"
+ ],
+ "external": ["cesium"]
+ },
+ "air-quality-source": {
+ "exports": ["./layers/air-quality/source"],
+ "modules": [
+ "src/layers/airQuality/model.js",
+ "src/layers/airQuality/source.js"
+ ],
+ "external": []
}
}
diff --cc src/app/constructCatalog.js
index a9728f317,184b51f17..832c174bc
--- a/src/app/constructCatalog.js
+++ b/src/app/constructCatalog.js
@@@ -23,9 -24,10 +24,11 @@@ import { createApplicationLocalAdsb } f
import { createApplicationAwareness } from './layers/militaryAwareness.js';
import { createApplicationFirms } from './layers/firms.js';
import { createApplicationEarthquakes } from './layers/earthquakes.js';
+import { createApplicationAirQuality } from './layers/airQuality.js';
import { createApplicationFirePerimeters } from './layers/perimeters.js';
+ import { createApplicationGnssIntegrity } from './layers/gnss.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';
diff --cc src/app/constructCatalog.test.mjs
index 3a802edbe,f8ebb1e73..9e1059c33
--- a/src/app/constructCatalog.test.mjs
+++ b/src/app/constructCatalog.test.mjs
@@@ -39,7 -40,7 +40,7 @@@ test('catalogs construct distinct layer
signal: b.signal,
surface: fixtureSurface(b.signal),
});
- assert.equal(first.layers.length, 30);
- assert.equal(first.layers.length, 31);
++ assert.equal(first.layers.length, 32);
assert.ok(first.get('local-adsb'), 'Local ADS-B is registered');
assert.deepEqual(
first.metadata.find(({ id }) => id === 'local-adsb'),
@@@ -140,3 -142,53 +142,53 @@@ function fixtureSurface(signal)
eventTarget: null,
});
}
+
+ test('Mapillary can be omitted or replaced without changing catalog membership', (t) => {
+ const lifetime = new AbortController();
+ t.after(() => lifetime.abort());
+ const sources = fixtureSources([], []);
+ delete sources.mapillary;
+ const options = {
+ sources,
+ signal: lifetime.signal,
+ surface: fixtureSurface(lifetime.signal),
+ };
+ const catalog = createApplicationCatalog(options);
- assert.equal(catalog.layers.length, 31);
++ assert.equal(catalog.layers.length, 32);
+ assert.deepEqual(catalog.get('street-level').providerIds, []);
+ assert.equal(
+ catalogControlServices(catalog).streetLevelLayer,
+ catalog.get('street-level'),
+ );
+ assert.match(
+ catalog.get('street-level').getUIState().coverage.hint,
+ /No street-level imagery providers/,
+ );
+ const provider = fakeStreetLevelProvider({
+ id: 'example',
+ pickPrefix: 'example:',
+ });
+ const replacement = createApplicationCatalog({
+ ...options,
+ streetLevelProviders: [provider],
+ });
+ assert.deepEqual(replacement.get('street-level').providerIds, ['example']);
+ assert.deepEqual(replacement.metadata, catalog.metadata);
+ assert.equal(provider.calls.activate, 0, 'construction must not acquire');
+ assert.deepEqual(
+ createApplicationCatalog({
+ ...options,
+ sources: fixtureSources([], []),
+ streetLevelProviders: [],
+ }).get('street-level').providerIds,
+ [],
+ );
+ assert.throws(
+ () =>
+ createApplicationCatalog({
+ ...options,
+ sources: { ...sources, mapillary: {} },
+ }),
+ /Mapillary source/,
+ );
+ });
diff --cc src/app/sourceComposition.js
index 000000000,0b516f5b4..0fc619142
mode 000000,100644..100644
--- a/src/app/sourceComposition.js
+++ b/src/app/sourceComposition.js
@@@ -1,0 -1,114 +1,115 @@@
+ const contract = (layers, methods) =>
+ Object.freeze({
+ layers: Object.freeze(layers),
+ methods: Object.freeze(methods),
+ });
+
+ /** Acquisition contracts and their consumers; records remain family-specific. */
+ export const CATALOG_SOURCE_CONTRACTS = Object.freeze({
+ directions: contract(['directions'], ['getRoute']),
+ 'recent-imagery': contract(
+ ['recent-imagery'],
+ ['searchHls', 'getThumbnail', 'getTileTemplate'],
+ ),
+ flights: contract(['flights'], ['getSnapshot']),
+ military: contract(['military'], ['getSnapshot']),
+ vessels: contract(['ais-live-vessels'], ['getSnapshot']),
+ cctv: contract(
+ ['cctv'],
+ ['getCatalog', 'getHealth', 'getFrameUrl', 'getMediaUrl'],
+ ),
+ radio: contract(['radio'], ['getDirectory', 'recordClick']),
+ traffic: contract(
+ ['traffic'],
+ [
+ 'requestRoads',
+ 'getStatus',
+ 'fetchFlowForBounds',
+ 'getFlowSessionStats',
+ 'resetFlowTileCache',
+ ],
+ ),
+ bikeshare: contract(['bikeshare'], ['getStations']),
+ installations: contract(
+ ['military-installations'],
+ ['getMappedSites', 'searchNearby'],
+ ),
+ satellites: contract(['satellites'], ['readGroup']),
+ launches: contract(['rocket-launches'], ['getLaunches', 'getActiveTle']),
+ alpr: contract(['alpr-cameras'], ['fetch']),
+ firms: contract(['local-firms'], ['getSnapshot']),
+ wind: contract(['wind'], ['getSnapshot']),
+ weather: contract(
+ ['weather-radar', 'weather-satellite', 'weather-lightning'],
+ ['getSnapshot'],
+ ),
+ cyclones: contract(['weather-cyclones'], ['getSnapshot']),
+ earthquakes: contract(['earthquakes'], ['getSnapshot']),
+ 'fire-perimeters': contract(['fire-perimeters'], ['getSnapshot']),
++ 'air-quality': contract(['air-quality'], ['getSnapshot']),
+ 'gnss-integrity': contract(['gnss-integrity'], ['getSnapshot']),
+ cables: contract(['telegeography-submarine-cables'], ['fetch']),
+ transit: contract(['transit'], ['requestSnapshot', 'getHistory']),
+ });
+
+ /** An omitted provider is unavailable, never an authoritative empty dataset. */
+ export class SourceUnavailableError extends Error {
+ constructor(name) {
+ super(`Data source not configured: ${name}`);
+ this.name = 'SourceUnavailableError';
+ this.code = 'unavailable';
+ this.unavailable = true;
+ this.retryable = false;
+ }
+ }
+
+ /** Validate supplied contracts and keep omitted sources inert during construction. */
+ export function resolveCatalogSources(supplied = {}) {
+ if (!supplied || typeof supplied !== 'object' || Array.isArray(supplied))
+ throw new TypeError('Catalog sources must be an object');
+ const sources = { ...supplied };
+ const missing = new Set();
+ for (const [name, { methods }] of Object.entries(CATALOG_SOURCE_CONTRACTS)) {
+ const source = sources[name];
+ if (source == null) {
+ missing.add(name);
+ const unavailable = () => {
+ throw new SourceUnavailableError(name);
+ };
+ sources[name] = Object.freeze({
+ label: name,
+ ...Object.fromEntries(methods.map((method) => [method, unavailable])),
+ });
+ } else if (methods.some((method) => typeof source[method] !== 'function')) {
+ throw new TypeError(`Invalid catalog source: ${name}`);
+ }
+ }
+ return {
+ sources,
+ isConfigured: (name) => !missing.has(name),
+ createAvailabilityLookup(layers) {
+ const byId = new Map(layers.map((layer) => [layer.id, layer]));
+ const availability = new Map();
+ for (const [name, { layers: ids }] of Object.entries(
+ CATALOG_SOURCE_CONTRACTS,
+ )) {
+ for (const id of ids) {
+ const layer = byId.get(id);
+ if (!layer) throw new Error(`Missing source consumer: ${id}`);
+ availability.set(
+ id,
+ Object.freeze({
+ available: !missing.has(name),
+ source: name,
+ reason: missing.has(name)
+ ? `${layer.name || id}: data source not configured`
+ : null,
+ }),
+ );
+ }
+ }
+ return (id) =>
+ availability.get(id) ?? byId.get(id)?.getSourceAvailability?.();
+ },
+ };
+ }
diff --cc src/app/sourceComposition.test.mjs
index 000000000,cf8646e25..422308f1e
mode 000000,100644..100644
--- a/src/app/sourceComposition.test.mjs
+++ b/src/app/sourceComposition.test.mjs
@@@ -1,0 -1,156 +1,156 @@@
+ import assert from 'node:assert/strict';
+ import test from 'node:test';
+ import {
+ resolveCatalogSources,
+ CATALOG_SOURCE_CONTRACTS,
+ } from './sourceComposition.js';
+ import { createApplicationCatalog } from './constructCatalog.js';
+ import { createSurfaceServices } from './surfaceServices.js';
+ import { createStandaloneLayerSources } from '../standalone/layerSources.js';
+ import { LayerLifecycle } from '../data/lifecycle.js';
+
+ function catalog(sources, t) {
+ const lifetime = new AbortController();
+ t.after(() => lifetime.abort());
+ return createApplicationCatalog({
+ sources,
+ signal: lifetime.signal,
+ surface: createSurfaceServices({
+ terrainSource: { getHeights: async () => [] },
+ signal: lifetime.signal,
+ eventTarget: null,
+ }),
+ });
+ }
+
+ test('every acquisition source can be omitted without losing catalog membership', (t) => {
+ const baseline = catalog(createStandaloneLayerSources(), t);
+ for (const name of Object.keys(CATALOG_SOURCE_CONTRACTS)) {
+ const sources = createStandaloneLayerSources({ [name]: null });
+ const actual = catalog(sources, t);
+ assert.deepEqual(actual.metadata, baseline.metadata, name);
+ for (const id of CATALOG_SOURCE_CONTRACTS[name].layers) {
+ assert.equal(actual.getSourceAvailability(id).available, false, id);
+ }
+ }
+ });
+
+ test('all acquisition sources may be absent, and enable fails before initializing or fetching', async (t) => {
+ const actual = catalog({}, t);
- assert.equal(actual.layers.length, 31);
++ assert.equal(actual.layers.length, 32);
+ const manager = new LayerLifecycle(
+ {},
+ { getSourceAvailability: actual.getSourceAvailability },
+ );
+ for (const layer of actual.layers) manager.register(layer);
+ for (const { layers: ids } of Object.values(CATALOG_SOURCE_CONTRACTS)) {
+ for (const id of ids) {
+ assert.equal(await manager.setEnabled(id, true), false, id);
+ assert.equal(manager.layers.get(id).initialized, false, id);
+ const row = manager.getAll().find((entry) => entry.id === id);
+ assert.equal(row.enabled, false);
+ assert.equal(row.stats.status, 'unavailable');
+ assert.match(row.stats.error, /data source not configured/);
+ }
+ }
+ });
+
+ test('configured sources retain identity; invalid implementations never become unavailable silently', () => {
+ const source = { getSnapshot: async () => [] };
+ assert.equal(
+ resolveCatalogSources({ earthquakes: source }).sources.earthquakes,
+ source,
+ );
+ for (const name of Object.keys(CATALOG_SOURCE_CONTRACTS)) {
+ assert.throws(
+ () => resolveCatalogSources({ [name]: {} }),
+ /Invalid catalog source/,
+ );
+ }
+ const missing = resolveCatalogSources({}).sources.earthquakes;
+ assert.throws(() => missing.getSnapshot(), { code: 'unavailable' });
+ });
+
+ test('standalone defaults allow exact replacements and explicit removal, and reject typos', () => {
+ const source = { getSnapshot: async () => [] };
+ const sources = createStandaloneLayerSources({
+ flights: source,
+ military: null,
+ });
+ assert.equal(sources.flights, source);
+ assert.equal(sources.military, null);
+ assert.equal(typeof sources.cctv.getCatalog, 'function');
+ assert.throws(
+ () => createStandaloneLayerSources({ fligts: source }),
+ /Unknown source/,
+ );
+ });
+
+ test('empty Street Level uses the shared unavailable lifecycle without initialization', async (t) => {
+ const actual = catalog({}, t);
+ const manager = new LayerLifecycle(
+ {},
+ { getSourceAvailability: actual.getSourceAvailability },
+ );
+ manager.register(actual.get('street-level'));
+ assert.equal(await manager.setEnabled('street-level', true), false);
+ assert.equal(manager.layers.get('street-level').initialized, false);
+ const row = manager.getAll()[0];
+ assert.equal(row.stats.status, 'unavailable');
+ assert.equal(row.stats.error, 'No street-level imagery providers configured');
+ assert.equal(await manager.setEnabled('street-level', false), true);
+ const configured = catalog(createStandaloneLayerSources(), t);
+ assert.equal(
+ configured.get('street-level').getSourceAvailability().available,
+ true,
+ );
+ });
+
+ test('availability lookup accepts frozen layers and uses their display names', () => {
+ const composition = resolveCatalogSources({});
+ const layers = Object.values(CATALOG_SOURCE_CONTRACTS)
+ .flatMap(({ layers }) => layers)
+ .map((id) =>
+ Object.freeze({
+ id,
+ name: id === 'fire-perimeters' ? 'Fire perimeters' : id,
+ }),
+ );
+ const lookup = composition.createAvailabilityLookup(layers);
+ assert.equal(
+ lookup('fire-perimeters').reason,
+ 'Fire perimeters: data source not configured',
+ );
+ assert.equal(Object.hasOwn(layers[0], 'getSourceAvailability'), false);
+ const manager = new LayerLifecycle({}, { getSourceAvailability: lookup });
+ manager.register(layers.find(({ id }) => id === 'fire-perimeters'));
+ assert.equal(
+ manager.getAll()[0].stats.error,
+ 'Fire perimeters: data source not configured',
+ );
+ });
+
+ test('absent military acquisition does not poll, suppress flights, or erase supplied classification', async (t) => {
+ let fetches = 0;
+ t.mock.method(globalThis, 'fetch', async () => {
+ fetches++;
+ throw new Error('Unexpected fallback acquisition');
+ });
+ const actual = catalog(createStandaloneLayerSources({ military: null }), t);
+ const registry = actual.militaryRegistry;
+ assert.equal(actual.getSourceAvailability('flights').available, true);
+ assert.equal(registry.isMilitaryLayerActive(), false);
+ assert.equal(registry.isMilitaryIcao('abc123'), false);
+ registry.registerMilitaryIcaos([' ABC123 ']);
+ await registry.refreshMilitaryRegistryIfStale();
+ assert.equal(registry.isMilitaryIcao('abc123'), true);
+ assert.equal(registry.isMilitaryIcao('def456'), false);
+ const manager = new LayerLifecycle(
+ {},
+ { getSourceAvailability: actual.getSourceAvailability },
+ );
+ manager.register(actual.get('military'));
+ assert.equal(await manager.setEnabled('military', true), false);
+ assert.equal(registry.isMilitaryLayerActive(), false);
+ assert.equal(fetches, 0);
+ });
diff --cc src/data/layerState.js
index ea43cfd15,d7175fd67..2522308b4
--- a/src/data/layerState.js
+++ b/src/data/layerState.js
@@@ -553,11 -582,6 +582,11 @@@ export const LAYER_STATE_TOKEN_RESERVAT
* owns stable URL ordering.
*/
export const LAYER_STATE_REGISTRY = Object.freeze([
+ Object.freeze({
+ id: 'air-quality',
- token: '0',
++ token: '4',
+ disposition: 'enabled-only',
+ }),
Object.freeze({
id: 'ais-live-vessels',
token: 'a',
diff --cc src/data/layerState.test.mjs
index 3bebbc7b3,631e5dfec..77b8f902f
--- a/src/data/layerState.test.mjs
+++ b/src/data/layerState.test.mjs
@@@ -199,8 -202,8 +202,8 @@@ function encode(state)
test('production registry is exact, canonical, and rejects incomplete contracts', async () => {
assert.equal(validateLayerStateRegistry(), true);
- assert.equal(REGISTERED_LAYER_IDS.length, 29);
- assert.equal(new Set(REGISTERED_LAYER_IDS).size, 29);
- assert.equal(REGISTERED_LAYER_IDS.length, 30);
- assert.equal(new Set(REGISTERED_LAYER_IDS).size, 30);
++ assert.equal(REGISTERED_LAYER_IDS.length, 31);
++ assert.equal(new Set(REGISTERED_LAYER_IDS).size, 31);
assert.ok(REGISTERED_LAYER_IDS.includes('transit'));
assert.deepEqual(REGISTERED_LAYER_IDS, [...REGISTERED_LAYER_IDS].sort());
assert.deepEqual(LEGACY_LAYER_STATE_TOKENS, {
@@@ -239,15 -242,19 +242,19 @@@
for (const [id, token] of Object.entries(LEGACY_LAYER_STATE_TOKENS)) {
assert.equal(LAYER_STATE_TOKEN_RESERVATIONS[id], token);
}
- assert.equal(nextLayerStateToken(), '3');
- assert.equal(nextLayerStateToken(), '4');
++ assert.equal(nextLayerStateToken(), '5');
assert.equal(
- nextLayerStateToken({ ...LAYER_STATE_TOKEN_RESERVATIONS, alpha: '0', bravo: '3' }),
- '4',
+ nextLayerStateToken({
+ ...LAYER_STATE_TOKEN_RESERVATIONS,
- alpha: '4',
- bravo: '5',
++ alpha: '5',
++ bravo: '6',
+ }),
- '6',
++ '7',
);
const digitsExhausted = {
...LAYER_STATE_TOKEN_RESERVATIONS,
...Object.fromEntries(
- [...'3456789'].map((digit) => [`prior-${digit}`, digit]),
- [...'456789'].map((digit) => [`prior-${digit}`, digit]),
++ [...'56789'].map((digit) => [`prior-${digit}`, digit]),
),
};
assert.equal(nextLayerStateToken(digitsExhausted), '00');
@@@ -296,18 -305,20 +305,20 @@@
true,
);
assert.equal(
- validateLayerStateAllocations(
- LAYER_STATE_TOKEN_RESERVATIONS,
- { ...LAYER_STATE_TOKEN_RESERVATIONS, future: '3', next: '4' },
- ),
+ validateLayerStateAllocations(LAYER_STATE_TOKEN_RESERVATIONS, {
+ ...LAYER_STATE_TOKEN_RESERVATIONS,
- future: '4',
- next: '5',
++ future: '5',
++ next: '6',
+ }),
true,
);
assert.throws(
- () => validateLayerStateAllocations(LAYER_STATE_TOKEN_RESERVATIONS, {
- ...LAYER_STATE_TOKEN_RESERVATIONS,
- future: '00',
- }),
- /next free token 3/,
+ () =>
+ validateLayerStateAllocations(LAYER_STATE_TOKEN_RESERVATIONS, {
+ ...LAYER_STATE_TOKEN_RESERVATIONS,
+ future: '00',
+ }),
- /next free token 4/,
++ /next free token 5/,
);
const beforeLastDigit = { ...digitsExhausted };
delete beforeLastDigit['prior-9'];
@@@ -328,10 -341,10 +341,10 @@@
assert.throws(
() =>
validateLayerStateAllocations(
- { ...LAYER_STATE_TOKEN_RESERVATIONS, merged: '0' },
- { ...LAYER_STATE_TOKEN_RESERVATIONS, merged: '0', competing: '0' },
- { ...LAYER_STATE_TOKEN_RESERVATIONS, merged: '4' },
- { ...LAYER_STATE_TOKEN_RESERVATIONS, merged: '4', competing: '4' },
++ { ...LAYER_STATE_TOKEN_RESERVATIONS, merged: '5' },
++ { ...LAYER_STATE_TOKEN_RESERVATIONS, merged: '5', competing: '5' },
),
- /next free token 3/,
- /next free token 5/,
++ /next free token 6/,
);
assert.throws(
() => validateLayerStateAllocations({ future: '00' }, { future: '01' }),
diff --cc src/data/layerStateTokenLedger.test.mjs
index 28223762e,a38a43d51..7bcfd96cb
--- a/src/data/layerStateTokenLedger.test.mjs
+++ b/src/data/layerStateTokenLedger.test.mjs
@@@ -122,20 -128,17 +128,23 @@@ test('reservation ledger is complete, p
{ ...parseLayerStateTokenReservations(reservationRows) },
{ ...LAYER_STATE_TOKEN_RESERVATIONS },
);
- assert.equal(Object.keys(LAYER_STATE_TOKEN_RESERVATIONS).length, 29);
- // The legacy assignments are a closed compatibility set that never grows, so
- // the ledger is exactly that set plus every token reserved since.
- assert.equal(Object.keys(LAYER_STATE_TOKEN_RESERVATIONS).length, 30);
++ assert.equal(Object.keys(LAYER_STATE_TOKEN_RESERVATIONS).length, 31);
assert.deepEqual(
{ ...LAYER_STATE_TOKEN_RESERVATIONS },
- { ...LEGACY_LAYER_STATE_TOKENS, 'air-quality': '0' },
+ {
+ ...LEGACY_LAYER_STATE_TOKENS,
+ 'street-level': '0',
+ 'gnss-integrity': '3',
++ 'air-quality': '4',
+ },
);
assert.throws(
- () => parseLayerStateTokenReservations(reservationRows.slice(1)),
+ () =>
+ parseLayerStateTokenReservations(
- // Dropping any legacy row must fail. This used to slice off row 0,
- // which is no longer a legacy reservation.
++ // Drop a legacy row by id; the first row sorts as air-quality, which
++ // is not a legacy reservation.
+ reservationRows.filter(([id]) => id !== 'ais-live-vessels'),
+ ),
/Missing or changed legacy/,
);
assert.throws(
@@@ -152,9 -155,9 +161,9 @@@
/Duplicate layer-state token reservation/,
);
assert.equal(
- parseLayerStateTokenReservations([...reservationRows, ['future', '3']])
- parseLayerStateTokenReservations([...reservationRows, ['future', '4']])
++ parseLayerStateTokenReservations([...reservationRows, ['future', '5']])
.future,
- '3',
- '4',
++ '5',
);
assert.throws(
() =>
@@@ -172,14 -175,14 +181,14 @@@
test('published retired digits and competing PRs advance the merge-time allocation', () => {
withPublishedBase(
- { rows: [...reservationRows, ['retired-layer', '3']] },
- { rows: [...reservationRows, ['retired-layer', '4']] },
++ { rows: [...reservationRows, ['retired-layer', '5']] },
(cwd) => {
const published = readPublishedLayerStateReservations('HEAD', cwd);
- assert.equal(nextLayerStateToken(published), '4');
- assert.equal(nextLayerStateToken(published), '5');
++ assert.equal(nextLayerStateToken(published), '6');
assert.equal(
validateLayerStateAllocations(published, {
...published,
- newcomer: '4',
- newcomer: '5',
++ newcomer: '6',
}),
true,
);
@@@ -187,15 -190,15 +196,15 @@@
() =>
validateLayerStateAllocations(published, {
...published,
- competing: '0',
- competing: '4',
++ competing: '5',
}),
- /next free token 4/,
- /next free token 5/,
++ /next free token 6/,
);
assert.throws(
() =>
validateLayerStateAllocations(published, {
...LAYER_STATE_TOKEN_RESERVATIONS,
- newcomer: '0',
- newcomer: '4',
++ newcomer: '5',
}),
/changed or removed: retired-layer/,
);
@@@ -203,8 -206,8 +212,8 @@@
);
});
- test('PR B manually replaces provisional 3 with 4 after PR A publishes 3', () => {
- withPublishedBase({ rows: [...reservationRows, ['pr-a', '3']] }, (cwd) => {
-test('PR B manually replaces provisional 4 with 5 after PR A publishes 4', () => {
- withPublishedBase({ rows: [...reservationRows, ['pr-a', '4']] }, (cwd) => {
++test('PR B manually replaces provisional 5 with 6 after PR A publishes 5', () => {
++ withPublishedBase({ rows: [...reservationRows, ['pr-a', '5']] }, (cwd) => {
mkdirSync(path.join(cwd, 'scripts'));
const fixtureChecker = path.join(
cwd,
@@@ -225,8 -228,8 +234,8 @@@
writeCodecFixture(
cwd,
- [...reservationRows, ['pr-b', '3']],
- [{ id: 'pr-b', token: '3' }],
- [...reservationRows, ['pr-b', '4']],
- [{ id: 'pr-b', token: '4' }],
++ [...reservationRows, ['pr-b', '5']],
++ [{ id: 'pr-b', token: '5' }],
);
const beforeRebase = runCheck();
assert.equal(beforeRebase.status, 1);
@@@ -234,10 -237,10 +243,10 @@@
writeCodecFixture(
cwd,
- [...reservationRows, ['pr-a', '3'], ['pr-b', '3']],
- [...reservationRows, ['pr-a', '4'], ['pr-b', '4']],
++ [...reservationRows, ['pr-a', '5'], ['pr-b', '5']],
[
- { id: 'pr-a', token: '3' },
- { id: 'pr-b', token: '3' },
- { id: 'pr-a', token: '4' },
- { id: 'pr-b', token: '4' },
++ { id: 'pr-a', token: '5' },
++ { id: 'pr-b', token: '5' },
],
);
const staleRebase = runCheck();
@@@ -245,16 -248,16 +254,16 @@@
assert.match(staleRebase.stderr, /Duplicate layer-state token reservation/);
const published = readPublishedLayerStateReservations('HEAD', cwd);
- assert.equal(nextLayerStateToken(published), '4');
- const validBaselineRows = [...reservationRows, ['pr-a', '3']];
- writeCodecFixture(cwd, validBaselineRows, [{ id: 'pr-a', token: '3' }]);
- assert.equal(nextLayerStateToken(published), '5');
- const validBaselineRows = [...reservationRows, ['pr-a', '4']];
- writeCodecFixture(cwd, validBaselineRows, [{ id: 'pr-a', token: '4' }]);
++ assert.equal(nextLayerStateToken(published), '6');
++ const validBaselineRows = [...reservationRows, ['pr-a', '5']];
++ writeCodecFixture(cwd, validBaselineRows, [{ id: 'pr-a', token: '5' }]);
const helper = spawnSync(
process.execPath,
[realpathSync(fixtureNext), 'pr-b'],
{ cwd, encoding: 'utf8' },
);
assert.equal(helper.status, 0, helper.stderr);
- assert.match(helper.stdout, /pr-b: 4/);
- assert.match(helper.stdout, /pr-b: 5/);
++ assert.match(helper.stdout, /pr-b: 6/);
assert.deepEqual(
JSON.parse(readFileSync(path.join(cwd, LEDGER_PATH), 'utf8')),
validBaselineRows,
@@@ -262,20 -265,20 +271,20 @@@
);
writeCodecFixture(
cwd,
- [...reservationRows, ['pr-a', '3'], ['pr-b', '4']],
- [...reservationRows, ['pr-a', '4'], ['pr-b', '5']],
++ [...reservationRows, ['pr-a', '5'], ['pr-b', '6']],
[
- { id: 'pr-a', token: '3' },
- { id: 'pr-b', token: '4' },
- { id: 'pr-a', token: '4' },
- { id: 'pr-b', token: '5' },
++ { id: 'pr-a', token: '5' },
++ { id: 'pr-b', token: '6' },
],
);
const corrected = runCheck();
assert.equal(corrected.status, 0, corrected.stderr);
- assert.match(corrected.stdout, /30 published, 1 new/);
- assert.match(corrected.stdout, /31 published, 1 new/);
++ assert.match(corrected.stdout, /32 published, 1 new/);
});
});
test('allocation batches cross the last digit and base-36 pair boundaries in order', () => {
- const digitRows = [...'3456789'].map((digit) => [`retired-${digit}`, digit]);
- const digitRows = [...'456789'].map((digit) => [`retired-${digit}`, digit]);
++ const digitRows = [...'56789'].map((digit) => [`retired-${digit}`, digit]);
const allDigits = parseLayerStateTokenReservations([
...reservationRows,
...digitRows,
@@@ -327,7 -330,7 +336,7 @@@
test('an isolated valid two-character fixture round-trips an l field beyond the old 64-character cap', async () => {
const cwd = mkdtempSync(path.join(tmpdir(), 'gev-layer-token-width-'));
try {
- const priorDigits = [...'3456789'].map((digit) => [
- const priorDigits = [...'456789'].map((digit) => [
++ const priorDigits = [...'56789'].map((digit) => [
`qa-prior-digit-${digit}`,
digit,
]);
@@@ -364,7 -367,7 +373,7 @@@
const params = new URLSearchParams([['v', '2']]);
codec.encodeLayerStateParams(params, state);
assert.ok(params.get('l').length > 64, 'fixture must cross the old cap');
- assert.equal(params.get('l').length, 69);
- assert.equal(params.get('l').length, 71);
++ assert.equal(params.get('l').length, 73);
const restored = codec.decodeLayerStateParams(params);
assert.deepEqual(restored?.enabledLayerIds, expectedLayerIds);
assert.deepEqual(restored?.options, state.options);
@@@ -382,7 -385,7 +391,7 @@@ test('checker reads a complete future b
},
(cwd) => {
const published = readPublishedLayerStateReservations('HEAD', cwd);
- assert.equal(Object.keys(published).length, 30);
- assert.equal(Object.keys(published).length, 31);
++ assert.equal(Object.keys(published).length, 32);
assert.equal(published['retired-layer'], '00');
assert.throws(
() =>
diff --cc src/data/layerStateTokenReservations.json
index 7329ad59f,34ba725b5..dd8dcd7c4
--- a/src/data/layerStateTokenReservations.json
+++ b/src/data/layerStateTokenReservations.json
@@@ -1,5 -1,4 +1,5 @@@
[
- ["air-quality", "0"],
++ ["air-quality", "4"],
["ais-live-vessels", "a"],
["alpr-cameras", "p"],
["bhote-koshi-2026", "h"],
diff --cc src/sources/reference.js
index 34c776164,8631d3ad2..35c0087b7
--- a/src/sources/reference.js
+++ b/src/sources/reference.js
@@@ -1,14 -1,14 +1,16 @@@
import { createUsgsEarthquakeSource } from '../layers/earthquakes/source.js';
+import { createEcccAirQualitySource } from '../layers/airQuality/source.js';
import { createWfigsPerimeterSource } from '../layers/perimeters/source.js';
import { createBundledCableSource } from '../layers/submarineCables/bundledSource.js';
+ import { createAdsbGnssSource } from '../layers/gnss/source.js';
/** Construct the existing reference feeds independently of application setup. */
export function createReferenceSources() {
return {
earthquakes: createUsgsEarthquakeSource(),
+ 'air-quality': createEcccAirQualitySource(),
'fire-perimeters': createWfigsPerimeterSource(),
cables: createBundledCableSource(),
+ 'gnss-integrity': createAdsbGnssSource(),
};
}
diff --cc src/sources/reference.test.mjs
index 285ee6d66,9f9cc9d92..d4f56033e
--- a/src/sources/reference.test.mjs
+++ b/src/sources/reference.test.mjs
@@@ -14,17 -14,17 +14,20 @@@ test('reference factories retain compat
const second = createReferenceSources();
assert.deepEqual(Object.keys(first), [
'earthquakes',
+ 'air-quality',
'fire-perimeters',
'cables',
+ 'gnss-integrity',
]);
assert.notEqual(first.earthquakes, second.earthquakes);
+ assert.notEqual(first['air-quality'], second['air-quality']);
assert.notEqual(first['fire-perimeters'], second['fire-perimeters']);
assert.notEqual(first.cables, second.cables);
+ assert.notEqual(first['gnss-integrity'], second['gnss-integrity']);
assert.equal(typeof first.earthquakes.getSnapshot, 'function');
+ assert.equal(typeof first['air-quality'].getSnapshot, 'function');
assert.equal(typeof first['fire-perimeters'].getSnapshot, 'function');
assert.equal(typeof first.cables.fetch, 'function');
+ assert.equal(typeof first['gnss-integrity'].getSnapshot, 'function');
assert.equal(requests, 0);
});