RFC(geo-layers) SharedTileLayer#10367
Conversation
| "contributing", | ||
| "faq" | ||
| ] | ||
| "items": ["README", "whats-new", "upgrade-guide", "contributing", "faq"] |
There was a problem hiding this comment.
Looks like some lint thrashing on unmodified lines. Which is right?
| export {Tile2DHeader as _Tile2DHeader} from './tileset-2d/index'; | ||
| export {SharedTileset2D as _SharedTileset2D} from './shared-tileset-2d/index'; | ||
| export {SharedTile2DHeader as _SharedTile2DHeader} from './shared-tileset-2d/index'; | ||
| export {sharedTile2DDeckAdapter} from './shared-tile-2d-layer/index'; |
There was a problem hiding this comment.
This would be experiential too, right? Is there an api doc on how to use it?
| expect(TileLayer, 'TileLayer symbol imported').toBeTruthy(); | ||
| expect(SharedTile2DLayer, 'SharedTile2DLayer symbol imported').toBeTruthy(); | ||
| expect(SharedTileset2D, 'SharedTileset2D symbol imported').toBeTruthy(); | ||
| expect(SharedTile2DHeader, 'SharedTile2DHeader symbol imported').toBeTruthy(); |
There was a problem hiding this comment.
Expect the adapter to be exported too?
| }; | ||
|
|
||
| render() { | ||
| return <App onTilesLoad={this._onTilesLoad} />; |
There was a problem hiding this comment.
Would be nice if this example also had a toggle between shared and not shared, along with some stats to measure the benefit
| ```ts | ||
| import { | ||
| _SharedTileset2D as SharedTileset2D, | ||
| sharedTile2DDeckAdapter |
There was a problem hiding this comment.
I'm not sure what the adapter is for if I'm reading these docs for the first time
| SharedTileset2D.fromTileSource<TileDataT>(tileSource, props); | ||
| ``` | ||
|
|
||
| Provide either `getTileData` or `tileSource`. A shared tileset also needs an adapter before traversal is used. `_SharedTile2DLayer` installs `sharedTile2DDeckAdapter` automatically for deck.gl viewport traversal; applications constructing the tileset directly should usually pass that adapter themselves. |
There was a problem hiding this comment.
Ah, the adapter is for viewport transversal within the layer. I'd like to see if LayerManager could provide layers with a hook for this as a part of experimental graduation, unless users would want to write their own custom adapter for some reason
The deck.gl-community SharedTileLayer allows multiple layers x multiple views to load from the same tile source and reuse common tiles across views.
The community demo is here: https://visgl.github.io/deck.gl-community/docs/modules/geo-layers/api-reference/shared-tile-2d-layer
It would likely be a great basis for TerrainLayer, sharing terrain tiles between layers.
One tricky question is whether to try to make this layer replace TileLayer, that layer is heavily customizable and changing the implementation may be risky, and will likely break some applications.
Make Shared Tile Layer the TileLayer Replacement
Summary
_SharedTile2DLayerpath with a shared-backedTileLayerimplementation.TileLayeras the canonical public class and preserve strict drop-in compatibility for current props, subclasses, exported helper classes, callbacks, tests, and in-repo consumers._SharedTile2DLayer,_SharedTileset2D, and_SharedTile2DHeaderas experimental alias exports around the same implementation, not a second behavior path.Key Changes
TileLayer/Tileset2Dstack soTileset2Downs shared tile content, loading, request scheduling, cache eviction, stats, TileSource metadata, and subscriptions._Tile2DHeadercompatibility by exposing stable view-scoped tile header facades with existing fields:isSelected,isVisible,state,layers,parent,children,content,data,isLoaded,isLoading,needsReload,abort, andsetNeedsReload.TilesetClass?: typeof Tileset2Dworking unchanged. Existing_Tileset2Dsubclasses such as H3, Quadbin, and custom app tilesets continue overridinggetTileIndices,getTileId,getTileZoom,getTileMetadata, andgetParentIndex.refinementStrategycallbacks. Run them per viewport against that viewport’s tile header facades so mutations do not leak between views.TileLayerinstance automatically share tile content across all rendered viewports. Separate layer instances share only when passed the same external_SharedTileset2D.TileLayer.dataadditively to accept URL templates, loaders.glTileSource, or an external_SharedTileset2D. URL-template behavior remains exact; explicit layer props override TileSource metadata; external tilesets are not finalized by layers.tile.layerscaching semantics per layer/view,renderSubLayers,filterSubLayer, picking info,onViewportLoad,onTileLoad,onTileUnload,onTileError, errored-tile loaded state, abort/reload behavior, repeat views, and current cache defaults.state.tilesetand public-ish tileset fields usable. For direct legacy access,tiles,selectedTiles,isLoaded,isTileVisible,_tiles,_cache, andoptsreflect the active/default view; directtileset.update(viewport)uses a default legacy view.Public API
TileLayerbecomes the shared-backed replacement._SharedTile2DLayerbecomes an alias ofTileLayer._SharedTileset2Dbecomes an alias or thin experimental wrapper over_Tileset2D._SharedTile2DHeaderbecomes an alias of_Tile2DHeader.SharedTile2DLayerPropsaliasesTileLayerProps.SharedTile2DLayerPickingInfoaliasesTileLayerPickingInfo.SharedTileset2DProps/ related shared tileset types map to the compatibleTileset2Dsurface.SharedRefinementStrategyaliasesRefinementStrategy, including custom callback functions.@deck.gl/geo-layersanddeck.gl; do not add a separate tileset subpath.Docs And Example
TileLayerdocs to describe shared cache behavior, multi-view sharing, TileSource input, and external_SharedTileset2D.docs/developer-guide/views.md,docs/whats-new.md, and affected WebGPU notes.TileLayeras the main layer API and_SharedTileset2Donly for explicit cross-layer sharing across main/minimap views.Test Plan
TileLayer,Tileset2D,Tile2DHeader,MVTLayer,TerrainLayer, CARTO, and custom tileset tests passing unchanged.yarn,yarn build,yarn lint,yarn test-headless,yarn test-browser, andyarn test-website.Assumptions
_Tileset2D/_Tile2DHeaderextension points and in-repo state usage.TileLayeris the final user-facing replacement;_Shared*names remain transitional experimental aliases.MVTLayer,TerrainLayer, CARTO layers, and customTilesetClassimplementations should not require source changes beyond incidental type fixes if the refactor exposes existing type gaps.