| @@ -16,9 +16,7 @@ const ELEC_URL = | |||
| class AmapImageryProvider extends Cesium.UrlTemplateImageryProvider { | |||
| constructor(options = {}) { | |||
| options['url'] = options.style === 'img' ? IMG_URL : ELEC_URL | |||
| if (!options.subdomains || !options.subdomains.length) { | |||
| options['subdomains'] = ['01', '02', '03', '04'] | |||
| } | |||
| options['subdomains'] = options.subdomains || ['01', '02', '03', '04'] | |||
| super(options) | |||
| } | |||
| } | |||
| @@ -24,9 +24,7 @@ class GoogleImageryProvider extends Cesium.UrlTemplateImageryProvider { | |||
| : options.style === 'ter' | |||
| ? TER_URL | |||
| : ELEC_URL | |||
| if (!options.subdomains || !options.subdomains.length) { | |||
| options['subdomains'] = ['1', '2', '3'] | |||
| } | |||
| options['subdomains'] = options.subdomains || ['1', '2', '3'] | |||
| super(options) | |||
| } | |||
| } | |||
| @@ -1,20 +1,32 @@ | |||
| /** | |||
| * @Author: Caven | |||
| * @Date: 2020-01-21 16:10:47 | |||
| * @Date: 2020-01-21 18:10:47 | |||
| */ | |||
| import ImageryType from '../ImageryType' | |||
| const { Cesium } = DC.Namespace | |||
| const IMG_URL = | |||
| 'https://p{s}.map.gtimg.com/sateTiles/{z}/{sx}/{sy}/{x}_{reverseY}.jpg?version=400' | |||
| const ELEC_URL = | |||
| 'https://rt{s}.map.gtimg.com/tile?z={z}&x={x}&y={reverseY}&styleid={style}&scene=0&version=347' | |||
| class TencentImageryProvider extends Cesium.UrlTemplateImageryProvider { | |||
| constructor(options = {}) { | |||
| options['url'] = ELEC_URL.replace('{style}', options.style || 1) | |||
| if (!options.subdomains || !options.subdomains.length) { | |||
| options['subdomains'] = ['0', '1', '2'] | |||
| let url = options.style === 'img' ? IMG_URL : ELEC_URL | |||
| options['url'] = url.replace('{style}', options.style || 1) | |||
| options['subdomains'] = options.subdomains || ['1', '2', '3'] | |||
| if (options.style === 'img') { | |||
| options['customTags'] = { | |||
| sx: (imageryProvider, x, y, level) => { | |||
| return x >> 4 | |||
| }, | |||
| sy: (imageryProvider, x, y, level) => { | |||
| return ((1 << level) - y) >> 4 | |||
| } | |||
| } | |||
| } | |||
| super(options) | |||
| } | |||
| @@ -0,0 +1,92 @@ | |||
| /** | |||
| * @Author: Caven | |||
| * @Date: 2020-08-16 11:14:23 | |||
| */ | |||
| /** | |||
| * Some of the code borrows from MAPV | |||
| * https://github.com/huiyan-fe/mapv/blob/3292c7c25dbbf29af3cf7b3acb48108d60b3eed8/src/utils/curve.js | |||
| */ | |||
| export default function curve(points, options) { | |||
| options = options || {} | |||
| let curvePoints = [] | |||
| for (let i = 0; i < points.length - 1; i++) { | |||
| let p = getCurveByTwoPoints(points[i], points[i + 1], options.count) | |||
| if (p && p.length > 0) { | |||
| curvePoints = curvePoints.concat(p) | |||
| } | |||
| } | |||
| return curvePoints | |||
| } | |||
| /** | |||
| * Get a curvilinear coordinate set of points based on two points | |||
| * @param obj1 | |||
| * @param obj2 | |||
| * @param count | |||
| * @returns {null|[]} | |||
| */ | |||
| function getCurveByTwoPoints(obj1, obj2, count) { | |||
| if (!obj1 || !obj2) { | |||
| return null | |||
| } | |||
| let curveCoordinates = [] | |||
| count = count || 40 // 曲线是由一些小的线段组成的,这个表示这个曲线所有到的折线的个数 | |||
| let B1 = function(x) { | |||
| return 1 - 2 * x + x * x | |||
| } | |||
| let B2 = x => { | |||
| return 2 * x - 2 * x * x | |||
| } | |||
| let B3 = x => { | |||
| return x * x | |||
| } | |||
| let t, h, h2, lat3, lng3, t2 | |||
| let inc = 0 | |||
| let lat1 = parseFloat(obj1.lat) | |||
| let lat2 = parseFloat(obj2.lat) | |||
| let lng1 = parseFloat(obj1.lng) | |||
| let lng2 = parseFloat(obj2.lng) | |||
| // 计算曲线角度的方法 | |||
| if (lng2 > lng1) { | |||
| if (lng2 - lng1 > 180) { | |||
| if (lng1 < 0) { | |||
| lng1 = 180 + 180 + lng1 | |||
| lng2 = 180 + 180 + lng2 | |||
| } | |||
| } | |||
| } | |||
| // 此时纠正了 lng1 lng2 | |||
| t2 = 0 | |||
| // 纬度相同 | |||
| if (lat2 === lat1) { | |||
| t = 0 | |||
| h = lng1 - lng2 | |||
| // 经度相同 | |||
| } else if (lng2 === lng1) { | |||
| t = Math.PI / 2 | |||
| h = lat1 - lat2 | |||
| } else { | |||
| t = Math.atan((lat2 - lat1) / (lng2 - lng1)) | |||
| h = (lat2 - lat1) / Math.sin(t) | |||
| } | |||
| if (t2 === 0) { | |||
| t2 = t + Math.PI / 5 | |||
| } | |||
| h2 = h / 2 | |||
| lng3 = h2 * Math.cos(t2) + lng1 | |||
| lat3 = h2 * Math.sin(t2) + lat1 | |||
| for (let i = 0; i < count + 1; i++) { | |||
| let x = lng1 * B1(inc) + lng3 * B2(inc) + lng2 * B3(inc) | |||
| let y = lat1 * B1(inc) + lat3 * B2(inc) + lat2 * B3(inc) | |||
| let lng1_src = obj1.lng | |||
| let lng2_src = obj2.lng | |||
| curveCoordinates.push([lng1_src < 0 && lng2_src > 0 ? x - 360 : x, y]) | |||
| inc = inc + 1 / count | |||
| } | |||
| return curveCoordinates | |||
| } | |||
| @@ -10,3 +10,4 @@ export { default as distance } from './distance' | |||
| export { default as heading } from './heading' | |||
| export { default as isBetween } from './isBetween' | |||
| export { default as parabola } from './parabola' | |||
| export { default as curve } from './curve' | |||
| @@ -59,7 +59,7 @@ class CameraOption { | |||
| * | |||
| */ | |||
| limitCameraToGround() { | |||
| this._viewer.camera.changed.addEventListener(framestate => { | |||
| this._viewer.camera.changed.addEventListener(frameState => { | |||
| if ( | |||
| this._viewer.camera._suspendTerrainAdjustment && | |||
| this._viewer.scene.mode === Cesium.SceneMode.SCENE3D | |||
| @@ -8,8 +8,7 @@ const CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.s | |||
| ) | |||
| /** | |||
| * 工具类 | |||
| * 部分代码借鉴leaflet | |||
| * Some of the code borrows from leaflet | |||
| * https://github.com/Leaflet/Leaflet/tree/master/src/core | |||
| */ | |||
| class Util { | |||