-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Target Use Case
Right now the TileLayer only has a single method for getting per-tile data: the getTileData callback.
This is fine, or at least, the best we can do for most tiled data sources, such as MVT from an API, since there's a separate URL per tile.
But for some data sources, such as PMTiles (which stores a pyramid of MVTs in a single range-request addressable resource) and Cloud-Optimized GeoTIFF (which contain a similar pyramid of raster image data), all tile requests are ranges within one specific URL.
As noted by TileLayer.maxRequests, Chrome only allows 6 concurrent requests per domain on HTTP 1.
But, since:
- these data sources are all contained in a single file/URL
- internal tiles are laid out in a predictable layout, such as horizontal rows or a hilbert curve
If we know we're fetching many tiles at once, we can coalesce adjacent HTTP Ranges and reduce the number of requests we're making.
Right now, since getTileData is called independently for every tile, it's very difficult to know from inside getTileData the set of tiles being fetched at a time, and so it's impossible to do this range coalescing.
Proposal
- Update
TileLayerwith a new user-facing propgetTileDataBatched(open to naming suggestions) that takes in an array of tiles and fetches all of them. This prop should be optional, falling back to callinggetTileDataifgetTileDataBatcheddoesn't exist - Update
Tileset2Dclass to callgetTileDataBatched. Refthis._selectedTiles = tileIndices.map(index => this._getTile(index, true));