Add ol.Rectangle.getSize
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ ol.TileBounds.prototype.forEachTileCoord = function(z, f, opt_obj) {
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @return {goog.math.Size} Size.
|
||||
*/
|
||||
ol.TileBounds.prototype.getSize = function() {
|
||||
|
||||
Reference in New Issue
Block a user