Cesium-坐标转换

笛卡尔坐标系转经纬度高程

cartesianTolngLat = (cartesianObj) => {
    if (!Cesium || !window._cesium) {
        throw new Error('非cesium地图')
    }
    if (!cartesianObj || Object.keys(cartesianObj).length !== 3) {
        throw new Error('请传入合法的cartesian对象 {x, y, z}')
    }
    const cartesian3 = new Cesium.Cartesian3(cartesianObj.x, cartesianObj.y, cartesianObj.z);
    const cartographic = window._cesium.scene.globe.ellipsoid.cartesianToCartographic(cartesian3);
    const lat = Cesium.Math.toDegrees(cartographic.latitude);
    const lng = Cesium.Math.toDegrees(cartographic.longitude);
    const alt = cartographic.height;
    return { lng, lat, alt }
}

你可能感兴趣的:(cesium,js,vue,前端,cesium,vue.js)