Skip to content

Commit

Permalink
Using negativePiToPi instead of convertLongitudeRange for Rectangle.u…
Browse files Browse the repository at this point in the history
…nion
  • Loading branch information
IanLilleyT committed Oct 12, 2021
1 parent f95eb47 commit 628ce7e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
##### Fixes :wrench:

- Fixed zip.js configurations causing CesiumJS to not work with Node 16. [#9861](https://github.com/CesiumGS/cesium/pull/9861)
- Fixed a bug in `Rectangle.union` with rectangles that span the entire globe. [#9865](https://github.com/CesiumGS/cesium/pull/9861)

### 1.86 - 2021-10-01

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,10 @@ Rectangle.union = function (rectangle, otherRectangle, result) {
rectangleWest += CesiumMath.TWO_PI;
}

var west = CesiumMath.convertLongitudeRange(
var west = CesiumMath.negativePiToPi(
Math.min(rectangleWest, otherRectangleWest)
);
var east = CesiumMath.convertLongitudeRange(
var east = CesiumMath.negativePiToPi(
Math.max(rectangleEast, otherRectangleEast)
);

Expand Down
23 changes: 23 additions & 0 deletions Specs/Core/RectangleSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,29 @@ describe("Core/Rectangle", function () {
expect(returnedResult).toEqualEpsilon(expected, CesiumMath.EPSILON15);
});

it("union works with rectangles that span the entire globe", function () {
var rectangle1 = new Rectangle(
-CesiumMath.PI,
-CesiumMath.PI_OVER_TWO,
+CesiumMath.PI,
0.0
);
var rectangle2 = new Rectangle(
-CesiumMath.PI,
0.0,
+CesiumMath.PI,
+CesiumMath.PI_OVER_TWO
);
var expected = new Rectangle(
-CesiumMath.PI,
-CesiumMath.PI_OVER_TWO,
+CesiumMath.PI,
+CesiumMath.PI_OVER_TWO
);
var returnedResult = Rectangle.union(rectangle1, rectangle2);
expect(returnedResult).toEqualEpsilon(expected, CesiumMath.EPSILON15);
});

it("expand works if rectangle needs to grow right", function () {
var rectangle = new Rectangle(0.5, 0.1, 0.75, 0.9);
var cartographic = new Cartographic(0.85, 0.5);
Expand Down

0 comments on commit 628ce7e

Please sign in to comment.