From aded70d6e6d2e2dd87c2207e69d165eb84a2f203 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 17 Jul 2012 16:06:10 +0200 Subject: [PATCH] Add ol.TileBounds.getSize --- src/ol/tilebounds.js | 10 ++++++++++ src/ol/tilebounds_test.js | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/ol/tilebounds.js b/src/ol/tilebounds.js index 216ee49e0a..5da030a29d 100644 --- a/src/ol/tilebounds.js +++ b/src/ol/tilebounds.js @@ -1,6 +1,7 @@ goog.provide('ol.TileBounds'); goog.require('goog.asserts'); +goog.require('goog.math.Size'); goog.require('ol.Rectangle'); goog.require('ol.TileCoord'); @@ -71,3 +72,12 @@ ol.TileBounds.prototype.forEachTileCoord = function(z, f, opt_obj) { } } }; + + +/** + * @return {goog.math.Size} Size. + */ +ol.TileBounds.prototype.getSize = function() { + return new goog.math.Size( + this.maxX - this.minX + 1, this.maxY - this.minY + 1); +}; diff --git a/src/ol/tilebounds_test.js b/src/ol/tilebounds_test.js index 9a877c4c12..152c287980 100644 --- a/src/ol/tilebounds_test.js +++ b/src/ol/tilebounds_test.js @@ -76,3 +76,11 @@ function testForEachTileCoord() { assertEquals(3, tileCoords[3].y); } + + +function testSize() { + var tileBounds = new ol.TileBounds(0, 1, 2, 4); + var size = tileBounds.getSize(); + assertEquals(3, size.width); + assertEquals(4, size.height); +}