Degrees from cartesian 3

3,798 views
Skip to first unread message

gianmaria...@gmail.com

unread,
Jan 15, 2016, 4:28:23 AM1/15/16
to cesium-dev
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



nki...@yahoo.co.uk

unread,
Jan 15, 2016, 9:19:52 PM1/15/16
to cesium-dev
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);

Gianmaria Dalla Torre

unread,
Jan 18, 2016, 5:05:34 AM1/18/16
to cesium-dev, nki...@yahoo.co.uk
I thought it was very similar to my own solution instead seems to work very well!

Thanks
Gianmaria
Reply all
Reply to author
Forward
0 new messages