From 92931c336c8a28193c9c6fae9616d6aab6470cf1 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 20 Aug 2019 16:26:24 +0200 Subject: [PATCH] Use source tile resolution for pixel buffer --- src/ol/source/VectorTile.js | 4 ++-- test/spec/ol/source/vectortile.test.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ol/source/VectorTile.js b/src/ol/source/VectorTile.js index 19dd7cfd1e..e8991559d4 100644 --- a/src/ol/source/VectorTile.js +++ b/src/ol/source/VectorTile.js @@ -190,7 +190,7 @@ class VectorTile extends UrlTile { const z = urlTileCoord[0]; const resolution = tileGrid.getResolution(z); // make extent 1 pixel smaller so we don't load tiles for < 0.5 pixel render space - bufferExtent(extent, -1 / resolution, extent); + bufferExtent(extent, -resolution, extent); const sourceTileGrid = this.tileGrid; const sourceExtent = sourceTileGrid.getExtent(); if (sourceExtent) { @@ -338,7 +338,7 @@ class VectorTile extends UrlTile { const tileGrid = this.getTileGridForProjection(projection); const tileExtent = tileGrid.getTileCoordExtent(urlTileCoord); // make extent 1 pixel smaller so we don't load tiles for < 0.5 pixel render space - bufferExtent(tileExtent, -1 / tileGrid.getResolution(z), tileExtent); + bufferExtent(tileExtent, -tileGrid.getResolution(z), tileExtent); if (!intersects(sourceExtent, tileExtent)) { urlTileCoord = null; } diff --git a/test/spec/ol/source/vectortile.test.js b/test/spec/ol/source/vectortile.test.js index f971a2ad1f..6dfb743500 100644 --- a/test/spec/ol/source/vectortile.test.js +++ b/test/spec/ol/source/vectortile.test.js @@ -109,6 +109,15 @@ describe('ol.source.VectorTile', function() { expect(tile.getState()).to.be(TileState.IDLE); }); + it('creates non-empty tiles for overzoomed resolutions', function() { + const source = new VectorTileSource({ + maxZoom: 16 + }); + const tile = source.getTile(24, 9119385, 5820434, 1, source.getProjection()); + tile.load(); + expect(tile.getState()).to.be(TileState.LOADING); + }); + it('creates new tile when source key changes', function() { source.setKey('key1'); const tile1 = source.getTile(0, 0, 0, 1, getProjection('EPSG:3857'));