Rectangle.fromCartographicArray maybe missing some borderline case?


Should’t “Rectangle.fromCartographicArray” function account for cases where the rectangle crosses 180 degrees longitude? I see other function like “Rectangle.contains” expect a rectangle’s east to be sometimes less than its west, I am assuming that is to cover the cases where the rectangle crosses 180 degrees?

Here is what I am doing. I compute the current minimum bounding rectangle using the code below. Then I am trying to use “Rectangle.contains” to test if a bunch cartographic points are in view.

var leftTop = camera.pickEllipsoid(new Cesium.Cartesian2(0, 0), ellipsoid);
var leftBottom = camera.pickEllipsoid(new Cesium.Cartesian2(0, canvasHeight), ellipsoid);
var rightTop = camera.pickEllipsoid(new Cesium.Cartesian2(canvasWidth, 0), ellipsoid);
var rightBottom = camera.pickEllipsoid(new Cesium.Cartesian2(canvasWidth, canvasHeight), ellipsoid);

if (leftTop !== undefined && leftBottom !== undefined && rightTop !== undefined && rightBottom !== undefined) {
var cartographicArray = ;

[leftTop, leftBottom, rightTop, rightBottom].forEach(function (point) {

var rectangle = Rectangle.fromCartographicArray(cartographicArray);


Hello Tim,

Thanks for pointing this out! It seems to be an oversight. In the beginning, we didn’t support rectangles that crossed the 180 degrees line. We made changes to most functions to it supports it, but we seem to have missed this one.

I’ve created an issue on github here:

If you would like to fix the function, we would gladly take the pull request!



Thanks! Could you submit this as a pull request to our Github repo? There are instructions for doing so here:

Sure will try doing that over the weekend…

  • Tim

Hi Tim,

I went ahead and submitted a fix for this. It will be included in the next Cesium release (1.17)



Thanks Hannah! Sorry I did not get to it on time. I actually found today the code I posted sometimes gives values of longitude > PI because the floating point less than comparison is a toss up when it comes to equal values. I see you handled the case by making sure the final values are not greater that PI. I removed the post that had the code so people don’t pick it it by mistake.