| | |
| | | } |
| | | |
| | | // 获取当前经纬度海拔 |
| | | export const getHaeHeight = (start: { longitude: number; latitude: number; height: number }, end: { longitude: number; latitude: number; height: number }) => { |
| | | export const getHaeHeight = ( |
| | | start: { longitude: number; latitude: number; height: number }, |
| | | end: { longitude: number; latitude: number; height: number }, |
| | | ) => { |
| | | const ellipsoid = Cesium.Ellipsoid.WGS84 // 选择合适的椭圆体模型 |
| | | // const { longitude, latitude, height } = start |
| | | // const { longitude: endLng, latitude: endLat, height: endHeight } = end |
| | |
| | | const haeHeight = ellipsoid.cartesianToCartographic(cartesianPosition).height |
| | | return haeHeight |
| | | } |
| | | |
| | | // Cesium Cartesian3 转正常经纬度 |
| | | export const cartesian3Convert = (cartesian3Position: Cesium.Cartesian3, viewer: { scene: { globe: { ellipsoid: any } } }) => { |
| | | // 转换为经纬度 |
| | | const ellipsoid = viewer.scene.globe.ellipsoid |
| | | const cartographicPosition = Cesium.Cartographic.fromCartesian(cartesian3Position, ellipsoid) |
| | | const longitude = Cesium.Math.toDegrees(cartographicPosition.longitude) |
| | | const latitude = Cesium.Math.toDegrees(cartographicPosition.latitude) |
| | | const height = cartographicPosition.height |
| | | |
| | | console.log('经度: ' + longitude) |
| | | console.log('纬度: ' + latitude) |
| | | console.log('高度: ' + height) |
| | | |
| | | return { |
| | | longitude, |
| | | latitude, |
| | | height, |
| | | } |
| | | } |