deeptwins-engine-3d 0.1.32 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/Build/DeepTwins/Image/f_point.png +0 -0
- package/dist/esm/analyze/SubmergenceAnalysis.d.ts +19 -0
- package/dist/esm/analyze/SubmergenceAnalysis.js +137 -0
- package/dist/esm/constant.d.ts +29 -0
- package/dist/esm/constant.js +47 -0
- package/dist/esm/drawer/index.d.ts +56 -59
- package/dist/esm/drawer/index.js +380 -292
- package/dist/esm/drawer/shape/BaseShape.d.ts +33 -0
- package/dist/esm/drawer/shape/BaseShape.js +228 -0
- package/dist/esm/drawer/shape/Point.d.ts +44 -11
- package/dist/esm/drawer/shape/Point.js +299 -35
- package/dist/esm/drawer/shape/Polygon.d.ts +43 -9
- package/dist/esm/drawer/shape/Polygon.js +408 -56
- package/dist/esm/drawer/shape/Polyline.d.ts +41 -10
- package/dist/esm/drawer/shape/Polyline.js +373 -31
- package/dist/esm/drawer/utils.d.ts +1 -0
- package/dist/esm/drawer/utils.js +63 -0
- package/dist/esm/graphicLayer/BaseLayer.d.ts +1 -0
- package/dist/esm/graphicLayer/BaseLayer.js +8 -3
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/graphicLayer/BaseSource.js +13 -3
- package/dist/esm/graphicLayer/GraphicLayerCollection.d.ts +2 -0
- package/dist/esm/graphicLayer/GraphicLayerCollection.js +46 -4
- package/dist/esm/graphicLayer/HtmlEntity.js +1 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +7 -4
- package/dist/esm/map/Map.d.ts +1 -0
- package/dist/esm/map/Map.js +10 -0
- package/dist/esm/measure/Area.d.ts +29 -0
- package/dist/esm/measure/{AreaMeasure.js → Area.js} +156 -65
- package/dist/esm/measure/BaseDraw.d.ts +13 -0
- package/dist/esm/measure/BaseDraw.js +70 -0
- package/dist/esm/measure/Distance.d.ts +23 -0
- package/dist/esm/measure/Distance.js +239 -0
- package/dist/esm/measure/index.d.ts +44 -5
- package/dist/esm/measure/index.js +278 -5
- package/dist/esm/measure/utils.d.ts +108 -14
- package/dist/esm/measure/utils.js +262 -20
- package/dist/esm/plot/create/CreateAssemble.d.ts +2 -0
- package/dist/esm/plot/create/CreateAssemble.js +63 -0
- package/dist/esm/plot/create/CreateAttackArrow.d.ts +5 -0
- package/dist/esm/plot/create/CreateAttackArrow.js +75 -0
- package/dist/esm/plot/create/CreateBillboard.d.ts +2 -0
- package/dist/esm/plot/create/CreateBillboard.js +47 -0
- package/dist/esm/plot/create/CreateBow.d.ts +2 -0
- package/dist/esm/plot/create/CreateBow.js +63 -0
- package/dist/esm/plot/create/CreateCircle.d.ts +2 -0
- package/dist/esm/plot/create/CreateCircle.js +68 -0
- package/dist/esm/plot/create/CreateCurve.d.ts +2 -0
- package/dist/esm/plot/create/CreateCurve.js +76 -0
- package/dist/esm/plot/create/CreateElliptic.d.ts +2 -0
- package/dist/esm/plot/create/CreateElliptic.js +69 -0
- package/dist/esm/plot/create/CreateFlag.d.ts +2 -0
- package/dist/esm/plot/create/CreateFlag.js +80 -0
- package/dist/esm/plot/create/CreateFormation.d.ts +2 -0
- package/dist/esm/plot/create/CreateFormation.js +65 -0
- package/dist/esm/plot/create/CreateFreeLine.d.ts +2 -0
- package/dist/esm/plot/create/CreateFreeLine.js +69 -0
- package/dist/esm/plot/create/CreateFreePolygon.d.ts +2 -0
- package/dist/esm/plot/create/CreateFreePolygon.js +65 -0
- package/dist/esm/plot/create/CreateLabel.d.ts +2 -0
- package/dist/esm/plot/create/CreateLabel.js +55 -0
- package/dist/esm/plot/create/CreateLineArrow.d.ts +2 -0
- package/dist/esm/plot/create/CreateLineArrow.js +79 -0
- package/dist/esm/plot/create/CreatePincerArrow.d.ts +5 -0
- package/dist/esm/plot/create/CreatePincerArrow.js +73 -0
- package/dist/esm/plot/create/CreatePoint.d.ts +2 -0
- package/dist/esm/plot/create/CreatePoint.js +47 -0
- package/dist/esm/plot/create/CreatePolygon.d.ts +2 -0
- package/dist/esm/plot/create/CreatePolygon.js +80 -0
- package/dist/esm/plot/create/CreatePolyline.d.ts +2 -0
- package/dist/esm/plot/create/CreatePolyline.js +70 -0
- package/dist/esm/plot/create/CreateRectangle.d.ts +2 -0
- package/dist/esm/plot/create/CreateRectangle.js +60 -0
- package/dist/esm/plot/create/CreateRegularPolygon.d.ts +2 -0
- package/dist/esm/plot/create/CreateRegularPolygon.js +75 -0
- package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +5 -0
- package/dist/esm/plot/create/CreateRightAngleArrow.js +73 -0
- package/dist/esm/plot/create/CreateRoundRectangle.d.ts +2 -0
- package/dist/esm/plot/create/CreateRoundRectangle.js +63 -0
- package/dist/esm/plot/create/CreateSector.d.ts +2 -0
- package/dist/esm/plot/create/CreateSector.js +65 -0
- package/dist/esm/plot/create/CreateStraightArrow.d.ts +5 -0
- package/dist/esm/plot/create/CreateStraightArrow.js +65 -0
- package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +5 -0
- package/dist/esm/plot/create/CreateSwallowtailArrow.js +67 -0
- package/dist/esm/plot/create/index.d.ts +25 -0
- package/dist/esm/plot/create/index.js +25 -0
- package/dist/esm/plot/edit/EditAssemble.d.ts +8 -0
- package/dist/esm/plot/edit/EditAssemble.js +120 -0
- package/dist/esm/plot/edit/EditAttackArrow.d.ts +8 -0
- package/dist/esm/plot/edit/EditAttackArrow.js +182 -0
- package/dist/esm/plot/edit/EditBillboard.d.ts +7 -0
- package/dist/esm/plot/edit/EditBillboard.js +70 -0
- package/dist/esm/plot/edit/EditBow.d.ts +8 -0
- package/dist/esm/plot/edit/EditBow.js +119 -0
- package/dist/esm/plot/edit/EditCircle.d.ts +8 -0
- package/dist/esm/plot/edit/EditCircle.js +133 -0
- package/dist/esm/plot/edit/EditCurve.d.ts +8 -0
- package/dist/esm/plot/edit/EditCurve.js +180 -0
- package/dist/esm/plot/edit/EditElliptic.d.ts +8 -0
- package/dist/esm/plot/edit/EditElliptic.js +144 -0
- package/dist/esm/plot/edit/EditFlag.d.ts +8 -0
- package/dist/esm/plot/edit/EditFlag.js +121 -0
- package/dist/esm/plot/edit/EditFormation.d.ts +8 -0
- package/dist/esm/plot/edit/EditFormation.js +120 -0
- package/dist/esm/plot/edit/EditLabel.d.ts +7 -0
- package/dist/esm/plot/edit/EditLabel.js +100 -0
- package/dist/esm/plot/edit/EditLineArrow.d.ts +8 -0
- package/dist/esm/plot/edit/EditLineArrow.js +180 -0
- package/dist/esm/plot/edit/EditPincerArrow.d.ts +8 -0
- package/dist/esm/plot/edit/EditPincerArrow.js +121 -0
- package/dist/esm/plot/edit/EditPoint.d.ts +7 -0
- package/dist/esm/plot/edit/EditPoint.js +70 -0
- package/dist/esm/plot/edit/EditPolygon.d.ts +8 -0
- package/dist/esm/plot/edit/EditPolygon.js +181 -0
- package/dist/esm/plot/edit/EditPolyline.d.ts +8 -0
- package/dist/esm/plot/edit/EditPolyline.js +179 -0
- package/dist/esm/plot/edit/EditRectangle.d.ts +8 -0
- package/dist/esm/plot/edit/EditRectangle.js +119 -0
- package/dist/esm/plot/edit/EditRegularPolygon.d.ts +8 -0
- package/dist/esm/plot/edit/EditRegularPolygon.js +170 -0
- package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +8 -0
- package/dist/esm/plot/edit/EditRightAngleArrow.js +143 -0
- package/dist/esm/plot/edit/EditRoundRectangle.d.ts +8 -0
- package/dist/esm/plot/edit/EditRoundRectangle.js +119 -0
- package/dist/esm/plot/edit/EditSector.d.ts +8 -0
- package/dist/esm/plot/edit/EditSector.js +120 -0
- package/dist/esm/plot/edit/EditStraightArrow.d.ts +8 -0
- package/dist/esm/plot/edit/EditStraightArrow.js +120 -0
- package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +8 -0
- package/dist/esm/plot/edit/EditSwallowtailArrow.js +121 -0
- package/dist/esm/plot/edit/index.d.ts +23 -0
- package/dist/esm/plot/edit/index.js +23 -0
- package/dist/esm/plot/utils/Algorithm.d.ts +2 -0
- package/dist/esm/plot/utils/Algorithm.js +316 -0
- package/dist/esm/plot/utils/Coordinate.d.ts +98 -0
- package/dist/esm/plot/utils/Coordinate.js +184 -0
- package/dist/esm/plot/utils/DomUtil.d.ts +34 -0
- package/dist/esm/plot/utils/DomUtil.js +100 -0
- package/dist/esm/plot/utils/PlotCommon.d.ts +101 -0
- package/dist/esm/plot/utils/PlotCommon.js +1412 -0
- package/dist/esm/plot/utils/ReminderTip.d.ts +10 -0
- package/dist/esm/plot/utils/ReminderTip.js +67 -0
- package/dist/esm/plot/utils/Tooltip.d.ts +3 -0
- package/dist/esm/plot/utils/Tooltip.js +97 -0
- package/dist/esm/plot/utils/plotUtil.d.ts +5 -0
- package/dist/esm/plot/utils/plotUtil.js +268 -0
- package/dist/esm/tool/utils.d.ts +8 -7
- package/dist/esm/tool/utils.js +20 -16
- package/dist/esm/toolTip/index.d.ts +2 -1
- package/dist/esm/toolTip/index.js +12 -6
- package/dist/esm/typings.d.ts +1 -0
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -1
- package/dist/esm/drawer/base.d.ts +0 -51
- package/dist/esm/drawer/base.js +0 -179
- package/dist/esm/drawer/painter.d.ts +0 -41
- package/dist/esm/drawer/painter.js +0 -115
- package/dist/esm/drawer/shape/Ellipse.d.ts +0 -10
- package/dist/esm/drawer/shape/Ellipse.js +0 -62
- package/dist/esm/drawer/shape/Rectangle.d.ts +0 -10
- package/dist/esm/drawer/shape/Rectangle.js +0 -85
- package/dist/esm/drawer/typings.d.ts +0 -106
- package/dist/esm/drawer/typings.js +0 -1
- package/dist/esm/measure/AreaMeasure.d.ts +0 -19
- package/dist/esm/measure/AreaSurfaceMeasure.d.ts +0 -30
- package/dist/esm/measure/AreaSurfaceMeasure.js +0 -151
- package/dist/esm/measure/DistanceMeasure.d.ts +0 -19
- package/dist/esm/measure/DistanceMeasure.js +0 -91
- package/dist/esm/measure/DistanceSurfaceMeasure.d.ts +0 -37
- package/dist/esm/measure/DistanceSurfaceMeasure.js +0 -122
- package/dist/esm/measure/Measure.d.ts +0 -111
- package/dist/esm/measure/Measure.js +0 -177
- package/dist/esm/tool/cesiumExtends/Subscriber/index.d.ts +0 -66
- package/dist/esm/tool/cesiumExtends/Subscriber/index.js +0 -246
- package/dist/esm/tool/kriging.d.ts +0 -10
- package/dist/esm/tool/kriging.js +0 -436
|
@@ -1,23 +1,117 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare function pickCartesian3(
|
|
1
|
+
import { Polygon } from '@turf/helpers';
|
|
2
|
+
import { Cartesian2, Cartesian3, type Viewer } from 'deeptwins-cesium';
|
|
3
|
+
/**
|
|
4
|
+
* 从地图中拾取指定屏幕坐标对应的三维笛卡尔坐标
|
|
5
|
+
* @param map - Cesium Viewer实例,用于访问地图场景和相机
|
|
6
|
+
* @param position - 屏幕坐标位置,使用Cartesian2表示
|
|
7
|
+
* @returns 返回拾取到的三维笛卡尔坐标,如果未拾取到则返回undefined
|
|
8
|
+
*/
|
|
9
|
+
export declare function pickCartesian3(map: Viewer, position: Cartesian2): Cartesian3 | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* 计算给定点集合的边界范围
|
|
12
|
+
* @param points - 二维笛卡尔坐标点数组
|
|
13
|
+
* @returns 返回边界范围数组,格式为[left, top, right, bottom]
|
|
14
|
+
*/
|
|
10
15
|
export declare function getBounds(points: Cartesian2[]): number[];
|
|
11
16
|
/**
|
|
12
17
|
* 格式化显示长度
|
|
13
18
|
* @param length 单位米
|
|
14
|
-
* @param unit 目标单位
|
|
15
19
|
*/
|
|
16
|
-
export declare function formatLength(length: number
|
|
20
|
+
export declare function formatLength(length: number): string;
|
|
17
21
|
/**
|
|
18
22
|
* 格式化显示面积
|
|
19
23
|
* @param area 单位米
|
|
20
|
-
* @param unit 目标单位
|
|
21
24
|
*/
|
|
22
|
-
export declare function formatArea(area: number
|
|
23
|
-
|
|
25
|
+
export declare function formatArea(area: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* 计算两点之间的距离
|
|
28
|
+
* @param {Cartesian3} start 点位1
|
|
29
|
+
* @param {Cartesian3} end 点位2
|
|
30
|
+
* @returns {number} 距离/米
|
|
31
|
+
*/
|
|
32
|
+
export declare function getDistance(start: Cartesian3, end: Cartesian3): number;
|
|
33
|
+
/**
|
|
34
|
+
* 计算线段的表面距离
|
|
35
|
+
* @param map 地图实例
|
|
36
|
+
* @param startPoint 线段起点的屏幕坐标
|
|
37
|
+
* @param endPoint 线段终点的屏幕坐标
|
|
38
|
+
* @param splitNum 分段数
|
|
39
|
+
* @returns 表面距离
|
|
40
|
+
*/
|
|
41
|
+
export declare function calculateSurfaceDistance(map: Viewer, startPoint: Cartesian2, endPoint: Cartesian2, splitNum?: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* 计算给定三维坐标点围成区域的面积
|
|
44
|
+
* @param map 地图对象,用于坐标转换
|
|
45
|
+
* @param positions 三维笛卡尔坐标点数组
|
|
46
|
+
* @returns 返回计算得到的区域面积
|
|
47
|
+
*/
|
|
48
|
+
export declare function getArea(map: any, positions: Cartesian3[]): number;
|
|
49
|
+
/**
|
|
50
|
+
* 将笛卡尔坐标转换为经纬度坐标
|
|
51
|
+
* @param map - 地图对象,用于获取场景和椭球体信息
|
|
52
|
+
* @param positions - 笛卡尔坐标数组
|
|
53
|
+
* @returns 经纬度坐标数组,每个元素为[经度, 纬度]格式
|
|
54
|
+
*/
|
|
55
|
+
export declare function cartesian2LngLat(map: any, positions: Cartesian3[]): number[][];
|
|
56
|
+
/**
|
|
57
|
+
* 获取线段上距起点一定距离出的线上点坐标(屏幕坐标)
|
|
58
|
+
* @param startPosition 线段起点(屏幕坐标)
|
|
59
|
+
* @param endPosition 线段终点(屏幕坐标)
|
|
60
|
+
* @param interval 距起点距离
|
|
61
|
+
* @returns -结果坐标(屏幕坐标)
|
|
62
|
+
*/
|
|
63
|
+
export declare function findWindowPositionByPixelInterval(startPosition: Cartesian2, endPosition: Cartesian2, interval: number): Cartesian2;
|
|
64
|
+
/**
|
|
65
|
+
* 计算细分后的,每一小段的笛卡尔坐标距离(也就是大地坐标系距离)
|
|
66
|
+
* @param map 地图实例
|
|
67
|
+
* @param startPoint 每一段线段起点
|
|
68
|
+
* @param endPoint 每一段线段终点
|
|
69
|
+
* @returns 表面距离
|
|
70
|
+
*/
|
|
71
|
+
export declare function calculateDetailSurfaceLength(map: Viewer, startPoint: Cartesian2, endPoint: Cartesian2): number;
|
|
72
|
+
/**
|
|
73
|
+
* 计算给定区域的表面积
|
|
74
|
+
*
|
|
75
|
+
* @param map - Viewer对象,用于地图操作
|
|
76
|
+
* @param positions - Cartesian2坐标数组,定义区域边界
|
|
77
|
+
* @param splitNum - 分割数量,默认为50,用于控制计算精度
|
|
78
|
+
* @returns 返回计算得到的表面积数值
|
|
79
|
+
*/
|
|
80
|
+
export declare function calculateSurfaceArea(map: Viewer, positions: Cartesian2[], splitNum?: number): number;
|
|
81
|
+
/**
|
|
82
|
+
* 将Cartesian2坐标数组转换为turf.js的Polygon几何对象
|
|
83
|
+
* @param positions - Cartesian2坐标点数组,用于构建多边形
|
|
84
|
+
* @returns 返回对应的Polygon几何对象
|
|
85
|
+
*/
|
|
86
|
+
export declare function Cartesian2turfPolygon(positions: Cartesian2[]): Polygon;
|
|
87
|
+
/**
|
|
88
|
+
* 计算两个多边形的交集区域
|
|
89
|
+
* @param poly1 - 第一个多边形
|
|
90
|
+
* @param poly2 - 第二个多边形
|
|
91
|
+
* @returns 交集区域的顶点坐标数组,如果没有交集则返回空数组
|
|
92
|
+
*/
|
|
93
|
+
export declare function getIntersect(poly1: Polygon, poly2: Polygon): Cartesian2[];
|
|
94
|
+
/**
|
|
95
|
+
* 将Turf.js的Polygon对象转换为Cesium的Cartesian2数组
|
|
96
|
+
*
|
|
97
|
+
* @param polygon - Turf.js的Polygon对象,包含经纬度坐标信息
|
|
98
|
+
* @returns 返回一个Cartesian2数组,每个元素对应polygon外环坐标点的二维笛卡尔坐标
|
|
99
|
+
*/
|
|
100
|
+
export declare function turfPolygon2CartesianArr(polygon: Polygon): Cartesian2[];
|
|
101
|
+
/**
|
|
102
|
+
* 计算地图上指定位置围成区域的表面积
|
|
103
|
+
* @param map - 地图查看器实例
|
|
104
|
+
* @param positions - 屏幕坐标点数组
|
|
105
|
+
* @returns 返回世界坐标系中围成区域的表面积
|
|
106
|
+
*/
|
|
107
|
+
export declare function calculateDetailSurfaceArea(map: Viewer, positions: Cartesian2[]): number;
|
|
108
|
+
/**
|
|
109
|
+
* 计算一组世界坐标点所围成区域的面积。
|
|
110
|
+
*
|
|
111
|
+
* 该函数通过将三维笛卡尔坐标转换为地理坐标(经纬度),然后计算相邻点之间的大地测量距离,
|
|
112
|
+
* 并利用平面近似方法估算这些点在地球表面围成的多边形区域的面积。
|
|
113
|
+
*
|
|
114
|
+
* @param positions - 表示多边形顶点的世界坐标数组,每个元素是 Cartesian3 类型。
|
|
115
|
+
* @returns 返回由输入点围成区域的近似面积(单位:平方米)。
|
|
116
|
+
*/
|
|
117
|
+
export declare function getWorldPositionsArea(positions: Cartesian3[]): number;
|
|
@@ -4,13 +4,30 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
6
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import area from '@turf/area';
|
|
8
|
+
import { polygon } from '@turf/helpers';
|
|
9
|
+
import intersect from '@turf/intersect';
|
|
10
|
+
import { randomPoint } from '@turf/random';
|
|
11
|
+
import voronoi from '@turf/voronoi';
|
|
12
|
+
import { Math as CMath, Cartesian2, Cartesian3, Cartographic, EllipsoidGeodesic } from 'deeptwins-cesium';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 从地图中拾取指定屏幕坐标对应的三维笛卡尔坐标
|
|
16
|
+
* @param map - Cesium Viewer实例,用于访问地图场景和相机
|
|
17
|
+
* @param position - 屏幕坐标位置,使用Cartesian2表示
|
|
18
|
+
* @returns 返回拾取到的三维笛卡尔坐标,如果未拾取到则返回undefined
|
|
19
|
+
*/
|
|
20
|
+
export function pickCartesian3(map, position) {
|
|
21
|
+
var ray = map.camera.getPickRay(position);
|
|
22
|
+
if (ray) return map.scene.globe.pick(ray, map.scene);
|
|
12
23
|
return undefined;
|
|
13
24
|
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 计算给定点集合的边界范围
|
|
28
|
+
* @param points - 二维笛卡尔坐标点数组
|
|
29
|
+
* @returns 返回边界范围数组,格式为[left, top, right, bottom]
|
|
30
|
+
*/
|
|
14
31
|
export function getBounds(points) {
|
|
15
32
|
var left = Math.min.apply(Math, _toConsumableArray(points.map(function (item) {
|
|
16
33
|
return item.x;
|
|
@@ -24,35 +41,260 @@ export function getBounds(points) {
|
|
|
24
41
|
var bottom = Math.min.apply(Math, _toConsumableArray(points.map(function (item) {
|
|
25
42
|
return item.y;
|
|
26
43
|
})));
|
|
27
|
-
|
|
28
|
-
return bounds;
|
|
44
|
+
return [left, top, right, bottom];
|
|
29
45
|
}
|
|
30
46
|
|
|
31
47
|
/**
|
|
32
48
|
* 格式化显示长度
|
|
33
49
|
* @param length 单位米
|
|
34
|
-
* @param unit 目标单位
|
|
35
50
|
*/
|
|
36
|
-
export function formatLength(length
|
|
51
|
+
export function formatLength(length) {
|
|
37
52
|
if (length < 1000) {
|
|
38
|
-
return length + '米';
|
|
53
|
+
return length.toFixed(2) + '米';
|
|
39
54
|
}
|
|
40
|
-
return
|
|
55
|
+
return (length / 1000).toFixed(2) + '千米';
|
|
41
56
|
}
|
|
42
57
|
|
|
43
58
|
/**
|
|
44
59
|
* 格式化显示面积
|
|
45
60
|
* @param area 单位米
|
|
46
|
-
* @param unit 目标单位
|
|
47
61
|
*/
|
|
48
|
-
export function formatArea(area
|
|
49
|
-
if (area <
|
|
50
|
-
return area + '平方米';
|
|
62
|
+
export function formatArea(area) {
|
|
63
|
+
if (area < 10000) {
|
|
64
|
+
return area.toFixed(2) + '平方米';
|
|
65
|
+
}
|
|
66
|
+
return (area / 1000000).toFixed(2) + '平方千米';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 计算两点之间的距离
|
|
71
|
+
* @param {Cartesian3} start 点位1
|
|
72
|
+
* @param {Cartesian3} end 点位2
|
|
73
|
+
* @returns {number} 距离/米
|
|
74
|
+
*/
|
|
75
|
+
export function getDistance(start, end) {
|
|
76
|
+
return Cartesian3.distance(start, end);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 计算线段的表面距离
|
|
81
|
+
* @param map 地图实例
|
|
82
|
+
* @param startPoint 线段起点的屏幕坐标
|
|
83
|
+
* @param endPoint 线段终点的屏幕坐标
|
|
84
|
+
* @param splitNum 分段数
|
|
85
|
+
* @returns 表面距离
|
|
86
|
+
*/
|
|
87
|
+
export function calculateSurfaceDistance(map, startPoint, endPoint) {
|
|
88
|
+
var splitNum = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 20;
|
|
89
|
+
var resultDistance = 0;
|
|
90
|
+
var sampleWindowPoints = [startPoint];
|
|
91
|
+
var interval = Math.sqrt(Math.pow(endPoint.x - startPoint.x, 2) + (endPoint.y - startPoint.y, 2)) / splitNum;
|
|
92
|
+
for (var ii = 1; ii <= splitNum; ii += 1) {
|
|
93
|
+
var tempPositon = findWindowPositionByPixelInterval(startPoint, endPoint, ii * interval);
|
|
94
|
+
sampleWindowPoints.push(tempPositon);
|
|
95
|
+
}
|
|
96
|
+
sampleWindowPoints.push(endPoint);
|
|
97
|
+
for (var jj = 0; jj < sampleWindowPoints.length - 1; jj += 1) {
|
|
98
|
+
resultDistance += calculateDetailSurfaceLength(map, sampleWindowPoints[jj + 1], sampleWindowPoints[jj]);
|
|
99
|
+
}
|
|
100
|
+
return resultDistance;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 计算给定三维坐标点围成区域的面积
|
|
105
|
+
* @param map 地图对象,用于坐标转换
|
|
106
|
+
* @param positions 三维笛卡尔坐标点数组
|
|
107
|
+
* @returns 返回计算得到的区域面积
|
|
108
|
+
*/
|
|
109
|
+
export function getArea(map, positions) {
|
|
110
|
+
var lngLats = cartesian2LngLat(map, positions);
|
|
111
|
+
var pg = polygon([[].concat(_toConsumableArray(lngLats), [lngLats[0]])]);
|
|
112
|
+
return area(pg);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 将笛卡尔坐标转换为经纬度坐标
|
|
117
|
+
* @param map - 地图对象,用于获取场景和椭球体信息
|
|
118
|
+
* @param positions - 笛卡尔坐标数组
|
|
119
|
+
* @returns 经纬度坐标数组,每个元素为[经度, 纬度]格式
|
|
120
|
+
*/
|
|
121
|
+
export function cartesian2LngLat(map, positions) {
|
|
122
|
+
return positions.map(function (pos) {
|
|
123
|
+
var cartographic = map.scene.globe.ellipsoid.cartesianToCartographic(pos);
|
|
124
|
+
var lon = +CMath.toDegrees(cartographic.longitude);
|
|
125
|
+
var lat = +CMath.toDegrees(cartographic.latitude);
|
|
126
|
+
return [lon, lat];
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 获取线段上距起点一定距离出的线上点坐标(屏幕坐标)
|
|
132
|
+
* @param startPosition 线段起点(屏幕坐标)
|
|
133
|
+
* @param endPosition 线段终点(屏幕坐标)
|
|
134
|
+
* @param interval 距起点距离
|
|
135
|
+
* @returns -结果坐标(屏幕坐标)
|
|
136
|
+
*/
|
|
137
|
+
export function findWindowPositionByPixelInterval(startPosition, endPosition, interval) {
|
|
138
|
+
var result = new Cartesian2(0, 0);
|
|
139
|
+
var length = Math.sqrt(Math.pow(endPosition.x - startPosition.x, 2) + Math.pow(endPosition.y - startPosition.y, 2));
|
|
140
|
+
if (length < interval) {
|
|
141
|
+
return result;
|
|
142
|
+
} else {
|
|
143
|
+
var x = interval / length * (endPosition.x - startPosition.x) + startPosition.x;
|
|
144
|
+
//alert(interval/length)
|
|
145
|
+
var y = interval / length * (endPosition.y - startPosition.y) + startPosition.y;
|
|
146
|
+
result.x = x;
|
|
147
|
+
result.y = y;
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 计算细分后的,每一小段的笛卡尔坐标距离(也就是大地坐标系距离)
|
|
154
|
+
* @param map 地图实例
|
|
155
|
+
* @param startPoint 每一段线段起点
|
|
156
|
+
* @param endPoint 每一段线段终点
|
|
157
|
+
* @returns 表面距离
|
|
158
|
+
*/
|
|
159
|
+
export function calculateDetailSurfaceLength(map, startPoint, endPoint) {
|
|
160
|
+
var innerS = 0;
|
|
161
|
+
var surfaceStartCartesian3 = pickCartesian3(map, startPoint);
|
|
162
|
+
var surfaceEndCartesian3 = pickCartesian3(map, endPoint);
|
|
163
|
+
if (surfaceStartCartesian3 && surfaceEndCartesian3) {
|
|
164
|
+
var cartographicStart = Cartographic.fromCartesian(surfaceStartCartesian3);
|
|
165
|
+
var cartographicEnd = Cartographic.fromCartesian(surfaceEndCartesian3);
|
|
166
|
+
var geoD = new EllipsoidGeodesic();
|
|
167
|
+
geoD.setEndPoints(cartographicStart, cartographicEnd);
|
|
168
|
+
innerS = geoD.surfaceDistance;
|
|
169
|
+
innerS = Math.sqrt(Math.pow(innerS, 2) + Math.pow(cartographicStart.height - cartographicEnd.height, 2));
|
|
170
|
+
}
|
|
171
|
+
return innerS;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 计算给定区域的表面积
|
|
176
|
+
*
|
|
177
|
+
* @param map - Viewer对象,用于地图操作
|
|
178
|
+
* @param positions - Cartesian2坐标数组,定义区域边界
|
|
179
|
+
* @param splitNum - 分割数量,默认为50,用于控制计算精度
|
|
180
|
+
* @returns 返回计算得到的表面积数值
|
|
181
|
+
*/
|
|
182
|
+
export function calculateSurfaceArea(map, positions) {
|
|
183
|
+
var splitNum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 20;
|
|
184
|
+
var result = 0;
|
|
185
|
+
// 获取边界范围
|
|
186
|
+
var bounds = getBounds(positions);
|
|
187
|
+
// 生成随机点
|
|
188
|
+
var points = randomPoint(splitNum, {
|
|
189
|
+
bbox: [bounds[0], bounds[1], bounds[2], bounds[3]]
|
|
190
|
+
});
|
|
191
|
+
// 转换为主多边形
|
|
192
|
+
var mainPoly = Cartesian2turfPolygon(positions);
|
|
193
|
+
// 生成Voronoi多边形
|
|
194
|
+
var voronoiPolygons = voronoi(points, {
|
|
195
|
+
bbox: [bounds[0], bounds[1], bounds[2], bounds[3]]
|
|
196
|
+
});
|
|
197
|
+
// 遍历Voronoi多边形计算相交区域的表面积
|
|
198
|
+
voronoiPolygons.features.forEach(function (element) {
|
|
199
|
+
var intersectPoints = getIntersect(mainPoly, element.geometry);
|
|
200
|
+
result += calculateDetailSurfaceArea(map, intersectPoints);
|
|
201
|
+
});
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* 将Cartesian2坐标数组转换为turf.js的Polygon几何对象
|
|
207
|
+
* @param positions - Cartesian2坐标点数组,用于构建多边形
|
|
208
|
+
* @returns 返回对应的Polygon几何对象
|
|
209
|
+
*/
|
|
210
|
+
export function Cartesian2turfPolygon(positions) {
|
|
211
|
+
var coordinates = [[]];
|
|
212
|
+
positions.forEach(function (element) {
|
|
213
|
+
coordinates[0].push([element.x, element.y]);
|
|
214
|
+
});
|
|
215
|
+
coordinates[0].push([positions[0].x, positions[0].y]);
|
|
216
|
+
var pg = polygon(coordinates);
|
|
217
|
+
return pg.geometry;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 计算两个多边形的交集区域
|
|
222
|
+
* @param poly1 - 第一个多边形
|
|
223
|
+
* @param poly2 - 第二个多边形
|
|
224
|
+
* @returns 交集区域的顶点坐标数组,如果没有交集则返回空数组
|
|
225
|
+
*/
|
|
226
|
+
export function getIntersect(poly1, poly2) {
|
|
227
|
+
var intersection = intersect(poly1, poly2);
|
|
228
|
+
if ((intersection === null || intersection === void 0 ? void 0 : intersection.geometry) !== undefined) {
|
|
229
|
+
return turfPolygon2CartesianArr(intersection === null || intersection === void 0 ? void 0 : intersection.geometry);
|
|
230
|
+
} else {
|
|
231
|
+
return [];
|
|
51
232
|
}
|
|
52
|
-
return unitedArea + '平方千米';
|
|
53
233
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 将Turf.js的Polygon对象转换为Cesium的Cartesian2数组
|
|
237
|
+
*
|
|
238
|
+
* @param polygon - Turf.js的Polygon对象,包含经纬度坐标信息
|
|
239
|
+
* @returns 返回一个Cartesian2数组,每个元素对应polygon外环坐标点的二维笛卡尔坐标
|
|
240
|
+
*/
|
|
241
|
+
export function turfPolygon2CartesianArr(polygon) {
|
|
242
|
+
return polygon.coordinates[0].map(function (item) {
|
|
243
|
+
return new Cartesian2(item[0], item[1]);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 计算地图上指定位置围成区域的表面积
|
|
249
|
+
* @param map - 地图查看器实例
|
|
250
|
+
* @param positions - 屏幕坐标点数组
|
|
251
|
+
* @returns 返回世界坐标系中围成区域的表面积
|
|
252
|
+
*/
|
|
253
|
+
export function calculateDetailSurfaceArea(map, positions) {
|
|
254
|
+
var worldPositions = [];
|
|
255
|
+
positions.forEach(function (element) {
|
|
256
|
+
var pickResult = pickCartesian3(map, element);
|
|
257
|
+
if (pickResult) worldPositions.push(pickResult);
|
|
258
|
+
});
|
|
259
|
+
return getWorldPositionsArea(worldPositions);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* 计算一组世界坐标点所围成区域的面积。
|
|
264
|
+
*
|
|
265
|
+
* 该函数通过将三维笛卡尔坐标转换为地理坐标(经纬度),然后计算相邻点之间的大地测量距离,
|
|
266
|
+
* 并利用平面近似方法估算这些点在地球表面围成的多边形区域的面积。
|
|
267
|
+
*
|
|
268
|
+
* @param positions - 表示多边形顶点的世界坐标数组,每个元素是 Cartesian3 类型。
|
|
269
|
+
* @returns 返回由输入点围成区域的近似面积(单位:平方米)。
|
|
270
|
+
*/
|
|
271
|
+
export function getWorldPositionsArea(positions) {
|
|
272
|
+
var x = [0];
|
|
273
|
+
var y = [0];
|
|
274
|
+
var geodesic = new EllipsoidGeodesic();
|
|
275
|
+
var radiansPerDegree = Math.PI / 180.0; //角度转化为弧度(rad)
|
|
276
|
+
//数组x,y分别按顺序存储各点的横、纵坐标值
|
|
277
|
+
for (var i = 0; i < positions.length - 1; i += 1) {
|
|
278
|
+
var p1 = positions[i];
|
|
279
|
+
var p2 = positions[i + 1];
|
|
280
|
+
var point1cartographic = Cartographic.fromCartesian(p1);
|
|
281
|
+
var point2cartographic = Cartographic.fromCartesian(p2);
|
|
282
|
+
geodesic.setEndPoints(point1cartographic, point2cartographic);
|
|
283
|
+
var s = Math.sqrt(Math.pow(geodesic.surfaceDistance, 2) + Math.pow(point2cartographic.height - point1cartographic.height, 2));
|
|
284
|
+
var lat1 = point2cartographic.latitude * radiansPerDegree;
|
|
285
|
+
var lon1 = point2cartographic.longitude * radiansPerDegree;
|
|
286
|
+
var lat2 = point1cartographic.latitude * radiansPerDegree;
|
|
287
|
+
var lon2 = point1cartographic.longitude * radiansPerDegree;
|
|
288
|
+
var angle = -Math.atan2(Math.sin(lon1 - lon2) * Math.cos(lat2), Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon1 - lon2));
|
|
289
|
+
if (angle < 0) {
|
|
290
|
+
angle += Math.PI * 2.0;
|
|
291
|
+
}
|
|
292
|
+
y.push(Math.sin(angle) * s + y[i]);
|
|
293
|
+
x.push(Math.cos(angle) * s + x[i]);
|
|
294
|
+
}
|
|
295
|
+
var sum = 0;
|
|
296
|
+
for (var _i = 0; _i < x.length - 1; _i += 1) {
|
|
297
|
+
sum += x[_i] * y[_i + 1] - x[_i + 1] * y[_i];
|
|
298
|
+
}
|
|
299
|
+
return Math.abs(sum + x[x.length - 1] * y[0] - x[0] * y[y.length - 1]) / 2;
|
|
58
300
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 集结地标绘功能
|
|
3
|
+
*/
|
|
4
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
5
|
+
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
6
|
+
import { computeAssemblePoints, newSessionid } from "../utils/PlotCommon";
|
|
7
|
+
import CreateRemindertip from "../utils/ReminderTip";
|
|
8
|
+
var CreateAssemble = function CreateAssemble(viewer, handler, resultList, options, callback) {
|
|
9
|
+
var id = options.id || newSessionid();
|
|
10
|
+
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.BLUE.withAlpha(0.4);
|
|
11
|
+
var onground = options.onground || true;
|
|
12
|
+
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
13
|
+
window.toolTip = '左键点击开始绘制';
|
|
14
|
+
var anchorpoints = [];
|
|
15
|
+
var assemblePolygon = undefined;
|
|
16
|
+
// 左键点击事件
|
|
17
|
+
handler.setInputAction(function (event) {
|
|
18
|
+
window.toolTip = '左键双击键结束绘制';
|
|
19
|
+
var pos = getCatesian3FromPX(viewer, event.position);
|
|
20
|
+
if (!pos || Cesium.defined(assemblePolygon)) return;
|
|
21
|
+
anchorpoints.push(pos);
|
|
22
|
+
var dynamicPositions = new Cesium.CallbackProperty(function () {
|
|
23
|
+
var points = computeAssemblePoints(anchorpoints);
|
|
24
|
+
return new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights(points));
|
|
25
|
+
}, false);
|
|
26
|
+
assemblePolygon = viewer.entities.add({
|
|
27
|
+
name: 'AssemblePolygon',
|
|
28
|
+
id: id,
|
|
29
|
+
polygon: {
|
|
30
|
+
hierarchy: dynamicPositions,
|
|
31
|
+
material: color,
|
|
32
|
+
outline: true,
|
|
33
|
+
outlineColor: Cesium.Color.GREEN,
|
|
34
|
+
heightReference: onground ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
assemblePolygon.GeoType = 'AssemblePolygon'; //记录对象的类型,用户后续编辑等操作
|
|
38
|
+
assemblePolygon.Editable = true; //代表当前对象可编辑,false状态下不可编辑
|
|
39
|
+
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
40
|
+
// 鼠标移动事件
|
|
41
|
+
handler.setInputAction(function (movement) {
|
|
42
|
+
//console.log('鼠标移动事件监测:------创建集结地------');
|
|
43
|
+
var endPos = movement.endPosition;
|
|
44
|
+
CreateRemindertip(window.toolTip, endPos, true);
|
|
45
|
+
var endCartesian = getCatesian3FromPX(viewer, endPos);
|
|
46
|
+
if (!endCartesian || !Cesium.defined(assemblePolygon)) return;
|
|
47
|
+
if (anchorpoints.length === 2) {
|
|
48
|
+
anchorpoints.pop();
|
|
49
|
+
}
|
|
50
|
+
anchorpoints.push(endCartesian);
|
|
51
|
+
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
52
|
+
// 左键双击事件
|
|
53
|
+
handler.setInputAction(function () {
|
|
54
|
+
assemblePolygon.polygon.hierarchy = new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights(computeAssemblePoints(anchorpoints)));
|
|
55
|
+
assemblePolygon.PottingPoint = Cesium.clone(anchorpoints, true);
|
|
56
|
+
assemblePolygon.EditingPoint = Cesium.clone(anchorpoints, true);
|
|
57
|
+
resultList.push(assemblePolygon);
|
|
58
|
+
handler.destroy();
|
|
59
|
+
CreateRemindertip(window.toolTip, null, false);
|
|
60
|
+
if (typeof callback == 'function') callback(assemblePolygon);
|
|
61
|
+
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
62
|
+
};
|
|
63
|
+
export default CreateAssemble;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 创建攻击箭头
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
6
|
+
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
7
|
+
import { getAttackArrowPoints, newSessionid } from "../utils/PlotCommon";
|
|
8
|
+
import CreateRemindertip from "../utils/ReminderTip";
|
|
9
|
+
var CreateAttackArrow = function CreateAttackArrow(viewer, handler, resultList, options, callback) {
|
|
10
|
+
var id = options.id || newSessionid();
|
|
11
|
+
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
12
|
+
var color = options.color ? Cesium.Color.fromCssColorString(options.color) : Cesium.Color.RED;
|
|
13
|
+
var onground = options.onground || true;
|
|
14
|
+
var anchorpoints = [];
|
|
15
|
+
var attackArrow = undefined;
|
|
16
|
+
window.toolTip = '左键点击开始绘制';
|
|
17
|
+
//左键点击事件
|
|
18
|
+
handler.setInputAction(function (event) {
|
|
19
|
+
window.toolTip = '左键添加点,右键撤销,左键双击结束绘制';
|
|
20
|
+
var cartesian = getCatesian3FromPX(viewer, event.position);
|
|
21
|
+
if (!cartesian) return;
|
|
22
|
+
anchorpoints.push(cartesian);
|
|
23
|
+
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
24
|
+
//鼠标移动事件
|
|
25
|
+
handler.setInputAction(function (move) {
|
|
26
|
+
//console.log('鼠标移动事件监测:------创建攻击箭头------');
|
|
27
|
+
var endPos = move.endPosition;
|
|
28
|
+
CreateRemindertip(window.toolTip, endPos, true);
|
|
29
|
+
var cartesian = getCatesian3FromPX(viewer, endPos);
|
|
30
|
+
if (!cartesian) return;
|
|
31
|
+
if (anchorpoints.length >= 2) {
|
|
32
|
+
var dynamicPositions = new Cesium.CallbackProperty(function () {
|
|
33
|
+
var pointlist = getAttackArrowPoints(anchorpoints);
|
|
34
|
+
return new Cesium.PolygonHierarchy(pointlist);
|
|
35
|
+
}, false);
|
|
36
|
+
if (!Cesium.defined(attackArrow)) {
|
|
37
|
+
anchorpoints.push(cartesian);
|
|
38
|
+
attackArrow = viewer.entities.add({
|
|
39
|
+
id: id,
|
|
40
|
+
name: 'AttackArrow',
|
|
41
|
+
polygon: new Cesium.PolygonGraphics({
|
|
42
|
+
hierarchy: dynamicPositions,
|
|
43
|
+
show: true,
|
|
44
|
+
fill: true,
|
|
45
|
+
material: color,
|
|
46
|
+
heightReference: onground ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
attackArrow.GeoType = 'AttackArrow'; //记录对象的类型,用户后续编辑等操作
|
|
50
|
+
attackArrow.Editable = true; //代表当前对象可编辑,false状态下不可编辑
|
|
51
|
+
} else {
|
|
52
|
+
anchorpoints.pop();
|
|
53
|
+
anchorpoints.push(cartesian);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
57
|
+
//左键双击事件
|
|
58
|
+
handler.setInputAction(function (event) {
|
|
59
|
+
anchorpoints.pop();
|
|
60
|
+
anchorpoints.pop(); //因为是双击结束,所以要pop两次,一次是move的结果,一次是单击结果
|
|
61
|
+
attackArrow.PottingPoint = Cesium.clone(anchorpoints, true); //记录对象的节点数据,用户后续编辑等操作
|
|
62
|
+
attackArrow.EditingPoint = Cesium.clone(anchorpoints, true); //记录复杂对象的编辑的节点数据,用户后续编辑等操作
|
|
63
|
+
var pointlist = getAttackArrowPoints(anchorpoints);
|
|
64
|
+
attackArrow.polygon.hierarchy = new Cesium.PolygonHierarchy(pointlist);
|
|
65
|
+
resultList.push(attackArrow);
|
|
66
|
+
handler.destroy();
|
|
67
|
+
CreateRemindertip(window.toolTip, event.position, false);
|
|
68
|
+
if (typeof callback == 'function') callback(attackArrow);
|
|
69
|
+
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
70
|
+
// 右键摁下事件
|
|
71
|
+
handler.setInputAction(function () {
|
|
72
|
+
anchorpoints.pop();
|
|
73
|
+
}, Cesium.ScreenSpaceEventType.RIGHT_DOWN);
|
|
74
|
+
};
|
|
75
|
+
export default CreateAttackArrow;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 广告牌标绘功能
|
|
3
|
+
*/
|
|
4
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
5
|
+
import * as utils from "../../tool/utils";
|
|
6
|
+
import { getCatesian3FromPX } from "../utils/Coordinate";
|
|
7
|
+
import { newSessionid } from "../utils/PlotCommon";
|
|
8
|
+
import CreateRemindertip from "../utils/ReminderTip";
|
|
9
|
+
var CreateBillboard = function CreateBillboard(viewer, handler, resultList, options, callback) {
|
|
10
|
+
var id = options.id || newSessionid();
|
|
11
|
+
var onground = options.onground || true;
|
|
12
|
+
var image = options.image || utils.getDeepTwinsFile('Image/f_point.png');
|
|
13
|
+
if (viewer.entities.getById(id)) throw new Error('the id parameter is an unique value');
|
|
14
|
+
window.toolTip = '左键点击选择点位';
|
|
15
|
+
handler.setInputAction(function (event) {
|
|
16
|
+
var pixPos = event.position;
|
|
17
|
+
var cartesian = getCatesian3FromPX(viewer, pixPos);
|
|
18
|
+
var billboard = viewer.entities.add({
|
|
19
|
+
id: id,
|
|
20
|
+
name: 'Billboard',
|
|
21
|
+
position: cartesian,
|
|
22
|
+
billboard: {
|
|
23
|
+
image: image,
|
|
24
|
+
scale: 1,
|
|
25
|
+
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
|
26
|
+
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
27
|
+
scaleByDistance: new Cesium.NearFarScalar(1.5e1, 1.5, 1.5e5, 0.4),
|
|
28
|
+
heightReference: onground ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE,
|
|
29
|
+
disableDepthTestDistance: 15000 //解决遮挡显示一半的问题
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
billboard.GeoType = 'Billboard'; //记录对象的类型,用户后续编辑等操作
|
|
33
|
+
billboard.PottingPoint = cartesian; //记录对象的节点数据,用户后续编辑等操作
|
|
34
|
+
billboard.EditingPoint = cartesian; //记录对象的节点数据,用户后续编辑等操作
|
|
35
|
+
billboard.Editable = true; //代表当前对象可编辑,false状态下不可编辑
|
|
36
|
+
resultList.push(billboard);
|
|
37
|
+
handler.destroy();
|
|
38
|
+
CreateRemindertip(window.toolTip, event.position, false);
|
|
39
|
+
if (callback && typeof callback == 'function') callback(billboard);
|
|
40
|
+
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
41
|
+
handler.setInputAction(function (movement) {
|
|
42
|
+
//console.log('鼠标移动事件监测:------创建点------');
|
|
43
|
+
var endPos = movement.endPosition;
|
|
44
|
+
CreateRemindertip(window.toolTip, endPos, true);
|
|
45
|
+
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
46
|
+
};
|
|
47
|
+
export default CreateBillboard;
|