From 76cd52325d17f76c8ebb6ecb6da3a49f1faa9ba6 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 7 Feb 2018 14:22:07 +0100 Subject: [PATCH] Fix getIntersection return value when an opt extent is provided The return value was not an empty extent when the extents didn't intersect. --- test/spec/ol/extent.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/spec/ol/extent.test.js b/test/spec/ol/extent.test.js index 1d83f0d656..e0984eb4b9 100644 --- a/test/spec/ol/extent.test.js +++ b/test/spec/ol/extent.test.js @@ -291,6 +291,20 @@ describe('ol.extent', function() { expect(_ol_extent_.getIntersection(north, west)).to.eql([-180, 0, 0, 90]); expect(_ol_extent_.getIntersection(east, south)).to.eql([0, -90, 180, 0]); }); + + + it('can take an destination extent', function() { + const world = [-180, -90, 180, 90]; + const north = [-180, 0, 180, 90]; + const none = _ol_extent_.createEmpty(); + let tmpExtent = [-180, 45, 180, 90]; + expect(_ol_extent_.getIntersection(world, north, tmpExtent)).to.eql(north); + expect(_ol_extent_.getIntersection(world, none, tmpExtent)).to.eql(none); + + tmpExtent = [-180, -90, 180, 90]; + expect(_ol_extent_.getIntersection(tmpExtent, north, tmpExtent)).to.eql(north); + }); + }); describe('containsCoordinate', function() {