Accept a destination array for transforms

This allows in-place transforms.
This commit is contained in:
Tim Schaub
2013-03-03 20:24:14 +01:00
parent 7a5e6a06d8
commit 40bde4056b
6 changed files with 67 additions and 37 deletions

View File

@@ -109,9 +109,9 @@ ol.Extent.prototype.getTopRight = function() {
*/
ol.Extent.prototype.transform = function(transformFn) {
var input = [this.minX, this.minY, this.maxX, this.maxY];
var output = transformFn(input, 2);
return new ol.Extent(Math.min(output[0], output[2]),
Math.min(output[1], output[3]),
Math.max(output[0], output[2]),
Math.max(output[1], output[3]));
input = transformFn(input, input, 2);
return new ol.Extent(Math.min(input[0], input[2]),
Math.min(input[1], input[3]),
Math.max(input[0], input[2]),
Math.max(input[1], input[3]));
};