WGS84弧度坐标系转世界坐标
const handelCartographic = ()=>{
const a = new Cesium.Cartesian3.fromDegrees(104.1, 30.6, 200);
console.log("世界坐标",a);
const b = new Cesium.Cartographic.fromDegrees(104.1, 30.6, 200);
console.log("WGS84弧度坐标系",b);
/* 方法一 */
const c = new Cesium.Cartesian3.fromRadians(b.longitude,b.latitude,b.height)
console.log("方法一WGS84弧度坐标系转世界坐标",c);
/* 方法二 */
const ellipsoid = window.viewer.scene.globe.ellipsoid;
const cartesian3 = ellipsoid.cartographicToCartesian(b);
console.log("方法二WGS84弧度坐标系转世界坐标",cartesian3);
// 方法三
const d = new Cesium.Cartographic.toCartesian(b)
console.log('WGS84弧度坐标系转换为世界坐标',d);
}
世界坐标转换为WGS84弧度坐标系
const handelCartographic = ()=>{
const a = new Cesium.Cartesian3.fromDegrees(104.1, 30.6, 200);
console.log("世界坐标",a);
const b = new Cesium.Cartographic.fromDegrees(104.1, 30.6, 200);
console.log("WGS84弧度坐标系",b);
const c = Cesium.Cartographic.fromCartesian(a)
console.log('世界坐标转换为WGS84弧度坐标系',c);
}
世界坐标转换为WGS84经纬度坐标系
const handelCartographic = ()=>{
const ellipsoid = window.viewer.scene.globe.ellipsoid;
const a = new Cesium.Cartesian3.fromDegrees(104.1, 30.6, 200);
console.log("世界坐标",a);
const cartographic = ellipsoid.cartesianToCartographic(a);
console.log(cartographic);
// toDegrees:将弧度转换为度数函数
const lat = Cesium.Math.toDegrees(cartographic.latitude);
const lng = Cesium.Math.toDegrees(cartographic.longitude);
const alt = cartographic.height;
console.log('世界坐标转换为经纬度',lat,lng,alt);
}