Merge pull request #4733 from ahocevar/fix-scale
Avoid rendering too big and too small images for vector tiles
This commit is contained in:
@@ -93,7 +93,6 @@ ol.renderer.canvas.VectorTileLayer.prototype.composeFrame = function(frameState,
|
|||||||
goog.asserts.assertInstanceof(source, ol.source.VectorTile,
|
goog.asserts.assertInstanceof(source, ol.source.VectorTile,
|
||||||
'Source is an ol.source.VectorTile');
|
'Source is an ol.source.VectorTile');
|
||||||
var tilePixelRatio = source.getTilePixelRatio(pixelRatio);
|
var tilePixelRatio = source.getTilePixelRatio(pixelRatio);
|
||||||
var maxScale = tilePixelRatio / pixelRatio;
|
|
||||||
|
|
||||||
var transform = this.getTransform(frameState, 0);
|
var transform = this.getTransform(frameState, 0);
|
||||||
|
|
||||||
@@ -118,9 +117,9 @@ ol.renderer.canvas.VectorTileLayer.prototype.composeFrame = function(frameState,
|
|||||||
var tileGrid = source.getTileGrid();
|
var tileGrid = source.getTileGrid();
|
||||||
|
|
||||||
var currentZ, height, i, ii, insertPoint, insertTransform, offsetX, offsetY;
|
var currentZ, height, i, ii, insertPoint, insertTransform, offsetX, offsetY;
|
||||||
var origin, pixelSpace, replayState, scale, tile, tileCenter, tileContext;
|
var origin, pixelSpace, replayState, resolutionRatio, tile, tileCenter;
|
||||||
var tileExtent, tilePixelResolution, tilePixelSize, tileResolution, tileSize;
|
var tileContext, tileExtent, tilePixelResolution, tilePixelSize;
|
||||||
var tileTransform, width;
|
var tileResolution, tileSize, tileTransform, width;
|
||||||
for (i = 0, ii = tilesToDraw.length; i < ii; ++i) {
|
for (i = 0, ii = tilesToDraw.length; i < ii; ++i) {
|
||||||
tile = tilesToDraw[i];
|
tile = tilesToDraw[i];
|
||||||
replayState = tile.getReplayState();
|
replayState = tile.getReplayState();
|
||||||
@@ -131,12 +130,13 @@ ol.renderer.canvas.VectorTileLayer.prototype.composeFrame = function(frameState,
|
|||||||
pixelSpace = tile.getProjection().getUnits() == ol.proj.Units.TILE_PIXELS;
|
pixelSpace = tile.getProjection().getUnits() == ol.proj.Units.TILE_PIXELS;
|
||||||
tileResolution = tileGrid.getResolution(currentZ);
|
tileResolution = tileGrid.getResolution(currentZ);
|
||||||
tilePixelResolution = tileResolution / tilePixelRatio;
|
tilePixelResolution = tileResolution / tilePixelRatio;
|
||||||
scale = tileResolution / resolution;
|
resolutionRatio = tileResolution / resolution;
|
||||||
offsetX = Math.round(pixelRatio * size[0] / 2);
|
offsetX = Math.round(pixelRatio * size[0] / 2);
|
||||||
offsetY = Math.round(pixelRatio * size[1] / 2);
|
offsetY = Math.round(pixelRatio * size[1] / 2);
|
||||||
width = tileSize[0] * pixelRatio * scale;
|
width = tileSize[0] * pixelRatio * resolutionRatio;
|
||||||
height = tileSize[1] * pixelRatio * scale;
|
height = tileSize[1] * pixelRatio * resolutionRatio;
|
||||||
if (width < 1 || scale > maxScale) {
|
var unscaledPixelTileSize = tileSize[0] * pixelRatio;
|
||||||
|
if (width < unscaledPixelTileSize / 4 || width > unscaledPixelTileSize * 4) {
|
||||||
if (pixelSpace) {
|
if (pixelSpace) {
|
||||||
origin = ol.extent.getTopLeft(tileExtent);
|
origin = ol.extent.getTopLeft(tileExtent);
|
||||||
tileTransform = ol.vec.Mat4.makeTransform2D(this.tmpTransform_,
|
tileTransform = ol.vec.Mat4.makeTransform2D(this.tmpTransform_,
|
||||||
|
|||||||
Reference in New Issue
Block a user