mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 07:42:23 +00:00
createTrafficSource({ roadModes }) lets a host offer a subset of the TomTom,
OSM and Hybrid road modes (all three by default). Without OSM the layer never
draws simulated roads, and a single mode shows no road chip.
While flow is live the Street Traffic row offers Lines (every road with flow
as a steady green/amber/red line, from the heat-line renderer) and Dots (the
moving dots), saved in layer state and share links. Defaults: Lines off,
Dots on.
66 lines
2.3 KiB
JavaScript
66 lines
2.3 KiB
JavaScript
import { TRAFFIC_TIMING_ENABLED } from './policy.js';
|
|
import { createStyle } from './style.js';
|
|
import { createTiming } from './timing.js';
|
|
import { createModel } from './model.js';
|
|
import { createIngestion } from './ingestion.js';
|
|
import { createAnimation } from './animation.js';
|
|
import { createViewport } from './viewport.js';
|
|
import { createFlow } from './flow.js';
|
|
import { createRendering } from './rendering.js';
|
|
import { createControls } from './controls.js';
|
|
import { createLifecycle } from './lifecycle.js';
|
|
import { createRetention } from './retention.js';
|
|
import { createState } from './state.js';
|
|
|
|
/** Construct one layer with its own scene state and supplied application services. */
|
|
export function createTrafficLayer({ services, source }) {
|
|
if (
|
|
![
|
|
'requestRoads',
|
|
'getStatus',
|
|
'fetchFlowForBounds',
|
|
'getFlowSessionStats',
|
|
'resetFlowTileCache',
|
|
].every((key) => typeof source?.[key] === 'function')
|
|
)
|
|
throw new TypeError('A traffic source is required');
|
|
const state = createState({ services, source });
|
|
const parts = {};
|
|
const context = { state, services, parts, source };
|
|
parts.style = createStyle(context);
|
|
parts.timing = createTiming(context);
|
|
parts.model = createModel(context);
|
|
parts.ingestion = createIngestion(context);
|
|
parts.animation = createAnimation(context);
|
|
parts.viewport = createViewport(context);
|
|
parts.flow = createFlow(context);
|
|
parts.retention = createRetention(context);
|
|
parts.rendering = createRendering(context);
|
|
parts.controls = createControls(context);
|
|
parts.lifecycle = createLifecycle(context);
|
|
state._parseRoads = TRAFFIC_TIMING_ENABLED
|
|
? (data, trace) =>
|
|
trace
|
|
? parts.timing.parseRoadsTimed(data, trace)
|
|
: parts.model.parseRoads(data)
|
|
: parts.model.parseRoads;
|
|
|
|
state._loadRoadsForBounds = TRAFFIC_TIMING_ENABLED
|
|
? parts.timing.loadRoadsForBoundsTimed
|
|
: parts.ingestion.loadRoadsForBounds;
|
|
|
|
return Object.assign(
|
|
{},
|
|
parts.controls.methods,
|
|
parts.lifecycle.methods,
|
|
parts.ingestion?.methods,
|
|
{
|
|
getTrafficTimingDiagnostics: parts.timing.getTrafficTimingDiagnostics,
|
|
deriveTrafficFlowError: parts.flow.deriveTrafficFlowError,
|
|
trafficFeedPresentation: parts.model.trafficFeedPresentation,
|
|
},
|
|
);
|
|
}
|
|
|
|
export { createTrafficSource } from './source.js';
|