# Rotated Rectangles Over Dateline

I’m seeing some oddities with rotated rectangle geometries over the dateline. When the rotated rectangle geometry crossing the dateline, if the center is on the eastern hemisphere, it works as expected. However, if the center is on the western hemisphere, the entire rotated rectangle is shifted north or south. The amount shifted depends on the rotation value. Below is a sandcastle snippet that demonstrates the issue:

Cesium.Camera.DEFAULT_VIEW_RECTANGLE = new Cesium.Rectangle(
Math.PI - 0.01,
Cesium.Math.PI_OVER_SIX - 0.01,
0.01 - Math.PI,
Cesium.Math.PI_OVER_SIX + 0.01
);
Cesium.Camera.DEFAULT_VIEW_FACTOR = 0.25;

var viewer = new Cesium.Viewer(‘cesiumContainer’, { infoBox : false });

// Show dateline
polyline : {
positions: Cesium.Cartesian3.fromDegreesArray([180, 80,
180, -80]),
width: 1,
material: Cesium.Color.RED
}
});

function createEasternRectangle(rotation) {
// Rectangle with center on Eastern Hemisphere
var easternRectangle = new Cesium.Rectangle(
Math.PI - 0.01,
Cesium.Math.PI_OVER_SIX - 0.01,
0.005 - Math.PI,
Cesium.Math.PI_OVER_SIX + 0.01
);

``````return new Cesium.GeometryInstance({
geometry: new Cesium.RectangleGeometry({
rectangle: easternRectangle,
rotation: rotation
}),
attributes: {
// yellow
color: new Cesium.ColorGeometryInstanceAttribute(1.0, 1.0, 0.0, 0.5)
}
});
``````

}

function createWesternRectangle(rotation) {
// Rectangle with center on Western Hemisphere
var westernRectangle = new Cesium.Rectangle(
Math.PI - 0.005,
Cesium.Math.PI_OVER_SIX + 0.02,
0.01 - Math.PI,
Cesium.Math.PI_OVER_SIX + 0.04
);

``````return new Cesium.GeometryInstance({
geometry: new Cesium.RectangleGeometry({
rectangle: westernRectangle,
rotation: rotation
}),
attributes: {
// blue
color: new Cesium.ColorGeometryInstanceAttribute(0.0, 1.0, 1.0, 0.5)
}
});
``````

}

var eastern1 = createEasternRectangle(0);
var eastern2 = createEasternRectangle(0.5);
var western1 = createWesternRectangle(0);
var western2 = createWesternRectangle(0.005);

geometryInstances: [eastern1, eastern2, western1, western2],
appearance: new Cesium.PerInstanceColorAppearance()
}));

``

Thanks,

Jed

Thanks for the great code example Jed! I can confirm this is a bug in Cesium, and I filed an issue on our GitHub here: https://github.com/AnalyticalGraphicsInc/cesium/issues/3874
I’ll try to take a look at this problem sometime soon. I don’t think it will be too hard to track down what is happening.

Best,

Hannah