Skip to content

feat(deck.gl-geotiff): give renderSource the props MosaicLayer passes to sublayers - #789

Merged
kylebarron merged 8 commits into
mainfrom
kyle/mosaic-inherited-props
Oct 30, 2026
Merged

kylebarron merged 8 commits into
mainfrom
kyle/mosaic-inherited-props

Conversation

@kylebarron

@kylebarron kylebarron commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Note

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

MosaicLayer didn't hand its items' layers the props a composite layer normally passes to its sublayers. So opacity, pickable, parameters, extensions and the rest had no effect on them.

Now renderSource gets them as subLayerProps, with a unique id for each item. The app spreads them into the layers it returns, before their own props:

new MosaicLayer({
  data: items,
  getSource: (item, options) => COGSource.open(item.url, options),
  renderSource: (item, { source, subLayerProps }) =>
    new COGLayer({ ...subLayerProps, source }),
  opacity: 0.5,
});

This is how deck.gl's TileLayer hands renderSubLayers its props, as in its docs example, new BitmapLayer(props, {...}). That includes a unique id for each tile's sublayer. An app that doesn't spread them gets no inheritance.

Changes

  • renderSource's options gain subLayerProps:

    • a unique id for each item, ${mosaic id}-${item id};
    • the props deck.gl passes from a composite layer to its sublayers;
    • whatever the layer's extensions add.

    Its type lists exactly those 17 props. An item that returns several layers gives each its own id.

  • The inner TileLayer is built from the same props.

  • naip-mosaic spreads subLayerProps, and gains an opacity slider.

    • Its bundled STAC features have no id, so it now gives each item its image URL as one. Otherwise MosaicLayer keys its cache, and names each item's layer, by the item's position.
  • Docs:

    • renderSource documents subLayerProps, and the class example and the spec spread it.
    • A comment says why MosaicTileset2DFactory must be a new class on every render.

Tests

  • Runtime:
    • opacity on a MosaicLayer reaches renderSource, and the layers it returns.
    • renderSource gets a unique id for each item, and no updateTriggers.
    • A new opacity reaches an item that's already loaded, without opening it again.
    • A changed updateTriggers.all doesn't open the sources again through deck.gl's reload.
  • Types:
    • renderSource's options have exactly the keys source and subLayerProps.
    • subLayerProps has exactly the 17 props, and its id is a string.
    • Spreading subLayerProps into a COGLayer typechecks, without an id of its own.
  • Mutation checks:
    • Not passing subLayerProps fails three of the four tests above.
    • Leaving out the default id fails three of them.
    • Keeping updateTriggers in it fails the id and updateTriggers test and the all test.
  • In Chrome:
    • naip-mosaic's 120 COGLayers are named naip-mosaic-layer-<image URL>.
    • Moving its slider to 0.5 set all of them to opacity 0.5.
    • Where neighboring NAIP images overlap, the overlap looks brighter. Each item's layer fades on its own, so two half-transparent layers stack there.

Closes #784

🤖 Written by Claude Code

…cLayer sources

MosaicLayer didn't pass on the props a composite layer normally hands its
sublayers, so `opacity`, `pickable`, `parameters`, `modelMatrix`,
`extensions` and the rest had no effect on the layers its sources render.
Its inner TileLayer was built from a fixed set of props rather than
`getSubLayerProps()`, and its `renderSubLayers` called `renderSource`
without the props TileLayer hands it.

Build the inner TileLayer from `this.getSubLayerProps()`, as deck.gl's
TerrainLayer does, keeping its `mosaic-layer-${id}` id. Then clone each
layer `renderSource` returns with the inherited props it didn't set
itself, so a source can still set its own `opacity`. A layer's own props
are the ones passed to its constructor, since deck.gl keeps defaults on
the props prototype. The inherited keys are the ones `getSubLayerProps()`
returns, less the per-layer `id` and `updateTriggers`.

