| export default function center(positions) { | export default function center(positions) { | ||||
| if (positions && Array.isArray(positions)) { | if (positions && Array.isArray(positions)) { | ||||
| let heightMax = 0 // 位置最高的点的高度 | |||||
| positions.forEach(({ alt }) => (heightMax = Math.max(heightMax, alt))) | |||||
| let boundingSphere = Cesium.BoundingSphere.fromPoints( | let boundingSphere = Cesium.BoundingSphere.fromPoints( | ||||
| Transform.transformWGS84ArrayToCartesianArray(positions) | Transform.transformWGS84ArrayToCartesianArray(positions) | ||||
| ) | ) | ||||
| return Transform.transformCartesianToWGS84(boundingSphere.center) | |||||
| const position = Transform.transformCartesianToWGS84(boundingSphere.center) | |||||
| position.alt = heightMax | |||||
| return position | |||||
| } | } | ||||
| return new Position() | return new Position() |