| * @Author: Caven | * @Author: Caven | ||||
| * @Date: 2020-05-09 13:19:53 | * @Date: 2020-05-09 13:19:53 | ||||
| * @Last Modified by: Caven | * @Last Modified by: Caven | ||||
| * @Last Modified time: 2020-05-12 00:21:25 | |||||
| * @Last Modified time: 2020-05-12 09:27:35 | |||||
| */ | */ | ||||
| import { DomUtil, Util } from './utils' | import { DomUtil, Util } from './utils' | 
| /* | |||||
| * @Author: Caven | |||||
| * @Date: 2020-04-10 16:58:31 | |||||
| * @Last Modified by: Caven | |||||
| * @Last Modified time: 2020-05-12 00:00:07 | |||||
| */ | |||||
| import { RoamingEventType } from './EventType' | |||||
| import Event from './Event' | |||||
| const { Cesium } = DC.Namespace | |||||
| class RoamingEvent extends Event { | |||||
| constructor() { | |||||
| super() | |||||
| } | |||||
| _registerEvent() { | |||||
| Object.keys(RoamingEventType).forEach(key => { | |||||
| let type = RoamingEventType[key] | |||||
| this._cache[type] = new Cesium.Event() | |||||
| }) | |||||
| } | |||||
| } | |||||
| export default RoamingEvent | 
| * @Author: Caven | * @Author: Caven | ||||
| * @Date: 2020-01-13 10:13:53 | * @Date: 2020-01-13 10:13:53 | ||||
| * @Last Modified by: Caven | * @Last Modified by: Caven | ||||
| * @Last Modified time: 2020-05-11 22:37:07 | |||||
| * @Last Modified time: 2020-05-12 09:27:31 | |||||
| */ | */ | ||||
| import { Layer, VectorLayer } from './index' | import { Layer, VectorLayer } from './index' | 
| * @Author: Caven | * @Author: Caven | ||||
| * @Date: 2019-12-31 17:58:01 | * @Date: 2019-12-31 17:58:01 | ||||
| * @Last Modified by: Caven | * @Last Modified by: Caven | ||||
| * @Last Modified time: 2020-05-11 22:38:51 | |||||
| * @Last Modified time: 2020-05-12 09:53:43 | |||||
| */ | */ | ||||
| import Position from '../position/Position' | |||||
| const CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split( | const CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split( | ||||
| '' | '' | ||||
| ) | ) | ||||
| * @param {*} position | * @param {*} position | ||||
| */ | */ | ||||
| static checkPosition(position) { | static checkPosition(position) { | ||||
| return position && position instanceof Position | |||||
| return ( | |||||
| position && | |||||
| position.hasOwnProperty('lng') && | |||||
| position.hasOwnProperty('lat') && | |||||
| position.hasOwnProperty('alt') | |||||
| ) | |||||
| } | } | ||||
| /** | /** | ||||
| positions && (typeof positions === 'string' || Array.isArray(positions)) | positions && (typeof positions === 'string' || Array.isArray(positions)) | ||||
| ) | ) | ||||
| } | } | ||||
| /** | |||||
| * @function checkViewer(viewer: Object): Boolean | |||||
| * Check viewer for validity | |||||
| * @param {*} position | |||||
| */ | |||||
| static checkViewer(viewer) { | |||||
| return viewer && viewer.delegate && viewer.canvas | |||||
| } | |||||
| } | } | ||||
| export default Util | export default Util | 
| * @Author: Caven | * @Author: Caven | ||||
| * @Date: 2020-01-31 15:51:32 | * @Date: 2020-01-31 15:51:32 | ||||
| * @Last Modified by: Caven | * @Last Modified by: Caven | ||||
| * @Last Modified time: 2020-05-11 23:08:29 | |||||
| * @Last Modified time: 2020-05-12 10:00:09 | |||||
| */ | */ | ||||
| import DrawPoint from './draw/DrawPoint' | import DrawPoint from './draw/DrawPoint' | ||||
| import EditPoint from './edit/EditPoint' | import EditPoint from './edit/EditPoint' | ||||
| import EditPolyline from './edit/EditPolyline' | import EditPolyline from './edit/EditPolyline' | ||||
| const { VectorLayer, OverlayType } = DC | |||||
| const { OverlayType, Util } = DC | |||||
| const { Cesium } = DC.Namespace | const { Cesium } = DC.Namespace | ||||
| class Plot { | class Plot { | ||||
| constructor(viewer) { | constructor(viewer) { | ||||
| if (!Util.checkViewer(viewer)) { | |||||
| throw new Error('Plot: the viewer invalid') | |||||
| } | |||||
| this._viewer = viewer | this._viewer = viewer | ||||
| this._plotEvent = new Cesium.Event() | this._plotEvent = new Cesium.Event() | ||||
| this._callback = undefined | this._callback = undefined | ||||
| this._editWorker = undefined | this._editWorker = undefined | ||||
| this._drawLayer = new Cesium.CustomDataSource('plot-draw-layer') | this._drawLayer = new Cesium.CustomDataSource('plot-draw-layer') | ||||
| this._viewer.delegate.dataSources.add(this._drawLayer) | this._viewer.delegate.dataSources.add(this._drawLayer) | ||||
| this._markerLayer = new VectorLayer('plot-marker-layer') | |||||
| this._markerLayer = new DC.VectorLayer('plot-marker-layer') | |||||
| this._viewer.addLayer(this._markerLayer) | this._viewer.addLayer(this._markerLayer) | ||||
| this._state = undefined | this._state = undefined | ||||
| } | } | 
| * @Author: Caven | * @Author: Caven | ||||
| * @Date: 2020-01-31 19:45:32 | * @Date: 2020-01-31 19:45:32 | ||||
| * @Last Modified by: Caven | * @Last Modified by: Caven | ||||
| * @Last Modified time: 2020-05-10 10:57:23 | |||||
| * @Last Modified time: 2020-05-12 09:39:12 | |||||
| */ | */ | ||||
| const { Cesium } = DC.NameSpace | |||||
| const { Cesium } = DC.Namespace | |||||
| class Draw { | class Draw { | ||||
| constructor(plotInfo) { | constructor(plotInfo) { | 
| * @Author: Caven | * @Author: Caven | ||||
| * @Date: 2020-01-31 19:44:41 | * @Date: 2020-01-31 19:44:41 | ||||
| * @Last Modified by: Caven | * @Last Modified by: Caven | ||||
| * @Last Modified time: 2020-05-11 22:31:32 | |||||
| * @Last Modified time: 2020-05-12 09:34:37 | |||||
| */ | */ | ||||
| import Draw from './Draw' | import Draw from './Draw' | ||||
| const { OverlayType, Transform } = DC | const { OverlayType, Transform } = DC | ||||
| const { Cesium } = DC.NameSpace | |||||
| const { Cesium } = DC.Namespace | |||||
| const DEF_STYLE = { | const DEF_STYLE = { | ||||
| width: 3, | width: 3, | 
| const { OverlayType, Transform } = DC | const { OverlayType, Transform } = DC | ||||
| const { Cesium } = DC.NameSpace | |||||
| const { Cesium } = DC.Namespace | |||||
| const DEF_STYLE = { | const DEF_STYLE = { | ||||
| pixelSize: 10, | pixelSize: 10, | 
| const { OverlayType, Transform } = DC | const { OverlayType, Transform } = DC | ||||
| const { Cesium } = DC.NameSpace | |||||
| const { Cesium } = DC.Namespace | |||||
| const DEF_STYLE = { | const DEF_STYLE = { | ||||
| material: Cesium.Color.BLUE.withAlpha(0.6) | material: Cesium.Color.BLUE.withAlpha(0.6) | 
| const { OverlayType, Transform } = DC | const { OverlayType, Transform } = DC | ||||
| const { Cesium } = DC.NameSpace | |||||
| const { Cesium } = DC.Namespace | |||||
| const DEF_STYLE = { | const DEF_STYLE = { | ||||
| width: 3, | width: 3, | 
| const { OverlayType, Transform } = DC | const { OverlayType, Transform } = DC | ||||
| const { Cesium } = DC.NameSpace | |||||
| const { Cesium } = DC.Namespace | |||||
| const DEF_STYLE = { | const DEF_STYLE = { | ||||
| material: Cesium.Color.BLUE.withAlpha(0.6) | material: Cesium.Color.BLUE.withAlpha(0.6) | 
| const { OverlayType, Transform } = DC | const { OverlayType, Transform } = DC | ||||
| const { Cesium } = DC.NameSpace | |||||
| const { Cesium } = DC.Namespace | |||||
| class Edit { | class Edit { | ||||
| constructor(plotInfo) { | constructor(plotInfo) { | 
| * @Author: Caven | * @Author: Caven | ||||
| * @Date: 2020-04-03 10:13:42 | * @Date: 2020-04-03 10:13:42 | ||||
| * @Last Modified by: Caven | * @Last Modified by: Caven | ||||
| * @Last Modified time: 2020-05-11 23:52:18 | |||||
| * @Last Modified time: 2020-05-12 09:31:46 | |||||
| */ | */ | ||||
| const install = function(DC) { | const install = function(DC) { | 
| * @Author: Caven | * @Author: Caven | ||||
| * @Date: 2020-03-02 23:14:20 | * @Date: 2020-03-02 23:14:20 | ||||
| * @Last Modified by: Caven | * @Last Modified by: Caven | ||||
| * @Last Modified time: 2020-05-11 22:17:25 | |||||
| * @Last Modified time: 2020-05-12 09:56:16 | |||||
| */ | */ | ||||
| const { Viewer, SceneEventType } = DC | |||||
| const { SceneEventType, Util } = DC | |||||
| const { Cesium } = DC.Namespace | const { Cesium } = DC.Namespace | ||||
| class AroundView { | class AroundView { | ||||
| constructor(viewer, options = {}) { | constructor(viewer, options = {}) { | ||||
| if (!viewer || !(viewer instanceof Viewer)) { | |||||
| throw new Error('the viewer invalid') | |||||
| if (!Util.checkViewer(viewer)) { | |||||
| throw new Error('AroundView: the viewer invalid') | |||||
| } | } | ||||
| this._viewer = viewer | this._viewer = viewer | ||||
| this._options = options | this._options = options | 
| * @Author: Caven | * @Author: Caven | ||||
| * @Date: 2020-03-02 22:38:10 | * @Date: 2020-03-02 22:38:10 | ||||
| * @Last Modified by: Caven | * @Last Modified by: Caven | ||||
| * @Last Modified time: 2020-05-11 21:39:33 | |||||
| * @Last Modified time: 2020-05-12 09:57:49 | |||||
| */ | */ | ||||
| const { Viewer, SceneEventType, Position, Transfrom } = DC | |||||
| const { Util, SceneEventType, Transfrom } = DC | |||||
| const { Cesium } = DC.Namespace | const { Cesium } = DC.Namespace | ||||
| class AroundPoint { | class AroundPoint { | ||||
| constructor(viewer, position, options = {}) { | constructor(viewer, position, options = {}) { | ||||
| if ( | |||||
| !position || | |||||
| !(viewer instanceof Viewer) || | |||||
| !(position instanceof Position) | |||||
| ) { | |||||
| throw new Error('the position invalid') | |||||
| if (!Util.checkViewer(viewer)) { | |||||
| throw new Error('AroundPoint:the viewer invalid') | |||||
| } | |||||
| if (!Util.checkPosition(position)) { | |||||
| throw new Error('AroundPoint:the position invalid') | |||||
| } | } | ||||
| this._viewer = viewer | this._viewer = viewer | ||||
| this._position = position | this._position = position |