Files
gods-eye-view/src/standalone/layerSources.js
T
Denis Groshev 830c080803 feat(rail): add a Rail layer with keyless live trains
Live trains from 30 keyless operator feeds: GPS positions from 29 and
Irish Rail's station reports, shown as the operators publish them. 28
work out of the box; Renfe long and medium distance and KTMB appear once
their pack is built, because their vehicles name no route.

Packs are opt-in (scripts/build-rail-paths.mjs): the operator's own
route lines, stop names, next stops and trip-update delays for live
trains. Nothing downloads when the app starts, no train is placed from a
timetable, and no request carries a deployer's key.
2026-11-11 16:06:22 +01:00

85 lines
3.8 KiB
JavaScript

import { createDirectionsSource } from '../layers/directions/source.js';
import { createRecentImagerySource } from '../layers/recentImagery/source.js';
import { createOpenFreeMapSource } from '../sources/openFreeMap.js';
import {
createFlightSource,
createMilitarySource,
createVesselSource,
} from '../sources/live/standalone.js';
import { createCctvSource } from '../layers/cctv/source.js';
import { createRadioSource } from '../layers/radio/source.js';
import { createTransitSource } from '../layers/transit/source.js';
import { createRailSource } from '../layers/rail/source.js';
import { createTrafficSource } from '../layers/traffic/source.js';
import { createBikeshareSource } from '../layers/bikeshare/source.js';
import { createInstallationSource } from '../layers/installations/source.js';
import { createSatelliteSource } from '../layers/satellites/source.js';
import { createLaunchSource } from '../layers/launches/source.js';
import { createAlprTileSource } from '../layers/alpr/source.js';
import { createWeatherSource } from '../layers/weather/source.js';
import { createCycloneSource } from '../layers/cyclones/source.js';
import { createWindSource } from '../layers/wind/source.js';
import { createFirmsSource } from '../layers/firms/source.js';
import { createGhostMapsSource } from '../layers/ghostMaps/source.js';
import { createNewsSource } from '../layers/news/source.js';
import { createShipwrecksSource } from '../layers/shipwrecks/source.js';
import { createMapillarySource } from '../layers/streetLevel/providers/mapillary/source.js';
import { createReferenceSources } from '../sources/reference.js';
export { createReferenceSources as createStandaloneReferenceSources } from '../sources/reference.js';
/** Select standalone providers without starting their acquisition. */
export function createStandaloneLayerSources(
overrides = {},
{ createMapTiles = createOpenFreeMapSource } = {},
) {
if (!overrides || typeof overrides !== 'object' || Array.isArray(overrides))
throw new TypeError('Source overrides must be an object');
const trafficTiles = createMapTiles({
selectDecoded: ({ roads }) => ({ roads }),
});
const installationTiles = createMapTiles({
selectDecoded: ({ military }) => ({ military }),
});
const defaults = {
...createReferenceSources(),
directions: createDirectionsSource(),
'recent-imagery': createRecentImagerySource(),
flights: createFlightSource(),
military: createMilitarySource(),
vessels: createVesselSource({
apiUrl: import.meta.env?.VITE_AIS_LIVE_API_URL || '/api/vessels',
// Resolved against the document's address, which a panel host may
// serve from its own scheme.
origin: () => globalThis.document?.baseURI ?? 'http://localhost',
}),
cctv: createCctvSource(),
radio: createRadioSource(),
traffic: createTrafficSource({ mapTiles: trafficTiles }),
transit: createTransitSource(),
rail: createRailSource(),
bikeshare: createBikeshareSource(),
installations: createInstallationSource({ mapTiles: installationTiles }),
satellites: createSatelliteSource(),
launches: createLaunchSource(),
alpr: createAlprTileSource(),
firms: createFirmsSource(),
's2-ghostmaps': createGhostMapsSource(),
// Same-origin /api/news: the local server proxies GEV_NEWS_ORIGIN and,
// without it, answers "not configured", which the layer shows as
// unavailable without retrying.
news: createNewsSource(),
shipwrecks: createShipwrecksSource(),
wind: createWindSource(),
weather: createWeatherSource(),
cyclones: createCycloneSource(),
mapillary: createMapillarySource({
token: import.meta.env?.MAPILLARY_CLIENT_TOKEN || '',
}),
};
for (const name of Object.keys(overrides)) {
if (!Object.hasOwn(defaults, name))
throw new TypeError(`Unknown source: ${name}`);
}
return { ...defaults, ...overrides };
}