You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Wall.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * @Author : Caven Chen
  3. */
  4. import { Cesium } from '../../../namespace'
  5. import State from '../../state/State'
  6. import Parse from '../../parse/Parse'
  7. import { Util } from '../../utils'
  8. import { Transform } from '../../transform'
  9. import Overlay from '../Overlay'
  10. class Wall extends Overlay {
  11. constructor(positions) {
  12. super()
  13. this._positions = Parse.parsePositions(positions)
  14. this._delegate = new Cesium.Entity({ wall: {} })
  15. this._state = State.INITIALIZED
  16. }
  17. get type() {
  18. return Overlay.getOverlayType('wall')
  19. }
  20. set positions(positions) {
  21. this._positions = Parse.parsePositions(positions)
  22. this._delegate.wall.positions =
  23. Transform.transformWGS84ArrayToCartesianArray(this._positions)
  24. }
  25. get positions() {
  26. return this._positions
  27. }
  28. _mountedHook() {
  29. /**
  30. * set the location
  31. */
  32. this.positions = this._positions
  33. }
  34. /**
  35. *
  36. * @param text
  37. * @param textStyle
  38. * @returns {Wall}
  39. */
  40. setLabel(text, textStyle) {
  41. return this
  42. }
  43. /**
  44. * Sets Style
  45. * @param style
  46. * @returns {Wall}
  47. */
  48. setStyle(style) {
  49. if (Object.keys(style).length === 0) {
  50. return this
  51. }
  52. delete style['positions']
  53. Util.merge(this._style, style)
  54. Util.merge(this._delegate.wall, style)
  55. return this
  56. }
  57. /**
  58. * Parses from entity
  59. * @param entity
  60. * @returns {Wall|any}
  61. */
  62. static fromEntity(entity) {
  63. let wall = undefined
  64. let now = Cesium.JulianDate.now()
  65. if (entity.polyline) {
  66. let positions = Transform.transformCartesianArrayToWGS84Array(
  67. entity.polyline.positions.getValue(now)
  68. )
  69. wall = new Wall(positions)
  70. wall.attr = {
  71. ...entity?.properties?.getValue(now),
  72. }
  73. }
  74. return wall
  75. }
  76. }
  77. Overlay.registerType('wall')
  78. export default Wall