| * @Date: 2020-01-03 12:18:17 | * @Date: 2020-01-03 12:18:17 | ||||
| */ | */ | ||||
| import { Cesium } from '@dc-modules/namespace' | |||||
| import State from '@dc-modules/state/State' | import State from '@dc-modules/state/State' | ||||
| import { Util } from '@dc-modules/utils' | import { Util } from '@dc-modules/utils' | ||||
| import { OverlayEventType, OverlayEvent } from '@dc-modules/event' | import { OverlayEventType, OverlayEvent } from '@dc-modules/event' | ||||
| this._layer.delegate.entities.add(this._delegate) | this._layer.delegate.entities.add(this._delegate) | ||||
| } else if (this._layer?.delegate?.add && this._delegate) { | } else if (this._layer?.delegate?.add && this._delegate) { | ||||
| // for Primitive | // for Primitive | ||||
| this._layer.delegate.add(this._delegate) | |||||
| if (this.type === 'point_primitive' && this._layer.points) { | |||||
| this._delegate = this._layer.points.add(this._delegate) | |||||
| } else if ( | |||||
| this.type === 'billboard_primitive' && | |||||
| this._layer.billboards | |||||
| ) { | |||||
| this._delegate = this._layer.billboards.add(this._delegate) | |||||
| } else if (this.type === 'polyline_primitive' && this._layer.polylines) { | |||||
| this._delegate = this._layer.polylines.add(this._delegate) | |||||
| } else if (this.type === 'label_primitive' && this._layer.labels) { | |||||
| this._delegate = this._layer.labels.add(this._delegate) | |||||
| } else { | |||||
| this._layer.delegate.remove(this._delegate) | |||||
| } | |||||
| } | } | ||||
| this._addedHook && this._addedHook() | this._addedHook && this._addedHook() | ||||
| this._state = State.ADDED | this._state = State.ADDED | ||||
| this._layer.delegate.entities.remove(this._delegate) | this._layer.delegate.entities.remove(this._delegate) | ||||
| } else if (this._layer?.delegate?.remove) { | } else if (this._layer?.delegate?.remove) { | ||||
| // for Primitive | // for Primitive | ||||
| this._layer.delegate.remove(this._delegate) | |||||
| if (this.type === 'point_primitive' && this._layer.points) { | |||||
| this._layer.points.remove(this._delegate) | |||||
| } else if ( | |||||
| this.type === 'billboard_primitive' && | |||||
| this._layer.billboards | |||||
| ) { | |||||
| this._layer.billboards.remove(this._delegate) | |||||
| } else if (this.type === 'polyline_primitive' && this._layer.polylines) { | |||||
| this._layer.polylines.remove(this._delegate) | |||||
| } else if (this.type === 'label_primitive' && this._layer.labels) { | |||||
| this._layer.labels.remove(this._delegate) | |||||
| } else { | |||||
| this._layer.delegate.remove(this._delegate) | |||||
| } | |||||
| } | } | ||||
| this._removedHook && this._removedHook() | this._removedHook && this._removedHook() | ||||
| this._state = State.REMOVED | this._state = State.REMOVED | ||||
| * @returns {Overlay} | * @returns {Overlay} | ||||
| */ | */ | ||||
| setLabel(text, textStyle) { | setLabel(text, textStyle) { | ||||
| this._delegate && | |||||
| (this._delegate.label = { | |||||
| if (!this._delegate) { | |||||
| return this | |||||
| } | |||||
| if (this._delegate instanceof Cesium.Entity) { | |||||
| this._delegate.label = { | |||||
| ...textStyle, | ...textStyle, | ||||
| text: text | text: text | ||||
| }) | |||||
| } | |||||
| } | |||||
| return this | return this | ||||
| } | } | ||||
| /** | /** | ||||
| * primitive | * primitive | ||||
| */ | */ | ||||
| export { default as BillboardPrimitive } from './primitive/BillboardPrimitive.js' | |||||
| export { default as ElecEllipsoidPrimitive } from './primitive/ElecEllipsoidPrimitive' | export { default as ElecEllipsoidPrimitive } from './primitive/ElecEllipsoidPrimitive' | ||||
| export { default as FlowLinePrimitive } from './primitive/FlowLinePrimitive' | export { default as FlowLinePrimitive } from './primitive/FlowLinePrimitive' | ||||
| export { default as LabelPrimitive } from './primitive/LabelPrimitive' | |||||
| export { default as ModelPrimitive } from './primitive/ModelPrimitive' | export { default as ModelPrimitive } from './primitive/ModelPrimitive' | ||||
| export { default as PointPrimitive } from './primitive/PointPrimitive.js' | |||||
| export { default as PolylinePrimitive } from './primitive/PolylinePrimitive.js' | |||||
| export { default as ScanCirclePrimitive } from './primitive/ScanCirclePrimitive' | export { default as ScanCirclePrimitive } from './primitive/ScanCirclePrimitive' | ||||
| export { default as TrailLinePrimitive } from './primitive/TrailLinePrimitive' | export { default as TrailLinePrimitive } from './primitive/TrailLinePrimitive' | ||||
| export { default as VideoPrimitive } from './primitive/VideoPrimitive' | export { default as VideoPrimitive } from './primitive/VideoPrimitive' |
| /** | |||||
| * @Author: Caven | |||||
| * @Date: 2021-06-03 21:06:17 | |||||
| */ | |||||
| import State from '@dc-modules/state/State' | |||||
| import Parse from '@dc-modules/parse/Parse' | |||||
| import { Util } from '@dc-modules/utils' | |||||
| import { Transform } from '@dc-modules/transform' | |||||
| import Overlay from '../Overlay' | |||||
| class BillboardPrimitive extends Overlay { | |||||
| constructor(position, icon) { | |||||
| super() | |||||
| this._position = Parse.parsePosition(position) | |||||
| this._icon = icon | |||||
| this._size = [32, 32] | |||||
| this._delegate = { | |||||
| position: undefined, | |||||
| image: undefined, | |||||
| width: 0, | |||||
| height: 0 | |||||
| } | |||||
| this.type = Overlay.getOverlayType('billboard_primitive') | |||||
| this._state = State.INITIALIZED | |||||
| } | |||||
| set position(position) { | |||||
| this._position = Parse.parsePosition(position) | |||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | |||||
| this._position | |||||
| ) | |||||
| return this | |||||
| } | |||||
| get position() { | |||||
| return this._position | |||||
| } | |||||
| set icon(icon) { | |||||
| this._icon = icon | |||||
| this._delegate.image = this._icon | |||||
| return this | |||||
| } | |||||
| get icon() { | |||||
| return this._icon | |||||
| } | |||||
| set size(size) { | |||||
| if (!Array.isArray(size)) { | |||||
| throw new Error('Billboard Primitive: the size invalid') | |||||
| } | |||||
| this._size = size | |||||
| this._delegate.width = this._size[0] || 32 | |||||
| this._delegate.height = this._size[1] || 32 | |||||
| return this | |||||
| } | |||||
| get size() { | |||||
| return this._size | |||||
| } | |||||
| _mountedHook() { | |||||
| /** | |||||
| * set the location | |||||
| */ | |||||
| this.position = this._position | |||||
| /** | |||||
| * initialize the Overlay parameter | |||||
| */ | |||||
| this.icon = this._icon | |||||
| this.size = this._size | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param style | |||||
| * @returns {BillboardPrimitive} | |||||
| */ | |||||
| setStyle(style) { | |||||
| if (!style || Object.keys(style).length === 0) { | |||||
| return this | |||||
| } | |||||
| delete style['position'] && | |||||
| delete style['image'] && | |||||
| delete style['width'] && | |||||
| delete style['height'] | |||||
| this._style = style | |||||
| Util.merge(this._delegate, this._style) | |||||
| return this | |||||
| } | |||||
| } | |||||
| Overlay.registerType('billboard_primitive') | |||||
| export default BillboardPrimitive |
| !this._delegate.appearance && this._setAppearance() | !this._delegate.appearance && this._setAppearance() | ||||
| } | } | ||||
| /** | |||||
| * | |||||
| * @param text | |||||
| * @param textStyle | |||||
| * @returns {ElecEllipsoidPrimitive} | |||||
| */ | |||||
| setLabel(text, textStyle) { | |||||
| return this | |||||
| } | |||||
| /** | /** | ||||
| * Sets Style | * Sets Style | ||||
| * @param style | * @param style | ||||
| } | } | ||||
| } | } | ||||
| Overlay.registerType('elec_ellipsoid_primitive') | |||||
| export default ElecEllipsoidPrimitive | export default ElecEllipsoidPrimitive |
| !this._delegate.appearance && this._setAppearance() | !this._delegate.appearance && this._setAppearance() | ||||
| } | } | ||||
| /** | |||||
| * | |||||
| * @param text | |||||
| * @param textStyle | |||||
| * @returns {FlowLinePrimitive} | |||||
| */ | |||||
| setLabel(text, textStyle) { | |||||
| return this | |||||
| } | |||||
| /** | /** | ||||
| * Sets Style | * Sets Style | ||||
| * @param style | * @param style |
| /** | |||||
| * @Author: Caven | |||||
| * @Date: 2021-06-03 22:28:49 | |||||
| */ | |||||
| import State from '@dc-modules/state/State' | |||||
| import Parse from '@dc-modules/parse/Parse' | |||||
| import { Util } from '@dc-modules/utils' | |||||
| import { Transform } from '@dc-modules/transform' | |||||
| import Overlay from '../Overlay' | |||||
| class LabelPrimitive extends Overlay { | |||||
| constructor(position, text) { | |||||
| super() | |||||
| this._position = Parse.parsePosition(position) | |||||
| this._text = text | |||||
| this._delegate = { | |||||
| position: undefined, | |||||
| text: undefined | |||||
| } | |||||
| this.type = Overlay.getOverlayType('label_primitive') | |||||
| this._state = State.INITIALIZED | |||||
| } | |||||
| set position(position) { | |||||
| this._position = Parse.parsePosition(position) | |||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | |||||
| this._position | |||||
| ) | |||||
| return this | |||||
| } | |||||
| get position() { | |||||
| return this._position | |||||
| } | |||||
| set text(text) { | |||||
| this._text = text | |||||
| this._delegate.text = this._text | |||||
| return this | |||||
| } | |||||
| get text() { | |||||
| return this._text | |||||
| } | |||||
| _mountedHook() { | |||||
| /** | |||||
| * set the location | |||||
| */ | |||||
| this.position = this._position | |||||
| /** | |||||
| * initialize the Overlay parameter | |||||
| */ | |||||
| this.text = this._text | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param {*} text | |||||
| * @param {*} textStyle | |||||
| */ | |||||
| setLabel(text, textStyle) { | |||||
| return this | |||||
| } | |||||
| /** | |||||
| * Sets Style | |||||
| * @param style | |||||
| * @returns {LabelPrimitive} | |||||
| */ | |||||
| setStyle(style) { | |||||
| if (!style || Object.keys(style).length === 0) { | |||||
| return this | |||||
| } | |||||
| delete style['position'] && delete style['text'] | |||||
| this._style = style | |||||
| Util.merge(this._delegate, this._style) | |||||
| return this | |||||
| } | |||||
| } | |||||
| Overlay.registerType('label_primitive') | |||||
| export default LabelPrimitive |
| /** | |||||
| * @Author: Caven | |||||
| * @Date: 2021-06-03 20:51:25 | |||||
| */ | |||||
| import { Cesium } from '@dc-modules/namespace' | |||||
| import State from '@dc-modules/state/State' | |||||
| import Parse from '@dc-modules/parse/Parse' | |||||
| import { Util } from '@dc-modules/utils' | |||||
| import { Transform } from '@dc-modules/transform' | |||||
| import Overlay from '../Overlay' | |||||
| const DEF_STYLE = { | |||||
| pixelSize: 8, | |||||
| outlineColor: Cesium.Color.BLUE, | |||||
| outlineWidth: 2 | |||||
| } | |||||
| class PointPrimitive extends Overlay { | |||||
| constructor(position) { | |||||
| super() | |||||
| this._position = Parse.parsePosition(position) | |||||
| this.type = Overlay.getOverlayType('point_primitive') | |||||
| this._delegate = { | |||||
| position: undefined | |||||
| } | |||||
| this._state = State.INITIALIZED | |||||
| } | |||||
| set position(position) { | |||||
| this._position = Parse.parsePosition(position) | |||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | |||||
| this._position | |||||
| ) | |||||
| return this | |||||
| } | |||||
| get position() { | |||||
| return this._position | |||||
| } | |||||
| _mountedHook() { | |||||
| /** | |||||
| * set the location | |||||
| */ | |||||
| this.position = this._position | |||||
| /** | |||||
| * initialize the Overlay parameter | |||||
| */ | |||||
| Util.merge(this._delegate, DEF_STYLE, this._style) | |||||
| } | |||||
| /** | |||||
| * Set style | |||||
| * @param style | |||||
| * @returns {PointPrimitive} | |||||
| */ | |||||
| setStyle(style) { | |||||
| if (!style || Object.keys(style).length === 0) { | |||||
| return this | |||||
| } | |||||
| delete style['position'] | |||||
| this._style = style | |||||
| Util.merge(this._delegate, DEF_STYLE, this._style) | |||||
| return this | |||||
| } | |||||
| } | |||||
| Overlay.registerType('point_primitive') | |||||
| export default PointPrimitive |
| /** | |||||
| * @Author: Caven | |||||
| * @Date: 2021-06-03 21:16:27 | |||||
| */ | |||||
| import State from '@dc-modules/state/State' | |||||
| import Parse from '@dc-modules/parse/Parse' | |||||
| import { Util } from '@dc-modules/utils' | |||||
| import { Transform } from '@dc-modules/transform' | |||||
| import { center, distance } from '@dc-modules/math' | |||||
| import Overlay from '../Overlay' | |||||
| class PolylinePrimitive extends Overlay { | |||||
| constructor(positions) { | |||||
| super() | |||||
| this._positions = Parse.parsePositions(positions) | |||||
| this._delegate = { | |||||
| positions: [] | |||||
| } | |||||
| this.type = Overlay.getOverlayType('polyline_primitive') | |||||
| this._state = State.INITIALIZED | |||||
| } | |||||
| set positions(positions) { | |||||
| this._positions = Parse.parsePositions(positions) | |||||
| this._delegate.positions = Transform.transformWGS84ArrayToCartesianArray( | |||||
| this._positions | |||||
| ) | |||||
| return this | |||||
| } | |||||
| get positions() { | |||||
| return this._positions | |||||
| } | |||||
| get center() { | |||||
| return center(this._positions) | |||||
| } | |||||
| get distance() { | |||||
| return distance(this._positions) | |||||
| } | |||||
| _mountedHook() { | |||||
| /** | |||||
| * initialize the Overlay parameter | |||||
| */ | |||||
| this.positions = this._positions | |||||
| } | |||||
| /** | |||||
| * Sets style | |||||
| * @param style | |||||
| * @returns {PolylinePrimitive} | |||||
| */ | |||||
| setStyle(style) { | |||||
| if (!style || Object.keys(style).length === 0) { | |||||
| return this | |||||
| } | |||||
| delete style['positions'] | |||||
| this._style = style | |||||
| Util.merge(this._delegate, this._style) | |||||
| return this | |||||
| } | |||||
| } | |||||
| Overlay.registerType('polyline_primitive') | |||||
| export default PolylinePrimitive |
| import DC from '../base/index' | |||||
| /** | /** | ||||
| * @Author: Caven | * @Author: Caven | ||||
| * @Date: 2021-03-13 13:15:38 | * @Date: 2021-03-13 13:15:38 |
| FineArrow, | FineArrow, | ||||
| GatheringPlace, | GatheringPlace, | ||||
| TailedAttackArrow, | TailedAttackArrow, | ||||
| BillboardPrimitive, | |||||
| ElecEllipsoidPrimitive, | ElecEllipsoidPrimitive, | ||||
| FlowLinePrimitive, | FlowLinePrimitive, | ||||
| LabelPrimitive, | |||||
| ModelPrimitive, | ModelPrimitive, | ||||
| PointPrimitive, | |||||
| PolylinePrimitive, | |||||
| ScanCirclePrimitive, | ScanCirclePrimitive, | ||||
| TrailLinePrimitive, | TrailLinePrimitive, | ||||
| VideoPrimitive, | VideoPrimitive, | ||||
| FineArrow, | FineArrow, | ||||
| GatheringPlace, | GatheringPlace, | ||||
| TailedAttackArrow, | TailedAttackArrow, | ||||
| BillboardPrimitive, | |||||
| ElecEllipsoidPrimitive, | ElecEllipsoidPrimitive, | ||||
| FlowLinePrimitive, | FlowLinePrimitive, | ||||
| LabelPrimitive, | |||||
| ModelPrimitive, | ModelPrimitive, | ||||
| PointPrimitive, | |||||
| PolylinePrimitive, | |||||
| ScanCirclePrimitive, | ScanCirclePrimitive, | ||||
| TrailLinePrimitive, | TrailLinePrimitive, | ||||
| VideoPrimitive, | VideoPrimitive, |