Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Ellipse.js 2.3KB

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