Only create and load tiles within the viewport

This commit is contained in:
Andreas Hocevar
2022-07-08 17:56:44 +02:00
parent 6ffbfa1a4a
commit 239487e9f0
3 changed files with 82 additions and 15 deletions
+17
View File
@@ -9,6 +9,7 @@ import {assert} from '../asserts.js';
import {ceil, clamp, floor} from '../math.js';
import {createOrUpdate, getTopLeft} from '../extent.js';
import {createOrUpdate as createOrUpdateTileCoord} from '../tilecoord.js';
import {intersectsLinearRing} from '../geom/flat/intersectsextent.js';
import {isSorted, linearFindNearest} from '../array.js';
import {toSize} from '../size.js';
@@ -656,6 +657,22 @@ class TileGrid {
return clamp(z, this.minZoom, this.maxZoom);
}
/**
* The tile with the provided tile coordinate intersects the given viewport.
* @param {import('../tilecoord.js').TileCoord} tileCoord Tile coordinate.
* @param {Array<number>} viewport Viewport as returned from {@link module:ol/extent.getRotatedViewport}.
* @return {boolean} The tile with the provided tile coordinate intersects the given viewport.
*/
tileCoordIntersectsViewport(tileCoord, viewport) {
return intersectsLinearRing(
viewport,
0,
viewport.length,
2,
this.getTileCoordExtent(tileCoord)
);
}
/**
* @param {!import("../extent.js").Extent} extent Extent for this tile grid.
* @private