Streaming 'live' data in CzmlDataSource: how can I delete a sample?

Let's have an aircraft, UAV, or terrestrial robot sending reports.

At date t0, position P0, I compute a predicted position Pr0 at t0+dt (using track, velocity...).
I process a first packet: [t0, P0, t0+dt, Pr0]
At date t1, I get a new position P1 and I compute a predicted position Pr1 at t1+dt.
I process this second packet: [t1, P1, t1+dt, Pr1]

When t1 is less than t0+dt (the second interval overlaps the first), my point follows the path:
P0 -> P1 -> Pr0 -> Pr1
when I would expect an updated path:
P0 -> P1 -> Pr1

From the wiki: AnalyticalGraphicsInc/czml-writer/wiki/CZML-Structure:
"When updating an existing interval, any provided sub-property value replaces the existing value, if any. The only exception is when both the previous property value and the new property value contain time-tagged samples. In that case, the samples are added to the list of samples for that interval."

Ok. That's it.

Digging into the code, I found a solution by updating the _times Array:
myTimes = czmlDataSource.entities.getById('point').position._property._times;
, removing the t1+dt time value.

What would be a cleaner way to delete not only the date, but also the data (position) attached to the sample, something like a deleteSample() ?

I’m assuming that t0+dt != t1. Samples are replaced only if the times are exactly equal.

Neither Cesium nor CZML have a mechanism to delete individual samples, currently. This would be a useful addition. You can delete and recreate the entire object, using the “delete” property, but that is not ideal in your case, because you’d have to then re-send all samples to recreate the entity.

Alternatively, you could calculate what the correct value for Pr0 should be, once you know P1, and send that as an additional sample at t0+dt, to replace the previous value.

Let's have an aircraft, UAV, or terrestrial robot sending reports.

At date t0, position P0, I compute a predicted position Pr0 at t0+dt (using track, velocity...).
I process a first packet: [t0, P0, t0+dt, Pr0]
At date t1, I get a new position P1 and I compute a predicted position Pr1 at t1+dt.
I process this second packet: [t1, P1, t1+dt, Pr1]

When t1 is less than t0+dt (the second interval overlaps the first), my point follows the path:
P0 -> P1 -> Pr0 -> Pr1
when I would expect an updated path:
P0 -> P1 -> Pr1

From the wiki: AnalyticalGraphicsInc/czml-writer/wiki/CZML-Structure:
"When updating an existing interval, any provided sub-property value replaces the existing value, if any. The only exception is when both the previous property value and the new property value contain time-tagged samples. In that case, the samples are added to the list of samples for that interval."

Ok. That's it.

Digging into the code, I found a solution by updating the _times Array:
myTimes = czmlDataSource.entities.getById('point').position._property._times;
, removing the t0+dt time value.

What would be a cleaner way to delete not only the date, but also the data (position) attached to the sample, something like a deleteSample() ?

Thanks Scott

I think I will replace the position at t0+dt by a new value, as you suggested.

Regard,
Yves