Use ol.array utility functions

This commit is contained in:
Tom Payne
2012-07-30 13:03:04 +02:00
parent 4f9044cda4
commit 65c8fe3741

View File

@@ -10,6 +10,7 @@ goog.require('ol.PixelBounds');
goog.require('ol.Size');
goog.require('ol.TileBounds');
goog.require('ol.TileCoord');
goog.require('ol.array');
@@ -302,20 +303,5 @@ ol.TileGrid.prototype.getTileSize = function() {
* @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;
return ol.array.linearFindNearest(this.resolutions_, resolution);
};