Fix private scope issues in source/UrlTile and subclasses

This commit is contained in:
Andreas Hocevar
2020-04-15 09:39:04 +02:00
parent 793ccbd411
commit 29ce0bb223
4 changed files with 187 additions and 190 deletions

View File

@@ -97,7 +97,6 @@ class TileWMS extends TileImage {
tileClass: options.tileClass,
tileGrid: options.tileGrid,
tileLoadFunction: options.tileLoadFunction,
tileUrlFunction: tileUrlFunction,
url: options.url,
urls: options.urls,
wrapX: options.wrapX !== undefined ? options.wrapX : true,
@@ -409,60 +408,60 @@ class TileWMS extends TileImage {
const version = this.params_['VERSION'] || DEFAULT_WMS_VERSION;
this.v13_ = compareVersions(version, '1.3') >= 0;
}
}
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord The tile coordinate
* @param {number} pixelRatio The pixel ratio
* @param {import("../proj/Projection.js").default} projection The projection
* @return {string|undefined} The tile URL
* @this {TileWMS}
*/
function tileUrlFunction(tileCoord, pixelRatio, projection) {
let tileGrid = this.getTileGrid();
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projection);
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord The tile coordinate
* @param {number} pixelRatio The pixel ratio
* @param {import("../proj/Projection.js").default} projection The projection
* @return {string|undefined} The tile URL
* @override
*/
tileUrlFunction(tileCoord, pixelRatio, projection) {
let tileGrid = this.getTileGrid();
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projection);
}
if (tileGrid.getResolutions().length <= tileCoord[0]) {
return undefined;
}
if (pixelRatio != 1 && (!this.hidpi_ || this.serverType_ === undefined)) {
pixelRatio = 1;
}
const tileResolution = tileGrid.getResolution(tileCoord[0]);
let tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
let tileSize = toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
const gutter = this.gutter_;
if (gutter !== 0) {
tileSize = bufferSize(tileSize, gutter, this.tmpSize);
tileExtent = buffer(tileExtent, tileResolution * gutter, tileExtent);
}
if (pixelRatio != 1) {
tileSize = scaleSize(tileSize, pixelRatio, this.tmpSize);
}
const baseParams = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_WMS_VERSION,
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': true,
};
assign(baseParams, this.params_);
return this.getRequestUrl_(
tileCoord,
tileSize,
tileExtent,
pixelRatio,
projection,
baseParams
);
}
if (tileGrid.getResolutions().length <= tileCoord[0]) {
return undefined;
}
if (pixelRatio != 1 && (!this.hidpi_ || this.serverType_ === undefined)) {
pixelRatio = 1;
}
const tileResolution = tileGrid.getResolution(tileCoord[0]);
let tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
let tileSize = toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
const gutter = this.gutter_;
if (gutter !== 0) {
tileSize = bufferSize(tileSize, gutter, this.tmpSize);
tileExtent = buffer(tileExtent, tileResolution * gutter, tileExtent);
}
if (pixelRatio != 1) {
tileSize = scaleSize(tileSize, pixelRatio, this.tmpSize);
}
const baseParams = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_WMS_VERSION,
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': true,
};
assign(baseParams, this.params_);
return this.getRequestUrl_(
tileCoord,
tileSize,
tileExtent,
pixelRatio,
projection,
baseParams
);
}
export default TileWMS;