Add ol.loading

This commit is contained in:
Tom Payne
2014-03-04 15:59:58 +01:00
parent 8c984cc8f7
commit 2842d1b254
2 changed files with 55 additions and 0 deletions

3
src/ol/loading.exports Normal file
View File

@@ -0,0 +1,3 @@
@exportSymbol ol.loading.all
@exportSymbol ol.loading.bbox
@exportSymbol ol.loading.createTile

52
src/ol/loading.js Normal file
View File

@@ -0,0 +1,52 @@
goog.provide('ol.loading');
goog.require('ol.TileCoord');
/**
* @param {ol.Extent} extent Extent.
* @param {number} resolution Resolution.
* @return {Array.<ol.Extent>} Extents.
*/
ol.loading.all = function(extent, resolution) {
return [[-Infinity, -Infinity, Infinity, Infinity]];
};
/**
* @param {ol.Extent} extent Extent.
* @param {number} resolution Resolution.
* @return {Array.<ol.Extent>} Extents.
*/
ol.loading.bbox = function(extent, resolution) {
return [extent];
};
/**
* @param {ol.tilegrid.TileGrid} tileGrid Tile grid.
* @return {function(ol.Extent, number): Array.<ol.Extent>} Loading strategy.
*/
ol.loading.createTile = function(tileGrid) {
return (
/**
* @param {ol.Extent} extent Extent.
* @param {number} resolution Resolution.
* @return {Array.<ol.Extent>} Extents.
*/
function(extent, resolution) {
var z = tileGrid.getZForResolution(resolution);
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
/** @type {Array.<ol.Extent>} */
var extents = [];
var tileCoord = new ol.TileCoord(z, 0, 0);
for (tileCoord.x = tileRange.minX; tileCoord.x <= tileRange.maxX;
++tileCoord.x) {
for (tileCoord.y = tileRange.minY; tileCoord.y <= tileRange.maxY;
++tileCoord.y) {
extents.push(tileGrid.getTileCoordExtent(tileCoord));
}
}
return extents;
});
};