Add ol.Rectangle.getSize

This commit is contained in:
Tom Payne
2012-07-17 22:37:21 +02:00
parent b31c3f90bd
commit 0d5bc44326
3 changed files with 18 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ goog.provide('ol.Rectangle');
goog.require('goog.asserts');
goog.require('goog.math.Coordinate');
goog.require('goog.math.Size');
@@ -78,3 +79,11 @@ ol.Rectangle.prototype.getCenter = function() {
return new goog.math.Coordinate(
(this.minX + this.maxX) / 2, (this.minY + this.maxY) / 2);
};
/**
* @return {goog.math.Size} Size.
*/
ol.Rectangle.prototype.getSize = function() {
return new goog.math.Size(this.maxX - this.minX, this.maxY - this.minY);
};

View File

@@ -99,3 +99,11 @@ function testIntersects() {
assertNotIntersects(new ol.Rectangle(80, 120, 120, 140));
assertNotIntersects(new ol.Rectangle(120, 120, 140, 140));
}
function testSize() {
var rectangle = new ol.Rectangle(0, 1, 2, 4);
var size = rectangle.getSize();
assertEquals(2, size.width);
assertEquals(3, size.height);
}

View File

@@ -75,6 +75,7 @@ ol.TileBounds.prototype.forEachTileCoord = function(z, f, opt_obj) {
/**
* @override
* @return {goog.math.Size} Size.
*/
ol.TileBounds.prototype.getSize = function() {