Skip to content

Commit

Permalink
Use source tile resolution for pixel buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Aug 20, 2019
1 parent a8b5dfa commit 5b3a9c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ol/source/VectorTile.js
Expand Up @@ -189,8 +189,8 @@ class VectorTile extends UrlTile {
const extent = tileGrid.getTileCoordExtent(urlTileCoord);
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);
// make extent 1 pixel smaller so we don't load tiles for < 0.5 pixels render space
bufferExtent(extent, -resolution, extent);
const sourceTileGrid = this.tileGrid;
const sourceExtent = sourceTileGrid.getExtent();
if (sourceExtent) {
Expand Down Expand Up @@ -337,8 +337,8 @@ class VectorTile extends UrlTile {
if (urlTileCoord && sourceExtent) {
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);
// make extent 1 pixel smaller so we don't load tiles for < 0.5 tile pixel render space
bufferExtent(tileExtent, -tileGrid.getResolution(z), tileExtent);
if (!intersects(sourceExtent, tileExtent)) {
urlTileCoord = null;
}
Expand Down
9 changes: 9 additions & 0 deletions test/spec/ol/source/vectortile.test.js
Expand Up @@ -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'));
Expand Down

0 comments on commit 5b3a9c8

Please sign in to comment.