您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Ellipsoid.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-04-14 18:20:23
  4. */
  5. import State from '@dc-modules/state/State'
  6. import Parse from '@dc-modules/parse/Parse'
  7. import { Util } from '@dc-modules/utils'
  8. import { Transform } from '@dc-modules/transform'
  9. import Overlay from '../Overlay'
  10. const { Cesium } = DC.Namespace
  11. class Ellipsoid extends Overlay {
  12. constructor(position, radius) {
  13. super()
  14. this._position = Parse.parsePosition(position)
  15. this._radius = radius || { x: 10, y: 10, z: 10 }
  16. this._delegate = new Cesium.Entity({ ellipsoid: {} })
  17. this.type = Overlay.getOverlayType('ellipsoid')
  18. this._state = State.INITIALIZED
  19. }
  20. set position(position) {
  21. this._position = Parse.parsePosition(position)
  22. this._delegate.position = Transform.transformWGS84ToCartesian(
  23. this._position
  24. )
  25. this._delegate.orientation = Cesium.Transforms.headingPitchRollQuaternion(
  26. Transform.transformWGS84ToCartesian(this._position),
  27. new Cesium.HeadingPitchRoll(
  28. Cesium.Math.toRadians(this._position.heading),
  29. Cesium.Math.toRadians(this._position.pitch),
  30. Cesium.Math.toRadians(this._position.roll)
  31. )
  32. )
  33. return this
  34. }
  35. get position() {
  36. return this._position
  37. }
  38. set radius(radius) {
  39. this._radius = radius || { x: 10, y: 10, z: 10 }
  40. this._delegate.ellipsoid.radii = this._radius
  41. return this
  42. }
  43. get radius() {
  44. return this._radius
  45. }
  46. _mountedHook() {
  47. /**
  48. * set the location
  49. */
  50. this.position = this._position
  51. /**
  52. * initialize the Overlay parameter
  53. */
  54. this.radius = this._radius
  55. }
  56. /**
  57. * Sets Style
  58. * @param style
  59. * @returns {Ellipsoid}
  60. */
  61. setStyle(style) {
  62. if (Object.keys(style).length === 0) {
  63. return this
  64. }
  65. delete style['radius']
  66. this._style = style
  67. Util.merge(this._delegate.ellipsoid, this._style)
  68. return this
  69. }
  70. }
  71. Overlay.registerType('ellipsoid')
  72. export default Ellipsoid