Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-04-14 18:10:00
  4. */
  5. import { Cesium } from '@dc-modules/namespace'
  6. import State from '@dc-modules/state/State'
  7. import Parse from '@dc-modules/parse/Parse'
  8. import { Util } from '@dc-modules/utils'
  9. import { Transform } from '@dc-modules/transform'
  10. import Overlay from '../Overlay'
  11. class Cylinder extends Overlay {
  12. constructor(position, length, topRadius, bottomRadius) {
  13. super()
  14. this._position = Parse.parsePosition(position)
  15. this._length = +length || 0
  16. this._topRadius = +topRadius || 0
  17. this._bottomRadius = +bottomRadius || 0
  18. this._delegate = new Cesium.Entity({ cylinder: {} })
  19. this._state = State.INITIALIZED
  20. }
  21. get type() {
  22. return Overlay.getOverlayType('cylinder')
  23. }
  24. set position(position) {
  25. this._position = Parse.parsePosition(position)
  26. this._delegate.position = Transform.transformWGS84ToCartesian(
  27. this._position
  28. )
  29. this._delegate.orientation = Cesium.Transforms.headingPitchRollQuaternion(
  30. Transform.transformWGS84ToCartesian(this._position),
  31. new Cesium.HeadingPitchRoll(
  32. Cesium.Math.toRadians(this._position.heading),
  33. Cesium.Math.toRadians(this._position.pitch),
  34. Cesium.Math.toRadians(this._position.roll)
  35. )
  36. )
  37. return this
  38. }
  39. get position() {
  40. return this._position
  41. }
  42. set length(length) {
  43. this._length = +length || 0
  44. this._delegate.cylinder.length = this._length
  45. return this
  46. }
  47. get length() {
  48. return this._length
  49. }
  50. set topRadius(topRadius) {
  51. this._topRadius = +topRadius || 0
  52. this._delegate.cylinder.topRadius = this._topRadius
  53. return this
  54. }
  55. get topRadius() {
  56. return this._topRadius
  57. }
  58. set bottomRadius(bottomRadius) {
  59. this._bottomRadius = +bottomRadius || 0
  60. this._delegate.cylinder.bottomRadius = this._bottomRadius
  61. return this
  62. }
  63. get bottomRadius() {
  64. return this._bottomRadius
  65. }
  66. _mountedHook() {
  67. /**
  68. * set the location
  69. */
  70. this.position = this._position
  71. /**
  72. * initialize the Overlay parameter
  73. */
  74. this.length = this._length
  75. this.topRadius = this._topRadius
  76. this.bottomRadius = this._bottomRadius
  77. }
  78. /**
  79. *
  80. * @param {*} text
  81. * @param {*} textStyle
  82. */
  83. setLabel(text, textStyle) {
  84. return this
  85. }
  86. /**
  87. * Sets Style
  88. * @param style
  89. * @returns {Cylinder}
  90. */
  91. setStyle(style) {
  92. if (Object.keys(style).length === 0) {
  93. return this
  94. }
  95. delete style['length'] &&
  96. delete style['topRadius'] &&
  97. delete style['bottomRadius']
  98. Util.merge(this._style, style)
  99. Util.merge(this._delegate.cylinder, style)
  100. return this
  101. }
  102. }
  103. Overlay.registerType('cylinder')
  104. export default Cylinder