| @@ -1,5 +1,13 @@ | |||
| # 更新 | |||
| ## 1.6.3 | |||
| ### 2020-5-28 | |||
| > 1. 修改函数 distance 的无法使用的问题 | |||
| > 2. 添加抛物线函数 | |||
| > 3. 添加 position 格式转换为 Turf 坐标格式函数 | |||
| ## 1.6.2 | |||
| ### 2020-5-25 | |||
| @@ -1,6 +1,6 @@ | |||
| { | |||
| "name": "@dvgis/dc-sdk", | |||
| "version": "1.6.2", | |||
| "version": "1.6.3", | |||
| "description": " The SDK is a secondary development based on the open source project Cesium, which optimizes some operations of Cesium and enables developers to quickly develop 3D applications through the framework.", | |||
| "main": "index.js", | |||
| "repository": "https://github.com/Digital-Visual/dc-sdk.git", | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-04-22 09:44:30 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-25 09:20:03 | |||
| * @Last Modified time: 2020-05-28 15:16:28 | |||
| */ | |||
| import { initMixin, initUse } from './global-api' | |||
| @@ -11,7 +11,7 @@ let DC = { | |||
| Author: 'Caven Chen', | |||
| GitHub: 'https://github.com/Digital-Visual', | |||
| Home: 'https://www.dvgis.cn', | |||
| Version: '1.6.2', | |||
| Version: '1.6.3', | |||
| Namespace: {}, | |||
| Initialized: false | |||
| } | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2019-12-27 17:18:52 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-19 22:05:23 | |||
| * @Last Modified time: 2020-05-28 14:35:10 | |||
| */ | |||
| import ImageryLayerFactory from './imagery/ImageryLayerFactory' | |||
| @@ -29,7 +29,15 @@ import { | |||
| Tileset | |||
| } from './overlay' | |||
| import { area, bounds, center, distance, heading, isBetween } from './math' | |||
| import { | |||
| area, | |||
| bounds, | |||
| center, | |||
| distance, | |||
| heading, | |||
| isBetween, | |||
| parabola | |||
| } from './math' | |||
| const { Cesium } = DC.Namespace | |||
| @@ -39,6 +47,7 @@ Cesium.Math.center = center | |||
| Cesium.Math.distance = distance | |||
| Cesium.Math.heading = heading | |||
| Cesium.Math.isBetween = isBetween | |||
| Cesium.Math.parabola = parabola | |||
| const core = { | |||
| ImageryLayerFactory, | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-02 15:24:38 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 22:34:56 | |||
| * @Last Modified time: 2020-05-27 12:50:32 | |||
| */ | |||
| class Event { | |||
| @@ -28,7 +28,7 @@ class Event { | |||
| _on(type, callback, context) { | |||
| let event = this.getEvent(type) | |||
| let removeCallback = undefined | |||
| if (callback && event) { | |||
| if (event && callback) { | |||
| removeCallback = event.addEventListener(callback, context || this) | |||
| } | |||
| return removeCallback | |||
| @@ -2,11 +2,13 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-03-31 20:58:06 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 21:48:23 | |||
| * @Last Modified time: 2020-05-27 12:54:49 | |||
| */ | |||
| import Transform from '../transform/Transform' | |||
| const { Cesium } = DC.Namespace | |||
| export default function distance(positions) { | |||
| let distance = 0 | |||
| if (positions && Array.isArray(positions)) { | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-03-31 20:57:36 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-12 00:42:27 | |||
| * @Last Modified time: 2020-05-28 10:27:54 | |||
| */ | |||
| export { default as area } from './area' | |||
| @@ -11,3 +11,4 @@ export { default as center } from './center' | |||
| export { default as distance } from './distance' | |||
| export { default as heading } from './heading' | |||
| export { default as isBetween } from './isBetween' | |||
| export { default as parabola } from './parabola' | |||
| @@ -0,0 +1,58 @@ | |||
| /* | |||
| * @Author: Caven | |||
| * @Date: 2020-05-28 10:24:38 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-28 14:33:28 | |||
| */ | |||
| import { Util } from '../utils' | |||
| export default function parabola( | |||
| startPosition, | |||
| endPosition, | |||
| height = 0, | |||
| count = 50 | |||
| ) { | |||
| //方程 y=-(4h/L^2)*x^2+h h:顶点高度 L:横纵间距较大者 | |||
| let result = [] | |||
| if (!Util.checkPosition(startPosition) || !Util.checkPosition(endPosition)) { | |||
| return result | |||
| } | |||
| height = Math.min(+height, 5000) | |||
| count = Math.min(+count, 50) | |||
| let diffLng = Math.abs(startPosition.lng - endPosition.lng) | |||
| let diffLat = Math.abs(startPosition.lat - endPosition.lat) | |||
| let L = Math.max(diffLng, diffLat) | |||
| let dlt = L / count | |||
| if (diffLng > diffLat) { | |||
| //以lng为基准 | |||
| let delLat = (endPosition.lat - startPosition.lat) / count | |||
| if (startPosition.lng - endPosition.lng > 0) { | |||
| dlt = -dlt | |||
| } | |||
| for (let i = 0; i < count; i++) { | |||
| let h = | |||
| height - | |||
| (Math.pow(-0.5 * L + Math.abs(dlt) * i, 2) * 4 * height) / | |||
| Math.pow(L, 2) | |||
| let lng = startPosition.lng + dlt * i | |||
| let lat = startPosition.lat + delLat * i | |||
| result.push([lng, lat, h]) | |||
| } | |||
| } else { | |||
| let delLng = (endPosition.lng - startPosition.lng) / count | |||
| if (startPosition.lat - endPosition.lat > 0) { | |||
| dlt = -dlt | |||
| } | |||
| for (let i = 0; i < count; i++) { | |||
| let h = | |||
| height - | |||
| (Math.pow(-0.5 * L + Math.abs(dlt) * i, 2) * 4 * height) / | |||
| Math.pow(L, 2) | |||
| let lng = startPosition.lng + delLng * i | |||
| let lat = startPosition.lat + dlt * i | |||
| result.push([lng, lat, h]) | |||
| } | |||
| } | |||
| return result | |||
| } | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-03 12:18:17 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 22:11:10 | |||
| * @Last Modified time: 2020-05-27 08:50:09 | |||
| */ | |||
| import { Util } from '../utils' | |||
| import { OverlayEventType, OverlayEvent } from '../event' | |||
| @@ -97,7 +97,7 @@ class Overlay { | |||
| } | |||
| this._layer = layer | |||
| this._mountedHook && this._mountedHook() | |||
| if (this._layer && this._layer.delegate && this._layer.delegate.entities) { | |||
| if (this._layer?.delegate?.entities) { | |||
| this._layer.delegate.entities.add(this._delegate) | |||
| this._addedHook && this._addedHook() | |||
| this._state = State.ADDED | |||
| @@ -108,7 +108,7 @@ class Overlay { | |||
| * | |||
| */ | |||
| _removeHandler() { | |||
| if (this._layer && this._layer.delegate && this._layer.delegate.entities) { | |||
| if (this._layer?.delegate?.entities) { | |||
| this._layer.delegate.entities.remove(this._delegate) | |||
| this._removedHook && this._removedHook() | |||
| this._state = State.REMOVED | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-03-22 00:10:25 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 22:11:23 | |||
| * @Last Modified time: 2020-05-28 15:33:20 | |||
| */ | |||
| import Position from '../position/Position' | |||
| @@ -18,8 +18,8 @@ class Parse { | |||
| result = Position.fromCoordString(position) | |||
| } else if (Array.isArray(position)) { | |||
| result = Position.fromCoordArray(position) | |||
| } else if (item instanceof Position) { | |||
| result = item | |||
| } else if (position instanceof Position) { | |||
| result = position | |||
| } | |||
| return result | |||
| } | |||
| @@ -46,6 +46,41 @@ class Parse { | |||
| } | |||
| }) | |||
| } | |||
| /** | |||
| * | |||
| * @param {*} position | |||
| */ | |||
| static parsePointCoordToArray(position) { | |||
| position = this.parsePosition(position) | |||
| return [position.lng, position.lat] | |||
| } | |||
| /** | |||
| * | |||
| * @param {*} positions | |||
| */ | |||
| static parsePolylineCoordToArray(positions) { | |||
| let result = [] | |||
| positions = this.parsePositions(positions) | |||
| positions.forEach(item => { | |||
| result.push([item.lng, item.lat]) | |||
| }) | |||
| return result | |||
| } | |||
| /** | |||
| * | |||
| * @param {*} positions | |||
| */ | |||
| static parsePolygonCoordToArray(positions) { | |||
| let result = [] | |||
| positions = this.parsePositions(positions) | |||
| positions.forEach(item => { | |||
| result.push([item.lng, item.lat]) | |||
| }) | |||
| return [result] | |||
| } | |||
| } | |||
| export default Parse | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2019-12-27 14:35:02 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 22:11:25 | |||
| * @Last Modified time: 2020-05-27 08:51:54 | |||
| */ | |||
| import Transform from '../transform/Transform' | |||
| @@ -20,7 +20,7 @@ class Position { | |||
| } | |||
| set lng(lng) { | |||
| this._lng = lng | |||
| this._lng = +lng | |||
| } | |||
| get lng() { | |||
| @@ -28,7 +28,7 @@ class Position { | |||
| } | |||
| set lat(lat) { | |||
| this._lat = lat | |||
| this._lat = +lat | |||
| } | |||
| get lat() { | |||
| @@ -36,7 +36,7 @@ class Position { | |||
| } | |||
| set alt(alt) { | |||
| this._alt = alt | |||
| this._alt = +alt | |||
| } | |||
| get alt() { | |||
| @@ -44,7 +44,7 @@ class Position { | |||
| } | |||
| set heading(heading) { | |||
| this._heading = heading | |||
| this._heading = +heading | |||
| } | |||
| get heading() { | |||
| @@ -52,7 +52,7 @@ class Position { | |||
| } | |||
| set pitch(pitch) { | |||
| this._pitch = pitch | |||
| this._pitch = +pitch | |||
| } | |||
| get pitch() { | |||
| @@ -60,7 +60,7 @@ class Position { | |||
| } | |||
| set roll(roll) { | |||
| this._roll = roll | |||
| this._roll = +roll | |||
| } | |||
| get roll() { | |||