gis-common 4.1.8 → 4.2.1
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/EventDispatcher.d.ts +1 -1
- package/dist/core/MqttClient.d.ts +33 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/gis-common.es.js +514 -420
- package/dist/gis-common.umd.js +1 -1
- package/dist/utils/ArrayUtil.d.ts +0 -1
- package/dist/utils/CommUtil.d.ts +14 -0
- package/package.json +4 -1
package/dist/gis-common.es.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var v = (t, e, n) => e in t ? L(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var g = (t, e, n) => v(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { connect as U } from "mqtt-browser";
|
|
5
|
+
var y = /* @__PURE__ */ ((t) => (t.MAP_RENDER = "mapRender", t.MAP_READY = "mapReady", t.MOUSE_CLICK = "click", t.MOUSE_DOUBLE_CLICK = "dblclick", t.MOUSE_MOVE = "mousemove", t.MOUSE_IN = "mousein", t.MOUSE_OUT = "mouseout", t.MOUSE_RIGHT_CLICK = "mouseRightClick", t.KEY_DOWN = "keyDown", t.KEY_UP = "keyUp", t.DRAW_ACTIVE = "drawActive", t.DRAW_MOVE = "drawMove", t.DRAW_COMPLETE = "drawComplete", t.MQTT_CONNECT = "mqttConnect", t.MQTT_ERROR = "mqttError", t.MQTT_MESSAGE = "mqttMessage", t.MQTT_CLOSE = "mqttClose", t.WEB_SOCKET_CONNECT = "webSocketConnect", t.WEB_SOCKET_ERROR = "webSocketError", t.WEB_SOCKET_MESSAGE = "webSocketMessage", t.WEB_SOCKET_CLOSE = "webSocketClose", t))(y || {}), b = /* @__PURE__ */ ((t) => (t.LOGIN_EXPIRED = "登录信息过期,请重新登录", t.CROSS_ERROR = "跨域访问", t.UNEXIST_RESOURCE = "资源不存在", t.TIMEOUT = "请求超时", t.INTERNAL_ERROR = "内部错误", t.NETWORK_ERROR = "请求失败,请检查网络是否已连接", t.PROCESS_FAIL = "处理失败", t.AUTH_VERIFY_ERROR = "权限验证失败", t.NO_DATA_FOUND = "未找到数据", t.DUPLICATE_INSTANCE = "实例为单例模式,不允许重复构建", t.COORDINATE_ERROR = "坐标验证失败", t.JSON_PARSE_ERROR = "JSON解析失败,格式有误", t.JSON_VALUE_ERROR = "JSON无此键", t.PARAMETER_ERROR = "验证数据类型失败", t.PARAMETER_ERROR_ARRAY = "格式类型验证失败:必须是数组", t.PARAMETER_ERROR_STRING = "格式类型验证失败:必须是字符", t.PARAMETER_ERROR_FUNCTION = "格式类型验证失败:必须是函数", t.PARAMETER_ERROR_OBJECT = "格式类型验证失败:必须是对象", t.PARAMETER_ERROR_LACK = "参数缺失", t.STRING_CHECK_LOSS = "字符缺少关键字", t))(b || {}), N = /* @__PURE__ */ ((t) => (t.SUPER_MAP_IMAGES = "SuperMapImages", t.SUPER_MAP_DATA = "SuperMapData", t.ARC_GIS_MAP_IMAGES = "ArcGisMapImages", t.ARC_GIS_MAP_DATA = "ArcGisMapData", t.OSGB_LAYER = "OSGBLayer", t.S3M_GROUP = "S3MGroup", t.TERRAIN_LAYER = "TerrainFileLayer", t))(N || {}), k = /* @__PURE__ */ ((t) => (t.POINT = "point", t.POLYLINE = "polyline", t.POLYGON = "polygon", t.BILLBOARD = "billboard", t.CYLINDER = "cylinder", t.ELLIPSOID = "ellipsoid", t.LABEL = "label", t.MODEL = "model", t.WALL = "wall", t))(k || {}), F = /* @__PURE__ */ ((t) => (t.DISTANCE = "distance", t.AREA = "area", t.HEIGHT = "height", t))(F || {}), B = /* @__PURE__ */ ((t) => (t.ADD = "add", t.REMOVE = "remove", t.INIT = "init", t))(B || {});
|
|
6
|
+
class H {
|
|
6
7
|
constructor(e) {
|
|
7
8
|
/**
|
|
8
9
|
* Creates an instance of AudioPlayer.
|
|
9
10
|
* @param {*} url
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
g(this, "audio");
|
|
12
13
|
this.audio = new Audio(), this.audio.src = e;
|
|
13
14
|
}
|
|
14
15
|
play() {
|
|
@@ -27,7 +28,7 @@ class F {
|
|
|
27
28
|
this.audio.muted = e;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
+
const R = {
|
|
31
32
|
DEG2RAD: Math.PI / 180,
|
|
32
33
|
RAD2DEG: 180 / Math.PI,
|
|
33
34
|
randInt(t, e) {
|
|
@@ -98,9 +99,9 @@ const m = {
|
|
|
98
99
|
return Math.max(Math.min(t, n), e);
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
|
-
class
|
|
102
|
+
class j {
|
|
102
103
|
constructor(e) {
|
|
103
|
-
|
|
104
|
+
g(this, "context", null);
|
|
104
105
|
if (typeof e == "string" && (e = document.querySelector("#" + e), !e))
|
|
105
106
|
throw new Error("Element not found");
|
|
106
107
|
if (e instanceof HTMLElement) {
|
|
@@ -120,12 +121,12 @@ class B {
|
|
|
120
121
|
* @param options 绘制选项,包括线条宽度和颜色
|
|
121
122
|
* @throws 当画布上下文不存在时抛出错误
|
|
122
123
|
*/
|
|
123
|
-
drawLine({ x: e, y: n }, { x: r, y:
|
|
124
|
+
drawLine({ x: e, y: n }, { x: r, y: i }, o = {}) {
|
|
124
125
|
if (!this.context)
|
|
125
126
|
throw new Error("Canvas context is null or undefined");
|
|
126
127
|
this.context.beginPath();
|
|
127
|
-
const a =
|
|
128
|
-
this.context.lineWidth = a, this.context.strokeStyle =
|
|
128
|
+
const a = o.width || 1, c = o.color || "#000";
|
|
129
|
+
this.context.lineWidth = a, this.context.strokeStyle = c, this.context.moveTo(e, n), this.context.lineTo(r, i), this.context.stroke();
|
|
129
130
|
}
|
|
130
131
|
/**
|
|
131
132
|
* 绘制圆弧
|
|
@@ -140,10 +141,10 @@ class B {
|
|
|
140
141
|
* @param bgColor 背景颜色
|
|
141
142
|
* @throws 当Canvas context为null或undefined时抛出错误
|
|
142
143
|
*/
|
|
143
|
-
drawArc({ x: e, y: n }, r,
|
|
144
|
+
drawArc({ x: e, y: n }, r, i, o, a, c, l) {
|
|
144
145
|
if (!this.context)
|
|
145
146
|
throw new Error("Canvas context is null or undefined");
|
|
146
|
-
|
|
147
|
+
c ? (this.context.fillStyle = l, this.context.beginPath(), this.context.arc(e, n, r, R.degreesToRadians(i), R.degreesToRadians(o), a), this.context.fill()) : (this.context.strokeStyle = l, this.context.beginPath(), this.context.arc(e, n, r, R.degreesToRadians(i), R.degreesToRadians(o), a), this.context.stroke());
|
|
147
148
|
}
|
|
148
149
|
static createCanvas(e = 1, n = 1) {
|
|
149
150
|
let r;
|
|
@@ -151,16 +152,16 @@ class B {
|
|
|
151
152
|
return r = document.createElement("canvas"), e && (r.width = e), n && (r.height = n), r;
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
|
-
class
|
|
155
|
+
class _ {
|
|
155
156
|
constructor() {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
g(this, "_listeners");
|
|
158
|
+
g(this, "_mutex", {});
|
|
159
|
+
g(this, "_context");
|
|
159
160
|
}
|
|
160
|
-
addEventListener(e, n, r,
|
|
161
|
+
addEventListener(e, n, r, i) {
|
|
161
162
|
this._listeners === void 0 && (this._listeners = {}), this._context = r;
|
|
162
|
-
const
|
|
163
|
-
return a[e] === void 0 && (a[e] = []), a[e].indexOf(n) === -1 && (
|
|
163
|
+
const o = this._mutex, a = this._listeners;
|
|
164
|
+
return a[e] === void 0 && (a[e] = []), a[e].indexOf(n) === -1 && (i && (o[e] = n), a[e].push(n)), this;
|
|
164
165
|
}
|
|
165
166
|
hasEventListener(e, n) {
|
|
166
167
|
if (this._listeners === null || this._listeners === void 0) return !1;
|
|
@@ -169,10 +170,10 @@ class v {
|
|
|
169
170
|
}
|
|
170
171
|
removeEventListener(e, n) {
|
|
171
172
|
if (this._listeners === void 0) return;
|
|
172
|
-
const
|
|
173
|
-
if (this._mutex[e] === n && (this._mutex[e] = null),
|
|
174
|
-
const
|
|
175
|
-
|
|
173
|
+
const i = this._listeners[e];
|
|
174
|
+
if (this._mutex[e] === n && (this._mutex[e] = null), i !== void 0) {
|
|
175
|
+
const o = i.map((a) => a.toString()).indexOf(n.toString());
|
|
176
|
+
o !== -1 && i.splice(o, 1);
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
dispatchEvent(e) {
|
|
@@ -180,17 +181,17 @@ class v {
|
|
|
180
181
|
const r = this._listeners[e.type];
|
|
181
182
|
if (r !== void 0) {
|
|
182
183
|
e.target = this;
|
|
183
|
-
const
|
|
184
|
+
const i = r.slice(0);
|
|
184
185
|
if (this._mutex[e.type] !== void 0) {
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
|
|
186
|
+
const o = i.find((a) => a === this._mutex[e.type]);
|
|
187
|
+
if (o) {
|
|
188
|
+
o.call(this._context || this, e);
|
|
188
189
|
return;
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
|
-
for (let
|
|
192
|
-
const
|
|
193
|
-
typeof
|
|
192
|
+
for (let o = 0, a = i.length; o < a; o++) {
|
|
193
|
+
const c = i[o];
|
|
194
|
+
typeof c == "function" && c.call(this._context || this, e);
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
}
|
|
@@ -200,7 +201,7 @@ class v {
|
|
|
200
201
|
this._listeners[e] = [];
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
|
-
class
|
|
204
|
+
class C extends Map {
|
|
204
205
|
isEmpty() {
|
|
205
206
|
return this.size === 0;
|
|
206
207
|
}
|
|
@@ -216,20 +217,20 @@ class x extends Map {
|
|
|
216
217
|
fromEntries() {
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
|
-
|
|
220
|
-
const e = new
|
|
220
|
+
C.prototype.fromEntries = function(t = []) {
|
|
221
|
+
const e = new C();
|
|
221
222
|
return t.forEach((n) => {
|
|
222
223
|
Array.isArray(n) && n.length === 2 && e.set(n[0], n[1]);
|
|
223
224
|
}), e;
|
|
224
225
|
};
|
|
225
|
-
class
|
|
226
|
+
class W extends _ {
|
|
226
227
|
constructor(n = "ws://127.0.0.1:10088") {
|
|
227
228
|
super();
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
g(this, "maxCheckTimes", 10);
|
|
230
|
+
g(this, "url");
|
|
231
|
+
g(this, "checkTimes", 0);
|
|
232
|
+
g(this, "connectStatus", !1);
|
|
233
|
+
g(this, "client", null);
|
|
233
234
|
this.maxCheckTimes = 10, this.url = n, this.checkTimes = 0, this.connect(), this.connCheckStatus(this.maxCheckTimes);
|
|
234
235
|
}
|
|
235
236
|
connect() {
|
|
@@ -239,22 +240,22 @@ class $ extends v {
|
|
|
239
240
|
const n = this;
|
|
240
241
|
this.client.onopen = function(r) {
|
|
241
242
|
n.dispatchEvent({
|
|
242
|
-
type:
|
|
243
|
+
type: y.WEB_SOCKET_CONNECT,
|
|
243
244
|
message: r
|
|
244
245
|
});
|
|
245
246
|
}, this.client.onmessage = function(r) {
|
|
246
247
|
n.connectStatus = !0, n.dispatchEvent({
|
|
247
|
-
type:
|
|
248
|
+
type: y.WEB_SOCKET_MESSAGE,
|
|
248
249
|
message: r
|
|
249
250
|
});
|
|
250
251
|
}, this.client.onclose = function(r) {
|
|
251
252
|
n.dispatchEvent({
|
|
252
|
-
type:
|
|
253
|
+
type: y.WEB_SOCKET_CLOSE,
|
|
253
254
|
message: r
|
|
254
255
|
});
|
|
255
256
|
}, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(r) {
|
|
256
257
|
n.dispatchEvent({
|
|
257
|
-
type:
|
|
258
|
+
type: y.WEB_SOCKET_ERROR,
|
|
258
259
|
message: r
|
|
259
260
|
});
|
|
260
261
|
});
|
|
@@ -285,7 +286,7 @@ class $ extends v {
|
|
|
285
286
|
}, 1e3);
|
|
286
287
|
}
|
|
287
288
|
}
|
|
288
|
-
const
|
|
289
|
+
const M = {
|
|
289
290
|
/**
|
|
290
291
|
* 获取数据类型
|
|
291
292
|
*
|
|
@@ -295,6 +296,18 @@ const y = {
|
|
|
295
296
|
getDataType(t) {
|
|
296
297
|
return Object.prototype.toString.call(t).slice(8, -1);
|
|
297
298
|
},
|
|
299
|
+
asArray(t) {
|
|
300
|
+
return this.isEmpty(t) ? [] : Array.isArray(t) ? t : [t];
|
|
301
|
+
},
|
|
302
|
+
asNumber(t) {
|
|
303
|
+
return Number.isNaN(Number(t)) ? 0 : Number(t);
|
|
304
|
+
},
|
|
305
|
+
/**
|
|
306
|
+
* 判断传入的值是否为空
|
|
307
|
+
*
|
|
308
|
+
* @param value 待判断的值
|
|
309
|
+
* @returns 返回布尔值,表示是否为空
|
|
310
|
+
*/
|
|
298
311
|
isEmpty(t) {
|
|
299
312
|
if (t == null)
|
|
300
313
|
return !0;
|
|
@@ -314,6 +327,12 @@ const y = {
|
|
|
314
327
|
isNotEmpty(t) {
|
|
315
328
|
return !this.isEmpty(t);
|
|
316
329
|
},
|
|
330
|
+
/**
|
|
331
|
+
* 将JSON对象转换为FormData对象
|
|
332
|
+
*
|
|
333
|
+
* @param json 待转换的JSON对象,其属性值为字符串或Blob类型
|
|
334
|
+
* @returns 转换后的FormData对象
|
|
335
|
+
*/
|
|
317
336
|
json2form(t) {
|
|
318
337
|
const e = new FormData();
|
|
319
338
|
return Object.keys(t).forEach((n) => {
|
|
@@ -342,8 +361,8 @@ const y = {
|
|
|
342
361
|
if (t.length > 1) {
|
|
343
362
|
const n = t.slice(1, t.length % 2 === 0 ? t.length - 1 : t.length);
|
|
344
363
|
for (let r = 0; r < n.length; r = r + 2) {
|
|
345
|
-
const
|
|
346
|
-
t[0] ===
|
|
364
|
+
const i = n[r];
|
|
365
|
+
t[0] === i && (e = n[r + 1]);
|
|
347
366
|
}
|
|
348
367
|
!e && t.length % 2 === 0 && (e = t[t.length - 1]);
|
|
349
368
|
} else
|
|
@@ -358,11 +377,11 @@ const y = {
|
|
|
358
377
|
* @returns 返回目标对象,包含所有复制的属性。
|
|
359
378
|
*/
|
|
360
379
|
extend(t, ...e) {
|
|
361
|
-
let n, r,
|
|
362
|
-
for (r = 0,
|
|
363
|
-
|
|
364
|
-
for (n in
|
|
365
|
-
t[n] =
|
|
380
|
+
let n, r, i, o;
|
|
381
|
+
for (r = 0, i = e.length; r < i; r++) {
|
|
382
|
+
o = e[r];
|
|
383
|
+
for (n in o)
|
|
384
|
+
t[n] = o[n];
|
|
366
385
|
}
|
|
367
386
|
return t;
|
|
368
387
|
},
|
|
@@ -376,14 +395,14 @@ const y = {
|
|
|
376
395
|
* @returns 转换后的树形结构数组
|
|
377
396
|
*/
|
|
378
397
|
convertToTree2(t, e = "id", n = "parentId", r = "children") {
|
|
379
|
-
const
|
|
380
|
-
function
|
|
381
|
-
const
|
|
382
|
-
|
|
398
|
+
const i = [];
|
|
399
|
+
function o(a) {
|
|
400
|
+
const c = t.filter((l) => l[n] === a[e]).map((l) => (i.some((u) => u[e] === l[e]) || o(l), l));
|
|
401
|
+
c.length > 0 && (a[r] = c);
|
|
383
402
|
}
|
|
384
403
|
return t.forEach((a) => {
|
|
385
|
-
t.some((
|
|
386
|
-
}),
|
|
404
|
+
t.some((c) => c[n] === a[e]) || (o(a), i.push(a));
|
|
405
|
+
}), i;
|
|
387
406
|
},
|
|
388
407
|
/**
|
|
389
408
|
* 异步加载script
|
|
@@ -430,11 +449,11 @@ const y = {
|
|
|
430
449
|
*/
|
|
431
450
|
template(t, e) {
|
|
432
451
|
const n = /\{ *([\w_-]+) *\}/g;
|
|
433
|
-
return t.replace(n, (r,
|
|
434
|
-
const
|
|
435
|
-
if (
|
|
436
|
-
throw new Error(`${
|
|
437
|
-
return typeof
|
|
452
|
+
return t.replace(n, (r, i) => {
|
|
453
|
+
const o = e[i];
|
|
454
|
+
if (o === void 0)
|
|
455
|
+
throw new Error(`${b.JSON_VALUE_ERROR}: ${r}`);
|
|
456
|
+
return typeof o == "function" ? o(e) : o;
|
|
438
457
|
});
|
|
439
458
|
},
|
|
440
459
|
/**
|
|
@@ -503,7 +522,176 @@ const y = {
|
|
|
503
522
|
parse(t) {
|
|
504
523
|
return !t || typeof t != "string" ? t : JSON.parse(t);
|
|
505
524
|
}
|
|
506
|
-
}
|
|
525
|
+
};
|
|
526
|
+
Array.prototype.groupBy = function(t) {
|
|
527
|
+
var e = {};
|
|
528
|
+
return this.forEach(function(n) {
|
|
529
|
+
var r = JSON.stringify(t(n));
|
|
530
|
+
e[r] = e[r] || [], e[r].push(n);
|
|
531
|
+
}), Object.keys(e).map((n) => e[n]);
|
|
532
|
+
};
|
|
533
|
+
Array.prototype.distinct = function(t = (e) => e) {
|
|
534
|
+
const e = [], n = {};
|
|
535
|
+
return this.forEach((r) => {
|
|
536
|
+
const i = t(r), o = String(i);
|
|
537
|
+
n[o] || (n[o] = !0, e.push(r));
|
|
538
|
+
}), e;
|
|
539
|
+
};
|
|
540
|
+
Array.prototype.max = function() {
|
|
541
|
+
return Math.max.apply({}, this);
|
|
542
|
+
};
|
|
543
|
+
Array.prototype.min = function() {
|
|
544
|
+
return Math.min.apply({}, this);
|
|
545
|
+
};
|
|
546
|
+
Array.prototype.sum = function() {
|
|
547
|
+
return this.length > 0 ? this.reduce((t = 0, e = 0) => t + e) : 0;
|
|
548
|
+
};
|
|
549
|
+
Array.prototype.avg = function() {
|
|
550
|
+
return this.length ? this.sum() / this.length : 0;
|
|
551
|
+
};
|
|
552
|
+
Array.prototype.desc = function(t = (e) => e) {
|
|
553
|
+
return this.sort((e, n) => t(n) - t(e));
|
|
554
|
+
};
|
|
555
|
+
Array.prototype.asc = function(t = (e) => e) {
|
|
556
|
+
return this.sort((e, n) => t(e) - t(n));
|
|
557
|
+
};
|
|
558
|
+
Array.prototype.remove = function(t) {
|
|
559
|
+
const e = this.indexOf(t);
|
|
560
|
+
return e > -1 && this.splice(e, 1), this;
|
|
561
|
+
};
|
|
562
|
+
Array.prototype.clear = function() {
|
|
563
|
+
return this.length = 0, this;
|
|
564
|
+
};
|
|
565
|
+
const S = {
|
|
566
|
+
/**
|
|
567
|
+
* 创建指定长度的数组,并返回其索引数组
|
|
568
|
+
*
|
|
569
|
+
* @param length 数组长度
|
|
570
|
+
* @returns 索引数组
|
|
571
|
+
*/
|
|
572
|
+
create(t) {
|
|
573
|
+
return [...new Array(t).keys()];
|
|
574
|
+
},
|
|
575
|
+
/**
|
|
576
|
+
* 合并多个数组,并去重
|
|
577
|
+
*
|
|
578
|
+
* @param args 需要合并的数组
|
|
579
|
+
* @returns 合并后的去重数组
|
|
580
|
+
*/
|
|
581
|
+
union(...t) {
|
|
582
|
+
let e = [];
|
|
583
|
+
return t.forEach((n) => {
|
|
584
|
+
Array.isArray(n) && (e = e.concat(n.filter((r) => !e.includes(r))));
|
|
585
|
+
}), e;
|
|
586
|
+
},
|
|
587
|
+
/**
|
|
588
|
+
* 求多个数组的交集
|
|
589
|
+
*
|
|
590
|
+
* @param args 多个需要求交集的数组
|
|
591
|
+
* @returns 返回多个数组的交集数组
|
|
592
|
+
*/
|
|
593
|
+
intersection(...t) {
|
|
594
|
+
let e = t[0] || [];
|
|
595
|
+
return t.forEach((n) => {
|
|
596
|
+
Array.isArray(n) && (e = e.filter((r) => n.includes(r)));
|
|
597
|
+
}), e;
|
|
598
|
+
},
|
|
599
|
+
/**
|
|
600
|
+
* 将多个数组拼接为一个数组,并去除其中的空值。
|
|
601
|
+
*
|
|
602
|
+
* @param args 需要拼接的数组列表。
|
|
603
|
+
* @returns 拼接并去空后的数组。
|
|
604
|
+
*/
|
|
605
|
+
unionAll(...t) {
|
|
606
|
+
return [...t].flat().filter((e) => !!e);
|
|
607
|
+
},
|
|
608
|
+
/**
|
|
609
|
+
* 求差集
|
|
610
|
+
*
|
|
611
|
+
* @param args 任意个集合
|
|
612
|
+
* @returns 返回差集结果
|
|
613
|
+
*/
|
|
614
|
+
difference(...t) {
|
|
615
|
+
return this.union(...t).filter((e) => !this.intersection(...t).includes(e));
|
|
616
|
+
}
|
|
617
|
+
}, x = class x extends _ {
|
|
618
|
+
constructor(n = {}) {
|
|
619
|
+
super();
|
|
620
|
+
g(this, "state");
|
|
621
|
+
g(this, "context");
|
|
622
|
+
g(this, "options");
|
|
623
|
+
g(this, "client");
|
|
624
|
+
g(this, "topics");
|
|
625
|
+
this.context = M.extend(x.defaultContext, n), this.options = {
|
|
626
|
+
connectTimeout: this.context.MQTT_TIMEOUTM,
|
|
627
|
+
clientId: M.guid(),
|
|
628
|
+
username: this.context.MQTT_USERNAME,
|
|
629
|
+
password: this.context.MQTT_PASSWORD,
|
|
630
|
+
clean: !0
|
|
631
|
+
}, this.client = U(this.context.MQTT_SERVICE, this.options), this._onConnect(), this._onMessage(), this.state = 0, this.topics = [];
|
|
632
|
+
}
|
|
633
|
+
_onConnect() {
|
|
634
|
+
this.client.on("connect", () => {
|
|
635
|
+
this.state = 1, console.log("链接mqtt成功==>" + this.context.MQTT_SERVICE), this.dispatchEvent({ type: y.MQTT_CONNECT, message: this });
|
|
636
|
+
}), this.client.on("error", (n) => {
|
|
637
|
+
console.log("链接mqtt报错", n), this.state = -1, this.dispatchEvent({ type: y.MQTT_ERROR, message: this }), this.client.end(), this.client.reconnect();
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
_onMessage() {
|
|
641
|
+
this.client.on("message", (n, r) => {
|
|
642
|
+
let i = r, o = "";
|
|
643
|
+
r instanceof Uint8Array && (i = r.toString());
|
|
644
|
+
try {
|
|
645
|
+
o = T.parse(i);
|
|
646
|
+
} catch {
|
|
647
|
+
throw new Error(b.JSON_PARSE_ERROR);
|
|
648
|
+
}
|
|
649
|
+
this.dispatchEvent({
|
|
650
|
+
type: y.MQTT_MESSAGE,
|
|
651
|
+
message: { topic: n, data: o }
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
sendMsg(n, r) {
|
|
656
|
+
if (!this.client.connected) {
|
|
657
|
+
console.error("客户端未连接");
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
this.client.publish(n, r, { qos: 1, retain: !0 });
|
|
661
|
+
}
|
|
662
|
+
subscribe(n) {
|
|
663
|
+
return this.state === 1 ? this.client.subscribe(n, { qos: 1 }, (r, i) => {
|
|
664
|
+
r instanceof Error ? console.error("订阅失败==>" + n, r) : (this.topics = S.union(this.topics, n), console.log("订阅成功==>" + n));
|
|
665
|
+
}) : this.addEventListener(y.MQTT_CONNECT, (r) => {
|
|
666
|
+
this.client.subscribe(n, { qos: 1 }, (i, o) => {
|
|
667
|
+
i instanceof Error ? console.error("订阅失败==>" + n, i) : (this.topics = S.union(this.topics, n), console.log("订阅成功==>" + n));
|
|
668
|
+
});
|
|
669
|
+
}), this;
|
|
670
|
+
}
|
|
671
|
+
unsubscribe(n) {
|
|
672
|
+
return this.client.unsubscribe(n, { qos: 1 }, (r, i) => {
|
|
673
|
+
r instanceof Error ? console.error(`取消订阅失败==>${n}`, r) : (this.topics = S.difference(this.topics, s), console.log(`取消订阅成功==>${n}`));
|
|
674
|
+
}), this;
|
|
675
|
+
}
|
|
676
|
+
unsubscribeAll() {
|
|
677
|
+
this.unsubscribe(this.topics);
|
|
678
|
+
}
|
|
679
|
+
unconnect() {
|
|
680
|
+
this.client.end(), this.client = null, this.dispatchEvent({ type: y.MQTT_CLOSE, message: null }), console.log("断开mqtt成功==>" + this.context.MQTT_SERVICE);
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
/**
|
|
684
|
+
* Creates an instance of MqttClient.
|
|
685
|
+
* @param {*} config mqtt实例参数
|
|
686
|
+
*/
|
|
687
|
+
g(x, "defaultContext", {
|
|
688
|
+
MQTT_USERNAME: "iRVMS-WEB",
|
|
689
|
+
MQTT_PASSWORD: "novasky888",
|
|
690
|
+
MQTT_SERVICE: `ws://${window.document.domain}:20007/mqtt`,
|
|
691
|
+
MQTT_TIMEOUTM: 2e4
|
|
692
|
+
});
|
|
693
|
+
let O = x;
|
|
694
|
+
const $ = {
|
|
507
695
|
emptyImageUrl: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
|
|
508
696
|
/**
|
|
509
697
|
*
|
|
@@ -536,8 +724,8 @@ const y = {
|
|
|
536
724
|
return new Promise((e, n) => {
|
|
537
725
|
let r = new Image();
|
|
538
726
|
r.setAttribute("crossOrigin", "Anonymous"), r.src = t, r.onload = () => {
|
|
539
|
-
let
|
|
540
|
-
e(
|
|
727
|
+
let i = this.getURL(r);
|
|
728
|
+
e(i);
|
|
541
729
|
}, r.onerror = n;
|
|
542
730
|
});
|
|
543
731
|
},
|
|
@@ -567,28 +755,28 @@ const y = {
|
|
|
567
755
|
const e = await this.getBase64(t), n = this.parseBase64(e.dataURL);
|
|
568
756
|
if (!n)
|
|
569
757
|
throw new Error("Failed to parse base64 data.");
|
|
570
|
-
let r = n.type,
|
|
571
|
-
for (let l = 0; l <
|
|
572
|
-
a[l] =
|
|
573
|
-
let
|
|
574
|
-
await navigator.clipboard.write([new ClipboardItem({ [r]:
|
|
758
|
+
let r = n.type, i = atob(n.data), o = new ArrayBuffer(i.length), a = new Uint8Array(o);
|
|
759
|
+
for (let l = 0; l < i.length; l++)
|
|
760
|
+
a[l] = i.charCodeAt(l);
|
|
761
|
+
let c = new Blob([o], { type: r });
|
|
762
|
+
await navigator.clipboard.write([new ClipboardItem({ [r]: c })]);
|
|
575
763
|
} catch (e) {
|
|
576
764
|
console.error("Failed to copy image to clipboard:", e);
|
|
577
765
|
}
|
|
578
766
|
}
|
|
579
|
-
},
|
|
767
|
+
}, E = {
|
|
580
768
|
/**
|
|
581
769
|
* Get JSON data by jsonp
|
|
582
770
|
* @param url - resource url
|
|
583
771
|
* @param callback - callback function when completed
|
|
584
772
|
*/
|
|
585
773
|
jsonp(t, e) {
|
|
586
|
-
const n = "_jsonp_" +
|
|
774
|
+
const n = "_jsonp_" + M.guid(), r = document.getElementsByTagName("head")[0];
|
|
587
775
|
t.includes("?") ? t += "&callback=" + n : t += "?callback=" + n;
|
|
588
|
-
let
|
|
589
|
-
|
|
590
|
-
e(null,
|
|
591
|
-
}, r.appendChild(
|
|
776
|
+
let i = document.createElement("script");
|
|
777
|
+
i.type = "text/javascript", i.src = t, window[n] = function(o) {
|
|
778
|
+
e(null, o), r.removeChild(i), i = null, delete window[n];
|
|
779
|
+
}, r.appendChild(i);
|
|
592
780
|
},
|
|
593
781
|
/**
|
|
594
782
|
* Fetch remote resource by HTTP "GET" method
|
|
@@ -611,14 +799,14 @@ const y = {
|
|
|
611
799
|
* );
|
|
612
800
|
*/
|
|
613
801
|
get(t, e, n) {
|
|
614
|
-
if (
|
|
615
|
-
const
|
|
616
|
-
n = e, e =
|
|
802
|
+
if (M.isFunction(e)) {
|
|
803
|
+
const i = n;
|
|
804
|
+
n = e, e = i;
|
|
617
805
|
}
|
|
618
|
-
const r =
|
|
806
|
+
const r = E._getClient(n);
|
|
619
807
|
if (r.open("GET", t, !0), e) {
|
|
620
|
-
for (const
|
|
621
|
-
r.setRequestHeader(
|
|
808
|
+
for (const i in e.headers)
|
|
809
|
+
r.setRequestHeader(i, e.headers[i]);
|
|
622
810
|
r.withCredentials = e.credentials === "include", e.responseType && (r.responseType = e.responseType);
|
|
623
811
|
}
|
|
624
812
|
return r.send(null), r;
|
|
@@ -652,10 +840,10 @@ const y = {
|
|
|
652
840
|
let r;
|
|
653
841
|
if (typeof t != "string" ? (n = e.cb, r = e.postData, e = { ...e }, delete e.cb, delete e.postData, t = e.url) : (typeof e == "function" && (n = e, e = {}), r = e.postData), !n)
|
|
654
842
|
throw new Error("Callback function is required");
|
|
655
|
-
const
|
|
656
|
-
return
|
|
657
|
-
|
|
658
|
-
}), typeof r != "string" && (r = JSON.stringify(r)),
|
|
843
|
+
const i = E._getClient(n);
|
|
844
|
+
return i.open("POST", t, !0), e.headers = e.headers || {}, e.headers["Content-Type"] || (e.headers["Content-Type"] = "application/x-www-form-urlencoded"), Object.keys(e.headers).forEach((o) => {
|
|
845
|
+
i.setRequestHeader(o, e.headers[o]);
|
|
846
|
+
}), typeof r != "string" && (r = JSON.stringify(r)), i.send(r), i;
|
|
659
847
|
},
|
|
660
848
|
_wrapCallback(t, e) {
|
|
661
849
|
return function() {
|
|
@@ -674,7 +862,7 @@ const y = {
|
|
|
674
862
|
} catch {
|
|
675
863
|
throw new Error("XMLHttpRequest not supported.");
|
|
676
864
|
}
|
|
677
|
-
return e && (e.onreadystatechange =
|
|
865
|
+
return e && (e.onreadystatechange = E._wrapCallback(e, t)), e;
|
|
678
866
|
},
|
|
679
867
|
/**
|
|
680
868
|
* Fetch resource as arraybuffer.
|
|
@@ -693,23 +881,23 @@ const y = {
|
|
|
693
881
|
* );
|
|
694
882
|
*/
|
|
695
883
|
getArrayBuffer(t, e, n) {
|
|
696
|
-
if (
|
|
884
|
+
if (M.isFunction(e)) {
|
|
697
885
|
const r = n;
|
|
698
886
|
n = e, e = r;
|
|
699
887
|
}
|
|
700
|
-
return e || (e = {}), e.responseType = "arraybuffer",
|
|
888
|
+
return e || (e = {}), e.responseType = "arraybuffer", E.get(t, e, n);
|
|
701
889
|
},
|
|
702
890
|
getImage(t, e, n) {
|
|
703
|
-
return
|
|
891
|
+
return E.getArrayBuffer(e, n, (r, i) => {
|
|
704
892
|
if (r)
|
|
705
893
|
t.onerror && t.onerror(r);
|
|
706
|
-
else if (
|
|
707
|
-
const
|
|
894
|
+
else if (i) {
|
|
895
|
+
const o = window.URL || window.webkitURL, a = t.onload;
|
|
708
896
|
t.onload = () => {
|
|
709
|
-
a && a(),
|
|
897
|
+
a && a(), o.revokeObjectURL(t.src);
|
|
710
898
|
};
|
|
711
|
-
const
|
|
712
|
-
t.cacheControl =
|
|
899
|
+
const c = new Blob([new Uint8Array(i.data)], { type: i.contentType });
|
|
900
|
+
t.cacheControl = i.cacheControl, t.expires = i.expires, t.src = i.data.byteLength ? o.createObjectURL(c) : $.emptyImageUrl;
|
|
713
901
|
}
|
|
714
902
|
});
|
|
715
903
|
},
|
|
@@ -733,112 +921,17 @@ const y = {
|
|
|
733
921
|
* );
|
|
734
922
|
*/
|
|
735
923
|
getJSON(t, e, n) {
|
|
736
|
-
if (
|
|
737
|
-
const
|
|
738
|
-
n = e, e =
|
|
924
|
+
if (M.isFunction(e)) {
|
|
925
|
+
const i = n;
|
|
926
|
+
n = e, e = i;
|
|
739
927
|
}
|
|
740
|
-
const r = function(
|
|
741
|
-
const a =
|
|
742
|
-
n && n(
|
|
928
|
+
const r = function(i, o) {
|
|
929
|
+
const a = o ? T.parse(o) : null;
|
|
930
|
+
n && n(i, a);
|
|
743
931
|
};
|
|
744
|
-
return e && e.jsonp ?
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
Array.prototype.groupBy = function(t) {
|
|
748
|
-
var e = {};
|
|
749
|
-
return this.forEach(function(n) {
|
|
750
|
-
var r = JSON.stringify(t(n));
|
|
751
|
-
e[r] = e[r] || [], e[r].push(n);
|
|
752
|
-
}), Object.keys(e).map((n) => e[n]);
|
|
753
|
-
};
|
|
754
|
-
Array.prototype.distinct = function(t = (e) => e) {
|
|
755
|
-
const e = [], n = {};
|
|
756
|
-
return this.forEach((r) => {
|
|
757
|
-
const s = t(r), i = String(s);
|
|
758
|
-
n[i] || (n[i] = !0, e.push(r));
|
|
759
|
-
}), e;
|
|
760
|
-
};
|
|
761
|
-
Array.prototype.max = function() {
|
|
762
|
-
return Math.max.apply({}, this);
|
|
763
|
-
};
|
|
764
|
-
Array.prototype.min = function() {
|
|
765
|
-
return Math.min.apply({}, this);
|
|
766
|
-
};
|
|
767
|
-
Array.prototype.sum = function() {
|
|
768
|
-
return this.length > 0 ? this.reduce((t = 0, e = 0) => t + e) : 0;
|
|
769
|
-
};
|
|
770
|
-
Array.prototype.avg = function() {
|
|
771
|
-
return this.length ? this.sum() / this.length : 0;
|
|
772
|
-
};
|
|
773
|
-
Array.prototype.desc = function(t = (e) => e) {
|
|
774
|
-
return this.sort((e, n) => t(n) - t(e));
|
|
775
|
-
};
|
|
776
|
-
Array.prototype.asc = function(t = (e) => e) {
|
|
777
|
-
return this.sort((e, n) => t(e) - t(n));
|
|
778
|
-
};
|
|
779
|
-
Array.prototype.remove = function(t) {
|
|
780
|
-
const e = this.indexOf(t);
|
|
781
|
-
return e > -1 && this.splice(e, 1), this;
|
|
782
|
-
};
|
|
783
|
-
Array.prototype.clear = function() {
|
|
784
|
-
return this.length = 0, this;
|
|
785
|
-
};
|
|
786
|
-
const G = {
|
|
787
|
-
asArray(t) {
|
|
788
|
-
return y.isEmpty(t) ? [] : Array.isArray(t) ? t : [t];
|
|
789
|
-
},
|
|
790
|
-
/**
|
|
791
|
-
* 创建指定长度的数组,并返回其索引数组
|
|
792
|
-
*
|
|
793
|
-
* @param length 数组长度
|
|
794
|
-
* @returns 索引数组
|
|
795
|
-
*/
|
|
796
|
-
create(t) {
|
|
797
|
-
return [...new Array(t).keys()];
|
|
798
|
-
},
|
|
799
|
-
/**
|
|
800
|
-
* 合并多个数组,并去重
|
|
801
|
-
*
|
|
802
|
-
* @param args 需要合并的数组
|
|
803
|
-
* @returns 合并后的去重数组
|
|
804
|
-
*/
|
|
805
|
-
union(...t) {
|
|
806
|
-
let e = [];
|
|
807
|
-
return t.forEach((n) => {
|
|
808
|
-
Array.isArray(n) && (e = e.concat(n.filter((r) => !e.includes(r))));
|
|
809
|
-
}), e;
|
|
810
|
-
},
|
|
811
|
-
/**
|
|
812
|
-
* 求多个数组的交集
|
|
813
|
-
*
|
|
814
|
-
* @param args 多个需要求交集的数组
|
|
815
|
-
* @returns 返回多个数组的交集数组
|
|
816
|
-
*/
|
|
817
|
-
intersection(...t) {
|
|
818
|
-
let e = t[0] || [];
|
|
819
|
-
return t.forEach((n) => {
|
|
820
|
-
Array.isArray(n) && (e = e.filter((r) => n.includes(r)));
|
|
821
|
-
}), e;
|
|
822
|
-
},
|
|
823
|
-
/**
|
|
824
|
-
* 将多个数组拼接为一个数组,并去除其中的空值。
|
|
825
|
-
*
|
|
826
|
-
* @param args 需要拼接的数组列表。
|
|
827
|
-
* @returns 拼接并去空后的数组。
|
|
828
|
-
*/
|
|
829
|
-
unionAll(...t) {
|
|
830
|
-
return [...t].flat().filter((e) => !!e);
|
|
831
|
-
},
|
|
832
|
-
/**
|
|
833
|
-
* 求差集
|
|
834
|
-
*
|
|
835
|
-
* @param args 任意个集合
|
|
836
|
-
* @returns 返回差集结果
|
|
837
|
-
*/
|
|
838
|
-
difference(...t) {
|
|
839
|
-
return this.union(...t).filter((e) => !this.intersection(...t).includes(e));
|
|
932
|
+
return e && e.jsonp ? E.jsonp(t, r) : E.get(t, e, r);
|
|
840
933
|
}
|
|
841
|
-
},
|
|
934
|
+
}, Q = {
|
|
842
935
|
/**
|
|
843
936
|
* 获取浏览器类型
|
|
844
937
|
*
|
|
@@ -855,8 +948,8 @@ const G = {
|
|
|
855
948
|
*/
|
|
856
949
|
detectOS() {
|
|
857
950
|
let t = "";
|
|
858
|
-
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,
|
|
859
|
-
return e ? t = "MS Windows" : n ? t = "Apple mac" : r ? t = "Linux" :
|
|
951
|
+
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, i = navigator.userAgent.indexOf("X11", 0) != -1 ? 1 : 0;
|
|
952
|
+
return e ? t = "MS Windows" : n ? t = "Apple mac" : r ? t = "Linux" : i && (t = "Unix"), t;
|
|
860
953
|
},
|
|
861
954
|
/**
|
|
862
955
|
* 切换全屏状态
|
|
@@ -878,9 +971,9 @@ const G = {
|
|
|
878
971
|
refreshScale() {
|
|
879
972
|
const t = document.documentElement.clientWidth || 0, e = document.documentElement.clientHeight || 0, n = document.getElementById("app");
|
|
880
973
|
if (!n) return;
|
|
881
|
-
const r = n.style,
|
|
974
|
+
const r = n.style, i = t / e, o = 16 / 9;
|
|
882
975
|
let a = t / 1920;
|
|
883
|
-
|
|
976
|
+
i > o && (a = e / 1080), r.transformOrigin = "left top", r.transform = `scale(${a}) translateX(-49.99%)`, r.width = `${t / a}px`;
|
|
884
977
|
},
|
|
885
978
|
/**
|
|
886
979
|
* 获取HTML字体大小
|
|
@@ -891,7 +984,7 @@ const G = {
|
|
|
891
984
|
const t = document.documentElement.clientWidth || document.body.clientWidth, e = document.querySelector("html");
|
|
892
985
|
e && (e.style.fontSize = t / 192 + "px");
|
|
893
986
|
}
|
|
894
|
-
},
|
|
987
|
+
}, K = {
|
|
895
988
|
set: function(t, e, n = 30) {
|
|
896
989
|
var r = /* @__PURE__ */ new Date();
|
|
897
990
|
r.setTime(r.getTime() + n * 24 * 60 * 60 * 1e3), document.cookie = t + "=" + escape(e) + ";expires=" + r.toUTCString();
|
|
@@ -906,17 +999,17 @@ const G = {
|
|
|
906
999
|
var e = document.cookie.match(new RegExp("(^| )" + t + "=([^;]*)(;|$)"));
|
|
907
1000
|
return e != null ? e[2] : "";
|
|
908
1001
|
}
|
|
909
|
-
},
|
|
1002
|
+
}, Y = {
|
|
910
1003
|
PI: 3.141592653589793,
|
|
911
1004
|
XPI: 3.141592653589793 * 3e3 / 180,
|
|
912
1005
|
delta(t, e) {
|
|
913
1006
|
const r = 0.006693421622965943;
|
|
914
|
-
let
|
|
1007
|
+
let i = this.transformLat(e - 105, t - 35), o = this.transformLon(e - 105, t - 35);
|
|
915
1008
|
const a = t / 180 * this.PI;
|
|
916
|
-
let
|
|
917
|
-
|
|
918
|
-
const l = Math.sqrt(
|
|
919
|
-
return
|
|
1009
|
+
let c = Math.sin(a);
|
|
1010
|
+
c = 1 - r * c * c;
|
|
1011
|
+
const l = Math.sqrt(c);
|
|
1012
|
+
return i = i * 180 / (6378245 * (1 - r) / (c * l) * this.PI), o = o * 180 / (6378245 / l * Math.cos(a) * this.PI), { lat: i, lng: o };
|
|
920
1013
|
},
|
|
921
1014
|
/**
|
|
922
1015
|
* 判断经纬度是否不在中国境内
|
|
@@ -944,23 +1037,23 @@ const G = {
|
|
|
944
1037
|
},
|
|
945
1038
|
// GCJ-02 to WGS-84 exactly
|
|
946
1039
|
gcjDecryptExact(t, e) {
|
|
947
|
-
let
|
|
1040
|
+
let i = 0.01, o = 0.01, a = t - i, c = e - o, l = t + i, u = e + o, h = 0, d = 0, f = 0;
|
|
948
1041
|
for (; ; ) {
|
|
949
|
-
|
|
950
|
-
const
|
|
951
|
-
if (
|
|
1042
|
+
h = (a + l) / 2, d = (c + u) / 2;
|
|
1043
|
+
const m = this.gcjEncrypt(h, d);
|
|
1044
|
+
if (i = m.lat - t, o = m.lng - e, Math.abs(i) < 1e-9 && Math.abs(o) < 1e-9 || (i > 0 ? l = h : a = h, o > 0 ? u = d : c = d, ++f > 1e4)) break;
|
|
952
1045
|
}
|
|
953
|
-
return { lat:
|
|
1046
|
+
return { lat: h, lng: d };
|
|
954
1047
|
},
|
|
955
1048
|
// GCJ-02 to BD-09
|
|
956
1049
|
bdEncrypt(t, e) {
|
|
957
|
-
const n = e, r = t,
|
|
958
|
-
return { lat:
|
|
1050
|
+
const n = e, r = t, i = Math.sqrt(n * n + r * r) + 2e-5 * Math.sin(r * this.XPI), o = Math.atan2(r, n) + 3e-6 * Math.cos(n * this.XPI), a = i * Math.cos(o) + 65e-4;
|
|
1051
|
+
return { lat: i * Math.sin(o) + 6e-3, lng: a };
|
|
959
1052
|
},
|
|
960
1053
|
// BD-09 to GCJ-02
|
|
961
1054
|
bdDecrypt(t, e) {
|
|
962
|
-
const n = e - 65e-4, r = t - 6e-3,
|
|
963
|
-
return { lat:
|
|
1055
|
+
const n = e - 65e-4, r = t - 6e-3, i = Math.sqrt(n * n + r * r) - 2e-5 * Math.sin(r * this.XPI), o = Math.atan2(r, n) - 3e-6 * Math.cos(n * this.XPI), a = i * Math.cos(o);
|
|
1056
|
+
return { lat: i * Math.sin(o), lng: a };
|
|
964
1057
|
},
|
|
965
1058
|
// WGS-84 to Web mercator
|
|
966
1059
|
// mercatorLat -> y mercatorLon -> x
|
|
@@ -1001,17 +1094,17 @@ const G = {
|
|
|
1001
1094
|
if (!Array.isArray(t))
|
|
1002
1095
|
return n ? e.call(n, t) : e(t);
|
|
1003
1096
|
const r = [];
|
|
1004
|
-
let
|
|
1005
|
-
for (let a = 0,
|
|
1006
|
-
if (
|
|
1097
|
+
let i, o;
|
|
1098
|
+
for (let a = 0, c = t.length; a < c; a++) {
|
|
1099
|
+
if (i = t[a], M.isNil(i)) {
|
|
1007
1100
|
r.push(null);
|
|
1008
1101
|
continue;
|
|
1009
1102
|
}
|
|
1010
|
-
Array.isArray(
|
|
1103
|
+
Array.isArray(i) ? r.push(this.deCompose(i, e, n)) : (o = n ? e.call(n, i) : e(i), r.push(o));
|
|
1011
1104
|
}
|
|
1012
1105
|
return r;
|
|
1013
1106
|
}
|
|
1014
|
-
},
|
|
1107
|
+
}, z = {
|
|
1015
1108
|
random() {
|
|
1016
1109
|
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);
|
|
1017
1110
|
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;
|
|
@@ -1043,11 +1136,11 @@ const G = {
|
|
|
1043
1136
|
* @returns 返回rgba格式的颜色值,格式为rgba(r,g,b,1)
|
|
1044
1137
|
*/
|
|
1045
1138
|
hexToRgba(t) {
|
|
1046
|
-
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, n = t.replace(e, (l,
|
|
1047
|
-
if (!
|
|
1139
|
+
const e = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, n = t.replace(e, (l, u, h, d) => u + u + h + h + d + d), i = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);
|
|
1140
|
+
if (!i)
|
|
1048
1141
|
return t;
|
|
1049
|
-
const
|
|
1050
|
-
return `rgba(${
|
|
1142
|
+
const o = parseInt(i[1], 16), a = parseInt(i[2], 16), c = parseInt(i[3], 16);
|
|
1143
|
+
return `rgba(${o},${a},${c},1)`;
|
|
1051
1144
|
},
|
|
1052
1145
|
/**
|
|
1053
1146
|
* 将 HSL 颜色值转换为 RGBA 颜色值
|
|
@@ -1061,18 +1154,18 @@ const G = {
|
|
|
1061
1154
|
const e = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t);
|
|
1062
1155
|
if (!e)
|
|
1063
1156
|
return null;
|
|
1064
|
-
const n = parseInt(e[1], 10) / 360, r = parseInt(e[2], 10) / 100,
|
|
1065
|
-
function a(
|
|
1066
|
-
return f < 0 && (f += 1), f > 1 && (f -= 1), f < 1 / 6 ?
|
|
1157
|
+
const n = parseInt(e[1], 10) / 360, r = parseInt(e[2], 10) / 100, i = parseInt(e[3], 10) / 100, o = e[4] ? parseFloat(e[4]) : 1;
|
|
1158
|
+
function a(h, d, f) {
|
|
1159
|
+
return f < 0 && (f += 1), f > 1 && (f -= 1), f < 1 / 6 ? h + (d - h) * 6 * f : f < 1 / 2 ? d : f < 2 / 3 ? h + (d - h) * (2 / 3 - f) * 6 : h;
|
|
1067
1160
|
}
|
|
1068
|
-
let
|
|
1161
|
+
let c, l, u;
|
|
1069
1162
|
if (r === 0)
|
|
1070
|
-
|
|
1163
|
+
c = l = u = i;
|
|
1071
1164
|
else {
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1165
|
+
const h = i < 0.5 ? i * (1 + r) : i + r - i * r, d = 2 * i - h;
|
|
1166
|
+
c = a(d, h, n + 1 / 3), l = a(d, h, n), u = a(d, h, n - 1 / 3);
|
|
1074
1167
|
}
|
|
1075
|
-
return `rgba(${Math.round(
|
|
1168
|
+
return `rgba(${Math.round(c * 255)},${Math.round(l * 255)},${Math.round(u * 255)},${o})`;
|
|
1076
1169
|
},
|
|
1077
1170
|
isHex(t) {
|
|
1078
1171
|
return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t);
|
|
@@ -1152,7 +1245,7 @@ Date.prototype.addDate = function(t, e) {
|
|
|
1152
1245
|
}
|
|
1153
1246
|
return n;
|
|
1154
1247
|
};
|
|
1155
|
-
const
|
|
1248
|
+
const X = {
|
|
1156
1249
|
lastMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1),
|
|
1157
1250
|
thisMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
|
|
1158
1251
|
nextMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 1),
|
|
@@ -1196,26 +1289,26 @@ const W = {
|
|
|
1196
1289
|
* @returns 返回格式化后的时间间隔字符串,格式为"天数 天 小时 时 分钟 分 秒 秒"或"少于1秒"
|
|
1197
1290
|
*/
|
|
1198
1291
|
formatDateInterval(t, e) {
|
|
1199
|
-
const n = new Date(t),
|
|
1292
|
+
const n = new Date(t), i = new Date(e).getTime() - n.getTime(), o = Math.floor(i / (24 * 3600 * 1e3)), a = i % (24 * 3600 * 1e3), c = Math.floor(a / (3600 * 1e3)), l = a % (3600 * 1e3), u = Math.floor(l / (60 * 1e3)), h = l % (60 * 1e3), d = Math.round(h / 1e3);
|
|
1200
1293
|
let f = "";
|
|
1201
|
-
return
|
|
1294
|
+
return o > 0 && (f += o + "天"), c > 0 && (f += c + "时"), u > 0 && (f += u + "分"), d > 0 && (f += d + "秒"), o === 0 && c === 0 && u === 0 && d === 0 && (f = "少于1秒"), f;
|
|
1202
1295
|
},
|
|
1203
1296
|
formatterCounter(t) {
|
|
1204
|
-
const e = function(
|
|
1205
|
-
return (
|
|
1206
|
-
}, n = e(Math.floor(t / 3600)), r = t % 3600,
|
|
1207
|
-
return `${n}:${
|
|
1297
|
+
const e = function(c) {
|
|
1298
|
+
return (c > 10 ? "" : "0") + (c || 0);
|
|
1299
|
+
}, n = e(Math.floor(t / 3600)), r = t % 3600, i = e(Math.floor(r / 60)), o = r % 60, a = e(Math.round(o));
|
|
1300
|
+
return `${n}:${i}:${a}`;
|
|
1208
1301
|
},
|
|
1209
1302
|
sleep(t) {
|
|
1210
1303
|
}
|
|
1211
1304
|
};
|
|
1212
|
-
function
|
|
1305
|
+
function q(t) {
|
|
1213
1306
|
return t.trim ? t.trim() : t.replace(/^\s+|\s+$/g, "");
|
|
1214
1307
|
}
|
|
1215
|
-
function
|
|
1216
|
-
return
|
|
1308
|
+
function D(t) {
|
|
1309
|
+
return q(t).split(/\s+/);
|
|
1217
1310
|
}
|
|
1218
|
-
const
|
|
1311
|
+
const V = {
|
|
1219
1312
|
/**
|
|
1220
1313
|
* 获取元素的样式值
|
|
1221
1314
|
*
|
|
@@ -1227,8 +1320,8 @@ const K = {
|
|
|
1227
1320
|
var r;
|
|
1228
1321
|
let n = t.style[e];
|
|
1229
1322
|
if (!n || n === "auto") {
|
|
1230
|
-
const
|
|
1231
|
-
n =
|
|
1323
|
+
const i = (r = document.defaultView) == null ? void 0 : r.getComputedStyle(t, null);
|
|
1324
|
+
n = i ? i[e] : null, n === "auto" && (n = null);
|
|
1232
1325
|
}
|
|
1233
1326
|
return n;
|
|
1234
1327
|
},
|
|
@@ -1314,8 +1407,8 @@ const K = {
|
|
|
1314
1407
|
*/
|
|
1315
1408
|
addClass(t, e) {
|
|
1316
1409
|
if (t.classList !== void 0) {
|
|
1317
|
-
const n =
|
|
1318
|
-
for (let r = 0,
|
|
1410
|
+
const n = D(e);
|
|
1411
|
+
for (let r = 0, i = n.length; r < i; r++)
|
|
1319
1412
|
t.classList.add(n[r]);
|
|
1320
1413
|
} else if (!this.hasClass(t, e)) {
|
|
1321
1414
|
const n = this.getClass(t);
|
|
@@ -1329,7 +1422,7 @@ const K = {
|
|
|
1329
1422
|
* @param name 要移除的类名,多个类名用空格分隔
|
|
1330
1423
|
*/
|
|
1331
1424
|
removeClass(t, e) {
|
|
1332
|
-
t.classList !== void 0 ?
|
|
1425
|
+
t.classList !== void 0 ? D(e).forEach((r) => t.classList.remove(r)) : this.setClass(t, (" " + this.getClass(t) + " ").replace(" " + e + " ", " ").trim());
|
|
1333
1426
|
},
|
|
1334
1427
|
/**
|
|
1335
1428
|
* 设置元素的 CSS 类名
|
|
@@ -1349,7 +1442,7 @@ const K = {
|
|
|
1349
1442
|
parseFromString(t) {
|
|
1350
1443
|
return new DOMParser().parseFromString(t, "text/xml").children[0];
|
|
1351
1444
|
}
|
|
1352
|
-
},
|
|
1445
|
+
}, w = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"], Z = {
|
|
1353
1446
|
/**
|
|
1354
1447
|
* 获取GeoJSON要素的几何类型
|
|
1355
1448
|
*
|
|
@@ -1368,8 +1461,8 @@ const K = {
|
|
|
1368
1461
|
isGeoJson(t) {
|
|
1369
1462
|
const e = this.getGeoJsonType(t);
|
|
1370
1463
|
if (e) {
|
|
1371
|
-
for (let n = 0, r =
|
|
1372
|
-
if (
|
|
1464
|
+
for (let n = 0, r = w.length; n < r; n++)
|
|
1465
|
+
if (w[n] === e)
|
|
1373
1466
|
return !0;
|
|
1374
1467
|
}
|
|
1375
1468
|
return !1;
|
|
@@ -1382,7 +1475,7 @@ const K = {
|
|
|
1382
1475
|
*/
|
|
1383
1476
|
isGeoJsonPolygon(t) {
|
|
1384
1477
|
const e = this.getGeoJsonType(t);
|
|
1385
|
-
return !!(e && (e ===
|
|
1478
|
+
return !!(e && (e === w[4] || e === w[5]));
|
|
1386
1479
|
},
|
|
1387
1480
|
/**
|
|
1388
1481
|
* 判断给定的 GeoJSONFeature 是否为 GeoJSON 线
|
|
@@ -1392,7 +1485,7 @@ const K = {
|
|
|
1392
1485
|
*/
|
|
1393
1486
|
isGeoJsonLine(t) {
|
|
1394
1487
|
const e = this.getGeoJsonType(t);
|
|
1395
|
-
return !!(e && (e ===
|
|
1488
|
+
return !!(e && (e === w[2] || e === w[3]));
|
|
1396
1489
|
},
|
|
1397
1490
|
/**
|
|
1398
1491
|
* 判断是否为 GeoJSON 点类型
|
|
@@ -1402,7 +1495,7 @@ const K = {
|
|
|
1402
1495
|
*/
|
|
1403
1496
|
isGeoJsonPoint(t) {
|
|
1404
1497
|
const e = this.getGeoJsonType(t);
|
|
1405
|
-
return !!(e && (e ===
|
|
1498
|
+
return !!(e && (e === w[0] || e === w[1]));
|
|
1406
1499
|
},
|
|
1407
1500
|
/**
|
|
1408
1501
|
* 判断传入的 GeoJSONFeature 是否为 Multi 类型的 GeoJSON。
|
|
@@ -1434,38 +1527,38 @@ const K = {
|
|
|
1434
1527
|
const n = this.getGeoJsonType(t);
|
|
1435
1528
|
if (!n || !t.geometry)
|
|
1436
1529
|
return null;
|
|
1437
|
-
const
|
|
1438
|
-
if (!
|
|
1530
|
+
const i = t.geometry.coordinates;
|
|
1531
|
+
if (!i)
|
|
1439
1532
|
return null;
|
|
1440
|
-
let
|
|
1533
|
+
let o = 0, a = 0, c = 0;
|
|
1441
1534
|
switch (n) {
|
|
1442
1535
|
case "Point": {
|
|
1443
|
-
|
|
1536
|
+
o = i[0], a = i[1], c++;
|
|
1444
1537
|
break;
|
|
1445
1538
|
}
|
|
1446
1539
|
case "MultiPoint":
|
|
1447
1540
|
case "LineString": {
|
|
1448
|
-
for (let
|
|
1449
|
-
|
|
1541
|
+
for (let h = 0, d = i.length; h < d; h++)
|
|
1542
|
+
o += i[h][0], a += i[h][1], c++;
|
|
1450
1543
|
break;
|
|
1451
1544
|
}
|
|
1452
1545
|
case "MultiLineString":
|
|
1453
1546
|
case "Polygon": {
|
|
1454
|
-
for (let
|
|
1455
|
-
for (let f = 0,
|
|
1456
|
-
|
|
1547
|
+
for (let h = 0, d = i.length; h < d; h++)
|
|
1548
|
+
for (let f = 0, m = i[h].length; f < m; f++)
|
|
1549
|
+
o += i[h][f][0], a += i[h][f][1], c++;
|
|
1457
1550
|
break;
|
|
1458
1551
|
}
|
|
1459
1552
|
case "MultiPolygon": {
|
|
1460
|
-
for (let
|
|
1461
|
-
for (let f = 0,
|
|
1462
|
-
for (let A = 0,
|
|
1463
|
-
|
|
1553
|
+
for (let h = 0, d = i.length; h < d; h++)
|
|
1554
|
+
for (let f = 0, m = i[h].length; f < m; f++)
|
|
1555
|
+
for (let A = 0, P = i[h][f].length; A < P; A++)
|
|
1556
|
+
o += i[h][f][A][0], a += i[h][f][A][1], c++;
|
|
1464
1557
|
break;
|
|
1465
1558
|
}
|
|
1466
1559
|
}
|
|
1467
|
-
const l =
|
|
1468
|
-
return e ? (e.x = l, e.y =
|
|
1560
|
+
const l = o / c, u = a / c;
|
|
1561
|
+
return e ? (e.x = l, e.y = u, e) : { x: l, y: u };
|
|
1469
1562
|
},
|
|
1470
1563
|
/**
|
|
1471
1564
|
* 将一个包含多个点、线或面的 GeoJSON 特征对象拆分成多个独立的 GeoJSON 特征对象数组。
|
|
@@ -1477,10 +1570,10 @@ const K = {
|
|
|
1477
1570
|
const e = this.getGeoJsonType(t);
|
|
1478
1571
|
if (!e || !t.geometry)
|
|
1479
1572
|
return null;
|
|
1480
|
-
const n = t.geometry, r = t.properties || {},
|
|
1481
|
-
if (!
|
|
1573
|
+
const n = t.geometry, r = t.properties || {}, i = n.coordinates;
|
|
1574
|
+
if (!i)
|
|
1482
1575
|
return null;
|
|
1483
|
-
const
|
|
1576
|
+
const o = [];
|
|
1484
1577
|
let a;
|
|
1485
1578
|
switch (e) {
|
|
1486
1579
|
case "MultiPoint": {
|
|
@@ -1497,18 +1590,18 @@ const K = {
|
|
|
1497
1590
|
}
|
|
1498
1591
|
}
|
|
1499
1592
|
if (a)
|
|
1500
|
-
for (let
|
|
1501
|
-
|
|
1593
|
+
for (let c = 0, l = i.length; c < l; c++)
|
|
1594
|
+
o.push({
|
|
1502
1595
|
type: "Feature",
|
|
1503
1596
|
geometry: {
|
|
1504
1597
|
type: a,
|
|
1505
|
-
coordinates:
|
|
1598
|
+
coordinates: i[c]
|
|
1506
1599
|
},
|
|
1507
1600
|
properties: r
|
|
1508
1601
|
});
|
|
1509
1602
|
else
|
|
1510
|
-
|
|
1511
|
-
return
|
|
1603
|
+
o.push(t);
|
|
1604
|
+
return o;
|
|
1512
1605
|
},
|
|
1513
1606
|
/**
|
|
1514
1607
|
* 根据坐标数组生成GeoJSON要素
|
|
@@ -1540,7 +1633,7 @@ const K = {
|
|
|
1540
1633
|
geometry: { type: e, coordinates: t }
|
|
1541
1634
|
};
|
|
1542
1635
|
}
|
|
1543
|
-
},
|
|
1636
|
+
}, tt = {
|
|
1544
1637
|
toRadian: Math.PI / 180,
|
|
1545
1638
|
R: 6371393,
|
|
1546
1639
|
/**
|
|
@@ -1571,9 +1664,9 @@ const K = {
|
|
|
1571
1664
|
* @returns 返回两点之间的距离,单位为米
|
|
1572
1665
|
*/
|
|
1573
1666
|
distanceByPoints(t, e) {
|
|
1574
|
-
const { lng: n, lat: r } = t, { lng:
|
|
1575
|
-
let
|
|
1576
|
-
return
|
|
1667
|
+
const { lng: n, lat: r } = t, { lng: i, lat: o } = e, a = 6371e3, c = Math.cos(r * Math.PI / 180) * Math.cos(o * Math.PI / 180) * Math.cos((n - i) * Math.PI / 180), l = Math.sin(r * Math.PI / 180) * Math.sin(o * Math.PI / 180);
|
|
1668
|
+
let u = c + l;
|
|
1669
|
+
return u > 1 && (u = 1), u < -1 && (u = -1), Math.acos(u) * a;
|
|
1577
1670
|
},
|
|
1578
1671
|
/**
|
|
1579
1672
|
* 格式化经纬度为度分秒格式
|
|
@@ -1584,9 +1677,9 @@ const K = {
|
|
|
1584
1677
|
*/
|
|
1585
1678
|
formatLnglat(t, e) {
|
|
1586
1679
|
let n = "";
|
|
1587
|
-
function r(
|
|
1588
|
-
const
|
|
1589
|
-
return `${
|
|
1680
|
+
function r(i) {
|
|
1681
|
+
const o = Math.floor(i), a = Math.floor((i - o) * 60), c = (i - o) * 3600 - a * 60;
|
|
1682
|
+
return `${o}°${a}′${c.toFixed(2)}″`;
|
|
1590
1683
|
}
|
|
1591
1684
|
return this.isLnglat(t, e) ? n = r(t) + "," + r(e) : isNaN(t) ? isNaN(e) || (n = r(e)) : n = r(t), n;
|
|
1592
1685
|
},
|
|
@@ -1599,12 +1692,12 @@ const K = {
|
|
|
1599
1692
|
*/
|
|
1600
1693
|
transformLnglat(t, e) {
|
|
1601
1694
|
function n(r) {
|
|
1602
|
-
let
|
|
1695
|
+
let o = /[sw]/i.test(r) ? -1 : 1;
|
|
1603
1696
|
const a = r.match(/[\d.]+/g) || [];
|
|
1604
|
-
let
|
|
1697
|
+
let c = 0;
|
|
1605
1698
|
for (let l = 0; l < a.length; l++)
|
|
1606
|
-
|
|
1607
|
-
return
|
|
1699
|
+
c += parseFloat(a[l]) / o, o *= 60;
|
|
1700
|
+
return c;
|
|
1608
1701
|
}
|
|
1609
1702
|
if (t && e)
|
|
1610
1703
|
return {
|
|
@@ -1620,18 +1713,18 @@ const K = {
|
|
|
1620
1713
|
* @returns 返回字符串,表示点相对于多边形的位置:'in'表示在多边形内,'out'表示在多边形外,'on'表示在多边形上
|
|
1621
1714
|
*/
|
|
1622
1715
|
rayCasting(t, e) {
|
|
1623
|
-
for (var n = t.x, r = t.y,
|
|
1624
|
-
var l = e[
|
|
1625
|
-
if (l === n &&
|
|
1716
|
+
for (var n = t.x, r = t.y, i = !1, o = 0, a = e.length, c = a - 1; o < a; c = o, o++) {
|
|
1717
|
+
var l = e[o].x, u = e[o].y, h = e[c].x, d = e[c].y;
|
|
1718
|
+
if (l === n && u === r || h === n && d === r)
|
|
1626
1719
|
return "on";
|
|
1627
|
-
if (
|
|
1628
|
-
var f = l + (r -
|
|
1720
|
+
if (u < r && d >= r || u >= r && d < r) {
|
|
1721
|
+
var f = l + (r - u) * (h - l) / (d - u);
|
|
1629
1722
|
if (f === n)
|
|
1630
1723
|
return "on";
|
|
1631
|
-
f > n && (
|
|
1724
|
+
f > n && (i = !i);
|
|
1632
1725
|
}
|
|
1633
1726
|
}
|
|
1634
|
-
return
|
|
1727
|
+
return i ? "in" : "out";
|
|
1635
1728
|
},
|
|
1636
1729
|
/**
|
|
1637
1730
|
* 旋转点
|
|
@@ -1642,8 +1735,8 @@ const K = {
|
|
|
1642
1735
|
* @returns 旋转后点坐标
|
|
1643
1736
|
*/
|
|
1644
1737
|
rotatePoint(t, e, n) {
|
|
1645
|
-
const r = (t.x - e.x) * Math.cos(Math.PI / 180 * -n) - (t.y - e.y) * Math.sin(Math.PI / 180 * -n) + e.x,
|
|
1646
|
-
return { x: r, y:
|
|
1738
|
+
const r = (t.x - e.x) * Math.cos(Math.PI / 180 * -n) - (t.y - e.y) * Math.sin(Math.PI / 180 * -n) + e.x, i = (t.x - e.x) * Math.sin(Math.PI / 180 * -n) + (t.y - e.y) * Math.cos(Math.PI / 180 * -n) + e.y;
|
|
1739
|
+
return { x: r, y: i };
|
|
1647
1740
|
},
|
|
1648
1741
|
/**
|
|
1649
1742
|
* 根据两个平面坐标点计算方位角和距离
|
|
@@ -1653,8 +1746,8 @@ const K = {
|
|
|
1653
1746
|
* @returns 返回一个对象,包含angle和distance属性,分别表示两点之间的角度(以度为单位,取值范围为0~359)和距离
|
|
1654
1747
|
*/
|
|
1655
1748
|
calcBearAndDis(t, e) {
|
|
1656
|
-
const { x: n, y: r } = t, { x:
|
|
1657
|
-
return { angle: (Math.atan2(
|
|
1749
|
+
const { x: n, y: r } = t, { x: i, y: o } = e, a = i - n, c = o - r, l = Math.sqrt(a * a + c * c);
|
|
1750
|
+
return { angle: (Math.atan2(c, a) * (180 / Math.PI) + 360 + 90) % 360, distance: l };
|
|
1658
1751
|
},
|
|
1659
1752
|
/**
|
|
1660
1753
|
* 根据两个经纬度点计算方位角和距离
|
|
@@ -1664,10 +1757,10 @@ const K = {
|
|
|
1664
1757
|
* @returns 包含方位角和距离的对象
|
|
1665
1758
|
*/
|
|
1666
1759
|
calcBearAndDisByPoints(t, e) {
|
|
1667
|
-
var n = t.lat * 1, r = t.lng * 1,
|
|
1760
|
+
var n = t.lat * 1, r = t.lng * 1, i = e.lat * 1, o = e.lng * 1, a = Math.sin((o - r) * this.toRadian) * Math.cos(i * this.toRadian), c = Math.cos(n * this.toRadian) * Math.sin(i * this.toRadian) - Math.sin(n * this.toRadian) * Math.cos(i * this.toRadian) * Math.cos((o - r) * this.toRadian), l = Math.atan2(a, c) * (180 / Math.PI), u = (i - n) * this.toRadian, h = (o - r) * this.toRadian, d = Math.sin(u / 2) * Math.sin(u / 2) + Math.cos(n * this.toRadian) * Math.cos(i * this.toRadian) * Math.sin(h / 2) * Math.sin(h / 2), f = 2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)), m = this.R * f;
|
|
1668
1761
|
return {
|
|
1669
1762
|
angle: l,
|
|
1670
|
-
distance:
|
|
1763
|
+
distance: m
|
|
1671
1764
|
};
|
|
1672
1765
|
},
|
|
1673
1766
|
/**
|
|
@@ -1679,14 +1772,14 @@ const K = {
|
|
|
1679
1772
|
* @returns 点P到线段P1P2的最短距离
|
|
1680
1773
|
*/
|
|
1681
1774
|
distanceToSegment(t, e, n) {
|
|
1682
|
-
const r = t.x,
|
|
1683
|
-
if (
|
|
1684
|
-
return Math.sqrt((r -
|
|
1685
|
-
const
|
|
1686
|
-
if (
|
|
1687
|
-
return Math.sqrt((r -
|
|
1688
|
-
const
|
|
1689
|
-
return Math.sqrt((r - f) * (r - f) + (
|
|
1775
|
+
const r = t.x, i = t.y, o = e.x, a = e.y, c = n.x, l = n.y, u = (c - o) * (r - o) + (l - a) * (i - a);
|
|
1776
|
+
if (u <= 0)
|
|
1777
|
+
return Math.sqrt((r - o) * (r - o) + (i - a) * (i - a));
|
|
1778
|
+
const h = (c - o) * (c - o) + (l - a) * (l - a);
|
|
1779
|
+
if (u >= h)
|
|
1780
|
+
return Math.sqrt((r - c) * (r - c) + (i - l) * (i - l));
|
|
1781
|
+
const d = u / h, f = o + (c - o) * d, m = a + (l - a) * d;
|
|
1782
|
+
return Math.sqrt((r - f) * (r - f) + (i - m) * (i - m));
|
|
1690
1783
|
},
|
|
1691
1784
|
/**
|
|
1692
1785
|
* 根据给定的经纬度、角度和距离计算新的经纬度点
|
|
@@ -1697,12 +1790,12 @@ const K = {
|
|
|
1697
1790
|
* @returns 返回计算后的新经纬度点,类型为{lat: number, lng: number}
|
|
1698
1791
|
*/
|
|
1699
1792
|
calcPointByBearAndDis(t, e, n) {
|
|
1700
|
-
const r =
|
|
1701
|
-
e =
|
|
1702
|
-
const a = Math.asin(Math.sin(r) * Math.cos(
|
|
1793
|
+
const r = R.toRadians(t.lat * 1), i = R.toRadians(t.lng * 1), o = n / this.R;
|
|
1794
|
+
e = R.toRadians(e);
|
|
1795
|
+
const a = Math.asin(Math.sin(r) * Math.cos(o) + Math.cos(r) * Math.sin(o) * Math.cos(e)), c = i + Math.atan2(Math.sin(e) * Math.sin(o) * Math.cos(r), Math.cos(o) - Math.sin(r) * Math.sin(a));
|
|
1703
1796
|
return {
|
|
1704
|
-
lat:
|
|
1705
|
-
lng:
|
|
1797
|
+
lat: R.toDegrees(a),
|
|
1798
|
+
lng: R.toDegrees(c)
|
|
1706
1799
|
};
|
|
1707
1800
|
},
|
|
1708
1801
|
/**
|
|
@@ -1715,8 +1808,8 @@ const K = {
|
|
|
1715
1808
|
mercatorTolonlat(t, e) {
|
|
1716
1809
|
const n = t / 2003750834e-2 * 180;
|
|
1717
1810
|
var r = e / 2003750834e-2 * 180;
|
|
1718
|
-
const
|
|
1719
|
-
return { lng: n, lat:
|
|
1811
|
+
const i = 180 / Math.PI * (2 * Math.atan(Math.exp(r * Math.PI / 180)) - Math.PI / 2);
|
|
1812
|
+
return { lng: n, lat: i };
|
|
1720
1813
|
},
|
|
1721
1814
|
/**
|
|
1722
1815
|
* 将经纬度坐标转换为墨卡托坐标
|
|
@@ -1728,9 +1821,9 @@ const K = {
|
|
|
1728
1821
|
lonlatToMercator(t, e) {
|
|
1729
1822
|
var n = 6378137;
|
|
1730
1823
|
const r = t * Math.PI / 180 * n;
|
|
1731
|
-
var
|
|
1732
|
-
const
|
|
1733
|
-
return { x: r, y:
|
|
1824
|
+
var i = e * Math.PI / 180;
|
|
1825
|
+
const o = n / 2 * Math.log((1 + Math.sin(i)) / (1 - Math.sin(i)));
|
|
1826
|
+
return { x: r, y: o };
|
|
1734
1827
|
},
|
|
1735
1828
|
/**
|
|
1736
1829
|
* 根据百分比获取坐标
|
|
@@ -1740,11 +1833,11 @@ const K = {
|
|
|
1740
1833
|
* @param percent 百分比,取值范围0-1
|
|
1741
1834
|
* @returns 返回插值后的坐标
|
|
1742
1835
|
*/
|
|
1743
|
-
interpolate({ x: t, y: e, z: n = 0 }, { x: r, y:
|
|
1744
|
-
const
|
|
1745
|
-
return { x: t +
|
|
1836
|
+
interpolate({ x: t, y: e, z: n = 0 }, { x: r, y: i, z: o = 0 }, a) {
|
|
1837
|
+
const c = r - t, l = i - e, u = o - n;
|
|
1838
|
+
return { x: t + c * a, y: e + l * a, z: n + u * a };
|
|
1746
1839
|
}
|
|
1747
|
-
},
|
|
1840
|
+
}, et = {
|
|
1748
1841
|
/**
|
|
1749
1842
|
* 将Base64编码的字符串转换为Blob对象
|
|
1750
1843
|
*
|
|
@@ -1755,8 +1848,8 @@ const K = {
|
|
|
1755
1848
|
const e = t.split(",")[0].split(":")[1].split(";")[0], n = atob(t.split(",")[1]), r = new Array(n.length);
|
|
1756
1849
|
for (let a = 0; a < n.length; a++)
|
|
1757
1850
|
r[a] = n.charCodeAt(a);
|
|
1758
|
-
const
|
|
1759
|
-
return new Blob([
|
|
1851
|
+
const i = new Uint8Array(r);
|
|
1852
|
+
return new Blob([i], { type: e });
|
|
1760
1853
|
},
|
|
1761
1854
|
/**
|
|
1762
1855
|
* 将图片的URL转换为Base64编码
|
|
@@ -1774,10 +1867,10 @@ const K = {
|
|
|
1774
1867
|
* @returns 返回文件对象
|
|
1775
1868
|
*/
|
|
1776
1869
|
convertBase64ToFile(t, e) {
|
|
1777
|
-
const n = t.split(","), r = n[0].match(/:(.*?);/),
|
|
1778
|
-
for (let l = 0; l <
|
|
1779
|
-
a[l] =
|
|
1780
|
-
return new File([a], e, { type:
|
|
1870
|
+
const n = t.split(","), r = n[0].match(/:(.*?);/), i = r ? r[1] : "image/png", o = atob(n[1]), a = new Uint8Array(o.length);
|
|
1871
|
+
for (let l = 0; l < o.length; l++)
|
|
1872
|
+
a[l] = o.charCodeAt(l);
|
|
1873
|
+
return new File([a], e, { type: i });
|
|
1781
1874
|
},
|
|
1782
1875
|
/**
|
|
1783
1876
|
* 从文件下载数据
|
|
@@ -1790,8 +1883,8 @@ const K = {
|
|
|
1790
1883
|
if (t instanceof Blob)
|
|
1791
1884
|
t = URL.createObjectURL(t);
|
|
1792
1885
|
else {
|
|
1793
|
-
const r = JSON.stringify(t),
|
|
1794
|
-
t = window.URL.createObjectURL(
|
|
1886
|
+
const r = JSON.stringify(t), i = new Blob([r], { type: "text/json" });
|
|
1887
|
+
t = window.URL.createObjectURL(i);
|
|
1795
1888
|
}
|
|
1796
1889
|
else if (typeof t == "string" && t.indexOf("http") === -1) {
|
|
1797
1890
|
const r = new Blob([t], { type: "text/json" });
|
|
@@ -1800,7 +1893,7 @@ const K = {
|
|
|
1800
1893
|
var n = document.createElement("a");
|
|
1801
1894
|
n.href = t, n.download = e || "", n.click(), window.URL.revokeObjectURL(n.href);
|
|
1802
1895
|
}
|
|
1803
|
-
},
|
|
1896
|
+
}, nt = {
|
|
1804
1897
|
/**
|
|
1805
1898
|
* 防抖函数,在指定的等待时间内,如果连续触发事件,则只在最后一次触发后执行函数。适用于像搜索输入框这种需要用户停止输入后才调用的场景
|
|
1806
1899
|
*
|
|
@@ -1810,15 +1903,15 @@ const K = {
|
|
|
1810
1903
|
* @returns 返回防抖后的函数。
|
|
1811
1904
|
*/
|
|
1812
1905
|
debounce(t, e, n = !0) {
|
|
1813
|
-
let r = null,
|
|
1814
|
-
const
|
|
1815
|
-
const l = Date.now() -
|
|
1816
|
-
l < e && l > 0 ? r = setTimeout(
|
|
1906
|
+
let r = null, i, o, a;
|
|
1907
|
+
const c = () => {
|
|
1908
|
+
const l = Date.now() - o;
|
|
1909
|
+
l < e && l > 0 ? r = setTimeout(c, e - l) : (r = null, n || (a = t.apply(this, i)));
|
|
1817
1910
|
};
|
|
1818
1911
|
return (...l) => {
|
|
1819
|
-
|
|
1820
|
-
const
|
|
1821
|
-
return r || (r = setTimeout(
|
|
1912
|
+
o = Date.now();
|
|
1913
|
+
const u = n && !r;
|
|
1914
|
+
return r || (r = setTimeout(c, e)), u && (a = t.apply(this, l), r || (l = null)), a;
|
|
1822
1915
|
};
|
|
1823
1916
|
},
|
|
1824
1917
|
/**
|
|
@@ -1830,13 +1923,13 @@ const K = {
|
|
|
1830
1923
|
* @returns 返回一个新的函数,该函数在节流控制下执行传入的函数
|
|
1831
1924
|
*/
|
|
1832
1925
|
throttle(t, e, n = 1) {
|
|
1833
|
-
let r = 0,
|
|
1834
|
-
return (...
|
|
1926
|
+
let r = 0, i = null;
|
|
1927
|
+
return (...o) => {
|
|
1835
1928
|
if (n === 1) {
|
|
1836
1929
|
const a = Date.now();
|
|
1837
|
-
a - r >= e && (t.apply(this,
|
|
1838
|
-
} else n === 2 && (
|
|
1839
|
-
|
|
1930
|
+
a - r >= e && (t.apply(this, o), r = a);
|
|
1931
|
+
} else n === 2 && (i || (i = setTimeout(() => {
|
|
1932
|
+
i = null, t.apply(this, o);
|
|
1840
1933
|
}, e)));
|
|
1841
1934
|
};
|
|
1842
1935
|
},
|
|
@@ -1853,8 +1946,8 @@ const K = {
|
|
|
1853
1946
|
if (e.has(r))
|
|
1854
1947
|
return e.get(r);
|
|
1855
1948
|
{
|
|
1856
|
-
const
|
|
1857
|
-
return e.set(r,
|
|
1949
|
+
const i = t.apply(this, n);
|
|
1950
|
+
return e.set(r, i), i;
|
|
1858
1951
|
}
|
|
1859
1952
|
};
|
|
1860
1953
|
},
|
|
@@ -1871,7 +1964,7 @@ const K = {
|
|
|
1871
1964
|
r++, r < Math.floor(n / e) && (t.call(this), setTimeout(this.recurve.bind(this, t, e, n), e));
|
|
1872
1965
|
}, e);
|
|
1873
1966
|
}
|
|
1874
|
-
},
|
|
1967
|
+
}, st = {
|
|
1875
1968
|
/**
|
|
1876
1969
|
* 校验字符串是否符合指定类型
|
|
1877
1970
|
*
|
|
@@ -1979,7 +2072,7 @@ const K = {
|
|
|
1979
2072
|
*/
|
|
1980
2073
|
tag(t, ...e) {
|
|
1981
2074
|
return e = e.map((n) => {
|
|
1982
|
-
switch (
|
|
2075
|
+
switch (M.getDataType(n)) {
|
|
1983
2076
|
case "Object":
|
|
1984
2077
|
return n || "{}";
|
|
1985
2078
|
case "Array":
|
|
@@ -1987,7 +2080,7 @@ const K = {
|
|
|
1987
2080
|
default:
|
|
1988
2081
|
return n || "";
|
|
1989
2082
|
}
|
|
1990
|
-
}), t.reduce((n, r,
|
|
2083
|
+
}), t.reduce((n, r, i) => `${n}${e[i - 1]}${r}`);
|
|
1991
2084
|
},
|
|
1992
2085
|
/**
|
|
1993
2086
|
* 计算字符串的字节长度
|
|
@@ -2010,8 +2103,8 @@ const K = {
|
|
|
2010
2103
|
var r = /[^\x00-\xff]/g;
|
|
2011
2104
|
if (t.replace(r, "mm").length <= n)
|
|
2012
2105
|
return t;
|
|
2013
|
-
for (var
|
|
2014
|
-
let a = t.substring(e,
|
|
2106
|
+
for (var i = Math.floor(n / 2), o = i; o < t.length; o++) {
|
|
2107
|
+
let a = t.substring(e, o);
|
|
2015
2108
|
if (a.replace(r, "mm").length >= n)
|
|
2016
2109
|
return a;
|
|
2017
2110
|
}
|
|
@@ -2024,9 +2117,9 @@ const K = {
|
|
|
2024
2117
|
* @returns 转换后的字符串,如果值为空,则返回空字符串
|
|
2025
2118
|
*/
|
|
2026
2119
|
asString(t) {
|
|
2027
|
-
if (
|
|
2120
|
+
if (M.isEmpty(t))
|
|
2028
2121
|
return "";
|
|
2029
|
-
switch (
|
|
2122
|
+
switch (M.getDataType(t)) {
|
|
2030
2123
|
case "Object":
|
|
2031
2124
|
case "Array":
|
|
2032
2125
|
return JSON.stringify(t);
|
|
@@ -2041,62 +2134,62 @@ const K = {
|
|
|
2041
2134
|
t = t.replace(e, n);
|
|
2042
2135
|
return t;
|
|
2043
2136
|
}
|
|
2044
|
-
},
|
|
2137
|
+
}, p = class p {
|
|
2045
2138
|
static set(e, n = null, r = null) {
|
|
2046
|
-
var
|
|
2139
|
+
var i = this._getPrefixedKey(e, r);
|
|
2047
2140
|
try {
|
|
2048
|
-
localStorage.setItem(
|
|
2141
|
+
localStorage.setItem(i, JSON.stringify({ data: n }));
|
|
2049
2142
|
} catch {
|
|
2050
2143
|
console && console.warn("StoreUtil didn't successfully save the '{" + e + ": " + n + "}' pair, because the localStorage is full.");
|
|
2051
2144
|
}
|
|
2052
2145
|
}
|
|
2053
2146
|
static get(e, n, r) {
|
|
2054
|
-
var
|
|
2147
|
+
var i = this._getPrefixedKey(e, r), o;
|
|
2055
2148
|
try {
|
|
2056
|
-
|
|
2149
|
+
o = JSON.parse(localStorage.getItem(i) || "");
|
|
2057
2150
|
} catch {
|
|
2058
|
-
localStorage[
|
|
2151
|
+
localStorage[i] ? o = { data: localStorage.getItem(i) } : o = null;
|
|
2059
2152
|
}
|
|
2060
|
-
if (
|
|
2061
|
-
if (typeof
|
|
2062
|
-
return
|
|
2153
|
+
if (o) {
|
|
2154
|
+
if (typeof o == "object" && typeof o.data < "u")
|
|
2155
|
+
return o.data;
|
|
2063
2156
|
} else return n;
|
|
2064
2157
|
}
|
|
2065
2158
|
static keys() {
|
|
2066
2159
|
const e = [];
|
|
2067
2160
|
var n = Object.keys(localStorage);
|
|
2068
|
-
return
|
|
2069
|
-
r.indexOf(
|
|
2161
|
+
return p.prefix.length === 0 ? n : (n.forEach(function(r) {
|
|
2162
|
+
r.indexOf(p.prefix) !== -1 && e.push(r.replace(p.prefix, ""));
|
|
2070
2163
|
}), e);
|
|
2071
2164
|
}
|
|
2072
2165
|
static getAll(e) {
|
|
2073
|
-
var n =
|
|
2166
|
+
var n = p.keys();
|
|
2074
2167
|
if (e) {
|
|
2075
2168
|
const r = [];
|
|
2076
|
-
return n.forEach((
|
|
2077
|
-
if (e.includes(
|
|
2078
|
-
const
|
|
2079
|
-
i
|
|
2169
|
+
return n.forEach((i) => {
|
|
2170
|
+
if (e.includes(i)) {
|
|
2171
|
+
const o = {};
|
|
2172
|
+
o[i] = p.get(i, null, null), r.push(o);
|
|
2080
2173
|
}
|
|
2081
2174
|
}), r;
|
|
2082
2175
|
}
|
|
2083
|
-
return n.map((r) =>
|
|
2176
|
+
return n.map((r) => p.get(r, null, null));
|
|
2084
2177
|
}
|
|
2085
2178
|
static remove(e, n) {
|
|
2086
2179
|
var r = this._getPrefixedKey(e, n);
|
|
2087
2180
|
localStorage.removeItem(r);
|
|
2088
2181
|
}
|
|
2089
2182
|
static clear(e) {
|
|
2090
|
-
|
|
2183
|
+
p.prefix.length ? this.keys().forEach((n) => {
|
|
2091
2184
|
localStorage.removeItem(this._getPrefixedKey(n, e));
|
|
2092
2185
|
}) : localStorage.clear();
|
|
2093
2186
|
}
|
|
2094
2187
|
};
|
|
2095
|
-
|
|
2096
|
-
return n = n || {}, n.noPrefix ? e :
|
|
2188
|
+
g(p, "prefix", ""), g(p, "_getPrefixedKey", function(e, n) {
|
|
2189
|
+
return n = n || {}, n.noPrefix ? e : p.prefix + e;
|
|
2097
2190
|
});
|
|
2098
|
-
let
|
|
2099
|
-
const
|
|
2191
|
+
let I = p;
|
|
2192
|
+
const rt = {
|
|
2100
2193
|
/**
|
|
2101
2194
|
* 将json对象转换为查询字符串
|
|
2102
2195
|
*
|
|
@@ -2107,11 +2200,11 @@ const Z = {
|
|
|
2107
2200
|
var e = [];
|
|
2108
2201
|
for (var n in t)
|
|
2109
2202
|
if (t.hasOwnProperty(n)) {
|
|
2110
|
-
var r = n,
|
|
2111
|
-
e.push(encodeURIComponent(r) + "=" + encodeURIComponent(
|
|
2203
|
+
var r = n, i = t[n];
|
|
2204
|
+
e.push(encodeURIComponent(r) + "=" + encodeURIComponent(i));
|
|
2112
2205
|
}
|
|
2113
|
-
var
|
|
2114
|
-
return
|
|
2206
|
+
var o = e.join("&");
|
|
2207
|
+
return o;
|
|
2115
2208
|
},
|
|
2116
2209
|
/**
|
|
2117
2210
|
* 从 URL 中解析出查询参数和哈希参数,并以对象的形式返回
|
|
@@ -2121,16 +2214,16 @@ const Z = {
|
|
|
2121
2214
|
* @returns 返回一个包含解析后参数的对象,其中键为参数名,值为参数值
|
|
2122
2215
|
*/
|
|
2123
2216
|
query2Json(t = window.location.href, e = !0) {
|
|
2124
|
-
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: r, hash:
|
|
2217
|
+
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: r, hash: i } = new URL(t), o = [r, i];
|
|
2125
2218
|
let a = {};
|
|
2126
|
-
for (let
|
|
2127
|
-
const l =
|
|
2219
|
+
for (let c = 0; c < o.length; c++) {
|
|
2220
|
+
const l = o[c];
|
|
2128
2221
|
if (l) {
|
|
2129
|
-
const
|
|
2130
|
-
if (
|
|
2131
|
-
for (let
|
|
2222
|
+
const h = l.replace(/#|\//g, "").split("?");
|
|
2223
|
+
if (h.length > 1)
|
|
2224
|
+
for (let d = 1; d < h.length; d++) {
|
|
2132
2225
|
let f;
|
|
2133
|
-
for (; f = n.exec(
|
|
2226
|
+
for (; f = n.exec(h[d]); )
|
|
2134
2227
|
a[f[1]] = e ? decodeURIComponent(f[2]) : f[2];
|
|
2135
2228
|
}
|
|
2136
2229
|
}
|
|
@@ -2139,34 +2232,35 @@ const Z = {
|
|
|
2139
2232
|
}
|
|
2140
2233
|
};
|
|
2141
2234
|
export {
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2235
|
+
E as AjaxUtil,
|
|
2236
|
+
S as ArrayUtil,
|
|
2237
|
+
H as AudioPlayer,
|
|
2238
|
+
Q as BrowserUtil,
|
|
2239
|
+
j as CanvasDrawer,
|
|
2240
|
+
z as ColorUtil,
|
|
2241
|
+
K as Cookie,
|
|
2242
|
+
Y as CoordsUtil,
|
|
2243
|
+
X as DateUtil,
|
|
2244
|
+
V as DomUtil,
|
|
2245
|
+
b as ErrorType,
|
|
2246
|
+
_ as EventDispatcher,
|
|
2247
|
+
y as EventType,
|
|
2248
|
+
et as FileUtil,
|
|
2249
|
+
Z as GeoJsonUtil,
|
|
2250
|
+
tt as GeoUtil,
|
|
2251
|
+
k as GraphicType,
|
|
2252
|
+
C as HashMap,
|
|
2253
|
+
$ as ImageUtil,
|
|
2254
|
+
N as LayerType,
|
|
2255
|
+
R as MathUtil,
|
|
2256
|
+
F as MeasureMode,
|
|
2257
|
+
O as MqttClient,
|
|
2258
|
+
B as ObjectState,
|
|
2165
2259
|
T as ObjectUtil,
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2260
|
+
nt as OptimizeUtil,
|
|
2261
|
+
I as StoreUtil,
|
|
2262
|
+
st as StringUtil,
|
|
2263
|
+
rt as UrlUtil,
|
|
2264
|
+
M as Util,
|
|
2265
|
+
W as WebSocketClient
|
|
2172
2266
|
};
|