cesium转换坐标,将没有高度的坐标转换为世界坐标

resdata为变量

var terrainProvider = viewer.terrainProvider;
    var psoitions = [];
    for (var i = 0; i < resdata.length; i++) {
        var a = resdata[i];
        psoitions.push(Cesium.Cartographic.fromDegrees(Number(a.lon), Number(a.lat)))
    }
    var promise = Cesium.sampleTerrain(terrainProvider, 11, psoitions);
    var pointY = [];
    Cesium.when(promise, function (updatedPositions) {
        // positions[0].height and positions[1].height have been updated.
        // updatedPositions is just a reference to positions.
        //console.log(updatedPositions)
        for (var i = 0; i < updatedPositions.length; i++) {
            var needxyz = Cesium.Cartesian3.fromRadians(updatedPositions[i].longitude, updatedPositions[i].latitude, updatedPositions[i].height);
            for (var r = 0; r < resdata.length; r++) {
                updatedPositions[i].longitude = needxyz.x;
                updatedPositions[i].latitude = needxyz.y;
                updatedPositions[i].height = needxyz.z;
                updatedPositions[i].numbers = resdata[i].numbers
                updatedPositions[i].title = resdata[i].title
            }
        }
        showPointer(updatedPositions);
    });

本文转自 https://blog.csdn.net/weixin_42476786/article/details/90766017?spm=1001.2014.3001.5501,如有侵权,请联系删除。

上一篇:Cesium横截面


下一篇:czml的模型运动及轨迹实现