Merge pull request #9197 from fredj/cleanup

Remove unused opt_this param
This commit is contained in:
Frédéric Junod
2019-02-08 08:43:31 +01:00
committed by GitHub
5 changed files with 17 additions and 26 deletions

View File

@@ -11,21 +11,19 @@
* @param {number} offset Offset.
* @param {number} end End.
* @param {number} stride Stride.
* @param {function(this: S, import("../../coordinate.js").Coordinate, import("../../coordinate.js").Coordinate): T} callback Function
* @param {function(import("../../coordinate.js").Coordinate, import("../../coordinate.js").Coordinate): T} callback Function
* called for each segment.
* @param {S=} opt_this The object to be used as the value of 'this'
* within callback.
* @return {T|boolean} Value.
* @template T,S
* @template T
*/
export function forEach(flatCoordinates, offset, end, stride, callback, opt_this) {
export function forEach(flatCoordinates, offset, end, stride, callback) {
const point1 = [flatCoordinates[offset], flatCoordinates[offset + 1]];
const point2 = [];
let ret;
for (; (offset + stride) < end; offset += stride) {
point2[0] = flatCoordinates[offset + stride];
point2[1] = flatCoordinates[offset + stride + 1];
ret = callback.call(opt_this, point1, point2);
ret = callback(point1, point2);
if (ret) {
return ret;
}

View File

@@ -221,10 +221,8 @@ class LayerRenderer extends Observable {
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} currentZ Current Z.
* @param {number} preload Load low resolution tiles up to 'preload' levels.
* @param {function(this: T, import("../Tile.js").default)=} opt_tileCallback Tile callback.
* @param {T=} opt_this Object to use as `this` in `opt_tileCallback`.
* @param {function(import("../Tile.js").default)=} opt_tileCallback Tile callback.
* @protected
* @template T
*/
manageTilePyramid(
frameState,
@@ -235,8 +233,7 @@ class LayerRenderer extends Observable {
extent,
currentZ,
preload,
opt_tileCallback,
opt_this
opt_tileCallback
) {
const tileSourceKey = getUid(tileSource);
if (!(tileSourceKey in frameState.wantedTiles)) {
@@ -261,7 +258,7 @@ class LayerRenderer extends Observable {
}
}
if (opt_tileCallback !== undefined) {
opt_tileCallback.call(opt_this, tile);
opt_tileCallback(tile);
}
} else {
tileSource.useTile(z, x, y, projection);

View File

@@ -199,7 +199,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
covered = findLoadedTiles(z + 1, childTileRange);
}
if (!covered) {
tileGrid.forEachTileCoordParentTileRange(tile.tileCoord, findLoadedTiles, null, tmpTileRange, tmpExtent);
tileGrid.forEachTileCoordParentTileRange(tile.tileCoord, findLoadedTiles, tmpTileRange, tmpExtent);
}
}

View File

@@ -138,25 +138,23 @@ export class CustomTile extends Tile {
* Calls the callback (synchronously by default) with the available data
* for given coordinate (or `null` if not yet loaded).
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {function(this: T, *): void} callback Callback.
* @param {T=} opt_this The object to use as `this` in the callback.
* @param {function(*): void} callback Callback.
* @param {boolean=} opt_request If `true` the callback is always async.
* The tile data is requested if not yet loaded.
* @template T
*/
forDataAtCoordinate(coordinate, callback, opt_this, opt_request) {
forDataAtCoordinate(coordinate, callback, opt_request) {
if (this.state == TileState.IDLE && opt_request === true) {
listenOnce(this, EventType.CHANGE, function(e) {
callback.call(opt_this, this.getData(coordinate));
callback(this.getData(coordinate));
}, this);
this.loadInternal_();
} else {
if (opt_request === true) {
setTimeout(function() {
callback.call(opt_this, this.getData(coordinate));
callback(this.getData(coordinate));
}.bind(this), 0);
} else {
callback.call(opt_this, this.getData(coordinate));
callback(this.getData(coordinate));
}
}
}
@@ -391,7 +389,7 @@ class UTFGrid extends TileSource {
coordinate, resolution);
const tile = /** @type {!CustomTile} */(this.getTile(
tileCoord[0], tileCoord[1], tileCoord[2], 1, this.getProjection()));
tile.forDataAtCoordinate(coordinate, callback, null, opt_request);
tile.forDataAtCoordinate(coordinate, callback, opt_request);
} else {
if (opt_request === true) {
setTimeout(function() {

View File

@@ -203,14 +203,12 @@ class TileGrid {
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {function(this: T, number, import("../TileRange.js").default): boolean} callback Callback.
* @param {T=} opt_this The object to use as `this` in `callback`.
* @param {function(number, import("../TileRange.js").default): boolean} callback Callback.
* @param {import("../TileRange.js").default=} opt_tileRange Temporary import("../TileRange.js").default object.
* @param {import("../extent.js").Extent=} opt_extent Temporary import("../extent.js").Extent object.
* @return {boolean} Callback succeeded.
* @template T
*/
forEachTileCoordParentTileRange(tileCoord, callback, opt_this, opt_tileRange, opt_extent) {
forEachTileCoordParentTileRange(tileCoord, callback, opt_tileRange, opt_extent) {
let tileRange, x, y;
let tileCoordExtent = null;
let z = tileCoord[0] - 1;
@@ -228,7 +226,7 @@ class TileGrid {
} else {
tileRange = this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange);
}
if (callback.call(opt_this, z, tileRange)) {
if (callback(z, tileRange)) {
return true;
}
--z;