Get latitude and longitude values in HeadingPitchRoll example

Hi,

I saw an example in Cesium tutorial ‘Interpolation’ which is basically a simulation of aircraft.

In addition to it, I want to get the latitude and longitude of aircraft after each second in the Interpolation example. How could I do that? Can anyone please help in it?

Regards,

Yogesh

Hi Yogesh, sorry for the delay in getting back to you on this question. The is straightforward to do, you can get the position of the aircraft at any time you want by calling entity.position.getValue(time), where time is the time you want the position for. This will be returned as a Cartesian3 WGS84 coordinate, which can then be converted to LLA degrees. Here’s a complete example:

var position = entity.position.getValue(time);

var cartographic = Cesium.Cartographic.fromCartesian(position);

var longitude = Cesium.Math.toDegrees(cartographic.longitude);

var latitude = Cesium.Math.toDegrees(cartographic.latitude);

You can call execute the above code in a loop and retrieve a list of positions at one second intervals if that’s what you desire.

Thanks,

Matt