From 9a89814896984214f018a4abd4aeae7f667bf38c Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sat, 7 Jul 2012 13:27:59 +0200 Subject: [PATCH] Store number of resolutions in member variable --- src/ol/tilegrid.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ol/tilegrid.js b/src/ol/tilegrid.js index 9425c3d911..80f2f05ad6 100644 --- a/src/ol/tilegrid.js +++ b/src/ol/tilegrid.js @@ -29,6 +29,12 @@ ol.TileGrid = function(resolutions, extent, corner, origin, opt_tileSize) { return -goog.array.defaultCompare(a, b); }, true)); + /** + * @private + * @type {number} + */ + this.numResolutions_ = this.resolutions_.length; + /** * @private * @type {ol.Extent} @@ -56,7 +62,7 @@ ol.TileGrid = function(resolutions, extent, corner, origin, opt_tileSize) { if (origin instanceof goog.math.Coordinate) { this.origin_ = origin; } else if (goog.isArray(origin)) { - goog.asserts.assert(origin.length == this.resolutions_.length); + goog.asserts.assert(origin.length == this.numResolutions_); this.origins_ = origin; } else { goog.asserts.assert(false); @@ -116,7 +122,7 @@ ol.TileGrid.prototype.getOrigin = function(z) { * @return {number} Resolution. */ ol.TileGrid.prototype.getResolution = function(z) { - goog.asserts.assert(0 <= z && z < this.resolutions_.length); + goog.asserts.assert(0 <= z && z < this.numResolutions_); return this.resolutions_[z]; }; @@ -224,8 +230,7 @@ ol.TileGrid.prototype.getTileSize = function() { * @return {number} Tile resolution. */ ol.TileGrid.prototype.getTileResolution = function(tileCoord) { - goog.asserts.assert( - 0 <= tileCoord.z && tileCoord.z < this.resolutions_.length); + goog.asserts.assert(0 <= tileCoord.z && tileCoord.z < this.numResolutions_); return this.resolutions_[tileCoord.z]; };