| File was renamed from applications/drone-command/src/views/areaManage/partition/shapeTools/edit/EditBufferCircleTool.js |
| | |
| | | lat: point.lat ?? point.latitude, |
| | | })) |
| | | |
| | | const resolveLngLat = point => { |
| | | if (!point) return null |
| | | const lng = point.lng ?? point.longitude |
| | | const lat = point.lat ?? point.latitude |
| | | if (Number.isFinite(lng) && Number.isFinite(lat)) { |
| | | return { lng: Number(lng), lat: Number(lat), height: Number(point.height) || 0 } |
| | | } |
| | | return null |
| | | } |
| | | |
| | | const resolveCartesian = point => { |
| | | if (!point) return null |
| | | if (Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z)) { |
| | | return new Cesium.Cartesian3(point.x, point.y, point.z) |
| | | } |
| | | const lngLat = resolveLngLat(point) |
| | | if (!lngLat) return null |
| | | return Cesium.Cartesian3.fromDegrees(lngLat.lng, lngLat.lat, lngLat.height || 0) |
| | | } |
| | | |
| | | export class EditBufferCircleTool extends ToolBase { |
| | | constructor(viewer) { |
| | | super(viewer) |
| | |
| | | start(data = []) { |
| | | const inputPoints = Array.isArray(data?.points) ? data.points : data |
| | | const normalized = normalizePoints(inputPoints) |
| | | const metaCenter = resolveCartesian(data?.meta?.center) |
| | | if (metaCenter) { |
| | | this.centerCartesian = metaCenter |
| | | } else { |
| | | if (!normalized.length) return |
| | | const centerLng = normalized.reduce((sum, p) => sum + p.lng, 0) / normalized.length |
| | | const centerLat = normalized.reduce((sum, p) => sum + p.lat, 0) / normalized.length |
| | | this.centerCartesian = Cesium.Cartesian3.fromDegrees(centerLng, centerLat) |
| | | } |
| | | const radii = Array.isArray(data?.meta?.bufferRadii) ? data.meta.bufferRadii : null |
| | | if (radii?.length) { |
| | | const [r1, r2, r3] = radii |
| | |
| | | meta: { |
| | | center: this.centerCartesian, |
| | | bufferRadii: [this.radiusLevel1, this.radiusLevel2, this.radiusLevel3], |
| | | controlPoints: [ |
| | | this.centerCartesian, |
| | | this.getRadiusPoint(this.radiusLevel1), |
| | | this.getRadiusPoint(this.radiusLevel2), |
| | | this.getRadiusPoint(this.radiusLevel3), |
| | | ], |
| | | }, |
| | | }) |
| | | } |
| | |
| | | meta: { |
| | | center: this.centerCartesian, |
| | | bufferRadii: [this.radiusLevel1, this.radiusLevel2, this.radiusLevel3], |
| | | controlPoints: [ |
| | | this.centerCartesian, |
| | | this.getRadiusPoint(this.radiusLevel1), |
| | | this.getRadiusPoint(this.radiusLevel2), |
| | | this.getRadiusPoint(this.radiusLevel3), |
| | | ], |
| | | }, |
| | | } |
| | | } |