Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. * @Author: Caven
  3. * @Date: 2021-07-11 09:56:33
  4. */
  5. import { Cesium } from '@dc-modules/namespace'
  6. import Angle from './type/Angle'
  7. import Area from './type/Area'
  8. import AreaHeight from './type/AreaHeight'
  9. import AreaSurface from './type/AreaSurface'
  10. import Distance from './type/Distance'
  11. import DistanceSurface from './type/DistanceSurface'
  12. import Heading from './type/Heading'
  13. import Height from './type/Height'
  14. import TriangleHeight from './type/TriangleHeight'
  15. import MeasureType from './MeasureType'
  16. class Measure {
  17. constructor() {
  18. this._viewer = undefined
  19. this._layer = new Cesium.CustomDataSource('measure-layer')
  20. }
  21. get viewer() {
  22. return this._viewer
  23. }
  24. get layer() {
  25. return this._layer
  26. }
  27. /**
  28. *
  29. * @param options
  30. * @returns {Measure}
  31. */
  32. angle(options = {}) {
  33. new Angle().start(this, options)
  34. return this
  35. }
  36. /**
  37. *
  38. * @param options
  39. * @returns {Measure}
  40. */
  41. area(options = {}) {
  42. new Area().start(this, options)
  43. return this
  44. }
  45. /**
  46. *
  47. * @param options
  48. * @returns {Measure}
  49. */
  50. areaHeight(options = {}) {
  51. new AreaHeight().start(this, options)
  52. return this
  53. }
  54. /**
  55. *
  56. * @param options
  57. * @returns {Measure}
  58. */
  59. areaSurface(options = {}) {
  60. new AreaSurface().start(this, options)
  61. return this
  62. }
  63. /**
  64. *
  65. * @param options
  66. * @returns {Measure}
  67. */
  68. distance(options = {}) {
  69. new Distance().start(this, options)
  70. return this
  71. }
  72. /**
  73. *
  74. * @param options
  75. * @returns {Measure}
  76. */
  77. distanceSurface(options = {}) {
  78. new DistanceSurface().start(this, options)
  79. return this
  80. }
  81. /**
  82. *
  83. * @param options
  84. * @returns {Measure}
  85. */
  86. heading(options = {}) {
  87. new Heading().start(this, options)
  88. return this
  89. }
  90. /**
  91. *
  92. * @param options
  93. * @returns {Measure}
  94. */
  95. height(options = {}) {
  96. new Height().start(this, options)
  97. return this
  98. }
  99. /**
  100. *
  101. * @param options
  102. * @returns {Measure}
  103. */
  104. triangleHeight(options = {}) {
  105. new TriangleHeight().start(this, options)
  106. return this
  107. }
  108. /**
  109. *
  110. * @param viewer
  111. */
  112. install(viewer) {
  113. this._viewer = viewer
  114. this._viewer.dataSources.add(this._layer)
  115. Object.defineProperty(viewer, 'measure', {
  116. value: this,
  117. writable: false
  118. })
  119. }
  120. /**
  121. *
  122. * @param type
  123. * @param options
  124. * @returns {Measure}
  125. */
  126. activate(type, options) {
  127. switch (type) {
  128. case MeasureType.ANGLE:
  129. this.angle(options)
  130. break
  131. case MeasureType.AREA:
  132. this.area(options)
  133. break
  134. case MeasureType.AREA_HEIGHT:
  135. this.areaHeight(options)
  136. break
  137. case MeasureType.AREA_SURFACE:
  138. this.areaSurface(options)
  139. break
  140. case MeasureType.DISTANCE:
  141. this.distance(options)
  142. break
  143. case MeasureType.DISTANCE_SURFACE:
  144. this.distanceSurface(options)
  145. break
  146. case MeasureType.HEADING:
  147. this.heading(options)
  148. break
  149. case MeasureType.HEIGHT:
  150. this.height(options)
  151. break
  152. case MeasureType.TRIANGLE_HEIGHT:
  153. this.triangleHeight(options)
  154. break
  155. default:
  156. break
  157. }
  158. return this
  159. }
  160. /**
  161. *
  162. * @returns {Measure}
  163. */
  164. deactivate() {
  165. this._layer.entities.removeAll()
  166. this._viewer.drawTool.tooltipMess = ''
  167. this._viewer.drawTool.deactivate()
  168. this._viewer.editTool.tooltipMess = ''
  169. this._viewer.editTool.deactivate()
  170. return this
  171. }
  172. }
  173. export default Measure