Hi Cesium Community!
I'm loading SingleTileImageryProviders into an array based on changing date variables so that I can create an animation loop of all the cloud patterns from a 24 hour period. Here's my code:
var vapors = ;
for (var i = 0; i <= 24; ++i) {
if ( i % 3 === 0 && i < 10 ) {
vapors.push( new Cesium.SingleTileImageryProvider({
url : ‘https://www.ncdc.noaa.gov/gibbs/image/GRD-1/IR/’ + year + ‘-’ + mon + ‘-’ + day + ‘-0’ + i,
proxy : new Cesium.DefaultProxy(’/proxy/’),
rectangle : Cesium.Rectangle.fromDegrees(-180, -70.0, 180.0, 70.0),
//errorEvent : new Cesium.Event()
}));
}
if ( i % 3 === 0 && i > 10 ) {
vapors.push( new Cesium.SingleTileImageryProvider({
url : ‘https://www.ncdc.noaa.gov/gibbs/image/GRD-1/IR/’ + year + ‘-’ + mon + ‘-’ + day + ‘-’ + i,
proxy : new Cesium.DefaultProxy(’/proxy/’),
rectangle : Cesium.Rectangle.fromDegrees(-180, -70.0, 180.0, 70.0)
}));
}
}
var vaporPlus = ;
for (var i = 0; i <= 8; ++i) {
vaporPlus.push( layers.addImageryProvider( vapors[i] ) );
vaporPlus[i].alpha = 0;
vaporPlus[i].saturation = 0;
}
cloudDrift();
function cloudDrift() {
var iter = 0;
var interval = 100; // ms
var expected = Date.now() + interval;
setTimeout(step, interval);
function step() {
var dt = Date.now() - expected; // the drift (positive for overshooting)
if (dt > interval) {
// something really bad happened.
}
if ( iter > 8 ) {
iter = 0;
vaporPlus[8].alpha = 0;
vaporPlus[0].alpha = 0.5;
}
if ( iter > 0 ) {
vaporPlus[iter - 1].alpha = 0;
vaporPlus[iter].alpha = 0.5;
}
iter = iter + 1;
expected += interval;
setTimeout(step, Math.max(0, interval - dt)); // take into account drift
}
}
The problem is, NOAA server isn't fast enough to request images at this speed, and it's giving me a 503 (Service Unavailable) error on every few requests, and then cesium is throwing me this error in the console:
An error occurred in "SingleTileImageryProvider": Failed to load image
I've played around with errorEvent in the SingleTileImageryProvider, but I can't figure out how to re-request the tile when the error occurs, or even attach a function to that event at all.
Can anyone give me tips on how to do error handling with imagery providers? I've looked through the documentation many times but am still confused.
Thank you!