From 9af1e223afc38a8bc0c93b0f48c42afcb1cc2406 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Tue, 31 Mar 2020 15:52:29 +0200 Subject: [PATCH] More tests and docs for extent and coordinate wrapX --- src/ol/coordinate.js | 3 ++- test/spec/ol/extent.test.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ol/coordinate.js b/src/ol/coordinate.js index 79d196a911..563ff1bf64 100644 --- a/src/ol/coordinate.js +++ b/src/ol/coordinate.js @@ -407,7 +407,8 @@ export function toStringXY(coordinate, opt_fractionDigits) { /** * Modifies the provided coordinate in-place to be within the real world - * extent. + * extent. The lower projection extent boundary is inclusive, the upper one + * exclusive. * * @param {Coordinate} coordinate Coordinate. * @param {import("./proj/Projection.js").default} projection Projection diff --git a/test/spec/ol/extent.test.js b/test/spec/ol/extent.test.js index ba971781da..cc9011175a 100644 --- a/test/spec/ol/extent.test.js +++ b/test/spec/ol/extent.test.js @@ -849,6 +849,12 @@ describe('ol.extent', function() { expect(_ol_extent_.wrapX([300, 48, 376, 49], projection)).to.eql([-60, 48, 16, 49]); }); + it('produces the same real world extent for shifted extents with center at +/-180', function() { + expect(_ol_extent_.wrapX([360, -90, 720, 90], projection)).to.eql([-360, -90, 0, 90]); + expect(_ol_extent_.wrapX([0, -90, 360, 90], projection)).to.eql([-360, -90, 0, 90]); + expect(_ol_extent_.wrapX([-360, -90, 0, 90], projection)).to.eql([-360, -90, 0, 90]); + }); + }); describe('approximatelyEquals', function() {