Repository navigation
fix: Keep raster tiles loaded when the map re-renders - #1356
Conversation
deck.gl-raster 0.10 names its inner TileLayer after the tileset descriptor object, so the new TileMatrixSetAdaptor built on every render made it drop its tiles and request them all from Python again. Memoize the adaptor on the tile matrix set and CRS converters. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The new raster UI test builds a TileMatrixSet with morecantile, which was only in the geotiff extra that CI doesn't install. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| } from "@developmentseed/deck.gl-raster"; | ||
| import type { TileMatrixSet } from "@developmentseed/morecantile"; | ||
| import type { WidgetModel } from "@jupyter-widgets/base"; | ||
| import memoizeOne from "memoize-one"; |
There was a problem hiding this comment.
is this already a dependency? I don't know that we explicitly depend on it?
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
Yes. package.json lists "memoize-one": "^6.0.0" under dependencies, and pnpm-lock.yaml already has it, so this PR doesn't change either file. It was added in #417, but as far as I can tell from the git history nothing ever imported it, so this is its first use.
If you'd rather not depend on it, a hand-written cache of the last (tileMatrixSet, converters) pair would take about 8 lines, and we could drop the dependency. I'd keep memoize-one, since it's small and says what it does.
🤖 Written by Claude Code
There was a problem hiding this comment.
oh weird, ok we can keep it
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
Fixes a regression from #1355. A
RasterLayerwith a tile matrix set (RasterLayer.from_geotiff, or the generic constructor) asked Python for every visible tile again whenever the map re-rendered. That includes changing any layer property, panning, and several times during the initial load.deck.gl-raster 0.10 names its inner
TileLayerafter thetilesetDescriptorobject (developmentseed/deck.gl-raster#799), so a new descriptor makes a newTileLayerwith an empty cache.RasterModel.render()built a newTileMatrixSetAdaptorevery time. Now it's memoized on the tile matrix set and the CRS converters, which only change when Python sets_tile_matrix_setor_crs.The PMTiles path uses deck.gl's own
TileLayerand wasn't affected.Testing
Tile fetches counted from Python, with a UTM (EPSG:32618) COG loaded through
from_geotiff:opacitymain)With this PR, using a global
WebMercatorQuadgrid, the initial load has no duplicate requests, and a small pan only requests the row of tiles that comes into view (6 new, 0 repeats).test_tile_matrix_set_tiles_not_refetched_on_rerenderfails onmain(36 requests instead of 24) and passes here.uv run pytest: 368 passed, 1 skipped.pnpm build,pnpm checkandpnpm testpass.tsc --noEmitreports the same 9 errors asmain.🤖 Written by Claude Code