Skip to content

RFC(geo-layers) Share TerrainLayer tile data#10374

Draft
ibgreen-openai wants to merge 1 commit into
ib/shared-tile-layerfrom
ib/shared-terrain
Draft

RFC(geo-layers) Share TerrainLayer tile data#10374
ibgreen-openai wants to merge 1 commit into
ib/shared-tile-layerfrom
ib/shared-terrain

Conversation

@ibgreen-openai

@ibgreen-openai ibgreen-openai commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

This is a stacked PR on top of the SharedTileLayer PR #10367

Summary

  • Add an experimental _TerrainSource plus TerrainLayer._terrainTileset path so multiple TerrainLayer instances can reuse one loaded terrain tile payload cache through _SharedTileset2D.
  • Keep the existing TerrainLayer URL-template API intact. The shared path is caller-owned and opt-in; elevationData still uses the existing internal TileLayer path when _terrainTileset is not supplied.
  • Load projection-independent normalized terrain payloads once, then cache derived MapView/GlobeView render meshes on the shared tile data as each terrain layer needs them.
  • Add the small _SharedTileset2D hooks needed for terrain payload byte accounting, plus focused tests and docs.

Why

TerrainLayer currently bakes viewport-projected bounds into each loaded tiled mesh, so separate terrain layers fetch and materialize the same source tile data independently. This stacks on #10367 and uses the shared tileset/cache machinery instead of adding a terrain-specific parallel cache.

Example

import {
  TerrainLayer,
  _SharedTileset2D,
  _TerrainSource,
  type _TerrainTileData as TerrainTileData
} from '@deck.gl/geo-layers';

const terrainSource = new _TerrainSource({...});

const terrainTileset = new _SharedTileset2D<TerrainTileData>({
  getTileData: tile => terrainSource.getTileData(tile)
});

new TerrainLayer({
  id: 'terrain-a',
  _terrainTileset: terrainTileset,
  ...
});

new TerrainLayer({
  id: 'terrain-b',
  _terrainTileset: terrainTileset,
  ...
});

The source owns elevation/texture/decoder/load configuration, the shared tileset owns tile traversal and cache state, and each TerrainLayer still owns its per-layer render props such as color, wireframe, material, and operation.

Validation

  • yarn build
  • yarn lint (passes with existing repo warnings only)
  • yarn vitest run --project headless test/modules/geo-layers/terrain-layer-loading.spec.ts
  • yarn vitest run --project node test/modules/imports.node.spec.ts
  • yarn test-headless was also run; the relevant terrain/shared specs passed, but the full suite still has an unrelated reproducible LoadingWidget failure and one DeckGL#mount/unmount failure that passed when rerun in isolation.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 82.933%ib/shared-terrain into ib/shared-tile-layer. No base build found for ib/shared-tile-layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants