@go-home-early/go-home-early98 0.3.1 → 0.3.2

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.

Potentially problematic release.


This version of @go-home-early/go-home-early98 might be problematic. Click here for more details.

Files changed (56) hide show
  1. package/README.md +28 -16
  2. package/dist/go-home-early.umd.js +5 -5
  3. package/package.json +2 -16
  4. package/src/packages/Cesium/DrawMap/DrawJs/CesiumEntityEdit.js +427 -0
  5. package/src/packages/Cesium/DrawMap/DrawJs/CreatePolygonOnGround.js +202 -0
  6. package/src/packages/Cesium/DrawMap/DrawJs/DrawAttackArrow.js +477 -0
  7. package/src/packages/Cesium/DrawMap/DrawJs/DrawBillboard.js +114 -0
  8. package/src/packages/Cesium/DrawMap/DrawJs/DrawCircle.js +311 -0
  9. package/src/packages/Cesium/DrawMap/DrawJs/DrawCircleTY.js +237 -0
  10. package/src/packages/Cesium/DrawMap/DrawJs/DrawCurve.js +256 -0
  11. package/src/packages/Cesium/DrawMap/DrawJs/DrawPincerArrow.js +584 -0
  12. package/src/packages/Cesium/DrawMap/DrawJs/DrawPoint.js +158 -0
  13. package/src/packages/Cesium/DrawMap/DrawJs/DrawPolygon.js +215 -0
  14. package/src/packages/Cesium/DrawMap/DrawJs/DrawPolyline.js +213 -0
  15. package/src/packages/Cesium/DrawMap/DrawJs/DrawPolylineJT.js +218 -0
  16. package/src/packages/Cesium/DrawMap/DrawJs/DrawProFile.js +314 -0
  17. package/src/packages/Cesium/DrawMap/DrawJs/DrawRectangle.js +215 -0
  18. package/src/packages/Cesium/DrawMap/DrawJs/DrawstraightArrow.js +364 -0
  19. package/src/packages/Cesium/DrawMap/DrawJs/MeasurePolygon.js +337 -0
  20. package/src/packages/Cesium/DrawMap/DrawJs/MeasurePolyline.js +285 -0
  21. package/src/packages/Cesium/DrawMap/DrawJs/ReminderTip.js +78 -0
  22. package/src/packages/Cesium/DrawMap/DrawJs/SlopeAspect.js +436 -0
  23. package/src/packages/Cesium/DrawMap/DrawJs/measureLength.js +177 -0
  24. package/src/packages/Cesium/DrawMap/index.vue +272 -0
  25. package/src/packages/Cesium/components/LocationDialog.vue +283 -0
  26. package/src/packages/Cesium/components/Popup.vue +591 -0
  27. package/src/packages/Cesium/components/PoumianDialog.vue +200 -0
  28. package/src/packages/Cesium/imgs/add-off.png +0 -0
  29. package/src/packages/Cesium/imgs/add.png +0 -0
  30. package/src/packages/Cesium/imgs/circle.png +0 -0
  31. package/src/packages/Cesium/imgs/icon-position-blue.png +0 -0
  32. package/src/packages/Cesium/imgs/line.png +0 -0
  33. package/src/packages/Cesium/imgs/map-delete.png +0 -0
  34. package/src/packages/Cesium/imgs/map.png +0 -0
  35. package/src/packages/Cesium/imgs/orientation-bg.svg +14 -0
  36. package/src/packages/Cesium/imgs/orientation.svg +21 -0
  37. package/src/packages/Cesium/imgs/poi.png +0 -0
  38. package/src/packages/Cesium/imgs/point.png +0 -0
  39. package/src/packages/Cesium/imgs/polygon.png +0 -0
  40. package/src/packages/Cesium/imgs/popup/back-popup-img.png +0 -0
  41. package/src/packages/Cesium/imgs/popup/backimg-btn.png +0 -0
  42. package/src/packages/Cesium/imgs/popup/dialog-bd.png +0 -0
  43. package/src/packages/Cesium/imgs/popup/dialog-btn.png +0 -0
  44. package/src/packages/Cesium/imgs/popup/dialog-ft.png +0 -0
  45. package/src/packages/Cesium/imgs/popup/dialog-hd.png +0 -0
  46. package/src/packages/Cesium/imgs/reduce-off.png +0 -0
  47. package/src/packages/Cesium/index.md +292 -0
  48. package/src/packages/Cesium/index.vue +3830 -0
  49. package/src/packages/Cesium/materials/CircularDiffusionMaterialProperty.js +98 -0
  50. package/src/packages/Cesium/materials/CircularRippleMaterialProperty.js +126 -0
  51. package/src/packages/Cesium/materials/PolylineArrowMaterialProperty.js +109 -0
  52. package/src/packages/Cesium/utils/MeasureHeight.js +261 -0
  53. package/src/packages/Cesium/utils/MeasureTools.js +1188 -0
  54. package/src/packages/index.js +33 -0
  55. package/src/packages/utils/charts.js +54 -0
  56. package/src/packages/utils/index.js +50 -0
