cesium_dev_kit 1.0.45 → 1.0.47

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.
@@ -1,117 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Analysis", {
7
- enumerable: true,
8
- get: function () {
9
- return _Analysis.Analysis;
10
- }
11
- });
12
- Object.defineProperty(exports, "AttackArrow", {
13
- enumerable: true,
14
- get: function () {
15
- return _AttackArrow.AttackArrow;
16
- }
17
- });
18
- Object.defineProperty(exports, "Base", {
19
- enumerable: true,
20
- get: function () {
21
- return _Base.Base;
22
- }
23
- });
24
- Object.defineProperty(exports, "Control", {
25
- enumerable: true,
26
- get: function () {
27
- return _Control.Control;
28
- }
29
- });
30
- Object.defineProperty(exports, "CustomCesiumPlugin", {
31
- enumerable: true,
32
- get: function () {
33
- return _CustomCesiumPlugin.CustomCesiumPlugin;
34
- }
35
- });
36
- Object.defineProperty(exports, "Draw", {
37
- enumerable: true,
38
- get: function () {
39
- return _Draw.Draw;
40
- }
41
- });
42
- Object.defineProperty(exports, "Graphics", {
43
- enumerable: true,
44
- get: function () {
45
- return _Graphics.Graphics;
46
- }
47
- });
48
- Object.defineProperty(exports, "Material", {
49
- enumerable: true,
50
- get: function () {
51
- return _Material.Material;
52
- }
53
- });
54
- Object.defineProperty(exports, "Math2d", {
55
- enumerable: true,
56
- get: function () {
57
- return _Math2d.Math2d;
58
- }
59
- });
60
- Object.defineProperty(exports, "Math3d", {
61
- enumerable: true,
62
- get: function () {
63
- return _Math3d.Math3d;
64
- }
65
- });
66
- Object.defineProperty(exports, "PassEffect", {
67
- enumerable: true,
68
- get: function () {
69
- return _PassEffect.PassEffect;
70
- }
71
- });
72
- Object.defineProperty(exports, "PincerArrow", {
73
- enumerable: true,
74
- get: function () {
75
- return _PincerArrow.PincerArrow;
76
- }
77
- });
78
- Object.defineProperty(exports, "Plugin", {
79
- enumerable: true,
80
- get: function () {
81
- return _Plugin.Plugin;
82
- }
83
- });
84
- Object.defineProperty(exports, "Primitive", {
85
- enumerable: true,
86
- get: function () {
87
- return _Primitive.Primitive;
88
- }
89
- });
90
- Object.defineProperty(exports, "Shaders", {
91
- enumerable: true,
92
- get: function () {
93
- return _Shaders.Shaders;
94
- }
95
- });
96
- Object.defineProperty(exports, "StraightArrow", {
97
- enumerable: true,
98
- get: function () {
99
- return _StraightArrow.StraightArrow;
100
- }
101
- });
102
- var _Graphics = require("./Graphics");
103
- var _Material = require("./Material");
104
- var _Shaders = require("./Shaders");
105
- var _Base = require("./Base");
106
- var _Math3d = require("./Math3d");
107
- var _Primitive = require("./Primitive");
108
- var _Draw = require("./Draw");
109
- var _Math2d = require("./Math2d");
110
- var _PassEffect = require("./PassEffect");
111
- var _CustomCesiumPlugin = require("./CustomCesiumPlugin");
112
- var _Control = require("./Control");
113
- var _Plugin = require("./Plugin");
114
- var _Analysis = require("./Analysis");
115
- var _AttackArrow = require("./plot/AttackArrow");
116
- var _StraightArrow = require("./plot/StraightArrow");
117
- var _PincerArrow = require("./plot/PincerArrow");
@@ -1,266 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.AttackArrow = void 0;
7
- var _BasePlot = require("./BasePlot");
8
- let Cesium = null;
9
- //攻击箭头
10
- var AttackArrow = function (viewer, cesiumGlobal) {
11
- _BasePlot.BasePlot.call(this, viewer, cesiumGlobal);
12
- Cesium = cesiumGlobal;
13
- this.type = "AttackArrow";
14
- this.fillMaterial = Cesium.Color.RED.withAlpha(0.5);
15
- };
16
- exports.AttackArrow = AttackArrow;
17
- AttackArrow.prototype = {
18
- disable: function () {
19
- this.positions = [];
20
- if (this.arrowEntity) {
21
- this.viewer.entities.remove(this.arrowEntity);
22
- this.arrowEntity = null;
23
- }
24
- this.state = -1;
25
- if (this.handler) {
26
- this.handler.destroy();
27
- this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
28
- }
29
- if (this.floatPoint) {
30
- this.viewer.entities.remove(this.floatPoint);
31
- this.floatPoint = null;
32
- }
33
- if (this.selectPoint) {
34
- this.viewer.entities.remove(this.selectPoint);
35
- this.selectPoint = null;
36
- }
37
- for (var i = 0; i < this.pointArr.length; i++) {
38
- if (this.pointArr[i]) this.viewer.entities.remove(this.pointArr[i]);
39
- }
40
- if (this.modifyHandler) {
41
- this.modifyHandler.destroy();
42
- this.modifyHandler = null;
43
- }
44
- this.clickStep = 0;
45
- },
46
- startDraw: function (cb) {
47
- this.objId = Number(new Date().getTime() + "" + Number(Math.random() * 1000).toFixed(0));
48
- var $this = this;
49
- this.state = 1;
50
- if (!this.handler) {
51
- this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
52
- }
53
- this.handler.setInputAction(function (evt) {
54
- //单机开始绘制
55
- var cartesian;
56
- cartesian = getCatesian3FromPX(evt.position, $this.viewer);
57
- if (!cartesian) return;
58
- // var ray = viewer.camera.getPickRay(evt.position);
59
- // if (!ray) return;
60
- // var cartesian = viewer.scene.globe.pick(ray, $this.viewer.scene);
61
- if ($this.positions.length == 0) {
62
- $this.floatPoint = $this.creatPoint(cartesian);
63
- $this.floatPoint.wz = -1;
64
- }
65
- $this.positions.push(cartesian);
66
- var point = $this.creatPoint(cartesian);
67
- if ($this.positions.length > 2) {
68
- point.wz = $this.positions.length - 1; //点对应的在positions中的位置 屏蔽mouseMove里往postions添加时 未创建点
69
- } else {
70
- point.wz = $this.positions.length; //点对应的在positions中的位置
71
- }
72
-
73
- $this.pointArr.push(point);
74
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
75
- this.handler.setInputAction(function (evt) {
76
- //移动时绘制面
77
- if (!$this.floatPoint || $this.positions.length < 2) return;
78
- // var ray = viewer.camera.getPickRay(evt.endPosition);
79
- // if (!ray) return;
80
- // var cartesian = viewer.scene.globe.pick(ray, $this.viewer.scene);
81
- var cartesian;
82
- cartesian = getCatesian3FromPX(evt.endPosition, $this.viewer);
83
- if (!cartesian) return;
84
- $this.floatPoint.position.setValue(cartesian);
85
- if ($this.positions.length >= 2) {
86
- if (!Cesium.defined($this.arrowEntity)) {
87
- $this.positions.push(cartesian);
88
- $this.arrowEntity = $this.showArrowOnMap($this.positions);
89
- $this.arrowEntity.objId = $this.objId;
90
- cb && cb($this.objId);
91
- } else {
92
- $this.positions.pop();
93
- $this.positions.push(cartesian);
94
- }
95
- }
96
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
97
- this.handler.setInputAction(function (evt) {
98
- //右击结束绘制
99
- // var ray = viewer.camera.getPickRay(evt.position);
100
- // if (!ray) return;
101
- // var cartesian = viewer.scene.globe.pick(ray, $this.viewer.scene);
102
- var cartesian;
103
- cartesian = getCatesian3FromPX(evt.position, $this.viewer);
104
- if (!cartesian) return;
105
- for (var i = 0; i < $this.pointArr.length; i++) {
106
- $this.pointArr[i].show = false;
107
- }
108
- $this.floatPoint.show = false;
109
- $this.viewer.entities.remove($this.floatPoint);
110
- $this.floatPoint = null;
111
- var point = $this.creatPoint(cartesian);
112
- point.show = false;
113
- point.wz = $this.positions.length;
114
- $this.pointArr.push(point);
115
- $this.positions = [];
116
- $this.pointArr = [];
117
- $this.arrowEntity = null;
118
- }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
119
- },
120
- createByData: function (data) {
121
- //根据传入的数据构建箭头
122
- this.positions = []; //控制点
123
- this.state = -1; //state用于区分当前的状态 0 为删除 1为添加 2为编辑
124
- this.floatPoint = null;
125
- this.pointArr = []; //中间各点
126
- this.selectPoint = null;
127
- this.clickStep = 0; //用于控制点的移动结束
128
- this.modifyHandler = null;
129
- var arr = [];
130
- for (var i = 0; i < data.length; i++) {
131
- var cart3 = Cesium.Cartesian3.fromDegrees(data[i][0], data[i][1]);
132
- arr.push(cart3);
133
- }
134
- this.positions = arr;
135
- //构建控制点
136
- for (var i = 0; i < this.positions.length; i++) {
137
- var point = this.creatPoint(this.positions[i]);
138
- point.show = false;
139
- point.wz = i + 1;
140
- this.pointArr.push(point);
141
- }
142
- this.arrowEntity = this.showArrowOnMap(this.positions);
143
- this.arrowEntity.objId = this.objId;
144
- },
145
- startModify: function () {
146
- //修改箭头
147
- this.state = 2;
148
- var $this = this;
149
- for (var i = 0; i < $this.pointArr.length; i++) {
150
- $this.pointArr[i].show = true;
151
- }
152
- if (!this.modifyHandler) this.modifyHandler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
153
- this.modifyHandler.setInputAction(function (evt) {
154
- //单机开始绘制
155
- var pick = $this.viewer.scene.pick(evt.position);
156
- if (Cesium.defined(pick) && pick.id) {
157
- $this.clickStep++;
158
- if (!pick.id.objId) $this.selectPoint = pick.id;
159
- } else {
160
- //激活移动点之后 单机面之外 移除这个事件
161
- for (var i = 0; i < $this.pointArr.length; i++) {
162
- $this.pointArr[i].show = false;
163
- }
164
- if ($this.floatPoint) $this.floatPoint.show = false;
165
- $this.state = -1;
166
- $this.modifyHandler.destroy();
167
- $this.modifyHandler = null;
168
- }
169
- if ($this.clickStep == 2) {
170
- $this.clickStep = 0;
171
- // var ray = $this.viewer.camera.getPickRay(evt.position);
172
- // if (!ray) return;
173
- // var cartesian = $this.viewer.scene.globe.pick(ray, $this.viewer.scene);
174
- var cartesian;
175
- cartesian = getCatesian3FromPX(evt.position, $this.viewer);
176
- if (!cartesian) return;
177
- if ($this.selectPoint) {
178
- $this.selectPoint.position.setValue(cartesian);
179
- $this.selectPoint = null;
180
- }
181
- }
182
- ;
183
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
184
- this.modifyHandler.setInputAction(function (evt) {
185
- //单机开始绘制
186
- // var ray = $this.viewer.camera.getPickRay(evt.endPosition);
187
- // if (!ray) return;
188
- // var cartesian = $this.viewer.scene.globe.pick(ray, $this.viewer.scene);
189
- var cartesian;
190
- cartesian = getCatesian3FromPX(evt.endPosition, $this.viewer);
191
- if (!cartesian) return;
192
- if ($this.selectPoint) {
193
- $this.selectPoint.position.setValue(cartesian);
194
- $this.positions[$this.selectPoint.wz - 1] = cartesian; //上方的wz用于此处辨识修改positions数组里的哪个元素
195
- } else {
196
- return;
197
- }
198
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
199
- },
200
- getLnglats: function () {
201
- var arr = [];
202
- for (var i = 0; i < this.positions.length; i++) {
203
- var item = this.cartesianToLatlng(this.positions[i]);
204
- arr.push(item);
205
- }
206
- return arr;
207
- },
208
- getPositions: function () {
209
- //获取直角箭头中的控制点 世界坐标
210
- return this.positions;
211
- },
212
- creatPoint: function (cartesian) {
213
- var point = this.viewer.entities.add({
214
- position: cartesian,
215
- point: {
216
- pixelSize: 10,
217
- color: Cesium.Color.YELLOW
218
- }
219
- });
220
- point.attr = "editPoint";
221
- return point;
222
- },
223
- showArrowOnMap: function (positions) {
224
- var $this = this;
225
- var update = function () {
226
- //计算面
227
- if (positions.length < 3) {
228
- return null;
229
- }
230
- var lnglatArr = [];
231
- for (var i = 0; i < positions.length; i++) {
232
- var lnglat = $this.cartesianToLatlng(positions[i]);
233
- lnglatArr.push(lnglat);
234
- }
235
- var res = $this.xp.algorithm.tailedAttackArrow(lnglatArr, Cesium);
236
- var index = JSON.stringify(res.polygonalPoint).indexOf("null");
237
- var returnData = [];
238
- if (index == -1) returnData = res.polygonalPoint;
239
- return new Cesium.PolygonHierarchy(returnData);
240
- };
241
- return this.viewer.entities.add({
242
- id: $this.objId,
243
- polygon: new Cesium.PolygonGraphics({
244
- hierarchy: new Cesium.CallbackProperty(update, false),
245
- show: true,
246
- fill: true,
247
- material: $this.fillMaterial
248
- })
249
- });
250
- },
251
- cartesianToLatlng: function (cartesian) {
252
- var latlng = this.viewer.scene.globe.ellipsoid.cartesianToCartographic(cartesian);
253
- var lat = Cesium.Math.toDegrees(latlng.latitude);
254
- var lng = Cesium.Math.toDegrees(latlng.longitude);
255
- return [lng, lat];
256
- }
257
- };
258
- AttackArrow.prototype = Object.create(Object.assign({}, AttackArrow.prototype, _BasePlot.BasePlot.prototype));
259
- AttackArrow.prototype.constructor = AttackArrow;
260
- function getCatesian3FromPX(px, viewer) {
261
- var cartesian;
262
- var ray = viewer.camera.getPickRay(px);
263
- if (!ray) return null;
264
- cartesian = viewer.scene.globe.pick(ray, viewer.scene);
265
- return cartesian;
266
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.BasePlot = BasePlot;
7
- var _algorithm = require("./algorithm");
8
- let Cesium = null;
9
- function BasePlot(viewer, cesiumGlobal) {
10
- this.viewer = viewer;
11
- Cesium = cesiumGlobal;
12
- this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
13
- this.fillMaterial = Cesium.Color.RED.withAlpha(0.5);
14
- this.positions = []; //控制点
15
- this.state = -1; //state用于区分当前的状态 0 为删除 1为添加 2为编辑
16
- this.floatPoint = null;
17
- this.arrowEntity = null;
18
- this.pointArr = []; //中间各点
19
- this.selectPoint = null;
20
- this.clickStep = 0; //用于控制点的移动结束
21
- this.modifyHandler = null;
22
- this.xp = _algorithm.xp;
23
- }
24
- BasePlot.prototype.clear = function () {
25
- //清除绘制箭头
26
- this.state = 0;
27
- if (this.firstPoint) this.viewer.entities.remove(this.firstPoint);
28
- if (this.floatPoint) this.viewer.entities.remove(this.floatPoint);
29
- if (this.arrowEntity) this.viewer.entities.remove(this.arrowEntity);
30
- this.state = -1;
31
- };
32
- BasePlot.prototype.disableHandler = function () {
33
- if (this.handler) {
34
- this.handler.destroy();
35
- this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
36
- }
37
- if (this.modifyHandler) {
38
- this.modifyHandler.destroy();
39
- this.modifyHandler = null;
40
- }
41
- };
@@ -1,278 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PincerArrow = void 0;
7
- var _BasePlot = require("./BasePlot");
8
- let Cesium = null;
9
- //钳击箭头
10
- var PincerArrow = function (viewer, cesiumGlobal) {
11
- _BasePlot.BasePlot.call(this, viewer, cesiumGlobal);
12
- Cesium = cesiumGlobal;
13
- this.type = "PincerArrow";
14
- this.fillMaterial = Cesium.Color.YELLOW.withAlpha(0.8);
15
- };
16
- exports.PincerArrow = PincerArrow;
17
- PincerArrow.prototype = {
18
- disable: function () {
19
- this.positions = [];
20
- if (this.arrowEntity) {
21
- this.viewer.entities.remove(this.arrowEntity);
22
- this.arrowEntity = null;
23
- }
24
- this.state = -1;
25
- if (this.handler) {
26
- this.handler.destroy();
27
- this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
28
- }
29
- if (this.floatPoint) {
30
- this.viewer.entities.remove(this.floatPoint);
31
- this.floatPoint = null;
32
- }
33
- if (this.selectPoint) {
34
- this.viewer.entities.remove(this.selectPoint);
35
- this.selectPoint = null;
36
- }
37
- for (var i = 0; i < this.pointArr.length; i++) {
38
- if (this.pointArr[i]) this.viewer.entities.remove(this.pointArr[i]);
39
- }
40
- if (this.modifyHandler) {
41
- this.modifyHandler.destroy();
42
- this.modifyHandler = null;
43
- }
44
- this.clickStep = 0;
45
- },
46
- startDraw: function (cb) {
47
- // 创建id
48
- this.objId = Number(new Date().getTime() + "" + Number(Math.random() * 1000).toFixed(0));
49
- var $this = this;
50
- this.state = 1;
51
- this.handler.setInputAction(function (evt) {
52
- //单机开始绘制
53
- // var ray = viewer.camera.getPickRay(evt.position);
54
- // if (!ray) return;
55
- // var cartesian = viewer.scene.globe.pick(ray, $this.viewer.scene);
56
- var cartesian;
57
- cartesian = getCatesian3FromPX(evt.position, $this.viewer);
58
- if (!cartesian) return;
59
- if ($this.positions.length == 0) {
60
- $this.floatPoint = $this.creatPoint(cartesian);
61
- }
62
- if ($this.positions.length > 4) {
63
- //结束绘制
64
- var point = $this.creatPoint(cartesian);
65
- point.wz = $this.positions.length;
66
- $this.pointArr.push(point);
67
- for (var i = 0; i < $this.pointArr.length; i++) {
68
- $this.pointArr[i].show = false;
69
- }
70
- if ($this.floatPoint) {
71
- //移除动态点
72
- $this.floatPoint.show = false;
73
- $this.viewer.entities.remove($this.floatPoint);
74
- $this.floatPoint = null;
75
- }
76
- $this.positions = [];
77
- $this.pointArr = [];
78
- $this.arrowEntity = null;
79
- } else {
80
- $this.positions.push(cartesian);
81
- var point = $this.creatPoint(cartesian);
82
- if ($this.positions.length > 2) {
83
- point.wz = $this.positions.length - 1; //点对应的在positions中的位置 屏蔽mouseMove里往postions添加时 未创建点
84
- } else {
85
- point.wz = $this.positions.length; //点对应的在positions中的位置
86
- }
87
-
88
- $this.pointArr.push(point);
89
- }
90
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
91
- this.handler.setInputAction(function (evt) {
92
- //移动时绘制面
93
- if (!$this.floatPoint || $this.positions.length < 2) return;
94
- // var ray = viewer.camera.getPickRay(evt.endPosition);
95
- // if (!ray) return;
96
- // var cartesian = viewer.scene.globe.pick(ray, $this.viewer.scene);
97
- var cartesian;
98
- cartesian = getCatesian3FromPX(evt.endPosition, $this.viewer);
99
- if (!cartesian) return;
100
- $this.floatPoint.position.setValue(cartesian);
101
- if ($this.positions.length >= 2) {
102
- if (!Cesium.defined($this.arrowEntity)) {
103
- $this.positions.push(cartesian);
104
- $this.arrowEntity = $this.showArrowOnMap($this.positions);
105
- $this.arrowEntity.objId = $this.objId;
106
- cb && cb($this.objId); // 将实体id 返回
107
- } else {
108
- $this.positions.pop();
109
- $this.positions.push(cartesian);
110
- }
111
- }
112
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
113
- this.handler.setInputAction(function (evt) {
114
- //右击结束绘制
115
- if ($this.positions.length >= 4) {
116
- var cartesian;
117
- cartesian = getCatesian3FromPX(evt.position, $this.viewer);
118
- if (!cartesian) return;
119
- for (var i = 0; i < $this.pointArr.length; i++) {
120
- $this.pointArr[i].show = false;
121
- }
122
- $this.floatPoint.show = false;
123
- $this.viewer.entities.remove($this.floatPoint);
124
- $this.floatPoint = null;
125
- var point = $this.creatPoint(cartesian);
126
- point.show = false;
127
- point.wz = $this.positions.length;
128
- $this.pointArr.push(point);
129
- $this.positions = [];
130
- $this.pointArr = [];
131
- $this.arrowEntity = null;
132
- }
133
- }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
134
- },
135
- createByData: function (data) {
136
- //根据传入的数据构建箭头
137
- this.positions = []; //控制点
138
- this.state = -1; //state用于区分当前的状态 0 为删除 1为添加 2为编辑
139
- this.floatPoint = null;
140
- this.pointArr = []; //中间各点
141
- this.selectPoint = null;
142
- this.clickStep = 0; //用于控制点的移动结束
143
- this.modifyHandler = null;
144
- var arr = [];
145
- for (var i = 0; i < data.length; i++) {
146
- var cart3 = Cesium.Cartesian3.fromDegrees(data[i][0], data[i][1]);
147
- arr.push(cart3);
148
- }
149
- this.positions = arr;
150
- //构建控制点
151
- for (var i = 0; i < this.positions.length; i++) {
152
- var point = this.creatPoint(this.positions[i]);
153
- point.show = false;
154
- point.wz = i + 1;
155
- this.pointArr.push(point);
156
- }
157
- this.arrowEntity = this.showArrowOnMap(this.positions);
158
- this.arrowEntity.objId = this.objId;
159
- },
160
- startModify: function () {
161
- //修改箭头
162
- this.state = 2;
163
- var $this = this;
164
- for (var i = 0; i < $this.pointArr.length; i++) {
165
- $this.pointArr[i].show = true;
166
- }
167
- if (!this.modifyHandler) this.modifyHandler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
168
- this.modifyHandler.setInputAction(function (evt) {
169
- //单机开始绘制
170
- var pick = $this.viewer.scene.pick(evt.position);
171
- if (Cesium.defined(pick) && pick.id) {
172
- $this.clickStep++;
173
- if (!pick.id.objId) $this.selectPoint = pick.id;
174
- } else {
175
- for (var i = 0; i < $this.pointArr.length; i++) {
176
- $this.pointArr[i].show = false;
177
- }
178
- $this.state = -1;
179
- $this.modifyHandler.destroy(); //激活移动点之后 单机面之外 移除这个事件
180
- $this.modifyHandler = null;
181
- }
182
- if ($this.clickStep == 2) {
183
- $this.clickStep = 0;
184
- // var ray = $this.viewer.camera.getPickRay(evt.position);
185
- // if (!ray) return;
186
- // var cartesian = $this.viewer.scene.globe.pick(ray, $this.viewer.scene);
187
- var cartesian;
188
- cartesian = getCatesian3FromPX(evt.position, $this.viewer);
189
- if (!cartesian) return;
190
- if ($this.selectPoint) {
191
- $this.selectPoint.position.setValue(cartesian);
192
- $this.selectPoint = null;
193
- }
194
- }
195
- ;
196
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
197
- this.modifyHandler.setInputAction(function (evt) {
198
- //单机开始绘制
199
- // var ray = $this.viewer.camera.getPickRay(evt.endPosition);
200
- // if (!ray) return;
201
- // var cartesian = $this.viewer.scene.globe.pick(ray, $this.viewer.scene);
202
- var cartesian;
203
- cartesian = getCatesian3FromPX(evt.endPosition, $this.viewer);
204
- if (!cartesian) return;
205
- if ($this.selectPoint) {
206
- $this.selectPoint.position.setValue(cartesian);
207
- $this.positions[$this.selectPoint.wz - 1] = cartesian; //上方的wz用于此处辨识修改positions数组里的哪个元素
208
- } else {
209
- return;
210
- }
211
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
212
- },
213
- getLnglats: function () {
214
- //获取直角箭头中的关键点 经纬度
215
- var arr = [];
216
- for (var i = 0; i < this.positions.length; i++) {
217
- var item = this.cartesianToLatlng(this.positions[i]);
218
- arr.push(item);
219
- }
220
- return arr;
221
- },
222
- getPositions: function () {
223
- //获取直角箭头中的关键点 世界坐标
224
- return this.positions;
225
- },
226
- creatPoint: function (cartesian) {
227
- return this.viewer.entities.add({
228
- position: cartesian,
229
- point: {
230
- pixelSize: 10,
231
- color: Cesium.Color.YELLOW
232
- }
233
- });
234
- },
235
- showArrowOnMap: function (positions) {
236
- var $this = this;
237
- var update = function () {
238
- //计算面
239
- if (positions.length < 3) {
240
- return null;
241
- }
242
- var lnglatArr = [];
243
- for (var i = 0; i < positions.length; i++) {
244
- var lnglat = $this.cartesianToLatlng(positions[i]);
245
- lnglatArr.push(lnglat);
246
- }
247
- var res = $this.xp.algorithm.doubleArrow(lnglatArr, Cesium);
248
- var returnData = [];
249
- var index = JSON.stringify(res.polygonalPoint).indexOf("null");
250
- if (index == -1) returnData = res.polygonalPoint;
251
- return new Cesium.PolygonHierarchy(returnData);
252
- };
253
- return this.viewer.entities.add({
254
- id: $this.objId,
255
- polygon: new Cesium.PolygonGraphics({
256
- hierarchy: new Cesium.CallbackProperty(update, false),
257
- show: true,
258
- fill: true,
259
- material: $this.fillMaterial
260
- })
261
- });
262
- },
263
- cartesianToLatlng: function (cartesian) {
264
- var latlng = this.viewer.scene.globe.ellipsoid.cartesianToCartographic(cartesian);
265
- var lat = Cesium.Math.toDegrees(latlng.latitude);
266
- var lng = Cesium.Math.toDegrees(latlng.longitude);
267
- return [lng, lat];
268
- }
269
- };
270
- PincerArrow.prototype = Object.create(Object.assign({}, PincerArrow.prototype, _BasePlot.BasePlot.prototype));
271
- PincerArrow.prototype.constructor = PincerArrow;
272
- function getCatesian3FromPX(px, viewer) {
273
- var cartesian;
274
- var ray = viewer.camera.getPickRay(px);
275
- if (!ray) return null;
276
- cartesian = viewer.scene.globe.pick(ray, viewer.scene);
277
- return cartesian;
278
- }