Files
gods-eye-view/docs/INFRASTRUCTURE-LAYERS.md
T
Mazeyar Moeini FeizabadiandClaude Fable 5.2 0f4dda5cc6 perf(terrain): one shared, cached and budgeted terrain height reader for Transit, Rail, Bike Share and local data
globe.getHeight is a ray cast against the drawn tile's mesh and
scene.sampleHeight a GPU depth render; several layers asked for them
uncached and unbudgeted. The cache written for Transit moves to
src/services/terrainSurface.js and is handed to every layer through the
ground service, so layers share one cache and one read budget.

- Rail reads each train on a ~4 m grid instead of every frame.
- Local data layers read terrain floors through it and stop depth samples
  at 8 ms a frame.
- Bike Share draws stations at once and finds their heights afterwards in
  4 ms steps.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-12 23:05:24 +01:00

3.6 KiB

Reusing infrastructure layers

gods-eye-view/infrastructure exports createInfrastructureLayers(services). It returns fresh datacenter and dam layers in that order, with the existing IDs, appearance, label budgets and bundled public datasets. Importing the module or calling the factory does not load data, create a viewer, or start the application. The asset URLs resolve relative to the module; Vite rewrites them for production base paths. This browser source export expects a Vite-compatible asset build.

Pass the application's existing functions:

import { createInfrastructureLayers } from 'gods-eye-view/infrastructure';

const layers = createInfrastructureLayers({
  overlayHost: { setEntries, setVisible, clearSource },
  registerEntityContext,
  selectEntityContext,
  clearSelectedEntityContextForLayer,
  removeEntityContextsForLayer,
  governorRequestRender,
});

// Register these layers with the existing data-layer manager and viewer.
Function Arguments / responsibility
overlayHost.setEntries (sourceId, entries, options); publish the existing infrastructure overlay records and paint budget
overlayHost.setVisible (sourceId, visible); toggle a source
overlayHost.clearSource (sourceId); remove that source's overlay entries
registerEntityContext (entity, metadata); register selectable feature metadata, including the owning layer and data source
selectEntityContext (entity); select that registered feature
clearSelectedEntityContextForLayer (layerId); clear selection only if owned by this layer
removeEntityContextsForLayer (layerId); remove records owned by the layer on destruction or failed setup
governorRequestRender (reason); request a frame through the existing render scheduler
terrainSurface Optional. The application's shared terrain surface (groundFloor.terrainSurface), so its layers read each terrain height once; without it each layer keeps its own

Each returned layer supports init(viewer), enable(viewer), disable(viewer), update(viewer), destroy(viewer), getStats(), getLodDiagnostics() and getAnalystRecords(). Use the same viewer for the instance's entire lifetime. Each viewer/context/overlay host permits one live instance per layer ID; destroy an old instance before replacing it. Separate applications may use identical IDs with separate hosts. Callbacks must be ready before enable and remain usable through destruction.

Disable retains the loaded dataset for reuse and clears selection and listeners. Concurrent enables share one load. Destroy is permanent, aborts pending fetches, discards late results, and clears the owned data source, context records, overlays, input handler and listeners. The layer never creates an application context store, overlay host, viewer, or render scheduler. The consumer must resolve one compatible Cesium installation shared with its viewer; it must not bundle separate copies.

gods-eye-view/infrastructure/geojson exports the lower-level createLocalGeoJsonLayer(options, services) and existing infrastructure overlay helpers. gods-eye-view/infrastructure/lod exports the existing LOD policy helpers. Consumers use the package exports, which do not import standalone application globals.

Dataset files and source/license notices remain under src/data/local_data/. Their input counts are 4,352 datacenter features and 704 dam features. Cesium may expand multipart geometries into multiple entities; entity and stem counts are different measurements. This change does not refresh or relicense the datasets.