diff --git a/src/ol/UnreferencedBounds.js b/src/ol/UnreferencedBounds.js index e9371d5bba..5f4797094c 100644 --- a/src/ol/UnreferencedBounds.js +++ b/src/ol/UnreferencedBounds.js @@ -92,3 +92,16 @@ ol.UnreferencedBounds.prototype.setMaxY = function(maxY) { this.maxY_ = maxY; }; +/** + * @return {number} Bounds width. + */ +ol.UnreferencedBounds.prototype.getWidth = function() { + return this.maxX_ - this.minX_; +}; + +/** + * @return {number} Bounds height. + */ +ol.UnreferencedBounds.prototype.getHeight = function() { + return this.maxY_ - this.minY_; +}; diff --git a/test/index.html b/test/index.html index 981c89b3cd..3ea5bd3afc 100644 --- a/test/index.html +++ b/test/index.html @@ -55,6 +55,7 @@ + diff --git a/test/spec/ol/UnreferencedBounds.test.js b/test/spec/ol/UnreferencedBounds.test.js new file mode 100644 index 0000000000..56b984d196 --- /dev/null +++ b/test/spec/ol/UnreferencedBounds.test.js @@ -0,0 +1,21 @@ +describe("ol.UnreferencedBounds", function() { + + describe("creating a bounds", function() { + it("creates a bounds instance", function() { + var bounds = new ol.UnreferencedBounds(1, 2, 3, 4); + expect(bounds).toBeA(ol.UnreferencedBounds); + }); + }); + describe("getting properties", function() { + var bounds = new ol.UnreferencedBounds(10, 20, 30, 50); + + it("allows getting width", function() { + expect(bounds.getWidth()).toBe(20); + }); + + it("allows getting height", function() { + expect(bounds.getHeight()).toBe(30); + }); + }); + +});