How to add imagery layer with dynamic realtime data

Hello,

I’m trying to create an imagery provider to a custom backend that pushes realtime updates to imagery tiles in realtime. I looked into the source for various imagery providers and tried using a TimeIntervalCollection but this seemed to be for when you know the time intervals in advance (not sure how this is used with weather map service when images updated). There is no way of notifying Cesium when an individual tile had been updated except by calling _reload() that is set by GlobeSurfaceTileProvider to reload all tiles from the provider.

There is also no way to know when Cesium has released an imagery tile image. The ImageryProvider is expected to return an Image or Canvas HTML element in response to a call to requestImage(x, y, level). If I create a websocket for each image then I don’t know when I can disconnect them. HTTP2 allows up to 128 active websockets. I exceed this very quickly when zooming in/out even though the ImageryProvider’s min/max bounds is less than 1km per side.

When I update the returned Canvas images and call _reload() so Cesium will use the updated images, I notice Cesium sometimes stops updating some of the tiles. I have tested this without websocket code, just returning Canvas that is updated 30 times a second with a rotating coloured square. I can provide code of this example to show the problem. I’m not sure if this is because I am updating the same Canvas I returned previously. Should I use double buffering to update 2nd Canvas and swap them each time Cesium calls requestImage() ?

Can you please add support for dynamic ImageryProvider images to your schedule?

Is there a way to find out when an image is no longer active?

Thanks,

Brendan

Using Cesium 1.58.1

Hey Brendan,

This sounds like a pretty cool project! What kind of application are you working on?

The WMTS imagery provider in CesiumJS does actually support time dynamic imagery, as you noted by passing in a TimeIntervalCollection. I noticed the Sandcastle example for this was broken because the imagery URL we were using for it must have changed, so I’ve logged this bug here: https://github.com/AnalyticalGraphicsInc/cesium/issues/8310

There’s a lot of Sandcastle examples using time dynamic data, such as this one moving the vehicle and its wheels:

https://sandcastle.cesium.com/index.html?src=Time%20Dynamic%20Wheels.html

They’re all using a pre-set time interval collection, but all you’d need to do get this to work for real-time data is to push samples to the TimeIntervalCollection as you receive them from the server. You would then have the “live” view be maybe a second or so behind (or whatever the granularity of your push updates are) so it can interpolate between samples.

So that might be the easiest way to get it working (just push new values to the time interval collection as you get them from your server). Although the other problem then is the reload function reloads all tiles.

If it helps, this is where you can find the logic for detecting when the clock has moved to a new time and triggers the reload:

https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/TimeDynamicImagery.js

And this is the PR that added the TimeIntervalCollection to the WMTS provider: https://github.com/AnalyticalGraphicsInc/cesium/pull/6348/