Skip to content

refactor(deck.gl-geotiff): keep one layer per source class, and build MultiCOGLayerProps from RasterTileLayerProps - #820

Merged
kylebarron merged 3 commits into
mainfrom
kyle/one-layer-per-source
Oct 29, 2026
Merged

kylebarron merged 3 commits into
mainfrom
kyle/one-layer-per-source

Conversation

@kylebarron

Copy link
Copy Markdown
Member

Note

This PR was written by Claude (Claude Code), not by @kylebarron.

This replaces stage 5 of the Sources design (dev-docs/specs/2026-10-22-sources-design.md, decision 25): each source class keeps its own layer. COGLayer draws a COGSource, MultiCOGLayer a MultiCOGSource, and ZarrLayer a ZarrSource.

Stage 5 planned for COGLayer to take over MultiCOGLayer's band compositing, and to deprecate MultiCOGLayer. But one layer for both COG classes would need:

  • a union for onSourceLoad, since TypeScript can't pick props by what source holds;
  • props that apply to one kind of source only;
  • tile callbacks typed for the wrong data.

With one layer per class, each layer's types are exact. A mosaic returns the right layer for each item's source from renderSource, as it already can.

MultiCOGLayerProps

It now starts from RasterTileLayerProps, as COGLayerProps does, and takes pool from COGLayerProps, so no prop is declared twice:

export type MultiCOGLayerProps = Omit<
  RasterTileLayerProps<MultiTileResult>,
  "tilesetDescriptor" | "getTileData" | "renderTile"
> &
  Pick<COGLayerProps, "pool"> & {
    source: MultiCOGSource | Record<string, COGInput>;
    onSourceLoad?: (source: MultiCOGSource) => void;
    composite?: { r: string; g?: string; b?: string; a?: string };
    renderPipeline?: RasterModule[];
    resampling?: "linear" | "nearest";
    debugLevel?: 1 | 2 | 3;
  };
  • Before: it picked five TileLayer props and redeclared maxError, debug, debugOpacity, signal and pool.
    • new MultiCOGLayer(...) already accepted every RasterTileLayer prop, so callers see no change.
    • The exported MultiCOGLayerProps type, though, lacked extent, maxZoom, minZoom, onTileError, onTileLoad, onTileUnload, onViewportLoad, tileSize, zRange and zoomOffset.
  • signal is declared once, on RasterTileLayerProps, with the note that it doesn't abort opening source. COGLayer stops redeclaring it too.
    • Its tip about MosaicLayer went. deck.gl doesn't abort a tile once it has loaded, so an item's signal can only abort while its source opens.
  • COGLayer's pool docs no longer mention a GeoTIFFLayer, which doesn't exist.
  • COGLayer's docs point to MultiCOGLayer for bands stored as separate files.

Tests

  • Type tests, checked by tsc:
    • MultiCOGLayerProps takes every COGLayerProps prop except getTileData and renderTile. This failed before the change, naming the ten props above.
    • Its only props beyond COGLayerProps are composite, renderPipeline, resampling and debugLevel.
  • The workspace typecheck passes for every package and example.

🤖 Written by Claude Code

kylebarron and others added 3 commits October 29, 2026 12:41
…yerProps

MultiCOGLayerProps picked five TileLayer props and redeclared maxError,
debug, debugOpacity, signal and pool. The layer took every
RasterTileLayer prop, but the exported type rejected extent, zRange,
minZoom, zoomOffset, onTileLoad and the rest. It now starts from
RasterTileLayerProps, as COGLayerProps does, and takes `pool` from
COGLayerProps, so it adds only its source and band props.

`signal` is declared once, on RasterTileLayerProps, with the note that it
doesn't abort opening `source`. COGLayer's docs point to MultiCOGLayer
for bands stored as separate files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Decision 25: COGLayer draws a COGSource, MultiCOGLayer a MultiCOGSource,
and ZarrLayer a ZarrSource. One layer for both COG classes would need a
union for `onSourceLoad`, props that apply to one kind of source only,
and tile callbacks typed for the wrong data. This replaces stage 5's plan
for COGLayer to take over MultiCOGLayer, and answers open question 4.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@kylebarron kylebarron left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅

Comment on lines -100 to -109

/** A user-provided AbortSignal to cancel tile requests. It doesn't abort
* opening `source`: the layer aborts that itself when `source` changes or
* the layer is removed.
*
* This can be useful in combination with the MosaicLayer, so that when a
* mosaic source is out of the viewport, all of its tile requests are
* automatically aborted.
*/
signal?: AbortSignal;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we take this out again? Because it's now on the source?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This reply was written by Claude (Claude Code), not by @kylebarron.

It's not on the source. COGLayer still has signal: COGLayerProps starts from Omit<RasterTileLayerProps<DataT>, "tilesetDescriptor" | "getTileData" | "renderTile">, which keeps it. This declaration only repeated the base one (62ccec4).

  • Its rule moved. It said the signal doesn't abort opening source. That's true of every layer with a source, since RasterTileLayer does the opening, so the note now sits on the base declaration (the thread below).
  • The MosaicLayer tip was dropped. It was stale: deck.gl doesn't abort a tile once it has loaded. So the signal MosaicLayer passes to renderSource can only abort while the item's source is opening, never the COGLayer's tile requests afterwards.

🤖 Written by Claude Code

* per-tile signal. It doesn't abort opening `source`: the layer aborts
* that itself when `source` changes or the layer is removed.
*/
signal?: AbortSignal;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh it's because signal is inherited from here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This reply was written by Claude (Claude Code), not by @kylebarron.

Yes, every RasterTileLayer subclass inherits signal from here. COGLayer and MultiCOGLayer redeclared it only to add the note about source, which now lives here once, so ZarrLayer's docs get it too (62ccec4).

🤖 Written by Claude Code

@kylebarron
kylebarron merged commit c9de579 into main Oct 29, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/one-layer-per-source branch October 29, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant