| | |
| | | import * as Cesium from 'cesium' |
| | | import { MapTooltip } from '@ztzf/utils' |
| | | import { ToolBase } from '../ToolBase' |
| | | import { buildEllipsePositions, cartesianToLocal } from '../shapeUtils' |
| | | import { buildEllipsePositions, cartesianToLocal, formatBufferRadius } from '../shapeUtils' |
| | | |
| | | const normalizePoints = points => |
| | | (points || []).map(point => ({ |
| | |
| | | this.radiusLevel1Entity = null |
| | | this.radiusLevel2Entity = null |
| | | this.radiusLevel3Entity = null |
| | | this.radiusLevel1LabelEntity = null |
| | | this.radiusLevel2LabelEntity = null |
| | | this.radiusLevel3LabelEntity = null |
| | | } |
| | | |
| | | start(data = []) { |
| | |
| | | }, |
| | | customType: 'circle-radius-3', |
| | | }) |
| | | |
| | | this.radiusLevel1LabelEntity = this.createRadiusLabelEntity(() => this.radiusLevel1) |
| | | this.radiusLevel2LabelEntity = this.createRadiusLabelEntity(() => this.radiusLevel2) |
| | | this.radiusLevel3LabelEntity = this.createRadiusLabelEntity(() => this.radiusLevel3) |
| | | } |
| | | |
| | | updateRadiusPoints() { |
| | |
| | | const frame = Cesium.Transforms.eastNorthUpToFixedFrame(this.centerCartesian) |
| | | const local = new Cesium.Cartesian3(radius, 0, 0) |
| | | return Cesium.Matrix4.multiplyByPoint(frame, local, new Cesium.Cartesian3()) |
| | | } |
| | | |
| | | createRadiusLabelEntity(getRadius) { |
| | | return this.dataSource.entities.add({ |
| | | position: new Cesium.CallbackProperty(() => this.getRadiusPoint(getRadius()), false), |
| | | label: { |
| | | text: new Cesium.CallbackProperty(() => formatBufferRadius(getRadius()), false), |
| | | font: '14px Source Han Sans CN', |
| | | fillColor: Cesium.Color.WHITE, |
| | | outlineColor: Cesium.Color.fromBytes(24, 48, 92, 255), |
| | | outlineWidth: 2, |
| | | style: Cesium.LabelStyle.FILL_AND_OUTLINE, |
| | | showBackground: true, |
| | | backgroundColor: Cesium.Color.fromBytes(8, 12, 22, 180), |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER, |
| | | pixelOffset: new Cesium.Cartesian2(0, -12), |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | }, |
| | | }) |
| | | } |
| | | |
| | | getPositionFromScreen(screenPosition) { |
| | |
| | | this.circleLevel1OutlineEntity = null |
| | | this.circleLevel2OutlineEntity = null |
| | | this.circleLevel3OutlineEntity = null |
| | | this.radiusLevel1LabelEntity = null |
| | | this.radiusLevel2LabelEntity = null |
| | | this.radiusLevel3LabelEntity = null |
| | | this.dragType = null |
| | | } |
| | | } |