其他分享
首页 > 其他分享> > cesium转换坐标,将没有高度的坐标转换为世界坐标

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,如有侵权,请联系删除。

标签:转换,needxyz,resdata,世界坐标,Cesium,坐标,var,height,updatedPositions
来源: https://www.cnblogs.com/hustshu/p/15640039.html