From 7a46b3a61a8f3a48c8cd769a2614b54d95e18764 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Fri, 1 May 2020 12:06:38 +0100 Subject: [PATCH 1/9] add dummy parameter to url to avoid shared cache --- examples/disable-image-smoothing.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/disable-image-smoothing.js b/examples/disable-image-smoothing.js index 0a6b23923a..fbce6af1a6 100644 --- a/examples/disable-image-smoothing.js +++ b/examples/disable-image-smoothing.js @@ -35,7 +35,8 @@ const enabledLayer = new TileLayer({ source: new XYZ({ attributions: attributions, url: - 'https://api.maptiler.com/tiles/terrain-rgb/{z}/{x}/{y}.png?key=' + key, + 'https://api.maptiler.com/tiles/terrain-rgb/{z}/{x}/{y}.png?key=' + key + + '&map=2', // dummy parameter added to avoid shared cache maxZoom: 10, crossOrigin: '', }), From 62f150176ae54d919bda9cfb2616e5009e9ac101 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Fri, 1 May 2020 12:28:07 +0100 Subject: [PATCH 2/9] add dummy parameter to url to avoid shared cache fix prettier --- examples/disable-image-smoothing.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/disable-image-smoothing.js b/examples/disable-image-smoothing.js index fbce6af1a6..f9bc6598ed 100644 --- a/examples/disable-image-smoothing.js +++ b/examples/disable-image-smoothing.js @@ -35,7 +35,8 @@ const enabledLayer = new TileLayer({ source: new XYZ({ attributions: attributions, url: - 'https://api.maptiler.com/tiles/terrain-rgb/{z}/{x}/{y}.png?key=' + key + + 'https://api.maptiler.com/tiles/terrain-rgb/{z}/{x}/{y}.png?key=' + + key + '&map=2', // dummy parameter added to avoid shared cache maxZoom: 10, crossOrigin: '', From b2a1540ee046ae628160b3b9be03304a699bad2a Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 4 May 2020 12:47:15 +0100 Subject: [PATCH 3/9] Include context options in reprojection cache key --- src/ol/source/TileImage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ol/source/TileImage.js b/src/ol/source/TileImage.js index cf9623aaa3..c11ddd1660 100644 --- a/src/ol/source/TileImage.js +++ b/src/ol/source/TileImage.js @@ -332,7 +332,8 @@ class TileImage extends UrlTile { if (cache.containsKey(tileCoordKey)) { tile = cache.get(tileCoordKey); } - const key = this.getKey(); + const key = this.getKey() + + (this.contextOptions_ ? '\n' + JSON.stringify(this.contextOptions_) : ''); if (tile && tile.key == key) { return tile; } else { From 9bf037947cd86bf27498e1597cf68a27dd8829cd Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 4 May 2020 12:53:24 +0100 Subject: [PATCH 4/9] Include context options in reprojection cache key fix prettier --- src/ol/source/TileImage.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ol/source/TileImage.js b/src/ol/source/TileImage.js index c11ddd1660..b3f88f6e8e 100644 --- a/src/ol/source/TileImage.js +++ b/src/ol/source/TileImage.js @@ -332,8 +332,11 @@ class TileImage extends UrlTile { if (cache.containsKey(tileCoordKey)) { tile = cache.get(tileCoordKey); } - const key = this.getKey() + - (this.contextOptions_ ? '\n' + JSON.stringify(this.contextOptions_) : ''); + const key = + this.getKey() + + (this.contextOptions_ + ? '\n' + JSON.stringify(this.contextOptions_) + : ''); if (tile && tile.key == key) { return tile; } else { From 9e160e75f97315c5b37a62ab64c930f9a10b280d Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 4 May 2020 14:31:46 +0100 Subject: [PATCH 5/9] Include context options in reprojection cache key use reprojection tileCoordKey instead of source key --- src/ol/source/TileImage.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ol/source/TileImage.js b/src/ol/source/TileImage.js index b3f88f6e8e..bebe98534c 100644 --- a/src/ol/source/TileImage.js +++ b/src/ol/source/TileImage.js @@ -328,15 +328,15 @@ class TileImage extends UrlTile { const cache = this.getTileCacheForProjection(projection); const tileCoord = [z, x, y]; let tile; - const tileCoordKey = getKey(tileCoord); - if (cache.containsKey(tileCoordKey)) { - tile = cache.get(tileCoordKey); - } - const key = - this.getKey() + + const tileCoordKey = + getKey(tileCoord) + (this.contextOptions_ ? '\n' + JSON.stringify(this.contextOptions_) : ''); + if (cache.containsKey(tileCoordKey)) { + tile = cache.get(tileCoordKey); + } + const key = this.getKey(); if (tile && tile.key == key) { return tile; } else { From 76d2d6e7371a0e039cc6e29d4b1a2140ff632f0c Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 4 May 2020 16:27:27 +0100 Subject: [PATCH 6/9] Include context options in reprojection cache key override the inherited getKey() method --- src/ol/source/TileImage.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/ol/source/TileImage.js b/src/ol/source/TileImage.js index bebe98534c..e6ecdfc139 100644 --- a/src/ol/source/TileImage.js +++ b/src/ol/source/TileImage.js @@ -207,6 +207,18 @@ class TileImage extends UrlTile { getGutter() { return 0; } + + /** + * Return the key to be used for all tiles in the source. + * @return {string} The key for all tiles. + * @protected + */ + getKey() { + return super.getKey() + + (this.contextOptions_ + ? '\n' + JSON.stringify(this.contextOptions_) + : ''); + } /** * @param {import("../proj/Projection.js").default} projection Projection. @@ -328,11 +340,7 @@ class TileImage extends UrlTile { const cache = this.getTileCacheForProjection(projection); const tileCoord = [z, x, y]; let tile; - const tileCoordKey = - getKey(tileCoord) + - (this.contextOptions_ - ? '\n' + JSON.stringify(this.contextOptions_) - : ''); + const tileCoordKey = getKey(tileCoord); if (cache.containsKey(tileCoordKey)) { tile = cache.get(tileCoordKey); } From c0577c3293f4eade85a71657597d1fce8e9bbc6f Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 4 May 2020 16:45:29 +0100 Subject: [PATCH 7/9] Include context options in reprojection cache key fix prettier --- src/ol/source/TileImage.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ol/source/TileImage.js b/src/ol/source/TileImage.js index e6ecdfc139..ba100b94af 100644 --- a/src/ol/source/TileImage.js +++ b/src/ol/source/TileImage.js @@ -207,17 +207,17 @@ class TileImage extends UrlTile { getGutter() { return 0; } - + /** * Return the key to be used for all tiles in the source. * @return {string} The key for all tiles. * @protected */ getKey() { - return super.getKey() + - (this.contextOptions_ - ? '\n' + JSON.stringify(this.contextOptions_) - : ''); + return ( + super.getKey() + + (this.contextOptions_ ? '\n' + JSON.stringify(this.contextOptions_) : '') + ); } /** From e0047139e17d185efd4864d2607986d8342b653d Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 4 May 2020 17:11:16 +0100 Subject: [PATCH 8/9] Revert dummy parameter change --- examples/disable-image-smoothing.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/disable-image-smoothing.js b/examples/disable-image-smoothing.js index f9bc6598ed..994f2187e9 100644 --- a/examples/disable-image-smoothing.js +++ b/examples/disable-image-smoothing.js @@ -35,9 +35,7 @@ const enabledLayer = new TileLayer({ source: new XYZ({ attributions: attributions, url: - 'https://api.maptiler.com/tiles/terrain-rgb/{z}/{x}/{y}.png?key=' + - key + - '&map=2', // dummy parameter added to avoid shared cache + 'https://api.maptiler.com/tiles/terrain-rgb/{z}/{x}/{y}.png?key=' + key; maxZoom: 10, crossOrigin: '', }), From 960abdbec1f4fda075889e15adb040c95fca069e Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 4 May 2020 17:14:57 +0100 Subject: [PATCH 9/9] Revert dummy parameter change fix typo --- examples/disable-image-smoothing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/disable-image-smoothing.js b/examples/disable-image-smoothing.js index 994f2187e9..0a6b23923a 100644 --- a/examples/disable-image-smoothing.js +++ b/examples/disable-image-smoothing.js @@ -35,7 +35,7 @@ const enabledLayer = new TileLayer({ source: new XYZ({ attributions: attributions, url: - 'https://api.maptiler.com/tiles/terrain-rgb/{z}/{x}/{y}.png?key=' + key; + 'https://api.maptiler.com/tiles/terrain-rgb/{z}/{x}/{y}.png?key=' + key, maxZoom: 10, crossOrigin: '', }),