根据每两个点求出一条边的长度,把所有边长度加和即为多边形周长
const getMarkPerimeter = (pos) => {
let lengthAll = 0;
let posData = deepClone(pos)
posData.push(pos[0])//首尾点连接
let positions = posData.map(item=>item.areaPosition)
for (let i = 0; i < positions.length - 1; i++) {
const point1cartographic = Cesium.Cartographic.fromCartesian(positions[i]);
const point2cartographic = Cesium.Cartographic.fromCartesian(positions[i + 1]);
const geodesic = new Cesium.EllipsoidGeodesic();
geodesic.setEndPoints(point1cartographic, point2cartographic);
let sfd = geodesic.surfaceDistance; // surfaceDistance返回number 单位为m,带小数
sfd = Math.sqrt(Math.pow(sfd, 2) + Math.pow(point2cartographic.height - point1cartographic.height, 2));
// 求和
lengthAll += sfd
}
return lengthAll.toFixed(2)
}