Also say why `MosaicTileset2DFactory` must be a new class on every
render: it is what makes the inner TileLayer pick up new `sources` and
re-render loaded sources with a new `renderSource`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron and others added 2 commits October 30, 2026 11:45
…-props-refresh

# Conflicts:
#	packages/deck.gl-geotiff/src/mosaic-layer/mosaic-layer.ts
#	packages/deck.gl-geotiff/tests/mosaic-layer.test.ts
… top of main

Re-applies this PR's change to main's MosaicLayer, which stage 3 and
#821 rewrote: the inner TileLayer is built from `getSubLayerProps()`, and
each layer `renderSource` returns inherits the props it didn't set
itself, such as `opacity`.

`updateTriggers.all`, which `getSubLayerProps()` passes, no longer reaches
the inner TileLayer, as in deck.gl's TerrainLayer: deck.gl's TileLayer
would reload through `Tileset2D.reloadAll`, which leaks sources (#816).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron kylebarron changed the title fix(deck.gl-geotiff): pass opacity and other inherited props to MosaicLayer sources fix(deck.gl-geotiff): pass opacity and other inherited props to the layers of MosaicLayer's items Oct 30, 2026
Comment on lines +295 to +297
const inheritedKeys = Object.keys(subLayerProps).filter(
(key) => key !== "id" && key !== "updateTriggers",
);

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 have to override subLayerProps at all?

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.

deck.gl doesn't pass a composite layer's props, such as opacity or extensions, to the layers it returns on its own. The composite has to pass this.getSubLayerProps() itself, and TerrainLayer does the same for its TileLayer (terrain-layer.ts#L363-L378). That's the first hop, MosaicLayer to its TileLayer.

The second object only adds what's MosaicLayer's own: the TileLayer's id, its tileset class and callbacks, and updateTriggers: {} to keep all out.

An item's layers are a second hop. TileLayer hands the inherited props on to renderSubLayers, but renderSource never sees them. So withInheritedProps copies them onto whatever renderSource returns, and inheritedKeys lists which props to copy.

🤖 Written by Claude Code

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.

Right, we need to pass down this.getSubLayerProps... I get that. But I don't see why we need these two lines on inheritedKeys

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.

They're gone. e91e018 removed inheritedKeys and the cloning it fed. MosaicLayer now hands these props to renderSource as subLayerProps, and the app spreads them into its layers, so nothing has to list which props to copy. 006a657 adds a unique id for each item to those props.

🤖 Written by Claude Code

// An item's layers take them too, copied from the props TileLayer hands
// `renderSubLayers`. There, `id` is the tile's and `updateTriggers` are
// TileLayer's own, so an item's layers don't take those two.
const inheritedKeys = Object.keys(subLayerProps).filter(

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, maybe this should be named like subGetTileDataProps?

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.

Agreed that inheritedKeys doesn't say who inherits. But getTileData isn't involved: these keys are used in renderSubLayers, which copies those props onto the layers renderSource returns. A name with getTileData in it would point at the step that opens sources instead.

I'd name it after its target: itemLayerPropKeys, the keys of the props an item's layers inherit. It's also a list of keys, not of props. subLayerProps can stay, since it's deck.gl's own name (getSubLayerProps()).

Happy to rename it to that, or to whatever you prefer.

🤖 Written by Claude Code

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.

Moot now: e91e018 removes inheritedKeys. What apps see is renderSource's subLayerProps option.

🤖 Written by Claude Code

renderSubLayers: (props) => {
const { item, source } = props.data;
return renderSource(item, { source });
const layers = renderSource(item, { 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.

Or, what if we passed props down into renderSource? as parameters that the user can then pass on if they'd like.

That's cleaner than us overriding any props automatically

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.

I like that better. It's deck.gl's own pattern: TileLayer hands renderSubLayers its sublayer props, and deck.gl's docs example spreads them into the layer it returns, new BitmapLayer(props, {...}). It also removes the cloning, the nested-array flattening and the own-prop rule.

The shape I'd use:

renderSource: (item, { source, subLayerProps }) =>
  new COGLayer({ ...subLayerProps, id: item.url, source }),
  • What subLayerProps holds: what MosaicLayer passes on, such as opacity, pickable and extensions, without id and updateTriggers. Spreading it first never clobbers what the app sets after it.
  • Not everything TileLayer hands renderSubLayers: that includes MosaicLayer's internal getTileData, which would clash with COGLayer's own.
  • The cost: an app that doesn't spread it gets no inheritance, as with TileLayer. The docs example and naip-mosaic would spread it.

Shall I switch to that? The option could also be called just props.

🤖 Written by Claude Code

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.

Done in e91e018. renderSource now gets subLayerProps, and MosaicLayer no longer clones the layers it returns. naip-mosaic spreads them and gains an opacity slider. In Chrome, moving it to 0.5 set all 120 of its COGLayers to opacity 0.5.

🤖 Written by Claude Code

Instead of MosaicLayer cloning each layer `renderSource` returns with the
props it inherits, `renderSource` gets them as `subLayerProps`, and the
app spreads them into the layers it returns, before their own props:

  renderSource: (item, { source, subLayerProps }) =>
    new COGLayer({ ...subLayerProps, id: item.url, source }),

This is how deck.gl's TileLayer hands `renderSubLayers` its props. It
drops the cloning, the nested-array flattening and the own-prop rule.

One destructuring now drops `id` and `updateTriggers` for both the inner
TileLayer and `renderSource`, so `updateTriggers.all` still never reaches
deck.gl's leaky `reloadAll`.

naip-mosaic spreads `subLayerProps` and gets an opacity slider, which
shows the mosaic's `opacity` reaching every item.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron kylebarron changed the title fix(deck.gl-geotiff): pass opacity and other inherited props to the layers of MosaicLayer's items feat(deck.gl-geotiff): give renderSource the props MosaicLayer passes to sublayers Oct 30, 2026
@github-actions github-actions Bot added feat and removed fix labels Oct 30, 2026
kylebarron and others added 2 commits October 30, 2026 15:51
…erProps

`subLayerProps` now holds a unique `id` for each item,
`${mosaic id}-${item id}`, as deck.gl's TileLayer gives each tile's
sublayer one. `new COGLayer({ ...subLayerProps, source })` needs no id
of its own.

Its type now lists exactly what arrives: the `id`, and the 16 props
deck.gl passes from a composite layer to its sublayers. It no longer
offers every layer prop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The bundled STAC features have no `id`, so MosaicLayer keyed its cache by
each item's position, and since the previous commit, named each item's
layer by it too. The image URL keys both now.

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.

✅

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron
kylebarron enabled auto-merge (squash) October 30, 2026 20:22
@kylebarron
kylebarron merged commit 48a83bb into main Oct 30, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/mosaic-inherited-props branch October 30, 2026 20:23
kylebarron added a commit that referenced this pull request Nov 5, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

Bumps `version` to `0.10.0-beta.3` in the root `package.json` and in
every `packages/*/package.json`. The publish workflow publishes it under
the `beta` dist-tag, so `latest` stays on 0.9.0.

`CHANGELOG.md` gets a `v0.10.0-beta.3` section with GitHub's generated
notes for the 17 PRs merged since v0.10.0-beta.2.

## Breaking change

- #843: `MosaicLayer` no longer takes `maxCacheByteSize`. To bound an
item's memory by bytes, set `maxCacheByteSize` on the layer that
`renderSource` returns.

## Behavior changes

- #839: a `MosaicLayer` item out of view keeps its opened source in the
cache but drops its layers, which frees their textures.
- #785: `parseGeoZarrMetadata` takes Y from the first entry of
`spatial:dimensions` and X from the second, whatever their names, as
v0.1 of the spatial convention says. Lists that aren't two entries long
are rejected.
- #841: `RasterTileset2D.getParentIndex` picks the parent tile that
contains the child's centre.

## New APIs

- #835: `parseVRT` in `@developmentseed/deck.gl-geotiff`, and `fromGDAL`
in `@developmentseed/affine`.
- #789: `renderSource` gets the props that `MosaicLayer` passes to its
sublayers.

## Not included

#838 (`ZarrSource` opens from a store with a `path`) and #837
(`DEFAULT_RANGE_READER` moves to `@developmentseed/deck.gl-raster`) are
still open. Both are breaking.

🤖 Written by [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
kylebarron added a commit that referenced this pull request Nov 5, 2026
…iggers.getSource changes (#848)

> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

`MosaicLayer` caches the source that `getSource` opens for each item.
Until now, nothing opened those sources again. When something
`getSource` reads changed, loaded items kept their old sources and only
items loaded afterward used the new ones, so the mosaic could show a mix
of both.

Now a change to `updateTriggers.getSource` or `updateTriggers.all` opens
every source again:

```ts
new MosaicLayer({
  data: items,
  getSource: (item, options) => COGSource.open(item.assets[band].href, options),
  updateTriggers: { getSource: band },
  renderSource: (item, { source, subLayerProps }) =>
    new COGLayer({ ...subLayerProps, source }),
});
```

- **How it works:**
- MosaicLayer hands `updateTriggers.getSource` to its inner `TileLayer`
as `updateTriggers.getTileData`, and `all` as `all`. When either
changes, deck.gl's `TileLayer` calls the tileset's `reloadAll`, as it
does upstream.
- `MosaicTileset2D` overrides `reloadAll`. It unloads every source
through `finalize` (#823), which also aborts the opens in flight. Then
it makes the next update select the items in view again, and they open
with the current `getSource`. Items out of view are opened when they
come back.
- **The old items stop drawing at once,** as #818's tiles do.
- **A new `getSource` function alone opens nothing again,** as with
deck.gl's accessors.
- **deck.gl's own `reloadAll` is replaced** (#816):
- It drops items out of view without unloading them, and keeps them in
`tileset.tiles`.
- It keeps drawing the items in view with their old sources until the
new ones open, and never unloads the old ones.
- The override stays until we adopt deck.gl v10's shared `Tileset2D`
(#846). Its `reloadAll` unloads the tiles it drops, but still not the
data a reload replaces.

`renderSource` gets no trigger. Every render of MosaicLayer already
draws the loaded items again with the current `renderSource`, and #844
tests that.

RasterTileLayer still refetches through a count in its inner
`TileLayer`'s id (#818). A follow-up moves it to the same override.

## Changes

- **`MosaicLayer`** passes the two triggers to its inner `TileLayer`,
and stores nothing.
- **`MosaicTileset2D`** overrides `reloadAll`.
- **Docs:** `getSource`'s docs say when and how to open the sources
again.
- **Spec:** decision 26 records this and the `renderSource` decision.
The 4c entry points to it.

## Tests

- **Runtime**, through deck.gl's `LayerManager`:
- A change to `updateTriggers.getSource`, and to `updateTriggers.all`,
opens every source again with the new `getSource`, and passes the old
sources to `onSourceUnload`.
- An unchanged trigger opens nothing again, even with a new `getSource`
function.
  - The old items stop drawing at once, before the new sources open.
- **`MosaicTileset2D`:** `reloadAll` unloads every item, and the next
update selects the items in view again, even though the viewport hasn't
changed.
- **Replaced test:** #789 had a test that `all` doesn't open the sources
again. `all` now opens them again, through the override instead of
deck.gl's `reloadAll`.
- **Mutation checks:**
  - Without the `setOptions` call in the override, 1 test fails.
  - Without the `getTileData` trigger, 2 tests fail.
  - Without the `all` trigger, 1 test fails.
  - Without the override, 4 tests fail.
- **Everything else:** all 222 `deck.gl-geotiff` tests pass, as do the
workspace typecheck and Biome. In Chrome, naip-mosaic still loads and
pans with no errors.

Closes #816

🤖 Written by [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

MosaicLayer ignores its own opacity and other inherited layer props

1 participant