Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Ellipse.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-04-14 18:30:45
  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 Ellipse extends Overlay {
  12. constructor(position, semiMajorAxis, semiMinorAxis) {
  13. super()
  14. this._position = Parse.parsePosition(position)
  15. this._semiMajorAxis = +semiMajorAxis || 0
  16. this._semiMinorAxis = +semiMinorAxis || 0
  17. this._delegate = new Cesium.Entity({ ellipse: {} })
  18. this._state = State.INITIALIZED
  19. }
  20. get type() {
  21. return Overlay.getOverlayType('ellipse')
  22. }
  23. set position(position) {
  24. this._position = Parse.parsePosition(position)
  25. this._delegate.position = Transform.transformWGS84ToCartesian(
  26. this._position
  27. )
  28. this._delegate.orientation = Cesium.Transforms.headingPitchRollQuaternion(
  29. Transform.transformWGS84ToCartesian(this._position),
  30. new Cesium.HeadingPitchRoll(
  31. Cesium.Math.toRadians(this._position.heading),
  32. Cesium.Math.toRadians(this._position.pitch),
  33. Cesium.Math.toRadians(this._position.roll)
  34. )
  35. )
  36. return this
  37. }
  38. get position() {
  39. return this._position
  40. }
  41. set semiMajorAxis(semiMajorAxis) {
  42. this._semiMajorAxis = +semiMajorAxis || 0
  43. this._delegate.ellipse.semiMajorAxis = this._semiMajorAxis
  44. return this
  45. }
  46. get semiMajorAxis() {
  47. return this._semiMajorAxis
  48. }
  49. set semiMinorAxis(semiMinorAxis) {
  50. this._semiMinorAxis = +semiMinorAxis || 0
  51. this._delegate.ellipse.semiMinorAxis = this._semiMinorAxis
  52. return this
  53. }
  54. get semiMinorAxis() {
  55. return this._semiMinorAxis
  56. }
  57. _mountedHook() {
  58. /**
  59. * set the location
  60. */
  61. this.position = this._position
  62. /**
  63. * initialize the Overlay parameter
  64. */
  65. this.semiMajorAxis = this._semiMajorAxis
  66. this.semiMinorAxis = this._semiMinorAxis
  67. }
  68. /**
  69. * Sets Style
  70. * @param style
  71. * @returns {Ellipse}
  72. */
  73. setStyle(style) {
  74. if (Object.keys(style).length === 0) {
  75. return this
  76. }
  77. delete style['semiMajorAxis'] && delete style['semiMinorAxis']
  78. Util.merge(this._style, style)
  79. Util.merge(this._delegate.ellipse, style)
  80. return this
  81. }
  82. }
  83. Overlay.registerType('ellipse')
  84. export default Ellipse