Make ol.source.Tile#getTilePixelRatio work for all sources
Even for sources which serve dynamic tile sizes based on devicePixelRatio
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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_,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user