From ebb40c80469b999dc727d806feb425cb6bb61531 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Tue, 24 Mar 2015 19:03:33 +0100 Subject: [PATCH] Clean up docs and consistently work with resolutions --- externs/olx.js | 25 ++++++++++++++++--------- src/ol/tilegrid/tilegrid.js | 4 ++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 42cc2d2a67..bbaac3bbcb 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -6503,8 +6503,8 @@ olx.tilegrid.TileGridOptions.prototype.origin; /** - * Origins. If given, the array should match the `resolutions` array, i.e. - * each resolution can have a different origin. + * Origins. If given, the array length should match the length of the + * `resolutions` array, i.e. each resolution can have a different origin. * @type {Array.|undefined} * @api stable */ @@ -6512,7 +6512,9 @@ olx.tilegrid.TileGridOptions.prototype.origins; /** - * Resolutions. + * Resolutions. The array index of each resolution needs to match the zoom + * level. This means that even if a `minZoom` is configured, the resolutions + * array will have a length of `maxZoom + 1`. * @type {!Array.} * @api stable */ @@ -6528,8 +6530,8 @@ olx.tilegrid.TileGridOptions.prototype.tileSize; /** - * Tile sizes. If given, the array should match the `resolutions` array, i.e. - * each resolution can have a different tile size. + * Tile sizes. If given, the array length should match the length of the + * `resolutions` array, i.e. each resolution can have a different tile size. * @type {Array.|undefined} * @api stable */ @@ -6567,7 +6569,8 @@ olx.tilegrid.WMTSOptions.prototype.origin; /** - * Origins. + * Origins. The length of this array needs to match the length of the + * `resolutions` array. * @type {Array.|undefined} * @api */ @@ -6575,7 +6578,9 @@ olx.tilegrid.WMTSOptions.prototype.origins; /** - * Resolutions. + * Resolutions. The array index of each resolution needs to match the zoom + * level. This means that even if a `minZoom` is configured, the resolutions + * array will have a length of `maxZoom + 1` * @type {!Array.} * @api */ @@ -6583,7 +6588,8 @@ olx.tilegrid.WMTSOptions.prototype.resolutions; /** - * matrix IDs. + * matrix IDs. The length of this array needs to match the length of the + * `resolutions` array. * @type {!Array.} * @api */ @@ -6599,7 +6605,8 @@ olx.tilegrid.WMTSOptions.prototype.tileSize; /** - * Tile sizes. + * Tile sizes. The length of this array needs to match the length of the + * `resolutions` array. * @type {Array.|undefined} * @api */ diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js index 8169dc1c06..8807e6e657 100644 --- a/src/ol/tilegrid/tilegrid.js +++ b/src/ol/tilegrid/tilegrid.js @@ -65,7 +65,7 @@ ol.tilegrid.TileGrid = function(options) { this.origins_ = null; if (goog.isDef(options.origins)) { this.origins_ = options.origins; - goog.asserts.assert(this.origins_.length == this.maxZoom + 1); + goog.asserts.assert(this.origins_.length == this.resolutions_.length); } goog.asserts.assert( (goog.isNull(this.origin_) && !goog.isNull(this.origins_)) || @@ -78,7 +78,7 @@ ol.tilegrid.TileGrid = function(options) { this.tileSizes_ = null; if (goog.isDef(options.tileSizes)) { this.tileSizes_ = options.tileSizes; - goog.asserts.assert(this.tileSizes_.length == this.maxZoom + 1); + goog.asserts.assert(this.tileSizes_.length == this.resolutions_.length); } /**