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.

Wall.js 1.8KB

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