Function to buffer an extent

This commit is contained in:
Tim Schaub
2013-09-23 19:22:28 +02:00
parent 10b6b5f2c5
commit b0cea7139b
2 changed files with 23 additions and 0 deletions

View File

@@ -52,6 +52,19 @@ ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) {
};
/**
* Increase an extent by the provided value.
* @param {ol.Extent} extent The extent to buffer.
* @param {number} value The amount by wich the extent should be buffered.
*/
ol.extent.buffer = function(extent, value) {
extent[0] -= value;
extent[1] -= value;
extent[2] += value;
extent[3] += value;
};
/**
* Creates a clone of an extent.
*

View File

@@ -3,6 +3,16 @@ goog.provide('ol.test.extent');
describe('ol.extent', function() {
describe('buffer', function() {
it('buffers an extent by some value', function() {
var extent = [-10, -20, 10, 20];
ol.extent.buffer(extent, 15);
expect(extent).to.eql([-25, -35, 25, 35]);
});
});
describe('clone', function() {
it('creates a copy of an extent', function() {