gis-common 4.1.1 → 4.1.3
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 +31 -0
- package/dist/core/index.d.ts +0 -1
- package/dist/gis-common.es.js +314 -344
- package/dist/gis-common.umd.js +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/utils/BrowserUtil.d.ts +0 -8
- package/dist/utils/CoordsUtil.d.ts +17 -12
- package/dist/utils/GeoUtil.d.ts +1 -16
- package/dist/utils/UrlUtil.d.ts +8 -3
- package/package.json +1 -8
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Coordinate } from '../types';
|
|
2
|
+
export default class CanvasDrawer {
|
|
3
|
+
private context;
|
|
4
|
+
constructor(el: HTMLElement | null);
|
|
5
|
+
/**
|
|
6
|
+
* 绘制线条
|
|
7
|
+
*
|
|
8
|
+
* @param start 起始坐标点
|
|
9
|
+
* @param end 终止坐标点
|
|
10
|
+
* @param options 绘制选项,包括线条宽度和颜色
|
|
11
|
+
* @throws 当画布上下文不存在时抛出错误
|
|
12
|
+
*/
|
|
13
|
+
drawLine({ x: startX, y: startY }: Coordinate, { x: endX, y: endY }: Coordinate, options?: {
|
|
14
|
+
width?: number;
|
|
15
|
+
color?: string;
|
|
16
|
+
}): void;
|
|
17
|
+
/**
|
|
18
|
+
* 绘制圆弧
|
|
19
|
+
*
|
|
20
|
+
* @param x 圆心x坐标
|
|
21
|
+
* @param y 圆心y坐标
|
|
22
|
+
* @param radius 半径
|
|
23
|
+
* @param startAngle 起始角度(度)
|
|
24
|
+
* @param endAngle 结束角度(度)
|
|
25
|
+
* @param anticlockwise 是否逆时针绘制
|
|
26
|
+
* @param isFill 是否填充
|
|
27
|
+
* @param bgColor 背景颜色
|
|
28
|
+
* @throws 当Canvas context为null或undefined时抛出错误
|
|
29
|
+
*/
|
|
30
|
+
drawArc({ x, y }: Coordinate, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean, isFill: boolean, bgColor: string): void;
|
|
31
|
+
}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { default as AudioPlayer } from './AudioPlayer';
|
|
2
2
|
export { default as CanvasDrawer } from './CanvasDrawer';
|
|
3
|
-
export { default as DevicePixelRatio } from './DevicePixelRatio';
|
|
4
3
|
export { default as EventDispatcher } from './EventDispatcher';
|
|
5
4
|
export { default as HashMap } from './HashMap';
|
|
6
5
|
export { default as WebSocketClient } from './WebSocketClient';
|
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 x = Object.defineProperty;
|
|
2
|
+
var D = (t, e, n) => e in t ? x(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var f = (t, e, n) => D(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
const y = {
|
|
5
5
|
MAP_RENDER: "mapRender",
|
|
6
6
|
MAP_READY: "mapReady",
|
|
7
7
|
MOUSE_CLICK: "click",
|
|
@@ -23,7 +23,7 @@ const M = {
|
|
|
23
23
|
WEB_SOCKET_ERROR: "webSocketError",
|
|
24
24
|
WEB_SOCKET_MESSAGE: "webSocketMessage",
|
|
25
25
|
WEB_SOCKET_CLOSE: "webSocketClose"
|
|
26
|
-
},
|
|
26
|
+
}, S = {
|
|
27
27
|
LOGIN_EXPIRED: "登录信息过期,请重新登录",
|
|
28
28
|
CROSS_ERROR: "跨域访问",
|
|
29
29
|
UNEXIST_RESOURCE: "资源不存在",
|
|
@@ -44,7 +44,7 @@ const M = {
|
|
|
44
44
|
PARAMETER_ERROR_OBJECT: "格式类型验证失败:必须是对象",
|
|
45
45
|
PARAMETER_ERROR_LACK: "参数缺失",
|
|
46
46
|
STRING_CHECK_LOSS: "字符缺少关键字"
|
|
47
|
-
},
|
|
47
|
+
}, b = {
|
|
48
48
|
SUPER_MAP_IMAGES: "SuperMapImages",
|
|
49
49
|
// 超图影像服务 栅格数据
|
|
50
50
|
SUPER_MAP_DATA: "SuperMapData",
|
|
@@ -68,11 +68,11 @@ const M = {
|
|
|
68
68
|
LABEL: "label",
|
|
69
69
|
MODEL: "model",
|
|
70
70
|
WALL: "wall"
|
|
71
|
-
},
|
|
71
|
+
}, T = {
|
|
72
72
|
DISTANCE: "distance",
|
|
73
73
|
AREA: "area",
|
|
74
74
|
HEIGHT: "height"
|
|
75
|
-
},
|
|
75
|
+
}, _ = {
|
|
76
76
|
ADD: "add",
|
|
77
77
|
REMOVE: "remove",
|
|
78
78
|
INIT: "init"
|
|
@@ -102,7 +102,238 @@ class v {
|
|
|
102
102
|
this.audio.muted = e;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
const
|
|
105
|
+
const g = {
|
|
106
|
+
DEG2RAD: Math.PI / 180,
|
|
107
|
+
RAD2DEG: 180 / Math.PI,
|
|
108
|
+
randInt(t, e) {
|
|
109
|
+
return t + Math.floor(Math.random() * (e - t + 1));
|
|
110
|
+
},
|
|
111
|
+
randFloat(t, e) {
|
|
112
|
+
return t + Math.random() * (e - t);
|
|
113
|
+
},
|
|
114
|
+
/**
|
|
115
|
+
* 角度转弧度
|
|
116
|
+
*
|
|
117
|
+
* @param {*} degrees
|
|
118
|
+
* @returns {*}
|
|
119
|
+
*/
|
|
120
|
+
degreesToRadians(t) {
|
|
121
|
+
return t * this.DEG2RAD;
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* 角度转弧度
|
|
125
|
+
*
|
|
126
|
+
* @param {*} degrees
|
|
127
|
+
* @returns {*}
|
|
128
|
+
*/
|
|
129
|
+
toRadians(t) {
|
|
130
|
+
return t * this.DEG2RAD;
|
|
131
|
+
},
|
|
132
|
+
/**
|
|
133
|
+
* 弧度转角度
|
|
134
|
+
*
|
|
135
|
+
* @param {*} radians
|
|
136
|
+
* @returns {*}
|
|
137
|
+
*/
|
|
138
|
+
radiansToDegrees(t) {
|
|
139
|
+
return t * this.RAD2DEG;
|
|
140
|
+
},
|
|
141
|
+
/**
|
|
142
|
+
* 弧度转角度
|
|
143
|
+
*
|
|
144
|
+
* @param {*} radians
|
|
145
|
+
* @returns {*}
|
|
146
|
+
*/
|
|
147
|
+
toDegrees(t) {
|
|
148
|
+
return t * this.RAD2DEG;
|
|
149
|
+
},
|
|
150
|
+
formatFloat(t, e = 2) {
|
|
151
|
+
return Math.round(t * Math.pow(10, e)) / Math.pow(10, e);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
class P {
|
|
155
|
+
constructor(e) {
|
|
156
|
+
f(this, "context", null);
|
|
157
|
+
if (typeof e == "string" && (e = document.querySelector("#" + e), !e))
|
|
158
|
+
throw new Error("Element not found");
|
|
159
|
+
if (e instanceof HTMLElement) {
|
|
160
|
+
const n = e;
|
|
161
|
+
if (n.getContext)
|
|
162
|
+
this.context = n.getContext("2d");
|
|
163
|
+
else
|
|
164
|
+
throw new Error("getContext is not available on this element");
|
|
165
|
+
} else
|
|
166
|
+
throw new Error("Element is not an HTMLElement");
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* 绘制线条
|
|
170
|
+
*
|
|
171
|
+
* @param start 起始坐标点
|
|
172
|
+
* @param end 终止坐标点
|
|
173
|
+
* @param options 绘制选项,包括线条宽度和颜色
|
|
174
|
+
* @throws 当画布上下文不存在时抛出错误
|
|
175
|
+
*/
|
|
176
|
+
drawLine({ x: e, y: n }, { x: s, y: r }, i = {}) {
|
|
177
|
+
if (!this.context)
|
|
178
|
+
throw new Error("Canvas context is null or undefined");
|
|
179
|
+
this.context.beginPath();
|
|
180
|
+
const a = i.width ?? 1, o = i.color ?? "#000";
|
|
181
|
+
this.context.lineWidth = a, this.context.strokeStyle = o, this.context.moveTo(e, n), this.context.lineTo(s, r), this.context.stroke();
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* 绘制圆弧
|
|
185
|
+
*
|
|
186
|
+
* @param x 圆心x坐标
|
|
187
|
+
* @param y 圆心y坐标
|
|
188
|
+
* @param radius 半径
|
|
189
|
+
* @param startAngle 起始角度(度)
|
|
190
|
+
* @param endAngle 结束角度(度)
|
|
191
|
+
* @param anticlockwise 是否逆时针绘制
|
|
192
|
+
* @param isFill 是否填充
|
|
193
|
+
* @param bgColor 背景颜色
|
|
194
|
+
* @throws 当Canvas context为null或undefined时抛出错误
|
|
195
|
+
*/
|
|
196
|
+
drawArc({ x: e, y: n }, s, r, i, a, o, c) {
|
|
197
|
+
if (!this.context)
|
|
198
|
+
throw new Error("Canvas context is null or undefined");
|
|
199
|
+
o ? (this.context.fillStyle = c, this.context.beginPath(), this.context.arc(e, n, s, g.degreesToRadians(r), g.degreesToRadians(i), a), this.context.fill()) : (this.context.strokeStyle = c, this.context.beginPath(), this.context.arc(e, n, s, g.degreesToRadians(r), g.degreesToRadians(i), a), this.context.stroke());
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
class A {
|
|
203
|
+
constructor() {
|
|
204
|
+
f(this, "_listeners");
|
|
205
|
+
f(this, "_mutex", {});
|
|
206
|
+
f(this, "_context");
|
|
207
|
+
}
|
|
208
|
+
addEventListener(e, n, s, r = !1) {
|
|
209
|
+
this._listeners === void 0 && (this._listeners = {}), this._context = s;
|
|
210
|
+
const i = this._mutex, a = this._listeners;
|
|
211
|
+
return a[e] === void 0 && (a[e] = []), a[e].indexOf(n) === -1 && (r && (i[e] = n), a[e].push(n)), this;
|
|
212
|
+
}
|
|
213
|
+
hasEventListener(e, n) {
|
|
214
|
+
if (this._listeners === null || this._listeners === void 0) return !1;
|
|
215
|
+
const s = this._listeners;
|
|
216
|
+
return s[e] !== void 0 && s[e].indexOf(n) !== -1;
|
|
217
|
+
}
|
|
218
|
+
removeEventListener(e, n) {
|
|
219
|
+
if (this._listeners === void 0) return;
|
|
220
|
+
const r = this._listeners[e];
|
|
221
|
+
if (this._mutex[e] === n && (this._mutex[e] = null), r !== void 0) {
|
|
222
|
+
const i = r.map((a) => a.toString()).indexOf(n.toString());
|
|
223
|
+
i !== -1 && r.splice(i, 1);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
dispatchEvent(e) {
|
|
227
|
+
if (this._listeners === void 0) return;
|
|
228
|
+
const s = this._listeners[e.type];
|
|
229
|
+
if (s !== void 0) {
|
|
230
|
+
e.target = this;
|
|
231
|
+
const r = s.slice(0);
|
|
232
|
+
if (this._mutex[e.type] !== void 0) {
|
|
233
|
+
const i = r.find((a) => a === this._mutex[e.type]);
|
|
234
|
+
if (i) {
|
|
235
|
+
i.call(this._context || this, e);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
for (let i = 0, a = r.length; i < a; i++) {
|
|
240
|
+
const o = r[i];
|
|
241
|
+
typeof o == "function" && o.call(this._context || this, e);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
removeAllListener() {
|
|
246
|
+
this._mutex = {};
|
|
247
|
+
for (const e in this._listeners)
|
|
248
|
+
this._listeners[e] = [];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
class E extends Map {
|
|
252
|
+
isEmpty() {
|
|
253
|
+
return this.size === 0;
|
|
254
|
+
}
|
|
255
|
+
_values() {
|
|
256
|
+
return Array.from(this.values());
|
|
257
|
+
}
|
|
258
|
+
_keys() {
|
|
259
|
+
return Array.from(this.keys());
|
|
260
|
+
}
|
|
261
|
+
_entries() {
|
|
262
|
+
return Array.from(this.entries());
|
|
263
|
+
}
|
|
264
|
+
fromEntries() {
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
E.prototype.fromEntries = function(t = []) {
|
|
268
|
+
const e = new E();
|
|
269
|
+
return t.forEach((n) => {
|
|
270
|
+
Array.isArray(n) && n.length === 2 && e.set(n[0], n[1]);
|
|
271
|
+
}), e;
|
|
272
|
+
};
|
|
273
|
+
class L extends A {
|
|
274
|
+
constructor(n = "ws://127.0.0.1:10088") {
|
|
275
|
+
super();
|
|
276
|
+
f(this, "maxCheckTimes", 10);
|
|
277
|
+
f(this, "url");
|
|
278
|
+
f(this, "checkTimes", 0);
|
|
279
|
+
f(this, "connectStatus", !1);
|
|
280
|
+
f(this, "client", null);
|
|
281
|
+
this.maxCheckTimes = 10, this.url = n, this.checkTimes = 0, this.connect(), this.connCheckStatus(this.maxCheckTimes);
|
|
282
|
+
}
|
|
283
|
+
connect() {
|
|
284
|
+
if (this.disconnect(), this.url)
|
|
285
|
+
try {
|
|
286
|
+
if (console.info("创建ws连接>>>" + this.url), this.client = new WebSocket(this.url), this.client) {
|
|
287
|
+
const n = this;
|
|
288
|
+
this.client.onopen = function(s) {
|
|
289
|
+
n.dispatchEvent({
|
|
290
|
+
type: y.WEB_SOCKET_CONNECT,
|
|
291
|
+
message: s
|
|
292
|
+
});
|
|
293
|
+
}, this.client.onmessage = function(s) {
|
|
294
|
+
n.connectStatus = !0, n.dispatchEvent({
|
|
295
|
+
type: y.WEB_SOCKET_MESSAGE,
|
|
296
|
+
message: s
|
|
297
|
+
});
|
|
298
|
+
}, this.client.onclose = function(s) {
|
|
299
|
+
n.dispatchEvent({
|
|
300
|
+
type: y.WEB_SOCKET_CLOSE,
|
|
301
|
+
message: s
|
|
302
|
+
});
|
|
303
|
+
}, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(s) {
|
|
304
|
+
n.dispatchEvent({
|
|
305
|
+
type: y.WEB_SOCKET_ERROR,
|
|
306
|
+
message: s
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
} catch (n) {
|
|
311
|
+
console.error("创建ws连接失败" + this.url + ":" + n);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
disconnect() {
|
|
315
|
+
if (this.client)
|
|
316
|
+
try {
|
|
317
|
+
console.log("ws断开连接" + this.url), this.client.close(), this.client = null;
|
|
318
|
+
} catch {
|
|
319
|
+
this.client = null;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
connCheckStatus(n) {
|
|
323
|
+
this.checkTimes > n || setTimeout(() => {
|
|
324
|
+
this.checkTimes++, this.client && this.client.readyState !== 0 && this.client.readyState !== 1 && this.connect(), this.connCheckStatus(n);
|
|
325
|
+
}, 2e3);
|
|
326
|
+
}
|
|
327
|
+
send(n) {
|
|
328
|
+
return this.client && this.client.readyState === 1 ? (this.client.send(n), !0) : (console.error(this.url + "消息发送失败:" + n), !1);
|
|
329
|
+
}
|
|
330
|
+
heartbeat() {
|
|
331
|
+
setTimeout(() => {
|
|
332
|
+
this.client && this.client.readyState === 1 && this.send("HeartBeat"), console.log("HeartBeat," + this.url), setTimeout(this.heartbeat, 3e4);
|
|
333
|
+
}, 1e3);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
const M = {
|
|
106
337
|
/**
|
|
107
338
|
* 获取数据类型
|
|
108
339
|
*
|
|
@@ -250,7 +481,7 @@ const y = {
|
|
|
250
481
|
return t.replace(n, (s, r) => {
|
|
251
482
|
const i = e[r];
|
|
252
483
|
if (i === void 0)
|
|
253
|
-
throw new Error(`${
|
|
484
|
+
throw new Error(`${S.JSON_VALUE_ERROR}: ${s}`);
|
|
254
485
|
return typeof i == "function" ? i(e) : i;
|
|
255
486
|
});
|
|
256
487
|
},
|
|
@@ -304,260 +535,7 @@ const y = {
|
|
|
304
535
|
isNil(t) {
|
|
305
536
|
return typeof t > "u" || t === null;
|
|
306
537
|
}
|
|
307
|
-
}, m = {
|
|
308
|
-
DEG2RAD: Math.PI / 180,
|
|
309
|
-
RAD2DEG: 180 / Math.PI,
|
|
310
|
-
randInt(t, e) {
|
|
311
|
-
return t + Math.floor(Math.random() * (e - t + 1));
|
|
312
|
-
},
|
|
313
|
-
randFloat(t, e) {
|
|
314
|
-
return t + Math.random() * (e - t);
|
|
315
|
-
},
|
|
316
|
-
/**
|
|
317
|
-
* 角度转弧度
|
|
318
|
-
*
|
|
319
|
-
* @param {*} degrees
|
|
320
|
-
* @returns {*}
|
|
321
|
-
*/
|
|
322
|
-
degreesToRadians(t) {
|
|
323
|
-
return t * this.DEG2RAD;
|
|
324
|
-
},
|
|
325
|
-
/**
|
|
326
|
-
* 角度转弧度
|
|
327
|
-
*
|
|
328
|
-
* @param {*} degrees
|
|
329
|
-
* @returns {*}
|
|
330
|
-
*/
|
|
331
|
-
toRadians(t) {
|
|
332
|
-
return t * this.DEG2RAD;
|
|
333
|
-
},
|
|
334
|
-
/**
|
|
335
|
-
* 弧度转角度
|
|
336
|
-
*
|
|
337
|
-
* @param {*} radians
|
|
338
|
-
* @returns {*}
|
|
339
|
-
*/
|
|
340
|
-
radiansToDegrees(t) {
|
|
341
|
-
return t * this.RAD2DEG;
|
|
342
|
-
},
|
|
343
|
-
/**
|
|
344
|
-
* 弧度转角度
|
|
345
|
-
*
|
|
346
|
-
* @param {*} radians
|
|
347
|
-
* @returns {*}
|
|
348
|
-
*/
|
|
349
|
-
toDegrees(t) {
|
|
350
|
-
return t * this.RAD2DEG;
|
|
351
|
-
},
|
|
352
|
-
formatFloat(t, e = 2) {
|
|
353
|
-
return Math.round(t * Math.pow(10, e)) / Math.pow(10, e);
|
|
354
|
-
}
|
|
355
538
|
};
|
|
356
|
-
class P {
|
|
357
|
-
constructor(e) {
|
|
358
|
-
y.getDataType(e) === "String" && (e = document.querySelector("#" + e)), this.ctx = e.getContext("2d");
|
|
359
|
-
}
|
|
360
|
-
drawLine(e, n, s, r, i = {}) {
|
|
361
|
-
this.cxt.beginPath();
|
|
362
|
-
const a = i.width || 1, o = i.color || "#000";
|
|
363
|
-
this.cxt.lineWidth = a, this.cxt.fillStyle = o, this.cxt.moveTo(e, n), this.cxt.lineTo(s, r), this.cxt.closePath(), this.cxt.fill();
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* 绘制圆弧
|
|
367
|
-
* @param {*} x 圆心X坐标
|
|
368
|
-
* @param {*} y 圆心Y坐标
|
|
369
|
-
* @param {*} radius 半径
|
|
370
|
-
* @param {*} startAngle 开始的弧度
|
|
371
|
-
* @param {*} endAngle 结束的弧度
|
|
372
|
-
* @param {*} anticlockwise true为逆时针,false为顺时针
|
|
373
|
-
* @param {boolean} isOnlyArc
|
|
374
|
-
* @param {boolean} isFill 是否是填充,false为绘制边框,true为绘制填充
|
|
375
|
-
* @param {*} bgColor 圆弧的颜色
|
|
376
|
-
* @memberof CanvasDrawer
|
|
377
|
-
*/
|
|
378
|
-
drawArc(e, n, s, r, i, a, o, c) {
|
|
379
|
-
o ? (this.cxt.fillStyle = c, this.cxt.beginPath(), this.cxt.arc(e, n, s, m.degreesToRadians(r), m.degreesToRadians(i), a), this.cxt.closePath(), this.cxt.fill()) : (this.cxt.strokeStyle = c, this.cxt.beginPath(), this.cxt.arc(e, n, s, m.degreesToRadians(r), m.degreesToRadians(i), a), this.cxt.stroke());
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
class L {
|
|
383
|
-
constructor(e = 1) {
|
|
384
|
-
this.magnification = e;
|
|
385
|
-
}
|
|
386
|
-
// 获取系统类型
|
|
387
|
-
_getSystem() {
|
|
388
|
-
var e = navigator.userAgent.toLowerCase();
|
|
389
|
-
if (e.indexOf("windows") >= 0)
|
|
390
|
-
return !0;
|
|
391
|
-
}
|
|
392
|
-
// 获取页面缩放比例
|
|
393
|
-
// _getDevicePixelRatio() {
|
|
394
|
-
// let t = this;
|
|
395
|
-
// }
|
|
396
|
-
// 监听方法兼容写法
|
|
397
|
-
_addHandler(e, n, s) {
|
|
398
|
-
e.addEventListener ? e.addEventListener(n, s, !1) : e.attachEvent ? e.attachEvent("on" + n, s) : e["on" + n] = s;
|
|
399
|
-
}
|
|
400
|
-
// 校正浏览器缩放比例
|
|
401
|
-
_correct() {
|
|
402
|
-
let e = window.innerWidth;
|
|
403
|
-
if (typeof e != "number" && (document.compatMode == "CSS1Compat" ? e = document.documentElement.clientWidth : e = document.body.clientWidth), e <= 750) {
|
|
404
|
-
const s = document.documentElement.clientWidth / e;
|
|
405
|
-
document.documentElement.style.fontSize = this.magnification * 75 * Math.min(s, 2) + "px";
|
|
406
|
-
} else if (e > 750 && e <= 1200) {
|
|
407
|
-
const s = document.documentElement.clientWidth / e;
|
|
408
|
-
document.documentElement.style.fontSize = this.magnification * 85 * Math.min(s, 2) + "px";
|
|
409
|
-
} else {
|
|
410
|
-
const s = document.documentElement.clientWidth / 1920;
|
|
411
|
-
document.documentElement.style.fontSize = this.magnification * 100 * Math.min(s, 2) + "px";
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
// 监听页面缩放
|
|
415
|
-
_watch() {
|
|
416
|
-
let e = this;
|
|
417
|
-
e._addHandler(window, "resize", function() {
|
|
418
|
-
e._correct();
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
// 初始化页面比例
|
|
422
|
-
init() {
|
|
423
|
-
let e = this;
|
|
424
|
-
e._getSystem() && (e._correct(), e._watch());
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
class A {
|
|
428
|
-
constructor() {
|
|
429
|
-
f(this, "_listeners");
|
|
430
|
-
f(this, "_mutex", {});
|
|
431
|
-
f(this, "_context");
|
|
432
|
-
}
|
|
433
|
-
addEventListener(e, n, s, r = !1) {
|
|
434
|
-
this._listeners === void 0 && (this._listeners = {}), this._context = s;
|
|
435
|
-
const i = this._mutex, a = this._listeners;
|
|
436
|
-
return a[e] === void 0 && (a[e] = []), a[e].indexOf(n) === -1 && (r && (i[e] = n), a[e].push(n)), this;
|
|
437
|
-
}
|
|
438
|
-
hasEventListener(e, n) {
|
|
439
|
-
if (this._listeners === null || this._listeners === void 0) return !1;
|
|
440
|
-
const s = this._listeners;
|
|
441
|
-
return s[e] !== void 0 && s[e].indexOf(n) !== -1;
|
|
442
|
-
}
|
|
443
|
-
removeEventListener(e, n) {
|
|
444
|
-
if (this._listeners === void 0) return;
|
|
445
|
-
const r = this._listeners[e];
|
|
446
|
-
if (this._mutex[e] === n && (this._mutex[e] = null), r !== void 0) {
|
|
447
|
-
const i = r.map((a) => a.toString()).indexOf(n.toString());
|
|
448
|
-
i !== -1 && r.splice(i, 1);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
dispatchEvent(e) {
|
|
452
|
-
if (this._listeners === void 0) return;
|
|
453
|
-
const s = this._listeners[e.type];
|
|
454
|
-
if (s !== void 0) {
|
|
455
|
-
e.target = this;
|
|
456
|
-
const r = s.slice(0);
|
|
457
|
-
if (this._mutex[e.type] !== void 0) {
|
|
458
|
-
const i = r.find((a) => a === this._mutex[e.type]);
|
|
459
|
-
if (i) {
|
|
460
|
-
i.call(this._context || this, e);
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
for (let i = 0, a = r.length; i < a; i++) {
|
|
465
|
-
const o = r[i];
|
|
466
|
-
typeof o == "function" && o.call(this._context || this, e);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
removeAllListener() {
|
|
471
|
-
this._mutex = {};
|
|
472
|
-
for (const e in this._listeners)
|
|
473
|
-
this._listeners[e] = [];
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
class E extends Map {
|
|
477
|
-
isEmpty() {
|
|
478
|
-
return this.size === 0;
|
|
479
|
-
}
|
|
480
|
-
_values() {
|
|
481
|
-
return Array.from(this.values());
|
|
482
|
-
}
|
|
483
|
-
_keys() {
|
|
484
|
-
return Array.from(this.keys());
|
|
485
|
-
}
|
|
486
|
-
_entries() {
|
|
487
|
-
return Array.from(this.entries());
|
|
488
|
-
}
|
|
489
|
-
fromEntries() {
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
E.prototype.fromEntries = function(t = []) {
|
|
493
|
-
const e = new E();
|
|
494
|
-
return t.forEach((n) => {
|
|
495
|
-
Array.isArray(n) && n.length === 2 && e.set(n[0], n[1]);
|
|
496
|
-
}), e;
|
|
497
|
-
};
|
|
498
|
-
class U extends A {
|
|
499
|
-
constructor(n = "ws://127.0.0.1:10088") {
|
|
500
|
-
super();
|
|
501
|
-
f(this, "maxCheckTimes", 10);
|
|
502
|
-
f(this, "url");
|
|
503
|
-
f(this, "checkTimes", 0);
|
|
504
|
-
f(this, "connectStatus", !1);
|
|
505
|
-
f(this, "client", null);
|
|
506
|
-
this.maxCheckTimes = 10, this.url = n, this.checkTimes = 0, this.connect(), this.connCheckStatus(this.maxCheckTimes);
|
|
507
|
-
}
|
|
508
|
-
connect() {
|
|
509
|
-
if (this.disconnect(), this.url)
|
|
510
|
-
try {
|
|
511
|
-
if (console.info("创建ws连接>>>" + this.url), this.client = new WebSocket(this.url), this.client) {
|
|
512
|
-
const n = this;
|
|
513
|
-
this.client.onopen = function(s) {
|
|
514
|
-
n.dispatchEvent({
|
|
515
|
-
type: M.WEB_SOCKET_CONNECT,
|
|
516
|
-
message: s
|
|
517
|
-
});
|
|
518
|
-
}, this.client.onmessage = function(s) {
|
|
519
|
-
n.connectStatus = !0, n.dispatchEvent({
|
|
520
|
-
type: M.WEB_SOCKET_MESSAGE,
|
|
521
|
-
message: s
|
|
522
|
-
});
|
|
523
|
-
}, this.client.onclose = function(s) {
|
|
524
|
-
n.dispatchEvent({
|
|
525
|
-
type: M.WEB_SOCKET_CLOSE,
|
|
526
|
-
message: s
|
|
527
|
-
});
|
|
528
|
-
}, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(s) {
|
|
529
|
-
n.dispatchEvent({
|
|
530
|
-
type: M.WEB_SOCKET_ERROR,
|
|
531
|
-
message: s
|
|
532
|
-
});
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
} catch (n) {
|
|
536
|
-
console.error("创建ws连接失败" + this.url + ":" + n);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
disconnect() {
|
|
540
|
-
if (this.client)
|
|
541
|
-
try {
|
|
542
|
-
console.log("ws断开连接" + this.url), this.client.close(), this.client = null;
|
|
543
|
-
} catch {
|
|
544
|
-
this.client = null;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
connCheckStatus(n) {
|
|
548
|
-
this.checkTimes > n || setTimeout(() => {
|
|
549
|
-
this.checkTimes++, this.client && this.client.readyState !== 0 && this.client.readyState !== 1 && this.connect(), this.connCheckStatus(n);
|
|
550
|
-
}, 2e3);
|
|
551
|
-
}
|
|
552
|
-
send(n) {
|
|
553
|
-
return this.client && this.client.readyState === 1 ? (this.client.send(n), !0) : (console.error(this.url + "消息发送失败:" + n), !1);
|
|
554
|
-
}
|
|
555
|
-
heartbeat() {
|
|
556
|
-
setTimeout(() => {
|
|
557
|
-
this.client && this.client.readyState === 1 && this.send("HeartBeat"), console.log("HeartBeat," + this.url), setTimeout(this.heartbeat, 3e4);
|
|
558
|
-
}, 1e3);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
539
|
Array.prototype.groupBy = function(t) {
|
|
562
540
|
var e = {};
|
|
563
541
|
return this.forEach(function(n) {
|
|
@@ -595,7 +573,7 @@ Array.prototype.clear = function() {
|
|
|
595
573
|
};
|
|
596
574
|
const k = {
|
|
597
575
|
asArray(t) {
|
|
598
|
-
return
|
|
576
|
+
return M.isEmpty(t) ? [] : Array.isArray(t) ? t : [t];
|
|
599
577
|
},
|
|
600
578
|
generateArray(t) {
|
|
601
579
|
return [...new Array(t).keys()];
|
|
@@ -642,31 +620,7 @@ const k = {
|
|
|
642
620
|
difference(...t) {
|
|
643
621
|
return this.union(...t).filter((e) => !this.intersection(...t).includes(e));
|
|
644
622
|
}
|
|
645
|
-
},
|
|
646
|
-
/**
|
|
647
|
-
* 从 URL 中解析出查询参数和哈希参数,并以对象的形式返回
|
|
648
|
-
*
|
|
649
|
-
* @param href 需要解析的 URL 链接,默认为当前窗口的 URL
|
|
650
|
-
* @param needDecode 是否需要解码参数值,默认为 true
|
|
651
|
-
* @returns 返回一个包含解析后参数的对象,其中键为参数名,值为参数值
|
|
652
|
-
*/
|
|
653
|
-
getUrlParams(t = window.location.href, e = !0) {
|
|
654
|
-
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: s, hash: r } = new URL(t), i = [s, r];
|
|
655
|
-
let a = {};
|
|
656
|
-
for (let o = 0; o < i.length; o++) {
|
|
657
|
-
const c = i[o];
|
|
658
|
-
if (c) {
|
|
659
|
-
const h = c.replace(/#|\//g, "").split("?");
|
|
660
|
-
if (h.length > 1)
|
|
661
|
-
for (let u = 1; u < h.length; u++) {
|
|
662
|
-
let d;
|
|
663
|
-
for (; d = n.exec(h[u]); )
|
|
664
|
-
a[d[1]] = e ? decodeURIComponent(d[2]) : d[2];
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
return a;
|
|
669
|
-
},
|
|
623
|
+
}, U = {
|
|
670
624
|
/**
|
|
671
625
|
* 获取浏览器类型
|
|
672
626
|
*
|
|
@@ -719,7 +673,7 @@ const k = {
|
|
|
719
673
|
const t = document.documentElement.clientWidth || document.body.clientWidth, e = document.querySelector("html");
|
|
720
674
|
e && (e.style.fontSize = t / 192 + "px");
|
|
721
675
|
}
|
|
722
|
-
},
|
|
676
|
+
}, N = {
|
|
723
677
|
set: function(t, e, n = 30) {
|
|
724
678
|
var s = /* @__PURE__ */ new Date();
|
|
725
679
|
s.setTime(s.getTime() + n * 24 * 60 * 60 * 1e3), document.cookie = t + "=" + escape(e) + ";expires=" + s.toUTCString();
|
|
@@ -734,7 +688,7 @@ const k = {
|
|
|
734
688
|
var e = document.cookie.match(new RegExp("(^| )" + t + "=([^;]*)(;|$)"));
|
|
735
689
|
return e != null ? e[2] : "";
|
|
736
690
|
}
|
|
737
|
-
},
|
|
691
|
+
}, F = {
|
|
738
692
|
PI: 3.141592653589793,
|
|
739
693
|
XPI: 3.141592653589793 * 3e3 / 180,
|
|
740
694
|
delta(t, e) {
|
|
@@ -746,6 +700,16 @@ const k = {
|
|
|
746
700
|
const c = Math.sqrt(o);
|
|
747
701
|
return r = r * 180 / (6378245 * (1 - s) / (o * c) * this.PI), i = i * 180 / (6378245 / c * Math.cos(a) * this.PI), { lat: r, lng: i };
|
|
748
702
|
},
|
|
703
|
+
/**
|
|
704
|
+
* 判断经纬度是否不在中国境内
|
|
705
|
+
*
|
|
706
|
+
* @param lng 经度
|
|
707
|
+
* @param lat 纬度
|
|
708
|
+
* @returns 如果经纬度不在中国境内则返回true,否则返回false
|
|
709
|
+
*/
|
|
710
|
+
outOfChina(t, e) {
|
|
711
|
+
return t < 72.004 || t > 137.8347 || e < 0.8293 || e > 55.8271;
|
|
712
|
+
},
|
|
749
713
|
// WGS-84 to GCJ-02
|
|
750
714
|
gcjEncrypt(t, e) {
|
|
751
715
|
if (this.outOfChina(t, e))
|
|
@@ -765,8 +729,8 @@ const k = {
|
|
|
765
729
|
let r = 0.01, i = 0.01, a = t - r, o = e - i, c = t + r, l = e + i, h = 0, u = 0, d = 0;
|
|
766
730
|
for (; ; ) {
|
|
767
731
|
h = (a + c) / 2, u = (o + l) / 2;
|
|
768
|
-
const
|
|
769
|
-
if (r =
|
|
732
|
+
const m = this.gcjEncrypt(h, u);
|
|
733
|
+
if (r = m.lat - t, i = m.lng - e, Math.abs(r) < 1e-9 && Math.abs(i) < 1e-9 || (r > 0 ? c = h : a = h, i > 0 ? l = u : o = u, ++d > 1e4)) break;
|
|
770
734
|
}
|
|
771
735
|
return { lat: h, lng: u };
|
|
772
736
|
},
|
|
@@ -808,7 +772,7 @@ const k = {
|
|
|
808
772
|
lng: Math.random() * (n - t) + t
|
|
809
773
|
};
|
|
810
774
|
}
|
|
811
|
-
},
|
|
775
|
+
}, $ = {
|
|
812
776
|
/**
|
|
813
777
|
* 将RGB颜色值转换为十六进制颜色值
|
|
814
778
|
*
|
|
@@ -945,7 +909,7 @@ Date.prototype.addDate = function(t, e) {
|
|
|
945
909
|
}
|
|
946
910
|
return n;
|
|
947
911
|
};
|
|
948
|
-
const
|
|
912
|
+
const B = {
|
|
949
913
|
lastMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1),
|
|
950
914
|
thisMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
|
|
951
915
|
nextMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 1),
|
|
@@ -1155,16 +1119,6 @@ const q = {
|
|
|
1155
1119
|
isLnglat(t, e) {
|
|
1156
1120
|
return !isNaN(t) && !isNaN(e) && +e > -90 && +e < 90 && +t > -180 && +t < 180;
|
|
1157
1121
|
},
|
|
1158
|
-
/**
|
|
1159
|
-
* 判断经纬度是否不在中国境内
|
|
1160
|
-
*
|
|
1161
|
-
* @param lng 经度
|
|
1162
|
-
* @param lat 纬度
|
|
1163
|
-
* @returns 如果经纬度不在中国境内则返回true,否则返回false
|
|
1164
|
-
*/
|
|
1165
|
-
outOfChina({ lng: t, lat: e }) {
|
|
1166
|
-
return t < 72.004 || t > 137.8347 || e < 0.8293 || e > 55.8271;
|
|
1167
|
-
},
|
|
1168
1122
|
/**
|
|
1169
1123
|
* 计算两哥平面坐标点间的距离
|
|
1170
1124
|
*
|
|
@@ -1276,10 +1230,10 @@ const q = {
|
|
|
1276
1230
|
* @returns 包含方位角和距离的对象
|
|
1277
1231
|
*/
|
|
1278
1232
|
calcBearAndDisByPoints(t, e) {
|
|
1279
|
-
var n = t.lat * 1, s = t.lng * 1, r = e.lat * 1, i = e.lng * 1, a = Math.sin((i - s) * this.toRadian) * Math.cos(r * this.toRadian), o = Math.cos(n * this.toRadian) * Math.sin(r * this.toRadian) - Math.sin(n * this.toRadian) * Math.cos(r * this.toRadian) * Math.cos((i - s) * this.toRadian), c = Math.atan2(a, o) * (180 / Math.PI), l = (r - n) * this.toRadian, h = (i - s) * this.toRadian, u = Math.sin(l / 2) * Math.sin(l / 2) + Math.cos(n * this.toRadian) * Math.cos(r * this.toRadian) * Math.sin(h / 2) * Math.sin(h / 2), d = 2 * Math.atan2(Math.sqrt(u), Math.sqrt(1 - u)),
|
|
1233
|
+
var n = t.lat * 1, s = t.lng * 1, r = e.lat * 1, i = e.lng * 1, a = Math.sin((i - s) * this.toRadian) * Math.cos(r * this.toRadian), o = Math.cos(n * this.toRadian) * Math.sin(r * this.toRadian) - Math.sin(n * this.toRadian) * Math.cos(r * this.toRadian) * Math.cos((i - s) * this.toRadian), c = Math.atan2(a, o) * (180 / Math.PI), l = (r - n) * this.toRadian, h = (i - s) * this.toRadian, u = Math.sin(l / 2) * Math.sin(l / 2) + Math.cos(n * this.toRadian) * Math.cos(r * this.toRadian) * Math.sin(h / 2) * Math.sin(h / 2), d = 2 * Math.atan2(Math.sqrt(u), Math.sqrt(1 - u)), m = this.R * d;
|
|
1280
1234
|
return {
|
|
1281
1235
|
angle: c,
|
|
1282
|
-
distance:
|
|
1236
|
+
distance: m
|
|
1283
1237
|
};
|
|
1284
1238
|
},
|
|
1285
1239
|
/**
|
|
@@ -1297,8 +1251,8 @@ const q = {
|
|
|
1297
1251
|
const h = (o - i) * (o - i) + (c - a) * (c - a);
|
|
1298
1252
|
if (l >= h)
|
|
1299
1253
|
return Math.sqrt((s - o) * (s - o) + (r - c) * (r - c));
|
|
1300
|
-
const u = l / h, d = i + (o - i) * u,
|
|
1301
|
-
return Math.sqrt((s - d) * (s - d) + (r -
|
|
1254
|
+
const u = l / h, d = i + (o - i) * u, m = a + (c - a) * u;
|
|
1255
|
+
return Math.sqrt((s - d) * (s - d) + (r - m) * (r - m));
|
|
1302
1256
|
},
|
|
1303
1257
|
/**
|
|
1304
1258
|
* 根据给定的经纬度、角度和距离计算新的经纬度点
|
|
@@ -1309,12 +1263,12 @@ const q = {
|
|
|
1309
1263
|
* @returns 返回计算后的新经纬度点,类型为{lat: number, lng: number}
|
|
1310
1264
|
*/
|
|
1311
1265
|
calcPointByBearAndDis(t, e, n) {
|
|
1312
|
-
const s =
|
|
1313
|
-
e =
|
|
1266
|
+
const s = g.toRadians(t.lat * 1), r = g.toRadians(t.lng * 1), i = n / this.R;
|
|
1267
|
+
e = g.toRadians(e);
|
|
1314
1268
|
const a = Math.asin(Math.sin(s) * Math.cos(i) + Math.cos(s) * Math.sin(i) * Math.cos(e)), o = r + Math.atan2(Math.sin(e) * Math.sin(i) * Math.cos(s), Math.cos(i) - Math.sin(s) * Math.sin(a));
|
|
1315
1269
|
return {
|
|
1316
|
-
lat:
|
|
1317
|
-
lng:
|
|
1270
|
+
lat: g.toDegrees(a),
|
|
1271
|
+
lng: g.toDegrees(o)
|
|
1318
1272
|
};
|
|
1319
1273
|
},
|
|
1320
1274
|
/**
|
|
@@ -1344,14 +1298,14 @@ const q = {
|
|
|
1344
1298
|
const i = n / 2 * Math.log((1 + Math.sin(r)) / (1 - Math.sin(r)));
|
|
1345
1299
|
return { x: s, y: i };
|
|
1346
1300
|
}
|
|
1347
|
-
},
|
|
1301
|
+
}, W = {
|
|
1348
1302
|
deepClone(t) {
|
|
1349
1303
|
return structuredClone(t);
|
|
1350
1304
|
},
|
|
1351
1305
|
isEqual(t, e) {
|
|
1352
1306
|
return JSON.stringify(t) === JSON.stringify(e);
|
|
1353
1307
|
}
|
|
1354
|
-
},
|
|
1308
|
+
}, H = {
|
|
1355
1309
|
/**
|
|
1356
1310
|
* 将Base64编码的字符串转换为Blob对象
|
|
1357
1311
|
*
|
|
@@ -1428,7 +1382,7 @@ const q = {
|
|
|
1428
1382
|
var n = document.createElement("a");
|
|
1429
1383
|
n.href = t, n.download = e || "", n.click(), window.URL.revokeObjectURL(n.href);
|
|
1430
1384
|
}
|
|
1431
|
-
},
|
|
1385
|
+
}, K = {
|
|
1432
1386
|
/**
|
|
1433
1387
|
* 防抖函数,在指定的等待时间内,如果连续触发事件,则只在最后一次触发后执行函数。适用于像搜索输入框这种需要用户停止输入后才调用的场景
|
|
1434
1388
|
*
|
|
@@ -1499,7 +1453,7 @@ const q = {
|
|
|
1499
1453
|
s++, s < Math.floor(n / e) && (t.call(this), setTimeout(this.recurve.bind(this, t, e, n), e));
|
|
1500
1454
|
}, e);
|
|
1501
1455
|
}
|
|
1502
|
-
},
|
|
1456
|
+
}, j = {
|
|
1503
1457
|
/**
|
|
1504
1458
|
* 校验字符串是否符合指定类型
|
|
1505
1459
|
*
|
|
@@ -1607,7 +1561,7 @@ const q = {
|
|
|
1607
1561
|
*/
|
|
1608
1562
|
tag(t, ...e) {
|
|
1609
1563
|
return e = e.map((n) => {
|
|
1610
|
-
switch (
|
|
1564
|
+
switch (M.getDataType(n)) {
|
|
1611
1565
|
case "Object":
|
|
1612
1566
|
return n || "{}";
|
|
1613
1567
|
case "Array":
|
|
@@ -1652,9 +1606,9 @@ const q = {
|
|
|
1652
1606
|
* @returns 转换后的字符串,如果值为空,则返回空字符串
|
|
1653
1607
|
*/
|
|
1654
1608
|
asString(t) {
|
|
1655
|
-
if (
|
|
1609
|
+
if (M.isEmpty(t))
|
|
1656
1610
|
return "";
|
|
1657
|
-
switch (
|
|
1611
|
+
switch (M.getDataType(t)) {
|
|
1658
1612
|
case "Object":
|
|
1659
1613
|
case "Array":
|
|
1660
1614
|
return JSON.stringify(t);
|
|
@@ -1734,41 +1688,57 @@ const Y = {
|
|
|
1734
1688
|
var i = e.join("&");
|
|
1735
1689
|
return i;
|
|
1736
1690
|
},
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1691
|
+
/**
|
|
1692
|
+
* 从 URL 中解析出查询参数和哈希参数,并以对象的形式返回
|
|
1693
|
+
*
|
|
1694
|
+
* @param href 需要解析的 URL 链接,默认为当前窗口的 URL
|
|
1695
|
+
* @param needDecode 是否需要解码参数值,默认为 true
|
|
1696
|
+
* @returns 返回一个包含解析后参数的对象,其中键为参数名,值为参数值
|
|
1697
|
+
*/
|
|
1698
|
+
query2Json(t = window.location.href, e = !0) {
|
|
1699
|
+
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: s, hash: r } = new URL(t), i = [s, r];
|
|
1700
|
+
let a = {};
|
|
1701
|
+
for (let o = 0; o < i.length; o++) {
|
|
1702
|
+
const c = i[o];
|
|
1703
|
+
if (c) {
|
|
1704
|
+
const h = c.replace(/#|\//g, "").split("?");
|
|
1705
|
+
if (h.length > 1)
|
|
1706
|
+
for (let u = 1; u < h.length; u++) {
|
|
1707
|
+
let d;
|
|
1708
|
+
for (; d = n.exec(h[u]); )
|
|
1709
|
+
a[d[1]] = e ? decodeURIComponent(d[2]) : d[2];
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
return a;
|
|
1743
1714
|
}
|
|
1744
1715
|
};
|
|
1745
1716
|
export {
|
|
1746
1717
|
k as ArrayUtil,
|
|
1747
1718
|
v as AudioPlayer,
|
|
1748
|
-
|
|
1719
|
+
U as BrowserUtil,
|
|
1749
1720
|
P as CanvasDrawer,
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
L as DevicePixelRatio,
|
|
1721
|
+
$ as ColorUtil,
|
|
1722
|
+
N as Cookie,
|
|
1723
|
+
F as CoordsUtil,
|
|
1724
|
+
B as DateUtil,
|
|
1755
1725
|
q as DomUtil,
|
|
1756
|
-
|
|
1726
|
+
S as ErrorType,
|
|
1757
1727
|
A as EventDispatcher,
|
|
1758
|
-
|
|
1759
|
-
|
|
1728
|
+
y as EventType,
|
|
1729
|
+
H as FileUtil,
|
|
1760
1730
|
G as GeoUtil,
|
|
1761
1731
|
I as GraphicType,
|
|
1762
1732
|
E as HashMap,
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1733
|
+
W as JsonUtil,
|
|
1734
|
+
b as LayerType,
|
|
1735
|
+
g as MathUtil,
|
|
1736
|
+
T as MeasureMode,
|
|
1737
|
+
_ as ObjectState,
|
|
1738
|
+
K as OptimizeUtil,
|
|
1769
1739
|
w as StoreUtil,
|
|
1770
|
-
|
|
1740
|
+
j as StringUtil,
|
|
1771
1741
|
Y as UrlUtil,
|
|
1772
|
-
|
|
1773
|
-
|
|
1742
|
+
M as Util,
|
|
1743
|
+
L as WebSocketClient
|
|
1774
1744
|
};
|
package/dist/gis-common.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(h=typeof globalThis<"u"?globalThis:h||self,m(h["gis-common"]={}))})(this,function(h){"use strict";var K=Object.defineProperty;var Y=(h,m,M)=>m in h?K(h,m,{enumerable:!0,configurable:!0,writable:!0,value:M}):h[m]=M;var p=(h,m,M)=>Y(h,typeof m!="symbol"?m+"":m,M);const m={MAP_RENDER:"mapRender",MAP_READY:"mapReady",MOUSE_CLICK:"click",MOUSE_DOUBLE_CLICK:"dblclick",MOUSE_MOVE:"mousemove",MOUSE_IN:"mousein",MOUSE_OUT:"mouseout",MOUSE_RIGHT_CLICK:"mouseRightClick",KEY_DOWN:"keyDown",KEY_UP:"keyUp",DRAW_ACTIVE:"drawActive",DRAW_MOVE:"drawMove",DRAW_COMPLETE:"drawComplete",MQTT_CONNECT:"mqttConnect",MQTT_ERROR:"mqttError",MQTT_MESSAGE:"mqttMessage",MQTT_CLOSE:"mqttClose",WEB_SOCKET_CONNECT:"webSocketConnect",WEB_SOCKET_ERROR:"webSocketError",WEB_SOCKET_MESSAGE:"webSocketMessage",WEB_SOCKET_CLOSE:"webSocketClose"},M={LOGIN_EXPIRED:"登录信息过期,请重新登录",CROSS_ERROR:"跨域访问",UNEXIST_RESOURCE:"资源不存在",TIMEOUT:"请求超时",INTERNAL_ERROR:"内部错误",NETWORK_ERROR:"请求失败,请检查网络是否已连接",PROCESS_FAIL:"处理失败",AUTH_VERIFY_ERROR:"权限验证失败",NO_DATA_FOUND:"未找到数据",DUPLICATE_INSTANCE:"实例为单例模式,不允许重复构建",COORDINATE_ERROR:"坐标验证失败",JSON_PARSE_ERROR:"JSON解析失败,格式有误",JSON_VALUE_ERROR:"JSON无此键",PARAMETER_ERROR:"验证数据类型失败",PARAMETER_ERROR_ARRAY:"格式类型验证失败:必须是数组",PARAMETER_ERROR_STRING:"格式类型验证失败:必须是字符",PARAMETER_ERROR_FUNCTION:"格式类型验证失败:必须是函数",PARAMETER_ERROR_OBJECT:"格式类型验证失败:必须是对象",PARAMETER_ERROR_LACK:"参数缺失",STRING_CHECK_LOSS:"字符缺少关键字"},A={SUPER_MAP_IMAGES:"SuperMapImages",SUPER_MAP_DATA:"SuperMapData",ARC_GIS_MAP_IMAGES:"ArcGisMapImages",ARC_GIS_MAP_DATA:"ArcGisMapData",OSGB_LAYER:"OSGBLayer",S3M_GROUP:"S3MGroup",TERRAIN_LAYER:"TerrainFileLayer"},O={POINT:"point",POLYLINE:"polyline",POLYGON:"polygon",BILLBOARD:"billboard",CYLINDER:"cylinder",ELLIPSOID:"ellipsoid",LABEL:"label",MODEL:"model",WALL:"wall"},x={DISTANCE:"distance",AREA:"area",HEIGHT:"height"},C={ADD:"add",REMOVE:"remove",INIT:"init"};class I{constructor(e){p(this,"audio");this.audio=new Audio,this.audio.src=e}play(){!this.muted&&this.audio.play()}pause(){this.audio.pause()}get muted(){return this.audio.muted}set muted(e){this.audio.muted=e}}const R={getDataType(t){return Object.prototype.toString.call(t).slice(8,-1)},isEmpty(t){if(t==null)return!0;switch(this.getDataType(t)){case"String":return t.trim()==="";case"Array":return!t.length;case"Object":return!Object.keys(t).length;case"Boolean":return!t;default:return!1}},isNotEmpty(t){return!this.isEmpty(t)},json2form(t){const e=new FormData;return Object.keys(t).forEach(n=>{e.append(n,t[n]instanceof Object?JSON.stringify(t[n]):t[n])}),e},generateGuid(){const t=function(){return((1+Math.random())*65536|0).toString(16).substring(1)};return t()+t()+t()+t()+t()+t()+t()+t()},decodeDict(...t){let e="";if(t.length>1){const n=t.slice(1,t.length%2===0?t.length-1:t.length);for(let s=0;s<n.length;s=s+2){const r=n[s];t[0]===r&&(e=n[s+1])}!e&&t.length%2===0&&(e=t[t.length-1])}else e=t[0];return e},extend(t,...e){let n,s,r,i;for(s=0,r=e.length;s<r;s++){i=e[s];for(n in i)t[n]=i[n]}return t},convertToTree2(t,e="id",n="parentId",s="children"){const r=[];function i(a){const o=t.filter(c=>c[n]===a[e]).map(c=>(r.some(l=>l[e]===c[e])||i(c),c));o.length>0&&(a[s]=o)}return t.forEach(a=>{t.some(o=>o[n]===a[e])||(i(a),r.push(a))}),r},asyncLoadScript(t){return new Promise((e,n)=>{try{const s=document.createElement("script");s.type="text/javascript",s.src=t,"readyState"in s?s.onreadystatechange=function(){(s.readyState==="complete"||s.readyState==="loaded")&&e(s)}:(s.onload=function(){e(s)},s.onerror=function(){n(new Error("Script failed to load for URL: "+t))}),document.body.appendChild(s)}catch(s){n(s)}})},loadStyle(t){t.forEach(e=>{const n=document.createElement("link");n.href=e,n.rel="stylesheet",n.type="text/css",n.onerror=function(){console.error(`Style loading failed for URL: ${e}`)},document.head.appendChild(n)})},template(t,e){const n=/\{ *([\w_-]+) *\}/g;return t.replace(n,(s,r)=>{const i=e[r];if(i===void 0)throw new Error(`${M.JSON_VALUE_ERROR}: ${s}`);return typeof i=="function"?i(e):i})},deleteEmptyProperty(t){return Object.fromEntries(Object.keys(t).filter(e=>!this.isEmpty(t[e])).map(e=>[e,t[e]]))},deepAssign(t,...e){(typeof t!="object"||t===null)&&(t={});for(const n of e)if(typeof n=="object"&&n!==null)for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(typeof n[s]=="object"&&n[s]!==null?(t[s]||(t[s]=Array.isArray(n[s])?[]:{}),this.deepAssign(t[s],n[s])):t[s]=n[s]);return t},handleCopyValue(t){if(navigator.clipboard&&window.isSecureContext)return navigator.clipboard.writeText(t);{const e=document.createElement("textarea");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,s)=>{try{document.execCommand("copy"),n()}catch{s(new Error("copy failed"))}finally{e.remove()}})}},isArray(t){return Array.isArray(t)},isObject(t){return Object.prototype.toString.call(t).indexOf("Object")>-1},isNil(t){return typeof t>"u"||t===null}},y={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,randInt(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat(t,e){return t+Math.random()*(e-t)},degreesToRadians(t){return t*this.DEG2RAD},toRadians(t){return t*this.DEG2RAD},radiansToDegrees(t){return t*this.RAD2DEG},toDegrees(t){return t*this.RAD2DEG},formatFloat(t,e=2){return Math.round(t*Math.pow(10,e))/Math.pow(10,e)}};class T{constructor(e){R.getDataType(e)==="String"&&(e=document.querySelector("#"+e)),this.ctx=e.getContext("2d")}drawLine(e,n,s,r,i={}){this.cxt.beginPath();const a=i.width||1,o=i.color||"#000";this.cxt.lineWidth=a,this.cxt.fillStyle=o,this.cxt.moveTo(e,n),this.cxt.lineTo(s,r),this.cxt.closePath(),this.cxt.fill()}drawArc(e,n,s,r,i,a,o,c){o?(this.cxt.fillStyle=c,this.cxt.beginPath(),this.cxt.arc(e,n,s,y.degreesToRadians(r),y.degreesToRadians(i),a),this.cxt.closePath(),this.cxt.fill()):(this.cxt.strokeStyle=c,this.cxt.beginPath(),this.cxt.arc(e,n,s,y.degreesToRadians(r),y.degreesToRadians(i),a),this.cxt.stroke())}}class _{constructor(e=1){this.magnification=e}_getSystem(){var e=navigator.userAgent.toLowerCase();if(e.indexOf("windows")>=0)return!0}_addHandler(e,n,s){e.addEventListener?e.addEventListener(n,s,!1):e.attachEvent?e.attachEvent("on"+n,s):e["on"+n]=s}_correct(){let e=window.innerWidth;if(typeof e!="number"&&(document.compatMode=="CSS1Compat"?e=document.documentElement.clientWidth:e=document.body.clientWidth),e<=750){const s=document.documentElement.clientWidth/e;document.documentElement.style.fontSize=this.magnification*75*Math.min(s,2)+"px"}else if(e>750&&e<=1200){const s=document.documentElement.clientWidth/e;document.documentElement.style.fontSize=this.magnification*85*Math.min(s,2)+"px"}else{const s=document.documentElement.clientWidth/1920;document.documentElement.style.fontSize=this.magnification*100*Math.min(s,2)+"px"}}_watch(){let e=this;e._addHandler(window,"resize",function(){e._correct()})}init(){let e=this;e._getSystem()&&(e._correct(),e._watch())}}class D{constructor(){p(this,"_listeners");p(this,"_mutex",{});p(this,"_context")}addEventListener(e,n,s,r=!1){this._listeners===void 0&&(this._listeners={}),this._context=s;const i=this._mutex,a=this._listeners;return a[e]===void 0&&(a[e]=[]),a[e].indexOf(n)===-1&&(r&&(i[e]=n),a[e].push(n)),this}hasEventListener(e,n){if(this._listeners===null||this._listeners===void 0)return!1;const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const r=this._listeners[e];if(this._mutex[e]===n&&(this._mutex[e]=null),r!==void 0){const i=r.map(a=>a.toString()).indexOf(n.toString());i!==-1&&r.splice(i,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const s=this._listeners[e.type];if(s!==void 0){e.target=this;const r=s.slice(0);if(this._mutex[e.type]!==void 0){const i=r.find(a=>a===this._mutex[e.type]);if(i){i.call(this._context||this,e);return}}for(let i=0,a=r.length;i<a;i++){const o=r[i];typeof o=="function"&&o.call(this._context||this,e)}}}removeAllListener(){this._mutex={};for(const e in this._listeners)this._listeners[e]=[]}}class w extends Map{isEmpty(){return this.size===0}_values(){return Array.from(this.values())}_keys(){return Array.from(this.keys())}_entries(){return Array.from(this.entries())}fromEntries(){}}w.prototype.fromEntries=function(t=[]){const e=new w;return t.forEach(n=>{Array.isArray(n)&&n.length===2&&e.set(n[0],n[1])}),e};class v extends D{constructor(n="ws://127.0.0.1:10088"){super();p(this,"maxCheckTimes",10);p(this,"url");p(this,"checkTimes",0);p(this,"connectStatus",!1);p(this,"client",null);this.maxCheckTimes=10,this.url=n,this.checkTimes=0,this.connect(),this.connCheckStatus(this.maxCheckTimes)}connect(){if(this.disconnect(),this.url)try{if(console.info("创建ws连接>>>"+this.url),this.client=new WebSocket(this.url),this.client){const n=this;this.client.onopen=function(s){n.dispatchEvent({type:m.WEB_SOCKET_CONNECT,message:s})},this.client.onmessage=function(s){n.connectStatus=!0,n.dispatchEvent({type:m.WEB_SOCKET_MESSAGE,message:s})},this.client.onclose=function(s){n.dispatchEvent({type:m.WEB_SOCKET_CLOSE,message:s})},this.checkTimes===this.maxCheckTimes&&(this.client.onerror=function(s){n.dispatchEvent({type:m.WEB_SOCKET_ERROR,message:s})})}}catch(n){console.error("创建ws连接失败"+this.url+":"+n)}}disconnect(){if(this.client)try{console.log("ws断开连接"+this.url),this.client.close(),this.client=null}catch{this.client=null}}connCheckStatus(n){this.checkTimes>n||setTimeout(()=>{this.checkTimes++,this.client&&this.client.readyState!==0&&this.client.readyState!==1&&this.connect(),this.connCheckStatus(n)},2e3)}send(n){return this.client&&this.client.readyState===1?(this.client.send(n),!0):(console.error(this.url+"消息发送失败:"+n),!1)}heartbeat(){setTimeout(()=>{this.client&&this.client.readyState===1&&this.send("HeartBeat"),console.log("HeartBeat,"+this.url),setTimeout(this.heartbeat,3e4)},1e3)}}Array.prototype.groupBy=function(t){var e={};return this.forEach(function(n){var s=JSON.stringify(t(n));e[s]=e[s]||[],e[s].push(n)}),Object.keys(e).map(n=>e[n])},Array.prototype.distinct=function(t=e=>e){const e=[],n={};return this.forEach(s=>{const r=t(s),i=String(r);n[i]||(n[i]=!0,e.push(s))}),e},Array.prototype.max=function(){return Math.max.apply({},this)},Array.prototype.min=function(){return Math.min.apply({},this)},Array.prototype.sum=function(){return this.length>0?this.reduce((t=0,e=0)=>t+e):0},Array.prototype.avg=function(){return this.length?this.sum()/this.length:0},Array.prototype.desc=function(t=e=>e){return this.sort((e,n)=>t(n)-t(e))},Array.prototype.asc=function(t=e=>e){return this.sort((e,n)=>t(e)-t(n))},Array.prototype.clear=function(){return this.length=0,this};const P={asArray(t){return R.isEmpty(t)?[]:Array.isArray(t)?t:[t]},generateArray(t){return[...new Array(t).keys()]},union(...t){let e=[];return t.forEach(n=>{Array.isArray(n)&&(e=e.concat(n.filter(s=>!e.includes(s))))}),e},intersection(...t){let e=t[0]||[];return t.forEach(n=>{Array.isArray(n)&&(e=e.filter(s=>n.includes(s)))}),e},unionAll(...t){return[...t].flat().filter(e=>!!e)},difference(...t){return this.union(...t).filter(e=>!this.intersection(...t).includes(e))}},L={getUrlParams(t=window.location.href,e=!0){const n=/([^&=]+)=([\w\W]*?)(&|$|#)/g,{search:s,hash:r}=new URL(t),i=[s,r];let a={};for(let o=0;o<i.length;o++){const c=i[o];if(c){const u=c.replace(/#|\//g,"").split("?");if(u.length>1)for(let d=1;d<u.length;d++){let f;for(;f=n.exec(u[d]);)a[f[1]]=e?decodeURIComponent(f[2]):f[2]}}}return a},getExplorer(){var t=window.navigator.userAgent;return t.indexOf("MSIE")>=0||/Trident\//.test(t)?"IE":t.indexOf("Firefox")>=0?"Firefox":t.indexOf("Chrome")>=0?"Chrome":t.indexOf("Opera")>=0?"Opera":t.indexOf("Safari")>=0&&t.indexOf("Chrome")===-1?"Safari":"Unknown"},detectOS(){let t="";const e=navigator.userAgent.indexOf("Windows",0)!=-1?1:0,n=navigator.userAgent.indexOf("mac",0)!=-1?1:0,s=navigator.userAgent.indexOf("Linux",0)!=-1?1:0,r=navigator.userAgent.indexOf("X11",0)!=-1?1:0;return e?t="MS Windows":n?t="Apple mac":s?t="Linux":r&&(t="Unix"),t},switchFullScreen(t){if(t){const e=document.documentElement;e.requestFullscreen?e.requestFullscreen():"msRequestFullscreen"in e?e.msRequestFullscreen():"mozRequestFullScreen"in e?e.mozRequestFullScreen():"webkitRequestFullscreen"in e&&e.webkitRequestFullscreen()}else document.exitFullscreen?document.exitFullscreen():"msExitFullscreen"in document?document.msExitFullscreen():"mozCancelFullScreen"in document?document.mozCancelFullScreen():"webkitExitFullscreen"in document&&document.webkitExitFullscreen()},refreshScale(){const t=document.documentElement.clientWidth||0,e=document.documentElement.clientHeight||0,n=document.getElementById("app");if(!n)return;const s=n.style,r=t/e,i=16/9;let a=t/1920;r>i&&(a=e/1080),s.transformOrigin="left top",s.transform=`scale(${a}) translateX(-49.99%)`,s.width=`${t/a}px`},getHtmlFontSize(){const t=document.documentElement.clientWidth||document.body.clientWidth,e=document.querySelector("html");e&&(e.style.fontSize=t/192+"px")}},U={set:function(t,e,n=30){var s=new Date;s.setTime(s.getTime()+n*24*60*60*1e3),document.cookie=t+"="+escape(e)+";expires="+s.toUTCString()},remove:function(t){var e=new Date;e.setTime(e.getTime()-1);var n=this.get(t);n!=null&&(document.cookie=t+"="+n+";expires="+e.toUTCString())},get:function(t){var e=document.cookie.match(new RegExp("(^| )"+t+"=([^;]*)(;|$)"));return e!=null?e[2]:""}},k={PI:3.141592653589793,XPI:3.141592653589793*3e3/180,delta(t,e){const s=.006693421622965943;let r=this.transformLat(e-105,t-35),i=this.transformLon(e-105,t-35);const a=t/180*this.PI;let o=Math.sin(a);o=1-s*o*o;const c=Math.sqrt(o);return r=r*180/(6378245*(1-s)/(o*c)*this.PI),i=i*180/(6378245/c*Math.cos(a)*this.PI),{lat:r,lng:i}},gcjEncrypt(t,e){if(this.outOfChina(t,e))return{lat:t,lng:e};const n=this.delta(t,e);return{lat:t+n.lat,lng:e+n.lng}},gcjDecrypt(t,e){if(this.outOfChina(t,e))return{lat:t,lng:e};const n=this.delta(t,e);return{lat:t-n.lat,lng:e-n.lng}},gcjDecryptExact(t,e){let r=.01,i=.01,a=t-r,o=e-i,c=t+r,l=e+i,u=0,d=0,f=0;for(;;){u=(a+c)/2,d=(o+l)/2;const E=this.gcjEncrypt(u,d);if(r=E.lat-t,i=E.lng-e,Math.abs(r)<1e-9&&Math.abs(i)<1e-9||(r>0?c=u:a=u,i>0?l=d:o=d,++f>1e4))break}return{lat:u,lng:d}},bdEncrypt(t,e){const n=e,s=t,r=Math.sqrt(n*n+s*s)+2e-5*Math.sin(s*this.XPI),i=Math.atan2(s,n)+3e-6*Math.cos(n*this.XPI),a=r*Math.cos(i)+.0065;return{lat:r*Math.sin(i)+.006,lng:a}},bdDecrypt(t,e){const n=e-.0065,s=t-.006,r=Math.sqrt(n*n+s*s)-2e-5*Math.sin(s*this.XPI),i=Math.atan2(s,n)-3e-6*Math.cos(n*this.XPI),a=r*Math.cos(i);return{lat:r*Math.sin(i),lng:a}},mercatorEncrypt(t,e){const n=e*2003750834e-2/180;let s=Math.log(Math.tan((90+t)*this.PI/360))/(this.PI/180);return s=s*2003750834e-2/180,{lat:s,lng:n}},mercatorDecrypt(t,e){const n=e/2003750834e-2*180;let s=t/2003750834e-2*180;return s=180/this.PI*(2*Math.atan(Math.exp(s*this.PI/180))-this.PI/2),{lat:s,lng:n}},transformLat(t,e){let n=-100+2*t+3*e+.2*e*e+.1*t*e+.2*Math.sqrt(Math.abs(t));return n+=(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))*2/3,n+=(20*Math.sin(e*this.PI)+40*Math.sin(e/3*this.PI))*2/3,n+=(160*Math.sin(e/12*this.PI)+320*Math.sin(e*this.PI/30))*2/3,n},transformLon(t,e){let n=300+t+2*e+.1*t*t+.1*t*e+.1*Math.sqrt(Math.abs(t));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},randomCoordinate(t,e,n,s){return{lat:Math.random()*(s-e)+e,lng:Math.random()*(n-t)+t}}},N={rgb2hex(t){var e="#"+(16777216+(t[0]<<16)+(t[1]<<8)+t[2]).toString(16).slice(1);return e},rgbToRgba(t){const e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(t);return e?`rgba(${e[1]}, 1)`:t},hexToRgba(t){const e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,n=t.replace(e,(c,l,u,d)=>l+l+u+u+d+d),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);if(!r)return t;const i=parseInt(r[1],16),a=parseInt(r[2],16),o=parseInt(r[3],16);return`rgba(${i},${a},${o},1)`},hslToRgba(t){if(!t)return null;const e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t);if(!e)return null;const n=parseInt(e[1],10)/360,s=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100,i=e[4]?parseFloat(e[4]):1;function a(u,d,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?u+(d-u)*6*f:f<1/2?d:f<2/3?u+(d-u)*(2/3-f)*6:u}let o,c,l;if(s===0)o=c=l=r;else{const u=r<.5?r*(1+s):r+s-r*s,d=2*r-u;o=a(d,u,n+1/3),c=a(d,u,n),l=a(d,u,n-1/3)}return`rgba(${Math.round(o*255)},${Math.round(c*255)},${Math.round(l*255)},${i})`},isHex(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)},isRgb(t){return/^rgb/.test(t)},isHsl(t){return/^hsl/.test(t)},isColor(t){return this.isHex(t)||this.isRgb(t)||this.isHsl(t)},colorToRgb(t){if(this.isRgb(t))return this.rgbToRgba(t);if(this.isHex(t))return this.hexToRgba(t);if(this.isHsl(t))return this.hslToRgba(t)}};Date.prototype.format=function(t){const e={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours()%12,"H+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)));for(const n in e)if(new RegExp("("+n+")").test(t)){const s=n.length===1?1:Number(n.slice(1));t=t.replace(RegExp.$1,("00"+e[n]).substr((""+e[n]).length+s-(e[n]+"").length))}return t},Date.prototype.addDate=function(t,e){const n=new Date(this);switch(t){case"y":n.setFullYear(this.getFullYear()+e);break;case"q":n.setMonth(this.getMonth()+e*3);break;case"M":n.setMonth(this.getMonth()+e);break;case"w":n.setDate(this.getDate()+e*7);break;case"d":n.setDate(this.getDate()+e);break;case"h":n.setHours(this.getHours()+e);break;case"m":n.setMinutes(this.getMinutes()+e);break;case"s":n.setSeconds(this.getSeconds()+e);break;default:n.setDate(this.getDate()+e);break}return n};const F={lastMonthDate:new Date(new Date().getFullYear(),new Date().getMonth()-1,1),thisMonthDate:new Date(new Date().getFullYear(),new Date().getMonth(),1),nextMonthDate:new Date(new Date().getFullYear(),new Date().getMonth()+1,1),lastWeekDate:new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()+1-7-new Date().getDay()),thisWeekDate:new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()+1-new Date().getDay()),nextWeekDate:new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()+1+7-new Date().getDay()),lastDayDate:new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()-1),thisDayDate:new Date(new Date().setHours(0,0,0,0)),nextDayDate:new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()+1),parseDate(t){if(typeof t=="string"){var e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);if(e&&e.length>3)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]));if(e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/),e&&e.length>6)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]),parseInt(e[4]),parseInt(e[5]),parseInt(e[6]));if(e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/),e&&e.length>7)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]),parseInt(e[4]),parseInt(e[5]),parseInt(e[6]),parseInt(e[7]))}return null},formatDateInterval(t,e){const n=new Date(t),r=new Date(e).getTime()-n.getTime(),i=Math.floor(r/(24*3600*1e3)),a=r%(24*3600*1e3),o=Math.floor(a/(3600*1e3)),c=a%(3600*1e3),l=Math.floor(c/(60*1e3)),u=c%(60*1e3),d=Math.round(u/1e3);let f="";return i>0&&(f+=i+"天"),o>0&&(f+=o+"时"),l>0&&(f+=l+"分"),d>0&&(f+=d+"秒"),i===0&&o===0&&l===0&&d===0&&(f="少于1秒"),f},formatterCounter(t){const e=function(o){return(o>10?"":"0")+(o||0)},n=e(Math.floor(t/3600)),s=t%3600,r=e(Math.floor(s/60)),i=s%60,a=e(Math.round(i));return`${n}:${r}:${a}`},sleep(t){}};function $(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function b(t){return $(t).split(/\s+/)}const B={getStyle(t,e){var s;let n=t.style[e];if(!n||n==="auto"){const r=(s=document.defaultView)==null?void 0:s.getComputedStyle(t,null);n=r?r[e]:null,n==="auto"&&(n=null)}return n},create(t,e,n){const s=document.createElement(t);return s.className=e||"",n&&n.appendChild(s),s},remove(t){const e=t.parentNode;e&&e.removeChild(t)},empty(t){for(;t.firstChild;)t.removeChild(t.firstChild)},toFront(t){const e=t.parentNode;e&&e.lastChild!==t&&e.appendChild(t)},toBack(t){const e=t.parentNode;e&&e.firstChild!==t&&e.insertBefore(t,e.firstChild)},getClass(t){return((t==null?void 0:t.host)||t).className.toString()},hasClass(t,e){var s;if((s=t.classList)!=null&&s.contains(e))return!0;const n=this.getClass(t);return n.length>0&&new RegExp(`(^|\\s)${e}(\\s|$)`).test(n)},addClass(t,e){if(t.classList!==void 0){const n=b(e);for(let s=0,r=n.length;s<r;s++)t.classList.add(n[s])}else if(!this.hasClass(t,e)){const n=this.getClass(t);this.setClass(t,(n?n+" ":"")+e)}},removeClass(t,e){t.classList!==void 0?b(e).forEach(s=>t.classList.remove(s)):this.setClass(t,(" "+this.getClass(t)+" ").replace(" "+e+" "," ").trim())},setClass(t,e){"classList"in t&&(t.classList.value="",e.split(" ").forEach(n=>t.classList.add(n)))},parseFromString(t){return new DOMParser().parseFromString(t,"text/xml").children[0]}},W={toRadian:Math.PI/180,R:6371393,isLnglat(t,e){return!isNaN(t)&&!isNaN(e)&&+e>-90&&+e<90&&+t>-180&&+t<180},outOfChina({lng:t,lat:e}){return t<72.004||t>137.8347||e<.8293||e>55.8271},distance(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))},distanceByPoints(t,e){const{lng:n,lat:s}=t,{lng:r,lat:i}=e,a=6371e3,o=Math.cos(s*Math.PI/180)*Math.cos(i*Math.PI/180)*Math.cos((n-r)*Math.PI/180),c=Math.sin(s*Math.PI/180)*Math.sin(i*Math.PI/180);let l=o+c;return l>1&&(l=1),l<-1&&(l=-1),Math.acos(l)*a},formatLnglat(t,e){let n="";function s(r){const i=Math.floor(r),a=Math.floor((r-i)*60),o=(r-i)*3600-a*60;return`${i}°${a}′${o.toFixed(2)}″`}return this.isLnglat(t,e)?n=s(t)+","+s(e):isNaN(t)?isNaN(e)||(n=s(e)):n=s(t),n},transformLnglat(t,e){function n(s){let i=/[sw]/i.test(s)?-1:1;const a=s.match(/[\d.]+/g)||[];let o=0;for(let c=0;c<a.length;c++)o+=parseFloat(a[c])/i,i*=60;return o}if(t&&e)return{lng:n(t),lat:n(e)}},rayCasting(t,e){for(var n=t.x,s=t.y,r=!1,i=0,a=e.length,o=a-1;i<a;o=i,i++){var c=e[i].x,l=e[i].y,u=e[o].x,d=e[o].y;if(c===n&&l===s||u===n&&d===s)return"on";if(l<s&&d>=s||l>=s&&d<s){var f=c+(s-l)*(u-c)/(d-l);if(f===n)return"on";f>n&&(r=!r)}}return r?"in":"out"},rotatePoint(t,e,n){const s=(t.x-e.x)*Math.cos(Math.PI/180*-n)-(t.y-e.y)*Math.sin(Math.PI/180*-n)+e.x,r=(t.x-e.x)*Math.sin(Math.PI/180*-n)+(t.y-e.y)*Math.cos(Math.PI/180*-n)+e.y;return{x:s,y:r}},calcBearAndDis(t,e){const{x:n,y:s}=t,{x:r,y:i}=e,a=r-n,o=i-s,c=Math.sqrt(a*a+o*o);return{angle:(Math.atan2(o,a)*(180/Math.PI)+360+90)%360,distance:c}},calcBearAndDisByPoints(t,e){var n=t.lat*1,s=t.lng*1,r=e.lat*1,i=e.lng*1,a=Math.sin((i-s)*this.toRadian)*Math.cos(r*this.toRadian),o=Math.cos(n*this.toRadian)*Math.sin(r*this.toRadian)-Math.sin(n*this.toRadian)*Math.cos(r*this.toRadian)*Math.cos((i-s)*this.toRadian),c=Math.atan2(a,o)*(180/Math.PI),l=(r-n)*this.toRadian,u=(i-s)*this.toRadian,d=Math.sin(l/2)*Math.sin(l/2)+Math.cos(n*this.toRadian)*Math.cos(r*this.toRadian)*Math.sin(u/2)*Math.sin(u/2),f=2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)),E=this.R*f;return{angle:c,distance:E}},distanceToSegment(t,e,n){const s=t.x,r=t.y,i=e.x,a=e.y,o=n.x,c=n.y,l=(o-i)*(s-i)+(c-a)*(r-a);if(l<=0)return Math.sqrt((s-i)*(s-i)+(r-a)*(r-a));const u=(o-i)*(o-i)+(c-a)*(c-a);if(l>=u)return Math.sqrt((s-o)*(s-o)+(r-c)*(r-c));const d=l/u,f=i+(o-i)*d,E=a+(c-a)*d;return Math.sqrt((s-f)*(s-f)+(r-E)*(r-E))},calcPointByBearAndDis(t,e,n){const s=y.toRadians(t.lat*1),r=y.toRadians(t.lng*1),i=n/this.R;e=y.toRadians(e);const a=Math.asin(Math.sin(s)*Math.cos(i)+Math.cos(s)*Math.sin(i)*Math.cos(e)),o=r+Math.atan2(Math.sin(e)*Math.sin(i)*Math.cos(s),Math.cos(i)-Math.sin(s)*Math.sin(a));return{lat:y.toDegrees(a),lng:y.toDegrees(o)}},mercatorTolonlat(t,e){const n=t/2003750834e-2*180;var s=e/2003750834e-2*180;const r=180/Math.PI*(2*Math.atan(Math.exp(s*Math.PI/180))-Math.PI/2);return{lng:n,lat:r}},lonlatToMercator(t,e){var n=6378137;const s=t*Math.PI/180*n;var r=e*Math.PI/180;const i=n/2*Math.log((1+Math.sin(r))/(1-Math.sin(r)));return{x:s,y:i}}},q={deepClone(t){return structuredClone(t)},isEqual(t,e){return JSON.stringify(t)===JSON.stringify(e)}},G={convertBase64ToBlob(t){const e=t.split(",")[0].split(":")[1].split(";")[0],n=atob(t.split(",")[1]),s=new Array(n.length);for(let a=0;a<n.length;a++)s[a]=n.charCodeAt(a);const r=new Uint8Array(s);return new Blob([r],{type:e})},convertUrlToBase64(t,e,n){return new Promise((s,r)=>{var i=new Image;i.crossOrigin="Anonymous",i.src=t,i.onload=function(){var a=document.createElement("canvas");a.width=e||i.width,a.height=n||i.height;var o=a.getContext("2d");if(!o){r(new Error("Failed to get canvas context"));return}o.drawImage(i,0,0,i.width,i.height);var c=i.src.substring(i.src.lastIndexOf(".")+1).toLowerCase(),l=a.toDataURL("image/"+c),u={dataURL:l,type:"image/"+c,ext:c};s(u)},i.onerror=r})},convertBase64ToFile(t,e){const n=t.split(","),s=n[0].match(/:(.*?);/),r=s?s[1]:"image/png",i=atob(n[1]),a=new Uint8Array(i.length);for(let c=0;c<i.length;c++)a[c]=i.charCodeAt(c);return new File([a],e,{type:r})},downloadFromFile(t,e){if(typeof t=="object")if(t instanceof Blob)t=URL.createObjectURL(t);else{const s=JSON.stringify(t),r=new Blob([s],{type:"text/json"});t=window.URL.createObjectURL(r)}else if(typeof t=="string"&&t.indexOf("http")===-1){const s=new Blob([t],{type:"text/json"});t=window.URL.createObjectURL(s)}var n=document.createElement("a");n.href=t,n.download=e||"",n.click(),window.URL.revokeObjectURL(n.href)}},H={debounce(t,e,n=!0){let s=null,r,i,a;const o=()=>{const c=Date.now()-i;c<e&&c>0?s=setTimeout(o,e-c):(s=null,n||(a=t.apply(this,r)))};return(...c)=>{i=Date.now();const l=n&&!s;return s||(s=setTimeout(o,e)),l&&(a=t.apply(this,c),s||(c=null)),a}},throttle(t,e,n=1){let s=0,r=null;return(...i)=>{if(n===1){const a=Date.now();a-s>=e&&(t.apply(this,i),s=a)}else n===2&&(r||(r=setTimeout(()=>{r=null,t.apply(this,i)},e)))}},memoize(t){const e=new Map;return(...n)=>{const s=JSON.stringify(n);if(e.has(s))return e.get(s);{const r=t.apply(this,n);return e.set(s,r),r}}},recurve(t,e=500,n=5e3){let s=0;setTimeout(()=>{s++,s<Math.floor(n/e)&&(t.call(this),setTimeout(this.recurve.bind(this,t,e,n),e))},e)}},z={checkStr(t,e){switch(e){case"phone":return/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(t);case"tel":return/^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(t);case"card":return/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(t);case"pwd":return/^[a-zA-Z]\w{5,17}$/.test(t);case"postal":return/[1-9]\d{5}(?!\d)/.test(t);case"QQ":return/^[1-9][0-9]{4,9}$/.test(t);case"email":return/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(t);case"money":return/^\d*(?:\.\d{0,2})?$/.test(t);case"URL":return/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(t);case"IP":return/((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(t);case"date":return/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(t)||/^(\d{4})\-(\d{2})\-(\d{2})$/.test(t);case"number":return/^[0-9]$/.test(t);case"english":return/^[a-zA-Z]+$/.test(t);case"chinese":return/^[\u4E00-\u9FA5]+$/.test(t);case"lower":return/^[a-z]+$/.test(t);case"upper":return/^[A-Z]+$/.test(t);case"HTML":return/<("[^"]*"|'[^']*'|[^'">])*>/.test(t);default:return!0}},changeCase(t,e){switch(e=e||4,e){case 1:return t.replace(/\b\w+\b/g,function(n){return n.substring(0,1).toUpperCase()+n.substring(1).toLowerCase()});case 2:return t.replace(/\b\w+\b/g,function(n){return n.substring(0,1).toLowerCase()+n.substring(1).toUpperCase()});case 3:return t.split("").map(function(n){return/[a-z]/.test(n)?n.toUpperCase():n.toLowerCase()}).join("");case 4:return t.toUpperCase();case 5:return t.toLowerCase();default:return t}},tag(t,...e){return e=e.map(n=>{switch(R.getDataType(n)){case"Object":return n||"{}";case"Array":return n||"[]";default:return n||""}}),t.reduce((n,s,r)=>`${n}${e[r-1]}${s}`)},getByteLength(t){return t.replace(/[\u0391-\uFFE5]/g,"aa").length},subStringByte(t,e,n){var s=/[^\x00-\xff]/g;if(t.replace(s,"mm").length<=n)return t;for(var r=Math.floor(n/2),i=r;i<t.length;i++){let a=t.substring(e,i);if(a.replace(s,"mm").length>=n)return a}return t},asString(t){if(R.isEmpty(t))return"";switch(R.getDataType(t)){case"Object":case"Array":return JSON.stringify(t);default:return t}}},g=class g{static set(e,n=null,s=null){var r=this._getPrefixedKey(e,s);try{localStorage.setItem(r,JSON.stringify({data:n}))}catch{console&&console.warn("StoreUtil didn't successfully save the '{"+e+": "+n+"}' pair, because the localStorage is full.")}}static get(e,n,s){var r=this._getPrefixedKey(e,s),i;try{i=JSON.parse(localStorage.getItem(r)||"")}catch{localStorage[r]?i={data:localStorage.getItem(r)}:i=null}if(i){if(typeof i=="object"&&typeof i.data<"u")return i.data}else return n}static keys(){const e=[];var n=Object.keys(localStorage);return g.prefix.length===0?n:(n.forEach(function(s){s.indexOf(g.prefix)!==-1&&e.push(s.replace(g.prefix,""))}),e)}static getAll(e){var n=g.keys();if(e){const s=[];return n.forEach(r=>{if(e.includes(r)){const i={};i[r]=g.get(r,null,null),s.push(i)}}),s}return n.map(s=>g.get(s,null,null))}static remove(e,n){var s=this._getPrefixedKey(e,n);localStorage.removeItem(s)}static clear(e){g.prefix.length?this.keys().forEach(n=>{localStorage.removeItem(this._getPrefixedKey(n,e))}):localStorage.clear()}};p(g,"prefix",""),p(g,"_getPrefixedKey",function(e,n){return n=n||{},n.noPrefix?e:g.prefix+e});let S=g;const j={json2Query(t){var e=[];for(var n in t)if(t.hasOwnProperty(n)){var s=n,r=t[n];e.push(encodeURIComponent(s)+"="+encodeURIComponent(r))}var i=e.join("&");return i},query2Json(t){t.startsWith("http")||(t="http://dummy?"+t);const e=new URL(t),n=new URLSearchParams(e.search),s={};for(let r in n)s[r]=decodeURIComponent(n[r]);return s}};h.ArrayUtil=P,h.AudioPlayer=I,h.BrowserUtil=L,h.CanvasDrawer=T,h.ColorUtil=N,h.Cookie=U,h.CoordsUtil=k,h.DateUtil=F,h.DevicePixelRatio=_,h.DomUtil=B,h.ErrorType=M,h.EventDispatcher=D,h.EventType=m,h.FileUtil=G,h.GeoUtil=W,h.GraphicType=O,h.HashMap=w,h.JsonUtil=q,h.LayerType=A,h.MathUtil=y,h.MeasureMode=x,h.ObjectState=C,h.OptimizeUtil=H,h.StoreUtil=S,h.StringUtil=z,h.UrlUtil=j,h.Util=R,h.WebSocketClient=v,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(h,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(h=typeof globalThis<"u"?globalThis:h||self,g(h["gis-common"]={}))})(this,function(h){"use strict";var K=Object.defineProperty;var Y=(h,g,M)=>g in h?K(h,g,{enumerable:!0,configurable:!0,writable:!0,value:M}):h[g]=M;var p=(h,g,M)=>Y(h,typeof g!="symbol"?g+"":g,M);const g={MAP_RENDER:"mapRender",MAP_READY:"mapReady",MOUSE_CLICK:"click",MOUSE_DOUBLE_CLICK:"dblclick",MOUSE_MOVE:"mousemove",MOUSE_IN:"mousein",MOUSE_OUT:"mouseout",MOUSE_RIGHT_CLICK:"mouseRightClick",KEY_DOWN:"keyDown",KEY_UP:"keyUp",DRAW_ACTIVE:"drawActive",DRAW_MOVE:"drawMove",DRAW_COMPLETE:"drawComplete",MQTT_CONNECT:"mqttConnect",MQTT_ERROR:"mqttError",MQTT_MESSAGE:"mqttMessage",MQTT_CLOSE:"mqttClose",WEB_SOCKET_CONNECT:"webSocketConnect",WEB_SOCKET_ERROR:"webSocketError",WEB_SOCKET_MESSAGE:"webSocketMessage",WEB_SOCKET_CLOSE:"webSocketClose"},M={LOGIN_EXPIRED:"登录信息过期,请重新登录",CROSS_ERROR:"跨域访问",UNEXIST_RESOURCE:"资源不存在",TIMEOUT:"请求超时",INTERNAL_ERROR:"内部错误",NETWORK_ERROR:"请求失败,请检查网络是否已连接",PROCESS_FAIL:"处理失败",AUTH_VERIFY_ERROR:"权限验证失败",NO_DATA_FOUND:"未找到数据",DUPLICATE_INSTANCE:"实例为单例模式,不允许重复构建",COORDINATE_ERROR:"坐标验证失败",JSON_PARSE_ERROR:"JSON解析失败,格式有误",JSON_VALUE_ERROR:"JSON无此键",PARAMETER_ERROR:"验证数据类型失败",PARAMETER_ERROR_ARRAY:"格式类型验证失败:必须是数组",PARAMETER_ERROR_STRING:"格式类型验证失败:必须是字符",PARAMETER_ERROR_FUNCTION:"格式类型验证失败:必须是函数",PARAMETER_ERROR_OBJECT:"格式类型验证失败:必须是对象",PARAMETER_ERROR_LACK:"参数缺失",STRING_CHECK_LOSS:"字符缺少关键字"},O={SUPER_MAP_IMAGES:"SuperMapImages",SUPER_MAP_DATA:"SuperMapData",ARC_GIS_MAP_IMAGES:"ArcGisMapImages",ARC_GIS_MAP_DATA:"ArcGisMapData",OSGB_LAYER:"OSGBLayer",S3M_GROUP:"S3MGroup",TERRAIN_LAYER:"TerrainFileLayer"},x={POINT:"point",POLYLINE:"polyline",POLYGON:"polygon",BILLBOARD:"billboard",CYLINDER:"cylinder",ELLIPSOID:"ellipsoid",LABEL:"label",MODEL:"model",WALL:"wall"},C={DISTANCE:"distance",AREA:"area",HEIGHT:"height"},b={ADD:"add",REMOVE:"remove",INIT:"init"};class T{constructor(e){p(this,"audio");this.audio=new Audio,this.audio.src=e}play(){!this.muted&&this.audio.play()}pause(){this.audio.pause()}get muted(){return this.audio.muted}set muted(e){this.audio.muted=e}}const y={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,randInt(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat(t,e){return t+Math.random()*(e-t)},degreesToRadians(t){return t*this.DEG2RAD},toRadians(t){return t*this.DEG2RAD},radiansToDegrees(t){return t*this.RAD2DEG},toDegrees(t){return t*this.RAD2DEG},formatFloat(t,e=2){return Math.round(t*Math.pow(10,e))/Math.pow(10,e)}};class I{constructor(e){p(this,"context",null);if(typeof e=="string"&&(e=document.querySelector("#"+e),!e))throw new Error("Element not found");if(e instanceof HTMLElement){const n=e;if(n.getContext)this.context=n.getContext("2d");else throw new Error("getContext is not available on this element")}else throw new Error("Element is not an HTMLElement")}drawLine({x:e,y:n},{x:s,y:r},i={}){if(!this.context)throw new Error("Canvas context is null or undefined");this.context.beginPath();const a=i.width??1,o=i.color??"#000";this.context.lineWidth=a,this.context.strokeStyle=o,this.context.moveTo(e,n),this.context.lineTo(s,r),this.context.stroke()}drawArc({x:e,y:n},s,r,i,a,o,c){if(!this.context)throw new Error("Canvas context is null or undefined");o?(this.context.fillStyle=c,this.context.beginPath(),this.context.arc(e,n,s,y.degreesToRadians(r),y.degreesToRadians(i),a),this.context.fill()):(this.context.strokeStyle=c,this.context.beginPath(),this.context.arc(e,n,s,y.degreesToRadians(r),y.degreesToRadians(i),a),this.context.stroke())}}class D{constructor(){p(this,"_listeners");p(this,"_mutex",{});p(this,"_context")}addEventListener(e,n,s,r=!1){this._listeners===void 0&&(this._listeners={}),this._context=s;const i=this._mutex,a=this._listeners;return a[e]===void 0&&(a[e]=[]),a[e].indexOf(n)===-1&&(r&&(i[e]=n),a[e].push(n)),this}hasEventListener(e,n){if(this._listeners===null||this._listeners===void 0)return!1;const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const r=this._listeners[e];if(this._mutex[e]===n&&(this._mutex[e]=null),r!==void 0){const i=r.map(a=>a.toString()).indexOf(n.toString());i!==-1&&r.splice(i,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const s=this._listeners[e.type];if(s!==void 0){e.target=this;const r=s.slice(0);if(this._mutex[e.type]!==void 0){const i=r.find(a=>a===this._mutex[e.type]);if(i){i.call(this._context||this,e);return}}for(let i=0,a=r.length;i<a;i++){const o=r[i];typeof o=="function"&&o.call(this._context||this,e)}}}removeAllListener(){this._mutex={};for(const e in this._listeners)this._listeners[e]=[]}}class w extends Map{isEmpty(){return this.size===0}_values(){return Array.from(this.values())}_keys(){return Array.from(this.keys())}_entries(){return Array.from(this.entries())}fromEntries(){}}w.prototype.fromEntries=function(t=[]){const e=new w;return t.forEach(n=>{Array.isArray(n)&&n.length===2&&e.set(n[0],n[1])}),e};class v extends D{constructor(n="ws://127.0.0.1:10088"){super();p(this,"maxCheckTimes",10);p(this,"url");p(this,"checkTimes",0);p(this,"connectStatus",!1);p(this,"client",null);this.maxCheckTimes=10,this.url=n,this.checkTimes=0,this.connect(),this.connCheckStatus(this.maxCheckTimes)}connect(){if(this.disconnect(),this.url)try{if(console.info("创建ws连接>>>"+this.url),this.client=new WebSocket(this.url),this.client){const n=this;this.client.onopen=function(s){n.dispatchEvent({type:g.WEB_SOCKET_CONNECT,message:s})},this.client.onmessage=function(s){n.connectStatus=!0,n.dispatchEvent({type:g.WEB_SOCKET_MESSAGE,message:s})},this.client.onclose=function(s){n.dispatchEvent({type:g.WEB_SOCKET_CLOSE,message:s})},this.checkTimes===this.maxCheckTimes&&(this.client.onerror=function(s){n.dispatchEvent({type:g.WEB_SOCKET_ERROR,message:s})})}}catch(n){console.error("创建ws连接失败"+this.url+":"+n)}}disconnect(){if(this.client)try{console.log("ws断开连接"+this.url),this.client.close(),this.client=null}catch{this.client=null}}connCheckStatus(n){this.checkTimes>n||setTimeout(()=>{this.checkTimes++,this.client&&this.client.readyState!==0&&this.client.readyState!==1&&this.connect(),this.connCheckStatus(n)},2e3)}send(n){return this.client&&this.client.readyState===1?(this.client.send(n),!0):(console.error(this.url+"消息发送失败:"+n),!1)}heartbeat(){setTimeout(()=>{this.client&&this.client.readyState===1&&this.send("HeartBeat"),console.log("HeartBeat,"+this.url),setTimeout(this.heartbeat,3e4)},1e3)}}const R={getDataType(t){return Object.prototype.toString.call(t).slice(8,-1)},isEmpty(t){if(t==null)return!0;switch(this.getDataType(t)){case"String":return t.trim()==="";case"Array":return!t.length;case"Object":return!Object.keys(t).length;case"Boolean":return!t;default:return!1}},isNotEmpty(t){return!this.isEmpty(t)},json2form(t){const e=new FormData;return Object.keys(t).forEach(n=>{e.append(n,t[n]instanceof Object?JSON.stringify(t[n]):t[n])}),e},generateGuid(){const t=function(){return((1+Math.random())*65536|0).toString(16).substring(1)};return t()+t()+t()+t()+t()+t()+t()+t()},decodeDict(...t){let e="";if(t.length>1){const n=t.slice(1,t.length%2===0?t.length-1:t.length);for(let s=0;s<n.length;s=s+2){const r=n[s];t[0]===r&&(e=n[s+1])}!e&&t.length%2===0&&(e=t[t.length-1])}else e=t[0];return e},extend(t,...e){let n,s,r,i;for(s=0,r=e.length;s<r;s++){i=e[s];for(n in i)t[n]=i[n]}return t},convertToTree2(t,e="id",n="parentId",s="children"){const r=[];function i(a){const o=t.filter(c=>c[n]===a[e]).map(c=>(r.some(l=>l[e]===c[e])||i(c),c));o.length>0&&(a[s]=o)}return t.forEach(a=>{t.some(o=>o[n]===a[e])||(i(a),r.push(a))}),r},asyncLoadScript(t){return new Promise((e,n)=>{try{const s=document.createElement("script");s.type="text/javascript",s.src=t,"readyState"in s?s.onreadystatechange=function(){(s.readyState==="complete"||s.readyState==="loaded")&&e(s)}:(s.onload=function(){e(s)},s.onerror=function(){n(new Error("Script failed to load for URL: "+t))}),document.body.appendChild(s)}catch(s){n(s)}})},loadStyle(t){t.forEach(e=>{const n=document.createElement("link");n.href=e,n.rel="stylesheet",n.type="text/css",n.onerror=function(){console.error(`Style loading failed for URL: ${e}`)},document.head.appendChild(n)})},template(t,e){const n=/\{ *([\w_-]+) *\}/g;return t.replace(n,(s,r)=>{const i=e[r];if(i===void 0)throw new Error(`${M.JSON_VALUE_ERROR}: ${s}`);return typeof i=="function"?i(e):i})},deleteEmptyProperty(t){return Object.fromEntries(Object.keys(t).filter(e=>!this.isEmpty(t[e])).map(e=>[e,t[e]]))},deepAssign(t,...e){(typeof t!="object"||t===null)&&(t={});for(const n of e)if(typeof n=="object"&&n!==null)for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(typeof n[s]=="object"&&n[s]!==null?(t[s]||(t[s]=Array.isArray(n[s])?[]:{}),this.deepAssign(t[s],n[s])):t[s]=n[s]);return t},handleCopyValue(t){if(navigator.clipboard&&window.isSecureContext)return navigator.clipboard.writeText(t);{const e=document.createElement("textarea");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,s)=>{try{document.execCommand("copy"),n()}catch{s(new Error("copy failed"))}finally{e.remove()}})}},isArray(t){return Array.isArray(t)},isObject(t){return Object.prototype.toString.call(t).indexOf("Object")>-1},isNil(t){return typeof t>"u"||t===null}};Array.prototype.groupBy=function(t){var e={};return this.forEach(function(n){var s=JSON.stringify(t(n));e[s]=e[s]||[],e[s].push(n)}),Object.keys(e).map(n=>e[n])},Array.prototype.distinct=function(t=e=>e){const e=[],n={};return this.forEach(s=>{const r=t(s),i=String(r);n[i]||(n[i]=!0,e.push(s))}),e},Array.prototype.max=function(){return Math.max.apply({},this)},Array.prototype.min=function(){return Math.min.apply({},this)},Array.prototype.sum=function(){return this.length>0?this.reduce((t=0,e=0)=>t+e):0},Array.prototype.avg=function(){return this.length?this.sum()/this.length:0},Array.prototype.desc=function(t=e=>e){return this.sort((e,n)=>t(n)-t(e))},Array.prototype.asc=function(t=e=>e){return this.sort((e,n)=>t(e)-t(n))},Array.prototype.clear=function(){return this.length=0,this};const _={asArray(t){return R.isEmpty(t)?[]:Array.isArray(t)?t:[t]},generateArray(t){return[...new Array(t).keys()]},union(...t){let e=[];return t.forEach(n=>{Array.isArray(n)&&(e=e.concat(n.filter(s=>!e.includes(s))))}),e},intersection(...t){let e=t[0]||[];return t.forEach(n=>{Array.isArray(n)&&(e=e.filter(s=>n.includes(s)))}),e},unionAll(...t){return[...t].flat().filter(e=>!!e)},difference(...t){return this.union(...t).filter(e=>!this.intersection(...t).includes(e))}},P={getExplorer(){var t=window.navigator.userAgent;return t.indexOf("MSIE")>=0||/Trident\//.test(t)?"IE":t.indexOf("Firefox")>=0?"Firefox":t.indexOf("Chrome")>=0?"Chrome":t.indexOf("Opera")>=0?"Opera":t.indexOf("Safari")>=0&&t.indexOf("Chrome")===-1?"Safari":"Unknown"},detectOS(){let t="";const e=navigator.userAgent.indexOf("Windows",0)!=-1?1:0,n=navigator.userAgent.indexOf("mac",0)!=-1?1:0,s=navigator.userAgent.indexOf("Linux",0)!=-1?1:0,r=navigator.userAgent.indexOf("X11",0)!=-1?1:0;return e?t="MS Windows":n?t="Apple mac":s?t="Linux":r&&(t="Unix"),t},switchFullScreen(t){if(t){const e=document.documentElement;e.requestFullscreen?e.requestFullscreen():"msRequestFullscreen"in e?e.msRequestFullscreen():"mozRequestFullScreen"in e?e.mozRequestFullScreen():"webkitRequestFullscreen"in e&&e.webkitRequestFullscreen()}else document.exitFullscreen?document.exitFullscreen():"msExitFullscreen"in document?document.msExitFullscreen():"mozCancelFullScreen"in document?document.mozCancelFullScreen():"webkitExitFullscreen"in document&&document.webkitExitFullscreen()},refreshScale(){const t=document.documentElement.clientWidth||0,e=document.documentElement.clientHeight||0,n=document.getElementById("app");if(!n)return;const s=n.style,r=t/e,i=16/9;let a=t/1920;r>i&&(a=e/1080),s.transformOrigin="left top",s.transform=`scale(${a}) translateX(-49.99%)`,s.width=`${t/a}px`},getHtmlFontSize(){const t=document.documentElement.clientWidth||document.body.clientWidth,e=document.querySelector("html");e&&(e.style.fontSize=t/192+"px")}},L={set:function(t,e,n=30){var s=new Date;s.setTime(s.getTime()+n*24*60*60*1e3),document.cookie=t+"="+escape(e)+";expires="+s.toUTCString()},remove:function(t){var e=new Date;e.setTime(e.getTime()-1);var n=this.get(t);n!=null&&(document.cookie=t+"="+n+";expires="+e.toUTCString())},get:function(t){var e=document.cookie.match(new RegExp("(^| )"+t+"=([^;]*)(;|$)"));return e!=null?e[2]:""}},U={PI:3.141592653589793,XPI:3.141592653589793*3e3/180,delta(t,e){const s=.006693421622965943;let r=this.transformLat(e-105,t-35),i=this.transformLon(e-105,t-35);const a=t/180*this.PI;let o=Math.sin(a);o=1-s*o*o;const c=Math.sqrt(o);return r=r*180/(6378245*(1-s)/(o*c)*this.PI),i=i*180/(6378245/c*Math.cos(a)*this.PI),{lat:r,lng:i}},outOfChina(t,e){return t<72.004||t>137.8347||e<.8293||e>55.8271},gcjEncrypt(t,e){if(this.outOfChina(t,e))return{lat:t,lng:e};const n=this.delta(t,e);return{lat:t+n.lat,lng:e+n.lng}},gcjDecrypt(t,e){if(this.outOfChina(t,e))return{lat:t,lng:e};const n=this.delta(t,e);return{lat:t-n.lat,lng:e-n.lng}},gcjDecryptExact(t,e){let r=.01,i=.01,a=t-r,o=e-i,c=t+r,l=e+i,u=0,d=0,f=0;for(;;){u=(a+c)/2,d=(o+l)/2;const E=this.gcjEncrypt(u,d);if(r=E.lat-t,i=E.lng-e,Math.abs(r)<1e-9&&Math.abs(i)<1e-9||(r>0?c=u:a=u,i>0?l=d:o=d,++f>1e4))break}return{lat:u,lng:d}},bdEncrypt(t,e){const n=e,s=t,r=Math.sqrt(n*n+s*s)+2e-5*Math.sin(s*this.XPI),i=Math.atan2(s,n)+3e-6*Math.cos(n*this.XPI),a=r*Math.cos(i)+.0065;return{lat:r*Math.sin(i)+.006,lng:a}},bdDecrypt(t,e){const n=e-.0065,s=t-.006,r=Math.sqrt(n*n+s*s)-2e-5*Math.sin(s*this.XPI),i=Math.atan2(s,n)-3e-6*Math.cos(n*this.XPI),a=r*Math.cos(i);return{lat:r*Math.sin(i),lng:a}},mercatorEncrypt(t,e){const n=e*2003750834e-2/180;let s=Math.log(Math.tan((90+t)*this.PI/360))/(this.PI/180);return s=s*2003750834e-2/180,{lat:s,lng:n}},mercatorDecrypt(t,e){const n=e/2003750834e-2*180;let s=t/2003750834e-2*180;return s=180/this.PI*(2*Math.atan(Math.exp(s*this.PI/180))-this.PI/2),{lat:s,lng:n}},transformLat(t,e){let n=-100+2*t+3*e+.2*e*e+.1*t*e+.2*Math.sqrt(Math.abs(t));return n+=(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))*2/3,n+=(20*Math.sin(e*this.PI)+40*Math.sin(e/3*this.PI))*2/3,n+=(160*Math.sin(e/12*this.PI)+320*Math.sin(e*this.PI/30))*2/3,n},transformLon(t,e){let n=300+t+2*e+.1*t*t+.1*t*e+.1*Math.sqrt(Math.abs(t));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},randomCoordinate(t,e,n,s){return{lat:Math.random()*(s-e)+e,lng:Math.random()*(n-t)+t}}},k={rgb2hex(t){var e="#"+(16777216+(t[0]<<16)+(t[1]<<8)+t[2]).toString(16).slice(1);return e},rgbToRgba(t){const e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(t);return e?`rgba(${e[1]}, 1)`:t},hexToRgba(t){const e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,n=t.replace(e,(c,l,u,d)=>l+l+u+u+d+d),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);if(!r)return t;const i=parseInt(r[1],16),a=parseInt(r[2],16),o=parseInt(r[3],16);return`rgba(${i},${a},${o},1)`},hslToRgba(t){if(!t)return null;const e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t);if(!e)return null;const n=parseInt(e[1],10)/360,s=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100,i=e[4]?parseFloat(e[4]):1;function a(u,d,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?u+(d-u)*6*f:f<1/2?d:f<2/3?u+(d-u)*(2/3-f)*6:u}let o,c,l;if(s===0)o=c=l=r;else{const u=r<.5?r*(1+s):r+s-r*s,d=2*r-u;o=a(d,u,n+1/3),c=a(d,u,n),l=a(d,u,n-1/3)}return`rgba(${Math.round(o*255)},${Math.round(c*255)},${Math.round(l*255)},${i})`},isHex(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)},isRgb(t){return/^rgb/.test(t)},isHsl(t){return/^hsl/.test(t)},isColor(t){return this.isHex(t)||this.isRgb(t)||this.isHsl(t)},colorToRgb(t){if(this.isRgb(t))return this.rgbToRgba(t);if(this.isHex(t))return this.hexToRgba(t);if(this.isHsl(t))return this.hslToRgba(t)}};Date.prototype.format=function(t){const e={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours()%12,"H+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)));for(const n in e)if(new RegExp("("+n+")").test(t)){const s=n.length===1?1:Number(n.slice(1));t=t.replace(RegExp.$1,("00"+e[n]).substr((""+e[n]).length+s-(e[n]+"").length))}return t},Date.prototype.addDate=function(t,e){const n=new Date(this);switch(t){case"y":n.setFullYear(this.getFullYear()+e);break;case"q":n.setMonth(this.getMonth()+e*3);break;case"M":n.setMonth(this.getMonth()+e);break;case"w":n.setDate(this.getDate()+e*7);break;case"d":n.setDate(this.getDate()+e);break;case"h":n.setHours(this.getHours()+e);break;case"m":n.setMinutes(this.getMinutes()+e);break;case"s":n.setSeconds(this.getSeconds()+e);break;default:n.setDate(this.getDate()+e);break}return n};const N={lastMonthDate:new Date(new Date().getFullYear(),new Date().getMonth()-1,1),thisMonthDate:new Date(new Date().getFullYear(),new Date().getMonth(),1),nextMonthDate:new Date(new Date().getFullYear(),new Date().getMonth()+1,1),lastWeekDate:new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()+1-7-new Date().getDay()),thisWeekDate:new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()+1-new Date().getDay()),nextWeekDate:new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()+1+7-new Date().getDay()),lastDayDate:new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()-1),thisDayDate:new Date(new Date().setHours(0,0,0,0)),nextDayDate:new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()+1),parseDate(t){if(typeof t=="string"){var e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);if(e&&e.length>3)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]));if(e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/),e&&e.length>6)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]),parseInt(e[4]),parseInt(e[5]),parseInt(e[6]));if(e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/),e&&e.length>7)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]),parseInt(e[4]),parseInt(e[5]),parseInt(e[6]),parseInt(e[7]))}return null},formatDateInterval(t,e){const n=new Date(t),r=new Date(e).getTime()-n.getTime(),i=Math.floor(r/(24*3600*1e3)),a=r%(24*3600*1e3),o=Math.floor(a/(3600*1e3)),c=a%(3600*1e3),l=Math.floor(c/(60*1e3)),u=c%(60*1e3),d=Math.round(u/1e3);let f="";return i>0&&(f+=i+"天"),o>0&&(f+=o+"时"),l>0&&(f+=l+"分"),d>0&&(f+=d+"秒"),i===0&&o===0&&l===0&&d===0&&(f="少于1秒"),f},formatterCounter(t){const e=function(o){return(o>10?"":"0")+(o||0)},n=e(Math.floor(t/3600)),s=t%3600,r=e(Math.floor(s/60)),i=s%60,a=e(Math.round(i));return`${n}:${r}:${a}`},sleep(t){}};function F(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function A(t){return F(t).split(/\s+/)}const $={getStyle(t,e){var s;let n=t.style[e];if(!n||n==="auto"){const r=(s=document.defaultView)==null?void 0:s.getComputedStyle(t,null);n=r?r[e]:null,n==="auto"&&(n=null)}return n},create(t,e,n){const s=document.createElement(t);return s.className=e||"",n&&n.appendChild(s),s},remove(t){const e=t.parentNode;e&&e.removeChild(t)},empty(t){for(;t.firstChild;)t.removeChild(t.firstChild)},toFront(t){const e=t.parentNode;e&&e.lastChild!==t&&e.appendChild(t)},toBack(t){const e=t.parentNode;e&&e.firstChild!==t&&e.insertBefore(t,e.firstChild)},getClass(t){return((t==null?void 0:t.host)||t).className.toString()},hasClass(t,e){var s;if((s=t.classList)!=null&&s.contains(e))return!0;const n=this.getClass(t);return n.length>0&&new RegExp(`(^|\\s)${e}(\\s|$)`).test(n)},addClass(t,e){if(t.classList!==void 0){const n=A(e);for(let s=0,r=n.length;s<r;s++)t.classList.add(n[s])}else if(!this.hasClass(t,e)){const n=this.getClass(t);this.setClass(t,(n?n+" ":"")+e)}},removeClass(t,e){t.classList!==void 0?A(e).forEach(s=>t.classList.remove(s)):this.setClass(t,(" "+this.getClass(t)+" ").replace(" "+e+" "," ").trim())},setClass(t,e){"classList"in t&&(t.classList.value="",e.split(" ").forEach(n=>t.classList.add(n)))},parseFromString(t){return new DOMParser().parseFromString(t,"text/xml").children[0]}},B={toRadian:Math.PI/180,R:6371393,isLnglat(t,e){return!isNaN(t)&&!isNaN(e)&&+e>-90&&+e<90&&+t>-180&&+t<180},distance(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))},distanceByPoints(t,e){const{lng:n,lat:s}=t,{lng:r,lat:i}=e,a=6371e3,o=Math.cos(s*Math.PI/180)*Math.cos(i*Math.PI/180)*Math.cos((n-r)*Math.PI/180),c=Math.sin(s*Math.PI/180)*Math.sin(i*Math.PI/180);let l=o+c;return l>1&&(l=1),l<-1&&(l=-1),Math.acos(l)*a},formatLnglat(t,e){let n="";function s(r){const i=Math.floor(r),a=Math.floor((r-i)*60),o=(r-i)*3600-a*60;return`${i}°${a}′${o.toFixed(2)}″`}return this.isLnglat(t,e)?n=s(t)+","+s(e):isNaN(t)?isNaN(e)||(n=s(e)):n=s(t),n},transformLnglat(t,e){function n(s){let i=/[sw]/i.test(s)?-1:1;const a=s.match(/[\d.]+/g)||[];let o=0;for(let c=0;c<a.length;c++)o+=parseFloat(a[c])/i,i*=60;return o}if(t&&e)return{lng:n(t),lat:n(e)}},rayCasting(t,e){for(var n=t.x,s=t.y,r=!1,i=0,a=e.length,o=a-1;i<a;o=i,i++){var c=e[i].x,l=e[i].y,u=e[o].x,d=e[o].y;if(c===n&&l===s||u===n&&d===s)return"on";if(l<s&&d>=s||l>=s&&d<s){var f=c+(s-l)*(u-c)/(d-l);if(f===n)return"on";f>n&&(r=!r)}}return r?"in":"out"},rotatePoint(t,e,n){const s=(t.x-e.x)*Math.cos(Math.PI/180*-n)-(t.y-e.y)*Math.sin(Math.PI/180*-n)+e.x,r=(t.x-e.x)*Math.sin(Math.PI/180*-n)+(t.y-e.y)*Math.cos(Math.PI/180*-n)+e.y;return{x:s,y:r}},calcBearAndDis(t,e){const{x:n,y:s}=t,{x:r,y:i}=e,a=r-n,o=i-s,c=Math.sqrt(a*a+o*o);return{angle:(Math.atan2(o,a)*(180/Math.PI)+360+90)%360,distance:c}},calcBearAndDisByPoints(t,e){var n=t.lat*1,s=t.lng*1,r=e.lat*1,i=e.lng*1,a=Math.sin((i-s)*this.toRadian)*Math.cos(r*this.toRadian),o=Math.cos(n*this.toRadian)*Math.sin(r*this.toRadian)-Math.sin(n*this.toRadian)*Math.cos(r*this.toRadian)*Math.cos((i-s)*this.toRadian),c=Math.atan2(a,o)*(180/Math.PI),l=(r-n)*this.toRadian,u=(i-s)*this.toRadian,d=Math.sin(l/2)*Math.sin(l/2)+Math.cos(n*this.toRadian)*Math.cos(r*this.toRadian)*Math.sin(u/2)*Math.sin(u/2),f=2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)),E=this.R*f;return{angle:c,distance:E}},distanceToSegment(t,e,n){const s=t.x,r=t.y,i=e.x,a=e.y,o=n.x,c=n.y,l=(o-i)*(s-i)+(c-a)*(r-a);if(l<=0)return Math.sqrt((s-i)*(s-i)+(r-a)*(r-a));const u=(o-i)*(o-i)+(c-a)*(c-a);if(l>=u)return Math.sqrt((s-o)*(s-o)+(r-c)*(r-c));const d=l/u,f=i+(o-i)*d,E=a+(c-a)*d;return Math.sqrt((s-f)*(s-f)+(r-E)*(r-E))},calcPointByBearAndDis(t,e,n){const s=y.toRadians(t.lat*1),r=y.toRadians(t.lng*1),i=n/this.R;e=y.toRadians(e);const a=Math.asin(Math.sin(s)*Math.cos(i)+Math.cos(s)*Math.sin(i)*Math.cos(e)),o=r+Math.atan2(Math.sin(e)*Math.sin(i)*Math.cos(s),Math.cos(i)-Math.sin(s)*Math.sin(a));return{lat:y.toDegrees(a),lng:y.toDegrees(o)}},mercatorTolonlat(t,e){const n=t/2003750834e-2*180;var s=e/2003750834e-2*180;const r=180/Math.PI*(2*Math.atan(Math.exp(s*Math.PI/180))-Math.PI/2);return{lng:n,lat:r}},lonlatToMercator(t,e){var n=6378137;const s=t*Math.PI/180*n;var r=e*Math.PI/180;const i=n/2*Math.log((1+Math.sin(r))/(1-Math.sin(r)));return{x:s,y:i}}},q={deepClone(t){return structuredClone(t)},isEqual(t,e){return JSON.stringify(t)===JSON.stringify(e)}},G={convertBase64ToBlob(t){const e=t.split(",")[0].split(":")[1].split(";")[0],n=atob(t.split(",")[1]),s=new Array(n.length);for(let a=0;a<n.length;a++)s[a]=n.charCodeAt(a);const r=new Uint8Array(s);return new Blob([r],{type:e})},convertUrlToBase64(t,e,n){return new Promise((s,r)=>{var i=new Image;i.crossOrigin="Anonymous",i.src=t,i.onload=function(){var a=document.createElement("canvas");a.width=e||i.width,a.height=n||i.height;var o=a.getContext("2d");if(!o){r(new Error("Failed to get canvas context"));return}o.drawImage(i,0,0,i.width,i.height);var c=i.src.substring(i.src.lastIndexOf(".")+1).toLowerCase(),l=a.toDataURL("image/"+c),u={dataURL:l,type:"image/"+c,ext:c};s(u)},i.onerror=r})},convertBase64ToFile(t,e){const n=t.split(","),s=n[0].match(/:(.*?);/),r=s?s[1]:"image/png",i=atob(n[1]),a=new Uint8Array(i.length);for(let c=0;c<i.length;c++)a[c]=i.charCodeAt(c);return new File([a],e,{type:r})},downloadFromFile(t,e){if(typeof t=="object")if(t instanceof Blob)t=URL.createObjectURL(t);else{const s=JSON.stringify(t),r=new Blob([s],{type:"text/json"});t=window.URL.createObjectURL(r)}else if(typeof t=="string"&&t.indexOf("http")===-1){const s=new Blob([t],{type:"text/json"});t=window.URL.createObjectURL(s)}var n=document.createElement("a");n.href=t,n.download=e||"",n.click(),window.URL.revokeObjectURL(n.href)}},W={debounce(t,e,n=!0){let s=null,r,i,a;const o=()=>{const c=Date.now()-i;c<e&&c>0?s=setTimeout(o,e-c):(s=null,n||(a=t.apply(this,r)))};return(...c)=>{i=Date.now();const l=n&&!s;return s||(s=setTimeout(o,e)),l&&(a=t.apply(this,c),s||(c=null)),a}},throttle(t,e,n=1){let s=0,r=null;return(...i)=>{if(n===1){const a=Date.now();a-s>=e&&(t.apply(this,i),s=a)}else n===2&&(r||(r=setTimeout(()=>{r=null,t.apply(this,i)},e)))}},memoize(t){const e=new Map;return(...n)=>{const s=JSON.stringify(n);if(e.has(s))return e.get(s);{const r=t.apply(this,n);return e.set(s,r),r}}},recurve(t,e=500,n=5e3){let s=0;setTimeout(()=>{s++,s<Math.floor(n/e)&&(t.call(this),setTimeout(this.recurve.bind(this,t,e,n),e))},e)}},H={checkStr(t,e){switch(e){case"phone":return/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(t);case"tel":return/^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(t);case"card":return/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(t);case"pwd":return/^[a-zA-Z]\w{5,17}$/.test(t);case"postal":return/[1-9]\d{5}(?!\d)/.test(t);case"QQ":return/^[1-9][0-9]{4,9}$/.test(t);case"email":return/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(t);case"money":return/^\d*(?:\.\d{0,2})?$/.test(t);case"URL":return/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(t);case"IP":return/((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(t);case"date":return/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(t)||/^(\d{4})\-(\d{2})\-(\d{2})$/.test(t);case"number":return/^[0-9]$/.test(t);case"english":return/^[a-zA-Z]+$/.test(t);case"chinese":return/^[\u4E00-\u9FA5]+$/.test(t);case"lower":return/^[a-z]+$/.test(t);case"upper":return/^[A-Z]+$/.test(t);case"HTML":return/<("[^"]*"|'[^']*'|[^'">])*>/.test(t);default:return!0}},changeCase(t,e){switch(e=e||4,e){case 1:return t.replace(/\b\w+\b/g,function(n){return n.substring(0,1).toUpperCase()+n.substring(1).toLowerCase()});case 2:return t.replace(/\b\w+\b/g,function(n){return n.substring(0,1).toLowerCase()+n.substring(1).toUpperCase()});case 3:return t.split("").map(function(n){return/[a-z]/.test(n)?n.toUpperCase():n.toLowerCase()}).join("");case 4:return t.toUpperCase();case 5:return t.toLowerCase();default:return t}},tag(t,...e){return e=e.map(n=>{switch(R.getDataType(n)){case"Object":return n||"{}";case"Array":return n||"[]";default:return n||""}}),t.reduce((n,s,r)=>`${n}${e[r-1]}${s}`)},getByteLength(t){return t.replace(/[\u0391-\uFFE5]/g,"aa").length},subStringByte(t,e,n){var s=/[^\x00-\xff]/g;if(t.replace(s,"mm").length<=n)return t;for(var r=Math.floor(n/2),i=r;i<t.length;i++){let a=t.substring(e,i);if(a.replace(s,"mm").length>=n)return a}return t},asString(t){if(R.isEmpty(t))return"";switch(R.getDataType(t)){case"Object":case"Array":return JSON.stringify(t);default:return t}}},m=class m{static set(e,n=null,s=null){var r=this._getPrefixedKey(e,s);try{localStorage.setItem(r,JSON.stringify({data:n}))}catch{console&&console.warn("StoreUtil didn't successfully save the '{"+e+": "+n+"}' pair, because the localStorage is full.")}}static get(e,n,s){var r=this._getPrefixedKey(e,s),i;try{i=JSON.parse(localStorage.getItem(r)||"")}catch{localStorage[r]?i={data:localStorage.getItem(r)}:i=null}if(i){if(typeof i=="object"&&typeof i.data<"u")return i.data}else return n}static keys(){const e=[];var n=Object.keys(localStorage);return m.prefix.length===0?n:(n.forEach(function(s){s.indexOf(m.prefix)!==-1&&e.push(s.replace(m.prefix,""))}),e)}static getAll(e){var n=m.keys();if(e){const s=[];return n.forEach(r=>{if(e.includes(r)){const i={};i[r]=m.get(r,null,null),s.push(i)}}),s}return n.map(s=>m.get(s,null,null))}static remove(e,n){var s=this._getPrefixedKey(e,n);localStorage.removeItem(s)}static clear(e){m.prefix.length?this.keys().forEach(n=>{localStorage.removeItem(this._getPrefixedKey(n,e))}):localStorage.clear()}};p(m,"prefix",""),p(m,"_getPrefixedKey",function(e,n){return n=n||{},n.noPrefix?e:m.prefix+e});let S=m;const j={json2Query(t){var e=[];for(var n in t)if(t.hasOwnProperty(n)){var s=n,r=t[n];e.push(encodeURIComponent(s)+"="+encodeURIComponent(r))}var i=e.join("&");return i},query2Json(t=window.location.href,e=!0){const n=/([^&=]+)=([\w\W]*?)(&|$|#)/g,{search:s,hash:r}=new URL(t),i=[s,r];let a={};for(let o=0;o<i.length;o++){const c=i[o];if(c){const u=c.replace(/#|\//g,"").split("?");if(u.length>1)for(let d=1;d<u.length;d++){let f;for(;f=n.exec(u[d]);)a[f[1]]=e?decodeURIComponent(f[2]):f[2]}}}return a}};h.ArrayUtil=_,h.AudioPlayer=T,h.BrowserUtil=P,h.CanvasDrawer=I,h.ColorUtil=k,h.Cookie=L,h.CoordsUtil=U,h.DateUtil=N,h.DomUtil=$,h.ErrorType=M,h.EventDispatcher=D,h.EventType=g,h.FileUtil=G,h.GeoUtil=B,h.GraphicType=x,h.HashMap=w,h.JsonUtil=q,h.LayerType=O,h.MathUtil=y,h.MeasureMode=C,h.ObjectState=b,h.OptimizeUtil=W,h.StoreUtil=S,h.StringUtil=H,h.UrlUtil=j,h.Util=R,h.WebSocketClient=v,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types.d.ts
ADDED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
/**
|
|
3
|
-
* 从 URL 中解析出查询参数和哈希参数,并以对象的形式返回
|
|
4
|
-
*
|
|
5
|
-
* @param href 需要解析的 URL 链接,默认为当前窗口的 URL
|
|
6
|
-
* @param needDecode 是否需要解码参数值,默认为 true
|
|
7
|
-
* @returns 返回一个包含解析后参数的对象,其中键为参数名,值为参数值
|
|
8
|
-
*/
|
|
9
|
-
getUrlParams(href?: string, needDecode?: boolean): Record<string, string>;
|
|
10
2
|
/**
|
|
11
3
|
* 获取浏览器类型
|
|
12
4
|
*
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
lng: number;
|
|
3
|
-
lat: number;
|
|
4
|
-
}
|
|
1
|
+
import { LngLat } from '../types';
|
|
5
2
|
declare const _default: {
|
|
6
3
|
PI: number;
|
|
7
4
|
XPI: number;
|
|
8
|
-
delta(lat: number, lng: number):
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
delta(lat: number, lng: number): LngLat;
|
|
6
|
+
/**
|
|
7
|
+
* 判断经纬度是否不在中国境内
|
|
8
|
+
*
|
|
9
|
+
* @param lng 经度
|
|
10
|
+
* @param lat 纬度
|
|
11
|
+
* @returns 如果经纬度不在中国境内则返回true,否则返回false
|
|
12
|
+
*/
|
|
13
|
+
outOfChina(lng: number, lat: number): boolean;
|
|
14
|
+
gcjEncrypt(wgsLat: number, wgsLon: number): LngLat;
|
|
15
|
+
gcjDecrypt(gcjLat: number, gcjLon: number): LngLat;
|
|
16
|
+
gcjDecryptExact(gcjLat: number, gcjLon: number): LngLat;
|
|
17
|
+
bdEncrypt(gcjLat: number, gcjLon: number): LngLat;
|
|
13
18
|
bdDecrypt(bdLat: number, bdLon: number): {
|
|
14
19
|
lat: number;
|
|
15
20
|
lng: number;
|
|
16
21
|
};
|
|
17
|
-
mercatorEncrypt(wgsLat: number, wgsLon: number):
|
|
18
|
-
mercatorDecrypt(mercatorLat: number, mercatorLon: number):
|
|
22
|
+
mercatorEncrypt(wgsLat: number, wgsLon: number): LngLat;
|
|
23
|
+
mercatorDecrypt(mercatorLat: number, mercatorLon: number): LngLat;
|
|
19
24
|
transformLat(x: number, y: number): number;
|
|
20
25
|
transformLon(x: number, y: number): number;
|
|
21
|
-
randomCoordinate(minX: number, minY: number, maxX: number, maxY: number):
|
|
26
|
+
randomCoordinate(minX: number, minY: number, maxX: number, maxY: number): LngLat;
|
|
22
27
|
};
|
|
23
28
|
export default _default;
|
package/dist/utils/GeoUtil.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
4
|
-
};
|
|
5
|
-
type LngLat = {
|
|
6
|
-
lng: number;
|
|
7
|
-
lat: number;
|
|
8
|
-
};
|
|
1
|
+
import { Coordinate, LngLat } from '../types';
|
|
9
2
|
declare const _default: {
|
|
10
3
|
toRadian: number;
|
|
11
4
|
R: number;
|
|
@@ -17,14 +10,6 @@ declare const _default: {
|
|
|
17
10
|
* @returns 如果经纬度合法,返回true;否则返回false
|
|
18
11
|
*/
|
|
19
12
|
isLnglat(lng: number, lat: number): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* 判断经纬度是否不在中国境内
|
|
22
|
-
*
|
|
23
|
-
* @param lng 经度
|
|
24
|
-
* @param lat 纬度
|
|
25
|
-
* @returns 如果经纬度不在中国境内则返回true,否则返回false
|
|
26
|
-
*/
|
|
27
|
-
outOfChina({ lng, lat }: LngLat): boolean;
|
|
28
13
|
/**
|
|
29
14
|
* 计算两哥平面坐标点间的距离
|
|
30
15
|
*
|
package/dist/utils/UrlUtil.d.ts
CHANGED
|
@@ -8,8 +8,13 @@ declare const _default: {
|
|
|
8
8
|
json2Query(json: {
|
|
9
9
|
[x: string]: any;
|
|
10
10
|
}): string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 从 URL 中解析出查询参数和哈希参数,并以对象的形式返回
|
|
13
|
+
*
|
|
14
|
+
* @param href 需要解析的 URL 链接,默认为当前窗口的 URL
|
|
15
|
+
* @param needDecode 是否需要解码参数值,默认为 true
|
|
16
|
+
* @returns 返回一个包含解析后参数的对象,其中键为参数名,值为参数值
|
|
17
|
+
*/
|
|
18
|
+
query2Json(href?: string, needDecode?: boolean): Record<string, string>;
|
|
14
19
|
};
|
|
15
20
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gis-common",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"author": "Guo.Yan <luv02@vip.qq.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -17,13 +17,6 @@
|
|
|
17
17
|
"require": "./dist/gis-common.umd.js"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
"typesVersions": {
|
|
21
|
-
"*": {
|
|
22
|
-
".": [
|
|
23
|
-
"./dist/index.d.ts"
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
20
|
"scripts": {
|
|
28
21
|
"dev": "vite",
|
|
29
22
|
"lib": "vite build --mode lib",
|