Care with transform

Since the transform method takes an arbitrary transform function, new coordinates may not be ordered in the same way as the originals.
This commit is contained in:
Tim Schaub
2013-01-23 22:03:08 -07:00
parent d6c96c058f
commit 0845dea366
2 changed files with 21 additions and 3 deletions

View File

@@ -55,6 +55,23 @@ describe('ol.Extent', function() {
expect(destinationExtent.maxX).toRoughlyEqual(5009377.085697311, 1e-9);
expect(destinationExtent.maxY).toRoughlyEqual(8399737.889818361, 1e-9);
});
it('takes arbitrary function', function() {
var transformFn = function(coordinate) {
return new ol.Coordinate(-coordinate.x, -coordinate.y);
}
var sourceExtent = new ol.Extent(-15, -30, 45, 60);
var destinationExtent = sourceExtent.transform(transformFn);
expect(destinationExtent).not.toBeUndefined();
expect(destinationExtent).not.toBeNull();
// FIXME check values with third-party tool
expect(destinationExtent.minX).toBe(-45);
expect(destinationExtent.minY).toBe(-60);
expect(destinationExtent.maxX).toBe(15);
expect(destinationExtent.maxY).toBe(30);
});
});
});