Skip to content

Commit ea73fa1

Browse files
authored
fix: Ensure we reset state when changing sources in MultiCOGLayer (#414)
1 parent 418bb4d commit ea73fa1

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

packages/deck.gl-geotiff/src/multi-cog-layer.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,19 @@ export class MultiCOGLayer extends CompositeLayer<MultiCOGLayerProps> {
307307
});
308308
}
309309

310-
override updateState({ changeFlags }: UpdateParameters<this>): void {
311-
if (changeFlags.dataChanged || changeFlags.propsChanged) {
310+
override updateState({
311+
changeFlags,
312+
props,
313+
oldProps,
314+
}: UpdateParameters<this>): void {
315+
if (changeFlags.dataChanged || props.sources !== oldProps.sources) {
316+
// Reset state so renderLayers() returns null while we re-open COGs.
317+
// Without this, the TileLayer renders with new props but stale state,
318+
// caching tiles with the wrong bands.
319+
this.setState({
320+
sources: null,
321+
multiDescriptor: null,
322+
});
312323
this._parseAllSources();
313324
}
314325
}
@@ -494,6 +505,10 @@ export class MultiCOGLayer extends CompositeLayer<MultiCOGLayerProps> {
494505
0,
495506
);
496507

508+
console.log(
509+
`Tile (${x}, ${y}, ${z}): fetched bands [${[...bands.keys()].join(", ")}], total byte length: ${byteLength}`,
510+
);
511+
497512
return {
498513
bands,
499514
forwardTransform,

0 commit comments

Comments
 (0)