gis-common 4.1.4 → 4.1.6
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/core/CanvasDrawer.d.ts +1 -0
- package/dist/gis-common.es.js +497 -333
- package/dist/gis-common.umd.js +1 -1
- package/dist/types.d.ts +53 -0
- package/dist/utils/ArrayUtil.d.ts +7 -1
- package/dist/utils/ColorUtil.d.ts +1 -0
- package/dist/utils/CommUtil.d.ts +1 -1
- package/dist/utils/CoordsUtil.d.ts +9 -2
- package/dist/utils/DateUtil.d.ts +4 -4
- package/dist/utils/GeoJsonUtil.d.ts +15 -0
- package/dist/utils/MathUtil.d.ts +18 -0
- package/dist/utils/index.d.ts +2 -1
- package/package.json +1 -1
- /package/dist/utils/{JsonUtil.d.ts → ObjectUtil.d.ts} +0 -0
package/dist/gis-common.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var f = (t, e, n) =>
|
|
4
|
-
const
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var O = (t, e, n) => e in t ? b(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var f = (t, e, n) => O(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
const E = {
|
|
5
5
|
MAP_RENDER: "mapRender",
|
|
6
6
|
MAP_READY: "mapReady",
|
|
7
7
|
MOUSE_CLICK: "click",
|
|
@@ -23,7 +23,7 @@ const y = {
|
|
|
23
23
|
WEB_SOCKET_ERROR: "webSocketError",
|
|
24
24
|
WEB_SOCKET_MESSAGE: "webSocketMessage",
|
|
25
25
|
WEB_SOCKET_CLOSE: "webSocketClose"
|
|
26
|
-
},
|
|
26
|
+
}, A = {
|
|
27
27
|
LOGIN_EXPIRED: "登录信息过期,请重新登录",
|
|
28
28
|
CROSS_ERROR: "跨域访问",
|
|
29
29
|
UNEXIST_RESOURCE: "资源不存在",
|
|
@@ -44,7 +44,7 @@ const y = {
|
|
|
44
44
|
PARAMETER_ERROR_OBJECT: "格式类型验证失败:必须是对象",
|
|
45
45
|
PARAMETER_ERROR_LACK: "参数缺失",
|
|
46
46
|
STRING_CHECK_LOSS: "字符缺少关键字"
|
|
47
|
-
},
|
|
47
|
+
}, v = {
|
|
48
48
|
SUPER_MAP_IMAGES: "SuperMapImages",
|
|
49
49
|
// 超图影像服务 栅格数据
|
|
50
50
|
SUPER_MAP_DATA: "SuperMapData",
|
|
@@ -58,7 +58,7 @@ const y = {
|
|
|
58
58
|
// addS3MGroupLayer(url, options, index) 添加S3M分组图层。
|
|
59
59
|
TERRAIN_LAYER: "TerrainFileLayer"
|
|
60
60
|
// 地形图层, 需要单独处理
|
|
61
|
-
},
|
|
61
|
+
}, _ = {
|
|
62
62
|
POINT: "point",
|
|
63
63
|
POLYLINE: "polyline",
|
|
64
64
|
POLYGON: "polygon",
|
|
@@ -68,16 +68,16 @@ const y = {
|
|
|
68
68
|
LABEL: "label",
|
|
69
69
|
MODEL: "model",
|
|
70
70
|
WALL: "wall"
|
|
71
|
-
},
|
|
71
|
+
}, P = {
|
|
72
72
|
DISTANCE: "distance",
|
|
73
73
|
AREA: "area",
|
|
74
74
|
HEIGHT: "height"
|
|
75
|
-
},
|
|
75
|
+
}, L = {
|
|
76
76
|
ADD: "add",
|
|
77
77
|
REMOVE: "remove",
|
|
78
78
|
INIT: "init"
|
|
79
79
|
};
|
|
80
|
-
class
|
|
80
|
+
class k {
|
|
81
81
|
constructor(e) {
|
|
82
82
|
/**
|
|
83
83
|
* Creates an instance of AudioPlayer.
|
|
@@ -102,7 +102,7 @@ class v {
|
|
|
102
102
|
this.audio.muted = e;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
const
|
|
105
|
+
const m = {
|
|
106
106
|
DEG2RAD: Math.PI / 180,
|
|
107
107
|
RAD2DEG: 180 / Math.PI,
|
|
108
108
|
randInt(t, e) {
|
|
@@ -149,9 +149,31 @@ const g = {
|
|
|
149
149
|
},
|
|
150
150
|
formatFloat(t, e = 2) {
|
|
151
151
|
return Math.round(t * Math.pow(10, e)) / Math.pow(10, e);
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* 根据给定值返回指定的最小值和最大值之间的最小值
|
|
155
|
+
*
|
|
156
|
+
* @param val 给定的数值
|
|
157
|
+
* @param min 最小值
|
|
158
|
+
* @param max 最大值
|
|
159
|
+
* @returns 返回限制后的数值
|
|
160
|
+
*/
|
|
161
|
+
minMax(t, e, n) {
|
|
162
|
+
return Math.min(Math.max(t, e), n);
|
|
163
|
+
},
|
|
164
|
+
/**
|
|
165
|
+
* 根据给定值返回指定的最小值和最大值之间的最大值
|
|
166
|
+
*
|
|
167
|
+
* @param val 给定的数值
|
|
168
|
+
* @param min 最小值
|
|
169
|
+
* @param max 最大值
|
|
170
|
+
* @returns 返回限制后的数值
|
|
171
|
+
*/
|
|
172
|
+
maxMin(t, e, n) {
|
|
173
|
+
return Math.max(Math.min(t, n), e);
|
|
152
174
|
}
|
|
153
175
|
};
|
|
154
|
-
class
|
|
176
|
+
class U {
|
|
155
177
|
constructor(e) {
|
|
156
178
|
f(this, "context", null);
|
|
157
179
|
if (typeof e == "string" && (e = document.querySelector("#" + e), !e))
|
|
@@ -173,12 +195,12 @@ class P {
|
|
|
173
195
|
* @param options 绘制选项,包括线条宽度和颜色
|
|
174
196
|
* @throws 当画布上下文不存在时抛出错误
|
|
175
197
|
*/
|
|
176
|
-
drawLine({ x: e, y: n }, { x:
|
|
198
|
+
drawLine({ x: e, y: n }, { x: r, y: s }, i = {}) {
|
|
177
199
|
if (!this.context)
|
|
178
200
|
throw new Error("Canvas context is null or undefined");
|
|
179
201
|
this.context.beginPath();
|
|
180
|
-
const
|
|
181
|
-
this.context.lineWidth =
|
|
202
|
+
const o = i.width || 1, a = i.color || "#000";
|
|
203
|
+
this.context.lineWidth = o, this.context.strokeStyle = a, this.context.moveTo(e, n), this.context.lineTo(r, s), this.context.stroke();
|
|
182
204
|
}
|
|
183
205
|
/**
|
|
184
206
|
* 绘制圆弧
|
|
@@ -193,52 +215,57 @@ class P {
|
|
|
193
215
|
* @param bgColor 背景颜色
|
|
194
216
|
* @throws 当Canvas context为null或undefined时抛出错误
|
|
195
217
|
*/
|
|
196
|
-
drawArc({ x: e, y: n },
|
|
218
|
+
drawArc({ x: e, y: n }, r, s, i, o, a, c) {
|
|
197
219
|
if (!this.context)
|
|
198
220
|
throw new Error("Canvas context is null or undefined");
|
|
199
|
-
|
|
221
|
+
a ? (this.context.fillStyle = c, this.context.beginPath(), this.context.arc(e, n, r, m.degreesToRadians(s), m.degreesToRadians(i), o), this.context.fill()) : (this.context.strokeStyle = c, this.context.beginPath(), this.context.arc(e, n, r, m.degreesToRadians(s), m.degreesToRadians(i), o), this.context.stroke());
|
|
222
|
+
}
|
|
223
|
+
static createCanvas(e = 1, n = 1) {
|
|
224
|
+
let r;
|
|
225
|
+
if (typeof document < "u")
|
|
226
|
+
return r = document.createElement("canvas"), e && (r.width = e), n && (r.height = n), r;
|
|
200
227
|
}
|
|
201
228
|
}
|
|
202
|
-
class
|
|
229
|
+
class C {
|
|
203
230
|
constructor() {
|
|
204
231
|
f(this, "_listeners");
|
|
205
232
|
f(this, "_mutex", {});
|
|
206
233
|
f(this, "_context");
|
|
207
234
|
}
|
|
208
|
-
addEventListener(e, n,
|
|
209
|
-
this._listeners === void 0 && (this._listeners = {}), this._context =
|
|
210
|
-
const i = this._mutex,
|
|
211
|
-
return
|
|
235
|
+
addEventListener(e, n, r, s = !1) {
|
|
236
|
+
this._listeners === void 0 && (this._listeners = {}), this._context = r;
|
|
237
|
+
const i = this._mutex, o = this._listeners;
|
|
238
|
+
return o[e] === void 0 && (o[e] = []), o[e].indexOf(n) === -1 && (s && (i[e] = n), o[e].push(n)), this;
|
|
212
239
|
}
|
|
213
240
|
hasEventListener(e, n) {
|
|
214
241
|
if (this._listeners === null || this._listeners === void 0) return !1;
|
|
215
|
-
const
|
|
216
|
-
return
|
|
242
|
+
const r = this._listeners;
|
|
243
|
+
return r[e] !== void 0 && r[e].indexOf(n) !== -1;
|
|
217
244
|
}
|
|
218
245
|
removeEventListener(e, n) {
|
|
219
246
|
if (this._listeners === void 0) return;
|
|
220
|
-
const
|
|
221
|
-
if (this._mutex[e] === n && (this._mutex[e] = null),
|
|
222
|
-
const i =
|
|
223
|
-
i !== -1 &&
|
|
247
|
+
const s = this._listeners[e];
|
|
248
|
+
if (this._mutex[e] === n && (this._mutex[e] = null), s !== void 0) {
|
|
249
|
+
const i = s.map((o) => o.toString()).indexOf(n.toString());
|
|
250
|
+
i !== -1 && s.splice(i, 1);
|
|
224
251
|
}
|
|
225
252
|
}
|
|
226
253
|
dispatchEvent(e) {
|
|
227
254
|
if (this._listeners === void 0) return;
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
255
|
+
const r = this._listeners[e.type];
|
|
256
|
+
if (r !== void 0) {
|
|
230
257
|
e.target = this;
|
|
231
|
-
const
|
|
258
|
+
const s = r.slice(0);
|
|
232
259
|
if (this._mutex[e.type] !== void 0) {
|
|
233
|
-
const i =
|
|
260
|
+
const i = s.find((o) => o === this._mutex[e.type]);
|
|
234
261
|
if (i) {
|
|
235
262
|
i.call(this._context || this, e);
|
|
236
263
|
return;
|
|
237
264
|
}
|
|
238
265
|
}
|
|
239
|
-
for (let i = 0,
|
|
240
|
-
const
|
|
241
|
-
typeof
|
|
266
|
+
for (let i = 0, o = s.length; i < o; i++) {
|
|
267
|
+
const a = s[i];
|
|
268
|
+
typeof a == "function" && a.call(this._context || this, e);
|
|
242
269
|
}
|
|
243
270
|
}
|
|
244
271
|
}
|
|
@@ -248,7 +275,7 @@ class A {
|
|
|
248
275
|
this._listeners[e] = [];
|
|
249
276
|
}
|
|
250
277
|
}
|
|
251
|
-
class
|
|
278
|
+
class x extends Map {
|
|
252
279
|
isEmpty() {
|
|
253
280
|
return this.size === 0;
|
|
254
281
|
}
|
|
@@ -264,13 +291,13 @@ class E extends Map {
|
|
|
264
291
|
fromEntries() {
|
|
265
292
|
}
|
|
266
293
|
}
|
|
267
|
-
|
|
268
|
-
const e = new
|
|
294
|
+
x.prototype.fromEntries = function(t = []) {
|
|
295
|
+
const e = new x();
|
|
269
296
|
return t.forEach((n) => {
|
|
270
297
|
Array.isArray(n) && n.length === 2 && e.set(n[0], n[1]);
|
|
271
298
|
}), e;
|
|
272
299
|
};
|
|
273
|
-
class
|
|
300
|
+
class F extends C {
|
|
274
301
|
constructor(n = "ws://127.0.0.1:10088") {
|
|
275
302
|
super();
|
|
276
303
|
f(this, "maxCheckTimes", 10);
|
|
@@ -285,25 +312,25 @@ class L extends A {
|
|
|
285
312
|
try {
|
|
286
313
|
if (console.info("创建ws连接>>>" + this.url), this.client = new WebSocket(this.url), this.client) {
|
|
287
314
|
const n = this;
|
|
288
|
-
this.client.onopen = function(
|
|
315
|
+
this.client.onopen = function(r) {
|
|
289
316
|
n.dispatchEvent({
|
|
290
|
-
type:
|
|
291
|
-
message:
|
|
317
|
+
type: E.WEB_SOCKET_CONNECT,
|
|
318
|
+
message: r
|
|
292
319
|
});
|
|
293
|
-
}, this.client.onmessage = function(
|
|
320
|
+
}, this.client.onmessage = function(r) {
|
|
294
321
|
n.connectStatus = !0, n.dispatchEvent({
|
|
295
|
-
type:
|
|
296
|
-
message:
|
|
322
|
+
type: E.WEB_SOCKET_MESSAGE,
|
|
323
|
+
message: r
|
|
297
324
|
});
|
|
298
|
-
}, this.client.onclose = function(
|
|
325
|
+
}, this.client.onclose = function(r) {
|
|
299
326
|
n.dispatchEvent({
|
|
300
|
-
type:
|
|
301
|
-
message:
|
|
327
|
+
type: E.WEB_SOCKET_CLOSE,
|
|
328
|
+
message: r
|
|
302
329
|
});
|
|
303
|
-
}, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(
|
|
330
|
+
}, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(r) {
|
|
304
331
|
n.dispatchEvent({
|
|
305
|
-
type:
|
|
306
|
-
message:
|
|
332
|
+
type: E.WEB_SOCKET_ERROR,
|
|
333
|
+
message: r
|
|
307
334
|
});
|
|
308
335
|
});
|
|
309
336
|
}
|
|
@@ -333,7 +360,7 @@ class L extends A {
|
|
|
333
360
|
}, 1e3);
|
|
334
361
|
}
|
|
335
362
|
}
|
|
336
|
-
const
|
|
363
|
+
const R = {
|
|
337
364
|
/**
|
|
338
365
|
* 获取数据类型
|
|
339
366
|
*
|
|
@@ -373,7 +400,7 @@ const M = {
|
|
|
373
400
|
*
|
|
374
401
|
* @returns 返回一个由8个16进制数组成的GUID字符串
|
|
375
402
|
*/
|
|
376
|
-
|
|
403
|
+
guid() {
|
|
377
404
|
const t = function() {
|
|
378
405
|
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
379
406
|
};
|
|
@@ -389,9 +416,9 @@ const M = {
|
|
|
389
416
|
let e = "";
|
|
390
417
|
if (t.length > 1) {
|
|
391
418
|
const n = t.slice(1, t.length % 2 === 0 ? t.length - 1 : t.length);
|
|
392
|
-
for (let
|
|
393
|
-
const
|
|
394
|
-
t[0] ===
|
|
419
|
+
for (let r = 0; r < n.length; r = r + 2) {
|
|
420
|
+
const s = n[r];
|
|
421
|
+
t[0] === s && (e = n[r + 1]);
|
|
395
422
|
}
|
|
396
423
|
!e && t.length % 2 === 0 && (e = t[t.length - 1]);
|
|
397
424
|
} else
|
|
@@ -406,9 +433,9 @@ const M = {
|
|
|
406
433
|
* @returns 返回目标对象,包含所有复制的属性。
|
|
407
434
|
*/
|
|
408
435
|
extend(t, ...e) {
|
|
409
|
-
let n,
|
|
410
|
-
for (
|
|
411
|
-
i = e[
|
|
436
|
+
let n, r, s, i;
|
|
437
|
+
for (r = 0, s = e.length; r < s; r++) {
|
|
438
|
+
i = e[r];
|
|
412
439
|
for (n in i)
|
|
413
440
|
t[n] = i[n];
|
|
414
441
|
}
|
|
@@ -423,15 +450,15 @@ const M = {
|
|
|
423
450
|
* @param childrenPropertyName 树形结构中标识子节点的字段名,默认为'children'
|
|
424
451
|
* @returns 转换后的树形结构数组
|
|
425
452
|
*/
|
|
426
|
-
convertToTree2(t, e = "id", n = "parentId",
|
|
427
|
-
const
|
|
428
|
-
function i(
|
|
429
|
-
const
|
|
430
|
-
|
|
453
|
+
convertToTree2(t, e = "id", n = "parentId", r = "children") {
|
|
454
|
+
const s = [];
|
|
455
|
+
function i(o) {
|
|
456
|
+
const a = t.filter((c) => c[n] === o[e]).map((c) => (s.some((h) => h[e] === c[e]) || i(c), c));
|
|
457
|
+
a.length > 0 && (o[r] = a);
|
|
431
458
|
}
|
|
432
|
-
return t.forEach((
|
|
433
|
-
t.some((
|
|
434
|
-
}),
|
|
459
|
+
return t.forEach((o) => {
|
|
460
|
+
t.some((a) => a[n] === o[e]) || (i(o), s.push(o));
|
|
461
|
+
}), s;
|
|
435
462
|
},
|
|
436
463
|
/**
|
|
437
464
|
* 异步加载script
|
|
@@ -441,16 +468,16 @@ const M = {
|
|
|
441
468
|
asyncLoadScript(t) {
|
|
442
469
|
return new Promise((e, n) => {
|
|
443
470
|
try {
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
(
|
|
447
|
-
} : (
|
|
448
|
-
e(
|
|
449
|
-
},
|
|
471
|
+
const r = document.createElement("script");
|
|
472
|
+
r.type = "text/javascript", r.src = t, "readyState" in r ? r.onreadystatechange = function() {
|
|
473
|
+
(r.readyState === "complete" || r.readyState === "loaded") && e(r);
|
|
474
|
+
} : (r.onload = function() {
|
|
475
|
+
e(r);
|
|
476
|
+
}, r.onerror = function() {
|
|
450
477
|
n(new Error("Script failed to load for URL: " + t));
|
|
451
|
-
}), document.body.appendChild(
|
|
452
|
-
} catch (
|
|
453
|
-
n(
|
|
478
|
+
}), document.body.appendChild(r);
|
|
479
|
+
} catch (r) {
|
|
480
|
+
n(r);
|
|
454
481
|
}
|
|
455
482
|
});
|
|
456
483
|
},
|
|
@@ -478,10 +505,10 @@ const M = {
|
|
|
478
505
|
*/
|
|
479
506
|
template(t, e) {
|
|
480
507
|
const n = /\{ *([\w_-]+) *\}/g;
|
|
481
|
-
return t.replace(n, (
|
|
482
|
-
const i = e[
|
|
508
|
+
return t.replace(n, (r, s) => {
|
|
509
|
+
const i = e[s];
|
|
483
510
|
if (i === void 0)
|
|
484
|
-
throw new Error(`${
|
|
511
|
+
throw new Error(`${A.JSON_VALUE_ERROR}: ${r}`);
|
|
485
512
|
return typeof i == "function" ? i(e) : i;
|
|
486
513
|
});
|
|
487
514
|
},
|
|
@@ -500,8 +527,8 @@ const M = {
|
|
|
500
527
|
(typeof t != "object" || t === null) && (t = {});
|
|
501
528
|
for (const n of e)
|
|
502
529
|
if (typeof n == "object" && n !== null)
|
|
503
|
-
for (const
|
|
504
|
-
Object.prototype.hasOwnProperty.call(n,
|
|
530
|
+
for (const r in n)
|
|
531
|
+
Object.prototype.hasOwnProperty.call(n, r) && (typeof n[r] == "object" && n[r] !== null ? (t[r] || (t[r] = Array.isArray(n[r]) ? [] : {}), this.deepAssign(t[r], n[r])) : t[r] = n[r]);
|
|
505
532
|
return t;
|
|
506
533
|
},
|
|
507
534
|
/**
|
|
@@ -515,11 +542,11 @@ const M = {
|
|
|
515
542
|
return navigator.clipboard.writeText(t);
|
|
516
543
|
{
|
|
517
544
|
const e = document.createElement("textarea");
|
|
518
|
-
return e.style.position = "fixed", e.style.top = e.style.left = "-100vh", e.style.opacity = "0", e.value = t, document.body.appendChild(e), e.focus(), e.select(), new Promise((n,
|
|
545
|
+
return e.style.position = "fixed", e.style.top = e.style.left = "-100vh", e.style.opacity = "0", e.value = t, document.body.appendChild(e), e.focus(), e.select(), new Promise((n, r) => {
|
|
519
546
|
try {
|
|
520
547
|
document.execCommand("copy"), n();
|
|
521
548
|
} catch {
|
|
522
|
-
|
|
549
|
+
r(new Error("copy failed"));
|
|
523
550
|
} finally {
|
|
524
551
|
e.remove();
|
|
525
552
|
}
|
|
@@ -533,21 +560,21 @@ const M = {
|
|
|
533
560
|
return Object.prototype.toString.call(t).indexOf("Object") > -1;
|
|
534
561
|
},
|
|
535
562
|
isNil(t) {
|
|
536
|
-
return
|
|
563
|
+
return t === void 0 || t === "undefined" || t === null || t === "null";
|
|
537
564
|
}
|
|
538
565
|
};
|
|
539
566
|
Array.prototype.groupBy = function(t) {
|
|
540
567
|
var e = {};
|
|
541
568
|
return this.forEach(function(n) {
|
|
542
|
-
var
|
|
543
|
-
e[
|
|
569
|
+
var r = JSON.stringify(t(n));
|
|
570
|
+
e[r] = e[r] || [], e[r].push(n);
|
|
544
571
|
}), Object.keys(e).map((n) => e[n]);
|
|
545
572
|
};
|
|
546
573
|
Array.prototype.distinct = function(t = (e) => e) {
|
|
547
574
|
const e = [], n = {};
|
|
548
|
-
return this.forEach((
|
|
549
|
-
const
|
|
550
|
-
n[i] || (n[i] = !0, e.push(
|
|
575
|
+
return this.forEach((r) => {
|
|
576
|
+
const s = t(r), i = String(s);
|
|
577
|
+
n[i] || (n[i] = !0, e.push(r));
|
|
551
578
|
}), e;
|
|
552
579
|
};
|
|
553
580
|
Array.prototype.max = function() {
|
|
@@ -571,11 +598,17 @@ Array.prototype.asc = function(t = (e) => e) {
|
|
|
571
598
|
Array.prototype.clear = function() {
|
|
572
599
|
return this.length = 0, this;
|
|
573
600
|
};
|
|
574
|
-
const
|
|
601
|
+
const N = {
|
|
575
602
|
asArray(t) {
|
|
576
|
-
return
|
|
603
|
+
return R.isEmpty(t) ? [] : Array.isArray(t) ? t : [t];
|
|
577
604
|
},
|
|
578
|
-
|
|
605
|
+
/**
|
|
606
|
+
* 创建指定长度的数组,并返回其索引数组
|
|
607
|
+
*
|
|
608
|
+
* @param length 数组长度
|
|
609
|
+
* @returns 索引数组
|
|
610
|
+
*/
|
|
611
|
+
create(t) {
|
|
579
612
|
return [...new Array(t).keys()];
|
|
580
613
|
},
|
|
581
614
|
/**
|
|
@@ -587,7 +620,7 @@ const k = {
|
|
|
587
620
|
union(...t) {
|
|
588
621
|
let e = [];
|
|
589
622
|
return t.forEach((n) => {
|
|
590
|
-
Array.isArray(n) && (e = e.concat(n.filter((
|
|
623
|
+
Array.isArray(n) && (e = e.concat(n.filter((r) => !e.includes(r))));
|
|
591
624
|
}), e;
|
|
592
625
|
},
|
|
593
626
|
/**
|
|
@@ -599,7 +632,7 @@ const k = {
|
|
|
599
632
|
intersection(...t) {
|
|
600
633
|
let e = t[0] || [];
|
|
601
634
|
return t.forEach((n) => {
|
|
602
|
-
Array.isArray(n) && (e = e.filter((
|
|
635
|
+
Array.isArray(n) && (e = e.filter((r) => n.includes(r)));
|
|
603
636
|
}), e;
|
|
604
637
|
},
|
|
605
638
|
/**
|
|
@@ -620,7 +653,7 @@ const k = {
|
|
|
620
653
|
difference(...t) {
|
|
621
654
|
return this.union(...t).filter((e) => !this.intersection(...t).includes(e));
|
|
622
655
|
}
|
|
623
|
-
},
|
|
656
|
+
}, $ = {
|
|
624
657
|
/**
|
|
625
658
|
* 获取浏览器类型
|
|
626
659
|
*
|
|
@@ -637,8 +670,8 @@ const k = {
|
|
|
637
670
|
*/
|
|
638
671
|
detectOS() {
|
|
639
672
|
let t = "";
|
|
640
|
-
const e = navigator.userAgent.indexOf("Windows", 0) != -1 ? 1 : 0, n = navigator.userAgent.indexOf("mac", 0) != -1 ? 1 : 0,
|
|
641
|
-
return e ? t = "MS Windows" : n ? t = "Apple mac" :
|
|
673
|
+
const e = navigator.userAgent.indexOf("Windows", 0) != -1 ? 1 : 0, n = navigator.userAgent.indexOf("mac", 0) != -1 ? 1 : 0, r = navigator.userAgent.indexOf("Linux", 0) != -1 ? 1 : 0, s = navigator.userAgent.indexOf("X11", 0) != -1 ? 1 : 0;
|
|
674
|
+
return e ? t = "MS Windows" : n ? t = "Apple mac" : r ? t = "Linux" : s && (t = "Unix"), t;
|
|
642
675
|
},
|
|
643
676
|
/**
|
|
644
677
|
* 切换全屏状态
|
|
@@ -660,9 +693,9 @@ const k = {
|
|
|
660
693
|
refreshScale() {
|
|
661
694
|
const t = document.documentElement.clientWidth || 0, e = document.documentElement.clientHeight || 0, n = document.getElementById("app");
|
|
662
695
|
if (!n) return;
|
|
663
|
-
const
|
|
664
|
-
let
|
|
665
|
-
|
|
696
|
+
const r = n.style, s = t / e, i = 16 / 9;
|
|
697
|
+
let o = t / 1920;
|
|
698
|
+
s > i && (o = e / 1080), r.transformOrigin = "left top", r.transform = `scale(${o}) translateX(-49.99%)`, r.width = `${t / o}px`;
|
|
666
699
|
},
|
|
667
700
|
/**
|
|
668
701
|
* 获取HTML字体大小
|
|
@@ -673,10 +706,10 @@ const k = {
|
|
|
673
706
|
const t = document.documentElement.clientWidth || document.body.clientWidth, e = document.querySelector("html");
|
|
674
707
|
e && (e.style.fontSize = t / 192 + "px");
|
|
675
708
|
}
|
|
676
|
-
},
|
|
709
|
+
}, G = {
|
|
677
710
|
set: function(t, e, n = 30) {
|
|
678
|
-
var
|
|
679
|
-
|
|
711
|
+
var r = /* @__PURE__ */ new Date();
|
|
712
|
+
r.setTime(r.getTime() + n * 24 * 60 * 60 * 1e3), document.cookie = t + "=" + escape(e) + ";expires=" + r.toUTCString();
|
|
680
713
|
},
|
|
681
714
|
remove: function(t) {
|
|
682
715
|
var e = /* @__PURE__ */ new Date();
|
|
@@ -688,17 +721,17 @@ const k = {
|
|
|
688
721
|
var e = document.cookie.match(new RegExp("(^| )" + t + "=([^;]*)(;|$)"));
|
|
689
722
|
return e != null ? e[2] : "";
|
|
690
723
|
}
|
|
691
|
-
},
|
|
724
|
+
}, B = {
|
|
692
725
|
PI: 3.141592653589793,
|
|
693
726
|
XPI: 3.141592653589793 * 3e3 / 180,
|
|
694
727
|
delta(t, e) {
|
|
695
|
-
const
|
|
696
|
-
let
|
|
697
|
-
const
|
|
698
|
-
let
|
|
699
|
-
|
|
700
|
-
const c = Math.sqrt(
|
|
701
|
-
return
|
|
728
|
+
const r = 0.006693421622965943;
|
|
729
|
+
let s = this.transformLat(e - 105, t - 35), i = this.transformLon(e - 105, t - 35);
|
|
730
|
+
const o = t / 180 * this.PI;
|
|
731
|
+
let a = Math.sin(o);
|
|
732
|
+
a = 1 - r * a * a;
|
|
733
|
+
const c = Math.sqrt(a);
|
|
734
|
+
return s = s * 180 / (6378245 * (1 - r) / (a * c) * this.PI), i = i * 180 / (6378245 / c * Math.cos(o) * this.PI), { lat: s, lng: i };
|
|
702
735
|
},
|
|
703
736
|
/**
|
|
704
737
|
* 判断经纬度是否不在中国境内
|
|
@@ -726,37 +759,37 @@ const k = {
|
|
|
726
759
|
},
|
|
727
760
|
// GCJ-02 to WGS-84 exactly
|
|
728
761
|
gcjDecryptExact(t, e) {
|
|
729
|
-
let
|
|
762
|
+
let s = 0.01, i = 0.01, o = t - s, a = e - i, c = t + s, h = e + i, l = 0, u = 0, d = 0;
|
|
730
763
|
for (; ; ) {
|
|
731
|
-
|
|
732
|
-
const
|
|
733
|
-
if (
|
|
764
|
+
l = (o + c) / 2, u = (a + h) / 2;
|
|
765
|
+
const p = this.gcjEncrypt(l, u);
|
|
766
|
+
if (s = p.lat - t, i = p.lng - e, Math.abs(s) < 1e-9 && Math.abs(i) < 1e-9 || (s > 0 ? c = l : o = l, i > 0 ? h = u : a = u, ++d > 1e4)) break;
|
|
734
767
|
}
|
|
735
|
-
return { lat:
|
|
768
|
+
return { lat: l, lng: u };
|
|
736
769
|
},
|
|
737
770
|
// GCJ-02 to BD-09
|
|
738
771
|
bdEncrypt(t, e) {
|
|
739
|
-
const n = e,
|
|
740
|
-
return { lat:
|
|
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), o = s * Math.cos(i) + 65e-4;
|
|
773
|
+
return { lat: s * Math.sin(i) + 6e-3, lng: o };
|
|
741
774
|
},
|
|
742
775
|
// BD-09 to GCJ-02
|
|
743
776
|
bdDecrypt(t, e) {
|
|
744
|
-
const n = e - 65e-4,
|
|
745
|
-
return { lat:
|
|
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), o = s * Math.cos(i);
|
|
778
|
+
return { lat: s * Math.sin(i), lng: o };
|
|
746
779
|
},
|
|
747
780
|
// WGS-84 to Web mercator
|
|
748
781
|
// mercatorLat -> y mercatorLon -> x
|
|
749
782
|
mercatorEncrypt(t, e) {
|
|
750
783
|
const n = e * 2003750834e-2 / 180;
|
|
751
|
-
let
|
|
752
|
-
return
|
|
784
|
+
let r = Math.log(Math.tan((90 + t) * this.PI / 360)) / (this.PI / 180);
|
|
785
|
+
return r = r * 2003750834e-2 / 180, { lat: r, lng: n };
|
|
753
786
|
},
|
|
754
787
|
// Web mercator to WGS-84
|
|
755
788
|
// mercatorLat -> y mercatorLon -> x
|
|
756
789
|
mercatorDecrypt(t, e) {
|
|
757
790
|
const n = e / 2003750834e-2 * 180;
|
|
758
|
-
let
|
|
759
|
-
return
|
|
791
|
+
let r = t / 2003750834e-2 * 180;
|
|
792
|
+
return r = 180 / this.PI * (2 * Math.atan(Math.exp(r * this.PI / 180)) - this.PI / 2), { lat: r, lng: n };
|
|
760
793
|
},
|
|
761
794
|
transformLat(t, e) {
|
|
762
795
|
let n = -100 + 2 * t + 3 * e + 0.2 * e * e + 0.1 * t * e + 0.2 * Math.sqrt(Math.abs(t));
|
|
@@ -766,13 +799,24 @@ const k = {
|
|
|
766
799
|
let n = 300 + t + 2 * e + 0.1 * t * t + 0.1 * t * e + 0.1 * Math.sqrt(Math.abs(t));
|
|
767
800
|
return n += (20 * Math.sin(6 * t * this.PI) + 20 * Math.sin(2 * t * this.PI)) * 2 / 3, n += (20 * Math.sin(t * this.PI) + 40 * Math.sin(t / 3 * this.PI)) * 2 / 3, n += (150 * Math.sin(t / 12 * this.PI) + 300 * Math.sin(t / 30 * this.PI)) * 2 / 3, n;
|
|
768
801
|
},
|
|
769
|
-
|
|
802
|
+
/**
|
|
803
|
+
* 生成指定范围内的随机经纬度坐标
|
|
804
|
+
*
|
|
805
|
+
* @param min 最小坐标,包含属性 x 和 y,分别表示最小经度和最小纬度
|
|
806
|
+
* @param max 最大坐标,包含属性 x 和 y,分别表示最大经度和最大纬度
|
|
807
|
+
* @returns 返回生成的随机经纬度坐标,包含属性 lat 和 lng,分别表示纬度和经度
|
|
808
|
+
*/
|
|
809
|
+
random({ x: t, y: e }, { x: n, y: r }) {
|
|
770
810
|
return {
|
|
771
|
-
lat: Math.random() * (
|
|
811
|
+
lat: Math.random() * (r - e) + e,
|
|
772
812
|
lng: Math.random() * (n - t) + t
|
|
773
813
|
};
|
|
774
814
|
}
|
|
775
|
-
},
|
|
815
|
+
}, J = {
|
|
816
|
+
random() {
|
|
817
|
+
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
|
+
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;
|
|
819
|
+
},
|
|
776
820
|
/**
|
|
777
821
|
* 将RGB颜色值转换为十六进制颜色值
|
|
778
822
|
*
|
|
@@ -800,11 +844,11 @@ const k = {
|
|
|
800
844
|
* @returns 返回rgba格式的颜色值,格式为rgba(r,g,b,1)
|
|
801
845
|
*/
|
|
802
846
|
hexToRgba(t) {
|
|
803
|
-
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, n = t.replace(e, (c,
|
|
804
|
-
if (!
|
|
847
|
+
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, n = t.replace(e, (c, h, l, u) => h + h + l + l + u + u), s = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);
|
|
848
|
+
if (!s)
|
|
805
849
|
return t;
|
|
806
|
-
const i = parseInt(
|
|
807
|
-
return `rgba(${i},${
|
|
850
|
+
const i = parseInt(s[1], 16), o = parseInt(s[2], 16), a = parseInt(s[3], 16);
|
|
851
|
+
return `rgba(${i},${o},${a},1)`;
|
|
808
852
|
},
|
|
809
853
|
/**
|
|
810
854
|
* 将 HSL 颜色值转换为 RGBA 颜色值
|
|
@@ -818,18 +862,18 @@ const k = {
|
|
|
818
862
|
const e = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t);
|
|
819
863
|
if (!e)
|
|
820
864
|
return null;
|
|
821
|
-
const n = parseInt(e[1], 10) / 360,
|
|
822
|
-
function
|
|
823
|
-
return d < 0 && (d += 1), d > 1 && (d -= 1), d < 1 / 6 ?
|
|
865
|
+
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 o(l, u, d) {
|
|
867
|
+
return d < 0 && (d += 1), d > 1 && (d -= 1), d < 1 / 6 ? l + (u - l) * 6 * d : d < 1 / 2 ? u : d < 2 / 3 ? l + (u - l) * (2 / 3 - d) * 6 : l;
|
|
824
868
|
}
|
|
825
|
-
let
|
|
826
|
-
if (
|
|
827
|
-
|
|
869
|
+
let a, c, h;
|
|
870
|
+
if (r === 0)
|
|
871
|
+
a = c = h = s;
|
|
828
872
|
else {
|
|
829
|
-
const
|
|
830
|
-
|
|
873
|
+
const l = s < 0.5 ? s * (1 + r) : s + r - s * r, u = 2 * s - l;
|
|
874
|
+
a = o(u, l, n + 1 / 3), c = o(u, l, n), h = o(u, l, n - 1 / 3);
|
|
831
875
|
}
|
|
832
|
-
return `rgba(${Math.round(
|
|
876
|
+
return `rgba(${Math.round(a * 255)},${Math.round(c * 255)},${Math.round(h * 255)},${i})`;
|
|
833
877
|
},
|
|
834
878
|
isHex(t) {
|
|
835
879
|
return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t);
|
|
@@ -871,8 +915,8 @@ Date.prototype.format = function(t) {
|
|
|
871
915
|
/(y+)/.test(t) && (t = t.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)));
|
|
872
916
|
for (const n in e)
|
|
873
917
|
if (new RegExp("(" + n + ")").test(t)) {
|
|
874
|
-
const
|
|
875
|
-
t = t.replace(RegExp.$1, ("00" + e[n]).substr(("" + e[n]).length +
|
|
918
|
+
const r = n.length === 1 ? 1 : Number(n.slice(1));
|
|
919
|
+
t = t.replace(RegExp.$1, ("00" + e[n]).substr(("" + e[n]).length + r - (e[n] + "").length));
|
|
876
920
|
}
|
|
877
921
|
return t;
|
|
878
922
|
};
|
|
@@ -909,7 +953,7 @@ Date.prototype.addDate = function(t, e) {
|
|
|
909
953
|
}
|
|
910
954
|
return n;
|
|
911
955
|
};
|
|
912
|
-
const
|
|
956
|
+
const q = {
|
|
913
957
|
lastMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1),
|
|
914
958
|
thisMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
|
|
915
959
|
nextMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 1),
|
|
@@ -946,33 +990,33 @@ const B = {
|
|
|
946
990
|
return null;
|
|
947
991
|
},
|
|
948
992
|
/**
|
|
949
|
-
*
|
|
993
|
+
* 格式化时间间隔
|
|
950
994
|
*
|
|
951
|
-
* @param
|
|
952
|
-
* @param
|
|
953
|
-
* @returns
|
|
995
|
+
* @param startTime 开始时间,可以是字符串、数字或日期类型
|
|
996
|
+
* @param endTime 结束时间,可以是字符串、数字或日期类型
|
|
997
|
+
* @returns 返回格式化后的时间间隔字符串,格式为"天数 天 小时 时 分钟 分 秒 秒"或"少于1秒"
|
|
954
998
|
*/
|
|
955
999
|
formatDateInterval(t, e) {
|
|
956
|
-
const n = new Date(t),
|
|
1000
|
+
const n = new Date(t), s = new Date(e).getTime() - n.getTime(), i = Math.floor(s / (24 * 3600 * 1e3)), o = s % (24 * 3600 * 1e3), a = Math.floor(o / (3600 * 1e3)), c = o % (3600 * 1e3), h = Math.floor(c / (60 * 1e3)), l = c % (60 * 1e3), u = Math.round(l / 1e3);
|
|
957
1001
|
let d = "";
|
|
958
|
-
return i > 0 && (d += i + "天"),
|
|
1002
|
+
return i > 0 && (d += i + "天"), a > 0 && (d += a + "时"), h > 0 && (d += h + "分"), u > 0 && (d += u + "秒"), i === 0 && a === 0 && h === 0 && u === 0 && (d = "少于1秒"), d;
|
|
959
1003
|
},
|
|
960
1004
|
formatterCounter(t) {
|
|
961
|
-
const e = function(
|
|
962
|
-
return (
|
|
963
|
-
}, n = e(Math.floor(t / 3600)),
|
|
964
|
-
return `${n}:${
|
|
1005
|
+
const e = function(a) {
|
|
1006
|
+
return (a > 10 ? "" : "0") + (a || 0);
|
|
1007
|
+
}, n = e(Math.floor(t / 3600)), r = t % 3600, s = e(Math.floor(r / 60)), i = r % 60, o = e(Math.round(i));
|
|
1008
|
+
return `${n}:${s}:${o}`;
|
|
965
1009
|
},
|
|
966
1010
|
sleep(t) {
|
|
967
1011
|
}
|
|
968
1012
|
};
|
|
969
|
-
function
|
|
1013
|
+
function T(t) {
|
|
970
1014
|
return t.trim ? t.trim() : t.replace(/^\s+|\s+$/g, "");
|
|
971
1015
|
}
|
|
972
|
-
function
|
|
973
|
-
return
|
|
1016
|
+
function w(t) {
|
|
1017
|
+
return T(t).split(/\s+/);
|
|
974
1018
|
}
|
|
975
|
-
const
|
|
1019
|
+
const W = {
|
|
976
1020
|
/**
|
|
977
1021
|
* 获取元素的样式值
|
|
978
1022
|
*
|
|
@@ -981,11 +1025,11 @@ const q = {
|
|
|
981
1025
|
* @returns 元素的样式值,如果获取不到则返回 null
|
|
982
1026
|
*/
|
|
983
1027
|
getStyle(t, e) {
|
|
984
|
-
var
|
|
1028
|
+
var r;
|
|
985
1029
|
let n = t.style[e];
|
|
986
1030
|
if (!n || n === "auto") {
|
|
987
|
-
const
|
|
988
|
-
n =
|
|
1031
|
+
const s = (r = document.defaultView) == null ? void 0 : r.getComputedStyle(t, null);
|
|
1032
|
+
n = s ? s[e] : null, n === "auto" && (n = null);
|
|
989
1033
|
}
|
|
990
1034
|
return n;
|
|
991
1035
|
},
|
|
@@ -998,8 +1042,8 @@ const q = {
|
|
|
998
1042
|
* @returns 返回新创建的HTML元素
|
|
999
1043
|
*/
|
|
1000
1044
|
create(t, e, n) {
|
|
1001
|
-
const
|
|
1002
|
-
return
|
|
1045
|
+
const r = document.createElement(t);
|
|
1046
|
+
return r.className = e || "", n && n.appendChild(r), r;
|
|
1003
1047
|
},
|
|
1004
1048
|
/**
|
|
1005
1049
|
* 从父节点中移除指定元素。
|
|
@@ -1057,8 +1101,8 @@ const q = {
|
|
|
1057
1101
|
* @returns 返回一个布尔值,表示元素是否包含指定类名
|
|
1058
1102
|
*/
|
|
1059
1103
|
hasClass(t, e) {
|
|
1060
|
-
var
|
|
1061
|
-
if ((
|
|
1104
|
+
var r;
|
|
1105
|
+
if ((r = t.classList) != null && r.contains(e))
|
|
1062
1106
|
return !0;
|
|
1063
1107
|
const n = this.getClass(t);
|
|
1064
1108
|
return n.length > 0 && new RegExp(`(^|\\s)${e}(\\s|$)`).test(n);
|
|
@@ -1071,9 +1115,9 @@ const q = {
|
|
|
1071
1115
|
*/
|
|
1072
1116
|
addClass(t, e) {
|
|
1073
1117
|
if (t.classList !== void 0) {
|
|
1074
|
-
const n =
|
|
1075
|
-
for (let
|
|
1076
|
-
t.classList.add(n[
|
|
1118
|
+
const n = w(e);
|
|
1119
|
+
for (let r = 0, s = n.length; r < s; r++)
|
|
1120
|
+
t.classList.add(n[r]);
|
|
1077
1121
|
} else if (!this.hasClass(t, e)) {
|
|
1078
1122
|
const n = this.getClass(t);
|
|
1079
1123
|
this.setClass(t, (n ? n + " " : "") + e);
|
|
@@ -1086,7 +1130,7 @@ const q = {
|
|
|
1086
1130
|
* @param name 要移除的类名,多个类名用空格分隔
|
|
1087
1131
|
*/
|
|
1088
1132
|
removeClass(t, e) {
|
|
1089
|
-
t.classList !== void 0 ?
|
|
1133
|
+
t.classList !== void 0 ? w(e).forEach((r) => t.classList.remove(r)) : this.setClass(t, (" " + this.getClass(t) + " ").replace(" " + e + " ", " ").trim());
|
|
1090
1134
|
},
|
|
1091
1135
|
/**
|
|
1092
1136
|
* 设置元素的 CSS 类名
|
|
@@ -1106,7 +1150,7 @@ const q = {
|
|
|
1106
1150
|
parseFromString(t) {
|
|
1107
1151
|
return new DOMParser().parseFromString(t, "text/xml").children[0];
|
|
1108
1152
|
}
|
|
1109
|
-
},
|
|
1153
|
+
}, H = {
|
|
1110
1154
|
toRadian: Math.PI / 180,
|
|
1111
1155
|
R: 6371393,
|
|
1112
1156
|
/**
|
|
@@ -1137,9 +1181,9 @@ const q = {
|
|
|
1137
1181
|
* @returns 返回两点之间的距离,单位为米
|
|
1138
1182
|
*/
|
|
1139
1183
|
distanceByPoints(t, e) {
|
|
1140
|
-
const { lng: n, lat:
|
|
1141
|
-
let
|
|
1142
|
-
return
|
|
1184
|
+
const { lng: n, lat: r } = t, { lng: s, lat: i } = e, o = 6371e3, a = Math.cos(r * Math.PI / 180) * Math.cos(i * Math.PI / 180) * Math.cos((n - s) * Math.PI / 180), c = Math.sin(r * Math.PI / 180) * Math.sin(i * Math.PI / 180);
|
|
1185
|
+
let h = a + c;
|
|
1186
|
+
return h > 1 && (h = 1), h < -1 && (h = -1), Math.acos(h) * o;
|
|
1143
1187
|
},
|
|
1144
1188
|
/**
|
|
1145
1189
|
* 格式化经纬度为度分秒格式
|
|
@@ -1150,11 +1194,11 @@ const q = {
|
|
|
1150
1194
|
*/
|
|
1151
1195
|
formatLnglat(t, e) {
|
|
1152
1196
|
let n = "";
|
|
1153
|
-
function s
|
|
1154
|
-
const i = Math.floor(
|
|
1155
|
-
return `${i}°${
|
|
1197
|
+
function r(s) {
|
|
1198
|
+
const i = Math.floor(s), o = Math.floor((s - i) * 60), a = (s - i) * 3600 - o * 60;
|
|
1199
|
+
return `${i}°${o}′${a.toFixed(2)}″`;
|
|
1156
1200
|
}
|
|
1157
|
-
return this.isLnglat(t, e) ? n =
|
|
1201
|
+
return this.isLnglat(t, e) ? n = r(t) + "," + r(e) : isNaN(t) ? isNaN(e) || (n = r(e)) : n = r(t), n;
|
|
1158
1202
|
},
|
|
1159
1203
|
/**
|
|
1160
1204
|
* 将经纬度字符串转换为度
|
|
@@ -1164,13 +1208,13 @@ const q = {
|
|
|
1164
1208
|
* @returns 转换后的经纬度对象
|
|
1165
1209
|
*/
|
|
1166
1210
|
transformLnglat(t, e) {
|
|
1167
|
-
function n(
|
|
1168
|
-
let i = /[sw]/i.test(
|
|
1169
|
-
const
|
|
1170
|
-
let
|
|
1171
|
-
for (let c = 0; c <
|
|
1172
|
-
|
|
1173
|
-
return
|
|
1211
|
+
function n(r) {
|
|
1212
|
+
let i = /[sw]/i.test(r) ? -1 : 1;
|
|
1213
|
+
const o = r.match(/[\d.]+/g) || [];
|
|
1214
|
+
let a = 0;
|
|
1215
|
+
for (let c = 0; c < o.length; c++)
|
|
1216
|
+
a += parseFloat(o[c]) / i, i *= 60;
|
|
1217
|
+
return a;
|
|
1174
1218
|
}
|
|
1175
1219
|
if (t && e)
|
|
1176
1220
|
return {
|
|
@@ -1186,18 +1230,18 @@ const q = {
|
|
|
1186
1230
|
* @returns 返回字符串,表示点相对于多边形的位置:'in'表示在多边形内,'out'表示在多边形外,'on'表示在多边形上
|
|
1187
1231
|
*/
|
|
1188
1232
|
rayCasting(t, e) {
|
|
1189
|
-
for (var n = t.x,
|
|
1190
|
-
var c = e[i].x,
|
|
1191
|
-
if (c === n &&
|
|
1233
|
+
for (var n = t.x, r = t.y, s = !1, i = 0, o = e.length, a = o - 1; i < o; a = i, i++) {
|
|
1234
|
+
var c = e[i].x, h = e[i].y, l = e[a].x, u = e[a].y;
|
|
1235
|
+
if (c === n && h === r || l === n && u === r)
|
|
1192
1236
|
return "on";
|
|
1193
|
-
if (
|
|
1194
|
-
var d = c + (
|
|
1237
|
+
if (h < r && u >= r || h >= r && u < r) {
|
|
1238
|
+
var d = c + (r - h) * (l - c) / (u - h);
|
|
1195
1239
|
if (d === n)
|
|
1196
1240
|
return "on";
|
|
1197
|
-
d > n && (
|
|
1241
|
+
d > n && (s = !s);
|
|
1198
1242
|
}
|
|
1199
1243
|
}
|
|
1200
|
-
return
|
|
1244
|
+
return s ? "in" : "out";
|
|
1201
1245
|
},
|
|
1202
1246
|
/**
|
|
1203
1247
|
* 旋转点
|
|
@@ -1208,8 +1252,8 @@ const q = {
|
|
|
1208
1252
|
* @returns 旋转后点坐标
|
|
1209
1253
|
*/
|
|
1210
1254
|
rotatePoint(t, e, n) {
|
|
1211
|
-
const
|
|
1212
|
-
return { x:
|
|
1255
|
+
const r = (t.x - e.x) * Math.cos(Math.PI / 180 * -n) - (t.y - e.y) * Math.sin(Math.PI / 180 * -n) + e.x, s = (t.x - e.x) * Math.sin(Math.PI / 180 * -n) + (t.y - e.y) * Math.cos(Math.PI / 180 * -n) + e.y;
|
|
1256
|
+
return { x: r, y: s };
|
|
1213
1257
|
},
|
|
1214
1258
|
/**
|
|
1215
1259
|
* 根据两个平面坐标点计算方位角和距离
|
|
@@ -1219,8 +1263,8 @@ const q = {
|
|
|
1219
1263
|
* @returns 返回一个对象,包含angle和distance属性,分别表示两点之间的角度(以度为单位,取值范围为0~359)和距离
|
|
1220
1264
|
*/
|
|
1221
1265
|
calcBearAndDis(t, e) {
|
|
1222
|
-
const { x: n, y:
|
|
1223
|
-
return { angle: (Math.atan2(
|
|
1266
|
+
const { x: n, y: r } = t, { x: s, y: i } = e, o = s - n, a = i - r, c = Math.sqrt(o * o + a * a);
|
|
1267
|
+
return { angle: (Math.atan2(a, o) * (180 / Math.PI) + 360 + 90) % 360, distance: c };
|
|
1224
1268
|
},
|
|
1225
1269
|
/**
|
|
1226
1270
|
* 根据两个经纬度点计算方位角和距离
|
|
@@ -1230,10 +1274,10 @@ const q = {
|
|
|
1230
1274
|
* @returns 包含方位角和距离的对象
|
|
1231
1275
|
*/
|
|
1232
1276
|
calcBearAndDisByPoints(t, e) {
|
|
1233
|
-
var n = t.lat * 1,
|
|
1277
|
+
var n = t.lat * 1, r = t.lng * 1, s = e.lat * 1, i = e.lng * 1, o = Math.sin((i - r) * this.toRadian) * Math.cos(s * this.toRadian), a = 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), c = Math.atan2(o, a) * (180 / Math.PI), h = (s - n) * this.toRadian, l = (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(l / 2) * Math.sin(l / 2), d = 2 * Math.atan2(Math.sqrt(u), Math.sqrt(1 - u)), p = this.R * d;
|
|
1234
1278
|
return {
|
|
1235
1279
|
angle: c,
|
|
1236
|
-
distance:
|
|
1280
|
+
distance: p
|
|
1237
1281
|
};
|
|
1238
1282
|
},
|
|
1239
1283
|
/**
|
|
@@ -1245,14 +1289,14 @@ const q = {
|
|
|
1245
1289
|
* @returns 点P到线段P1P2的最短距离
|
|
1246
1290
|
*/
|
|
1247
1291
|
distanceToSegment(t, e, n) {
|
|
1248
|
-
const
|
|
1249
|
-
if (
|
|
1250
|
-
return Math.sqrt((
|
|
1251
|
-
const
|
|
1252
|
-
if (
|
|
1253
|
-
return Math.sqrt((
|
|
1254
|
-
const u =
|
|
1255
|
-
return Math.sqrt((
|
|
1292
|
+
const r = t.x, s = t.y, i = e.x, o = e.y, a = n.x, c = n.y, h = (a - i) * (r - i) + (c - o) * (s - o);
|
|
1293
|
+
if (h <= 0)
|
|
1294
|
+
return Math.sqrt((r - i) * (r - i) + (s - o) * (s - o));
|
|
1295
|
+
const l = (a - i) * (a - i) + (c - o) * (c - o);
|
|
1296
|
+
if (h >= l)
|
|
1297
|
+
return Math.sqrt((r - a) * (r - a) + (s - c) * (s - c));
|
|
1298
|
+
const u = h / l, d = i + (a - i) * u, p = o + (c - o) * u;
|
|
1299
|
+
return Math.sqrt((r - d) * (r - d) + (s - p) * (s - p));
|
|
1256
1300
|
},
|
|
1257
1301
|
/**
|
|
1258
1302
|
* 根据给定的经纬度、角度和距离计算新的经纬度点
|
|
@@ -1263,12 +1307,12 @@ const q = {
|
|
|
1263
1307
|
* @returns 返回计算后的新经纬度点,类型为{lat: number, lng: number}
|
|
1264
1308
|
*/
|
|
1265
1309
|
calcPointByBearAndDis(t, e, n) {
|
|
1266
|
-
const
|
|
1267
|
-
e =
|
|
1268
|
-
const
|
|
1310
|
+
const r = m.toRadians(t.lat * 1), s = m.toRadians(t.lng * 1), i = n / this.R;
|
|
1311
|
+
e = m.toRadians(e);
|
|
1312
|
+
const o = Math.asin(Math.sin(r) * Math.cos(i) + Math.cos(r) * Math.sin(i) * Math.cos(e)), a = s + Math.atan2(Math.sin(e) * Math.sin(i) * Math.cos(r), Math.cos(i) - Math.sin(r) * Math.sin(o));
|
|
1269
1313
|
return {
|
|
1270
|
-
lat:
|
|
1271
|
-
lng:
|
|
1314
|
+
lat: m.toDegrees(o),
|
|
1315
|
+
lng: m.toDegrees(a)
|
|
1272
1316
|
};
|
|
1273
1317
|
},
|
|
1274
1318
|
/**
|
|
@@ -1280,9 +1324,9 @@ const q = {
|
|
|
1280
1324
|
*/
|
|
1281
1325
|
mercatorTolonlat(t, e) {
|
|
1282
1326
|
const n = t / 2003750834e-2 * 180;
|
|
1283
|
-
var
|
|
1284
|
-
const
|
|
1285
|
-
return { lng: n, lat:
|
|
1327
|
+
var r = e / 2003750834e-2 * 180;
|
|
1328
|
+
const s = 180 / Math.PI * (2 * Math.atan(Math.exp(r * Math.PI / 180)) - Math.PI / 2);
|
|
1329
|
+
return { lng: n, lat: s };
|
|
1286
1330
|
},
|
|
1287
1331
|
/**
|
|
1288
1332
|
* 将经纬度坐标转换为墨卡托坐标
|
|
@@ -1293,19 +1337,138 @@ const q = {
|
|
|
1293
1337
|
*/
|
|
1294
1338
|
lonlatToMercator(t, e) {
|
|
1295
1339
|
var n = 6378137;
|
|
1296
|
-
const
|
|
1297
|
-
var
|
|
1298
|
-
const i = n / 2 * Math.log((1 + Math.sin(
|
|
1299
|
-
return { x:
|
|
1340
|
+
const r = t * Math.PI / 180 * n;
|
|
1341
|
+
var s = e * Math.PI / 180;
|
|
1342
|
+
const i = n / 2 * Math.log((1 + Math.sin(s)) / (1 - Math.sin(s)));
|
|
1343
|
+
return { x: r, y: i };
|
|
1300
1344
|
}
|
|
1301
|
-
},
|
|
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
|
+
},
|
|
1414
|
+
spliteGeoJsonMulti(t) {
|
|
1415
|
+
const e = this.getGeoJsonType(t);
|
|
1416
|
+
if (!e || !t.geometry)
|
|
1417
|
+
return null;
|
|
1418
|
+
const n = t.geometry, r = t.properties || {}, s = n.coordinates;
|
|
1419
|
+
if (!s)
|
|
1420
|
+
return null;
|
|
1421
|
+
const i = [];
|
|
1422
|
+
let o;
|
|
1423
|
+
switch (e) {
|
|
1424
|
+
case "MultiPoint": {
|
|
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 = {
|
|
1302
1465
|
deepClone(t) {
|
|
1303
1466
|
return structuredClone(t);
|
|
1304
1467
|
},
|
|
1305
1468
|
isEqual(t, e) {
|
|
1306
1469
|
return JSON.stringify(t) === JSON.stringify(e);
|
|
1307
1470
|
}
|
|
1308
|
-
},
|
|
1471
|
+
}, Y = {
|
|
1309
1472
|
/**
|
|
1310
1473
|
* 将Base64编码的字符串转换为Blob对象
|
|
1311
1474
|
*
|
|
@@ -1313,11 +1476,11 @@ const q = {
|
|
|
1313
1476
|
* @returns 转换后的Blob对象
|
|
1314
1477
|
*/
|
|
1315
1478
|
convertBase64ToBlob(t) {
|
|
1316
|
-
const e = t.split(",")[0].split(":")[1].split(";")[0], n = atob(t.split(",")[1]),
|
|
1317
|
-
for (let
|
|
1318
|
-
|
|
1319
|
-
const
|
|
1320
|
-
return new Blob([
|
|
1479
|
+
const e = t.split(",")[0].split(":")[1].split(";")[0], n = atob(t.split(",")[1]), r = new Array(n.length);
|
|
1480
|
+
for (let o = 0; o < n.length; o++)
|
|
1481
|
+
r[o] = n.charCodeAt(o);
|
|
1482
|
+
const s = new Uint8Array(r);
|
|
1483
|
+
return new Blob([s], { type: e });
|
|
1321
1484
|
},
|
|
1322
1485
|
/**
|
|
1323
1486
|
* 将图片的URL转换为Base64编码
|
|
@@ -1328,24 +1491,24 @@ const q = {
|
|
|
1328
1491
|
* @returns 返回Promise对象,解析后得到包含Base64编码数据的对象
|
|
1329
1492
|
*/
|
|
1330
1493
|
convertUrlToBase64(t, e, n) {
|
|
1331
|
-
return new Promise((
|
|
1494
|
+
return new Promise((r, s) => {
|
|
1332
1495
|
var i = new Image();
|
|
1333
1496
|
i.crossOrigin = "Anonymous", i.src = t, i.onload = function() {
|
|
1334
|
-
var
|
|
1335
|
-
|
|
1336
|
-
var
|
|
1337
|
-
if (!
|
|
1338
|
-
|
|
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"));
|
|
1339
1502
|
return;
|
|
1340
1503
|
}
|
|
1341
|
-
|
|
1342
|
-
var c = i.src.substring(i.src.lastIndexOf(".") + 1).toLowerCase(),
|
|
1343
|
-
dataURL:
|
|
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,
|
|
1344
1507
|
type: "image/" + c,
|
|
1345
1508
|
ext: c
|
|
1346
1509
|
};
|
|
1347
|
-
|
|
1348
|
-
}, i.onerror =
|
|
1510
|
+
r(l);
|
|
1511
|
+
}, i.onerror = s;
|
|
1349
1512
|
});
|
|
1350
1513
|
},
|
|
1351
1514
|
/**
|
|
@@ -1356,10 +1519,10 @@ const q = {
|
|
|
1356
1519
|
* @returns 返回文件对象
|
|
1357
1520
|
*/
|
|
1358
1521
|
convertBase64ToFile(t, e) {
|
|
1359
|
-
const n = t.split(","),
|
|
1522
|
+
const n = t.split(","), r = n[0].match(/:(.*?);/), s = r ? r[1] : "image/png", i = atob(n[1]), o = new Uint8Array(i.length);
|
|
1360
1523
|
for (let c = 0; c < i.length; c++)
|
|
1361
|
-
|
|
1362
|
-
return new File([
|
|
1524
|
+
o[c] = i.charCodeAt(c);
|
|
1525
|
+
return new File([o], e, { type: s });
|
|
1363
1526
|
},
|
|
1364
1527
|
/**
|
|
1365
1528
|
* 从文件下载数据
|
|
@@ -1372,17 +1535,17 @@ const q = {
|
|
|
1372
1535
|
if (t instanceof Blob)
|
|
1373
1536
|
t = URL.createObjectURL(t);
|
|
1374
1537
|
else {
|
|
1375
|
-
const
|
|
1376
|
-
t = window.URL.createObjectURL(
|
|
1538
|
+
const r = JSON.stringify(t), s = new Blob([r], { type: "text/json" });
|
|
1539
|
+
t = window.URL.createObjectURL(s);
|
|
1377
1540
|
}
|
|
1378
1541
|
else if (typeof t == "string" && t.indexOf("http") === -1) {
|
|
1379
|
-
const
|
|
1380
|
-
t = window.URL.createObjectURL(
|
|
1542
|
+
const r = new Blob([t], { type: "text/json" });
|
|
1543
|
+
t = window.URL.createObjectURL(r);
|
|
1381
1544
|
}
|
|
1382
1545
|
var n = document.createElement("a");
|
|
1383
1546
|
n.href = t, n.download = e || "", n.click(), window.URL.revokeObjectURL(n.href);
|
|
1384
1547
|
}
|
|
1385
|
-
},
|
|
1548
|
+
}, z = {
|
|
1386
1549
|
/**
|
|
1387
1550
|
* 防抖函数,在指定的等待时间内,如果连续触发事件,则只在最后一次触发后执行函数。适用于像搜索输入框这种需要用户停止输入后才调用的场景
|
|
1388
1551
|
*
|
|
@@ -1392,15 +1555,15 @@ const q = {
|
|
|
1392
1555
|
* @returns 返回防抖后的函数。
|
|
1393
1556
|
*/
|
|
1394
1557
|
debounce(t, e, n = !0) {
|
|
1395
|
-
let
|
|
1396
|
-
const
|
|
1558
|
+
let r = null, s, i, o;
|
|
1559
|
+
const a = () => {
|
|
1397
1560
|
const c = Date.now() - i;
|
|
1398
|
-
c < e && c > 0 ?
|
|
1561
|
+
c < e && c > 0 ? r = setTimeout(a, e - c) : (r = null, n || (o = t.apply(this, s)));
|
|
1399
1562
|
};
|
|
1400
1563
|
return (...c) => {
|
|
1401
1564
|
i = Date.now();
|
|
1402
|
-
const
|
|
1403
|
-
return
|
|
1565
|
+
const h = n && !r;
|
|
1566
|
+
return r || (r = setTimeout(a, e)), h && (o = t.apply(this, c), r || (c = null)), o;
|
|
1404
1567
|
};
|
|
1405
1568
|
},
|
|
1406
1569
|
/**
|
|
@@ -1412,13 +1575,13 @@ const q = {
|
|
|
1412
1575
|
* @returns 返回一个新的函数,该函数在节流控制下执行传入的函数
|
|
1413
1576
|
*/
|
|
1414
1577
|
throttle(t, e, n = 1) {
|
|
1415
|
-
let
|
|
1578
|
+
let r = 0, s = null;
|
|
1416
1579
|
return (...i) => {
|
|
1417
1580
|
if (n === 1) {
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
} else n === 2 && (
|
|
1421
|
-
|
|
1581
|
+
const o = Date.now();
|
|
1582
|
+
o - r >= e && (t.apply(this, i), r = o);
|
|
1583
|
+
} else n === 2 && (s || (s = setTimeout(() => {
|
|
1584
|
+
s = null, t.apply(this, i);
|
|
1422
1585
|
}, e)));
|
|
1423
1586
|
};
|
|
1424
1587
|
},
|
|
@@ -1431,12 +1594,12 @@ const q = {
|
|
|
1431
1594
|
memoize(t) {
|
|
1432
1595
|
const e = /* @__PURE__ */ new Map();
|
|
1433
1596
|
return (...n) => {
|
|
1434
|
-
const
|
|
1435
|
-
if (e.has(
|
|
1436
|
-
return e.get(
|
|
1597
|
+
const r = JSON.stringify(n);
|
|
1598
|
+
if (e.has(r))
|
|
1599
|
+
return e.get(r);
|
|
1437
1600
|
{
|
|
1438
|
-
const
|
|
1439
|
-
return e.set(
|
|
1601
|
+
const s = t.apply(this, n);
|
|
1602
|
+
return e.set(r, s), s;
|
|
1440
1603
|
}
|
|
1441
1604
|
};
|
|
1442
1605
|
},
|
|
@@ -1448,12 +1611,12 @@ const q = {
|
|
|
1448
1611
|
* @param duration 函数递归调用的总时长,单位为毫秒,默认为5000毫秒。
|
|
1449
1612
|
*/
|
|
1450
1613
|
recurve(t, e = 500, n = 5e3) {
|
|
1451
|
-
let
|
|
1614
|
+
let r = 0;
|
|
1452
1615
|
setTimeout(() => {
|
|
1453
|
-
|
|
1616
|
+
r++, r < Math.floor(n / e) && (t.call(this), setTimeout(this.recurve.bind(this, t, e, n), e));
|
|
1454
1617
|
}, e);
|
|
1455
1618
|
}
|
|
1456
|
-
},
|
|
1619
|
+
}, X = {
|
|
1457
1620
|
/**
|
|
1458
1621
|
* 校验字符串是否符合指定类型
|
|
1459
1622
|
*
|
|
@@ -1561,7 +1724,7 @@ const q = {
|
|
|
1561
1724
|
*/
|
|
1562
1725
|
tag(t, ...e) {
|
|
1563
1726
|
return e = e.map((n) => {
|
|
1564
|
-
switch (
|
|
1727
|
+
switch (R.getDataType(n)) {
|
|
1565
1728
|
case "Object":
|
|
1566
1729
|
return n || "{}";
|
|
1567
1730
|
case "Array":
|
|
@@ -1569,7 +1732,7 @@ const q = {
|
|
|
1569
1732
|
default:
|
|
1570
1733
|
return n || "";
|
|
1571
1734
|
}
|
|
1572
|
-
}), t.reduce((n,
|
|
1735
|
+
}), t.reduce((n, r, s) => `${n}${e[s - 1]}${r}`);
|
|
1573
1736
|
},
|
|
1574
1737
|
/**
|
|
1575
1738
|
* 计算字符串的字节长度
|
|
@@ -1589,13 +1752,13 @@ const q = {
|
|
|
1589
1752
|
* @returns 返回截取后的子串
|
|
1590
1753
|
*/
|
|
1591
1754
|
subStringByte(t, e, n) {
|
|
1592
|
-
var
|
|
1593
|
-
if (t.replace(
|
|
1755
|
+
var r = /[^\x00-\xff]/g;
|
|
1756
|
+
if (t.replace(r, "mm").length <= n)
|
|
1594
1757
|
return t;
|
|
1595
|
-
for (var
|
|
1596
|
-
let
|
|
1597
|
-
if (
|
|
1598
|
-
return
|
|
1758
|
+
for (var s = Math.floor(n / 2), i = s; i < t.length; i++) {
|
|
1759
|
+
let o = t.substring(e, i);
|
|
1760
|
+
if (o.replace(r, "mm").length >= n)
|
|
1761
|
+
return o;
|
|
1599
1762
|
}
|
|
1600
1763
|
return t;
|
|
1601
1764
|
},
|
|
@@ -1606,9 +1769,9 @@ const q = {
|
|
|
1606
1769
|
* @returns 转换后的字符串,如果值为空,则返回空字符串
|
|
1607
1770
|
*/
|
|
1608
1771
|
asString(t) {
|
|
1609
|
-
if (
|
|
1772
|
+
if (R.isEmpty(t))
|
|
1610
1773
|
return "";
|
|
1611
|
-
switch (
|
|
1774
|
+
switch (R.getDataType(t)) {
|
|
1612
1775
|
case "Object":
|
|
1613
1776
|
case "Array":
|
|
1614
1777
|
return JSON.stringify(t);
|
|
@@ -1616,21 +1779,21 @@ const q = {
|
|
|
1616
1779
|
return t;
|
|
1617
1780
|
}
|
|
1618
1781
|
}
|
|
1619
|
-
},
|
|
1620
|
-
static set(e, n = null,
|
|
1621
|
-
var
|
|
1782
|
+
}, g = class g {
|
|
1783
|
+
static set(e, n = null, r = null) {
|
|
1784
|
+
var s = this._getPrefixedKey(e, r);
|
|
1622
1785
|
try {
|
|
1623
|
-
localStorage.setItem(
|
|
1786
|
+
localStorage.setItem(s, JSON.stringify({ data: n }));
|
|
1624
1787
|
} catch {
|
|
1625
1788
|
console && console.warn("StoreUtil didn't successfully save the '{" + e + ": " + n + "}' pair, because the localStorage is full.");
|
|
1626
1789
|
}
|
|
1627
1790
|
}
|
|
1628
|
-
static get(e, n,
|
|
1629
|
-
var
|
|
1791
|
+
static get(e, n, r) {
|
|
1792
|
+
var s = this._getPrefixedKey(e, r), i;
|
|
1630
1793
|
try {
|
|
1631
|
-
i = JSON.parse(localStorage.getItem(
|
|
1794
|
+
i = JSON.parse(localStorage.getItem(s) || "");
|
|
1632
1795
|
} catch {
|
|
1633
|
-
localStorage[
|
|
1796
|
+
localStorage[s] ? i = { data: localStorage.getItem(s) } : i = null;
|
|
1634
1797
|
}
|
|
1635
1798
|
if (i) {
|
|
1636
1799
|
if (typeof i == "object" && typeof i.data < "u")
|
|
@@ -1640,38 +1803,38 @@ const q = {
|
|
|
1640
1803
|
static keys() {
|
|
1641
1804
|
const e = [];
|
|
1642
1805
|
var n = Object.keys(localStorage);
|
|
1643
|
-
return
|
|
1644
|
-
|
|
1806
|
+
return g.prefix.length === 0 ? n : (n.forEach(function(r) {
|
|
1807
|
+
r.indexOf(g.prefix) !== -1 && e.push(r.replace(g.prefix, ""));
|
|
1645
1808
|
}), e);
|
|
1646
1809
|
}
|
|
1647
1810
|
static getAll(e) {
|
|
1648
|
-
var n =
|
|
1811
|
+
var n = g.keys();
|
|
1649
1812
|
if (e) {
|
|
1650
|
-
const
|
|
1651
|
-
return n.forEach((
|
|
1652
|
-
if (e.includes(
|
|
1813
|
+
const r = [];
|
|
1814
|
+
return n.forEach((s) => {
|
|
1815
|
+
if (e.includes(s)) {
|
|
1653
1816
|
const i = {};
|
|
1654
|
-
i[
|
|
1817
|
+
i[s] = g.get(s, null, null), r.push(i);
|
|
1655
1818
|
}
|
|
1656
|
-
}),
|
|
1819
|
+
}), r;
|
|
1657
1820
|
}
|
|
1658
|
-
return n.map((
|
|
1821
|
+
return n.map((r) => g.get(r, null, null));
|
|
1659
1822
|
}
|
|
1660
1823
|
static remove(e, n) {
|
|
1661
|
-
var
|
|
1662
|
-
localStorage.removeItem(
|
|
1824
|
+
var r = this._getPrefixedKey(e, n);
|
|
1825
|
+
localStorage.removeItem(r);
|
|
1663
1826
|
}
|
|
1664
1827
|
static clear(e) {
|
|
1665
|
-
|
|
1828
|
+
g.prefix.length ? this.keys().forEach((n) => {
|
|
1666
1829
|
localStorage.removeItem(this._getPrefixedKey(n, e));
|
|
1667
1830
|
}) : localStorage.clear();
|
|
1668
1831
|
}
|
|
1669
1832
|
};
|
|
1670
|
-
f(
|
|
1671
|
-
return n = n || {}, n.noPrefix ? e :
|
|
1833
|
+
f(g, "prefix", ""), f(g, "_getPrefixedKey", function(e, n) {
|
|
1834
|
+
return n = n || {}, n.noPrefix ? e : g.prefix + e;
|
|
1672
1835
|
});
|
|
1673
|
-
let
|
|
1674
|
-
const
|
|
1836
|
+
let S = g;
|
|
1837
|
+
const Q = {
|
|
1675
1838
|
/**
|
|
1676
1839
|
* 将json对象转换为查询字符串
|
|
1677
1840
|
*
|
|
@@ -1682,8 +1845,8 @@ const Y = {
|
|
|
1682
1845
|
var e = [];
|
|
1683
1846
|
for (var n in t)
|
|
1684
1847
|
if (t.hasOwnProperty(n)) {
|
|
1685
|
-
var
|
|
1686
|
-
e.push(encodeURIComponent(
|
|
1848
|
+
var r = n, s = t[n];
|
|
1849
|
+
e.push(encodeURIComponent(r) + "=" + encodeURIComponent(s));
|
|
1687
1850
|
}
|
|
1688
1851
|
var i = e.join("&");
|
|
1689
1852
|
return i;
|
|
@@ -1696,49 +1859,50 @@ const Y = {
|
|
|
1696
1859
|
* @returns 返回一个包含解析后参数的对象,其中键为参数名,值为参数值
|
|
1697
1860
|
*/
|
|
1698
1861
|
query2Json(t = window.location.href, e = !0) {
|
|
1699
|
-
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search:
|
|
1700
|
-
let
|
|
1701
|
-
for (let
|
|
1702
|
-
const c = i[
|
|
1862
|
+
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: r, hash: s } = new URL(t), i = [r, s];
|
|
1863
|
+
let o = {};
|
|
1864
|
+
for (let a = 0; a < i.length; a++) {
|
|
1865
|
+
const c = i[a];
|
|
1703
1866
|
if (c) {
|
|
1704
|
-
const
|
|
1705
|
-
if (
|
|
1706
|
-
for (let u = 1; u <
|
|
1867
|
+
const l = c.replace(/#|\//g, "").split("?");
|
|
1868
|
+
if (l.length > 1)
|
|
1869
|
+
for (let u = 1; u < l.length; u++) {
|
|
1707
1870
|
let d;
|
|
1708
|
-
for (; d = n.exec(
|
|
1709
|
-
|
|
1871
|
+
for (; d = n.exec(l[u]); )
|
|
1872
|
+
o[d[1]] = e ? decodeURIComponent(d[2]) : d[2];
|
|
1710
1873
|
}
|
|
1711
1874
|
}
|
|
1712
1875
|
}
|
|
1713
|
-
return
|
|
1876
|
+
return o;
|
|
1714
1877
|
}
|
|
1715
1878
|
};
|
|
1716
1879
|
export {
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
K as
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1880
|
+
N as ArrayUtil,
|
|
1881
|
+
k as AudioPlayer,
|
|
1882
|
+
$ as BrowserUtil,
|
|
1883
|
+
U as CanvasDrawer,
|
|
1884
|
+
J as ColorUtil,
|
|
1885
|
+
G as Cookie,
|
|
1886
|
+
B as CoordsUtil,
|
|
1887
|
+
q as DateUtil,
|
|
1888
|
+
W as DomUtil,
|
|
1889
|
+
A as ErrorType,
|
|
1890
|
+
C as EventDispatcher,
|
|
1891
|
+
E as EventType,
|
|
1892
|
+
Y as FileUtil,
|
|
1893
|
+
j as GeoJsonUtil,
|
|
1894
|
+
H as GeoUtil,
|
|
1895
|
+
_ as GraphicType,
|
|
1896
|
+
x as HashMap,
|
|
1897
|
+
v as LayerType,
|
|
1898
|
+
m as MathUtil,
|
|
1899
|
+
P as MeasureMode,
|
|
1900
|
+
L as ObjectState,
|
|
1901
|
+
K as ObjectUtil,
|
|
1902
|
+
z as OptimizeUtil,
|
|
1903
|
+
S as StoreUtil,
|
|
1904
|
+
X as StringUtil,
|
|
1905
|
+
Q as UrlUtil,
|
|
1906
|
+
R as Util,
|
|
1907
|
+
F as WebSocketClient
|
|
1744
1908
|
};
|