cesium_dev_kit 1.0.49 → 1.0.50
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/.babelrc +13 -0
- package/dist/ColorDeal.js +59 -0
- package/dist/common.js +40 -0
- package/dist/index.js +24 -13563
- package/dist/initConf.js +188 -0
- package/dist/libs/Analysis.js +779 -0
- package/dist/libs/Base.js +950 -0
- package/dist/libs/ChartLayer.js +24 -0
- package/dist/libs/Control.js +947 -0
- package/dist/libs/CustomCesiumPlugin.js +92 -0
- package/dist/libs/DomUtil.js +105 -0
- package/dist/libs/Draw.js +704 -0
- package/dist/libs/Graphics.js +734 -0
- package/dist/libs/MapvLayer.js +26 -0
- package/dist/libs/Material.js +590 -0
- package/dist/libs/Math2d.js +559 -0
- package/dist/libs/Math3d.js +646 -0
- package/dist/libs/PassEffect.js +154 -0
- package/dist/libs/Plugin.js +751 -0
- package/dist/libs/Primitive.js +1559 -0
- package/dist/libs/Shaders.js +298 -0
- package/dist/libs/ThreeJs.js +190 -0
- package/dist/libs/cesium-plugin.js +3387 -0
- package/dist/libs/index.js +117 -0
- package/dist/libs/plot/AttackArrow.js +266 -0
- package/dist/libs/plot/BasePlot.js +41 -0
- package/dist/libs/plot/PincerArrow.js +278 -0
- package/dist/libs/plot/StraightArrow.js +244 -0
- package/dist/libs/plot/algorithm.js +315 -0
- package/dist/libs/plot/index.js +19 -0
- package/dist/libs/plot/plotUtil.js +242 -0
- package/index.js +2 -2
- package/package.json +5 -12
- package/dist/index.min.js +0 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StraightArrow = void 0;
|
|
7
|
+
var _BasePlot = require("./BasePlot");
|
|
8
|
+
let Cesium = null;
|
|
9
|
+
//直线箭头
|
|
10
|
+
var StraightArrow = function (viewer, cesiumGlobal) {
|
|
11
|
+
_BasePlot.BasePlot.call(this, viewer, cesiumGlobal);
|
|
12
|
+
Cesium = cesiumGlobal;
|
|
13
|
+
this.type = "StraightArrow";
|
|
14
|
+
this.fillMaterial = Cesium.Color.fromCssColorString('#0000FF').withAlpha(0.8);
|
|
15
|
+
};
|
|
16
|
+
exports.StraightArrow = StraightArrow;
|
|
17
|
+
StraightArrow.prototype = {
|
|
18
|
+
disable: function () {
|
|
19
|
+
this.positions = [];
|
|
20
|
+
if (this.firstPoint) {
|
|
21
|
+
this.viewer.entities.remove(this.firstPoint);
|
|
22
|
+
this.firstPoint = null;
|
|
23
|
+
}
|
|
24
|
+
if (this.floatPoint) {
|
|
25
|
+
this.viewer.entities.remove(this.floatPoint);
|
|
26
|
+
this.floatPoint = null;
|
|
27
|
+
}
|
|
28
|
+
if (this.arrowEntity) {
|
|
29
|
+
this.viewer.entities.remove(this.arrowEntity);
|
|
30
|
+
this.arrowEntity = null;
|
|
31
|
+
}
|
|
32
|
+
this.state = -1;
|
|
33
|
+
if (this.handler) {
|
|
34
|
+
this.handler.destroy();
|
|
35
|
+
this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
|
|
36
|
+
}
|
|
37
|
+
if (this.selectPoint) {
|
|
38
|
+
this.viewer.entities.remove(this.selectPoint);
|
|
39
|
+
this.selectPoint = null;
|
|
40
|
+
}
|
|
41
|
+
if (this.modifyHandler) {
|
|
42
|
+
this.modifyHandler.destroy();
|
|
43
|
+
this.modifyHandler = null;
|
|
44
|
+
}
|
|
45
|
+
this.clickStep = 0;
|
|
46
|
+
},
|
|
47
|
+
startDraw: function (cb) {
|
|
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 cartesian;
|
|
54
|
+
cartesian = getCatesian3FromPX(evt.position, $this.viewer);
|
|
55
|
+
if (!cartesian) return;
|
|
56
|
+
if ($this.positions.length == 0) {
|
|
57
|
+
$this.firstPoint = $this.creatPoint(cartesian);
|
|
58
|
+
$this.firstPoint.type = "firstPoint";
|
|
59
|
+
$this.floatPoint = $this.creatPoint(cartesian);
|
|
60
|
+
$this.floatPoint.type = "floatPoint";
|
|
61
|
+
$this.positions.push(cartesian);
|
|
62
|
+
}
|
|
63
|
+
$this.firstPoint.position.setValue(cartesian);
|
|
64
|
+
$this.firstPoint.show = true;
|
|
65
|
+
if ($this.positions && $this.positions.length == 3) {
|
|
66
|
+
$this.firstPoint.show = false;
|
|
67
|
+
$this.positions = [];
|
|
68
|
+
$this.pointArr = [];
|
|
69
|
+
$this.arrowEntity = null;
|
|
70
|
+
}
|
|
71
|
+
// 增加最后一个光标点
|
|
72
|
+
$this.positions.push(cartesian.clone());
|
|
73
|
+
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
74
|
+
this.handler.setInputAction(function (evt) {
|
|
75
|
+
//移动时绘制面
|
|
76
|
+
if ($this.positions.length < 1) return;
|
|
77
|
+
var cartesian;
|
|
78
|
+
cartesian = getCatesian3FromPX(evt.endPosition, $this.viewer);
|
|
79
|
+
if (!cartesian) return;
|
|
80
|
+
// 修改浮动光标位置
|
|
81
|
+
$this.floatPoint.position.setValue(cartesian);
|
|
82
|
+
if ($this.positions.length >= 2) {
|
|
83
|
+
if (!Cesium.defined($this.arrowEntity)) {
|
|
84
|
+
$this.positions.push(cartesian);
|
|
85
|
+
$this.arrowEntity = $this.showArrowOnMap($this.positions);
|
|
86
|
+
cb && cb($this.objId);
|
|
87
|
+
} else {
|
|
88
|
+
$this.positions.pop();
|
|
89
|
+
$this.positions.push(cartesian);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
93
|
+
this.handler.setInputAction(function (evt) {
|
|
94
|
+
var cartesian;
|
|
95
|
+
cartesian = getCatesian3FromPX(evt.position, $this.viewer);
|
|
96
|
+
if (!cartesian) return;
|
|
97
|
+
$this.firstPoint.show = false;
|
|
98
|
+
$this.positions = [];
|
|
99
|
+
$this.pointArr = [];
|
|
100
|
+
$this.arrowEntity = null;
|
|
101
|
+
$this.positions.push(cartesian.clone());
|
|
102
|
+
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
103
|
+
},
|
|
104
|
+
startModify: function () {
|
|
105
|
+
//修改箭头
|
|
106
|
+
this.state = 2;
|
|
107
|
+
this.firstPoint.show = true;
|
|
108
|
+
this.floatPoint.show = true;
|
|
109
|
+
var $this = this;
|
|
110
|
+
this.clickStep = 0;
|
|
111
|
+
if (!this.modifyHandler) this.modifyHandler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
|
|
112
|
+
this.modifyHandler.setInputAction(function (evt) {
|
|
113
|
+
//单机开始绘制
|
|
114
|
+
var pick = $this.viewer.scene.pick(evt.position);
|
|
115
|
+
if (Cesium.defined(pick) && pick.id) {
|
|
116
|
+
$this.clickStep++;
|
|
117
|
+
if (!pick.id.objId) $this.selectPoint = pick.id;
|
|
118
|
+
} else {
|
|
119
|
+
//激活移动点之后 单机面之外 移除这个事件
|
|
120
|
+
$this.modifyHandler.destroy();
|
|
121
|
+
$this.modifyHandler = null;
|
|
122
|
+
$this.firstPoint.show = false;
|
|
123
|
+
$this.floatPoint.show = false;
|
|
124
|
+
$this.state = -1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//选中点后 第二次点击 则重新定位该点
|
|
128
|
+
if ($this.clickStep == 2) {
|
|
129
|
+
$this.clickStep = 0;
|
|
130
|
+
var cartesian;
|
|
131
|
+
cartesian = getCatesian3FromPX(evt.position, $this.viewer);
|
|
132
|
+
if (!cartesian) return;
|
|
133
|
+
if ($this.selectPoint) {
|
|
134
|
+
$this.selectPoint.position.setValue(cartesian);
|
|
135
|
+
$this.selectPoint = null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
;
|
|
139
|
+
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
140
|
+
this.modifyHandler.setInputAction(function (evt) {
|
|
141
|
+
if ($this.selectPoint) {
|
|
142
|
+
var cartesian;
|
|
143
|
+
cartesian = getCatesian3FromPX(evt.endPosition, $this.viewer);
|
|
144
|
+
if (!cartesian) return;
|
|
145
|
+
$this.selectPoint.position.setValue(cartesian);
|
|
146
|
+
if ($this.selectPoint.type == "firstPoint") {
|
|
147
|
+
$this.positions[1] = cartesian;
|
|
148
|
+
}
|
|
149
|
+
if ($this.selectPoint.type == "floatPoint") {
|
|
150
|
+
$this.positions[2] = cartesian;
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
156
|
+
},
|
|
157
|
+
createByData: function (data) {
|
|
158
|
+
//通过传入的经纬度数组 构建箭头
|
|
159
|
+
this.state = -1;
|
|
160
|
+
this.positions = [];
|
|
161
|
+
var arr = [];
|
|
162
|
+
for (var i = 0; i < data.length; i++) {
|
|
163
|
+
var cart3 = Cesium.Cartesian3.fromDegrees(data[i][0], data[i][1]);
|
|
164
|
+
arr.push(cart3);
|
|
165
|
+
}
|
|
166
|
+
this.positions = arr;
|
|
167
|
+
this.firstPoint = this.creatPoint(this.positions[1]);
|
|
168
|
+
this.firstPoint.type = "firstPoint";
|
|
169
|
+
this.floatPoint = this.creatPoint(this.positions[2]);
|
|
170
|
+
this.floatPoint.type = "floatPoint";
|
|
171
|
+
this.arrowEntity = this.showArrowOnMap(this.positions);
|
|
172
|
+
this.firstPoint.show = false;
|
|
173
|
+
this.floatPoint.show = false;
|
|
174
|
+
this.arrowEntity.objId = this.objId;
|
|
175
|
+
},
|
|
176
|
+
getLnglats: function () {
|
|
177
|
+
var arr = [];
|
|
178
|
+
for (var i = 0; i < this.positions.length; i++) {
|
|
179
|
+
var item = this.cartesianToLatlng(this.positions[i]);
|
|
180
|
+
arr.push(item);
|
|
181
|
+
}
|
|
182
|
+
return arr;
|
|
183
|
+
},
|
|
184
|
+
getPositions: function () {
|
|
185
|
+
//获取直角箭头中的关键点
|
|
186
|
+
return this.positions;
|
|
187
|
+
},
|
|
188
|
+
creatPoint: function (cartesian) {
|
|
189
|
+
var point = this.viewer.entities.add({
|
|
190
|
+
position: cartesian,
|
|
191
|
+
point: {
|
|
192
|
+
pixelSize: 10,
|
|
193
|
+
color: Cesium.Color.YELLOW
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
point.attr = "editPoint";
|
|
197
|
+
return point;
|
|
198
|
+
},
|
|
199
|
+
showArrowOnMap: function (positions) {
|
|
200
|
+
var $this = this;
|
|
201
|
+
var update = function () {
|
|
202
|
+
if (positions.length < 2) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
var p1 = positions[1];
|
|
206
|
+
var p2 = positions[2];
|
|
207
|
+
var firstPoint = $this.cartesianToLatlng(p1);
|
|
208
|
+
var endPoints = $this.cartesianToLatlng(p2);
|
|
209
|
+
var arrow = [];
|
|
210
|
+
var res = $this.xp.algorithm.fineArrow([firstPoint[0], firstPoint[1]], [endPoints[0], endPoints[1]], Cesium);
|
|
211
|
+
var index = JSON.stringify(res).indexOf("null");
|
|
212
|
+
if (index != -1) return [];
|
|
213
|
+
for (var i = 0; i < res.length; i++) {
|
|
214
|
+
var c3 = new Cesium.Cartesian3(res[i].x, res[i].y, res[i].z);
|
|
215
|
+
arrow.push(c3);
|
|
216
|
+
}
|
|
217
|
+
return new Cesium.PolygonHierarchy(arrow);
|
|
218
|
+
};
|
|
219
|
+
return this.viewer.entities.add({
|
|
220
|
+
id: $this.objId,
|
|
221
|
+
polygon: new Cesium.PolygonGraphics({
|
|
222
|
+
hierarchy: new Cesium.CallbackProperty(update, false),
|
|
223
|
+
show: true,
|
|
224
|
+
fill: true,
|
|
225
|
+
material: $this.fillMaterial
|
|
226
|
+
})
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
cartesianToLatlng: function (cartesian) {
|
|
230
|
+
var latlng = this.viewer.scene.globe.ellipsoid.cartesianToCartographic(cartesian);
|
|
231
|
+
var lat = Cesium.Math.toDegrees(latlng.latitude);
|
|
232
|
+
var lng = Cesium.Math.toDegrees(latlng.longitude);
|
|
233
|
+
return [lng, lat];
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
StraightArrow.prototype = Object.create(Object.assign({}, StraightArrow.prototype, _BasePlot.BasePlot.prototype));
|
|
237
|
+
StraightArrow.prototype.constructor = StraightArrow;
|
|
238
|
+
function getCatesian3FromPX(px, viewer) {
|
|
239
|
+
var cartesian;
|
|
240
|
+
var ray = viewer.camera.getPickRay(px);
|
|
241
|
+
if (!ray) return null;
|
|
242
|
+
cartesian = viewer.scene.globe.pick(ray, viewer.scene);
|
|
243
|
+
return cartesian;
|
|
244
|
+
}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.xp = void 0;
|
|
7
|
+
var _plotUtil = require("./plotUtil");
|
|
8
|
+
var xp = {
|
|
9
|
+
version: "1.0.0",
|
|
10
|
+
createTime: "2018.6.19",
|
|
11
|
+
author: "xupinhui"
|
|
12
|
+
};
|
|
13
|
+
exports.xp = xp;
|
|
14
|
+
var doubleArrowDefualParam = {
|
|
15
|
+
type: "doublearrow",
|
|
16
|
+
headHeightFactor: .25,
|
|
17
|
+
headWidthFactor: .3,
|
|
18
|
+
neckHeightFactor: .85,
|
|
19
|
+
fixPointCount: 4,
|
|
20
|
+
neckWidthFactor: .15
|
|
21
|
+
};
|
|
22
|
+
var tailedAttackArrowDefualParam = {
|
|
23
|
+
headHeightFactor: .18,
|
|
24
|
+
headWidthFactor: .3,
|
|
25
|
+
neckHeightFactor: .85,
|
|
26
|
+
neckWidthFactor: .15,
|
|
27
|
+
tailWidthFactor: .1,
|
|
28
|
+
headTailFactor: .8,
|
|
29
|
+
swallowTailFactor: 1
|
|
30
|
+
};
|
|
31
|
+
var fineArrowDefualParam = {
|
|
32
|
+
tailWidthFactor: 0.15,
|
|
33
|
+
neckWidthFactor: 0.20,
|
|
34
|
+
headWidthFactor: 0.25,
|
|
35
|
+
headAngle: Math.PI / 8.5,
|
|
36
|
+
neckAngle: Math.PI / 13
|
|
37
|
+
};
|
|
38
|
+
xp.algorithm = {};
|
|
39
|
+
xp.algorithm.doubleArrow = function (inputPoint, Cesium) {
|
|
40
|
+
this.connPoint = null;
|
|
41
|
+
this.tempPoint4 = null;
|
|
42
|
+
this.points = inputPoint;
|
|
43
|
+
var result = {
|
|
44
|
+
controlPoint: null,
|
|
45
|
+
polygonalPoint: null
|
|
46
|
+
};
|
|
47
|
+
//获取已经点击的坐标数
|
|
48
|
+
var t = inputPoint.length;
|
|
49
|
+
if (!(2 > t)) {
|
|
50
|
+
if (2 == t) return inputPoint;
|
|
51
|
+
var o = this.points[0],
|
|
52
|
+
//第一个点
|
|
53
|
+
e = this.points[1],
|
|
54
|
+
//第二个点
|
|
55
|
+
r = this.points[2],
|
|
56
|
+
//第三个点
|
|
57
|
+
t = inputPoint.length; //获取已经点击的坐标数
|
|
58
|
+
//下面的是移动点位后的坐标
|
|
59
|
+
3 == t ? this.tempPoint4 = xp.algorithm.getTempPoint4(o, e, r) : this.tempPoint4 = this.points[3], 3 == t || 4 == t ? this.connPoint = _plotUtil.P.PlotUtils.mid(o, e) : this.connPoint = this.points[4];
|
|
60
|
+
var n, g;
|
|
61
|
+
_plotUtil.P.PlotUtils.isClockWise(o, e, r) ? (n = xp.algorithm.getArrowPoints(o, this.connPoint, this.tempPoint4, !1), g = xp.algorithm.getArrowPoints(this.connPoint, e, r, !0)) : (n = xp.algorithm.getArrowPoints(e, this.connPoint, r, !1), g = xp.algorithm.getArrowPoints(this.connPoint, o, this.tempPoint4, !0));
|
|
62
|
+
var i = n.length,
|
|
63
|
+
s = (i - 5) / 2,
|
|
64
|
+
a = n.slice(0, s),
|
|
65
|
+
l = n.slice(s, s + 5),
|
|
66
|
+
u = n.slice(s + 5, i),
|
|
67
|
+
c = g.slice(0, s),
|
|
68
|
+
p = g.slice(s, s + 5),
|
|
69
|
+
h = g.slice(s + 5, i);
|
|
70
|
+
c = _plotUtil.P.PlotUtils.getBezierPoints(c);
|
|
71
|
+
var d = _plotUtil.P.PlotUtils.getBezierPoints(h.concat(a.slice(1)));
|
|
72
|
+
u = _plotUtil.P.PlotUtils.getBezierPoints(u);
|
|
73
|
+
var f = c.concat(p, d, l, u);
|
|
74
|
+
var newArray = xp.algorithm.array2Dto1D(f);
|
|
75
|
+
result.controlPoint = [o, e, r, this.tempPoint4, this.connPoint];
|
|
76
|
+
result.polygonalPoint = Cesium.Cartesian3.fromDegreesArray(newArray);
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}, xp.algorithm.threeArrow = function (inputPoint) {
|
|
80
|
+
this.connPoint = null;
|
|
81
|
+
this.tempPoint4 = null;
|
|
82
|
+
this.tempPoint5 = null;
|
|
83
|
+
this.points = inputPoint;
|
|
84
|
+
var result = {
|
|
85
|
+
controlPoint: null,
|
|
86
|
+
polygonalPoint: null
|
|
87
|
+
};
|
|
88
|
+
//获取已经点击的坐标数
|
|
89
|
+
var t = inputPoint.length;
|
|
90
|
+
if (t >= 2) {
|
|
91
|
+
if (t == 2) {
|
|
92
|
+
return inputPoint;
|
|
93
|
+
}
|
|
94
|
+
var o = this.points[0],
|
|
95
|
+
//第一个点
|
|
96
|
+
e = this.points[1],
|
|
97
|
+
//第二个点
|
|
98
|
+
r = this.points[2],
|
|
99
|
+
//第三个点
|
|
100
|
+
t = inputPoint.length; //获取已经点击的坐标数
|
|
101
|
+
//下面的是移动点位后的坐标
|
|
102
|
+
if (t == 3) {
|
|
103
|
+
this.tempPoint4 = xp.algorithm.getTempPoint4(o, e, r);
|
|
104
|
+
this.tempPoint5 = _plotUtil.P.PlotUtils.mid(r, this.tempPoint4);
|
|
105
|
+
} else {
|
|
106
|
+
this.tempPoint4 = this.points[3];
|
|
107
|
+
this.tempPoint5 = this.points[4];
|
|
108
|
+
}
|
|
109
|
+
if (t < 6) {
|
|
110
|
+
this.connPoint = _plotUtil.P.PlotUtils.mid(o, e);
|
|
111
|
+
} else {
|
|
112
|
+
this.connPoint = this.points[5];
|
|
113
|
+
}
|
|
114
|
+
var n, g;
|
|
115
|
+
if (_plotUtil.P.PlotUtils.isClockWise(o, e, r)) {
|
|
116
|
+
n = xp.algorithm.getArrowPoints(o, this.connPoint, this.tempPoint4, !1);
|
|
117
|
+
g = xp.algorithm.getArrowPoints(this.connPoint, e, r, !0);
|
|
118
|
+
} else {
|
|
119
|
+
n = xp.algorithm.getArrowPoints(e, this.connPoint, r, !1);
|
|
120
|
+
g = xp.algorithm.getArrowPoints(this.connPoint, o, this.tempPoint4, !0);
|
|
121
|
+
}
|
|
122
|
+
var i = n.length,
|
|
123
|
+
s = (i - 5) / 2,
|
|
124
|
+
a = n.slice(0, s),
|
|
125
|
+
l = n.slice(s, s + 5),
|
|
126
|
+
u = n.slice(s + 5, i),
|
|
127
|
+
c = g.slice(0, s),
|
|
128
|
+
p = g.slice(s, s + 5),
|
|
129
|
+
h = g.slice(s + 5, i);
|
|
130
|
+
c = _plotUtil.P.PlotUtils.getBezierPoints(c);
|
|
131
|
+
var d = _plotUtil.P.PlotUtils.getBezierPoints(h.concat(a.slice(1)));
|
|
132
|
+
u = _plotUtil.P.PlotUtils.getBezierPoints(u);
|
|
133
|
+
var f = c.concat(p, d, l, u);
|
|
134
|
+
var newArray = xp.algorithm.array2Dto1D(f);
|
|
135
|
+
result.controlPoint = [o, e, r, this.tempPoint4, this.tempPoint5, this.connPoint];
|
|
136
|
+
result.polygonalPoint = Cesium.Cartesian3.fromDegreesArray(newArray);
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}, xp.algorithm.array2Dto1D = function (array) {
|
|
140
|
+
var newArray = [];
|
|
141
|
+
array.forEach(function (elt) {
|
|
142
|
+
newArray.push(elt[0]);
|
|
143
|
+
newArray.push(elt[1]);
|
|
144
|
+
});
|
|
145
|
+
return newArray;
|
|
146
|
+
}, xp.algorithm.getArrowPoints = function (t, o, e, r) {
|
|
147
|
+
this.type = doubleArrowDefualParam.type, this.headHeightFactor = doubleArrowDefualParam.headHeightFactor, this.headWidthFactor = doubleArrowDefualParam.headWidthFactor, this.neckHeightFactor = doubleArrowDefualParam.neckHeightFactor, this.neckWidthFactor = doubleArrowDefualParam.neckWidthFactor;
|
|
148
|
+
var n = _plotUtil.P.PlotUtils.mid(t, o),
|
|
149
|
+
g = _plotUtil.P.PlotUtils.distance(n, e),
|
|
150
|
+
i = _plotUtil.P.PlotUtils.getThirdPoint(e, n, 0, .3 * g, !0),
|
|
151
|
+
s = _plotUtil.P.PlotUtils.getThirdPoint(e, n, 0, .5 * g, !0);
|
|
152
|
+
i = _plotUtil.P.PlotUtils.getThirdPoint(n, i, _plotUtil.P.Constants.HALF_PI, g / 5, r), s = _plotUtil.P.PlotUtils.getThirdPoint(n, s, _plotUtil.P.Constants.HALF_PI, g / 4, r);
|
|
153
|
+
var a = [n, i, s, e],
|
|
154
|
+
l = xp.algorithm.getArrowHeadPoints(a, this.headHeightFactor, this.headWidthFactor, this.neckHeightFactor, this.neckWidthFactor),
|
|
155
|
+
u = l[0],
|
|
156
|
+
c = l[4],
|
|
157
|
+
p = _plotUtil.P.PlotUtils.distance(t, o) / _plotUtil.P.PlotUtils.getBaseLength(a) / 2,
|
|
158
|
+
h = xp.algorithm.getArrowBodyPoints(a, u, c, p),
|
|
159
|
+
d = h.length,
|
|
160
|
+
f = h.slice(0, d / 2),
|
|
161
|
+
E = h.slice(d / 2, d);
|
|
162
|
+
return f.push(u), E.push(c), f = f.reverse(), f.push(o), E = E.reverse(), E.push(t), f.reverse().concat(l, E);
|
|
163
|
+
}, xp.algorithm.getArrowHeadPoints = function (t, o, e) {
|
|
164
|
+
this.type = doubleArrowDefualParam.type, this.headHeightFactor = doubleArrowDefualParam.headHeightFactor, this.headWidthFactor = doubleArrowDefualParam.headWidthFactor, this.neckHeightFactor = doubleArrowDefualParam.neckHeightFactor, this.neckWidthFactor = doubleArrowDefualParam.neckWidthFactor;
|
|
165
|
+
var r = _plotUtil.P.PlotUtils.getBaseLength(t),
|
|
166
|
+
n = r * this.headHeightFactor,
|
|
167
|
+
g = t[t.length - 1],
|
|
168
|
+
i = (_plotUtil.P.PlotUtils.distance(o, e), n * this.headWidthFactor),
|
|
169
|
+
s = n * this.neckWidthFactor,
|
|
170
|
+
a = n * this.neckHeightFactor,
|
|
171
|
+
l = _plotUtil.P.PlotUtils.getThirdPoint(t[t.length - 2], g, 0, n, !0),
|
|
172
|
+
u = _plotUtil.P.PlotUtils.getThirdPoint(t[t.length - 2], g, 0, a, !0),
|
|
173
|
+
c = _plotUtil.P.PlotUtils.getThirdPoint(g, l, _plotUtil.P.Constants.HALF_PI, i, !1),
|
|
174
|
+
p = _plotUtil.P.PlotUtils.getThirdPoint(g, l, _plotUtil.P.Constants.HALF_PI, i, !0),
|
|
175
|
+
h = _plotUtil.P.PlotUtils.getThirdPoint(g, u, _plotUtil.P.Constants.HALF_PI, s, !1),
|
|
176
|
+
d = _plotUtil.P.PlotUtils.getThirdPoint(g, u, _plotUtil.P.Constants.HALF_PI, s, !0);
|
|
177
|
+
return [h, c, g, p, d];
|
|
178
|
+
}, xp.algorithm.getArrowBodyPoints = function (t, o, e, r) {
|
|
179
|
+
for (var n = _plotUtil.P.PlotUtils.wholeDistance(t), g = _plotUtil.P.PlotUtils.getBaseLength(t), i = g * r, s = _plotUtil.P.PlotUtils.distance(o, e), a = (i - s) / 2, l = 0, u = [], c = [], p = 1; p < t.length - 1; p++) {
|
|
180
|
+
var h = _plotUtil.P.PlotUtils.getAngleOfThreePoints(t[p - 1], t[p], t[p + 1]) / 2;
|
|
181
|
+
l += _plotUtil.P.PlotUtils.distance(t[p - 1], t[p]);
|
|
182
|
+
var d = (i / 2 - l / n * a) / Math.sin(h),
|
|
183
|
+
f = _plotUtil.P.PlotUtils.getThirdPoint(t[p - 1], t[p], Math.PI - h, d, !0),
|
|
184
|
+
E = _plotUtil.P.PlotUtils.getThirdPoint(t[p - 1], t[p], h, d, !1);
|
|
185
|
+
u.push(f), c.push(E);
|
|
186
|
+
}
|
|
187
|
+
return u.concat(c);
|
|
188
|
+
}, xp.algorithm.getTempPoint4 = function (t, o, e) {
|
|
189
|
+
var r,
|
|
190
|
+
n,
|
|
191
|
+
g,
|
|
192
|
+
i,
|
|
193
|
+
s = _plotUtil.P.PlotUtils.mid(t, o),
|
|
194
|
+
a = _plotUtil.P.PlotUtils.distance(s, e),
|
|
195
|
+
l = _plotUtil.P.PlotUtils.getAngleOfThreePoints(t, s, e);
|
|
196
|
+
return l < _plotUtil.P.Constants.HALF_PI ? (n = a * Math.sin(l), g = a * Math.cos(l), i = _plotUtil.P.PlotUtils.getThirdPoint(t, s, _plotUtil.P.Constants.HALF_PI, n, !1), r = _plotUtil.P.PlotUtils.getThirdPoint(s, i, _plotUtil.P.Constants.HALF_PI, g, !0)) : l >= _plotUtil.P.Constants.HALF_PI && l < Math.PI ? (n = a * Math.sin(Math.PI - l), g = a * Math.cos(Math.PI - l), i = _plotUtil.P.PlotUtils.getThirdPoint(t, s, _plotUtil.P.Constants.HALF_PI, n, !1), r = _plotUtil.P.PlotUtils.getThirdPoint(s, i, _plotUtil.P.Constants.HALF_PI, g, !1)) : l >= Math.PI && l < 1.5 * Math.PI ? (n = a * Math.sin(l - Math.PI), g = a * Math.cos(l - Math.PI), i = _plotUtil.P.PlotUtils.getThirdPoint(t, s, _plotUtil.P.Constants.HALF_PI, n, !0), r = _plotUtil.P.PlotUtils.getThirdPoint(s, i, _plotUtil.P.Constants.HALF_PI, g, !0)) : (n = a * Math.sin(2 * Math.PI - l), g = a * Math.cos(2 * Math.PI - l), i = _plotUtil.P.PlotUtils.getThirdPoint(t, s, _plotUtil.P.Constants.HALF_PI, n, !0), r = _plotUtil.P.PlotUtils.getThirdPoint(s, i, _plotUtil.P.Constants.HALF_PI, g, !1)), r;
|
|
197
|
+
}, xp.algorithm.tailedAttackArrow = function (inputPoint, Cesium) {
|
|
198
|
+
inputPoint = xp.algorithm.dereplication(inputPoint);
|
|
199
|
+
this.tailWidthFactor = tailedAttackArrowDefualParam.tailWidthFactor;
|
|
200
|
+
this.swallowTailFactor = tailedAttackArrowDefualParam.swallowTailFactor;
|
|
201
|
+
this.swallowTailPnt = tailedAttackArrowDefualParam.swallowTailPnt;
|
|
202
|
+
//控制点
|
|
203
|
+
var result = {
|
|
204
|
+
controlPoint: null,
|
|
205
|
+
polygonalPoint: null
|
|
206
|
+
};
|
|
207
|
+
result.controlPoint = inputPoint;
|
|
208
|
+
var t = inputPoint.length;
|
|
209
|
+
if (!(2 > t)) {
|
|
210
|
+
if (2 == inputPoint.length) {
|
|
211
|
+
result.polygonalPoint = inputPoint;
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
var o = inputPoint,
|
|
215
|
+
e = o[0],
|
|
216
|
+
r = o[1];
|
|
217
|
+
_plotUtil.P.PlotUtils.isClockWise(o[0], o[1], o[2]) && (e = o[1], r = o[0]);
|
|
218
|
+
var n = _plotUtil.P.PlotUtils.mid(e, r),
|
|
219
|
+
g = [n].concat(o.slice(2)),
|
|
220
|
+
i = xp.algorithm.getAttackArrowHeadPoints(g, e, r, tailedAttackArrowDefualParam),
|
|
221
|
+
s = i[0],
|
|
222
|
+
a = i[4],
|
|
223
|
+
l = _plotUtil.P.PlotUtils.distance(e, r),
|
|
224
|
+
u = _plotUtil.P.PlotUtils.getBaseLength(g),
|
|
225
|
+
c = u * this.tailWidthFactor * this.swallowTailFactor;
|
|
226
|
+
this.swallowTailPnt = _plotUtil.P.PlotUtils.getThirdPoint(g[1], g[0], 0, c, !0);
|
|
227
|
+
var p = l / u,
|
|
228
|
+
h = xp.algorithm.getAttackArrowBodyPoints(g, s, a, p),
|
|
229
|
+
t = h.length,
|
|
230
|
+
d = [e].concat(h.slice(0, t / 2));
|
|
231
|
+
d.push(s);
|
|
232
|
+
var f = [r].concat(h.slice(t / 2, t));
|
|
233
|
+
var newArray = [];
|
|
234
|
+
f.push(a), d = _plotUtil.P.PlotUtils.getQBSplinePoints(d), f = _plotUtil.P.PlotUtils.getQBSplinePoints(f), newArray = xp.algorithm.array2Dto1D(d.concat(i, f.reverse(), [this.swallowTailPnt, d[0]]));
|
|
235
|
+
result.polygonalPoint = Cesium.Cartesian3.fromDegreesArray(newArray);
|
|
236
|
+
}
|
|
237
|
+
return result;
|
|
238
|
+
}, xp.algorithm.getAttackArrowHeadPoints = function (t, o, e, defaultParam) {
|
|
239
|
+
this.headHeightFactor = defaultParam.headHeightFactor;
|
|
240
|
+
this.headTailFactor = defaultParam.headTailFactor;
|
|
241
|
+
this.headWidthFactor = defaultParam.headWidthFactor;
|
|
242
|
+
this.neckWidthFactor = defaultParam.neckWidthFactor;
|
|
243
|
+
this.neckHeightFactor = defaultParam.neckHeightFactor;
|
|
244
|
+
var r = _plotUtil.P.PlotUtils.getBaseLength(t),
|
|
245
|
+
n = r * this.headHeightFactor,
|
|
246
|
+
g = t[t.length - 1];
|
|
247
|
+
r = _plotUtil.P.PlotUtils.distance(g, t[t.length - 2]);
|
|
248
|
+
var i = _plotUtil.P.PlotUtils.distance(o, e);
|
|
249
|
+
n > i * this.headTailFactor && (n = i * this.headTailFactor);
|
|
250
|
+
var s = n * this.headWidthFactor,
|
|
251
|
+
a = n * this.neckWidthFactor;
|
|
252
|
+
n = n > r ? r : n;
|
|
253
|
+
var l = n * this.neckHeightFactor,
|
|
254
|
+
u = _plotUtil.P.PlotUtils.getThirdPoint(t[t.length - 2], g, 0, n, !0),
|
|
255
|
+
c = _plotUtil.P.PlotUtils.getThirdPoint(t[t.length - 2], g, 0, l, !0),
|
|
256
|
+
p = _plotUtil.P.PlotUtils.getThirdPoint(g, u, _plotUtil.P.Constants.HALF_PI, s, !1),
|
|
257
|
+
h = _plotUtil.P.PlotUtils.getThirdPoint(g, u, _plotUtil.P.Constants.HALF_PI, s, !0),
|
|
258
|
+
d = _plotUtil.P.PlotUtils.getThirdPoint(g, c, _plotUtil.P.Constants.HALF_PI, a, !1),
|
|
259
|
+
f = _plotUtil.P.PlotUtils.getThirdPoint(g, c, _plotUtil.P.Constants.HALF_PI, a, !0);
|
|
260
|
+
return [d, p, g, h, f];
|
|
261
|
+
}, xp.algorithm.getAttackArrowBodyPoints = function (t, o, e, r) {
|
|
262
|
+
for (var n = _plotUtil.P.PlotUtils.wholeDistance(t), g = _plotUtil.P.PlotUtils.getBaseLength(t), i = g * r, s = _plotUtil.P.PlotUtils.distance(o, e), a = (i - s) / 2, l = 0, u = [], c = [], p = 1; p < t.length - 1; p++) {
|
|
263
|
+
var h = _plotUtil.P.PlotUtils.getAngleOfThreePoints(t[p - 1], t[p], t[p + 1]) / 2;
|
|
264
|
+
l += _plotUtil.P.PlotUtils.distance(t[p - 1], t[p]);
|
|
265
|
+
var d = (i / 2 - l / n * a) / Math.sin(h),
|
|
266
|
+
f = _plotUtil.P.PlotUtils.getThirdPoint(t[p - 1], t[p], Math.PI - h, d, !0),
|
|
267
|
+
E = _plotUtil.P.PlotUtils.getThirdPoint(t[p - 1], t[p], h, d, !1);
|
|
268
|
+
u.push(f), c.push(E);
|
|
269
|
+
}
|
|
270
|
+
return u.concat(c);
|
|
271
|
+
}, xp.algorithm.dereplication = function (array) {
|
|
272
|
+
var last = array[array.length - 1];
|
|
273
|
+
var change = false;
|
|
274
|
+
var newArray = [];
|
|
275
|
+
newArray = array.filter(function (i) {
|
|
276
|
+
if (i[0] != last[0] && i[1] != last[1]) {
|
|
277
|
+
return i;
|
|
278
|
+
}
|
|
279
|
+
change = true;
|
|
280
|
+
});
|
|
281
|
+
if (change) newArray.push(last);
|
|
282
|
+
return newArray;
|
|
283
|
+
}, xp.algorithm.fineArrow = function (tailPoint, headerPoint, Cesium) {
|
|
284
|
+
if (tailPoint.length < 2 || headerPoint.length < 2) return;
|
|
285
|
+
|
|
286
|
+
//画箭头的函数
|
|
287
|
+
let tailWidthFactor = fineArrowDefualParam.tailWidthFactor;
|
|
288
|
+
let neckWidthFactor = fineArrowDefualParam.neckWidthFactor;
|
|
289
|
+
let headWidthFactor = fineArrowDefualParam.headWidthFactor;
|
|
290
|
+
let headAngle = fineArrowDefualParam.headAngle;
|
|
291
|
+
let neckAngle = fineArrowDefualParam.neckAngle;
|
|
292
|
+
var o = [];
|
|
293
|
+
o[0] = tailPoint;
|
|
294
|
+
o[1] = headerPoint;
|
|
295
|
+
var e = o[0],
|
|
296
|
+
r = o[1],
|
|
297
|
+
n = _plotUtil.P.PlotUtils.getBaseLength(o),
|
|
298
|
+
g = n * tailWidthFactor,
|
|
299
|
+
//尾部宽度因子
|
|
300
|
+
i = n * neckWidthFactor,
|
|
301
|
+
//脖子宽度银子
|
|
302
|
+
s = n * headWidthFactor,
|
|
303
|
+
//头部宽度因子
|
|
304
|
+
a = _plotUtil.P.PlotUtils.getThirdPoint(r, e, _plotUtil.P.Constants.HALF_PI, g, !0),
|
|
305
|
+
l = _plotUtil.P.PlotUtils.getThirdPoint(r, e, _plotUtil.P.Constants.HALF_PI, g, !1),
|
|
306
|
+
u = _plotUtil.P.PlotUtils.getThirdPoint(e, r, headAngle, s, !1),
|
|
307
|
+
c = _plotUtil.P.PlotUtils.getThirdPoint(e, r, headAngle, s, !0),
|
|
308
|
+
p = _plotUtil.P.PlotUtils.getThirdPoint(e, r, neckAngle, i, !1),
|
|
309
|
+
h = _plotUtil.P.PlotUtils.getThirdPoint(e, r, neckAngle, i, !0),
|
|
310
|
+
d = [];
|
|
311
|
+
d.push(a[0], a[1], p[0], p[1], u[0], u[1], r[0], r[1], c[0], c[1], h[0], h[1], l[0], l[1], e[0], e[1]);
|
|
312
|
+
// 判断是否有脏数据
|
|
313
|
+
const vaildData = d.some(e => isNaN(e));
|
|
314
|
+
return vaildData ? '' : Cesium.Cartesian3.fromDegreesArray(d);
|
|
315
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.initPlot = initPlot;
|
|
7
|
+
var _AttackArrow = require("./AttackArrow");
|
|
8
|
+
var _StraightArrow = require("./StraightArrow");
|
|
9
|
+
var _PincerArrow = require("./PincerArrow");
|
|
10
|
+
function initPlot(viewer, cesiumGlobal) {
|
|
11
|
+
const AttackArrowObj = new _AttackArrow.AttackArrow(viewer, cesiumGlobal);
|
|
12
|
+
const StraightArrowObj = new _StraightArrow.StraightArrow(viewer, cesiumGlobal);
|
|
13
|
+
const PincerArrowObj = new _PincerArrow.PincerArrow(viewer, cesiumGlobal);
|
|
14
|
+
return {
|
|
15
|
+
AttackArrowObj,
|
|
16
|
+
StraightArrowObj,
|
|
17
|
+
PincerArrowObj
|
|
18
|
+
};
|
|
19
|
+
}
|