Retrieving all positions of an entity

I was wondering if there was a way to retrieve an array of all given positions of an entity. As an example lets say there is a billboard read in from a czml file that has several positions defined to give it an orbit. Is there any way to retrieve the original positions specified in the czml file at some arbitrary time after it has been loaded? The purpose of this is to have a window that will show a table of the positions for a tracked entity once I can figure out how to get the data out of Cesium.

The only way I’ve been able to find in the documentation is something like viewer.trackedEntity.position.getValue(clock.currentTime). This can give the position for the current time, but not all of them. This function also takes into account any interpolation taking place, and I would prefer to only return the original positions. I’m not sure what goes on behind the scenes with the positions data when the czml is loaded, but I’m hoping this is doable and I’ve just missed something in the documentation.

Thanks,

Chris

It varies from Property to Property, and enforcing a “give me all your positions” function isn’t really possible because they may be computed on the fly rather than stored as samples.

That being said, you can do this now with TimeIntervalCollectionPositionProperty and ConstantPositionProperty. What’s missing is SampledPositionProperty, which has been on the to-do for a while. The main problem for sampled positions is that they are not stored as Cartesian3 instances (both for performance and memory reasons) and are instead stored in packed arrays parallel with time, this means they need to be unpacked in order to return them to the user.

Here’s a work around that reaches into the internals of SampledPositionProperty to get you an array of samples. You should be able to tweak this to fit your needs.

function getPositionSamples(property) {

if (!(property instanceof Cesium.SampledPositionProperty)) {

return undefined;

}

var result = ;

property = property._property;

var times = property._times;

var values = property._values;

for (var i = 0; i < times.length; i++) {

result.push({

time : times[i],

value : Cesium.Cartesian3.unpack(values, i * 3)

});

}

return result;

}

I definitely want to expose something like the above as part of the public API some time in the near future, but I would like to do it in a way that makes it generic so that you don’t necessarily need to know what type of property you are dealing with to do it.

That works perfectly, thank you! I had a feeling everything was going to be stored in some compressed way, but I’m glad there’s a way to get it all back out. Since this is reaching into the internals of Cesium a bit, is there a possibility this could be broken in some future release? I’ll be sure to keep an eye out for a public release of something of this kind as well.

Sorry, I meant to mention that. Yes, it could break in a future release; but it’s extremely unlikely to change anytime soon (and almost certainly not before a public API is added to get the data officially).