@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.
- package/README.md +28 -16
- package/dist/go-home-early.umd.js +5 -5
- package/package.json +2 -16
- package/src/packages/Cesium/DrawMap/DrawJs/CesiumEntityEdit.js +427 -0
- package/src/packages/Cesium/DrawMap/DrawJs/CreatePolygonOnGround.js +202 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawAttackArrow.js +477 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawBillboard.js +114 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawCircle.js +311 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawCircleTY.js +237 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawCurve.js +256 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawPincerArrow.js +584 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawPoint.js +158 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawPolygon.js +215 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawPolyline.js +213 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawPolylineJT.js +218 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawProFile.js +314 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawRectangle.js +215 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawstraightArrow.js +364 -0
- package/src/packages/Cesium/DrawMap/DrawJs/MeasurePolygon.js +337 -0
- package/src/packages/Cesium/DrawMap/DrawJs/MeasurePolyline.js +285 -0
- package/src/packages/Cesium/DrawMap/DrawJs/ReminderTip.js +78 -0
- package/src/packages/Cesium/DrawMap/DrawJs/SlopeAspect.js +436 -0
- package/src/packages/Cesium/DrawMap/DrawJs/measureLength.js +177 -0
- package/src/packages/Cesium/DrawMap/index.vue +272 -0
- package/src/packages/Cesium/components/LocationDialog.vue +283 -0
- package/src/packages/Cesium/components/Popup.vue +591 -0
- package/src/packages/Cesium/components/PoumianDialog.vue +200 -0
- package/src/packages/Cesium/imgs/add-off.png +0 -0
- package/src/packages/Cesium/imgs/add.png +0 -0
- package/src/packages/Cesium/imgs/circle.png +0 -0
- package/src/packages/Cesium/imgs/icon-position-blue.png +0 -0
- package/src/packages/Cesium/imgs/line.png +0 -0
- package/src/packages/Cesium/imgs/map-delete.png +0 -0
- package/src/packages/Cesium/imgs/map.png +0 -0
- package/src/packages/Cesium/imgs/orientation-bg.svg +14 -0
- package/src/packages/Cesium/imgs/orientation.svg +21 -0
- package/src/packages/Cesium/imgs/poi.png +0 -0
- package/src/packages/Cesium/imgs/point.png +0 -0
- package/src/packages/Cesium/imgs/polygon.png +0 -0
- package/src/packages/Cesium/imgs/popup/back-popup-img.png +0 -0
- package/src/packages/Cesium/imgs/popup/backimg-btn.png +0 -0
- package/src/packages/Cesium/imgs/popup/dialog-bd.png +0 -0
- package/src/packages/Cesium/imgs/popup/dialog-btn.png +0 -0
- package/src/packages/Cesium/imgs/popup/dialog-ft.png +0 -0
- package/src/packages/Cesium/imgs/popup/dialog-hd.png +0 -0
- package/src/packages/Cesium/imgs/reduce-off.png +0 -0
- package/src/packages/Cesium/index.md +292 -0
- package/src/packages/Cesium/index.vue +3830 -0
- package/src/packages/Cesium/materials/CircularDiffusionMaterialProperty.js +98 -0
- package/src/packages/Cesium/materials/CircularRippleMaterialProperty.js +126 -0
- package/src/packages/Cesium/materials/PolylineArrowMaterialProperty.js +109 -0
- package/src/packages/Cesium/utils/MeasureHeight.js +261 -0
- package/src/packages/Cesium/utils/MeasureTools.js +1188 -0
- package/src/packages/index.js +33 -0
- package/src/packages/utils/charts.js +54 -0
- package/src/packages/utils/index.js +50 -0
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
// DrawPincerArrow
|
|
2
|
+
/*
|
|
3
|
+
绘制钳击箭头
|
|
4
|
+
*/
|
|
5
|
+
class DrawPincerArrow {
|
|
6
|
+
constructor(arg) {
|
|
7
|
+
this.drawName = 'DrawPincerArrow';
|
|
8
|
+
this.viewer = arg.viewer;
|
|
9
|
+
this.Cesium = arg.Cesium;
|
|
10
|
+
this.Text = arg.data.text || '';
|
|
11
|
+
this.Color = arg.data.color || '#000';
|
|
12
|
+
this.imgUrl = arg.data.imgUrl || '';
|
|
13
|
+
this.FontSize = arg.data.fontSize || 16;
|
|
14
|
+
this.callback = arg.data.callback || null;
|
|
15
|
+
this.pxNum = arg.data.pxNum || 5;
|
|
16
|
+
this.handler = null;
|
|
17
|
+
this.floatingPoint = null; // 标识点
|
|
18
|
+
this._PincerArrow = null; // 活动箭头
|
|
19
|
+
this._PincerArrowLast = null; // 最后一个箭头
|
|
20
|
+
this._positions = []; // 活动点
|
|
21
|
+
this._entities_point = []; // 脏数据
|
|
22
|
+
this._entities_PincerArrow = []; // 脏数据
|
|
23
|
+
this._PincerArrowData = null; // 用于构造箭头数据
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 返回箭头
|
|
27
|
+
get PincerArrow() {
|
|
28
|
+
return this._PincerArrowLast;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 修改样式
|
|
32
|
+
updateStyleFunction(data) {
|
|
33
|
+
this.Text = data.text || '';
|
|
34
|
+
this.Color = data.color || '#000';
|
|
35
|
+
this.imgUrl = data.imgUrl || '';
|
|
36
|
+
this.FontSize = data.fontSize || 16;
|
|
37
|
+
this.callback = data.callback || null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 返回箭头数据用于加载箭头
|
|
41
|
+
getData() {
|
|
42
|
+
return this._PincerArrowData;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 加载箭头
|
|
46
|
+
loadPincerArrow(data) {
|
|
47
|
+
var $this = this;
|
|
48
|
+
if (data.length < 3) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
for (var i = 0; i < this._entities_point.length; i++) {
|
|
52
|
+
this.viewer.entities.remove(this._entities_point[i]);
|
|
53
|
+
}
|
|
54
|
+
// 计算面
|
|
55
|
+
var lnglatArr = [];
|
|
56
|
+
for (let i = 0; i < data.length; i++) {
|
|
57
|
+
var lnglat = $this.cartesianToLatlng(data[i]);
|
|
58
|
+
lnglatArr.push(lnglat);
|
|
59
|
+
}
|
|
60
|
+
var res = $this.doubleArrow(lnglatArr);
|
|
61
|
+
var returnData = res.polygonalPoint;
|
|
62
|
+
var arrowEntity = $this.viewer.entities.add({
|
|
63
|
+
polygon: {
|
|
64
|
+
hierarchy: new $this.Cesium.PolygonHierarchy(returnData),
|
|
65
|
+
show: true,
|
|
66
|
+
fill: true,
|
|
67
|
+
clampToGround: true,
|
|
68
|
+
material: $this.Cesium.Color.fromCssColorString($this.Color)
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return arrowEntity;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 开始创建
|
|
75
|
+
startCreate() {
|
|
76
|
+
var $this = this;
|
|
77
|
+
this.handler = new this.Cesium.ScreenSpaceEventHandler(
|
|
78
|
+
this.viewer.scene.canvas
|
|
79
|
+
);
|
|
80
|
+
$this.viewer.scene.globe.depthTestAgainstTerrain = false;
|
|
81
|
+
|
|
82
|
+
this.handler.setInputAction(function(evt) {
|
|
83
|
+
// 单机开始绘制
|
|
84
|
+
var cartesian = $this.getCatesian3FromPX(evt.position);
|
|
85
|
+
if (!cartesian) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if ($this._positions.length == 0) {
|
|
89
|
+
$this.floatingPoint = $this.createPoint(cartesian);
|
|
90
|
+
}
|
|
91
|
+
if ($this._positions.length < 5) {
|
|
92
|
+
$this._positions.push(cartesian);
|
|
93
|
+
$this.createPoint(cartesian); // 绘制点
|
|
94
|
+
}
|
|
95
|
+
if ($this._positions.length == 5) {
|
|
96
|
+
$this._positions[4] = cartesian;
|
|
97
|
+
$this.floatingPoint.position.setValue(cartesian);
|
|
98
|
+
}
|
|
99
|
+
}, $this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
100
|
+
|
|
101
|
+
this.handler.setInputAction(function(evt) {
|
|
102
|
+
// 移动时绘制面
|
|
103
|
+
var cartesian = $this.getCatesian3FromPX(evt.endPosition);
|
|
104
|
+
if (!cartesian) return;
|
|
105
|
+
if ($this._positions.length < 2) return;
|
|
106
|
+
if (!$this.Cesium.defined($this._PincerArrow)) {
|
|
107
|
+
if ($this._positions.length == 2) {
|
|
108
|
+
$this._positions.push(cartesian);
|
|
109
|
+
}
|
|
110
|
+
$this._PincerArrow = $this.createPincerArrow();
|
|
111
|
+
}
|
|
112
|
+
$this.floatingPoint.position.setValue(cartesian);
|
|
113
|
+
if ($this._positions.length == 3) {
|
|
114
|
+
$this._positions[2] = cartesian;
|
|
115
|
+
}
|
|
116
|
+
if ($this._positions.length > 3) {
|
|
117
|
+
// 因为有时候获取移动的点会出现undefined导致报错,所以在这里控制住
|
|
118
|
+
if (cartesian.x && cartesian.y && cartesian.z) {
|
|
119
|
+
$this._positions.pop();
|
|
120
|
+
$this._positions.push(cartesian);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
console.log($this._positions.length);
|
|
124
|
+
}, $this.Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
125
|
+
|
|
126
|
+
this.handler.setInputAction(function(evt) {
|
|
127
|
+
if (!$this._PincerArrow) return;
|
|
128
|
+
var cartesian = $this.getCatesian3FromPX(evt.position);
|
|
129
|
+
if (!cartesian) return;
|
|
130
|
+
$this._positions.pop();
|
|
131
|
+
$this._positions.push(cartesian);
|
|
132
|
+
$this._PincerArrowData = $this._positions.concat();
|
|
133
|
+
$this.viewer.entities.remove($this._PincerArrow); // 移除
|
|
134
|
+
$this._PincerArrow = null;
|
|
135
|
+
$this._positions = [];
|
|
136
|
+
$this.floatingPoint.position.setValue(cartesian);
|
|
137
|
+
var pincerArrow = $this.loadPincerArrow($this._PincerArrowData); // 加载
|
|
138
|
+
$this._entities_PincerArrow.push(pincerArrow);
|
|
139
|
+
$this._PincerArrowLast = pincerArrow;
|
|
140
|
+
$this.clearPoint();
|
|
141
|
+
if (typeof $this.callback == 'function') {
|
|
142
|
+
// 提取多边形层次结构
|
|
143
|
+
var hierarchy = pincerArrow.polygon.hierarchy.getValue();
|
|
144
|
+
|
|
145
|
+
// 从层次结构中提取坐标
|
|
146
|
+
var coordinates = hierarchy.positions.map(function(position) {
|
|
147
|
+
var cartographic = $this.Cesium.Cartographic.fromCartesian(position);
|
|
148
|
+
return [
|
|
149
|
+
$this.Cesium.Math.toDegrees(cartographic.longitude),
|
|
150
|
+
$this.Cesium.Math.toDegrees(cartographic.latitude)
|
|
151
|
+
];
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// 创建GeoJSON对象
|
|
155
|
+
var geojson = {
|
|
156
|
+
type: 'Polygon',
|
|
157
|
+
coordinates: [coordinates],
|
|
158
|
+
geometry: {
|
|
159
|
+
type: 'Polygon'
|
|
160
|
+
},
|
|
161
|
+
properties: {
|
|
162
|
+
color: $this.Color
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
$this.callback(geojson);
|
|
167
|
+
}
|
|
168
|
+
// $this.handler.destroy();
|
|
169
|
+
}, $this.Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 创建钳击箭头
|
|
173
|
+
createPincerArrow() {
|
|
174
|
+
var $this = this;
|
|
175
|
+
$this._computeTempPositions();
|
|
176
|
+
var arrowEntity = $this.viewer.entities.add({
|
|
177
|
+
polygon: {
|
|
178
|
+
hierarchy: new $this.Cesium.CallbackProperty(function() {
|
|
179
|
+
// 计算面
|
|
180
|
+
var lnglatArr = [];
|
|
181
|
+
for (var i = 0; i < $this._positions.length; i++) {
|
|
182
|
+
var lnglat = $this.cartesianToLatlng($this._positions[i]);
|
|
183
|
+
lnglatArr.push(lnglat);
|
|
184
|
+
}
|
|
185
|
+
var res = $this.doubleArrow(lnglatArr);
|
|
186
|
+
var returnData = res.polygonalPoint;
|
|
187
|
+
return new $this.Cesium.PolygonHierarchy(returnData);
|
|
188
|
+
}, false),
|
|
189
|
+
show: true,
|
|
190
|
+
fill: true,
|
|
191
|
+
clampToGround: true,
|
|
192
|
+
material:
|
|
193
|
+
$this.Cesium.Color.fromCssColorString('#ffffff').withAlpha(0.5)
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
$this._entities_PincerArrow.push(arrowEntity);
|
|
197
|
+
return arrowEntity;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// 创建点
|
|
201
|
+
createPoint(cartesian) {
|
|
202
|
+
var $this = this;
|
|
203
|
+
var point = this.viewer.entities.add({
|
|
204
|
+
position: cartesian,
|
|
205
|
+
point: {
|
|
206
|
+
pixelSize: 10,
|
|
207
|
+
color: $this.Cesium.Color.YELLOW
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
$this._entities_point.push(point);
|
|
211
|
+
return point;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
cartesianToLatlng(cartesian) {
|
|
215
|
+
var latlng =
|
|
216
|
+
this.viewer.scene.globe.ellipsoid.cartesianToCartographic(cartesian);
|
|
217
|
+
var lat = this.Cesium.Math.toDegrees(latlng.latitude);
|
|
218
|
+
var lng = this.Cesium.Math.toDegrees(latlng.longitude);
|
|
219
|
+
return [lng, lat];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// 销毁
|
|
223
|
+
destroy() {
|
|
224
|
+
if (this.handler) {
|
|
225
|
+
this.handler.destroy();
|
|
226
|
+
this.handler = null;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
clearPoint() {
|
|
231
|
+
for (var i = 0; i < this._entities_point.length; i++) {
|
|
232
|
+
this.viewer.entities.remove(this._entities_point[i]);
|
|
233
|
+
}
|
|
234
|
+
this._entities_point = []; // 脏数据
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// 清空实体对象
|
|
238
|
+
clear() {
|
|
239
|
+
for (let i = 0; i < this._entities_point.length; i++) {
|
|
240
|
+
this.viewer.entities.remove(this._entities_point[i]);
|
|
241
|
+
}
|
|
242
|
+
for (let i = 0; i < this._entities_PincerArrow.length; i++) {
|
|
243
|
+
this.viewer.entities.remove(this._entities_PincerArrow[i]);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
this.floatingPoint = null; // 标识点
|
|
247
|
+
this._PincerArrow = null; // 活动箭头
|
|
248
|
+
this._PincerArrowLast = null; // 最后一个箭头
|
|
249
|
+
this._positions = []; // 活动点
|
|
250
|
+
this._entities_point = []; // 脏数据
|
|
251
|
+
this._entities_PincerArrow = []; // 脏数据
|
|
252
|
+
this._PincerArrowData = null; // 用于构造箭头数据
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
getCatesian3FromPX(px) {
|
|
256
|
+
var cartesian;
|
|
257
|
+
var ray = this.viewer.camera.getPickRay(px);
|
|
258
|
+
if (!ray) return null;
|
|
259
|
+
cartesian = this.viewer.scene.globe.pick(ray, this.viewer.scene);
|
|
260
|
+
return cartesian;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
_computeTempPositions() {
|
|
264
|
+
var _this = this;
|
|
265
|
+
|
|
266
|
+
var pnts = [].concat(_this._positions);
|
|
267
|
+
var num = pnts.length;
|
|
268
|
+
var first = pnts[0];
|
|
269
|
+
var last = pnts[num - 1];
|
|
270
|
+
if (_this._isSimpleXYZ(first, last) == false) {
|
|
271
|
+
pnts.push(first);
|
|
272
|
+
num += 1;
|
|
273
|
+
}
|
|
274
|
+
_this.tempPositions = [];
|
|
275
|
+
for (var i = 1; i < num; i++) {
|
|
276
|
+
var p1 = pnts[i - 1];
|
|
277
|
+
var p2 = pnts[i];
|
|
278
|
+
var cp = _this._computeCenterPotition(p1, p2);
|
|
279
|
+
_this.tempPositions.push(p1);
|
|
280
|
+
_this.tempPositions.push(cp);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
_isSimpleXYZ(p1, p2) {
|
|
285
|
+
if (p1.x == p2.x && p1.y == p2.y && p1.z == p2.z) {
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
_computeCenterPotition(p1, p2) {
|
|
292
|
+
var _this = this;
|
|
293
|
+
var c1 = _this.viewer.scene.globe.ellipsoid.cartesianToCartographic(p1);
|
|
294
|
+
var c2 = _this.viewer.scene.globe.ellipsoid.cartesianToCartographic(p2);
|
|
295
|
+
var cm = new _this.Cesium.EllipsoidGeodesic(
|
|
296
|
+
c1,
|
|
297
|
+
c2
|
|
298
|
+
).interpolateUsingFraction(0.5);
|
|
299
|
+
var cp = _this.viewer.scene.globe.ellipsoid.cartographicToCartesian(cm);
|
|
300
|
+
return cp;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// //////////////////////////////////////求取箭头坐标函数/////////////////////////////////////////////////////
|
|
304
|
+
// 箭头配置函数
|
|
305
|
+
doubleArrow(inputPoint) {
|
|
306
|
+
var $this = this;
|
|
307
|
+
this.connPoint = null;
|
|
308
|
+
this.tempPoint4 = null;
|
|
309
|
+
this.points = inputPoint;
|
|
310
|
+
var result = {
|
|
311
|
+
controlPoint: null,
|
|
312
|
+
polygonalPoint: null
|
|
313
|
+
};
|
|
314
|
+
// 获取已经点击的坐标数
|
|
315
|
+
var t = inputPoint.length;
|
|
316
|
+
if (!(t < 2)) {
|
|
317
|
+
if (t == 2) return inputPoint;
|
|
318
|
+
var o = this.points[0]; // 第一个点
|
|
319
|
+
var e = this.points[1]; // 第二个点
|
|
320
|
+
var r = this.points[2]; // 第三个点
|
|
321
|
+
const t = inputPoint.length; // 获取已经点击的坐标数
|
|
322
|
+
// 下面的是移动点位后的坐标
|
|
323
|
+
t == 3
|
|
324
|
+
? (this.tempPoint4 = $this.getTempPoint4(o, e, r))
|
|
325
|
+
: (this.tempPoint4 = this.points[3]);
|
|
326
|
+
t == 3 || t == 4
|
|
327
|
+
? (this.connPoint = $this.mid(o, e))
|
|
328
|
+
: (this.connPoint = this.points[4]);
|
|
329
|
+
var n, g;
|
|
330
|
+
$this.isClockWise(o, e, r)
|
|
331
|
+
? ((n = $this.getArrowPoints(o, this.connPoint, this.tempPoint4, !1)),
|
|
332
|
+
(g = $this.getArrowPoints(this.connPoint, e, r, !0)))
|
|
333
|
+
: ((n = $this.getArrowPoints(e, this.connPoint, r, !1)),
|
|
334
|
+
(g = $this.getArrowPoints(this.connPoint, o, this.tempPoint4, !0)));
|
|
335
|
+
var i = n.length;
|
|
336
|
+
var s = (i - 5) / 2;
|
|
337
|
+
var a = n.slice(0, s);
|
|
338
|
+
var l = n.slice(s, s + 5);
|
|
339
|
+
var u = n.slice(s + 5, i);
|
|
340
|
+
var c = g.slice(0, s);
|
|
341
|
+
var p = g.slice(s, s + 5);
|
|
342
|
+
var h = g.slice(s + 5, i);
|
|
343
|
+
c = $this.getBezierPoints(c);
|
|
344
|
+
var d = $this.getBezierPoints(h.concat(a.slice(1)));
|
|
345
|
+
u = $this.getBezierPoints(u);
|
|
346
|
+
var f = c.concat(p, d, l, u);
|
|
347
|
+
var newArray = $this.array2Dto1D(f);
|
|
348
|
+
result.controlPoint = [o, e, r, this.tempPoint4, this.connPoint];
|
|
349
|
+
result.polygonalPoint =
|
|
350
|
+
$this.Cesium.Cartesian3.fromDegreesArray(newArray);
|
|
351
|
+
}
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
getTempPoint4(t, o, e) {
|
|
356
|
+
var $this = this;
|
|
357
|
+
var r;
|
|
358
|
+
var n;
|
|
359
|
+
var g;
|
|
360
|
+
var i;
|
|
361
|
+
var s = $this.mid(t, o);
|
|
362
|
+
var a = $this.distance(s, e);
|
|
363
|
+
var l = $this.getAngleOfThreePoints(t, s, e);
|
|
364
|
+
return (
|
|
365
|
+
l < Math.PI / 2
|
|
366
|
+
? ((n = a * Math.sin(l)),
|
|
367
|
+
(g = a * Math.cos(l)),
|
|
368
|
+
(i = $this.getThirdPoint(t, s, Math.PI / 2, n, !1)),
|
|
369
|
+
(r = $this.getThirdPoint(s, i, Math.PI / 2, g, !0)))
|
|
370
|
+
: l >= Math.PI / 2 && l < Math.PI
|
|
371
|
+
? ((n = a * Math.sin(Math.PI - l)),
|
|
372
|
+
(g = a * Math.cos(Math.PI - l)),
|
|
373
|
+
(i = $this.getThirdPoint(t, s, Math.PI / 2, n, !1)),
|
|
374
|
+
(r = $this.getThirdPoint(s, i, Math.PI / 2, g, !1)))
|
|
375
|
+
: l >= Math.PI && l < 1.5 * Math.PI
|
|
376
|
+
? ((n = a * Math.sin(l - Math.PI)),
|
|
377
|
+
(g = a * Math.cos(l - Math.PI)),
|
|
378
|
+
(i = $this.getThirdPoint(t, s, Math.PI / 2, n, !0)),
|
|
379
|
+
(r = $this.getThirdPoint(s, i, Math.PI / 2, g, !0)))
|
|
380
|
+
: ((n = a * Math.sin(2 * Math.PI - l)),
|
|
381
|
+
(g = a * Math.cos(2 * Math.PI - l)),
|
|
382
|
+
(i = $this.getThirdPoint(t, s, Math.PI / 2, n, !0)),
|
|
383
|
+
(r = $this.getThirdPoint(s, i, Math.PI / 2, g, !1))),
|
|
384
|
+
r
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
mid(t, o) {
|
|
389
|
+
return [(t[0] + o[0]) / 2, (t[1] + o[1]) / 2];
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
isClockWise(t, o, e) {
|
|
393
|
+
return (e[1] - t[1]) * (o[0] - t[0]) > (o[1] - t[1]) * (e[0] - t[0]);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
getArrowPoints(t, o, e, r) {
|
|
397
|
+
var $this = this;
|
|
398
|
+
var doubleArrowDefualParam = {
|
|
399
|
+
type: 'doublearrow',
|
|
400
|
+
headHeightFactor: 0.25,
|
|
401
|
+
headWidthFactor: 0.3,
|
|
402
|
+
neckHeightFactor: 0.85,
|
|
403
|
+
fixPointCount: 4,
|
|
404
|
+
neckWidthFactor: 0.15
|
|
405
|
+
};
|
|
406
|
+
this.type = doubleArrowDefualParam.type;
|
|
407
|
+
this.headHeightFactor = doubleArrowDefualParam.headHeightFactor;
|
|
408
|
+
this.headWidthFactor = doubleArrowDefualParam.headWidthFactor;
|
|
409
|
+
this.neckHeightFactor = doubleArrowDefualParam.neckHeightFactor;
|
|
410
|
+
this.neckWidthFactor = doubleArrowDefualParam.neckWidthFactor;
|
|
411
|
+
var n = $this.mid(t, o);
|
|
412
|
+
var g = $this.distance(n, e);
|
|
413
|
+
var i = $this.getThirdPoint(e, n, 0, 0.3 * g, !0);
|
|
414
|
+
var s = $this.getThirdPoint(e, n, 0, 0.5 * g, !0);
|
|
415
|
+
i = $this.getThirdPoint(n, i, Math.PI / 2, g / 5, r);
|
|
416
|
+
s = $this.getThirdPoint(n, s, Math.PI / 2, g / 4, r);
|
|
417
|
+
var a = [n, i, s, e];
|
|
418
|
+
var l = $this.getArrowHeadPoints(
|
|
419
|
+
a,
|
|
420
|
+
this.headHeightFactor,
|
|
421
|
+
this.headWidthFactor,
|
|
422
|
+
this.neckHeightFactor,
|
|
423
|
+
this.neckWidthFactor
|
|
424
|
+
);
|
|
425
|
+
var u = l[0];
|
|
426
|
+
var c = l[4];
|
|
427
|
+
var p = $this.distance(t, o) / $this.getBaseLength(a) / 2;
|
|
428
|
+
var h = $this.getArrowBodyPoints(a, u, c, p);
|
|
429
|
+
var d = h.length;
|
|
430
|
+
var f = h.slice(0, d / 2);
|
|
431
|
+
var E = h.slice(d / 2, d);
|
|
432
|
+
return (
|
|
433
|
+
f.push(u),
|
|
434
|
+
E.push(c),
|
|
435
|
+
(f = f.reverse()),
|
|
436
|
+
f.push(o),
|
|
437
|
+
(E = E.reverse()),
|
|
438
|
+
E.push(t),
|
|
439
|
+
f.reverse().concat(l, E)
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
getArrowHeadPoints(t, o, e) {
|
|
444
|
+
var $this = this;
|
|
445
|
+
var doubleArrowDefualParam = {
|
|
446
|
+
type: 'doublearrow',
|
|
447
|
+
headHeightFactor: 0.25,
|
|
448
|
+
headWidthFactor: 0.3,
|
|
449
|
+
neckHeightFactor: 0.85,
|
|
450
|
+
fixPointCount: 4,
|
|
451
|
+
neckWidthFactor: 0.15
|
|
452
|
+
};
|
|
453
|
+
this.type = doubleArrowDefualParam.type;
|
|
454
|
+
this.headHeightFactor = doubleArrowDefualParam.headHeightFactor;
|
|
455
|
+
this.headWidthFactor = doubleArrowDefualParam.headWidthFactor;
|
|
456
|
+
this.neckHeightFactor = doubleArrowDefualParam.neckHeightFactor;
|
|
457
|
+
this.neckWidthFactor = doubleArrowDefualParam.neckWidthFactor;
|
|
458
|
+
var r = $this.getBaseLength(t);
|
|
459
|
+
var n = r * this.headHeightFactor;
|
|
460
|
+
var g = t[t.length - 1];
|
|
461
|
+
var i = ($this.distance(o, e), n * this.headWidthFactor);
|
|
462
|
+
var s = n * this.neckWidthFactor;
|
|
463
|
+
var a = n * this.neckHeightFactor;
|
|
464
|
+
var l = $this.getThirdPoint(t[t.length - 2], g, 0, n, !0);
|
|
465
|
+
var u = $this.getThirdPoint(t[t.length - 2], g, 0, a, !0);
|
|
466
|
+
var c = $this.getThirdPoint(g, l, Math.PI / 2, i, !1);
|
|
467
|
+
var p = $this.getThirdPoint(g, l, Math.PI / 2, i, !0);
|
|
468
|
+
var h = $this.getThirdPoint(g, u, Math.PI / 2, s, !1);
|
|
469
|
+
var d = $this.getThirdPoint(g, u, Math.PI / 2, s, !0);
|
|
470
|
+
return [h, c, g, p, d];
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
getArrowBodyPoints(t, o, e, r) {
|
|
474
|
+
var $this = this;
|
|
475
|
+
for (
|
|
476
|
+
var n = $this.wholeDistance(t),
|
|
477
|
+
g = $this.getBaseLength(t),
|
|
478
|
+
i = g * r,
|
|
479
|
+
s = $this.distance(o, e),
|
|
480
|
+
a = (i - s) / 2,
|
|
481
|
+
l = 0,
|
|
482
|
+
u = [],
|
|
483
|
+
c = [],
|
|
484
|
+
p = 1;
|
|
485
|
+
p < t.length - 1;
|
|
486
|
+
p++
|
|
487
|
+
) {
|
|
488
|
+
var h = $this.getAngleOfThreePoints(t[p - 1], t[p], t[p + 1]) / 2;
|
|
489
|
+
l += $this.distance(t[p - 1], t[p]);
|
|
490
|
+
var d = (i / 2 - (l / n) * a) / Math.sin(h);
|
|
491
|
+
var f = $this.getThirdPoint(t[p - 1], t[p], Math.PI - h, d, !0);
|
|
492
|
+
var E = $this.getThirdPoint(t[p - 1], t[p], h, d, !1);
|
|
493
|
+
u.push(f);
|
|
494
|
+
c.push(E);
|
|
495
|
+
}
|
|
496
|
+
return u.concat(c);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
getBezierPoints(t) {
|
|
500
|
+
if (t.length <= 2) return t;
|
|
501
|
+
for (var o = [], e = t.length - 1, r = 0; r <= 1; r += 0.01) {
|
|
502
|
+
for (var n = 0, y = 0, g = 0; e >= g; g++) {
|
|
503
|
+
var i = this.getBinomialFactor(e, g);
|
|
504
|
+
var s = Math.pow(r, g);
|
|
505
|
+
var a = Math.pow(1 - r, e - g);
|
|
506
|
+
n += i * s * a * t[g][0];
|
|
507
|
+
y += i * s * a * t[g][1];
|
|
508
|
+
}
|
|
509
|
+
o.push([n, y]);
|
|
510
|
+
}
|
|
511
|
+
o.push(t[e]);
|
|
512
|
+
return o;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
getBaseLength(t) {
|
|
516
|
+
return Math.pow(this.wholeDistance(t), 0.99);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
wholeDistance(t) {
|
|
520
|
+
for (var o = 0, e = 0; e < t.length - 1; e++) {
|
|
521
|
+
o += this.distance(t[e], t[e + 1]);
|
|
522
|
+
}
|
|
523
|
+
return o;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
getBinomialFactor(t, o) {
|
|
527
|
+
return (
|
|
528
|
+
this.getFactorial(t) / (this.getFactorial(o) * this.getFactorial(t - o))
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
getFactorial(t) {
|
|
533
|
+
if (t <= 1) return 1;
|
|
534
|
+
if (t == 2) return 2;
|
|
535
|
+
if (t == 3) return 6;
|
|
536
|
+
if (t == 4) return 24;
|
|
537
|
+
if (t == 5) return 120;
|
|
538
|
+
for (var o = 1, e = 1; t >= e; e++) o *= e;
|
|
539
|
+
return o;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
array2Dto1D(array) {
|
|
543
|
+
var newArray = [];
|
|
544
|
+
array.forEach(function(elt) {
|
|
545
|
+
newArray.push(elt[0]);
|
|
546
|
+
newArray.push(elt[1]);
|
|
547
|
+
});
|
|
548
|
+
return newArray;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
distance(t, o) {
|
|
552
|
+
return Math.sqrt(Math.pow(t[0] - o[0], 2) + Math.pow(t[1] - o[1], 2));
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
getAngleOfThreePoints(t, o, e) {
|
|
556
|
+
var r = this.getAzimuth(o, t) - this.getAzimuth(o, e);
|
|
557
|
+
return r < 0 ? r + 2 * Math.PI : r;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
getAzimuth(t, o) {
|
|
561
|
+
var e;
|
|
562
|
+
var r = Math.asin(Math.abs(o[1] - t[1]) / this.distance(t, o));
|
|
563
|
+
return (
|
|
564
|
+
o[1] >= t[1] && o[0] >= t[0]
|
|
565
|
+
? (e = r + Math.PI)
|
|
566
|
+
: o[1] >= t[1] && o[0] < t[0]
|
|
567
|
+
? (e = 2 * Math.PI - r)
|
|
568
|
+
: o[1] < t[1] && o[0] < t[0]
|
|
569
|
+
? (e = r)
|
|
570
|
+
: o[1] < t[1] && o[0] >= t[0] && (e = Math.PI - r),
|
|
571
|
+
e
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
getThirdPoint(t, o, e, r, n) {
|
|
576
|
+
var g = this.getAzimuth(t, o);
|
|
577
|
+
var i = n ? g + e : g - e;
|
|
578
|
+
var s = r * Math.cos(i);
|
|
579
|
+
var a = r * Math.sin(i);
|
|
580
|
+
return [o[0] + s, o[1] + a];
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export default DrawPincerArrow;
|