Files
openlayers/src/ol/loadingstrategy.js
Tim Schaub ccfacc5ee6 Transformed types
Using the [ts.js codemod](https://gist.github.com/tschaub/1ea498c9d1e5268cf36d212b3949be4e):

    jscodeshift --transform ts.js src
2018-09-05 08:05:29 -06:00

60 lines
1.8 KiB
JavaScript

/**
* @module ol/loadingstrategy
*/
/**
* Strategy function for loading all features with a single request.
* @param {import("./extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @return {Array<import("./extent.js").Extent>} Extents.
* @api
*/
export function all(extent, resolution) {
return [[-Infinity, -Infinity, Infinity, Infinity]];
}
/**
* Strategy function for loading features based on the view's extent and
* resolution.
* @param {import("./extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @return {Array<import("./extent.js").Extent>} Extents.
* @api
*/
export function bbox(extent, resolution) {
return [extent];
}
/**
* Creates a strategy function for loading features based on a tile grid.
* @param {import("./tilegrid/TileGrid.js").default} tileGrid Tile grid.
* @return {function(import("./extent.js").Extent, number): Array<import("./extent.js").Extent>} Loading strategy.
* @api
*/
export function tile(tileGrid) {
return (
/**
* @param {import("./extent.js").Extent} extent Extent.
* @param {number} resolution Resolution.
* @return {Array<import("./extent.js").Extent>} Extents.
*/
function(extent, resolution) {
const z = tileGrid.getZForResolution(resolution);
const tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
/** @type {Array<import("./extent.js").Extent>} */
const extents = [];
/** @type {import("./tilecoord.js").TileCoord} */
const tileCoord = [z, 0, 0];
for (tileCoord[1] = tileRange.minX; tileCoord[1] <= tileRange.maxX; ++tileCoord[1]) {
for (tileCoord[2] = tileRange.minY; tileCoord[2] <= tileRange.maxY; ++tileCoord[2]) {
extents.push(tileGrid.getTileCoordExtent(tileCoord));
}
}
return extents;
}
);
}