Skip to content

Commit

Permalink
Merge pull request #12212 from hotpocket/issue-4921
Browse files Browse the repository at this point in the history
per naming convention and #4921 this should make this `Rectangle.validate` private.
  • Loading branch information
jjspace authored Sep 27, 2024
2 parents 1101847 + 9394354 commit 6c2e520
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
- Reverts Firefox OIT temporary fix [#4815] and Firefox test failure fix [#5047]
- Fixed noise in ambient occlusion post process. [#12201](https://github.com/CesiumGS/cesium/pull/12201)

##### Deprecated :hourglass_flowing_sand:

- `Rectangle.validate` has been deprecated. It will be removed in 1.124.

### 1.121.1 - 2024-09-04

This is an npm-only release to extra source maps included in 1.121
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu

## [Individual CLA](Documentation/Contributors/CLAs/individual-contributor-license-agreement-v1.0.pdf)

- [Brandon Landry](https://github.com/hotpocket)
- [Victor Berchet](https://github.com/vicb)
- [Caleb Morse](https://github.com/cmorse)
- [Ravi Agrawal](https://github.com/macoda)
Expand Down
21 changes: 21 additions & 0 deletions packages/engine/Source/Core/Rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Ellipsoid from "./Ellipsoid.js";
import CesiumMath from "./Math.js";
import Transforms from "./Transforms.js";
import Matrix4 from "./Matrix4.js";
import deprecationWarning from "./deprecationWarning.js";

/**
* A two dimensional region specified as longitude and latitude coordinates.
Expand Down Expand Up @@ -541,8 +542,28 @@ Rectangle.prototype.equalsEpsilon = function (other, epsilon) {
* @exception {DeveloperError} <code>south</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>].
* @exception {DeveloperError} <code>east</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>].
* @exception {DeveloperError} <code>west</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>].
* @deprecated This function is deprecated and will be removed in Cesium 1.124. See <a href="https://github.com/CesiumGS/cesium/issues/4921">Issue 4921</a>
*/
Rectangle.validate = function (rectangle) {
deprecationWarning(
"Rectangle.validate",
"Rectangle.validate is a no-op and has been deprecated. It will be removed in Cesium 1.124.",
);
return Rectangle._validate(rectangle);
};

/**
* Checks a Rectangle's properties and throws if they are not in valid ranges.
*
* @param {Rectangle} rectangle The rectangle to validate
*
* @exception {DeveloperError} <code>north</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>].
* @exception {DeveloperError} <code>south</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>].
* @exception {DeveloperError} <code>east</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>].
* @exception {DeveloperError} <code>west</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>].
* @private
*/
Rectangle._validate = function (rectangle) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("rectangle", rectangle);

Expand Down
4 changes: 2 additions & 2 deletions packages/engine/Source/Core/RectangleGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ function RectangleGeometry(options) {

//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("rectangle", rectangle);
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
if (rectangle.north < rectangle.south) {
throw new DeveloperError(
"options.rectangle.north must be greater than or equal to options.rectangle.south",
Expand Down Expand Up @@ -1199,7 +1199,7 @@ RectangleGeometry.computeRectangle = function (options, result) {

//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("rectangle", rectangle);
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
if (rectangle.north < rectangle.south) {
throw new DeveloperError(
"options.rectangle.north must be greater than or equal to options.rectangle.south",
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/Source/Core/RectangleOutlineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function RectangleOutlineGeometry(options) {
if (!defined(rectangle)) {
throw new DeveloperError("rectangle is required.");
}
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
if (rectangle.north < rectangle.south) {
throw new DeveloperError(
"options.rectangle.north must be greater than options.rectangle.south",
Expand Down
18 changes: 9 additions & 9 deletions packages/engine/Specs/Core/RectangleSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,71 +413,71 @@ describe("Core/Rectangle", function () {

it("validate throws with no rectangle", function () {
expect(function () {
Rectangle.validate();
Rectangle._validate();
}).toThrowDeveloperError();
});

it("validate throws with no west", function () {
const rectangle = new Rectangle(west, south, east, north);
rectangle.west = undefined;
expect(function () {
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
}).toThrowDeveloperError();
});

it("validate throws with no south", function () {
const rectangle = new Rectangle(west, south, east, north);
rectangle.south = undefined;
expect(function () {
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
}).toThrowDeveloperError();
});

it("validate throws with no east", function () {
const rectangle = new Rectangle(west, south, east, north);
rectangle.east = undefined;
expect(function () {
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
}).toThrowDeveloperError();
});

it("validate throws with no north", function () {
const rectangle = new Rectangle(west, south, east, north);
rectangle.north = undefined;
expect(function () {
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
}).toThrowDeveloperError();
});

it("validate throws with bad west", function () {
const rectangle = new Rectangle(west, south, east, north);
rectangle.west = Math.PI * 2;
expect(function () {
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
}).toThrowDeveloperError();
});

it("validate throws with bad south", function () {
const rectangle = new Rectangle(west, south, east, north);
rectangle.south = Math.PI * 2;
expect(function () {
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
}).toThrowDeveloperError();
});

it("validate throws with bad east", function () {
const rectangle = new Rectangle(west, south, east, north);
rectangle.east = Math.PI * 2;
expect(function () {
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
}).toThrowDeveloperError();
});

it("validate throws with bad north", function () {
const rectangle = new Rectangle(west, south, east, north);
rectangle.north = Math.PI * 2;
expect(function () {
Rectangle.validate(rectangle);
Rectangle._validate(rectangle);
}).toThrowDeveloperError();
});

Expand Down

0 comments on commit 6c2e520

Please sign in to comment.