Add ol.TileBounds.getSize

This commit is contained in:
Tom Payne
2012-07-17 16:06:10 +02:00
parent b4fea2233e
commit aded70d6e6
2 changed files with 18 additions and 0 deletions

View File

@@ -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);
};

View File

@@ -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);
}