Add ol.TileGrid.getZForResolution

This commit is contained in:
Tom Payne
2012-07-08 12:37:22 +02:00
committed by Tom Payne
parent 391b5906bc
commit 40acb70a3c
2 changed files with 59 additions and 0 deletions
+24
View File
@@ -259,6 +259,30 @@ ol.TileGrid.prototype.getTileCoordResolution = function(tileCoord) {
};
/**
* @param {number} resolution Resolution.
* @return {number} Z.
*/
ol.TileGrid.prototype.getZForResolution = function(resolution) {
var z;
for (z = 0; z < this.numResolutions_; ++z) {
if (this.resolutions_[z] == resolution) {
return z;
} else if (this.resolutions_[z] < resolution) {
if (z === 0) {
return z;
} else if (resolution - this.resolutions_[z] <=
this.resolutions_[z - 1] - resolution) {
return z;
} else {
return z - 1;
}
}
}
return this.numResolutions_ - 1;
};
/**
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {function(number, ol.TileBounds): boolean} callback Callback.