gis-common 4.1.4 → 4.1.5
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 +459 -325
- package/dist/gis-common.umd.js +1 -1
- package/dist/types.d.ts +53 -0
- package/dist/utils/GeoJsonUtil.d.ts +13 -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 D = Object.defineProperty;
|
|
2
|
+
var A = (t, e, n) => e in t ? D(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var f = (t, e, n) => A(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
|
+
}, b = {
|
|
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 N {
|
|
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 k {
|
|
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 U 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
|
*
|
|
@@ -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(`${b.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
|
}
|
|
@@ -539,15 +566,15 @@ const M = {
|
|
|
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,9 +598,9 @@ 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 F = {
|
|
575
602
|
asArray(t) {
|
|
576
|
-
return
|
|
603
|
+
return R.isEmpty(t) ? [] : Array.isArray(t) ? t : [t];
|
|
577
604
|
},
|
|
578
605
|
generateArray(t) {
|
|
579
606
|
return [...new Array(t).keys()];
|
|
@@ -587,7 +614,7 @@ const k = {
|
|
|
587
614
|
union(...t) {
|
|
588
615
|
let e = [];
|
|
589
616
|
return t.forEach((n) => {
|
|
590
|
-
Array.isArray(n) && (e = e.concat(n.filter((
|
|
617
|
+
Array.isArray(n) && (e = e.concat(n.filter((r) => !e.includes(r))));
|
|
591
618
|
}), e;
|
|
592
619
|
},
|
|
593
620
|
/**
|
|
@@ -599,7 +626,7 @@ const k = {
|
|
|
599
626
|
intersection(...t) {
|
|
600
627
|
let e = t[0] || [];
|
|
601
628
|
return t.forEach((n) => {
|
|
602
|
-
Array.isArray(n) && (e = e.filter((
|
|
629
|
+
Array.isArray(n) && (e = e.filter((r) => n.includes(r)));
|
|
603
630
|
}), e;
|
|
604
631
|
},
|
|
605
632
|
/**
|
|
@@ -620,7 +647,7 @@ const k = {
|
|
|
620
647
|
difference(...t) {
|
|
621
648
|
return this.union(...t).filter((e) => !this.intersection(...t).includes(e));
|
|
622
649
|
}
|
|
623
|
-
},
|
|
650
|
+
}, $ = {
|
|
624
651
|
/**
|
|
625
652
|
* 获取浏览器类型
|
|
626
653
|
*
|
|
@@ -637,8 +664,8 @@ const k = {
|
|
|
637
664
|
*/
|
|
638
665
|
detectOS() {
|
|
639
666
|
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" :
|
|
667
|
+
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;
|
|
668
|
+
return e ? t = "MS Windows" : n ? t = "Apple mac" : r ? t = "Linux" : s && (t = "Unix"), t;
|
|
642
669
|
},
|
|
643
670
|
/**
|
|
644
671
|
* 切换全屏状态
|
|
@@ -660,9 +687,9 @@ const k = {
|
|
|
660
687
|
refreshScale() {
|
|
661
688
|
const t = document.documentElement.clientWidth || 0, e = document.documentElement.clientHeight || 0, n = document.getElementById("app");
|
|
662
689
|
if (!n) return;
|
|
663
|
-
const
|
|
664
|
-
let
|
|
665
|
-
|
|
690
|
+
const r = n.style, s = t / e, i = 16 / 9;
|
|
691
|
+
let o = t / 1920;
|
|
692
|
+
s > i && (o = e / 1080), r.transformOrigin = "left top", r.transform = `scale(${o}) translateX(-49.99%)`, r.width = `${t / o}px`;
|
|
666
693
|
},
|
|
667
694
|
/**
|
|
668
695
|
* 获取HTML字体大小
|
|
@@ -673,10 +700,10 @@ const k = {
|
|
|
673
700
|
const t = document.documentElement.clientWidth || document.body.clientWidth, e = document.querySelector("html");
|
|
674
701
|
e && (e.style.fontSize = t / 192 + "px");
|
|
675
702
|
}
|
|
676
|
-
},
|
|
703
|
+
}, G = {
|
|
677
704
|
set: function(t, e, n = 30) {
|
|
678
|
-
var
|
|
679
|
-
|
|
705
|
+
var r = /* @__PURE__ */ new Date();
|
|
706
|
+
r.setTime(r.getTime() + n * 24 * 60 * 60 * 1e3), document.cookie = t + "=" + escape(e) + ";expires=" + r.toUTCString();
|
|
680
707
|
},
|
|
681
708
|
remove: function(t) {
|
|
682
709
|
var e = /* @__PURE__ */ new Date();
|
|
@@ -688,17 +715,17 @@ const k = {
|
|
|
688
715
|
var e = document.cookie.match(new RegExp("(^| )" + t + "=([^;]*)(;|$)"));
|
|
689
716
|
return e != null ? e[2] : "";
|
|
690
717
|
}
|
|
691
|
-
},
|
|
718
|
+
}, B = {
|
|
692
719
|
PI: 3.141592653589793,
|
|
693
720
|
XPI: 3.141592653589793 * 3e3 / 180,
|
|
694
721
|
delta(t, e) {
|
|
695
|
-
const
|
|
696
|
-
let
|
|
697
|
-
const
|
|
698
|
-
let
|
|
699
|
-
|
|
700
|
-
const c = Math.sqrt(
|
|
701
|
-
return
|
|
722
|
+
const r = 0.006693421622965943;
|
|
723
|
+
let s = this.transformLat(e - 105, t - 35), i = this.transformLon(e - 105, t - 35);
|
|
724
|
+
const o = t / 180 * this.PI;
|
|
725
|
+
let a = Math.sin(o);
|
|
726
|
+
a = 1 - r * a * a;
|
|
727
|
+
const c = Math.sqrt(a);
|
|
728
|
+
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
729
|
},
|
|
703
730
|
/**
|
|
704
731
|
* 判断经纬度是否不在中国境内
|
|
@@ -726,37 +753,37 @@ const k = {
|
|
|
726
753
|
},
|
|
727
754
|
// GCJ-02 to WGS-84 exactly
|
|
728
755
|
gcjDecryptExact(t, e) {
|
|
729
|
-
let
|
|
756
|
+
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
757
|
for (; ; ) {
|
|
731
|
-
|
|
732
|
-
const
|
|
733
|
-
if (
|
|
758
|
+
l = (o + c) / 2, u = (a + h) / 2;
|
|
759
|
+
const p = this.gcjEncrypt(l, u);
|
|
760
|
+
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
761
|
}
|
|
735
|
-
return { lat:
|
|
762
|
+
return { lat: l, lng: u };
|
|
736
763
|
},
|
|
737
764
|
// GCJ-02 to BD-09
|
|
738
765
|
bdEncrypt(t, e) {
|
|
739
|
-
const n = e,
|
|
740
|
-
return { lat:
|
|
766
|
+
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;
|
|
767
|
+
return { lat: s * Math.sin(i) + 6e-3, lng: o };
|
|
741
768
|
},
|
|
742
769
|
// BD-09 to GCJ-02
|
|
743
770
|
bdDecrypt(t, e) {
|
|
744
|
-
const n = e - 65e-4,
|
|
745
|
-
return { lat:
|
|
771
|
+
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);
|
|
772
|
+
return { lat: s * Math.sin(i), lng: o };
|
|
746
773
|
},
|
|
747
774
|
// WGS-84 to Web mercator
|
|
748
775
|
// mercatorLat -> y mercatorLon -> x
|
|
749
776
|
mercatorEncrypt(t, e) {
|
|
750
777
|
const n = e * 2003750834e-2 / 180;
|
|
751
|
-
let
|
|
752
|
-
return
|
|
778
|
+
let r = Math.log(Math.tan((90 + t) * this.PI / 360)) / (this.PI / 180);
|
|
779
|
+
return r = r * 2003750834e-2 / 180, { lat: r, lng: n };
|
|
753
780
|
},
|
|
754
781
|
// Web mercator to WGS-84
|
|
755
782
|
// mercatorLat -> y mercatorLon -> x
|
|
756
783
|
mercatorDecrypt(t, e) {
|
|
757
784
|
const n = e / 2003750834e-2 * 180;
|
|
758
|
-
let
|
|
759
|
-
return
|
|
785
|
+
let r = t / 2003750834e-2 * 180;
|
|
786
|
+
return r = 180 / this.PI * (2 * Math.atan(Math.exp(r * this.PI / 180)) - this.PI / 2), { lat: r, lng: n };
|
|
760
787
|
},
|
|
761
788
|
transformLat(t, e) {
|
|
762
789
|
let n = -100 + 2 * t + 3 * e + 0.2 * e * e + 0.1 * t * e + 0.2 * Math.sqrt(Math.abs(t));
|
|
@@ -766,13 +793,13 @@ const k = {
|
|
|
766
793
|
let n = 300 + t + 2 * e + 0.1 * t * t + 0.1 * t * e + 0.1 * Math.sqrt(Math.abs(t));
|
|
767
794
|
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
795
|
},
|
|
769
|
-
randomCoordinate(t, e, n,
|
|
796
|
+
randomCoordinate(t, e, n, r) {
|
|
770
797
|
return {
|
|
771
|
-
lat: Math.random() * (
|
|
798
|
+
lat: Math.random() * (r - e) + e,
|
|
772
799
|
lng: Math.random() * (n - t) + t
|
|
773
800
|
};
|
|
774
801
|
}
|
|
775
|
-
},
|
|
802
|
+
}, J = {
|
|
776
803
|
/**
|
|
777
804
|
* 将RGB颜色值转换为十六进制颜色值
|
|
778
805
|
*
|
|
@@ -800,11 +827,11 @@ const k = {
|
|
|
800
827
|
* @returns 返回rgba格式的颜色值,格式为rgba(r,g,b,1)
|
|
801
828
|
*/
|
|
802
829
|
hexToRgba(t) {
|
|
803
|
-
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, n = t.replace(e, (c,
|
|
804
|
-
if (!
|
|
830
|
+
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);
|
|
831
|
+
if (!s)
|
|
805
832
|
return t;
|
|
806
|
-
const i = parseInt(
|
|
807
|
-
return `rgba(${i},${
|
|
833
|
+
const i = parseInt(s[1], 16), o = parseInt(s[2], 16), a = parseInt(s[3], 16);
|
|
834
|
+
return `rgba(${i},${o},${a},1)`;
|
|
808
835
|
},
|
|
809
836
|
/**
|
|
810
837
|
* 将 HSL 颜色值转换为 RGBA 颜色值
|
|
@@ -818,18 +845,18 @@ const k = {
|
|
|
818
845
|
const e = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t);
|
|
819
846
|
if (!e)
|
|
820
847
|
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 ?
|
|
848
|
+
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;
|
|
849
|
+
function o(l, u, d) {
|
|
850
|
+
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
851
|
}
|
|
825
|
-
let
|
|
826
|
-
if (
|
|
827
|
-
|
|
852
|
+
let a, c, h;
|
|
853
|
+
if (r === 0)
|
|
854
|
+
a = c = h = s;
|
|
828
855
|
else {
|
|
829
|
-
const
|
|
830
|
-
|
|
856
|
+
const l = s < 0.5 ? s * (1 + r) : s + r - s * r, u = 2 * s - l;
|
|
857
|
+
a = o(u, l, n + 1 / 3), c = o(u, l, n), h = o(u, l, n - 1 / 3);
|
|
831
858
|
}
|
|
832
|
-
return `rgba(${Math.round(
|
|
859
|
+
return `rgba(${Math.round(a * 255)},${Math.round(c * 255)},${Math.round(h * 255)},${i})`;
|
|
833
860
|
},
|
|
834
861
|
isHex(t) {
|
|
835
862
|
return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t);
|
|
@@ -871,8 +898,8 @@ Date.prototype.format = function(t) {
|
|
|
871
898
|
/(y+)/.test(t) && (t = t.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)));
|
|
872
899
|
for (const n in e)
|
|
873
900
|
if (new RegExp("(" + n + ")").test(t)) {
|
|
874
|
-
const
|
|
875
|
-
t = t.replace(RegExp.$1, ("00" + e[n]).substr(("" + e[n]).length +
|
|
901
|
+
const r = n.length === 1 ? 1 : Number(n.slice(1));
|
|
902
|
+
t = t.replace(RegExp.$1, ("00" + e[n]).substr(("" + e[n]).length + r - (e[n] + "").length));
|
|
876
903
|
}
|
|
877
904
|
return t;
|
|
878
905
|
};
|
|
@@ -909,7 +936,7 @@ Date.prototype.addDate = function(t, e) {
|
|
|
909
936
|
}
|
|
910
937
|
return n;
|
|
911
938
|
};
|
|
912
|
-
const
|
|
939
|
+
const q = {
|
|
913
940
|
lastMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1),
|
|
914
941
|
thisMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
|
|
915
942
|
nextMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 1),
|
|
@@ -953,26 +980,26 @@ const B = {
|
|
|
953
980
|
* @returns {*}
|
|
954
981
|
*/
|
|
955
982
|
formatDateInterval(t, e) {
|
|
956
|
-
const n = new Date(t),
|
|
983
|
+
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
984
|
let d = "";
|
|
958
|
-
return i > 0 && (d += i + "天"),
|
|
985
|
+
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
986
|
},
|
|
960
987
|
formatterCounter(t) {
|
|
961
|
-
const e = function(
|
|
962
|
-
return (
|
|
963
|
-
}, n = e(Math.floor(t / 3600)),
|
|
964
|
-
return `${n}:${
|
|
988
|
+
const e = function(a) {
|
|
989
|
+
return (a > 10 ? "" : "0") + (a || 0);
|
|
990
|
+
}, n = e(Math.floor(t / 3600)), r = t % 3600, s = e(Math.floor(r / 60)), i = r % 60, o = e(Math.round(i));
|
|
991
|
+
return `${n}:${s}:${o}`;
|
|
965
992
|
},
|
|
966
993
|
sleep(t) {
|
|
967
994
|
}
|
|
968
995
|
};
|
|
969
|
-
function
|
|
996
|
+
function T(t) {
|
|
970
997
|
return t.trim ? t.trim() : t.replace(/^\s+|\s+$/g, "");
|
|
971
998
|
}
|
|
972
|
-
function
|
|
973
|
-
return
|
|
999
|
+
function S(t) {
|
|
1000
|
+
return T(t).split(/\s+/);
|
|
974
1001
|
}
|
|
975
|
-
const
|
|
1002
|
+
const W = {
|
|
976
1003
|
/**
|
|
977
1004
|
* 获取元素的样式值
|
|
978
1005
|
*
|
|
@@ -981,11 +1008,11 @@ const q = {
|
|
|
981
1008
|
* @returns 元素的样式值,如果获取不到则返回 null
|
|
982
1009
|
*/
|
|
983
1010
|
getStyle(t, e) {
|
|
984
|
-
var
|
|
1011
|
+
var r;
|
|
985
1012
|
let n = t.style[e];
|
|
986
1013
|
if (!n || n === "auto") {
|
|
987
|
-
const
|
|
988
|
-
n =
|
|
1014
|
+
const s = (r = document.defaultView) == null ? void 0 : r.getComputedStyle(t, null);
|
|
1015
|
+
n = s ? s[e] : null, n === "auto" && (n = null);
|
|
989
1016
|
}
|
|
990
1017
|
return n;
|
|
991
1018
|
},
|
|
@@ -998,8 +1025,8 @@ const q = {
|
|
|
998
1025
|
* @returns 返回新创建的HTML元素
|
|
999
1026
|
*/
|
|
1000
1027
|
create(t, e, n) {
|
|
1001
|
-
const
|
|
1002
|
-
return
|
|
1028
|
+
const r = document.createElement(t);
|
|
1029
|
+
return r.className = e || "", n && n.appendChild(r), r;
|
|
1003
1030
|
},
|
|
1004
1031
|
/**
|
|
1005
1032
|
* 从父节点中移除指定元素。
|
|
@@ -1057,8 +1084,8 @@ const q = {
|
|
|
1057
1084
|
* @returns 返回一个布尔值,表示元素是否包含指定类名
|
|
1058
1085
|
*/
|
|
1059
1086
|
hasClass(t, e) {
|
|
1060
|
-
var
|
|
1061
|
-
if ((
|
|
1087
|
+
var r;
|
|
1088
|
+
if ((r = t.classList) != null && r.contains(e))
|
|
1062
1089
|
return !0;
|
|
1063
1090
|
const n = this.getClass(t);
|
|
1064
1091
|
return n.length > 0 && new RegExp(`(^|\\s)${e}(\\s|$)`).test(n);
|
|
@@ -1071,9 +1098,9 @@ const q = {
|
|
|
1071
1098
|
*/
|
|
1072
1099
|
addClass(t, e) {
|
|
1073
1100
|
if (t.classList !== void 0) {
|
|
1074
|
-
const n =
|
|
1075
|
-
for (let
|
|
1076
|
-
t.classList.add(n[
|
|
1101
|
+
const n = S(e);
|
|
1102
|
+
for (let r = 0, s = n.length; r < s; r++)
|
|
1103
|
+
t.classList.add(n[r]);
|
|
1077
1104
|
} else if (!this.hasClass(t, e)) {
|
|
1078
1105
|
const n = this.getClass(t);
|
|
1079
1106
|
this.setClass(t, (n ? n + " " : "") + e);
|
|
@@ -1086,7 +1113,7 @@ const q = {
|
|
|
1086
1113
|
* @param name 要移除的类名,多个类名用空格分隔
|
|
1087
1114
|
*/
|
|
1088
1115
|
removeClass(t, e) {
|
|
1089
|
-
t.classList !== void 0 ?
|
|
1116
|
+
t.classList !== void 0 ? S(e).forEach((r) => t.classList.remove(r)) : this.setClass(t, (" " + this.getClass(t) + " ").replace(" " + e + " ", " ").trim());
|
|
1090
1117
|
},
|
|
1091
1118
|
/**
|
|
1092
1119
|
* 设置元素的 CSS 类名
|
|
@@ -1106,7 +1133,7 @@ const q = {
|
|
|
1106
1133
|
parseFromString(t) {
|
|
1107
1134
|
return new DOMParser().parseFromString(t, "text/xml").children[0];
|
|
1108
1135
|
}
|
|
1109
|
-
},
|
|
1136
|
+
}, H = {
|
|
1110
1137
|
toRadian: Math.PI / 180,
|
|
1111
1138
|
R: 6371393,
|
|
1112
1139
|
/**
|
|
@@ -1137,9 +1164,9 @@ const q = {
|
|
|
1137
1164
|
* @returns 返回两点之间的距离,单位为米
|
|
1138
1165
|
*/
|
|
1139
1166
|
distanceByPoints(t, e) {
|
|
1140
|
-
const { lng: n, lat:
|
|
1141
|
-
let
|
|
1142
|
-
return
|
|
1167
|
+
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);
|
|
1168
|
+
let h = a + c;
|
|
1169
|
+
return h > 1 && (h = 1), h < -1 && (h = -1), Math.acos(h) * o;
|
|
1143
1170
|
},
|
|
1144
1171
|
/**
|
|
1145
1172
|
* 格式化经纬度为度分秒格式
|
|
@@ -1150,11 +1177,11 @@ const q = {
|
|
|
1150
1177
|
*/
|
|
1151
1178
|
formatLnglat(t, e) {
|
|
1152
1179
|
let n = "";
|
|
1153
|
-
function s
|
|
1154
|
-
const i = Math.floor(
|
|
1155
|
-
return `${i}°${
|
|
1180
|
+
function r(s) {
|
|
1181
|
+
const i = Math.floor(s), o = Math.floor((s - i) * 60), a = (s - i) * 3600 - o * 60;
|
|
1182
|
+
return `${i}°${o}′${a.toFixed(2)}″`;
|
|
1156
1183
|
}
|
|
1157
|
-
return this.isLnglat(t, e) ? n =
|
|
1184
|
+
return this.isLnglat(t, e) ? n = r(t) + "," + r(e) : isNaN(t) ? isNaN(e) || (n = r(e)) : n = r(t), n;
|
|
1158
1185
|
},
|
|
1159
1186
|
/**
|
|
1160
1187
|
* 将经纬度字符串转换为度
|
|
@@ -1164,13 +1191,13 @@ const q = {
|
|
|
1164
1191
|
* @returns 转换后的经纬度对象
|
|
1165
1192
|
*/
|
|
1166
1193
|
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
|
|
1194
|
+
function n(r) {
|
|
1195
|
+
let i = /[sw]/i.test(r) ? -1 : 1;
|
|
1196
|
+
const o = r.match(/[\d.]+/g) || [];
|
|
1197
|
+
let a = 0;
|
|
1198
|
+
for (let c = 0; c < o.length; c++)
|
|
1199
|
+
a += parseFloat(o[c]) / i, i *= 60;
|
|
1200
|
+
return a;
|
|
1174
1201
|
}
|
|
1175
1202
|
if (t && e)
|
|
1176
1203
|
return {
|
|
@@ -1186,18 +1213,18 @@ const q = {
|
|
|
1186
1213
|
* @returns 返回字符串,表示点相对于多边形的位置:'in'表示在多边形内,'out'表示在多边形外,'on'表示在多边形上
|
|
1187
1214
|
*/
|
|
1188
1215
|
rayCasting(t, e) {
|
|
1189
|
-
for (var n = t.x,
|
|
1190
|
-
var c = e[i].x,
|
|
1191
|
-
if (c === n &&
|
|
1216
|
+
for (var n = t.x, r = t.y, s = !1, i = 0, o = e.length, a = o - 1; i < o; a = i, i++) {
|
|
1217
|
+
var c = e[i].x, h = e[i].y, l = e[a].x, u = e[a].y;
|
|
1218
|
+
if (c === n && h === r || l === n && u === r)
|
|
1192
1219
|
return "on";
|
|
1193
|
-
if (
|
|
1194
|
-
var d = c + (
|
|
1220
|
+
if (h < r && u >= r || h >= r && u < r) {
|
|
1221
|
+
var d = c + (r - h) * (l - c) / (u - h);
|
|
1195
1222
|
if (d === n)
|
|
1196
1223
|
return "on";
|
|
1197
|
-
d > n && (
|
|
1224
|
+
d > n && (s = !s);
|
|
1198
1225
|
}
|
|
1199
1226
|
}
|
|
1200
|
-
return
|
|
1227
|
+
return s ? "in" : "out";
|
|
1201
1228
|
},
|
|
1202
1229
|
/**
|
|
1203
1230
|
* 旋转点
|
|
@@ -1208,8 +1235,8 @@ const q = {
|
|
|
1208
1235
|
* @returns 旋转后点坐标
|
|
1209
1236
|
*/
|
|
1210
1237
|
rotatePoint(t, e, n) {
|
|
1211
|
-
const
|
|
1212
|
-
return { x:
|
|
1238
|
+
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;
|
|
1239
|
+
return { x: r, y: s };
|
|
1213
1240
|
},
|
|
1214
1241
|
/**
|
|
1215
1242
|
* 根据两个平面坐标点计算方位角和距离
|
|
@@ -1219,8 +1246,8 @@ const q = {
|
|
|
1219
1246
|
* @returns 返回一个对象,包含angle和distance属性,分别表示两点之间的角度(以度为单位,取值范围为0~359)和距离
|
|
1220
1247
|
*/
|
|
1221
1248
|
calcBearAndDis(t, e) {
|
|
1222
|
-
const { x: n, y:
|
|
1223
|
-
return { angle: (Math.atan2(
|
|
1249
|
+
const { x: n, y: r } = t, { x: s, y: i } = e, o = s - n, a = i - r, c = Math.sqrt(o * o + a * a);
|
|
1250
|
+
return { angle: (Math.atan2(a, o) * (180 / Math.PI) + 360 + 90) % 360, distance: c };
|
|
1224
1251
|
},
|
|
1225
1252
|
/**
|
|
1226
1253
|
* 根据两个经纬度点计算方位角和距离
|
|
@@ -1230,10 +1257,10 @@ const q = {
|
|
|
1230
1257
|
* @returns 包含方位角和距离的对象
|
|
1231
1258
|
*/
|
|
1232
1259
|
calcBearAndDisByPoints(t, e) {
|
|
1233
|
-
var n = t.lat * 1,
|
|
1260
|
+
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
1261
|
return {
|
|
1235
1262
|
angle: c,
|
|
1236
|
-
distance:
|
|
1263
|
+
distance: p
|
|
1237
1264
|
};
|
|
1238
1265
|
},
|
|
1239
1266
|
/**
|
|
@@ -1245,14 +1272,14 @@ const q = {
|
|
|
1245
1272
|
* @returns 点P到线段P1P2的最短距离
|
|
1246
1273
|
*/
|
|
1247
1274
|
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((
|
|
1275
|
+
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);
|
|
1276
|
+
if (h <= 0)
|
|
1277
|
+
return Math.sqrt((r - i) * (r - i) + (s - o) * (s - o));
|
|
1278
|
+
const l = (a - i) * (a - i) + (c - o) * (c - o);
|
|
1279
|
+
if (h >= l)
|
|
1280
|
+
return Math.sqrt((r - a) * (r - a) + (s - c) * (s - c));
|
|
1281
|
+
const u = h / l, d = i + (a - i) * u, p = o + (c - o) * u;
|
|
1282
|
+
return Math.sqrt((r - d) * (r - d) + (s - p) * (s - p));
|
|
1256
1283
|
},
|
|
1257
1284
|
/**
|
|
1258
1285
|
* 根据给定的经纬度、角度和距离计算新的经纬度点
|
|
@@ -1263,12 +1290,12 @@ const q = {
|
|
|
1263
1290
|
* @returns 返回计算后的新经纬度点,类型为{lat: number, lng: number}
|
|
1264
1291
|
*/
|
|
1265
1292
|
calcPointByBearAndDis(t, e, n) {
|
|
1266
|
-
const
|
|
1267
|
-
e =
|
|
1268
|
-
const
|
|
1293
|
+
const r = m.toRadians(t.lat * 1), s = m.toRadians(t.lng * 1), i = n / this.R;
|
|
1294
|
+
e = m.toRadians(e);
|
|
1295
|
+
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
1296
|
return {
|
|
1270
|
-
lat:
|
|
1271
|
-
lng:
|
|
1297
|
+
lat: m.toDegrees(o),
|
|
1298
|
+
lng: m.toDegrees(a)
|
|
1272
1299
|
};
|
|
1273
1300
|
},
|
|
1274
1301
|
/**
|
|
@@ -1280,9 +1307,9 @@ const q = {
|
|
|
1280
1307
|
*/
|
|
1281
1308
|
mercatorTolonlat(t, e) {
|
|
1282
1309
|
const n = t / 2003750834e-2 * 180;
|
|
1283
|
-
var
|
|
1284
|
-
const
|
|
1285
|
-
return { lng: n, lat:
|
|
1310
|
+
var r = e / 2003750834e-2 * 180;
|
|
1311
|
+
const s = 180 / Math.PI * (2 * Math.atan(Math.exp(r * Math.PI / 180)) - Math.PI / 2);
|
|
1312
|
+
return { lng: n, lat: s };
|
|
1286
1313
|
},
|
|
1287
1314
|
/**
|
|
1288
1315
|
* 将经纬度坐标转换为墨卡托坐标
|
|
@@ -1293,19 +1320,125 @@ const q = {
|
|
|
1293
1320
|
*/
|
|
1294
1321
|
lonlatToMercator(t, e) {
|
|
1295
1322
|
var n = 6378137;
|
|
1296
|
-
const
|
|
1297
|
-
var
|
|
1298
|
-
const i = n / 2 * Math.log((1 + Math.sin(
|
|
1299
|
-
return { x:
|
|
1323
|
+
const r = t * Math.PI / 180 * n;
|
|
1324
|
+
var s = e * Math.PI / 180;
|
|
1325
|
+
const i = n / 2 * Math.log((1 + Math.sin(s)) / (1 - Math.sin(s)));
|
|
1326
|
+
return { x: r, y: i };
|
|
1327
|
+
}
|
|
1328
|
+
}, y = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"], j = {
|
|
1329
|
+
getGeoJSONType(t) {
|
|
1330
|
+
return t.geometry ? t.geometry.type : null;
|
|
1331
|
+
},
|
|
1332
|
+
isGeoJSON(t) {
|
|
1333
|
+
const e = this.getGeoJSONType(t);
|
|
1334
|
+
if (e) {
|
|
1335
|
+
for (let n = 0, r = y.length; n < r; n++)
|
|
1336
|
+
if (y[n] === e)
|
|
1337
|
+
return !0;
|
|
1338
|
+
}
|
|
1339
|
+
return !1;
|
|
1340
|
+
},
|
|
1341
|
+
isGeoJSONPolygon(t) {
|
|
1342
|
+
const e = this.getGeoJSONType(t);
|
|
1343
|
+
return !!(e && (e === y[4] || e === y[5]));
|
|
1344
|
+
},
|
|
1345
|
+
isGeoJSONLine(t) {
|
|
1346
|
+
const e = this.getGeoJSONType(t);
|
|
1347
|
+
return !!(e && (e === y[2] || e === y[3]));
|
|
1348
|
+
},
|
|
1349
|
+
isGeoJSONPoint(t) {
|
|
1350
|
+
const e = this.getGeoJSONType(t);
|
|
1351
|
+
return !!(e && (e === y[0] || e === y[1]));
|
|
1352
|
+
},
|
|
1353
|
+
isGeoJSONMulti(t) {
|
|
1354
|
+
const e = this.getGeoJSONType(t);
|
|
1355
|
+
return !!(e && e.indexOf("Multi") > -1);
|
|
1356
|
+
},
|
|
1357
|
+
getGeoJSONCoordinates(t) {
|
|
1358
|
+
return t.geometry ? t.geometry.coordinates : [];
|
|
1359
|
+
},
|
|
1360
|
+
getGeoJSONCenter(t, e) {
|
|
1361
|
+
const n = this.getGeoJSONType(t);
|
|
1362
|
+
if (!n || !t.geometry)
|
|
1363
|
+
return null;
|
|
1364
|
+
const s = t.geometry.coordinates;
|
|
1365
|
+
if (!s)
|
|
1366
|
+
return null;
|
|
1367
|
+
let i = 0, o = 0, a = 0;
|
|
1368
|
+
switch (n) {
|
|
1369
|
+
case "Point": {
|
|
1370
|
+
i = s[0], o = s[1], a++;
|
|
1371
|
+
break;
|
|
1372
|
+
}
|
|
1373
|
+
case "MultiPoint":
|
|
1374
|
+
case "LineString": {
|
|
1375
|
+
for (let l = 0, u = s.length; l < u; l++)
|
|
1376
|
+
i += s[l][0], o += s[l][1], a++;
|
|
1377
|
+
break;
|
|
1378
|
+
}
|
|
1379
|
+
case "MultiLineString":
|
|
1380
|
+
case "Polygon": {
|
|
1381
|
+
for (let l = 0, u = s.length; l < u; l++)
|
|
1382
|
+
for (let d = 0, p = s[l].length; d < p; d++)
|
|
1383
|
+
i += s[l][d][0], o += s[l][d][1], a++;
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
case "MultiPolygon": {
|
|
1387
|
+
for (let l = 0, u = s.length; l < u; l++)
|
|
1388
|
+
for (let d = 0, p = s[l].length; d < p; d++)
|
|
1389
|
+
for (let M = 0, O = s[l][d].length; M < O; M++)
|
|
1390
|
+
i += s[l][d][M][0], o += s[l][d][M][1], a++;
|
|
1391
|
+
break;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
const c = i / a, h = o / a;
|
|
1395
|
+
return e ? (e.x = c, e.y = h, e) : { x: c, y: h };
|
|
1396
|
+
},
|
|
1397
|
+
spliteGeoJSONMulti(t) {
|
|
1398
|
+
const e = this.getGeoJSONType(t);
|
|
1399
|
+
if (!e || !t.geometry)
|
|
1400
|
+
return null;
|
|
1401
|
+
const n = t.geometry, r = t.properties || {}, s = n.coordinates;
|
|
1402
|
+
if (!s)
|
|
1403
|
+
return null;
|
|
1404
|
+
const i = [];
|
|
1405
|
+
let o;
|
|
1406
|
+
switch (e) {
|
|
1407
|
+
case "MultiPoint": {
|
|
1408
|
+
o = "Point";
|
|
1409
|
+
break;
|
|
1410
|
+
}
|
|
1411
|
+
case "MultiLineString": {
|
|
1412
|
+
o = "LineString";
|
|
1413
|
+
break;
|
|
1414
|
+
}
|
|
1415
|
+
case "MultiPolygon": {
|
|
1416
|
+
o = "Polygon";
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
if (o)
|
|
1421
|
+
for (let a = 0, c = s.length; a < c; a++)
|
|
1422
|
+
i.push({
|
|
1423
|
+
type: "Feature",
|
|
1424
|
+
geometry: {
|
|
1425
|
+
type: o,
|
|
1426
|
+
coordinates: s[a]
|
|
1427
|
+
},
|
|
1428
|
+
properties: r
|
|
1429
|
+
});
|
|
1430
|
+
else
|
|
1431
|
+
i.push(t);
|
|
1432
|
+
return i;
|
|
1300
1433
|
}
|
|
1301
|
-
},
|
|
1434
|
+
}, K = {
|
|
1302
1435
|
deepClone(t) {
|
|
1303
1436
|
return structuredClone(t);
|
|
1304
1437
|
},
|
|
1305
1438
|
isEqual(t, e) {
|
|
1306
1439
|
return JSON.stringify(t) === JSON.stringify(e);
|
|
1307
1440
|
}
|
|
1308
|
-
},
|
|
1441
|
+
}, Y = {
|
|
1309
1442
|
/**
|
|
1310
1443
|
* 将Base64编码的字符串转换为Blob对象
|
|
1311
1444
|
*
|
|
@@ -1313,11 +1446,11 @@ const q = {
|
|
|
1313
1446
|
* @returns 转换后的Blob对象
|
|
1314
1447
|
*/
|
|
1315
1448
|
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([
|
|
1449
|
+
const e = t.split(",")[0].split(":")[1].split(";")[0], n = atob(t.split(",")[1]), r = new Array(n.length);
|
|
1450
|
+
for (let o = 0; o < n.length; o++)
|
|
1451
|
+
r[o] = n.charCodeAt(o);
|
|
1452
|
+
const s = new Uint8Array(r);
|
|
1453
|
+
return new Blob([s], { type: e });
|
|
1321
1454
|
},
|
|
1322
1455
|
/**
|
|
1323
1456
|
* 将图片的URL转换为Base64编码
|
|
@@ -1328,24 +1461,24 @@ const q = {
|
|
|
1328
1461
|
* @returns 返回Promise对象,解析后得到包含Base64编码数据的对象
|
|
1329
1462
|
*/
|
|
1330
1463
|
convertUrlToBase64(t, e, n) {
|
|
1331
|
-
return new Promise((
|
|
1464
|
+
return new Promise((r, s) => {
|
|
1332
1465
|
var i = new Image();
|
|
1333
1466
|
i.crossOrigin = "Anonymous", i.src = t, i.onload = function() {
|
|
1334
|
-
var
|
|
1335
|
-
|
|
1336
|
-
var
|
|
1337
|
-
if (!
|
|
1338
|
-
|
|
1467
|
+
var o = document.createElement("canvas");
|
|
1468
|
+
o.width = e || i.width, o.height = n || i.height;
|
|
1469
|
+
var a = o.getContext("2d");
|
|
1470
|
+
if (!a) {
|
|
1471
|
+
s(new Error("Failed to get canvas context"));
|
|
1339
1472
|
return;
|
|
1340
1473
|
}
|
|
1341
|
-
|
|
1342
|
-
var c = i.src.substring(i.src.lastIndexOf(".") + 1).toLowerCase(),
|
|
1343
|
-
dataURL:
|
|
1474
|
+
a.drawImage(i, 0, 0, i.width, i.height);
|
|
1475
|
+
var c = i.src.substring(i.src.lastIndexOf(".") + 1).toLowerCase(), h = o.toDataURL("image/" + c), l = {
|
|
1476
|
+
dataURL: h,
|
|
1344
1477
|
type: "image/" + c,
|
|
1345
1478
|
ext: c
|
|
1346
1479
|
};
|
|
1347
|
-
|
|
1348
|
-
}, i.onerror =
|
|
1480
|
+
r(l);
|
|
1481
|
+
}, i.onerror = s;
|
|
1349
1482
|
});
|
|
1350
1483
|
},
|
|
1351
1484
|
/**
|
|
@@ -1356,10 +1489,10 @@ const q = {
|
|
|
1356
1489
|
* @returns 返回文件对象
|
|
1357
1490
|
*/
|
|
1358
1491
|
convertBase64ToFile(t, e) {
|
|
1359
|
-
const n = t.split(","),
|
|
1492
|
+
const n = t.split(","), r = n[0].match(/:(.*?);/), s = r ? r[1] : "image/png", i = atob(n[1]), o = new Uint8Array(i.length);
|
|
1360
1493
|
for (let c = 0; c < i.length; c++)
|
|
1361
|
-
|
|
1362
|
-
return new File([
|
|
1494
|
+
o[c] = i.charCodeAt(c);
|
|
1495
|
+
return new File([o], e, { type: s });
|
|
1363
1496
|
},
|
|
1364
1497
|
/**
|
|
1365
1498
|
* 从文件下载数据
|
|
@@ -1372,17 +1505,17 @@ const q = {
|
|
|
1372
1505
|
if (t instanceof Blob)
|
|
1373
1506
|
t = URL.createObjectURL(t);
|
|
1374
1507
|
else {
|
|
1375
|
-
const
|
|
1376
|
-
t = window.URL.createObjectURL(
|
|
1508
|
+
const r = JSON.stringify(t), s = new Blob([r], { type: "text/json" });
|
|
1509
|
+
t = window.URL.createObjectURL(s);
|
|
1377
1510
|
}
|
|
1378
1511
|
else if (typeof t == "string" && t.indexOf("http") === -1) {
|
|
1379
|
-
const
|
|
1380
|
-
t = window.URL.createObjectURL(
|
|
1512
|
+
const r = new Blob([t], { type: "text/json" });
|
|
1513
|
+
t = window.URL.createObjectURL(r);
|
|
1381
1514
|
}
|
|
1382
1515
|
var n = document.createElement("a");
|
|
1383
1516
|
n.href = t, n.download = e || "", n.click(), window.URL.revokeObjectURL(n.href);
|
|
1384
1517
|
}
|
|
1385
|
-
},
|
|
1518
|
+
}, z = {
|
|
1386
1519
|
/**
|
|
1387
1520
|
* 防抖函数,在指定的等待时间内,如果连续触发事件,则只在最后一次触发后执行函数。适用于像搜索输入框这种需要用户停止输入后才调用的场景
|
|
1388
1521
|
*
|
|
@@ -1392,15 +1525,15 @@ const q = {
|
|
|
1392
1525
|
* @returns 返回防抖后的函数。
|
|
1393
1526
|
*/
|
|
1394
1527
|
debounce(t, e, n = !0) {
|
|
1395
|
-
let
|
|
1396
|
-
const
|
|
1528
|
+
let r = null, s, i, o;
|
|
1529
|
+
const a = () => {
|
|
1397
1530
|
const c = Date.now() - i;
|
|
1398
|
-
c < e && c > 0 ?
|
|
1531
|
+
c < e && c > 0 ? r = setTimeout(a, e - c) : (r = null, n || (o = t.apply(this, s)));
|
|
1399
1532
|
};
|
|
1400
1533
|
return (...c) => {
|
|
1401
1534
|
i = Date.now();
|
|
1402
|
-
const
|
|
1403
|
-
return
|
|
1535
|
+
const h = n && !r;
|
|
1536
|
+
return r || (r = setTimeout(a, e)), h && (o = t.apply(this, c), r || (c = null)), o;
|
|
1404
1537
|
};
|
|
1405
1538
|
},
|
|
1406
1539
|
/**
|
|
@@ -1412,13 +1545,13 @@ const q = {
|
|
|
1412
1545
|
* @returns 返回一个新的函数,该函数在节流控制下执行传入的函数
|
|
1413
1546
|
*/
|
|
1414
1547
|
throttle(t, e, n = 1) {
|
|
1415
|
-
let
|
|
1548
|
+
let r = 0, s = null;
|
|
1416
1549
|
return (...i) => {
|
|
1417
1550
|
if (n === 1) {
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
} else n === 2 && (
|
|
1421
|
-
|
|
1551
|
+
const o = Date.now();
|
|
1552
|
+
o - r >= e && (t.apply(this, i), r = o);
|
|
1553
|
+
} else n === 2 && (s || (s = setTimeout(() => {
|
|
1554
|
+
s = null, t.apply(this, i);
|
|
1422
1555
|
}, e)));
|
|
1423
1556
|
};
|
|
1424
1557
|
},
|
|
@@ -1431,12 +1564,12 @@ const q = {
|
|
|
1431
1564
|
memoize(t) {
|
|
1432
1565
|
const e = /* @__PURE__ */ new Map();
|
|
1433
1566
|
return (...n) => {
|
|
1434
|
-
const
|
|
1435
|
-
if (e.has(
|
|
1436
|
-
return e.get(
|
|
1567
|
+
const r = JSON.stringify(n);
|
|
1568
|
+
if (e.has(r))
|
|
1569
|
+
return e.get(r);
|
|
1437
1570
|
{
|
|
1438
|
-
const
|
|
1439
|
-
return e.set(
|
|
1571
|
+
const s = t.apply(this, n);
|
|
1572
|
+
return e.set(r, s), s;
|
|
1440
1573
|
}
|
|
1441
1574
|
};
|
|
1442
1575
|
},
|
|
@@ -1448,12 +1581,12 @@ const q = {
|
|
|
1448
1581
|
* @param duration 函数递归调用的总时长,单位为毫秒,默认为5000毫秒。
|
|
1449
1582
|
*/
|
|
1450
1583
|
recurve(t, e = 500, n = 5e3) {
|
|
1451
|
-
let
|
|
1584
|
+
let r = 0;
|
|
1452
1585
|
setTimeout(() => {
|
|
1453
|
-
|
|
1586
|
+
r++, r < Math.floor(n / e) && (t.call(this), setTimeout(this.recurve.bind(this, t, e, n), e));
|
|
1454
1587
|
}, e);
|
|
1455
1588
|
}
|
|
1456
|
-
},
|
|
1589
|
+
}, X = {
|
|
1457
1590
|
/**
|
|
1458
1591
|
* 校验字符串是否符合指定类型
|
|
1459
1592
|
*
|
|
@@ -1561,7 +1694,7 @@ const q = {
|
|
|
1561
1694
|
*/
|
|
1562
1695
|
tag(t, ...e) {
|
|
1563
1696
|
return e = e.map((n) => {
|
|
1564
|
-
switch (
|
|
1697
|
+
switch (R.getDataType(n)) {
|
|
1565
1698
|
case "Object":
|
|
1566
1699
|
return n || "{}";
|
|
1567
1700
|
case "Array":
|
|
@@ -1569,7 +1702,7 @@ const q = {
|
|
|
1569
1702
|
default:
|
|
1570
1703
|
return n || "";
|
|
1571
1704
|
}
|
|
1572
|
-
}), t.reduce((n,
|
|
1705
|
+
}), t.reduce((n, r, s) => `${n}${e[s - 1]}${r}`);
|
|
1573
1706
|
},
|
|
1574
1707
|
/**
|
|
1575
1708
|
* 计算字符串的字节长度
|
|
@@ -1589,13 +1722,13 @@ const q = {
|
|
|
1589
1722
|
* @returns 返回截取后的子串
|
|
1590
1723
|
*/
|
|
1591
1724
|
subStringByte(t, e, n) {
|
|
1592
|
-
var
|
|
1593
|
-
if (t.replace(
|
|
1725
|
+
var r = /[^\x00-\xff]/g;
|
|
1726
|
+
if (t.replace(r, "mm").length <= n)
|
|
1594
1727
|
return t;
|
|
1595
|
-
for (var
|
|
1596
|
-
let
|
|
1597
|
-
if (
|
|
1598
|
-
return
|
|
1728
|
+
for (var s = Math.floor(n / 2), i = s; i < t.length; i++) {
|
|
1729
|
+
let o = t.substring(e, i);
|
|
1730
|
+
if (o.replace(r, "mm").length >= n)
|
|
1731
|
+
return o;
|
|
1599
1732
|
}
|
|
1600
1733
|
return t;
|
|
1601
1734
|
},
|
|
@@ -1606,9 +1739,9 @@ const q = {
|
|
|
1606
1739
|
* @returns 转换后的字符串,如果值为空,则返回空字符串
|
|
1607
1740
|
*/
|
|
1608
1741
|
asString(t) {
|
|
1609
|
-
if (
|
|
1742
|
+
if (R.isEmpty(t))
|
|
1610
1743
|
return "";
|
|
1611
|
-
switch (
|
|
1744
|
+
switch (R.getDataType(t)) {
|
|
1612
1745
|
case "Object":
|
|
1613
1746
|
case "Array":
|
|
1614
1747
|
return JSON.stringify(t);
|
|
@@ -1616,21 +1749,21 @@ const q = {
|
|
|
1616
1749
|
return t;
|
|
1617
1750
|
}
|
|
1618
1751
|
}
|
|
1619
|
-
},
|
|
1620
|
-
static set(e, n = null,
|
|
1621
|
-
var
|
|
1752
|
+
}, g = class g {
|
|
1753
|
+
static set(e, n = null, r = null) {
|
|
1754
|
+
var s = this._getPrefixedKey(e, r);
|
|
1622
1755
|
try {
|
|
1623
|
-
localStorage.setItem(
|
|
1756
|
+
localStorage.setItem(s, JSON.stringify({ data: n }));
|
|
1624
1757
|
} catch {
|
|
1625
1758
|
console && console.warn("StoreUtil didn't successfully save the '{" + e + ": " + n + "}' pair, because the localStorage is full.");
|
|
1626
1759
|
}
|
|
1627
1760
|
}
|
|
1628
|
-
static get(e, n,
|
|
1629
|
-
var
|
|
1761
|
+
static get(e, n, r) {
|
|
1762
|
+
var s = this._getPrefixedKey(e, r), i;
|
|
1630
1763
|
try {
|
|
1631
|
-
i = JSON.parse(localStorage.getItem(
|
|
1764
|
+
i = JSON.parse(localStorage.getItem(s) || "");
|
|
1632
1765
|
} catch {
|
|
1633
|
-
localStorage[
|
|
1766
|
+
localStorage[s] ? i = { data: localStorage.getItem(s) } : i = null;
|
|
1634
1767
|
}
|
|
1635
1768
|
if (i) {
|
|
1636
1769
|
if (typeof i == "object" && typeof i.data < "u")
|
|
@@ -1640,38 +1773,38 @@ const q = {
|
|
|
1640
1773
|
static keys() {
|
|
1641
1774
|
const e = [];
|
|
1642
1775
|
var n = Object.keys(localStorage);
|
|
1643
|
-
return
|
|
1644
|
-
|
|
1776
|
+
return g.prefix.length === 0 ? n : (n.forEach(function(r) {
|
|
1777
|
+
r.indexOf(g.prefix) !== -1 && e.push(r.replace(g.prefix, ""));
|
|
1645
1778
|
}), e);
|
|
1646
1779
|
}
|
|
1647
1780
|
static getAll(e) {
|
|
1648
|
-
var n =
|
|
1781
|
+
var n = g.keys();
|
|
1649
1782
|
if (e) {
|
|
1650
|
-
const
|
|
1651
|
-
return n.forEach((
|
|
1652
|
-
if (e.includes(
|
|
1783
|
+
const r = [];
|
|
1784
|
+
return n.forEach((s) => {
|
|
1785
|
+
if (e.includes(s)) {
|
|
1653
1786
|
const i = {};
|
|
1654
|
-
i[
|
|
1787
|
+
i[s] = g.get(s, null, null), r.push(i);
|
|
1655
1788
|
}
|
|
1656
|
-
}),
|
|
1789
|
+
}), r;
|
|
1657
1790
|
}
|
|
1658
|
-
return n.map((
|
|
1791
|
+
return n.map((r) => g.get(r, null, null));
|
|
1659
1792
|
}
|
|
1660
1793
|
static remove(e, n) {
|
|
1661
|
-
var
|
|
1662
|
-
localStorage.removeItem(
|
|
1794
|
+
var r = this._getPrefixedKey(e, n);
|
|
1795
|
+
localStorage.removeItem(r);
|
|
1663
1796
|
}
|
|
1664
1797
|
static clear(e) {
|
|
1665
|
-
|
|
1798
|
+
g.prefix.length ? this.keys().forEach((n) => {
|
|
1666
1799
|
localStorage.removeItem(this._getPrefixedKey(n, e));
|
|
1667
1800
|
}) : localStorage.clear();
|
|
1668
1801
|
}
|
|
1669
1802
|
};
|
|
1670
|
-
f(
|
|
1671
|
-
return n = n || {}, n.noPrefix ? e :
|
|
1803
|
+
f(g, "prefix", ""), f(g, "_getPrefixedKey", function(e, n) {
|
|
1804
|
+
return n = n || {}, n.noPrefix ? e : g.prefix + e;
|
|
1672
1805
|
});
|
|
1673
|
-
let w =
|
|
1674
|
-
const
|
|
1806
|
+
let w = g;
|
|
1807
|
+
const Q = {
|
|
1675
1808
|
/**
|
|
1676
1809
|
* 将json对象转换为查询字符串
|
|
1677
1810
|
*
|
|
@@ -1682,8 +1815,8 @@ const Y = {
|
|
|
1682
1815
|
var e = [];
|
|
1683
1816
|
for (var n in t)
|
|
1684
1817
|
if (t.hasOwnProperty(n)) {
|
|
1685
|
-
var
|
|
1686
|
-
e.push(encodeURIComponent(
|
|
1818
|
+
var r = n, s = t[n];
|
|
1819
|
+
e.push(encodeURIComponent(r) + "=" + encodeURIComponent(s));
|
|
1687
1820
|
}
|
|
1688
1821
|
var i = e.join("&");
|
|
1689
1822
|
return i;
|
|
@@ -1696,49 +1829,50 @@ const Y = {
|
|
|
1696
1829
|
* @returns 返回一个包含解析后参数的对象,其中键为参数名,值为参数值
|
|
1697
1830
|
*/
|
|
1698
1831
|
query2Json(t = window.location.href, e = !0) {
|
|
1699
|
-
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search:
|
|
1700
|
-
let
|
|
1701
|
-
for (let
|
|
1702
|
-
const c = i[
|
|
1832
|
+
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: r, hash: s } = new URL(t), i = [r, s];
|
|
1833
|
+
let o = {};
|
|
1834
|
+
for (let a = 0; a < i.length; a++) {
|
|
1835
|
+
const c = i[a];
|
|
1703
1836
|
if (c) {
|
|
1704
|
-
const
|
|
1705
|
-
if (
|
|
1706
|
-
for (let u = 1; u <
|
|
1837
|
+
const l = c.replace(/#|\//g, "").split("?");
|
|
1838
|
+
if (l.length > 1)
|
|
1839
|
+
for (let u = 1; u < l.length; u++) {
|
|
1707
1840
|
let d;
|
|
1708
|
-
for (; d = n.exec(
|
|
1709
|
-
|
|
1841
|
+
for (; d = n.exec(l[u]); )
|
|
1842
|
+
o[d[1]] = e ? decodeURIComponent(d[2]) : d[2];
|
|
1710
1843
|
}
|
|
1711
1844
|
}
|
|
1712
1845
|
}
|
|
1713
|
-
return
|
|
1846
|
+
return o;
|
|
1714
1847
|
}
|
|
1715
1848
|
};
|
|
1716
1849
|
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
|
|
1850
|
+
F as ArrayUtil,
|
|
1851
|
+
N as AudioPlayer,
|
|
1852
|
+
$ as BrowserUtil,
|
|
1853
|
+
k as CanvasDrawer,
|
|
1854
|
+
J as ColorUtil,
|
|
1855
|
+
G as Cookie,
|
|
1856
|
+
B as CoordsUtil,
|
|
1857
|
+
q as DateUtil,
|
|
1858
|
+
W as DomUtil,
|
|
1859
|
+
b as ErrorType,
|
|
1860
|
+
C as EventDispatcher,
|
|
1861
|
+
E as EventType,
|
|
1862
|
+
Y as FileUtil,
|
|
1863
|
+
j as GeoJsonUtil,
|
|
1864
|
+
H as GeoUtil,
|
|
1865
|
+
_ as GraphicType,
|
|
1866
|
+
x as HashMap,
|
|
1867
|
+
v as LayerType,
|
|
1868
|
+
m as MathUtil,
|
|
1869
|
+
P as MeasureMode,
|
|
1870
|
+
L as ObjectState,
|
|
1871
|
+
K as ObjectUtil,
|
|
1872
|
+
z as OptimizeUtil,
|
|
1739
1873
|
w as StoreUtil,
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1874
|
+
X as StringUtil,
|
|
1875
|
+
Q as UrlUtil,
|
|
1876
|
+
R as Util,
|
|
1877
|
+
U as WebSocketClient
|
|
1744
1878
|
};
|