Degrees from cartesian 3

Hi,

after loading kml file with some coordinates inside cesium, i notice that cesium makes a conversion of my array of coordinates in degrees into an array of cartesian 3. I need return to an array of degrees through a reverse formula or a method.

At the moment i use 3 conversions with significant rounding error.

My initial coordinates(degrees) inside kml:

Lon: 61.296382224724795

Lat: 35.628536117000692

After conversion of cesium(cartesian 3):

X: 2494939.8298499687

Y: 4552677.081444226

Z: 3692848.606359371

After conversion on cesium by this code(cartographic radiant):

var positions = entity.polygon.hierarchy._value.positions;

var cartographicPositions = Cesium.Ellipsoid.WGS84.cartesianArrayToCartographicArray(positions);

Lon: 1.0694776254979663

Lat: 0.6214636648559897

After conversion on cesium by this code(degrees):

var lonDegree = cartographicPositions[0].longitude * 180 / Math.PI;

var latDegree = cartographicPositions[0].latitude * 180 / Math.PI;

Lon: 61.2765542247063 //after 3 conversion the error is too large

Lat: 35.60724511698087 //after 3 conversion the error is too large

Any idea, method or inverse formula?

Thanks,

Gianmaria

You can try this:

var pos = Cesium.Cartesian3.fromDegrees(61.296382224724795,35.628536117000692);
var carto = Cesium.Ellipsoid.WGS84.cartesianToCartographic(pos);
var lon = Cesium.Math.toDegrees(carto.longitude);
var lat = Cesium.Math.toDegrees(carto.latitude);

1 Like

I thought it was very similar to my own solution instead seems to work very well!

Thanks

Gianmaria