您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Corridor.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-04-11 18:58:17
  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 Corridor extends Overlay {
  12. constructor(positions) {
  13. super()
  14. this._positions = Parse.parsePositions(positions)
  15. this._delegate = new Cesium.Entity({ corridor: {} })
  16. this.type = Overlay.getOverlayType('corridor')
  17. this._state = State.INITIALIZED
  18. }
  19. set positions(positions) {
  20. this._positions = Parse.parsePositions(positions)
  21. this._delegate.corridor.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. */
  40. setLabel(text, textStyle) {
  41. return this
  42. }
  43. /**
  44. * Sets Style
  45. * @param style
  46. * @returns {Corridor}
  47. */
  48. setStyle(style) {
  49. if (Object.keys(style).length === 0) {
  50. return this
  51. }
  52. delete style['positions']
  53. this._style = style
  54. Util.merge(this._delegate.corridor, this._style)
  55. return this
  56. }
  57. /**
  58. * Parses from entity
  59. * @param entity
  60. * @returns {Corridor|any}
  61. */
  62. static fromEntity(entity) {
  63. let corridor = undefined
  64. let now = Cesium.JulianDate.now()
  65. if (entity.polyline) {
  66. let positions = Transform.transformCartesianArrayToWGS84Array(
  67. entity.polyline.positions.getValue(now)
  68. )
  69. corridor = new Corridor(positions)
  70. corridor.attr = {
  71. ...entity?.properties?.getValue(now)
  72. }
  73. }
  74. return corridor
  75. }
  76. }
  77. Overlay.registerType('corridor')
  78. export default Corridor