object timeout czml


Is there a simple way of giving a czml entity a timeout property that would effectively cause the runtime to automatically reap entities that have reached their timeout period?

I’d rather not manage a list of “active” entities server-side, where I’d either decide an entity should be kept active or otherwise removed.

I’m thinking currentTime and interval might provide this flexibility, but I’m unsure.

Hi James,

Good question! It depends on what you mean by reap:

A) If you just want to remove a entity from the display (eg. hide it), you can use the CZML availability property (https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/CZML-Structure#availability), which will hide the entity at specified intervals. Note that this means the objects persist in memory – if you were to scrub backwards in history, the hidden entities would return.

B) If you want to reclaim memory, totally erasing your entities, this can still be done client-side. If on the server-side you know the entity is going away, you can send a CZML delete request. However, if you don’t know when the entity needs to disappear, then you can iterate through your list of entities (probably as an EntityCollection of your datasource), and remove any that don’t need update. The issue is that for a large list of entities, doing this per-frame can get expensive, so I’d recommend only checking every X seconds instead.

If you share more details about your specific use-case, I can make some more specific recommendations.

Hope that helps!

  • Rachel

It depends on if he’s talking about removing an entity permanently from Cesium (for example, if he’s trying to reclaim memory for a long-running real-time application) or if he just wants it gone from the display.

a. If it’s just removing it from the display, he should be using either the CZML availability property (if he knows the first and final positions) or just setting the extrapolation options so the entity times out in the display (see https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/InterpolatableProperty). In both cases, Cesium will know the lifespan of the object and remove it from the display automatically. This also means if you scrub the timeline backward, the timed out entities will come back, because we have data for that time.

b. If it’s the former (reclaiming memory) then that can be done client side as well, but it’s a little trickier depending on his requirements. If he knows the entity is going away on the server, he can send a CZML delete request which will delete the entity on the client (this is server initiated though and sounds like he doesn’t know when it’s supposed to go away). A second option would be do as you suggested, iterate through entities and remove any that haven’t need updated in X seconds. This can be slow to do every frame, so you would probably want to do it every few seconds. It’s also a little tricky because it’s not really possible to tell what the “last update” of an entity is. If he’s just updating positions and they are definitely all SampledPositionProperties (which is likely), then the problem is a lot easier. Either way, I would share some of this info and ask for more details about his specific use case.