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

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