gis-common 4.1.6 → 4.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constant/ErrorTypeConstant.d.ts +23 -23
- package/dist/constant/EventTypeConstant.d.ts +24 -24
- package/dist/constant/GraphicConstant.d.ts +21 -21
- package/dist/constant/LayerType.d.ts +10 -10
- package/dist/gis-common.es.js +660 -396
- package/dist/gis-common.umd.js +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/utils/AjaxUtil.d.ts +102 -0
- package/dist/utils/CommUtil.d.ts +2 -0
- package/dist/utils/CoordsUtil.d.ts +1 -0
- package/dist/utils/FileUtil.d.ts +0 -5
- package/dist/utils/GeoJsonUtil.d.ts +63 -2
- package/dist/utils/GeoUtil.d.ts +9 -0
- package/dist/utils/ImageUtil.d.ts +42 -0
- package/dist/utils/ObjectUtil.d.ts +1 -0
- package/dist/utils/StringUtil.d.ts +1 -0
- package/dist/utils/index.d.ts +3 -1
- package/package.json +1 -1
package/dist/gis-common.es.js
CHANGED
|
@@ -1,89 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var O = (t, e, n) => e in t ?
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
MAP_READY: "mapReady",
|
|
7
|
-
MOUSE_CLICK: "click",
|
|
8
|
-
MOUSE_DOUBLE_CLICK: "dblclick",
|
|
9
|
-
MOUSE_MOVE: "mousemove",
|
|
10
|
-
MOUSE_IN: "mousein",
|
|
11
|
-
MOUSE_OUT: "mouseout",
|
|
12
|
-
MOUSE_RIGHT_CLICK: "mouseRightClick",
|
|
13
|
-
KEY_DOWN: "keyDown",
|
|
14
|
-
KEY_UP: "keyUp",
|
|
15
|
-
DRAW_ACTIVE: "drawActive",
|
|
16
|
-
DRAW_MOVE: "drawMove",
|
|
17
|
-
DRAW_COMPLETE: "drawComplete",
|
|
18
|
-
MQTT_CONNECT: "mqttConnect",
|
|
19
|
-
MQTT_ERROR: "mqttError",
|
|
20
|
-
MQTT_MESSAGE: "mqttMessage",
|
|
21
|
-
MQTT_CLOSE: "mqttClose",
|
|
22
|
-
WEB_SOCKET_CONNECT: "webSocketConnect",
|
|
23
|
-
WEB_SOCKET_ERROR: "webSocketError",
|
|
24
|
-
WEB_SOCKET_MESSAGE: "webSocketMessage",
|
|
25
|
-
WEB_SOCKET_CLOSE: "webSocketClose"
|
|
26
|
-
}, A = {
|
|
27
|
-
LOGIN_EXPIRED: "登录信息过期,请重新登录",
|
|
28
|
-
CROSS_ERROR: "跨域访问",
|
|
29
|
-
UNEXIST_RESOURCE: "资源不存在",
|
|
30
|
-
TIMEOUT: "请求超时",
|
|
31
|
-
INTERNAL_ERROR: "内部错误",
|
|
32
|
-
NETWORK_ERROR: "请求失败,请检查网络是否已连接",
|
|
33
|
-
PROCESS_FAIL: "处理失败",
|
|
34
|
-
AUTH_VERIFY_ERROR: "权限验证失败",
|
|
35
|
-
NO_DATA_FOUND: "未找到数据",
|
|
36
|
-
DUPLICATE_INSTANCE: "实例为单例模式,不允许重复构建",
|
|
37
|
-
COORDINATE_ERROR: "坐标验证失败",
|
|
38
|
-
JSON_PARSE_ERROR: "JSON解析失败,格式有误",
|
|
39
|
-
JSON_VALUE_ERROR: "JSON无此键",
|
|
40
|
-
PARAMETER_ERROR: "验证数据类型失败",
|
|
41
|
-
PARAMETER_ERROR_ARRAY: "格式类型验证失败:必须是数组",
|
|
42
|
-
PARAMETER_ERROR_STRING: "格式类型验证失败:必须是字符",
|
|
43
|
-
PARAMETER_ERROR_FUNCTION: "格式类型验证失败:必须是函数",
|
|
44
|
-
PARAMETER_ERROR_OBJECT: "格式类型验证失败:必须是对象",
|
|
45
|
-
PARAMETER_ERROR_LACK: "参数缺失",
|
|
46
|
-
STRING_CHECK_LOSS: "字符缺少关键字"
|
|
47
|
-
}, v = {
|
|
48
|
-
SUPER_MAP_IMAGES: "SuperMapImages",
|
|
49
|
-
// 超图影像服务 栅格数据
|
|
50
|
-
SUPER_MAP_DATA: "SuperMapData",
|
|
51
|
-
// 超图服务 矢量数据
|
|
52
|
-
ARC_GIS_MAP_IMAGES: "ArcGisMapImages",
|
|
53
|
-
// arcGis影像图层 栅格数据
|
|
54
|
-
ARC_GIS_MAP_DATA: "ArcGisMapData",
|
|
55
|
-
// arcGis图层 矢量数据
|
|
56
|
-
OSGB_LAYER: "OSGBLayer",
|
|
57
|
-
S3M_GROUP: "S3MGroup",
|
|
58
|
-
// addS3MGroupLayer(url, options, index) 添加S3M分组图层。
|
|
59
|
-
TERRAIN_LAYER: "TerrainFileLayer"
|
|
60
|
-
// 地形图层, 需要单独处理
|
|
61
|
-
}, _ = {
|
|
62
|
-
POINT: "point",
|
|
63
|
-
POLYLINE: "polyline",
|
|
64
|
-
POLYGON: "polygon",
|
|
65
|
-
BILLBOARD: "billboard",
|
|
66
|
-
CYLINDER: "cylinder",
|
|
67
|
-
ELLIPSOID: "ellipsoid",
|
|
68
|
-
LABEL: "label",
|
|
69
|
-
MODEL: "model",
|
|
70
|
-
WALL: "wall"
|
|
71
|
-
}, P = {
|
|
72
|
-
DISTANCE: "distance",
|
|
73
|
-
AREA: "area",
|
|
74
|
-
HEIGHT: "height"
|
|
75
|
-
}, L = {
|
|
76
|
-
ADD: "add",
|
|
77
|
-
REMOVE: "remove",
|
|
78
|
-
INIT: "init"
|
|
79
|
-
};
|
|
80
|
-
class k {
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var O = (t, e, n) => e in t ? D(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var d = (t, e, n) => O(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
var R = /* @__PURE__ */ ((t) => (t.MAP_RENDER = "mapRender", t.MAP_READY = "mapReady", t.MOUSE_CLICK = "click", t.MOUSE_DOUBLE_CLICK = "dblclick", t.MOUSE_MOVE = "mousemove", t.MOUSE_IN = "mousein", t.MOUSE_OUT = "mouseout", t.MOUSE_RIGHT_CLICK = "mouseRightClick", t.KEY_DOWN = "keyDown", t.KEY_UP = "keyUp", t.DRAW_ACTIVE = "drawActive", t.DRAW_MOVE = "drawMove", t.DRAW_COMPLETE = "drawComplete", t.MQTT_CONNECT = "mqttConnect", t.MQTT_ERROR = "mqttError", t.MQTT_MESSAGE = "mqttMessage", t.MQTT_CLOSE = "mqttClose", t.WEB_SOCKET_CONNECT = "webSocketConnect", t.WEB_SOCKET_ERROR = "webSocketError", t.WEB_SOCKET_MESSAGE = "webSocketMessage", t.WEB_SOCKET_CLOSE = "webSocketClose", t))(R || {}), C = /* @__PURE__ */ ((t) => (t.LOGIN_EXPIRED = "登录信息过期,请重新登录", t.CROSS_ERROR = "跨域访问", t.UNEXIST_RESOURCE = "资源不存在", t.TIMEOUT = "请求超时", t.INTERNAL_ERROR = "内部错误", t.NETWORK_ERROR = "请求失败,请检查网络是否已连接", t.PROCESS_FAIL = "处理失败", t.AUTH_VERIFY_ERROR = "权限验证失败", t.NO_DATA_FOUND = "未找到数据", t.DUPLICATE_INSTANCE = "实例为单例模式,不允许重复构建", t.COORDINATE_ERROR = "坐标验证失败", t.JSON_PARSE_ERROR = "JSON解析失败,格式有误", t.JSON_VALUE_ERROR = "JSON无此键", t.PARAMETER_ERROR = "验证数据类型失败", t.PARAMETER_ERROR_ARRAY = "格式类型验证失败:必须是数组", t.PARAMETER_ERROR_STRING = "格式类型验证失败:必须是字符", t.PARAMETER_ERROR_FUNCTION = "格式类型验证失败:必须是函数", t.PARAMETER_ERROR_OBJECT = "格式类型验证失败:必须是对象", t.PARAMETER_ERROR_LACK = "参数缺失", t.STRING_CHECK_LOSS = "字符缺少关键字", t))(C || {}), I = /* @__PURE__ */ ((t) => (t.SUPER_MAP_IMAGES = "SuperMapImages", t.SUPER_MAP_DATA = "SuperMapData", t.ARC_GIS_MAP_IMAGES = "ArcGisMapImages", t.ARC_GIS_MAP_DATA = "ArcGisMapData", t.OSGB_LAYER = "OSGBLayer", t.S3M_GROUP = "S3MGroup", t.TERRAIN_LAYER = "TerrainFileLayer", t))(I || {}), _ = /* @__PURE__ */ ((t) => (t.POINT = "point", t.POLYLINE = "polyline", t.POLYGON = "polygon", t.BILLBOARD = "billboard", t.CYLINDER = "cylinder", t.ELLIPSOID = "ellipsoid", t.LABEL = "label", t.MODEL = "model", t.WALL = "wall", t))(_ || {}), P = /* @__PURE__ */ ((t) => (t.DISTANCE = "distance", t.AREA = "area", t.HEIGHT = "height", t))(P || {}), L = /* @__PURE__ */ ((t) => (t.ADD = "add", t.REMOVE = "remove", t.INIT = "init", t))(L || {});
|
|
5
|
+
class F {
|
|
81
6
|
constructor(e) {
|
|
82
7
|
/**
|
|
83
8
|
* Creates an instance of AudioPlayer.
|
|
84
9
|
* @param {*} url
|
|
85
10
|
*/
|
|
86
|
-
|
|
11
|
+
d(this, "audio");
|
|
87
12
|
this.audio = new Audio(), this.audio.src = e;
|
|
88
13
|
}
|
|
89
14
|
play() {
|
|
@@ -173,9 +98,9 @@ const m = {
|
|
|
173
98
|
return Math.max(Math.min(t, n), e);
|
|
174
99
|
}
|
|
175
100
|
};
|
|
176
|
-
class
|
|
101
|
+
class B {
|
|
177
102
|
constructor(e) {
|
|
178
|
-
|
|
103
|
+
d(this, "context", null);
|
|
179
104
|
if (typeof e == "string" && (e = document.querySelector("#" + e), !e))
|
|
180
105
|
throw new Error("Element not found");
|
|
181
106
|
if (e instanceof HTMLElement) {
|
|
@@ -199,8 +124,8 @@ class U {
|
|
|
199
124
|
if (!this.context)
|
|
200
125
|
throw new Error("Canvas context is null or undefined");
|
|
201
126
|
this.context.beginPath();
|
|
202
|
-
const
|
|
203
|
-
this.context.lineWidth =
|
|
127
|
+
const a = i.width || 1, o = i.color || "#000";
|
|
128
|
+
this.context.lineWidth = a, this.context.strokeStyle = o, this.context.moveTo(e, n), this.context.lineTo(r, s), this.context.stroke();
|
|
204
129
|
}
|
|
205
130
|
/**
|
|
206
131
|
* 绘制圆弧
|
|
@@ -215,10 +140,10 @@ class U {
|
|
|
215
140
|
* @param bgColor 背景颜色
|
|
216
141
|
* @throws 当Canvas context为null或undefined时抛出错误
|
|
217
142
|
*/
|
|
218
|
-
drawArc({ x: e, y: n }, r, s, i,
|
|
143
|
+
drawArc({ x: e, y: n }, r, s, i, a, o, l) {
|
|
219
144
|
if (!this.context)
|
|
220
145
|
throw new Error("Canvas context is null or undefined");
|
|
221
|
-
|
|
146
|
+
o ? (this.context.fillStyle = l, this.context.beginPath(), this.context.arc(e, n, r, m.degreesToRadians(s), m.degreesToRadians(i), a), this.context.fill()) : (this.context.strokeStyle = l, this.context.beginPath(), this.context.arc(e, n, r, m.degreesToRadians(s), m.degreesToRadians(i), a), this.context.stroke());
|
|
222
147
|
}
|
|
223
148
|
static createCanvas(e = 1, n = 1) {
|
|
224
149
|
let r;
|
|
@@ -226,16 +151,16 @@ class U {
|
|
|
226
151
|
return r = document.createElement("canvas"), e && (r.width = e), n && (r.height = n), r;
|
|
227
152
|
}
|
|
228
153
|
}
|
|
229
|
-
class
|
|
154
|
+
class v {
|
|
230
155
|
constructor() {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
156
|
+
d(this, "_listeners");
|
|
157
|
+
d(this, "_mutex", {});
|
|
158
|
+
d(this, "_context");
|
|
234
159
|
}
|
|
235
160
|
addEventListener(e, n, r, s = !1) {
|
|
236
161
|
this._listeners === void 0 && (this._listeners = {}), this._context = r;
|
|
237
|
-
const i = this._mutex,
|
|
238
|
-
return
|
|
162
|
+
const i = this._mutex, a = this._listeners;
|
|
163
|
+
return a[e] === void 0 && (a[e] = []), a[e].indexOf(n) === -1 && (s && (i[e] = n), a[e].push(n)), this;
|
|
239
164
|
}
|
|
240
165
|
hasEventListener(e, n) {
|
|
241
166
|
if (this._listeners === null || this._listeners === void 0) return !1;
|
|
@@ -246,7 +171,7 @@ class C {
|
|
|
246
171
|
if (this._listeners === void 0) return;
|
|
247
172
|
const s = this._listeners[e];
|
|
248
173
|
if (this._mutex[e] === n && (this._mutex[e] = null), s !== void 0) {
|
|
249
|
-
const i = s.map((
|
|
174
|
+
const i = s.map((a) => a.toString()).indexOf(n.toString());
|
|
250
175
|
i !== -1 && s.splice(i, 1);
|
|
251
176
|
}
|
|
252
177
|
}
|
|
@@ -257,15 +182,15 @@ class C {
|
|
|
257
182
|
e.target = this;
|
|
258
183
|
const s = r.slice(0);
|
|
259
184
|
if (this._mutex[e.type] !== void 0) {
|
|
260
|
-
const i = s.find((
|
|
185
|
+
const i = s.find((a) => a === this._mutex[e.type]);
|
|
261
186
|
if (i) {
|
|
262
187
|
i.call(this._context || this, e);
|
|
263
188
|
return;
|
|
264
189
|
}
|
|
265
190
|
}
|
|
266
|
-
for (let i = 0,
|
|
267
|
-
const
|
|
268
|
-
typeof
|
|
191
|
+
for (let i = 0, a = s.length; i < a; i++) {
|
|
192
|
+
const o = s[i];
|
|
193
|
+
typeof o == "function" && o.call(this._context || this, e);
|
|
269
194
|
}
|
|
270
195
|
}
|
|
271
196
|
}
|
|
@@ -297,14 +222,14 @@ x.prototype.fromEntries = function(t = []) {
|
|
|
297
222
|
Array.isArray(n) && n.length === 2 && e.set(n[0], n[1]);
|
|
298
223
|
}), e;
|
|
299
224
|
};
|
|
300
|
-
class
|
|
225
|
+
class $ extends v {
|
|
301
226
|
constructor(n = "ws://127.0.0.1:10088") {
|
|
302
227
|
super();
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
228
|
+
d(this, "maxCheckTimes", 10);
|
|
229
|
+
d(this, "url");
|
|
230
|
+
d(this, "checkTimes", 0);
|
|
231
|
+
d(this, "connectStatus", !1);
|
|
232
|
+
d(this, "client", null);
|
|
308
233
|
this.maxCheckTimes = 10, this.url = n, this.checkTimes = 0, this.connect(), this.connCheckStatus(this.maxCheckTimes);
|
|
309
234
|
}
|
|
310
235
|
connect() {
|
|
@@ -314,22 +239,22 @@ class F extends C {
|
|
|
314
239
|
const n = this;
|
|
315
240
|
this.client.onopen = function(r) {
|
|
316
241
|
n.dispatchEvent({
|
|
317
|
-
type:
|
|
242
|
+
type: R.WEB_SOCKET_CONNECT,
|
|
318
243
|
message: r
|
|
319
244
|
});
|
|
320
245
|
}, this.client.onmessage = function(r) {
|
|
321
246
|
n.connectStatus = !0, n.dispatchEvent({
|
|
322
|
-
type:
|
|
247
|
+
type: R.WEB_SOCKET_MESSAGE,
|
|
323
248
|
message: r
|
|
324
249
|
});
|
|
325
250
|
}, this.client.onclose = function(r) {
|
|
326
251
|
n.dispatchEvent({
|
|
327
|
-
type:
|
|
252
|
+
type: R.WEB_SOCKET_CLOSE,
|
|
328
253
|
message: r
|
|
329
254
|
});
|
|
330
255
|
}, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(r) {
|
|
331
256
|
n.dispatchEvent({
|
|
332
|
-
type:
|
|
257
|
+
type: R.WEB_SOCKET_ERROR,
|
|
333
258
|
message: r
|
|
334
259
|
});
|
|
335
260
|
});
|
|
@@ -360,7 +285,7 @@ class F extends C {
|
|
|
360
285
|
}, 1e3);
|
|
361
286
|
}
|
|
362
287
|
}
|
|
363
|
-
const
|
|
288
|
+
const y = {
|
|
364
289
|
/**
|
|
365
290
|
* 获取数据类型
|
|
366
291
|
*
|
|
@@ -452,12 +377,12 @@ const R = {
|
|
|
452
377
|
*/
|
|
453
378
|
convertToTree2(t, e = "id", n = "parentId", r = "children") {
|
|
454
379
|
const s = [];
|
|
455
|
-
function i(
|
|
456
|
-
const
|
|
457
|
-
|
|
380
|
+
function i(a) {
|
|
381
|
+
const o = t.filter((l) => l[n] === a[e]).map((l) => (s.some((h) => h[e] === l[e]) || i(l), l));
|
|
382
|
+
o.length > 0 && (a[r] = o);
|
|
458
383
|
}
|
|
459
|
-
return t.forEach((
|
|
460
|
-
t.some((
|
|
384
|
+
return t.forEach((a) => {
|
|
385
|
+
t.some((o) => o[n] === a[e]) || (i(a), s.push(a));
|
|
461
386
|
}), s;
|
|
462
387
|
},
|
|
463
388
|
/**
|
|
@@ -508,7 +433,7 @@ const R = {
|
|
|
508
433
|
return t.replace(n, (r, s) => {
|
|
509
434
|
const i = e[s];
|
|
510
435
|
if (i === void 0)
|
|
511
|
-
throw new Error(`${
|
|
436
|
+
throw new Error(`${C.JSON_VALUE_ERROR}: ${r}`);
|
|
512
437
|
return typeof i == "function" ? i(e) : i;
|
|
513
438
|
});
|
|
514
439
|
},
|
|
@@ -561,6 +486,262 @@ const R = {
|
|
|
561
486
|
},
|
|
562
487
|
isNil(t) {
|
|
563
488
|
return t === void 0 || t === "undefined" || t === null || t === "null";
|
|
489
|
+
},
|
|
490
|
+
isNumber(t) {
|
|
491
|
+
return typeof t == "number" && !isNaN(t) || typeof t == "string" && Number.isFinite(+t);
|
|
492
|
+
},
|
|
493
|
+
isFunction(t) {
|
|
494
|
+
return this.isNil(t) ? !1 : typeof t == "function" || t.constructor !== null && t.constructor === Function;
|
|
495
|
+
}
|
|
496
|
+
}, T = {
|
|
497
|
+
deepClone(t) {
|
|
498
|
+
return structuredClone(t);
|
|
499
|
+
},
|
|
500
|
+
isEqual(t, e) {
|
|
501
|
+
return JSON.stringify(t) === JSON.stringify(e);
|
|
502
|
+
},
|
|
503
|
+
parse(t) {
|
|
504
|
+
return !t || typeof t != "string" ? t : JSON.parse(t);
|
|
505
|
+
}
|
|
506
|
+
}, k = {
|
|
507
|
+
emptyImageUrl: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
|
|
508
|
+
/**
|
|
509
|
+
*
|
|
510
|
+
* @param image image,类型可以是HTMLCanvasElement、ImageData
|
|
511
|
+
* @returns
|
|
512
|
+
*/
|
|
513
|
+
getURL(t) {
|
|
514
|
+
let e;
|
|
515
|
+
if (/^data:/i.test(t.src) || typeof HTMLCanvasElement > "u")
|
|
516
|
+
return t.src;
|
|
517
|
+
let n;
|
|
518
|
+
if (t instanceof HTMLCanvasElement)
|
|
519
|
+
n = t;
|
|
520
|
+
else {
|
|
521
|
+
e === void 0 && (e = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas")), e.width = t.width, e.height = t.height;
|
|
522
|
+
const r = e.getContext("2d");
|
|
523
|
+
r && (t instanceof ImageData ? r.putImageData(t, 0, 0) : r.drawImage(t, 0, 0, t.width, t.height)), n = e;
|
|
524
|
+
}
|
|
525
|
+
return n.width > 2048 || n.height > 2048 ? (console.warn("ImageUtil.getDataURL: Image converted to jpg for performance reasons", t), n.toDataURL("image/jpeg", 0.6)) : n.toDataURL("image/png");
|
|
526
|
+
},
|
|
527
|
+
/**
|
|
528
|
+
* 将图片的URL转换为Base64编码
|
|
529
|
+
*
|
|
530
|
+
* @param url 图片的URL地址
|
|
531
|
+
* @param width 图片的宽度,默认为图片原始宽度
|
|
532
|
+
* @param height 图片的高度,默认为图片原始高度
|
|
533
|
+
* @returns 返回Promise对象,解析后得到包含Base64编码数据的对象
|
|
534
|
+
*/
|
|
535
|
+
getBase64(t) {
|
|
536
|
+
return new Promise((e, n) => {
|
|
537
|
+
let r = new Image();
|
|
538
|
+
r.setAttribute("crossOrigin", "Anonymous"), r.src = t, r.onload = () => {
|
|
539
|
+
let s = this.getURL(r);
|
|
540
|
+
e(s);
|
|
541
|
+
}, r.onerror = n;
|
|
542
|
+
});
|
|
543
|
+
},
|
|
544
|
+
/**
|
|
545
|
+
* 解析base64编码
|
|
546
|
+
*
|
|
547
|
+
* @param base64 base64编码字符串
|
|
548
|
+
* @returns 返回一个对象,包含type(类型)、ext(扩展名)和data(数据)字段,如果解析失败则返回null
|
|
549
|
+
*/
|
|
550
|
+
parseBase64(t) {
|
|
551
|
+
let n = new RegExp("data:(?<type>.*?);base64,(?<data>.*)").exec(t);
|
|
552
|
+
return n && n.groups ? {
|
|
553
|
+
type: n.groups.type,
|
|
554
|
+
ext: n.groups.type.split("/").slice(-1)[0],
|
|
555
|
+
data: n.groups.data
|
|
556
|
+
} : null;
|
|
557
|
+
},
|
|
558
|
+
/**
|
|
559
|
+
* 复制图片到剪贴板
|
|
560
|
+
*
|
|
561
|
+
* @param url 图片的URL地址
|
|
562
|
+
* @returns 无返回值
|
|
563
|
+
* @throws 如果解析base64数据失败,则抛出异常
|
|
564
|
+
*/
|
|
565
|
+
async copyImage(t) {
|
|
566
|
+
try {
|
|
567
|
+
const e = await this.getBase64(t), n = this.parseBase64(e.dataURL);
|
|
568
|
+
if (!n)
|
|
569
|
+
throw new Error("Failed to parse base64 data.");
|
|
570
|
+
let r = n.type, s = atob(n.data), i = new ArrayBuffer(s.length), a = new Uint8Array(i);
|
|
571
|
+
for (let l = 0; l < s.length; l++)
|
|
572
|
+
a[l] = s.charCodeAt(l);
|
|
573
|
+
let o = new Blob([i], { type: r });
|
|
574
|
+
await navigator.clipboard.write([new ClipboardItem({ [r]: o })]);
|
|
575
|
+
} catch (e) {
|
|
576
|
+
console.error("Failed to copy image to clipboard:", e);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}, w = {
|
|
580
|
+
/**
|
|
581
|
+
* Get JSON data by jsonp
|
|
582
|
+
* @param url - resource url
|
|
583
|
+
* @param callback - callback function when completed
|
|
584
|
+
*/
|
|
585
|
+
jsonp(t, e) {
|
|
586
|
+
const n = "_jsonp_" + y.guid(), r = document.getElementsByTagName("head")[0];
|
|
587
|
+
t.includes("?") ? t += "&callback=" + n : t += "?callback=" + n;
|
|
588
|
+
let s = document.createElement("script");
|
|
589
|
+
s.type = "text/javascript", s.src = t, window[n] = function(i) {
|
|
590
|
+
e(null, i), r.removeChild(s), s = null, delete window[n];
|
|
591
|
+
}, r.appendChild(s);
|
|
592
|
+
},
|
|
593
|
+
/**
|
|
594
|
+
* Fetch remote resource by HTTP "GET" method
|
|
595
|
+
* @param {String} url - resource url
|
|
596
|
+
* @param {Object} [options=null] - request options
|
|
597
|
+
* @param {Object} [options.headers=null] - HTTP headers
|
|
598
|
+
* @param {String} [options.responseType=null] - responseType
|
|
599
|
+
* @param {String} [options.credentials=null] - if with credentials, set it to "include"
|
|
600
|
+
* @param {Function} cb - callback function when completed
|
|
601
|
+
* @return {Ajax} Ajax
|
|
602
|
+
* @example
|
|
603
|
+
* AjaxUtil.get(
|
|
604
|
+
* 'url/to/resource',
|
|
605
|
+
* (err, data) => {
|
|
606
|
+
* if (err) {
|
|
607
|
+
* throw new Error(err);
|
|
608
|
+
* }
|
|
609
|
+
* // do things with data
|
|
610
|
+
* }
|
|
611
|
+
* );
|
|
612
|
+
*/
|
|
613
|
+
get(t, e, n) {
|
|
614
|
+
if (y.isFunction(e)) {
|
|
615
|
+
const s = n;
|
|
616
|
+
n = e, e = s;
|
|
617
|
+
}
|
|
618
|
+
const r = w._getClient(n);
|
|
619
|
+
if (r.open("GET", t, !0), e) {
|
|
620
|
+
for (const s in e.headers)
|
|
621
|
+
r.setRequestHeader(s, e.headers[s]);
|
|
622
|
+
r.withCredentials = e.credentials === "include", e.responseType && (r.responseType = e.responseType);
|
|
623
|
+
}
|
|
624
|
+
return r.send(null), r;
|
|
625
|
+
},
|
|
626
|
+
/**
|
|
627
|
+
* Fetch remote resource by HTTP "POST" method
|
|
628
|
+
* @param {String} url - resource url
|
|
629
|
+
* @param {Object} options - request options
|
|
630
|
+
* @param {String|Object} options.postData - post data
|
|
631
|
+
* @param {Object} [options.headers=null] - HTTP headers
|
|
632
|
+
* @param {Function} cb - callback function when completed
|
|
633
|
+
* @return {Ajax} Ajax
|
|
634
|
+
* @example
|
|
635
|
+
* AjaxUtil.post(
|
|
636
|
+
* 'url/to/post',
|
|
637
|
+
* {
|
|
638
|
+
* postData : {
|
|
639
|
+
* 'param0' : 'val0',
|
|
640
|
+
* 'param1' : 1
|
|
641
|
+
* }
|
|
642
|
+
* },
|
|
643
|
+
* (err, data) => {
|
|
644
|
+
* if (err) {
|
|
645
|
+
* throw new Error(err);
|
|
646
|
+
* }
|
|
647
|
+
* // do things with data
|
|
648
|
+
* }
|
|
649
|
+
* );
|
|
650
|
+
*/
|
|
651
|
+
post(t, e = {}, n) {
|
|
652
|
+
let r;
|
|
653
|
+
if (typeof t != "string" ? (n = e.cb, r = e.postData, e = { ...e }, delete e.cb, delete e.postData, t = e.url) : (typeof e == "function" && (n = e, e = {}), r = e.postData), !n)
|
|
654
|
+
throw new Error("Callback function is required");
|
|
655
|
+
const s = w._getClient(n);
|
|
656
|
+
return s.open("POST", t, !0), e.headers = e.headers || {}, e.headers["Content-Type"] || (e.headers["Content-Type"] = "application/x-www-form-urlencoded"), Object.keys(e.headers).forEach((i) => {
|
|
657
|
+
s.setRequestHeader(i, e.headers[i]);
|
|
658
|
+
}), typeof r != "string" && (r = JSON.stringify(r)), s.send(r), s;
|
|
659
|
+
},
|
|
660
|
+
_wrapCallback(t, e) {
|
|
661
|
+
return function() {
|
|
662
|
+
t.readyState === 4 && (t.status === 200 ? t.responseType === "arraybuffer" ? t.response.byteLength === 0 ? e(new Error("http status 200 returned without content.")) : e(null, {
|
|
663
|
+
data: t.response,
|
|
664
|
+
cacheControl: t.getResponseHeader("Cache-Control"),
|
|
665
|
+
expires: t.getResponseHeader("Expires"),
|
|
666
|
+
contentType: t.getResponseHeader("Content-Type")
|
|
667
|
+
}) : e(null, t.responseText) : e(new Error(t.statusText + "," + t.status)));
|
|
668
|
+
};
|
|
669
|
+
},
|
|
670
|
+
_getClient(t) {
|
|
671
|
+
let e = null;
|
|
672
|
+
try {
|
|
673
|
+
e = new XMLHttpRequest();
|
|
674
|
+
} catch {
|
|
675
|
+
throw new Error("XMLHttpRequest not supported.");
|
|
676
|
+
}
|
|
677
|
+
return e && (e.onreadystatechange = w._wrapCallback(e, t)), e;
|
|
678
|
+
},
|
|
679
|
+
/**
|
|
680
|
+
* Fetch resource as arraybuffer.
|
|
681
|
+
* @param {String} url - url
|
|
682
|
+
* @param {Object} [options=null] - options, same as Ajax.get
|
|
683
|
+
* @param {Function} cb - callback function when completed.
|
|
684
|
+
* @example
|
|
685
|
+
* AjaxUtil.getArrayBuffer(
|
|
686
|
+
* 'url/to/resource.bin',
|
|
687
|
+
* (err, data) => {
|
|
688
|
+
* if (err) {
|
|
689
|
+
* throw new Error(err);
|
|
690
|
+
* }
|
|
691
|
+
* // data is a binary array
|
|
692
|
+
* }
|
|
693
|
+
* );
|
|
694
|
+
*/
|
|
695
|
+
getArrayBuffer(t, e, n) {
|
|
696
|
+
if (y.isFunction(e)) {
|
|
697
|
+
const r = n;
|
|
698
|
+
n = e, e = r;
|
|
699
|
+
}
|
|
700
|
+
return e || (e = {}), e.responseType = "arraybuffer", w.get(t, e, n);
|
|
701
|
+
},
|
|
702
|
+
getImage(t, e, n) {
|
|
703
|
+
return w.getArrayBuffer(e, n, (r, s) => {
|
|
704
|
+
if (r)
|
|
705
|
+
t.onerror && t.onerror(r);
|
|
706
|
+
else if (s) {
|
|
707
|
+
const i = window.URL || window.webkitURL, a = t.onload;
|
|
708
|
+
t.onload = () => {
|
|
709
|
+
a && a(), i.revokeObjectURL(t.src);
|
|
710
|
+
};
|
|
711
|
+
const o = new Blob([new Uint8Array(s.data)], { type: s.contentType });
|
|
712
|
+
t.cacheControl = s.cacheControl, t.expires = s.expires, t.src = s.data.byteLength ? i.createObjectURL(o) : k.emptyImageUrl;
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
},
|
|
716
|
+
/**
|
|
717
|
+
* Fetch resource as a JSON Object.
|
|
718
|
+
* @param {String} url - json's url
|
|
719
|
+
* @param {Object} [options=null] - optional options
|
|
720
|
+
* @param {String} [options.jsonp=false] - fetch by jsonp, false by default
|
|
721
|
+
* @param {Function} cb - callback function when completed.
|
|
722
|
+
* @example
|
|
723
|
+
* AjaxUtil.getJSON(
|
|
724
|
+
* 'url/to/resource.json',
|
|
725
|
+
* { jsonp : true },
|
|
726
|
+
* (err, json) => {
|
|
727
|
+
* if (err) {
|
|
728
|
+
* throw new Error(err);
|
|
729
|
+
* }
|
|
730
|
+
* // json is a JSON Object
|
|
731
|
+
* console.log(json.foo);
|
|
732
|
+
* }
|
|
733
|
+
* );
|
|
734
|
+
*/
|
|
735
|
+
getJSON(t, e, n) {
|
|
736
|
+
if (y.isFunction(e)) {
|
|
737
|
+
const s = n;
|
|
738
|
+
n = e, e = s;
|
|
739
|
+
}
|
|
740
|
+
const r = function(s, i) {
|
|
741
|
+
const a = i ? T.parse(i) : null;
|
|
742
|
+
n && n(s, a);
|
|
743
|
+
};
|
|
744
|
+
return e && e.jsonp ? w.jsonp(t, r) : w.get(t, e, r);
|
|
564
745
|
}
|
|
565
746
|
};
|
|
566
747
|
Array.prototype.groupBy = function(t) {
|
|
@@ -595,12 +776,16 @@ Array.prototype.desc = function(t = (e) => e) {
|
|
|
595
776
|
Array.prototype.asc = function(t = (e) => e) {
|
|
596
777
|
return this.sort((e, n) => t(e) - t(n));
|
|
597
778
|
};
|
|
779
|
+
Array.prototype.remove = function(t) {
|
|
780
|
+
const e = this.indexOf(t);
|
|
781
|
+
return e > -1 && this.splice(e, 1), this;
|
|
782
|
+
};
|
|
598
783
|
Array.prototype.clear = function() {
|
|
599
784
|
return this.length = 0, this;
|
|
600
785
|
};
|
|
601
|
-
const
|
|
786
|
+
const G = {
|
|
602
787
|
asArray(t) {
|
|
603
|
-
return
|
|
788
|
+
return y.isEmpty(t) ? [] : Array.isArray(t) ? t : [t];
|
|
604
789
|
},
|
|
605
790
|
/**
|
|
606
791
|
* 创建指定长度的数组,并返回其索引数组
|
|
@@ -653,7 +838,7 @@ const N = {
|
|
|
653
838
|
difference(...t) {
|
|
654
839
|
return this.union(...t).filter((e) => !this.intersection(...t).includes(e));
|
|
655
840
|
}
|
|
656
|
-
},
|
|
841
|
+
}, J = {
|
|
657
842
|
/**
|
|
658
843
|
* 获取浏览器类型
|
|
659
844
|
*
|
|
@@ -694,8 +879,8 @@ const N = {
|
|
|
694
879
|
const t = document.documentElement.clientWidth || 0, e = document.documentElement.clientHeight || 0, n = document.getElementById("app");
|
|
695
880
|
if (!n) return;
|
|
696
881
|
const r = n.style, s = t / e, i = 16 / 9;
|
|
697
|
-
let
|
|
698
|
-
s > i && (
|
|
882
|
+
let a = t / 1920;
|
|
883
|
+
s > i && (a = e / 1080), r.transformOrigin = "left top", r.transform = `scale(${a}) translateX(-49.99%)`, r.width = `${t / a}px`;
|
|
699
884
|
},
|
|
700
885
|
/**
|
|
701
886
|
* 获取HTML字体大小
|
|
@@ -706,7 +891,7 @@ const N = {
|
|
|
706
891
|
const t = document.documentElement.clientWidth || document.body.clientWidth, e = document.querySelector("html");
|
|
707
892
|
e && (e.style.fontSize = t / 192 + "px");
|
|
708
893
|
}
|
|
709
|
-
},
|
|
894
|
+
}, H = {
|
|
710
895
|
set: function(t, e, n = 30) {
|
|
711
896
|
var r = /* @__PURE__ */ new Date();
|
|
712
897
|
r.setTime(r.getTime() + n * 24 * 60 * 60 * 1e3), document.cookie = t + "=" + escape(e) + ";expires=" + r.toUTCString();
|
|
@@ -721,17 +906,17 @@ const N = {
|
|
|
721
906
|
var e = document.cookie.match(new RegExp("(^| )" + t + "=([^;]*)(;|$)"));
|
|
722
907
|
return e != null ? e[2] : "";
|
|
723
908
|
}
|
|
724
|
-
},
|
|
909
|
+
}, q = {
|
|
725
910
|
PI: 3.141592653589793,
|
|
726
911
|
XPI: 3.141592653589793 * 3e3 / 180,
|
|
727
912
|
delta(t, e) {
|
|
728
913
|
const r = 0.006693421622965943;
|
|
729
914
|
let s = this.transformLat(e - 105, t - 35), i = this.transformLon(e - 105, t - 35);
|
|
730
|
-
const
|
|
731
|
-
let
|
|
732
|
-
|
|
733
|
-
const
|
|
734
|
-
return s = s * 180 / (6378245 * (1 - r) / (
|
|
915
|
+
const a = t / 180 * this.PI;
|
|
916
|
+
let o = Math.sin(a);
|
|
917
|
+
o = 1 - r * o * o;
|
|
918
|
+
const l = Math.sqrt(o);
|
|
919
|
+
return s = s * 180 / (6378245 * (1 - r) / (o * l) * this.PI), i = i * 180 / (6378245 / l * Math.cos(a) * this.PI), { lat: s, lng: i };
|
|
735
920
|
},
|
|
736
921
|
/**
|
|
737
922
|
* 判断经纬度是否不在中国境内
|
|
@@ -759,23 +944,23 @@ const N = {
|
|
|
759
944
|
},
|
|
760
945
|
// GCJ-02 to WGS-84 exactly
|
|
761
946
|
gcjDecryptExact(t, e) {
|
|
762
|
-
let s = 0.01, i = 0.01,
|
|
947
|
+
let s = 0.01, i = 0.01, a = t - s, o = e - i, l = t + s, h = e + i, c = 0, u = 0, f = 0;
|
|
763
948
|
for (; ; ) {
|
|
764
|
-
|
|
765
|
-
const p = this.gcjEncrypt(
|
|
766
|
-
if (s = p.lat - t, i = p.lng - e, Math.abs(s) < 1e-9 && Math.abs(i) < 1e-9 || (s > 0 ?
|
|
949
|
+
c = (a + l) / 2, u = (o + h) / 2;
|
|
950
|
+
const p = this.gcjEncrypt(c, u);
|
|
951
|
+
if (s = p.lat - t, i = p.lng - e, Math.abs(s) < 1e-9 && Math.abs(i) < 1e-9 || (s > 0 ? l = c : a = c, i > 0 ? h = u : o = u, ++f > 1e4)) break;
|
|
767
952
|
}
|
|
768
|
-
return { lat:
|
|
953
|
+
return { lat: c, lng: u };
|
|
769
954
|
},
|
|
770
955
|
// GCJ-02 to BD-09
|
|
771
956
|
bdEncrypt(t, e) {
|
|
772
|
-
const n = e, r = t, s = Math.sqrt(n * n + r * r) + 2e-5 * Math.sin(r * this.XPI), i = Math.atan2(r, n) + 3e-6 * Math.cos(n * this.XPI),
|
|
773
|
-
return { lat: s * Math.sin(i) + 6e-3, lng:
|
|
957
|
+
const n = e, r = t, s = Math.sqrt(n * n + r * r) + 2e-5 * Math.sin(r * this.XPI), i = Math.atan2(r, n) + 3e-6 * Math.cos(n * this.XPI), a = s * Math.cos(i) + 65e-4;
|
|
958
|
+
return { lat: s * Math.sin(i) + 6e-3, lng: a };
|
|
774
959
|
},
|
|
775
960
|
// BD-09 to GCJ-02
|
|
776
961
|
bdDecrypt(t, e) {
|
|
777
|
-
const n = e - 65e-4, r = t - 6e-3, s = Math.sqrt(n * n + r * r) - 2e-5 * Math.sin(r * this.XPI), i = Math.atan2(r, n) - 3e-6 * Math.cos(n * this.XPI),
|
|
778
|
-
return { lat: s * Math.sin(i), lng:
|
|
962
|
+
const n = e - 65e-4, r = t - 6e-3, s = Math.sqrt(n * n + r * r) - 2e-5 * Math.sin(r * this.XPI), i = Math.atan2(r, n) - 3e-6 * Math.cos(n * this.XPI), a = s * Math.cos(i);
|
|
963
|
+
return { lat: s * Math.sin(i), lng: a };
|
|
779
964
|
},
|
|
780
965
|
// WGS-84 to Web mercator
|
|
781
966
|
// mercatorLat -> y mercatorLon -> x
|
|
@@ -811,8 +996,22 @@ const N = {
|
|
|
811
996
|
lat: Math.random() * (r - e) + e,
|
|
812
997
|
lng: Math.random() * (n - t) + t
|
|
813
998
|
};
|
|
999
|
+
},
|
|
1000
|
+
deCompose(t, e, n) {
|
|
1001
|
+
if (!Array.isArray(t))
|
|
1002
|
+
return n ? e.call(n, t) : e(t);
|
|
1003
|
+
const r = [];
|
|
1004
|
+
let s, i;
|
|
1005
|
+
for (let a = 0, o = t.length; a < o; a++) {
|
|
1006
|
+
if (s = t[a], y.isNil(s)) {
|
|
1007
|
+
r.push(null);
|
|
1008
|
+
continue;
|
|
1009
|
+
}
|
|
1010
|
+
Array.isArray(s) ? r.push(this.deCompose(s, e, n)) : (i = n ? e.call(n, s) : e(s), r.push(i));
|
|
1011
|
+
}
|
|
1012
|
+
return r;
|
|
814
1013
|
}
|
|
815
|
-
},
|
|
1014
|
+
}, j = {
|
|
816
1015
|
random() {
|
|
817
1016
|
let t = Math.floor(Math.random() * 256).toString(16), e = Math.floor(Math.random() * 256).toString(16), n = Math.floor(Math.random() * 256).toString(16);
|
|
818
1017
|
return t = t.length === 1 ? "0" + t : t, e = e.length === 1 ? "0" + e : e, n = n.length === 1 ? "0" + n : n, "#" + t + e + n;
|
|
@@ -844,11 +1043,11 @@ const N = {
|
|
|
844
1043
|
* @returns 返回rgba格式的颜色值,格式为rgba(r,g,b,1)
|
|
845
1044
|
*/
|
|
846
1045
|
hexToRgba(t) {
|
|
847
|
-
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, n = t.replace(e, (
|
|
1046
|
+
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, n = t.replace(e, (l, h, c, u) => h + h + c + c + u + u), s = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);
|
|
848
1047
|
if (!s)
|
|
849
1048
|
return t;
|
|
850
|
-
const i = parseInt(s[1], 16),
|
|
851
|
-
return `rgba(${i},${
|
|
1049
|
+
const i = parseInt(s[1], 16), a = parseInt(s[2], 16), o = parseInt(s[3], 16);
|
|
1050
|
+
return `rgba(${i},${a},${o},1)`;
|
|
852
1051
|
},
|
|
853
1052
|
/**
|
|
854
1053
|
* 将 HSL 颜色值转换为 RGBA 颜色值
|
|
@@ -863,17 +1062,17 @@ const N = {
|
|
|
863
1062
|
if (!e)
|
|
864
1063
|
return null;
|
|
865
1064
|
const n = parseInt(e[1], 10) / 360, r = parseInt(e[2], 10) / 100, s = parseInt(e[3], 10) / 100, i = e[4] ? parseFloat(e[4]) : 1;
|
|
866
|
-
function
|
|
867
|
-
return
|
|
1065
|
+
function a(c, u, f) {
|
|
1066
|
+
return f < 0 && (f += 1), f > 1 && (f -= 1), f < 1 / 6 ? c + (u - c) * 6 * f : f < 1 / 2 ? u : f < 2 / 3 ? c + (u - c) * (2 / 3 - f) * 6 : c;
|
|
868
1067
|
}
|
|
869
|
-
let
|
|
1068
|
+
let o, l, h;
|
|
870
1069
|
if (r === 0)
|
|
871
|
-
|
|
1070
|
+
o = l = h = s;
|
|
872
1071
|
else {
|
|
873
|
-
const
|
|
874
|
-
|
|
1072
|
+
const c = s < 0.5 ? s * (1 + r) : s + r - s * r, u = 2 * s - c;
|
|
1073
|
+
o = a(u, c, n + 1 / 3), l = a(u, c, n), h = a(u, c, n - 1 / 3);
|
|
875
1074
|
}
|
|
876
|
-
return `rgba(${Math.round(
|
|
1075
|
+
return `rgba(${Math.round(o * 255)},${Math.round(l * 255)},${Math.round(h * 255)},${i})`;
|
|
877
1076
|
},
|
|
878
1077
|
isHex(t) {
|
|
879
1078
|
return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t);
|
|
@@ -953,7 +1152,7 @@ Date.prototype.addDate = function(t, e) {
|
|
|
953
1152
|
}
|
|
954
1153
|
return n;
|
|
955
1154
|
};
|
|
956
|
-
const
|
|
1155
|
+
const W = {
|
|
957
1156
|
lastMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1),
|
|
958
1157
|
thisMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
|
|
959
1158
|
nextMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 1),
|
|
@@ -997,26 +1196,26 @@ const q = {
|
|
|
997
1196
|
* @returns 返回格式化后的时间间隔字符串,格式为"天数 天 小时 时 分钟 分 秒 秒"或"少于1秒"
|
|
998
1197
|
*/
|
|
999
1198
|
formatDateInterval(t, e) {
|
|
1000
|
-
const n = new Date(t), s = new Date(e).getTime() - n.getTime(), i = Math.floor(s / (24 * 3600 * 1e3)),
|
|
1001
|
-
let
|
|
1002
|
-
return i > 0 && (
|
|
1199
|
+
const n = new Date(t), s = new Date(e).getTime() - n.getTime(), i = Math.floor(s / (24 * 3600 * 1e3)), a = s % (24 * 3600 * 1e3), o = Math.floor(a / (3600 * 1e3)), l = a % (3600 * 1e3), h = Math.floor(l / (60 * 1e3)), c = l % (60 * 1e3), u = Math.round(c / 1e3);
|
|
1200
|
+
let f = "";
|
|
1201
|
+
return i > 0 && (f += i + "天"), o > 0 && (f += o + "时"), h > 0 && (f += h + "分"), u > 0 && (f += u + "秒"), i === 0 && o === 0 && h === 0 && u === 0 && (f = "少于1秒"), f;
|
|
1003
1202
|
},
|
|
1004
1203
|
formatterCounter(t) {
|
|
1005
|
-
const e = function(
|
|
1006
|
-
return (
|
|
1007
|
-
}, n = e(Math.floor(t / 3600)), r = t % 3600, s = e(Math.floor(r / 60)), i = r % 60,
|
|
1008
|
-
return `${n}:${s}:${
|
|
1204
|
+
const e = function(o) {
|
|
1205
|
+
return (o > 10 ? "" : "0") + (o || 0);
|
|
1206
|
+
}, n = e(Math.floor(t / 3600)), r = t % 3600, s = e(Math.floor(r / 60)), i = r % 60, a = e(Math.round(i));
|
|
1207
|
+
return `${n}:${s}:${a}`;
|
|
1009
1208
|
},
|
|
1010
1209
|
sleep(t) {
|
|
1011
1210
|
}
|
|
1012
1211
|
};
|
|
1013
|
-
function
|
|
1212
|
+
function U(t) {
|
|
1014
1213
|
return t.trim ? t.trim() : t.replace(/^\s+|\s+$/g, "");
|
|
1015
1214
|
}
|
|
1016
|
-
function
|
|
1017
|
-
return
|
|
1215
|
+
function E(t) {
|
|
1216
|
+
return U(t).split(/\s+/);
|
|
1018
1217
|
}
|
|
1019
|
-
const
|
|
1218
|
+
const K = {
|
|
1020
1219
|
/**
|
|
1021
1220
|
* 获取元素的样式值
|
|
1022
1221
|
*
|
|
@@ -1115,7 +1314,7 @@ const W = {
|
|
|
1115
1314
|
*/
|
|
1116
1315
|
addClass(t, e) {
|
|
1117
1316
|
if (t.classList !== void 0) {
|
|
1118
|
-
const n =
|
|
1317
|
+
const n = E(e);
|
|
1119
1318
|
for (let r = 0, s = n.length; r < s; r++)
|
|
1120
1319
|
t.classList.add(n[r]);
|
|
1121
1320
|
} else if (!this.hasClass(t, e)) {
|
|
@@ -1130,7 +1329,7 @@ const W = {
|
|
|
1130
1329
|
* @param name 要移除的类名,多个类名用空格分隔
|
|
1131
1330
|
*/
|
|
1132
1331
|
removeClass(t, e) {
|
|
1133
|
-
t.classList !== void 0 ?
|
|
1332
|
+
t.classList !== void 0 ? E(e).forEach((r) => t.classList.remove(r)) : this.setClass(t, (" " + this.getClass(t) + " ").replace(" " + e + " ", " ").trim());
|
|
1134
1333
|
},
|
|
1135
1334
|
/**
|
|
1136
1335
|
* 设置元素的 CSS 类名
|
|
@@ -1150,7 +1349,198 @@ const W = {
|
|
|
1150
1349
|
parseFromString(t) {
|
|
1151
1350
|
return new DOMParser().parseFromString(t, "text/xml").children[0];
|
|
1152
1351
|
}
|
|
1153
|
-
},
|
|
1352
|
+
}, M = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"], Y = {
|
|
1353
|
+
/**
|
|
1354
|
+
* 获取GeoJSON要素的几何类型
|
|
1355
|
+
*
|
|
1356
|
+
* @param feature GeoJSONFeature 类型的要素
|
|
1357
|
+
* @returns 返回要素的几何类型,如果要素没有几何属性则返回 null
|
|
1358
|
+
*/
|
|
1359
|
+
getGeoJsonType(t) {
|
|
1360
|
+
return t.geometry ? t.geometry.type : null;
|
|
1361
|
+
},
|
|
1362
|
+
/**
|
|
1363
|
+
* 判断给定的GeoJSON要素是否为有效的GeoJSON格式
|
|
1364
|
+
*
|
|
1365
|
+
* @param feature 要判断的GeoJSON要素
|
|
1366
|
+
* @returns 如果为有效的GeoJSON格式则返回true,否则返回false
|
|
1367
|
+
*/
|
|
1368
|
+
isGeoJson(t) {
|
|
1369
|
+
const e = this.getGeoJsonType(t);
|
|
1370
|
+
if (e) {
|
|
1371
|
+
for (let n = 0, r = M.length; n < r; n++)
|
|
1372
|
+
if (M[n] === e)
|
|
1373
|
+
return !0;
|
|
1374
|
+
}
|
|
1375
|
+
return !1;
|
|
1376
|
+
},
|
|
1377
|
+
/**
|
|
1378
|
+
* 判断是否为 GeoJSON 多边形
|
|
1379
|
+
*
|
|
1380
|
+
* @param feature GeoJSONFeature 对象
|
|
1381
|
+
* @returns 返回布尔值,表示是否为 GeoJSON 多边形
|
|
1382
|
+
*/
|
|
1383
|
+
isGeoJsonPolygon(t) {
|
|
1384
|
+
const e = this.getGeoJsonType(t);
|
|
1385
|
+
return !!(e && (e === M[4] || e === M[5]));
|
|
1386
|
+
},
|
|
1387
|
+
/**
|
|
1388
|
+
* 判断给定的 GeoJSONFeature 是否为 GeoJSON 线
|
|
1389
|
+
*
|
|
1390
|
+
* @param feature GeoJSONFeature 对象
|
|
1391
|
+
* @returns 是 GeoJSON 线返回 true,否则返回 false
|
|
1392
|
+
*/
|
|
1393
|
+
isGeoJsonLine(t) {
|
|
1394
|
+
const e = this.getGeoJsonType(t);
|
|
1395
|
+
return !!(e && (e === M[2] || e === M[3]));
|
|
1396
|
+
},
|
|
1397
|
+
/**
|
|
1398
|
+
* 判断是否为 GeoJSON 点类型
|
|
1399
|
+
*
|
|
1400
|
+
* @param feature GeoJSONFeature 对象
|
|
1401
|
+
* @returns 是点类型返回 true,否则返回 false
|
|
1402
|
+
*/
|
|
1403
|
+
isGeoJsonPoint(t) {
|
|
1404
|
+
const e = this.getGeoJsonType(t);
|
|
1405
|
+
return !!(e && (e === M[0] || e === M[1]));
|
|
1406
|
+
},
|
|
1407
|
+
/**
|
|
1408
|
+
* 判断传入的 GeoJSONFeature 是否为 Multi 类型的 GeoJSON。
|
|
1409
|
+
*
|
|
1410
|
+
* @param feature GeoJSONFeature 类型的参数,待判断是否为 Multi 类型的 GeoJSON。
|
|
1411
|
+
* @returns 返回一个布尔值,如果传入的 GeoJSONFeature 是 Multi 类型的 GeoJSON,则返回 true,否则返回 false。
|
|
1412
|
+
*/
|
|
1413
|
+
isGeoJsonMulti(t) {
|
|
1414
|
+
const e = this.getGeoJsonType(t);
|
|
1415
|
+
return !!(e && e.indexOf("Multi") > -1);
|
|
1416
|
+
},
|
|
1417
|
+
/**
|
|
1418
|
+
* 获取GeoJSON要素的坐标数组
|
|
1419
|
+
*
|
|
1420
|
+
* @param feature GeoJSONFeature对象
|
|
1421
|
+
* @returns 返回一个包含坐标数组的数组,可以是二维、三维或四维数组
|
|
1422
|
+
*/
|
|
1423
|
+
getGeoJsonCoordinates(t) {
|
|
1424
|
+
return t.geometry ? t.geometry.coordinates : [];
|
|
1425
|
+
},
|
|
1426
|
+
/**
|
|
1427
|
+
* 获取GeoJSON要素的中心点坐标
|
|
1428
|
+
*
|
|
1429
|
+
* @param feature GeoJSON要素
|
|
1430
|
+
* @param out 输出坐标对象,默认为null
|
|
1431
|
+
* @returns 返回中心点坐标,如果无法获取则返回null
|
|
1432
|
+
*/
|
|
1433
|
+
getGeoJsonCenter(t, e) {
|
|
1434
|
+
const n = this.getGeoJsonType(t);
|
|
1435
|
+
if (!n || !t.geometry)
|
|
1436
|
+
return null;
|
|
1437
|
+
const s = t.geometry.coordinates;
|
|
1438
|
+
if (!s)
|
|
1439
|
+
return null;
|
|
1440
|
+
let i = 0, a = 0, o = 0;
|
|
1441
|
+
switch (n) {
|
|
1442
|
+
case "Point": {
|
|
1443
|
+
i = s[0], a = s[1], o++;
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
case "MultiPoint":
|
|
1447
|
+
case "LineString": {
|
|
1448
|
+
for (let c = 0, u = s.length; c < u; c++)
|
|
1449
|
+
i += s[c][0], a += s[c][1], o++;
|
|
1450
|
+
break;
|
|
1451
|
+
}
|
|
1452
|
+
case "MultiLineString":
|
|
1453
|
+
case "Polygon": {
|
|
1454
|
+
for (let c = 0, u = s.length; c < u; c++)
|
|
1455
|
+
for (let f = 0, p = s[c].length; f < p; f++)
|
|
1456
|
+
i += s[c][f][0], a += s[c][f][1], o++;
|
|
1457
|
+
break;
|
|
1458
|
+
}
|
|
1459
|
+
case "MultiPolygon": {
|
|
1460
|
+
for (let c = 0, u = s.length; c < u; c++)
|
|
1461
|
+
for (let f = 0, p = s[c].length; f < p; f++)
|
|
1462
|
+
for (let A = 0, b = s[c][f].length; A < b; A++)
|
|
1463
|
+
i += s[c][f][A][0], a += s[c][f][A][1], o++;
|
|
1464
|
+
break;
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
const l = i / o, h = a / o;
|
|
1468
|
+
return e ? (e.x = l, e.y = h, e) : { x: l, y: h };
|
|
1469
|
+
},
|
|
1470
|
+
/**
|
|
1471
|
+
* 将一个包含多个点、线或面的 GeoJSON 特征对象拆分成多个独立的 GeoJSON 特征对象数组。
|
|
1472
|
+
*
|
|
1473
|
+
* @param feature 包含多个点、线或面的 GeoJSON 特征对象
|
|
1474
|
+
* @returns 返回一个 GeoJSON 特征对象数组,如果拆分失败则返回 null
|
|
1475
|
+
*/
|
|
1476
|
+
spliteGeoJsonMulti(t) {
|
|
1477
|
+
const e = this.getGeoJsonType(t);
|
|
1478
|
+
if (!e || !t.geometry)
|
|
1479
|
+
return null;
|
|
1480
|
+
const n = t.geometry, r = t.properties || {}, s = n.coordinates;
|
|
1481
|
+
if (!s)
|
|
1482
|
+
return null;
|
|
1483
|
+
const i = [];
|
|
1484
|
+
let a;
|
|
1485
|
+
switch (e) {
|
|
1486
|
+
case "MultiPoint": {
|
|
1487
|
+
a = "Point";
|
|
1488
|
+
break;
|
|
1489
|
+
}
|
|
1490
|
+
case "MultiLineString": {
|
|
1491
|
+
a = "LineString";
|
|
1492
|
+
break;
|
|
1493
|
+
}
|
|
1494
|
+
case "MultiPolygon": {
|
|
1495
|
+
a = "Polygon";
|
|
1496
|
+
break;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
if (a)
|
|
1500
|
+
for (let o = 0, l = s.length; o < l; o++)
|
|
1501
|
+
i.push({
|
|
1502
|
+
type: "Feature",
|
|
1503
|
+
geometry: {
|
|
1504
|
+
type: a,
|
|
1505
|
+
coordinates: s[o]
|
|
1506
|
+
},
|
|
1507
|
+
properties: r
|
|
1508
|
+
});
|
|
1509
|
+
else
|
|
1510
|
+
i.push(t);
|
|
1511
|
+
return i;
|
|
1512
|
+
},
|
|
1513
|
+
/**
|
|
1514
|
+
* 根据坐标数组生成GeoJSON要素
|
|
1515
|
+
*
|
|
1516
|
+
* @param coordinates 坐标数组
|
|
1517
|
+
* @returns GeoJSONFeature 生成的GeoJSON要素
|
|
1518
|
+
* @throws Error 如果coordinates参数格式错误
|
|
1519
|
+
*/
|
|
1520
|
+
getGeoJsonByCoordinates(t) {
|
|
1521
|
+
if (!Array.isArray(t))
|
|
1522
|
+
throw Error("coordinates 参数格式错误");
|
|
1523
|
+
let e;
|
|
1524
|
+
if (t.length === 2 && typeof t[0] == "number" && typeof t[1] == "number")
|
|
1525
|
+
e = "Point";
|
|
1526
|
+
else if (Array.isArray(t[0]) && t[0].length === 2)
|
|
1527
|
+
e = "LineString";
|
|
1528
|
+
else if (Array.isArray(t[0]) && Array.isArray(t[0][0])) {
|
|
1529
|
+
const n = t[0];
|
|
1530
|
+
if (n[0].join(",") === n[n.length - 1].join(","))
|
|
1531
|
+
e = "Polygon";
|
|
1532
|
+
else if (t.length > 1)
|
|
1533
|
+
e = "MultiPolygon";
|
|
1534
|
+
else
|
|
1535
|
+
throw Error("coordinates 参数格式错误");
|
|
1536
|
+
} else
|
|
1537
|
+
throw Error("coordinates 参数格式错误");
|
|
1538
|
+
return {
|
|
1539
|
+
type: "Feature",
|
|
1540
|
+
geometry: { type: e, coordinates: t }
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
}, z = {
|
|
1154
1544
|
toRadian: Math.PI / 180,
|
|
1155
1545
|
R: 6371393,
|
|
1156
1546
|
/**
|
|
@@ -1181,9 +1571,9 @@ const W = {
|
|
|
1181
1571
|
* @returns 返回两点之间的距离,单位为米
|
|
1182
1572
|
*/
|
|
1183
1573
|
distanceByPoints(t, e) {
|
|
1184
|
-
const { lng: n, lat: r } = t, { lng: s, lat: i } = e,
|
|
1185
|
-
let h =
|
|
1186
|
-
return h > 1 && (h = 1), h < -1 && (h = -1), Math.acos(h) *
|
|
1574
|
+
const { lng: n, lat: r } = t, { lng: s, lat: i } = e, a = 6371e3, o = Math.cos(r * Math.PI / 180) * Math.cos(i * Math.PI / 180) * Math.cos((n - s) * Math.PI / 180), l = Math.sin(r * Math.PI / 180) * Math.sin(i * Math.PI / 180);
|
|
1575
|
+
let h = o + l;
|
|
1576
|
+
return h > 1 && (h = 1), h < -1 && (h = -1), Math.acos(h) * a;
|
|
1187
1577
|
},
|
|
1188
1578
|
/**
|
|
1189
1579
|
* 格式化经纬度为度分秒格式
|
|
@@ -1195,8 +1585,8 @@ const W = {
|
|
|
1195
1585
|
formatLnglat(t, e) {
|
|
1196
1586
|
let n = "";
|
|
1197
1587
|
function r(s) {
|
|
1198
|
-
const i = Math.floor(s),
|
|
1199
|
-
return `${i}°${
|
|
1588
|
+
const i = Math.floor(s), a = Math.floor((s - i) * 60), o = (s - i) * 3600 - a * 60;
|
|
1589
|
+
return `${i}°${a}′${o.toFixed(2)}″`;
|
|
1200
1590
|
}
|
|
1201
1591
|
return this.isLnglat(t, e) ? n = r(t) + "," + r(e) : isNaN(t) ? isNaN(e) || (n = r(e)) : n = r(t), n;
|
|
1202
1592
|
},
|
|
@@ -1210,11 +1600,11 @@ const W = {
|
|
|
1210
1600
|
transformLnglat(t, e) {
|
|
1211
1601
|
function n(r) {
|
|
1212
1602
|
let i = /[sw]/i.test(r) ? -1 : 1;
|
|
1213
|
-
const
|
|
1214
|
-
let
|
|
1215
|
-
for (let
|
|
1216
|
-
|
|
1217
|
-
return
|
|
1603
|
+
const a = r.match(/[\d.]+/g) || [];
|
|
1604
|
+
let o = 0;
|
|
1605
|
+
for (let l = 0; l < a.length; l++)
|
|
1606
|
+
o += parseFloat(a[l]) / i, i *= 60;
|
|
1607
|
+
return o;
|
|
1218
1608
|
}
|
|
1219
1609
|
if (t && e)
|
|
1220
1610
|
return {
|
|
@@ -1230,15 +1620,15 @@ const W = {
|
|
|
1230
1620
|
* @returns 返回字符串,表示点相对于多边形的位置:'in'表示在多边形内,'out'表示在多边形外,'on'表示在多边形上
|
|
1231
1621
|
*/
|
|
1232
1622
|
rayCasting(t, e) {
|
|
1233
|
-
for (var n = t.x, r = t.y, s = !1, i = 0,
|
|
1234
|
-
var
|
|
1235
|
-
if (
|
|
1623
|
+
for (var n = t.x, r = t.y, s = !1, i = 0, a = e.length, o = a - 1; i < a; o = i, i++) {
|
|
1624
|
+
var l = e[i].x, h = e[i].y, c = e[o].x, u = e[o].y;
|
|
1625
|
+
if (l === n && h === r || c === n && u === r)
|
|
1236
1626
|
return "on";
|
|
1237
1627
|
if (h < r && u >= r || h >= r && u < r) {
|
|
1238
|
-
var
|
|
1239
|
-
if (
|
|
1628
|
+
var f = l + (r - h) * (c - l) / (u - h);
|
|
1629
|
+
if (f === n)
|
|
1240
1630
|
return "on";
|
|
1241
|
-
|
|
1631
|
+
f > n && (s = !s);
|
|
1242
1632
|
}
|
|
1243
1633
|
}
|
|
1244
1634
|
return s ? "in" : "out";
|
|
@@ -1263,8 +1653,8 @@ const W = {
|
|
|
1263
1653
|
* @returns 返回一个对象,包含angle和distance属性,分别表示两点之间的角度(以度为单位,取值范围为0~359)和距离
|
|
1264
1654
|
*/
|
|
1265
1655
|
calcBearAndDis(t, e) {
|
|
1266
|
-
const { x: n, y: r } = t, { x: s, y: i } = e,
|
|
1267
|
-
return { angle: (Math.atan2(
|
|
1656
|
+
const { x: n, y: r } = t, { x: s, y: i } = e, a = s - n, o = i - r, l = Math.sqrt(a * a + o * o);
|
|
1657
|
+
return { angle: (Math.atan2(o, a) * (180 / Math.PI) + 360 + 90) % 360, distance: l };
|
|
1268
1658
|
},
|
|
1269
1659
|
/**
|
|
1270
1660
|
* 根据两个经纬度点计算方位角和距离
|
|
@@ -1274,9 +1664,9 @@ const W = {
|
|
|
1274
1664
|
* @returns 包含方位角和距离的对象
|
|
1275
1665
|
*/
|
|
1276
1666
|
calcBearAndDisByPoints(t, e) {
|
|
1277
|
-
var n = t.lat * 1, r = t.lng * 1, s = e.lat * 1, i = e.lng * 1,
|
|
1667
|
+
var n = t.lat * 1, r = t.lng * 1, s = e.lat * 1, i = e.lng * 1, a = Math.sin((i - r) * this.toRadian) * Math.cos(s * this.toRadian), o = Math.cos(n * this.toRadian) * Math.sin(s * this.toRadian) - Math.sin(n * this.toRadian) * Math.cos(s * this.toRadian) * Math.cos((i - r) * this.toRadian), l = Math.atan2(a, o) * (180 / Math.PI), h = (s - n) * this.toRadian, c = (i - r) * this.toRadian, u = Math.sin(h / 2) * Math.sin(h / 2) + Math.cos(n * this.toRadian) * Math.cos(s * this.toRadian) * Math.sin(c / 2) * Math.sin(c / 2), f = 2 * Math.atan2(Math.sqrt(u), Math.sqrt(1 - u)), p = this.R * f;
|
|
1278
1668
|
return {
|
|
1279
|
-
angle:
|
|
1669
|
+
angle: l,
|
|
1280
1670
|
distance: p
|
|
1281
1671
|
};
|
|
1282
1672
|
},
|
|
@@ -1289,14 +1679,14 @@ const W = {
|
|
|
1289
1679
|
* @returns 点P到线段P1P2的最短距离
|
|
1290
1680
|
*/
|
|
1291
1681
|
distanceToSegment(t, e, n) {
|
|
1292
|
-
const r = t.x, s = t.y, i = e.x,
|
|
1682
|
+
const r = t.x, s = t.y, i = e.x, a = e.y, o = n.x, l = n.y, h = (o - i) * (r - i) + (l - a) * (s - a);
|
|
1293
1683
|
if (h <= 0)
|
|
1294
|
-
return Math.sqrt((r - i) * (r - i) + (s -
|
|
1295
|
-
const
|
|
1296
|
-
if (h >=
|
|
1297
|
-
return Math.sqrt((r -
|
|
1298
|
-
const u = h /
|
|
1299
|
-
return Math.sqrt((r -
|
|
1684
|
+
return Math.sqrt((r - i) * (r - i) + (s - a) * (s - a));
|
|
1685
|
+
const c = (o - i) * (o - i) + (l - a) * (l - a);
|
|
1686
|
+
if (h >= c)
|
|
1687
|
+
return Math.sqrt((r - o) * (r - o) + (s - l) * (s - l));
|
|
1688
|
+
const u = h / c, f = i + (o - i) * u, p = a + (l - a) * u;
|
|
1689
|
+
return Math.sqrt((r - f) * (r - f) + (s - p) * (s - p));
|
|
1300
1690
|
},
|
|
1301
1691
|
/**
|
|
1302
1692
|
* 根据给定的经纬度、角度和距离计算新的经纬度点
|
|
@@ -1309,10 +1699,10 @@ const W = {
|
|
|
1309
1699
|
calcPointByBearAndDis(t, e, n) {
|
|
1310
1700
|
const r = m.toRadians(t.lat * 1), s = m.toRadians(t.lng * 1), i = n / this.R;
|
|
1311
1701
|
e = m.toRadians(e);
|
|
1312
|
-
const
|
|
1702
|
+
const a = Math.asin(Math.sin(r) * Math.cos(i) + Math.cos(r) * Math.sin(i) * Math.cos(e)), o = s + Math.atan2(Math.sin(e) * Math.sin(i) * Math.cos(r), Math.cos(i) - Math.sin(r) * Math.sin(a));
|
|
1313
1703
|
return {
|
|
1314
|
-
lat: m.toDegrees(
|
|
1315
|
-
lng: m.toDegrees(
|
|
1704
|
+
lat: m.toDegrees(a),
|
|
1705
|
+
lng: m.toDegrees(o)
|
|
1316
1706
|
};
|
|
1317
1707
|
},
|
|
1318
1708
|
/**
|
|
@@ -1341,134 +1731,20 @@ const W = {
|
|
|
1341
1731
|
var s = e * Math.PI / 180;
|
|
1342
1732
|
const i = n / 2 * Math.log((1 + Math.sin(s)) / (1 - Math.sin(s)));
|
|
1343
1733
|
return { x: r, y: i };
|
|
1344
|
-
}
|
|
1345
|
-
}, y = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"], j = {
|
|
1346
|
-
getGeoJsonType(t) {
|
|
1347
|
-
return t.geometry ? t.geometry.type : null;
|
|
1348
|
-
},
|
|
1349
|
-
isGeoJson(t) {
|
|
1350
|
-
const e = this.getGeoJsonType(t);
|
|
1351
|
-
if (e) {
|
|
1352
|
-
for (let n = 0, r = y.length; n < r; n++)
|
|
1353
|
-
if (y[n] === e)
|
|
1354
|
-
return !0;
|
|
1355
|
-
}
|
|
1356
|
-
return !1;
|
|
1357
|
-
},
|
|
1358
|
-
isGeoJsonPolygon(t) {
|
|
1359
|
-
const e = this.getGeoJsonType(t);
|
|
1360
|
-
return !!(e && (e === y[4] || e === y[5]));
|
|
1361
|
-
},
|
|
1362
|
-
isGeoJsonLine(t) {
|
|
1363
|
-
const e = this.getGeoJsonType(t);
|
|
1364
|
-
return !!(e && (e === y[2] || e === y[3]));
|
|
1365
|
-
},
|
|
1366
|
-
isGeoJsonPoint(t) {
|
|
1367
|
-
const e = this.getGeoJsonType(t);
|
|
1368
|
-
return !!(e && (e === y[0] || e === y[1]));
|
|
1369
|
-
},
|
|
1370
|
-
isGeoJsonMulti(t) {
|
|
1371
|
-
const e = this.getGeoJsonType(t);
|
|
1372
|
-
return !!(e && e.indexOf("Multi") > -1);
|
|
1373
|
-
},
|
|
1374
|
-
getGeoJsonCoordinates(t) {
|
|
1375
|
-
return t.geometry ? t.geometry.coordinates : [];
|
|
1376
|
-
},
|
|
1377
|
-
getGeoJsonCenter(t, e) {
|
|
1378
|
-
const n = this.getGeoJsonType(t);
|
|
1379
|
-
if (!n || !t.geometry)
|
|
1380
|
-
return null;
|
|
1381
|
-
const s = t.geometry.coordinates;
|
|
1382
|
-
if (!s)
|
|
1383
|
-
return null;
|
|
1384
|
-
let i = 0, o = 0, a = 0;
|
|
1385
|
-
switch (n) {
|
|
1386
|
-
case "Point": {
|
|
1387
|
-
i = s[0], o = s[1], a++;
|
|
1388
|
-
break;
|
|
1389
|
-
}
|
|
1390
|
-
case "MultiPoint":
|
|
1391
|
-
case "LineString": {
|
|
1392
|
-
for (let l = 0, u = s.length; l < u; l++)
|
|
1393
|
-
i += s[l][0], o += s[l][1], a++;
|
|
1394
|
-
break;
|
|
1395
|
-
}
|
|
1396
|
-
case "MultiLineString":
|
|
1397
|
-
case "Polygon": {
|
|
1398
|
-
for (let l = 0, u = s.length; l < u; l++)
|
|
1399
|
-
for (let d = 0, p = s[l].length; d < p; d++)
|
|
1400
|
-
i += s[l][d][0], o += s[l][d][1], a++;
|
|
1401
|
-
break;
|
|
1402
|
-
}
|
|
1403
|
-
case "MultiPolygon": {
|
|
1404
|
-
for (let l = 0, u = s.length; l < u; l++)
|
|
1405
|
-
for (let d = 0, p = s[l].length; d < p; d++)
|
|
1406
|
-
for (let M = 0, D = s[l][d].length; M < D; M++)
|
|
1407
|
-
i += s[l][d][M][0], o += s[l][d][M][1], a++;
|
|
1408
|
-
break;
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
const c = i / a, h = o / a;
|
|
1412
|
-
return e ? (e.x = c, e.y = h, e) : { x: c, y: h };
|
|
1413
1734
|
},
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
o = "Point";
|
|
1426
|
-
break;
|
|
1427
|
-
}
|
|
1428
|
-
case "MultiLineString": {
|
|
1429
|
-
o = "LineString";
|
|
1430
|
-
break;
|
|
1431
|
-
}
|
|
1432
|
-
case "MultiPolygon": {
|
|
1433
|
-
o = "Polygon";
|
|
1434
|
-
break;
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
if (o)
|
|
1438
|
-
for (let a = 0, c = s.length; a < c; a++)
|
|
1439
|
-
i.push({
|
|
1440
|
-
type: "Feature",
|
|
1441
|
-
geometry: {
|
|
1442
|
-
type: o,
|
|
1443
|
-
coordinates: s[a]
|
|
1444
|
-
},
|
|
1445
|
-
properties: r
|
|
1446
|
-
});
|
|
1447
|
-
else
|
|
1448
|
-
i.push(t);
|
|
1449
|
-
return i;
|
|
1450
|
-
},
|
|
1451
|
-
getFeatureFromCoordinate(t) {
|
|
1452
|
-
return {
|
|
1453
|
-
type: "Feature",
|
|
1454
|
-
geometry: {
|
|
1455
|
-
type: "Point",
|
|
1456
|
-
// 根据coordinate判断shape
|
|
1457
|
-
coordinates: t
|
|
1458
|
-
}
|
|
1459
|
-
};
|
|
1460
|
-
},
|
|
1461
|
-
getCoordinateFromFeature(t) {
|
|
1462
|
-
return [];
|
|
1463
|
-
}
|
|
1464
|
-
}, K = {
|
|
1465
|
-
deepClone(t) {
|
|
1466
|
-
return structuredClone(t);
|
|
1467
|
-
},
|
|
1468
|
-
isEqual(t, e) {
|
|
1469
|
-
return JSON.stringify(t) === JSON.stringify(e);
|
|
1735
|
+
/**
|
|
1736
|
+
* 根据百分比获取坐标
|
|
1737
|
+
*
|
|
1738
|
+
* @param start 起点坐标
|
|
1739
|
+
* @param end 终点坐标
|
|
1740
|
+
* @param percent 百分比,取值范围0-1
|
|
1741
|
+
* @returns 返回插值后的坐标
|
|
1742
|
+
*/
|
|
1743
|
+
interpolate({ x: t, y: e, z: n = 0 }, { x: r, y: s, z: i = 0 }, a) {
|
|
1744
|
+
const o = r - t, l = s - e, h = i - n;
|
|
1745
|
+
return { x: t + o * a, y: e + l * a, z: n + h * a };
|
|
1470
1746
|
}
|
|
1471
|
-
},
|
|
1747
|
+
}, X = {
|
|
1472
1748
|
/**
|
|
1473
1749
|
* 将Base64编码的字符串转换为Blob对象
|
|
1474
1750
|
*
|
|
@@ -1477,8 +1753,8 @@ const W = {
|
|
|
1477
1753
|
*/
|
|
1478
1754
|
convertBase64ToBlob(t) {
|
|
1479
1755
|
const e = t.split(",")[0].split(":")[1].split(";")[0], n = atob(t.split(",")[1]), r = new Array(n.length);
|
|
1480
|
-
for (let
|
|
1481
|
-
r[
|
|
1756
|
+
for (let a = 0; a < n.length; a++)
|
|
1757
|
+
r[a] = n.charCodeAt(a);
|
|
1482
1758
|
const s = new Uint8Array(r);
|
|
1483
1759
|
return new Blob([s], { type: e });
|
|
1484
1760
|
},
|
|
@@ -1490,27 +1766,6 @@ const W = {
|
|
|
1490
1766
|
* @param height 图片的高度,默认为图片原始高度
|
|
1491
1767
|
* @returns 返回Promise对象,解析后得到包含Base64编码数据的对象
|
|
1492
1768
|
*/
|
|
1493
|
-
convertUrlToBase64(t, e, n) {
|
|
1494
|
-
return new Promise((r, s) => {
|
|
1495
|
-
var i = new Image();
|
|
1496
|
-
i.crossOrigin = "Anonymous", i.src = t, i.onload = function() {
|
|
1497
|
-
var o = document.createElement("canvas");
|
|
1498
|
-
o.width = e || i.width, o.height = n || i.height;
|
|
1499
|
-
var a = o.getContext("2d");
|
|
1500
|
-
if (!a) {
|
|
1501
|
-
s(new Error("Failed to get canvas context"));
|
|
1502
|
-
return;
|
|
1503
|
-
}
|
|
1504
|
-
a.drawImage(i, 0, 0, i.width, i.height);
|
|
1505
|
-
var c = i.src.substring(i.src.lastIndexOf(".") + 1).toLowerCase(), h = o.toDataURL("image/" + c), l = {
|
|
1506
|
-
dataURL: h,
|
|
1507
|
-
type: "image/" + c,
|
|
1508
|
-
ext: c
|
|
1509
|
-
};
|
|
1510
|
-
r(l);
|
|
1511
|
-
}, i.onerror = s;
|
|
1512
|
-
});
|
|
1513
|
-
},
|
|
1514
1769
|
/**
|
|
1515
1770
|
* 将base64字符串转换为文件对象
|
|
1516
1771
|
*
|
|
@@ -1519,10 +1774,10 @@ const W = {
|
|
|
1519
1774
|
* @returns 返回文件对象
|
|
1520
1775
|
*/
|
|
1521
1776
|
convertBase64ToFile(t, e) {
|
|
1522
|
-
const n = t.split(","), r = n[0].match(/:(.*?);/), s = r ? r[1] : "image/png", i = atob(n[1]),
|
|
1523
|
-
for (let
|
|
1524
|
-
|
|
1525
|
-
return new File([
|
|
1777
|
+
const n = t.split(","), r = n[0].match(/:(.*?);/), s = r ? r[1] : "image/png", i = atob(n[1]), a = new Uint8Array(i.length);
|
|
1778
|
+
for (let l = 0; l < i.length; l++)
|
|
1779
|
+
a[l] = i.charCodeAt(l);
|
|
1780
|
+
return new File([a], e, { type: s });
|
|
1526
1781
|
},
|
|
1527
1782
|
/**
|
|
1528
1783
|
* 从文件下载数据
|
|
@@ -1545,7 +1800,7 @@ const W = {
|
|
|
1545
1800
|
var n = document.createElement("a");
|
|
1546
1801
|
n.href = t, n.download = e || "", n.click(), window.URL.revokeObjectURL(n.href);
|
|
1547
1802
|
}
|
|
1548
|
-
},
|
|
1803
|
+
}, Q = {
|
|
1549
1804
|
/**
|
|
1550
1805
|
* 防抖函数,在指定的等待时间内,如果连续触发事件,则只在最后一次触发后执行函数。适用于像搜索输入框这种需要用户停止输入后才调用的场景
|
|
1551
1806
|
*
|
|
@@ -1555,15 +1810,15 @@ const W = {
|
|
|
1555
1810
|
* @returns 返回防抖后的函数。
|
|
1556
1811
|
*/
|
|
1557
1812
|
debounce(t, e, n = !0) {
|
|
1558
|
-
let r = null, s, i,
|
|
1559
|
-
const
|
|
1560
|
-
const
|
|
1561
|
-
|
|
1813
|
+
let r = null, s, i, a;
|
|
1814
|
+
const o = () => {
|
|
1815
|
+
const l = Date.now() - i;
|
|
1816
|
+
l < e && l > 0 ? r = setTimeout(o, e - l) : (r = null, n || (a = t.apply(this, s)));
|
|
1562
1817
|
};
|
|
1563
|
-
return (...
|
|
1818
|
+
return (...l) => {
|
|
1564
1819
|
i = Date.now();
|
|
1565
1820
|
const h = n && !r;
|
|
1566
|
-
return r || (r = setTimeout(
|
|
1821
|
+
return r || (r = setTimeout(o, e)), h && (a = t.apply(this, l), r || (l = null)), a;
|
|
1567
1822
|
};
|
|
1568
1823
|
},
|
|
1569
1824
|
/**
|
|
@@ -1578,8 +1833,8 @@ const W = {
|
|
|
1578
1833
|
let r = 0, s = null;
|
|
1579
1834
|
return (...i) => {
|
|
1580
1835
|
if (n === 1) {
|
|
1581
|
-
const
|
|
1582
|
-
|
|
1836
|
+
const a = Date.now();
|
|
1837
|
+
a - r >= e && (t.apply(this, i), r = a);
|
|
1583
1838
|
} else n === 2 && (s || (s = setTimeout(() => {
|
|
1584
1839
|
s = null, t.apply(this, i);
|
|
1585
1840
|
}, e)));
|
|
@@ -1616,7 +1871,7 @@ const W = {
|
|
|
1616
1871
|
r++, r < Math.floor(n / e) && (t.call(this), setTimeout(this.recurve.bind(this, t, e, n), e));
|
|
1617
1872
|
}, e);
|
|
1618
1873
|
}
|
|
1619
|
-
},
|
|
1874
|
+
}, V = {
|
|
1620
1875
|
/**
|
|
1621
1876
|
* 校验字符串是否符合指定类型
|
|
1622
1877
|
*
|
|
@@ -1724,7 +1979,7 @@ const W = {
|
|
|
1724
1979
|
*/
|
|
1725
1980
|
tag(t, ...e) {
|
|
1726
1981
|
return e = e.map((n) => {
|
|
1727
|
-
switch (
|
|
1982
|
+
switch (y.getDataType(n)) {
|
|
1728
1983
|
case "Object":
|
|
1729
1984
|
return n || "{}";
|
|
1730
1985
|
case "Array":
|
|
@@ -1756,9 +2011,9 @@ const W = {
|
|
|
1756
2011
|
if (t.replace(r, "mm").length <= n)
|
|
1757
2012
|
return t;
|
|
1758
2013
|
for (var s = Math.floor(n / 2), i = s; i < t.length; i++) {
|
|
1759
|
-
let
|
|
1760
|
-
if (
|
|
1761
|
-
return
|
|
2014
|
+
let a = t.substring(e, i);
|
|
2015
|
+
if (a.replace(r, "mm").length >= n)
|
|
2016
|
+
return a;
|
|
1762
2017
|
}
|
|
1763
2018
|
return t;
|
|
1764
2019
|
},
|
|
@@ -1769,15 +2024,22 @@ const W = {
|
|
|
1769
2024
|
* @returns 转换后的字符串,如果值为空,则返回空字符串
|
|
1770
2025
|
*/
|
|
1771
2026
|
asString(t) {
|
|
1772
|
-
if (
|
|
2027
|
+
if (y.isEmpty(t))
|
|
1773
2028
|
return "";
|
|
1774
|
-
switch (
|
|
2029
|
+
switch (y.getDataType(t)) {
|
|
1775
2030
|
case "Object":
|
|
1776
2031
|
case "Array":
|
|
1777
2032
|
return JSON.stringify(t);
|
|
1778
2033
|
default:
|
|
1779
2034
|
return t;
|
|
1780
2035
|
}
|
|
2036
|
+
},
|
|
2037
|
+
replaceAll(t, e, n) {
|
|
2038
|
+
if (!t)
|
|
2039
|
+
return t;
|
|
2040
|
+
for (; t.indexOf(e) > -1; )
|
|
2041
|
+
t = t.replace(e, n);
|
|
2042
|
+
return t;
|
|
1781
2043
|
}
|
|
1782
2044
|
}, g = class g {
|
|
1783
2045
|
static set(e, n = null, r = null) {
|
|
@@ -1830,11 +2092,11 @@ const W = {
|
|
|
1830
2092
|
}) : localStorage.clear();
|
|
1831
2093
|
}
|
|
1832
2094
|
};
|
|
1833
|
-
|
|
2095
|
+
d(g, "prefix", ""), d(g, "_getPrefixedKey", function(e, n) {
|
|
1834
2096
|
return n = n || {}, n.noPrefix ? e : g.prefix + e;
|
|
1835
2097
|
});
|
|
1836
2098
|
let S = g;
|
|
1837
|
-
const
|
|
2099
|
+
const Z = {
|
|
1838
2100
|
/**
|
|
1839
2101
|
* 将json对象转换为查询字符串
|
|
1840
2102
|
*
|
|
@@ -1860,49 +2122,51 @@ const Q = {
|
|
|
1860
2122
|
*/
|
|
1861
2123
|
query2Json(t = window.location.href, e = !0) {
|
|
1862
2124
|
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: r, hash: s } = new URL(t), i = [r, s];
|
|
1863
|
-
let
|
|
1864
|
-
for (let
|
|
1865
|
-
const
|
|
1866
|
-
if (
|
|
1867
|
-
const
|
|
1868
|
-
if (
|
|
1869
|
-
for (let u = 1; u <
|
|
1870
|
-
let
|
|
1871
|
-
for (;
|
|
1872
|
-
|
|
2125
|
+
let a = {};
|
|
2126
|
+
for (let o = 0; o < i.length; o++) {
|
|
2127
|
+
const l = i[o];
|
|
2128
|
+
if (l) {
|
|
2129
|
+
const c = l.replace(/#|\//g, "").split("?");
|
|
2130
|
+
if (c.length > 1)
|
|
2131
|
+
for (let u = 1; u < c.length; u++) {
|
|
2132
|
+
let f;
|
|
2133
|
+
for (; f = n.exec(c[u]); )
|
|
2134
|
+
a[f[1]] = e ? decodeURIComponent(f[2]) : f[2];
|
|
1873
2135
|
}
|
|
1874
2136
|
}
|
|
1875
2137
|
}
|
|
1876
|
-
return
|
|
2138
|
+
return a;
|
|
1877
2139
|
}
|
|
1878
2140
|
};
|
|
1879
2141
|
export {
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
q as
|
|
1888
|
-
W as
|
|
1889
|
-
|
|
1890
|
-
C as
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
2142
|
+
w as AjaxUtil,
|
|
2143
|
+
G as ArrayUtil,
|
|
2144
|
+
F as AudioPlayer,
|
|
2145
|
+
J as BrowserUtil,
|
|
2146
|
+
B as CanvasDrawer,
|
|
2147
|
+
j as ColorUtil,
|
|
2148
|
+
H as Cookie,
|
|
2149
|
+
q as CoordsUtil,
|
|
2150
|
+
W as DateUtil,
|
|
2151
|
+
K as DomUtil,
|
|
2152
|
+
C as ErrorType,
|
|
2153
|
+
v as EventDispatcher,
|
|
2154
|
+
R as EventType,
|
|
2155
|
+
X as FileUtil,
|
|
2156
|
+
Y as GeoJsonUtil,
|
|
2157
|
+
z as GeoUtil,
|
|
1895
2158
|
_ as GraphicType,
|
|
1896
2159
|
x as HashMap,
|
|
1897
|
-
|
|
2160
|
+
k as ImageUtil,
|
|
2161
|
+
I as LayerType,
|
|
1898
2162
|
m as MathUtil,
|
|
1899
2163
|
P as MeasureMode,
|
|
1900
2164
|
L as ObjectState,
|
|
1901
|
-
|
|
1902
|
-
|
|
2165
|
+
T as ObjectUtil,
|
|
2166
|
+
Q as OptimizeUtil,
|
|
1903
2167
|
S as StoreUtil,
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2168
|
+
V as StringUtil,
|
|
2169
|
+
Z as UrlUtil,
|
|
2170
|
+
y as Util,
|
|
2171
|
+
$ as WebSocketClient
|
|
1908
2172
|
};
|