Store number of resolutions in member variable

This commit is contained in:
Tom Payne
2012-07-07 13:27:59 +02:00
committed by Tom Payne
parent ff34400d96
commit 9a89814896
+9 -4
View File
@@ -29,6 +29,12 @@ ol.TileGrid = function(resolutions, extent, corner, origin, opt_tileSize) {
return -goog.array.defaultCompare(a, b); return -goog.array.defaultCompare(a, b);
}, true)); }, true));
/**
* @private
* @type {number}
*/
this.numResolutions_ = this.resolutions_.length;
/** /**
* @private * @private
* @type {ol.Extent} * @type {ol.Extent}
@@ -56,7 +62,7 @@ ol.TileGrid = function(resolutions, extent, corner, origin, opt_tileSize) {
if (origin instanceof goog.math.Coordinate) { if (origin instanceof goog.math.Coordinate) {
this.origin_ = origin; this.origin_ = origin;
} else if (goog.isArray(origin)) { } else if (goog.isArray(origin)) {
goog.asserts.assert(origin.length == this.resolutions_.length); goog.asserts.assert(origin.length == this.numResolutions_);
this.origins_ = origin; this.origins_ = origin;
} else { } else {
goog.asserts.assert(false); goog.asserts.assert(false);
@@ -116,7 +122,7 @@ ol.TileGrid.prototype.getOrigin = function(z) {
* @return {number} Resolution. * @return {number} Resolution.
*/ */
ol.TileGrid.prototype.getResolution = function(z) { 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]; return this.resolutions_[z];
}; };
@@ -224,8 +230,7 @@ ol.TileGrid.prototype.getTileSize = function() {
* @return {number} Tile resolution. * @return {number} Tile resolution.
*/ */
ol.TileGrid.prototype.getTileResolution = function(tileCoord) { ol.TileGrid.prototype.getTileResolution = function(tileCoord) {
goog.asserts.assert( goog.asserts.assert(0 <= tileCoord.z && tileCoord.z < this.numResolutions_);
0 <= tileCoord.z && tileCoord.z < this.resolutions_.length);
return this.resolutions_[tileCoord.z]; return this.resolutions_[tileCoord.z];
}; };