| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- /**
- * @Author: Caven
- * @Date: 2021-07-11 09:56:33
- */
-
- import { Cesium } from '@dc-modules/namespace'
- import Angle from './type/Angle'
- import Area from './type/Area'
- import AreaHeight from './type/AreaHeight'
- import AreaSurface from './type/AreaSurface'
- import Distance from './type/Distance'
- import DistanceSurface from './type/DistanceSurface'
- import Heading from './type/Heading'
- import Height from './type/Height'
- import TriangleHeight from './type/TriangleHeight'
- import MeasureType from './MeasureType'
-
- class Measure {
- constructor() {
- this._viewer = undefined
- this._layer = new Cesium.CustomDataSource('measure-layer')
- }
-
- get viewer() {
- return this._viewer
- }
-
- get layer() {
- return this._layer
- }
-
- /**
- *
- * @param options
- * @returns {Measure}
- */
- angle(options = {}) {
- new Angle().start(this, options)
- return this
- }
-
- /**
- *
- * @param options
- * @returns {Measure}
- */
- area(options = {}) {
- new Area().start(this, options)
- return this
- }
-
- /**
- *
- * @param options
- * @returns {Measure}
- */
- areaHeight(options = {}) {
- new AreaHeight().start(this, options)
- return this
- }
-
- /**
- *
- * @param options
- * @returns {Measure}
- */
- areaSurface(options = {}) {
- new AreaSurface().start(this, options)
- return this
- }
-
- /**
- *
- * @param options
- * @returns {Measure}
- */
- distance(options = {}) {
- new Distance().start(this, options)
- return this
- }
-
- /**
- *
- * @param options
- * @returns {Measure}
- */
- distanceSurface(options = {}) {
- new DistanceSurface().start(this, options)
- return this
- }
-
- /**
- *
- * @param options
- * @returns {Measure}
- */
- heading(options = {}) {
- new Heading().start(this, options)
- return this
- }
-
- /**
- *
- * @param options
- * @returns {Measure}
- */
- height(options = {}) {
- new Height().start(this, options)
- return this
- }
-
- /**
- *
- * @param options
- * @returns {Measure}
- */
- triangleHeight(options = {}) {
- new TriangleHeight().start(this, options)
- return this
- }
- /**
- *
- * @param viewer
- */
- install(viewer) {
- this._viewer = viewer
- this._viewer.dataSources.add(this._layer)
- Object.defineProperty(viewer, 'measure', {
- value: this,
- writable: false
- })
- }
-
- /**
- *
- * @param type
- * @param options
- * @returns {Measure}
- */
- activate(type, options) {
- switch (type) {
- case MeasureType.ANGLE:
- this.angle(options)
- break
- case MeasureType.AREA:
- this.area(options)
- break
- case MeasureType.AREA_HEIGHT:
- this.areaHeight(options)
- break
- case MeasureType.AREA_SURFACE:
- this.areaSurface(options)
- break
- case MeasureType.DISTANCE:
- this.distance(options)
- break
- case MeasureType.DISTANCE_SURFACE:
- this.distanceSurface(options)
- break
- case MeasureType.HEADING:
- this.heading(options)
- break
- case MeasureType.HEIGHT:
- this.height(options)
- break
- case MeasureType.TRIANGLE_HEIGHT:
- this.triangleHeight(options)
- break
- default:
- break
- }
- return this
- }
-
- /**
- *
- * @returns {Measure}
- */
- deactivate() {
- this._layer.entities.removeAll()
- this._viewer.drawTool.tooltipMess = ''
- this._viewer.drawTool.deactivate()
- this._viewer.editTool.tooltipMess = ''
- this._viewer.editTool.deactivate()
- return this
- }
- }
-
- export default Measure
|