diff --git a/src/ol/renderer/canvas/canvasvectortilelayerrenderer.js b/src/ol/renderer/canvas/canvasvectortilelayerrenderer.js index 3f53c28aa5..9bc3a65e99 100644 --- a/src/ol/renderer/canvas/canvasvectortilelayerrenderer.js +++ b/src/ol/renderer/canvas/canvasvectortilelayerrenderer.js @@ -94,7 +94,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.composeFrame = var source = layer.getSource(); goog.asserts.assertInstanceof(source, ol.source.VectorTile, 'Source is an ol.source.VectorTile'); - var tilePixelRatio = source.getTilePixelRatio(); + var tilePixelRatio = source.getTilePixelRatio(pixelRatio); var maxScale = tilePixelRatio / pixelRatio; var transform = this.getTransform(frameState, 0); @@ -240,7 +240,8 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup = function(tile, extent = tileGrid.getTileCoordExtent(tileCoord); } var resolution = tileGrid.getResolution(tileCoord[0]); - var tileResolution = pixelSpace ? source.getTilePixelRatio() : resolution; + var tileResolution = + pixelSpace ? source.getTilePixelRatio(pixelRatio) : resolution; replayState.dirty = false; var replayGroup = new ol.render.canvas.ReplayGroup(0, extent, tileResolution, layer.getRenderBuffer()); @@ -294,6 +295,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup = function(tile, */ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, callback, thisArg) { + var pixelRatio = frameState.pixelRatio; var resolution = frameState.viewState.resolution; var rotation = frameState.viewState.rotation; var layer = this.getLayer(); @@ -319,7 +321,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = } if (tile.getProjection().getUnits() === ol.proj.Units.TILE_PIXELS) { origin = ol.extent.getTopLeft(tileExtent); - tilePixelRatio = source.getTilePixelRatio(); + tilePixelRatio = source.getTilePixelRatio(pixelRatio); tileResolution = tileGrid.getResolution(tileCoord[0]) / tilePixelRatio; tileSpaceCoordinate = [ (coordinate[0] - origin[0]) / tileResolution, diff --git a/src/ol/source/tilearcgisrestsource.js b/src/ol/source/tilearcgisrestsource.js index 1f05c3812d..b4afd52cc0 100644 --- a/src/ol/source/tilearcgisrestsource.js +++ b/src/ol/source/tilearcgisrestsource.js @@ -134,19 +134,10 @@ ol.source.TileArcGISRest.prototype.getRequestUrl_ = /** - * @param {number} z Z. - * @param {number} pixelRatio Pixel ratio. - * @param {ol.proj.Projection} projection Projection. - * @return {ol.Size} Size. + * @inheritDoc */ -ol.source.TileArcGISRest.prototype.getTilePixelSize = - function(z, pixelRatio, projection) { - var tileSize = goog.base(this, 'getTilePixelSize', z, pixelRatio, projection); - if (pixelRatio == 1) { - return tileSize; - } else { - return ol.size.scale(tileSize, pixelRatio, this.tmpSize); - } +ol.source.TileArcGISRest.prototype.getTilePixelRatio = function(pixelRatio) { + return pixelRatio; }; diff --git a/src/ol/source/tileimagesource.js b/src/ol/source/tileimagesource.js index b9df921f8b..d6be2e131e 100644 --- a/src/ol/source/tileimagesource.js +++ b/src/ol/source/tileimagesource.js @@ -217,7 +217,7 @@ ol.source.TileImage.prototype.getTile = var tile = new ol.reproj.Tile( sourceProjection, sourceTileGrid, projection, targetTileGrid, - tileCoord, wrappedTileCoord, this.getTilePixelRatio(), + tileCoord, wrappedTileCoord, this.getTilePixelRatio(pixelRatio), goog.bind(function(z, x, y, pixelRatio) { return this.getTileInternal(z, x, y, pixelRatio, sourceProjection); }, this), this.reprojectionErrorThreshold_, diff --git a/src/ol/source/tilesource.js b/src/ol/source/tilesource.js index ad32b743ce..754004e5f5 100644 --- a/src/ol/source/tilesource.js +++ b/src/ol/source/tilesource.js @@ -243,9 +243,10 @@ ol.source.Tile.prototype.getTileCacheForProjection = function(projection) { /** + * @param {number} pixelRatio Pixel ratio. * @return {number} Tile pixel ratio. */ -ol.source.Tile.prototype.getTilePixelRatio = function() { +ol.source.Tile.prototype.getTilePixelRatio = function(pixelRatio) { return this.tilePixelRatio_; }; @@ -259,8 +260,13 @@ ol.source.Tile.prototype.getTilePixelRatio = function() { ol.source.Tile.prototype.getTilePixelSize = function(z, pixelRatio, projection) { var tileGrid = this.getTileGridForProjection(projection); - return ol.size.scale(ol.size.toSize(tileGrid.getTileSize(z), this.tmpSize), - this.tilePixelRatio_, this.tmpSize); + var tilePixelRatio = this.getTilePixelRatio(pixelRatio); + var tileSize = ol.size.toSize(tileGrid.getTileSize(z), this.tmpSize); + if (tilePixelRatio == 1) { + return tileSize; + } else { + return ol.size.scale(tileSize, tilePixelRatio, this.tmpSize); + } }; diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index 47b66b23ac..ccec57afeb 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -275,19 +275,10 @@ ol.source.TileWMS.prototype.getRequestUrl_ = /** - * @param {number} z Z. - * @param {number} pixelRatio Pixel ratio. - * @param {ol.proj.Projection} projection Projection. - * @return {ol.Size} Size. + * @inheritDoc */ -ol.source.TileWMS.prototype.getTilePixelSize = - function(z, pixelRatio, projection) { - var tileSize = goog.base(this, 'getTilePixelSize', z, pixelRatio, projection); - if (pixelRatio == 1 || !this.hidpi_ || this.serverType_ === undefined) { - return tileSize; - } else { - return ol.size.scale(tileSize, pixelRatio, this.tmpSize); - } +ol.source.TileWMS.prototype.getTilePixelRatio = function(pixelRatio) { + return (!this.hidpi_ || this.serverType_ === undefined) ? 1 : pixelRatio; };