Retrieving data from SampledProperty

Hi,

Please would it be possible to have some advice on retrieving data from a SampledProperty?

First, I’m setting up the clock in the Cesium viewer to cover the period of time in which I am interested:

var start = Cesium.JulianDate.fromIso8601(‘2012-08-04T13:21:40Z’);

var stop = Cesium.JulianDate.fromIso8601(‘2012-08-04T19:08:09Z’);

//Make sure viewer is at the desired time.

viewer.clock.startTime = start.clone();

viewer.clock.stopTime = stop.clone();

viewer.clock.currentTime = start.clone();

viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP; //Loop at the end

viewer.clock.multiplier = 4;

viewer.timeline.zoomTo(start, stop);

``

This function loads two data points into the SampledProperty, with the intention of interpolating between the two extremes:

function paramHdg () {

var propertyx = new Cesium.SampledProperty(Number);

propertyx.addSample(Cesium.JulianDate.fromIso8601(‘2012-08-04T13:21:40Z’), 1.0);

propertyx.addSample(Cesium.JulianDate.fromIso8601(‘2012-08-04T19:08:09Z’), 100.0);

return propertyx;

}

``

The intention of this code is to get back tHdg from the above function and then retrieve an interpolated value (I’ve omitted any ‘vars’ because I was using them as globals during troubleshooting):

var tHdg = paramHdg();

viewer.clock.onTick.addEventListener(function(clock) {

  currentTime = clock.currentTime;

  hg = tHdg.getValue(currentTime);

                                  // Do something with hg

									  }

);

``

What have I missed, included or otherwise turned on its head?!

Thanks,

Hugh

(just starting to get to grips with Cesium)

The code you included looks correct. To get the value of any Property (such as SampledProperty) you call getValue and pass in a time, as you have done. What problem are you seeing?

Hello Scott,

It doesn’t appear to return any data. If I put the same data as the first item of a quartenion and use SampledPositionProperty it works perfectly.

I took the code you pasted above and made a Sandcastle example.

http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=8dea46ae90144f70a0bc807316eca1f1

You can see that the correctly interpolated heading value is logged to the console and the returned value changes as the current time changes.

Thanks, Scott.

I got rid of the function ‘paramHdg’ (left it as a straight list) and it started working. The problem must be somewhere else in the code.

Thanks again,

Hugh