@@ -0,0 +1,98 @@
1
+ /*
2
+ * @Date: 2023-07-21 15:15:32
3
+ * @LastEditors: zwt
4
+ * @LastEditTime: 2025-12-25 08:43:54
5
+ * @FilePath: .js
6
+ * @Description: 动态扩散
7
+ */
8
+ import * as Cesium from 'cesium';
9
+
10
+ export default class CircularDiffusionMaterialProperty {
11
+ constructor(options) {
12
+ this._definitionChanged = new Cesium.Event();
13
+ this._color = undefined;
14
+ this._colorSubscription = undefined;
15
+ this._time = (new Date()).getTime();
16
+ this.color = options.color;
17
+ this.duration = options.duration;
18
+ };
19
+
20
+ get isConstant() {
21
+ return false;
22
+ }
23
+
24
+ get definitionChanged() {
25
+ return this._definitionChanged;
26
+ }
27
+
28
+ getType(time) {
29
+ return Cesium.Material.CircularDiffusionMaterialType;
30
+ }
31
+
32
+ getValue(time, result) {
33
+ if (!Cesium.defined(result)) {
34
+ result = {};
35
+ }
36
+
37
+ result.color = Cesium.Property.getValueOrClonedDefault(this._color, time, Cesium.Color.WHITE, result.color);
38
+ result.time = (((new Date()).getTime() - this._time) % this.duration) / this.duration;
39
+ return result;
40
+ }
41
+
42
+ equals(other) {
43
+ return (this === other ||
44
+ (other instanceof CircularDiffusionMaterialProperty &&
45
+ Property.equals(this._color, other._color))
46
+ );
47
+ }
48
+ }
49
+
50
+ Object.defineProperties(CircularDiffusionMaterialProperty.prototype, {
51
+ color: Cesium.createPropertyDescriptor('color'),
52
+ });
53
+
54
+ // Cesium.CircularDiffusionMaterialProperty = CircularDiffusionMaterialProperty;
55
+ Cesium.Material.CircularDiffusionMaterialProperty = 'CircularDiffusionMaterialProperty';
56
+ Cesium.Material.CircularDiffusionMaterialType = 'CircularDiffusionMaterialType';
57
+ Cesium.Material.CircularDiffusionMaterialSource =
58
+ `
59
+ czm_material czm_getMaterial(czm_materialInput materialInput)
60
+ {
61
+ czm_material material = czm_getDefaultMaterial(materialInput);
62
+ material.diffuse = 1.5 * color.rgb;
63
+ vec2 st = materialInput.st;
64
+ float dis = distance(st, vec2(0.5, 0.5));
65
+ float per = fract(time);
66
+ if(dis > per * 0.5){
67
+ material.alpha = 0.0;
68
+ discard;
69
+ }else {
70
+ material.alpha = color.a * dis / per / 1.0;
71
+ }
72
+ return material;
73
+ }
74
+ `;
75
+
76
+ Cesium.Material._materialCache.addMaterial(Cesium.Material.CircularDiffusionMaterialType, {
77
+ fabric: {
78
+ type: Cesium.Material.CircularDiffusionMaterialType,
79
+ uniforms: {
80
+ color: new Cesium.Color(1.0, 0.0, 0.0, 1),
81
+ time: 0
82
+ },
83
+ source: Cesium.Material.CircularDiffusionMaterialSource
84
+ },
85
+ translucent: function (material) {
86
+ return true;
87
+ }
88
+ });
89
+ // console.log('成功加载扩散圆材质');
90
+
91
+
92
+ // ? 如何使用
93
+ // import CircularDiffusionMaterialProperty from '@/packages/utils/Material/CircularDiffusionMaterialProperty.js'
94
+
95
+ // material: new CircularDiffusionMaterialProperty({
96
+ // color: new Cesium.Color(1.0, 1.0, 0.0, 0.8),
97
+ // duration: 3000,
98
+ // })
@@ -0,0 +1,126 @@
1
+ /*
2
+ * @Date: 2023-07-21 15:15:32
3
+ * @LastEditors: 傅霄玮
4
+ * @LastEditTime: 2024-07-26 17:06:24
5
+ * @FilePath: .js
6
+ * @Description: 动态扩散
7
+ */
8
+ import * as Cesium from 'cesium';
9
+
10
+ export default class CircularRippleMaterialProperty {
11
+ constructor(options) {
12
+ this._definitionChanged = new Cesium.Event();
13
+ this._color = undefined;
14
+ this._colorSubscription = undefined;
15
+ this._time = (new Date()).getTime();
16
+ this.color = options.color;
17
+ this.duration = options.duration;
18
+ };
19
+
20
+ get isConstant() {
21
+ return false;
22
+ }
23
+
24
+ get definitionChanged() {
25
+ return this._definitionChanged;
26
+ }
27
+
28
+ getType(time) {
29
+ return Cesium.Material.CircularRippleMaterialType;
30
+ }
31
+
32
+ getValue(time, result) {
33
+ if (!Cesium.defined(result)) {
34
+ result = {};
35
+ }
36
+
37
+ result.color = Cesium.Property.getValueOrClonedDefault(this._color, time, Cesium.Color.WHITE, result.color);
38
+ result.time = (((new Date()).getTime() - this._time) % this.duration) / this.duration;
39
+ return result;
40
+ }
41
+
42
+ equals(other) {
43
+ return (this === other ||
44
+ (other instanceof CircularRippleMaterialProperty &&
45
+ Property.equals(this._color, other._color))
46
+ );
47
+ }
48
+ }
49
+
50
+ Object.defineProperties(CircularRippleMaterialProperty.prototype, {
51
+ color: Cesium.createPropertyDescriptor('color'),
52
+ });
53
+
54
+ // Cesium.CircularRippleMaterialProperty = CircularRippleMaterialProperty;
55
+ Cesium.Material.CircularRippleMaterialProperty = 'CircularRippleMaterialProperty';
56
+ Cesium.Material.CircularRippleMaterialType = 'CircularRippleMaterialType';
57
+ Cesium.Material.CircularRippleMaterialSource =
58
+ `
59
+ czm_material czm_getMaterial(czm_materialInput materialInput)
60
+ {
61
+ czm_material material = czm_getDefaultMaterial(materialInput);
62
+ material.diffuse = 1.5 * color.rgb;
63
+ vec2 st = materialInput.st;
64
+ float dis = distance(st, vec2(0.5, 0.5));
65
+ float per = fract(czm_frameNumber * time / 1000.0);
66
+ if(count == 1.0){
67
+ if(dis > per * 0.5){
68
+ discard;
69
+ }else {
70
+ material.alpha = color.a * dis / per / 2.0;
71
+ }
72
+ } else {
73
+ vec3 str = materialInput.str;
74
+ if(abs(str.z) > 0.001){
75
+ discard;
76
+ }
77
+ if(dis > 0.5){
78
+ discard;
79
+ }else {
80
+ float perDis = 0.5 / count;
81
+ float disNum;
82
+ float bl = 0.0;
83
+ for(int i = 0; i <= 999; i++){
84
+ if(float(i) <= count){
85
+ disNum = perDis * float(i) - dis + per / count;
86
+ if(disNum > 0.0){
87
+ if(disNum < perDis){
88
+ bl = 1.0 - disNum / perDis;
89
+ }else if(disNum - perDis < perDis){
90
+ bl = 1.0 - abs(1.0 - disNum / perDis);
91
+ }
92
+ material.alpha = pow(bl,(1.0 + 10.0 * (1.0 - gradient)));
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ return material;
99
+ }
100
+ `;
101
+
102
+ Cesium.Material._materialCache.addMaterial(Cesium.Material.CircularRippleMaterialType, {
103
+ fabric: {
104
+ type: Cesium.Material.CircularRippleMaterialType,
105
+ uniforms: {
106
+ color: new Cesium.Color(1.0, 0.0, 0.0, 1),
107
+ time: 0,
108
+ count: 2,
109
+ gradient: 0.2
110
+ },
111
+ source: Cesium.Material.CircularRippleMaterialSource
112
+ },
113
+ translucent: function (material) {
114
+ return true;
115
+ }
116
+ });
117
+ // console.log('成功加载扩散圆材质');
118
+
119
+
120
+ // ? 如何使用
121
+ // import CircularRippleMaterialProperty from '@/packages/utils/Material/CircularRippleMaterialProperty.js'
122
+
123
+ // material: new CircularRippleMaterialProperty({
124
+ // color: new Cesium.Color(1.0, 1.0, 0.0, 0.8),
125
+ // duration: 3000,
126
+ // })
@@ -0,0 +1,109 @@
1
+ /**
2
+ * PolylineArrowMaterialProperty
3
+ * @param {*} options
4
+ * @constructor
5
+ *
6
+ *流动箭头线
7
+ *
8
+ * how to use
9
+ * let material = new PolylineArrowMaterialProperty({
10
+ color: Cesium.Color.RED,
11
+ duration: 1000
12
+ });
13
+ entity.polyline.material = material;
14
+ */
15
+ import * as Cesium from 'cesium';
16
+
17
+ function PolylineArrowMaterialProperty(options) {
18
+ options = options || {};
19
+ this._definitionChanged = new Cesium.Event();
20
+ this._color = undefined;
21
+ this._colorSubscription = undefined;
22
+ this.color = options.color || Cesium.Color.YELLOW;
23
+ this.duration = options.duration || 3000;
24
+ this._time = new Date().getTime();
25
+ }
26
+
27
+ Object.defineProperties(PolylineArrowMaterialProperty.prototype, {
28
+ isConstant: {
29
+ get: function () {
30
+ return false;
31
+ },
32
+ },
33
+ definitionChanged: {
34
+ get: function () {
35
+ return this._definitionChanged;
36
+ },
37
+ },
38
+ color: Cesium.createPropertyDescriptor("color"),
39
+ });
40
+
41
+ PolylineArrowMaterialProperty.prototype.getType = function (time) {
42
+ return "PolylineArrow";
43
+ };
44
+
45
+ PolylineArrowMaterialProperty.prototype.getValue = function (time, result) {
46
+ if (!Cesium.defined(result)) {
47
+ result = {};
48
+ }
49
+ result.color = Cesium.Property.getValueOrClonedDefault(
50
+ this._color,
51
+ time,
52
+ Cesium.Color.WHITE,
53
+ result.color
54
+ );
55
+ result.time =
56
+ ((new Date().getTime() - this._time) % this.duration) / this.duration;
57
+ return result;
58
+ };
59
+
60
+ PolylineArrowMaterialProperty.prototype.equals = function (other) {
61
+ return (
62
+ this === other ||
63
+ (other instanceof PolylineArrowMaterialProperty &&
64
+ Cesium.Property.equals(this.color, other.color))
65
+ );
66
+ };
67
+
68
+ Cesium.Material.PolylineArrowType = "PolylineArrow";
69
+
70
+ // 在 Cesium 1.95 (Vue2项目里) 下,无法通过 import/require 的方式引入图片,会报错
71
+ // 因此改用纯色箭头
72
+ // Cesium.Material.PolylineArrowImage = "static/images/arrow.png";
73
+
74
+ Cesium.Material._materialCache.addMaterial(Cesium.Material.PolylineArrowType, {
75
+ fabric: {
76
+ type: Cesium.Material.PolylineArrowType,
77
+ uniforms: {
78
+ color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
79
+ time: -20.0,
80
+ },
81
+ source: `
82
+ czm_material czm_getMaterial(czm_materialInput materialInput) {
83
+ czm_material material = czm_getDefaultMaterial(materialInput);
84
+ vec2 st = materialInput.st;
85
+ float t = fract(st.s * 2.0 - time);
86
+ float alpha = 1.0;
87
+ float width = 0.1;
88
+
89
+ if (t < (1.0 - width)) {
90
+ alpha = step(0.5 - width / 2.0, st.t) - step(0.5 + width / 2.0, st.t);
91
+ } else {
92
+ float headWidth = width * 2.0;
93
+ float headHeight = width * 2.0;
94
+ float k = (headHeight / headWidth) * (t - 1.0 + headWidth);
95
+ alpha = step(0.5 - k, st.t) - step(0.5 + k, st.t);
96
+ }
97
+
98
+ material.diffuse = color.rgb;
99
+ material.alpha = alpha * color.a;
100
+ return material;
101
+ }
102
+ `,
103
+ },
104
+ translucent: function (material) {
105
+ return material.uniforms.color.alpha < 1.0;
106
+ },
107
+ });
108
+
109
+ export default PolylineArrowMaterialProperty;
@@ -0,0 +1,261 @@
1
+ //高度测量类
2
+ export default class MeasureHeight {
3
+ constructor(viewer) {
4
+ this.viewer = viewer;
5
+ this.initEvents();
6
+ this.positions = [];
7
+ this.vertexEntities = [];
8
+ this.labelEntity = undefined;
9
+ this.measureHeight = 0; //测量结果
10
+ }
11
+
12
+ //初始化事件
13
+ initEvents() {
14
+ this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
15
+ this.MeasureStartEvent = new Cesium.Event(); //开始事件
16
+ this.MeasureEndEvent = new Cesium.Event(); //结束事件
17
+ }
18
+
19
+ //激活
20
+ activate() {
21
+ this.deactivate();
22
+ this.registerEvents(); //注册鼠标事件
23
+ //设置鼠标状态
24
+ this.viewer.enableCursorStyle = false;
25
+ this.viewer._element.style.cursor = 'default';
26
+ this.isMeasure = true;
27
+ this.circleRadius = 0.1;
28
+ this.measureHeight = 0;
29
+ this.positions = [];
30
+ }
31
+
32
+ //禁用
33
+ deactivate() {
34
+ if (!this.isMeasure) return;
35
+ this.unRegisterEvents();
36
+ this.viewer._element.style.cursor = 'pointer';
37
+ this.viewer.enableCursorStyle = true;
38
+ this.isMeasure = false;
39
+ }
40
+
41
+ //清空绘制
42
+ clear() {
43
+ //清除线对象
44
+ this.viewer.entities.remove(this.lineEntity);
45
+ this.lineEntity = undefined;
46
+
47
+ //清除文本
48
+ this.viewer.entities.remove(this.labelEntity);
49
+ this.labelEntity = undefined;
50
+
51
+ //移除圆
52
+ this.removeCircleEntity();
53
+
54
+ //清除节点
55
+ this.vertexEntities.forEach(item => {
56
+ this.viewer.entities.remove(item);
57
+ });
58
+ this.vertexEntities = [];
59
+ }
60
+
61
+ //创建线对象
62
+ createLineEntity() {
63
+ this.lineEntity = this.viewer.entities.add({
64
+ polyline: {
65
+ positions: new Cesium.CallbackProperty(e => {
66
+ return this.positions;
67
+ }, false),
68
+ width: 2,
69
+ material: Cesium.Color.YELLOW,
70
+ depthFailMaterial: new Cesium.PolylineDashMaterialProperty({
71
+ color: Cesium.Color.RED,
72
+ }),
73
+ }
74
+ });
75
+ }
76
+
77
+ //创建结果文本标签
78
+ createLabel() {
79
+ this.labelEntity = this.viewer.entities.add({
80
+ position: new Cesium.CallbackProperty(e => {
81
+ return this.positions[this.positions.length - 1]; //返回最后一个点
82
+ }, false),
83
+ label: {
84
+ text: "",
85
+ // scale: 0.5,
86
+ font: 'normal 40px MicroSoft YaHei',
87
+ // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 5000),
88
+ scaleByDistance: new Cesium.NearFarScalar(500, 1, 1500, 0.4),
89
+ verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
90
+ style: Cesium.LabelStyle.FILL_AND_OUTLINE,
91
+ pixelOffset: new Cesium.Cartesian2(0, -30),
92
+ outlineWidth: 9,
93
+ outlineColor: Cesium.Color.WHITE,
94
+ disableDepthTestDistance: Number.POSITIVE_INFINITY, // 新增,禁用深度
95
+ }
96
+ });
97
+ }
98
+
99
+ //创建线节点
100
+ createVertex(index) {
101
+ let vertexEntity = this.viewer.entities.add({
102
+ position: new Cesium.CallbackProperty(e => {
103
+ return this.positions[index];
104
+ }, false),
105
+ type: "MeasureHeightVertex",
106
+ point: {
107
+ color: Cesium.Color.FUCHSIA,
108
+ pixelSize: 6,
109
+ // disableDepthTestDistance: 2000,
110
+ disableDepthTestDistance: Number.POSITIVE_INFINITY, // 新增,禁用深度
111
+ },
112
+ });
113
+ this.vertexEntities.push(vertexEntity);
114
+ }
115
+
116
+ //创建圆 这样方便看出水平面的高低
117
+ createCircleEntitiy() {
118
+ // 计算点的高度
119
+ function positionHeight(position) {
120
+ // 使用 Cesium 来计算 Cartesian3 点的高度
121
+ const cartographic = Cesium.Cartographic.fromCartesian(position);
122
+ return cartographic.height;
123
+ }
124
+ this.circleEntity = this.viewer.entities.add({
125
+ position: new Cesium.CallbackProperty(e => {
126
+ return this.positions[this.positions.length - 1]; //返回最后一个点
127
+ }, false),
128
+ ellipse: {
129
+ height: new Cesium.CallbackProperty(e => {
130
+ return positionHeight(this.positions[this.positions.length - 1]);
131
+ }, false),
132
+ // semiMinorAxis: new Cesium.CallbackProperty(e => {
133
+ // return this.circleRadius;
134
+ // }, false),
135
+ // semiMajorAxis: new Cesium.CallbackProperty(e => {
136
+ // return this.circleRadius;
137
+ // }, false),
138
+ semiMajorAxis: 300.0,
139
+ semiMinorAxis: 200.0,
140
+ material: Cesium.Color.YELLOW.withAlpha(0.5),
141
+ disableDepthTestDistance: Number.POSITIVE_INFINITY, // 新增,禁用深度
142
+ },
143
+ });
144
+ }
145
+
146
+ //删除圆
147
+ removeCircleEntity() {
148
+ this.viewer.entities.remove(this.circleEntity);
149
+ this.circleEntity = undefined;
150
+ }
151
+
152
+ //注册鼠标事件
153
+ registerEvents() {
154
+ this.leftClickEvent();
155
+ this.rightClickEvent();
156
+ this.mouseMoveEvent();
157
+ }
158
+
159
+ //左键点击事件
160
+ leftClickEvent() {
161
+ //单击鼠标左键画点点击事件
162
+ this.handler.setInputAction(e => {
163
+ this.viewer._element.style.cursor = 'default';
164
+ let position = this.viewer.scene.pickPosition(e.position);
165
+ if (!position) {
166
+ const ellipsoid = this.viewer.scene.globe.ellipsoid;
167
+ position = this.viewer.scene.camera.pickEllipsoid(e.position, ellipsoid);
168
+ }
169
+ if (!position) return;
170
+
171
+ if (this.positions.length == 0) { //首次点击
172
+ this.positions.push(position);
173
+ this.createVertex(0);
174
+ this.createLineEntity();
175
+ this.createCircleEntitiy();
176
+ this.createLabel();
177
+ } else { //第二次点击结束测量
178
+ this.measureEnd();
179
+ }
180
+ }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
181
+ }
182
+
183
+ //鼠标移动事件
184
+ mouseMoveEvent() {
185
+ this.handler.setInputAction(e => {
186
+ if (!this.isMeasure) return;
187
+ this.viewer._element.style.cursor = 'default';
188
+ let position = this.viewer.scene.pickPosition(e.endPosition);
189
+ if (!position) {
190
+ position = this.viewer.scene.camera.pickEllipsoid(e.startPosition, this.viewer.scene.globe.ellipsoid);
191
+ }
192
+ if (!position) return;
193
+ this.handleMoveEvent(position);
194
+ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
195
+ }
196
+
197
+ //处理鼠标移动
198
+ handleMoveEvent(position) {
199
+
200
+ // 计算两点的水平距离
201
+ function getDistanceH(point1, point2) {
202
+ // 获取两个点的 Cartographic 经纬度坐标
203
+ const cartographic1 = Cesium.Cartographic.fromCartesian(point1);
204
+ const cartographic2 = Cesium.Cartographic.fromCartesian(point2);
205
+ // 计算经纬度平面上的水平距离
206
+ const geodesic = new Cesium.EllipsoidGeodesic(cartographic1, cartographic2);
207
+ return geodesic.surfaceDistance;
208
+ }
209
+
210
+ // 将 Cartesian3 点转换为经纬度和高度数组
211
+ function cartesian3Point3(position) {
212
+ // 将 Cartesian3 转换为 Cartographic,并返回经度、纬度、高度数组
213
+ const cartographic = Cesium.Cartographic.fromCartesian(position);
214
+ return [
215
+ Cesium.Math.toDegrees(cartographic.longitude),
216
+ Cesium.Math.toDegrees(cartographic.latitude),
217
+ cartographic.height
218
+ ];
219
+ }
220
+
221
+ if (this.positions.length < 1) return;
222
+ let firstPoint = cartesian3Point3(this.positions[0]); //第一个点
223
+ let movePoint = cartesian3Point3(position); //鼠标移动点
224
+ const h = movePoint[2] - firstPoint[2];
225
+ firstPoint[2] = movePoint[2];
226
+ const twoPosition = Cesium.Cartesian3.fromDegrees(firstPoint[0], firstPoint[1], movePoint[2]);
227
+ if (this.positions.length < 2) {
228
+ this.positions.push(twoPosition);
229
+ this.createVertex(1);
230
+ } else {
231
+ this.positions[1] = twoPosition;
232
+ this.measureHeight = h.toFixed(3);
233
+ this.labelEntity.label.text = "高度:" + this.measureHeight + " 米";
234
+ }
235
+ //计算圆的半径
236
+ this.circleRadius = getDistanceH(this.positions[0], position);
237
+ }
238
+
239
+ //右键事件
240
+ rightClickEvent() {
241
+ this.handler.setInputAction(e => {
242
+ if (this.isMeasure) {
243
+ this.deactivate();
244
+ this.clear();
245
+ }
246
+ }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
247
+ }
248
+
249
+ //测量结束
250
+ measureEnd() {
251
+ this.deactivate();
252
+ this.MeasureEndEvent.raiseEvent(this.measureHeight); //触发结束事件 传入结果
253
+ }
254
+
255
+ //解除鼠标事件
256
+ unRegisterEvents() {
257
+ this.handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
258
+ this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
259
+ this.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
260
+ }
261
+ }