Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smarter tile caching #1326

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app/src/tiles/rendererDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ if(!allLayersCacheSwitch) {
['base_light', 'base_night', 'base_night_outlines', 'base_boroughs'].includes(tileset) && z <= 18;
}

const MIN_ZOOM_FOR_RENDERING_TILES = 9

const tileCache = new TileCache(
process.env.TILECACHE_PATH,
{
tilesets: getBuildingLayerNames(),
minZoom: 9,
maxZoom: 19,
minZoom: MIN_ZOOM_FOR_RENDERING_TILES,
scales: [1, 2]
},
shouldCacheFn,
Expand All @@ -69,7 +70,12 @@ function stitchOrRenderBuildingTile(tileParams: TileParams, dataParams: any): Pr
}

function renderTile(tileParams: TileParams, dataParams: any): Promise<Tile> {
if (isOutsideExtent(tileParams, EXTENT_BBOX)) {
if (isOutsideExtent(tileParams, EXTENT_BBOX) || tileParams.z < MIN_ZOOM_FOR_RENDERING_TILES) {
// if tiles are on lower zoom level then producing/caching is expected
// then we should short-circuit tile generation
// otherwise tile would be generated and not cached

// also, tiles outside EXTENT_BBOX are not to be produced
return createBlankTile();
}

Expand Down
6 changes: 0 additions & 6 deletions app/src/tiles/tileCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ interface CacheDomain {
*/
minZoom: number;

/**
* The highest zoom level to cache
*/
maxZoom: number;

/**
* An array of scale factors to cache
*/
Expand Down Expand Up @@ -137,7 +132,6 @@ class TileCache {
private shouldUseCache(tileParams: TileParams): boolean {
return this.cacheDomain.tilesets.includes(tileParams.tileset) &&
this.cacheDomain.minZoom <= tileParams.z &&
this.cacheDomain.maxZoom >= tileParams.z &&
this.cacheDomain.scales.includes(tileParams.scale) &&
(this.shouldCacheFn == undefined || this.shouldCacheFn(tileParams));
}
Expand Down
Loading