| * @Author : Caven Chen | * @Author : Caven Chen | ||||
| */ | */ | ||||
| import Position from '../position/Position' | import Position from '../position/Position' | ||||
| import { Cesium } from '../../namespace' | |||||
| import { Transform } from '../transform' | |||||
| class Parse { | class Parse { | ||||
| /** | /** | ||||
| result = Position.fromObject(position) | result = Position.fromObject(position) | ||||
| } else if (Object(position) instanceof Position) { | } else if (Object(position) instanceof Position) { | ||||
| result = position | result = position | ||||
| } else if (Object(position) instanceof Cesium.Cartesian3) { | |||||
| result = Transform.transformCartesianToWGS84(position) | |||||
| } else if (Object(position) instanceof Cesium.Cartographic) { | |||||
| result = Transform.transformCartographicToWGS84(position) | |||||
| } | } | ||||
| return result | return result | ||||
| } | } |
| return new Position(0, 0) | return new Position(0, 0) | ||||
| } | } | ||||
| /** | |||||
| * Transforms Cartographic To WGS84 | |||||
| * @param cartographic | |||||
| * @returns {Position} | |||||
| */ | |||||
| static transformCartographicToWGS84(cartographic) { | |||||
| if (cartographic) { | |||||
| return new Position( | |||||
| Cesium.Math.toDegrees(cartographic?.longitude || 0), | |||||
| Cesium.Math.toDegrees(cartographic?.latitude || 0), | |||||
| cartographic.height || 0 | |||||
| ) | |||||
| } | |||||
| return new Position(0, 0) | |||||
| } | |||||
| /** | /** | ||||
| * Transforms WGS84 To Cartesian | * Transforms WGS84 To Cartesian | ||||
| * @param position | * @param position |
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'compass', { | Object.defineProperty(this._viewer, 'compass', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| this._wrapper.onmousedown = (e) => { | this._wrapper.onmousedown = (e) => { | ||||
| this._handleMouseDown(e) | this._handleMouseDown(e) |
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'contextMenu', { | Object.defineProperty(this._viewer, 'contextMenu', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| this._handler = new Cesium.ScreenSpaceEventHandler(this._viewer.canvas) | this._handler = new Cesium.ScreenSpaceEventHandler(this._viewer.canvas) | ||||
| } | } |
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'distanceLegend', { | Object.defineProperty(this._viewer, 'distanceLegend', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| } | } | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'hawkeyeMap', { | Object.defineProperty(this._viewer, 'hawkeyeMap', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| this._viewer.camera.percentageChanged = 0.01 | this._viewer.camera.percentageChanged = 0.01 | ||||
| } | } |
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'loadingMask', { | Object.defineProperty(this._viewer, 'loadingMask', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| } | } | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'locationBar', { | Object.defineProperty(this._viewer, 'locationBar', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| } | } | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'mapSplit', { | Object.defineProperty(this._viewer, 'mapSplit', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| } | } | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'mapSwitch', { | Object.defineProperty(this._viewer, 'mapSwitch', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| this.enable = true | this.enable = true | ||||
| let self = this | |||||
| // let self = this | |||||
| this._wrapper.onmouseover = () => { | this._wrapper.onmouseover = () => { | ||||
| let width = 80 | let width = 80 | ||||
| let rightMargin = 5 | let rightMargin = 5 |
| _installHook() { | _installHook() { | ||||
| this.enable = true | this.enable = true | ||||
| this._bindEvent() | this._bindEvent() | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'popup', { | Object.defineProperty(this._viewer, 'popup', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| } | } | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'sceneSplit', { | Object.defineProperty(this._viewer, 'sceneSplit', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| } | } | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'tilesetSplit', { | Object.defineProperty(this._viewer, 'tilesetSplit', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| } | } | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'tooltip', { | Object.defineProperty(this._viewer, 'tooltip', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| } | } | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _installHook() { | _installHook() { | ||||
| const self = this | |||||
| Object.defineProperty(this._viewer, 'zoomController', { | Object.defineProperty(this._viewer, 'zoomController', { | ||||
| value: this, | |||||
| writable: false, | |||||
| get() { | |||||
| return self | |||||
| }, | |||||
| }) | }) | ||||
| } | } | ||||