@vsleem-realsee-viewer/shared 2.0.7 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +28 -3
- package/dist/index.mjs +245 -182
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -450,6 +450,17 @@ export declare enum CoordinateType {
|
|
|
450
450
|
Data = 2
|
|
451
451
|
}
|
|
452
452
|
|
|
453
|
+
export declare class DataHelper {
|
|
454
|
+
/**
|
|
455
|
+
* 将源坐标系中的点转换到目标坐标系中
|
|
456
|
+
* @param points 需要转换的点数组
|
|
457
|
+
* @param srcCoordinate 源坐标系
|
|
458
|
+
* @param dstCoordinate 目标坐标系
|
|
459
|
+
* @returns 转换后的点数组
|
|
460
|
+
*/
|
|
461
|
+
static srcPointToDstPoint(points: Point[], srcCoordinate: Coordinate, dstCoordinate: Coordinate): Point[];
|
|
462
|
+
}
|
|
463
|
+
|
|
453
464
|
export declare class DataSource {
|
|
454
465
|
/**
|
|
455
466
|
* 获取坐标系树
|
|
@@ -555,6 +566,14 @@ export declare class GeoPoint {
|
|
|
555
566
|
|
|
556
567
|
declare function getCoordinateList(params?: Record<string, any>, options?: RequestOptions): Promise<CoordinateModel[]>;
|
|
557
568
|
|
|
569
|
+
/**
|
|
570
|
+
* 获取两个对象之间的差异。
|
|
571
|
+
* @param newObj 新对象
|
|
572
|
+
* @param oldObj 原始对象
|
|
573
|
+
* @returns 返回一个包含差异的对象,新增或修改的字段包含新值,删除的字段设为 undefined
|
|
574
|
+
*/
|
|
575
|
+
declare function getDiffProps(newObj?: Record<string, any>, oldObj?: Record<string, any>): Record<string, any>;
|
|
576
|
+
|
|
558
577
|
declare function getImageInfo(url: string, options?: RequestOptions): Promise<any>;
|
|
559
578
|
|
|
560
579
|
/**
|
|
@@ -614,8 +633,6 @@ declare function isNullOrUnDef(val: unknown): val is null | undefined;
|
|
|
614
633
|
|
|
615
634
|
declare function isNumber(val: unknown): val is number;
|
|
616
635
|
|
|
617
|
-
declare function isNumeric(val: number | string): val is string;
|
|
618
|
-
|
|
619
636
|
declare function isObject(val: any): val is Record<any, any>;
|
|
620
637
|
|
|
621
638
|
declare function isPromise<T = any>(val: unknown): val is Promise<T>;
|
|
@@ -630,6 +647,13 @@ declare function isUnDef<T = unknown>(val?: T): val is T;
|
|
|
630
647
|
|
|
631
648
|
declare function isWindow(val: any): val is Window;
|
|
632
649
|
|
|
650
|
+
/**
|
|
651
|
+
* 动态加载外部 CSS 文件并返回一个 Promise
|
|
652
|
+
* @param src - CSS 文件的 URL(建议使用 HTTPS)
|
|
653
|
+
* @returns Promise<boolean> - 解析表示加载成功,拒绝表示加载失败
|
|
654
|
+
*/
|
|
655
|
+
declare function loadCss(src: string): Promise<unknown>;
|
|
656
|
+
|
|
633
657
|
/**
|
|
634
658
|
* 动态加载 JavaScript 脚本
|
|
635
659
|
* @param src 脚本的 URL 地址
|
|
@@ -934,7 +958,6 @@ declare namespace utils {
|
|
|
934
958
|
isArray,
|
|
935
959
|
isWindow,
|
|
936
960
|
isElement,
|
|
937
|
-
isNumeric,
|
|
938
961
|
isNumber,
|
|
939
962
|
isSameValue,
|
|
940
963
|
isNullOrUnDef,
|
|
@@ -945,7 +968,9 @@ declare namespace utils {
|
|
|
945
968
|
throttle,
|
|
946
969
|
deepMerge,
|
|
947
970
|
deepMergeProps,
|
|
971
|
+
getDiffProps,
|
|
948
972
|
loadScript,
|
|
973
|
+
loadCss,
|
|
949
974
|
getImageTransform,
|
|
950
975
|
toCanvasCoord,
|
|
951
976
|
toModelCoord,
|
package/dist/index.mjs
CHANGED
|
@@ -12,50 +12,50 @@ class m extends Error {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
var
|
|
16
|
-
const
|
|
15
|
+
var D = /* @__PURE__ */ ((s) => (s[s.CADModel = 5] = "CADModel", s[s.BIMModel = 6] = "BIMModel", s[s.ForgeModel = 7] = "ForgeModel", s[s.ThreeDModel = 8] = "ThreeDModel", s[s.SkyMapModel = 9] = "SkyMapModel", s[s.ScaleModel = 10] = "ScaleModel", s))(D || {}), tt = /* @__PURE__ */ ((s) => (s[s.Global = 0] = "Global", s))(tt || {}), v = /* @__PURE__ */ ((s) => (s[s.Space = 0] = "Space", s[s.Model = 1] = "Model", s[s.Data = 2] = "Data", s))(v || {}), C = /* @__PURE__ */ ((s) => (s[s.Used = 0] = "Used", s[s.Enabled = 1] = "Enabled", s[s.Disabled = 2] = "Disabled", s))(C || {}), F = /* @__PURE__ */ ((s) => (s[s.SUCCESS = 200] = "SUCCESS", s[s.ERROR = -1] = "ERROR", s[s.TIMEOUT = 401] = "TIMEOUT", s))(F || {}), M = /* @__PURE__ */ ((s) => (s.GET = "GET", s.POST = "POST", s))(M || {}), R = /* @__PURE__ */ ((s) => (s.JSON = "application/json", s.FORM_URLENCODED = "application/x-www-form-urlencoded;charset=UTF-8", s.FORM_DATA = "multipart/form-data;charset=UTF-8", s.OCTET_STREAM = "'application/octet-stream", s))(R || {}), et = /* @__PURE__ */ ((s) => (s.Hw = "huawei", s.Ali = "aliyun", s.Hs = "hs", s.Aws = "amazon", s.Minio = "minio", s))(et || {}), y = /* @__PURE__ */ ((s) => (s[s.GeoPointNoPlane = 9e3] = "GeoPointNoPlane", s[s.PointUnmappedGIS = 9010] = "PointUnmappedGIS", s[s.PointNoXYZ = 9011] = "PointNoXYZ", s[s.PointNoPlane = 9012] = "PointNoPlane", s[s.RelativePlaneUnmatch = 9020] = "RelativePlaneUnmatch", s[s.RelativeNoPlane = 9021] = "RelativeNoPlane", s[s.RelativeJsonError = 9022] = "RelativeJsonError", s[s.RequestCodeError = 9030] = "RequestCodeError", s[s.RequestResultError = 9031] = "RequestResultError", s[s.RequestUnknownError = 9032] = "RequestUnknownError", s))(y || {});
|
|
16
|
+
const st = {
|
|
17
17
|
baseUrl: "https://vsleem.com/api",
|
|
18
18
|
obsType: "hs",
|
|
19
19
|
authorizeCode: ""
|
|
20
|
-
},
|
|
20
|
+
}, it = {
|
|
21
21
|
isTransformResponse: !0,
|
|
22
22
|
joinBaseUrl: !0,
|
|
23
23
|
withAuthorize: !0
|
|
24
|
-
},
|
|
24
|
+
}, nt = {
|
|
25
25
|
url: "",
|
|
26
|
-
method:
|
|
26
|
+
method: M.GET,
|
|
27
27
|
headers: {}
|
|
28
|
-
}, U = { ...
|
|
29
|
-
function
|
|
28
|
+
}, U = { ...st };
|
|
29
|
+
function ot(s) {
|
|
30
30
|
Object.assign(U, s);
|
|
31
31
|
}
|
|
32
|
-
async function
|
|
33
|
-
const e = { ...
|
|
32
|
+
async function T(s, t) {
|
|
33
|
+
const e = { ...it, ...t }, i = { ...nt, ...s };
|
|
34
34
|
try {
|
|
35
|
-
const n =
|
|
36
|
-
return
|
|
35
|
+
const n = rt(i, e), { url: o, ...r } = n, h = await (await window.fetch(o, r)).json();
|
|
36
|
+
return at(h, e);
|
|
37
37
|
} catch (n) {
|
|
38
|
-
return
|
|
38
|
+
return ht(n);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function rt(s, t) {
|
|
42
42
|
const { baseUrl: e, authorizeCode: i } = U, { joinBaseUrl: n, withAuthorize: o } = t;
|
|
43
43
|
let { url: r, method: a, headers: h = {}, params: l, data: c } = s;
|
|
44
44
|
n && e && (r = `${e}${r}`), a = a?.toUpperCase();
|
|
45
45
|
const u = { ...h };
|
|
46
|
-
if (/^https?:\/\/.+$/i.test(e ?? "") ? u.PlatForm = new URL(e ?? "").host : u.PlatForm = new URL(window.location.href).host, o && i && (u.AuthorizationCode = i), a ===
|
|
46
|
+
if (/^https?:\/\/.+$/i.test(e ?? "") ? u.PlatForm = new URL(e ?? "").host : u.PlatForm = new URL(window.location.href).host, o && i && (u.AuthorizationCode = i), a === M.POST && !u["Content-Type"] && (u["Content-Type"] = R.JSON), a === M.GET && l) {
|
|
47
47
|
const p = new URLSearchParams(l);
|
|
48
48
|
r += `?${p.toString()}`;
|
|
49
49
|
}
|
|
50
50
|
let d;
|
|
51
|
-
return a ===
|
|
51
|
+
return a === M.POST && (d = u["Content-Type"] === R.JSON ? JSON.stringify(c || {}) : c), {
|
|
52
52
|
url: r,
|
|
53
53
|
method: a,
|
|
54
54
|
headers: u,
|
|
55
55
|
body: d
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function at(s, t) {
|
|
59
59
|
if (!t.isTransformResponse)
|
|
60
60
|
return s;
|
|
61
61
|
if (!s)
|
|
@@ -65,102 +65,102 @@ function rt(s, t) {
|
|
|
65
65
|
return i;
|
|
66
66
|
throw new m(y.RequestCodeError, n || "请求返回的Code错误");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function ht(s) {
|
|
69
69
|
throw s instanceof Error ? s : new m(
|
|
70
70
|
y.RequestUnknownError,
|
|
71
71
|
typeof s == "string" ? s : "未知的请求错误"
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
|
-
const
|
|
74
|
+
const Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
75
75
|
__proto__: null,
|
|
76
|
-
request:
|
|
77
|
-
setRequestGlobalConfig:
|
|
76
|
+
request: T,
|
|
77
|
+
setRequestGlobalConfig: ot
|
|
78
78
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
79
79
|
function Y(s, t) {
|
|
80
|
-
return
|
|
80
|
+
return T(
|
|
81
81
|
{
|
|
82
82
|
url: "/project/jssdk/cs/list",
|
|
83
|
-
method:
|
|
83
|
+
method: M.GET,
|
|
84
84
|
params: s
|
|
85
85
|
},
|
|
86
86
|
t
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
return
|
|
89
|
+
function G(s, t) {
|
|
90
|
+
return T(
|
|
91
91
|
{
|
|
92
92
|
url: "/project/jssdk/cs/bind",
|
|
93
|
-
method:
|
|
93
|
+
method: M.POST,
|
|
94
94
|
data: s
|
|
95
95
|
},
|
|
96
96
|
t
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
return
|
|
99
|
+
function O(s, t) {
|
|
100
|
+
return T(
|
|
101
101
|
{
|
|
102
102
|
url: "/project/jssdk/cs/save",
|
|
103
|
-
method:
|
|
103
|
+
method: M.POST,
|
|
104
104
|
data: s
|
|
105
105
|
},
|
|
106
106
|
t
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
return
|
|
109
|
+
function B(s, t) {
|
|
110
|
+
return T(
|
|
111
111
|
{
|
|
112
112
|
url: "/project/jssdk/cs/delete",
|
|
113
|
-
method:
|
|
113
|
+
method: M.POST,
|
|
114
114
|
data: s
|
|
115
115
|
},
|
|
116
116
|
t
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
119
|
function $(s, t) {
|
|
120
|
-
return
|
|
120
|
+
return T(
|
|
121
121
|
{
|
|
122
122
|
url: "/project/jssdk/cs/mapping",
|
|
123
|
-
method:
|
|
123
|
+
method: M.POST,
|
|
124
124
|
data: s
|
|
125
125
|
},
|
|
126
126
|
t
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
129
|
function _(s, t) {
|
|
130
|
-
return
|
|
130
|
+
return T(
|
|
131
131
|
{
|
|
132
132
|
url: "/project/jssdk/cs/mapping/query",
|
|
133
|
-
method:
|
|
133
|
+
method: M.GET,
|
|
134
134
|
params: s
|
|
135
135
|
},
|
|
136
136
|
t
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function ct(s, t = {
|
|
140
140
|
isTransformResponse: !1,
|
|
141
141
|
joinBaseUrl: !1,
|
|
142
142
|
withAuthorize: !1
|
|
143
143
|
}) {
|
|
144
|
-
return
|
|
144
|
+
return T(
|
|
145
145
|
{
|
|
146
146
|
url: s,
|
|
147
|
-
method:
|
|
147
|
+
method: M.GET
|
|
148
148
|
},
|
|
149
149
|
t
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
|
-
const
|
|
152
|
+
const Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
153
153
|
__proto__: null,
|
|
154
|
-
bindCoordinate:
|
|
154
|
+
bindCoordinate: G,
|
|
155
155
|
getCoordinateList: Y,
|
|
156
|
-
getImageInfo:
|
|
156
|
+
getImageInfo: ct,
|
|
157
157
|
getMappingRelation: _,
|
|
158
158
|
mapingCoordinate: $,
|
|
159
|
-
removeCoordinate:
|
|
160
|
-
saveCoordinate:
|
|
161
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
162
|
-
function
|
|
163
|
-
return
|
|
159
|
+
removeCoordinate: B,
|
|
160
|
+
saveCoordinate: O
|
|
161
|
+
}, Symbol.toStringTag, { value: "Module" })), lt = typeof window < "u", ut = Object.prototype.toString;
|
|
162
|
+
function P(s, t) {
|
|
163
|
+
return ut.call(s) === `[object ${t}]`;
|
|
164
164
|
}
|
|
165
165
|
function Z(s) {
|
|
166
166
|
return typeof s < "u";
|
|
@@ -168,41 +168,38 @@ function Z(s) {
|
|
|
168
168
|
function q(s) {
|
|
169
169
|
return !Z(s);
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
return s !== null &&
|
|
171
|
+
function S(s) {
|
|
172
|
+
return s !== null && P(s, "Object");
|
|
173
173
|
}
|
|
174
174
|
function J(s) {
|
|
175
175
|
return s === null;
|
|
176
176
|
}
|
|
177
|
-
function ut(s) {
|
|
178
|
-
return v(s, "Date");
|
|
179
|
-
}
|
|
180
177
|
function dt(s) {
|
|
181
|
-
return
|
|
182
|
-
}
|
|
183
|
-
function O(s) {
|
|
184
|
-
return typeof s == "function";
|
|
178
|
+
return P(s, "Date");
|
|
185
179
|
}
|
|
186
180
|
function ft(s) {
|
|
187
|
-
return
|
|
181
|
+
return P(s, "String");
|
|
188
182
|
}
|
|
189
|
-
function
|
|
190
|
-
return
|
|
183
|
+
function L(s) {
|
|
184
|
+
return typeof s == "function";
|
|
191
185
|
}
|
|
192
|
-
function
|
|
193
|
-
return s
|
|
186
|
+
function mt(s) {
|
|
187
|
+
return P(s, "Boolean");
|
|
194
188
|
}
|
|
195
189
|
function yt(s) {
|
|
196
|
-
return
|
|
190
|
+
return P(s, "RegExp");
|
|
191
|
+
}
|
|
192
|
+
function g(s) {
|
|
193
|
+
return s && Array.isArray(s);
|
|
197
194
|
}
|
|
198
195
|
function wt(s) {
|
|
199
|
-
return
|
|
196
|
+
return typeof window < "u" && P(s, "Window");
|
|
200
197
|
}
|
|
201
198
|
function pt(s) {
|
|
202
|
-
return
|
|
199
|
+
return S(s) && !!s.tagName;
|
|
203
200
|
}
|
|
204
|
-
function
|
|
205
|
-
return
|
|
201
|
+
function b(s) {
|
|
202
|
+
return typeof s == "number" || /^\d+(\.\d+)?$/.test(String(s ?? ""));
|
|
206
203
|
}
|
|
207
204
|
function gt(s, t) {
|
|
208
205
|
return JSON.stringify(s) === JSON.stringify(t);
|
|
@@ -211,12 +208,12 @@ function xt(s) {
|
|
|
211
208
|
return q(s) || J(s);
|
|
212
209
|
}
|
|
213
210
|
function Mt(s) {
|
|
214
|
-
return
|
|
211
|
+
return P(s, "Promise") && S(s) && L(s.then) && L(s.catch);
|
|
215
212
|
}
|
|
216
213
|
function H(s) {
|
|
217
|
-
return
|
|
214
|
+
return E(s, /* @__PURE__ */ new WeakMap());
|
|
218
215
|
}
|
|
219
|
-
function
|
|
216
|
+
function E(s, t) {
|
|
220
217
|
if (typeof s != "object" || s === null)
|
|
221
218
|
return s;
|
|
222
219
|
if (t.has(s))
|
|
@@ -228,11 +225,11 @@ function T(s, t) {
|
|
|
228
225
|
return e = new RegExp(s), t.set(s, e), e;
|
|
229
226
|
if (s instanceof Map)
|
|
230
227
|
return e = /* @__PURE__ */ new Map(), t.set(s, e), s.forEach((n, o) => {
|
|
231
|
-
e.set(o,
|
|
228
|
+
e.set(o, E(n, t));
|
|
232
229
|
}), e;
|
|
233
230
|
if (s instanceof Set)
|
|
234
231
|
return e = /* @__PURE__ */ new Set(), t.set(s, e), s.forEach((n) => {
|
|
235
|
-
e.add(
|
|
232
|
+
e.add(E(n, t));
|
|
236
233
|
}), e;
|
|
237
234
|
if (ArrayBuffer.isView(s))
|
|
238
235
|
return e = new s.constructor(
|
|
@@ -245,15 +242,15 @@ function T(s, t) {
|
|
|
245
242
|
if (Array.isArray(s)) {
|
|
246
243
|
e = [], t.set(s, e);
|
|
247
244
|
for (let n = 0; n < s.length; n++)
|
|
248
|
-
n in s && (e[n] =
|
|
245
|
+
n in s && (e[n] = E(s[n], t));
|
|
249
246
|
return e;
|
|
250
247
|
}
|
|
251
248
|
e = Object.create(Object.getPrototypeOf(s)), t.set(s, e);
|
|
252
249
|
for (const n in s)
|
|
253
|
-
Object.prototype.hasOwnProperty.call(s, n) && (e[n] =
|
|
250
|
+
Object.prototype.hasOwnProperty.call(s, n) && (e[n] = E(s[n], t));
|
|
254
251
|
const i = Object.getOwnPropertySymbols(s);
|
|
255
252
|
for (const n of i)
|
|
256
|
-
Object.prototype.propertyIsEnumerable.call(s, n) && (e[n] =
|
|
253
|
+
Object.prototype.propertyIsEnumerable.call(s, n) && (e[n] = E(s[n], t));
|
|
257
254
|
return e;
|
|
258
255
|
}
|
|
259
256
|
function vt(s, t, e = !1) {
|
|
@@ -283,15 +280,15 @@ function bt(s, t, e = !1) {
|
|
|
283
280
|
clearTimeout(i), i = void 0, n = void 0;
|
|
284
281
|
}, o;
|
|
285
282
|
}
|
|
286
|
-
function
|
|
283
|
+
function k(s, ...t) {
|
|
287
284
|
if (!t.length) return s;
|
|
288
285
|
const e = t.shift();
|
|
289
|
-
return e === void 0 ? s : (
|
|
286
|
+
return e === void 0 ? s : (I(s) && I(e) && Object.keys(e).forEach((i) => {
|
|
290
287
|
const n = s[i], o = e[i];
|
|
291
|
-
Array.isArray(n) && Array.isArray(o) ? s[i] = [...n, ...o] :
|
|
292
|
-
}),
|
|
288
|
+
Array.isArray(n) && Array.isArray(o) ? s[i] = [...n, ...o] : I(n) && I(o) ? s[i] = k({ ...n }, o) : o !== void 0 && (s[i] = o);
|
|
289
|
+
}), k(s, ...t));
|
|
293
290
|
}
|
|
294
|
-
function
|
|
291
|
+
function I(s) {
|
|
295
292
|
return s !== null && typeof s == "object" && !Array.isArray(s);
|
|
296
293
|
}
|
|
297
294
|
function V(s, ...t) {
|
|
@@ -303,9 +300,30 @@ function V(s, ...t) {
|
|
|
303
300
|
});
|
|
304
301
|
return s;
|
|
305
302
|
}
|
|
303
|
+
function W(s, t) {
|
|
304
|
+
const e = {};
|
|
305
|
+
if (S(s) && !g(s)) {
|
|
306
|
+
for (const i in s)
|
|
307
|
+
if (Object.prototype.hasOwnProperty.call(s, i)) {
|
|
308
|
+
const n = s[i], o = S(t) && !g(t) ? t[i] : void 0;
|
|
309
|
+
if (!(i in (t || {})))
|
|
310
|
+
e[i] = n;
|
|
311
|
+
else if (g(n) && g(o))
|
|
312
|
+
JSON.stringify(n) !== JSON.stringify(o) && (e[i] = n);
|
|
313
|
+
else if (S(n) && S(o)) {
|
|
314
|
+
const r = W(n, o);
|
|
315
|
+
r && Object.keys(r).length > 0 && (e[i] = r);
|
|
316
|
+
} else n !== o && (e[i] = n);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (S(t) && g(t))
|
|
320
|
+
for (const i in t)
|
|
321
|
+
Object.prototype.hasOwnProperty.call(t, i) && !(i in (s || {})) && (e[i] = void 0);
|
|
322
|
+
return e;
|
|
323
|
+
}
|
|
306
324
|
function St(s, t = {}) {
|
|
307
325
|
return new Promise((e, i) => {
|
|
308
|
-
const n =
|
|
326
|
+
const n = z(s);
|
|
309
327
|
if (Tt(n)) {
|
|
310
328
|
e(!0);
|
|
311
329
|
return;
|
|
@@ -321,10 +339,29 @@ function St(s, t = {}) {
|
|
|
321
339
|
});
|
|
322
340
|
}
|
|
323
341
|
function Tt(s) {
|
|
324
|
-
const t =
|
|
325
|
-
return Array.from(document.scripts).some((e) =>
|
|
342
|
+
const t = z(s);
|
|
343
|
+
return Array.from(document.scripts).some((e) => z(e.src) === t);
|
|
326
344
|
}
|
|
327
|
-
function
|
|
345
|
+
function Pt(s) {
|
|
346
|
+
return new Promise((t, e) => {
|
|
347
|
+
const i = z(s);
|
|
348
|
+
if (Et(i)) {
|
|
349
|
+
t(!0);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const n = document.createElement("link");
|
|
353
|
+
n.rel = "stylesheet", n.type = "text/css", n.href = s, n.onload = () => {
|
|
354
|
+
t(!0);
|
|
355
|
+
}, n.onerror = () => {
|
|
356
|
+
document.head.removeChild(n), e(new Error(`Failed to load link: ${s}`));
|
|
357
|
+
}, document.head.appendChild(n);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
function Et(s) {
|
|
361
|
+
const t = z(s);
|
|
362
|
+
return Array.from(document.links).some((e) => z(e.href) === t);
|
|
363
|
+
}
|
|
364
|
+
function z(s) {
|
|
328
365
|
try {
|
|
329
366
|
const t = new URL(s, window.location.href);
|
|
330
367
|
return `${t.origin}${t.pathname}`;
|
|
@@ -332,7 +369,7 @@ function L(s) {
|
|
|
332
369
|
return s;
|
|
333
370
|
}
|
|
334
371
|
}
|
|
335
|
-
function
|
|
372
|
+
function Dt(s, t, e, i) {
|
|
336
373
|
const n = Math.min(s / e, t / i), o = e * n, r = i * n;
|
|
337
374
|
return {
|
|
338
375
|
scale: n,
|
|
@@ -344,7 +381,7 @@ function Pt(s, t, e, i) {
|
|
|
344
381
|
sh: r
|
|
345
382
|
};
|
|
346
383
|
}
|
|
347
|
-
function
|
|
384
|
+
function zt(s, t, e) {
|
|
348
385
|
return {
|
|
349
386
|
x: s * e.scale + e.x,
|
|
350
387
|
// 缩放后加上偏移量
|
|
@@ -358,44 +395,45 @@ function Nt(s, t, e) {
|
|
|
358
395
|
y: (t - e.y) / e.scale
|
|
359
396
|
};
|
|
360
397
|
}
|
|
361
|
-
function
|
|
398
|
+
function It(s) {
|
|
362
399
|
console.warn(`[warn]:${s}`);
|
|
363
400
|
}
|
|
364
|
-
function
|
|
401
|
+
function Ct(s) {
|
|
365
402
|
throw new Error(`[error]:${s}`);
|
|
366
403
|
}
|
|
367
|
-
const
|
|
404
|
+
const kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
368
405
|
__proto__: null,
|
|
369
406
|
cloneDeep: H,
|
|
370
407
|
debounce: vt,
|
|
371
|
-
deepMerge:
|
|
408
|
+
deepMerge: k,
|
|
372
409
|
deepMergeProps: V,
|
|
373
|
-
error:
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
410
|
+
error: Ct,
|
|
411
|
+
getDiffProps: W,
|
|
412
|
+
getImageTransform: Dt,
|
|
413
|
+
inBrowser: lt,
|
|
414
|
+
is: P,
|
|
415
|
+
isArray: g,
|
|
416
|
+
isBoolean: mt,
|
|
417
|
+
isDate: dt,
|
|
380
418
|
isDef: Z,
|
|
381
|
-
isElement:
|
|
382
|
-
isFunction:
|
|
419
|
+
isElement: pt,
|
|
420
|
+
isFunction: L,
|
|
383
421
|
isNull: J,
|
|
384
422
|
isNullOrUnDef: xt,
|
|
385
|
-
isNumber:
|
|
386
|
-
|
|
387
|
-
isObject: j,
|
|
423
|
+
isNumber: b,
|
|
424
|
+
isObject: S,
|
|
388
425
|
isPromise: Mt,
|
|
389
|
-
isRegExp:
|
|
426
|
+
isRegExp: yt,
|
|
390
427
|
isSameValue: gt,
|
|
391
|
-
isString:
|
|
428
|
+
isString: ft,
|
|
392
429
|
isUnDef: q,
|
|
393
|
-
isWindow:
|
|
430
|
+
isWindow: wt,
|
|
431
|
+
loadCss: Pt,
|
|
394
432
|
loadScript: St,
|
|
395
433
|
throttle: bt,
|
|
396
|
-
toCanvasCoord:
|
|
434
|
+
toCanvasCoord: zt,
|
|
397
435
|
toModelCoord: Nt,
|
|
398
|
-
warn:
|
|
436
|
+
warn: It
|
|
399
437
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
400
438
|
class f {
|
|
401
439
|
// 直角坐标系坐标
|
|
@@ -427,7 +465,7 @@ class f {
|
|
|
427
465
|
// 默认平面 ('xy' 或 'xz')
|
|
428
466
|
constructor(t) {
|
|
429
467
|
const { x: e, y: i, z: n, lat: o, lon: r, alt: a, yaw: h, pitch: l, roll: c, plane: u = "xy" } = t || {};
|
|
430
|
-
|
|
468
|
+
b(e) && b(i) && Number(e) !== 0 && Number(i) !== 0 && (this.x = Number(e) || 0, this.y = Number(i) || 0, this.z = Number(n) || 0, this.plane = u, this.hasXYZ = !0), b(o) && b(r) && Number(o) !== 0 && Number(r) !== 0 && (this.lat = Number(o) || 0, this.lon = Number(r) || 0, this.alt = Number(a) || 0, this.hasGeo = !0), (b(h) || b(l) || b(c)) && (this.yaw = Number(h) || 0, this.pitch = Number(l) || 0, this.roll = Number(c) || 0, this.hasAngle = !0);
|
|
431
469
|
}
|
|
432
470
|
/**
|
|
433
471
|
* 计算两点之间的三维距离
|
|
@@ -514,16 +552,21 @@ class f {
|
|
|
514
552
|
try {
|
|
515
553
|
if (e?.id === i?.id)
|
|
516
554
|
return new f(this);
|
|
517
|
-
if (e?.modelType ===
|
|
555
|
+
if (e?.modelType === D.SkyMapModel) {
|
|
518
556
|
const { refPoint: n } = e?.relativeMap || {};
|
|
557
|
+
if (this?.hasXYZ)
|
|
558
|
+
return this.project(t);
|
|
519
559
|
if (this.hasGeo && n) {
|
|
520
560
|
const o = N.LLHToXYZ(this, n);
|
|
521
561
|
return this.x = o.x, this.y = o.y, this.z = o.z, this.hasXYZ = !0, this.project(t);
|
|
522
562
|
}
|
|
523
563
|
throw new m(y.PointUnmappedGIS, "没有完成GIS与其他空间的映射");
|
|
524
564
|
}
|
|
525
|
-
if (i?.modelType ===
|
|
526
|
-
const { refPoint: n } = i?.relativeMap || {}
|
|
565
|
+
if (i?.modelType === D.SkyMapModel) {
|
|
566
|
+
const { refPoint: n } = i?.relativeMap || {};
|
|
567
|
+
if (this?.hasGeo)
|
|
568
|
+
return new f(this);
|
|
569
|
+
const o = this.project(t);
|
|
527
570
|
if (o?.hasXYZ && n) {
|
|
528
571
|
const r = N.XYZToLLH(o, n);
|
|
529
572
|
return o.lat = r.lat, o.lon = r.lon, o.alt = r.alt, o.hasGeo = !0, o;
|
|
@@ -620,7 +663,7 @@ class N {
|
|
|
620
663
|
throw new m(y.GeoPointNoPlane, "点的plane应为xz或xy");
|
|
621
664
|
}
|
|
622
665
|
}
|
|
623
|
-
class
|
|
666
|
+
class x {
|
|
624
667
|
scale = 1;
|
|
625
668
|
yaw = 0;
|
|
626
669
|
x = 0;
|
|
@@ -654,7 +697,7 @@ class g {
|
|
|
654
697
|
a = e.x + c * e.scale, h = e.y + u * e.scale, l = e.z + d * e.scale;
|
|
655
698
|
} else
|
|
656
699
|
throw new m(y.RelativeNoPlane, "映射关系的plane应为xz或xy");
|
|
657
|
-
return new
|
|
700
|
+
return new x({
|
|
658
701
|
scale: i,
|
|
659
702
|
yaw: n,
|
|
660
703
|
x: a,
|
|
@@ -679,7 +722,7 @@ class g {
|
|
|
679
722
|
r = -(t.x * n + t.y * o) * e, a = -(t.y * n - t.x * o) * e, h = -t.z * e;
|
|
680
723
|
else
|
|
681
724
|
throw new m(y.RelativeNoPlane, "映射关系的plane应为xz或xy");
|
|
682
|
-
return new
|
|
725
|
+
return new x({
|
|
683
726
|
scale: e,
|
|
684
727
|
yaw: i,
|
|
685
728
|
x: r,
|
|
@@ -694,7 +737,7 @@ class g {
|
|
|
694
737
|
try {
|
|
695
738
|
let e = t ? JSON.parse(t) : void 0;
|
|
696
739
|
const { reference_point: i } = e || {};
|
|
697
|
-
return i && (e = { refPoint: i }), e ? new
|
|
740
|
+
return i && (e = { refPoint: i }), e ? new x(e) : void 0;
|
|
698
741
|
} catch {
|
|
699
742
|
throw new m(y.RelativeJsonError, "relativeMap格式化失败");
|
|
700
743
|
}
|
|
@@ -733,7 +776,7 @@ class w {
|
|
|
733
776
|
renderType: l,
|
|
734
777
|
relativePosition: p
|
|
735
778
|
};
|
|
736
|
-
}), r = await
|
|
779
|
+
}), r = await O(o);
|
|
737
780
|
return w.handleCoordinateList(r);
|
|
738
781
|
}
|
|
739
782
|
/**
|
|
@@ -744,7 +787,7 @@ class w {
|
|
|
744
787
|
*/
|
|
745
788
|
static async removeCoordinate(t, e) {
|
|
746
789
|
const i = e.map((n) => n.id ?? -1);
|
|
747
|
-
return await
|
|
790
|
+
return await B(i);
|
|
748
791
|
}
|
|
749
792
|
/**
|
|
750
793
|
* 更新坐标系
|
|
@@ -754,9 +797,9 @@ class w {
|
|
|
754
797
|
*/
|
|
755
798
|
static async updateCoordinate(t, e) {
|
|
756
799
|
const { projectId: i, id: n } = t, o = e.map((a) => {
|
|
757
|
-
const { type: h, relativeMap: l, level: c, ...u } = a, d =
|
|
800
|
+
const { type: h, relativeMap: l, level: c, ...u } = a, d = x.toStringify(l);
|
|
758
801
|
return { ...u, relativePosition: d, projectId: i, parentId: n };
|
|
759
|
-
}), r = await
|
|
802
|
+
}), r = await O(o);
|
|
760
803
|
return w.handleCoordinateList(r);
|
|
761
804
|
}
|
|
762
805
|
/**
|
|
@@ -769,7 +812,7 @@ class w {
|
|
|
769
812
|
const { projectId: i, id: n } = t, o = e.map((a) => {
|
|
770
813
|
const { modelId: h } = a;
|
|
771
814
|
return { modelId: h, parentId: n, projectId: i };
|
|
772
|
-
}), r = await
|
|
815
|
+
}), r = await G(o);
|
|
773
816
|
return w.handleCoordinateList(r);
|
|
774
817
|
}
|
|
775
818
|
/**
|
|
@@ -785,8 +828,8 @@ class w {
|
|
|
785
828
|
renderType: o,
|
|
786
829
|
relativePosition: r,
|
|
787
830
|
...a
|
|
788
|
-
} = e, h =
|
|
789
|
-
return new
|
|
831
|
+
} = e, h = x.toParse(r);
|
|
832
|
+
return new Rt({
|
|
790
833
|
...a,
|
|
791
834
|
type: i,
|
|
792
835
|
modelType: o,
|
|
@@ -823,7 +866,7 @@ class w {
|
|
|
823
866
|
*/
|
|
824
867
|
static sortCoordinateTree(t) {
|
|
825
868
|
t.children && (t.children.sort((e, i) => {
|
|
826
|
-
if (e.type ===
|
|
869
|
+
if (e.type === v.Space) {
|
|
827
870
|
const n = Number(i?.relativeMap?.z) - Number(e?.relativeMap?.z);
|
|
828
871
|
return n !== 0 ? n : Number(i.createTime) - Number(e.createTime);
|
|
829
872
|
} else
|
|
@@ -838,11 +881,11 @@ class w {
|
|
|
838
881
|
const e = [];
|
|
839
882
|
return t.forEach((i) => {
|
|
840
883
|
const n = w.filterSpaceTree(i.children);
|
|
841
|
-
i.children = n, i.disabled = i.disabled ?? !1, i.type !==
|
|
884
|
+
i.children = n, i.disabled = i.disabled ?? !1, i.type !== v.Model && e.push(i);
|
|
842
885
|
}), e;
|
|
843
886
|
}
|
|
844
887
|
}
|
|
845
|
-
class
|
|
888
|
+
class Rt {
|
|
846
889
|
id = 0;
|
|
847
890
|
//id
|
|
848
891
|
type = 0;
|
|
@@ -884,10 +927,10 @@ class It {
|
|
|
884
927
|
this.setOptions(t);
|
|
885
928
|
}
|
|
886
929
|
get spaceList() {
|
|
887
|
-
return this.children.filter((t) => t.type ===
|
|
930
|
+
return this.children.filter((t) => t.type === v.Space);
|
|
888
931
|
}
|
|
889
932
|
get modelList() {
|
|
890
|
-
return this.children.filter((t) => t.type ===
|
|
933
|
+
return this.children.filter((t) => t.type === v.Model);
|
|
891
934
|
}
|
|
892
935
|
get fullName() {
|
|
893
936
|
const t = this.name ? `(${this.name})` : "";
|
|
@@ -896,16 +939,16 @@ class It {
|
|
|
896
939
|
//设置参数
|
|
897
940
|
setOptions(t) {
|
|
898
941
|
const { relativeMap: e, parent: i, children: n, ...o } = t || {};
|
|
899
|
-
e && (this.relativeMap = new
|
|
942
|
+
e && (this.relativeMap = new x(e)), i && (this.parent = i), n?.length && (this.children = n), Object.assign(this, o);
|
|
900
943
|
}
|
|
901
944
|
//添加子节点
|
|
902
945
|
async addChild(t) {
|
|
903
|
-
const e =
|
|
946
|
+
const e = g(t) ? t : [t], i = await w.addCoordinate(this, e);
|
|
904
947
|
this.mergeChild(i);
|
|
905
948
|
}
|
|
906
949
|
//删除子节点
|
|
907
950
|
async removeChild(t) {
|
|
908
|
-
const e =
|
|
951
|
+
const e = g(t) ? t : [t];
|
|
909
952
|
await w.removeCoordinate(this, e);
|
|
910
953
|
for (const i of e) {
|
|
911
954
|
const n = this.children.findIndex((o) => o.id === i.id);
|
|
@@ -914,12 +957,12 @@ class It {
|
|
|
914
957
|
}
|
|
915
958
|
//更新子节点
|
|
916
959
|
async updateChild(t) {
|
|
917
|
-
const e =
|
|
960
|
+
const e = g(t) ? t : [t], i = await w.updateCoordinate(this, e);
|
|
918
961
|
this.mergeChild(i);
|
|
919
962
|
}
|
|
920
963
|
//绑定子节点,不建立映射关系
|
|
921
964
|
async bindChild(t) {
|
|
922
|
-
const e =
|
|
965
|
+
const e = g(t) ? t : [t], i = await w.bindCoordinate(this, e);
|
|
923
966
|
this.mergeChild(i);
|
|
924
967
|
}
|
|
925
968
|
// 合并子节点,没有查询到节点就插入
|
|
@@ -965,9 +1008,9 @@ class It {
|
|
|
965
1008
|
* @param mapped 是否被映射
|
|
966
1009
|
* @returns
|
|
967
1010
|
*/
|
|
968
|
-
findChildModel(t = [
|
|
969
|
-
const i =
|
|
970
|
-
return i.includes(this.modelType ?? -1) && this.status !==
|
|
1011
|
+
findChildModel(t = [D.CADModel, D.SkyMapModel], e = !0) {
|
|
1012
|
+
const i = g(t) ? t : [t];
|
|
1013
|
+
return i.includes(this.modelType ?? -1) && this.status !== C.Disabled ? this : ([v.Data, v.Model].includes(this.type) ? this.findParentSpace() : this)?.modelList?.filter((a) => i.includes(a.modelType ?? -1) ? e ? !!a.relativeMap : !0 : !1)?.sort((a, h) => Number(a.status) - Number(h.status))?.[0];
|
|
971
1014
|
}
|
|
972
1015
|
/**
|
|
973
1016
|
* 寻找与当前节点最近的一个模型节点,从当前节点遍历到根节点-广度优先遍历
|
|
@@ -975,11 +1018,11 @@ class It {
|
|
|
975
1018
|
* @param excludeNodes //排除的坐标系
|
|
976
1019
|
* @returns
|
|
977
1020
|
*/
|
|
978
|
-
findClosestModel(t =
|
|
1021
|
+
findClosestModel(t = D.CADModel, e) {
|
|
979
1022
|
const i = /* @__PURE__ */ new Set();
|
|
980
1023
|
for (const l of e ?? [])
|
|
981
1024
|
i.add(String(l.id));
|
|
982
|
-
const n = [{ node: this, distance: 0 }], o =
|
|
1025
|
+
const n = [{ node: this, distance: 0 }], o = g(t) ? t : [t], r = /* @__PURE__ */ new Set();
|
|
983
1026
|
let a, h = 1 / 0;
|
|
984
1027
|
for (; n.length > 0; ) {
|
|
985
1028
|
const l = n.shift();
|
|
@@ -1012,7 +1055,7 @@ class It {
|
|
|
1012
1055
|
*/
|
|
1013
1056
|
findParentSpace() {
|
|
1014
1057
|
let t = this;
|
|
1015
|
-
for (; t && t.type !==
|
|
1058
|
+
for (; t && t.type !== v.Space; )
|
|
1016
1059
|
t = t.parent;
|
|
1017
1060
|
return t;
|
|
1018
1061
|
}
|
|
@@ -1025,7 +1068,7 @@ class It {
|
|
|
1025
1068
|
const e = [];
|
|
1026
1069
|
let i = this;
|
|
1027
1070
|
for (; i && t > 0; )
|
|
1028
|
-
i.type ===
|
|
1071
|
+
i.type === v.Space && (e.unshift(i.fullName), t--), i = i.parent;
|
|
1029
1072
|
return e;
|
|
1030
1073
|
}
|
|
1031
1074
|
// 寻找坐标系组, 有groupUuid表示坐标系组
|
|
@@ -1080,7 +1123,7 @@ class It {
|
|
|
1080
1123
|
*/
|
|
1081
1124
|
getMappedCsTree() {
|
|
1082
1125
|
function t(n) {
|
|
1083
|
-
return n.children?.length && (n.children = n.children.filter((o) => !!o?.relativeMap && o.status !==
|
|
1126
|
+
return n.children?.length && (n.children = n.children.filter((o) => !!o?.relativeMap && o.status !== C.Disabled).map((o) => t(o))), n;
|
|
1084
1127
|
}
|
|
1085
1128
|
const e = H(this.findRoot(!0)), i = t(e);
|
|
1086
1129
|
return i.parentId = 0, i.parent = void 0, i;
|
|
@@ -1092,13 +1135,13 @@ class It {
|
|
|
1092
1135
|
*/
|
|
1093
1136
|
getDestRelativeMap(t) {
|
|
1094
1137
|
if (this.id === t.id)
|
|
1095
|
-
return new
|
|
1138
|
+
return new x();
|
|
1096
1139
|
const e = this.getRelativeMaps(), i = t.getRelativeMaps();
|
|
1097
|
-
let n = new
|
|
1140
|
+
let n = new x();
|
|
1098
1141
|
return e?.forEach((o) => {
|
|
1099
|
-
n =
|
|
1142
|
+
n = x.addRelativeMap(n, o);
|
|
1100
1143
|
}), i?.reverse()?.forEach((o) => {
|
|
1101
|
-
n =
|
|
1144
|
+
n = x.addRelativeMap(n, x.inverseRelativeMap(o));
|
|
1102
1145
|
}), n;
|
|
1103
1146
|
}
|
|
1104
1147
|
/**
|
|
@@ -1132,7 +1175,7 @@ class It {
|
|
|
1132
1175
|
*/
|
|
1133
1176
|
static getCommonCoordinate(t) {
|
|
1134
1177
|
let e;
|
|
1135
|
-
const i = t.map((n) => n.getCsRoutes(!0).filter((r) => r.id && r.type ===
|
|
1178
|
+
const i = t.map((n) => n.getCsRoutes(!0).filter((r) => r.id && r.type === v.Space));
|
|
1136
1179
|
for (; this.checkSameCoordinate(i); ) {
|
|
1137
1180
|
const o = i.shift();
|
|
1138
1181
|
o?.length && (e = o[0]);
|
|
@@ -1160,7 +1203,7 @@ class It {
|
|
|
1160
1203
|
} else return !1;
|
|
1161
1204
|
}
|
|
1162
1205
|
}
|
|
1163
|
-
class
|
|
1206
|
+
class Q {
|
|
1164
1207
|
yaw = 0;
|
|
1165
1208
|
//偏航角
|
|
1166
1209
|
pitch = 0;
|
|
@@ -1174,14 +1217,14 @@ class W {
|
|
|
1174
1217
|
static toParse(t) {
|
|
1175
1218
|
if (t) {
|
|
1176
1219
|
const e = t?.split(",").map((i) => Number(i) || 0);
|
|
1177
|
-
return new
|
|
1220
|
+
return new Q({ yaw: e[0], pitch: e[1], roll: e[2] });
|
|
1178
1221
|
}
|
|
1179
1222
|
}
|
|
1180
1223
|
static toStringify(t) {
|
|
1181
1224
|
return t ? `${t.yaw},${t.pitch},${t.roll}` : "";
|
|
1182
1225
|
}
|
|
1183
1226
|
}
|
|
1184
|
-
class
|
|
1227
|
+
class K {
|
|
1185
1228
|
x = 0;
|
|
1186
1229
|
//x轴
|
|
1187
1230
|
y = 0;
|
|
@@ -1195,14 +1238,33 @@ class Q {
|
|
|
1195
1238
|
static toParse(t) {
|
|
1196
1239
|
if (t) {
|
|
1197
1240
|
const e = t?.split(",").map((i) => Number(i) || 0);
|
|
1198
|
-
return new
|
|
1241
|
+
return new K({ x: e[0], y: e[1], z: e[2] });
|
|
1199
1242
|
}
|
|
1200
1243
|
}
|
|
1201
1244
|
static toStringify(t) {
|
|
1202
1245
|
return t ? `${t.x},${t.y},${t.z}` : "";
|
|
1203
1246
|
}
|
|
1204
1247
|
}
|
|
1205
|
-
class
|
|
1248
|
+
class At {
|
|
1249
|
+
/**
|
|
1250
|
+
* 将源坐标系中的点转换到目标坐标系中
|
|
1251
|
+
* @param points 需要转换的点数组
|
|
1252
|
+
* @param srcCoordinate 源坐标系
|
|
1253
|
+
* @param dstCoordinate 目标坐标系
|
|
1254
|
+
* @returns 转换后的点数组
|
|
1255
|
+
*/
|
|
1256
|
+
static srcPointToDstPoint(t, e, i) {
|
|
1257
|
+
if (!e || !i || !t?.length) return [];
|
|
1258
|
+
const n = e?.getDestRelativeMap(i);
|
|
1259
|
+
if (!n) return [];
|
|
1260
|
+
const o = [];
|
|
1261
|
+
return t.forEach((r) => {
|
|
1262
|
+
const a = r.projection(n, e, i);
|
|
1263
|
+
a && o.push(a);
|
|
1264
|
+
}), o;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
class jt {
|
|
1206
1268
|
canvas;
|
|
1207
1269
|
ctx;
|
|
1208
1270
|
options;
|
|
@@ -1387,8 +1449,8 @@ class Lt {
|
|
|
1387
1449
|
this.isBindEvent && (this.canvas.removeEventListener("mousemove", this.onMousemove), this.canvas.removeEventListener("DOMMouseScroll", this.onMousewheel), this.canvas.removeEventListener("mousewheel", this.onMousewheel), this.canvas.removeEventListener("mousedown", this.onMousedown), this.canvas.removeEventListener("mouseout", this.onMouseout), this.canvas.removeEventListener("dblclick", this.onDblclick));
|
|
1388
1450
|
}
|
|
1389
1451
|
}
|
|
1390
|
-
const
|
|
1391
|
-
class
|
|
1452
|
+
const A = {};
|
|
1453
|
+
class Xt {
|
|
1392
1454
|
type = "image";
|
|
1393
1455
|
// 修改为更通用的名称
|
|
1394
1456
|
x;
|
|
@@ -1402,7 +1464,7 @@ class jt {
|
|
|
1402
1464
|
this.x = t.x || 0, this.y = t.y || 0, this.width = t.width || 0, this.height = t.height || 0, this.src = t.src, this.redraw = t.redraw, this.img = this.loadImage(t.onload);
|
|
1403
1465
|
}
|
|
1404
1466
|
loadImage(t) {
|
|
1405
|
-
const e =
|
|
1467
|
+
const e = A[this.src];
|
|
1406
1468
|
if (e)
|
|
1407
1469
|
return queueMicrotask(() => {
|
|
1408
1470
|
t?.(e), this.redraw?.();
|
|
@@ -1410,7 +1472,7 @@ class jt {
|
|
|
1410
1472
|
{
|
|
1411
1473
|
const i = new Image();
|
|
1412
1474
|
return i.crossOrigin = "anonymous", i.src = this.src, i.onload = () => {
|
|
1413
|
-
|
|
1475
|
+
A[this.src] = i, t?.(i), this.redraw?.();
|
|
1414
1476
|
}, i;
|
|
1415
1477
|
}
|
|
1416
1478
|
}
|
|
@@ -1423,7 +1485,7 @@ class jt {
|
|
|
1423
1485
|
}
|
|
1424
1486
|
}
|
|
1425
1487
|
}
|
|
1426
|
-
class
|
|
1488
|
+
class Ft {
|
|
1427
1489
|
id = "";
|
|
1428
1490
|
type = "point";
|
|
1429
1491
|
x;
|
|
@@ -1443,8 +1505,8 @@ class kt {
|
|
|
1443
1505
|
t.beginPath(), t.arc(this.x, this.y, this.r * i, 0, 2 * Math.PI), t.fillStyle = this.backgroundColor, t.fill(), t.font = `${this.r * i}px Microsoft YaHei`, t.textAlign = "center", t.fillStyle = "#FFFFFF", t.fillText(this.text, this.x, this.y + this.r * i / 3), t.restore();
|
|
1444
1506
|
}
|
|
1445
1507
|
}
|
|
1446
|
-
const
|
|
1447
|
-
class
|
|
1508
|
+
const j = {};
|
|
1509
|
+
class Ut {
|
|
1448
1510
|
id = "";
|
|
1449
1511
|
type = "issue";
|
|
1450
1512
|
//轨迹点上的事件
|
|
@@ -1464,7 +1526,7 @@ class At {
|
|
|
1464
1526
|
this.id = t.id, this.x = t.x, this.y = t.y, this.width = t.width || 0, this.height = t.height || 0, this.index = t.index, this.pIndex = t.pIndex, this.parentId = t.parentId, this.count = t.count || 0, this.badgeR = 3, this.src = t.src, this.redraw = t.redraw, this.img = this.loadImage(t.onload);
|
|
1465
1527
|
}
|
|
1466
1528
|
loadImage(t) {
|
|
1467
|
-
const e =
|
|
1529
|
+
const e = j[this.src];
|
|
1468
1530
|
if (e)
|
|
1469
1531
|
return queueMicrotask(() => {
|
|
1470
1532
|
t?.(e), this.redraw?.();
|
|
@@ -1472,7 +1534,7 @@ class At {
|
|
|
1472
1534
|
{
|
|
1473
1535
|
const i = new Image();
|
|
1474
1536
|
return i.src = this.src, i.crossOrigin = "anonymous", i.onload = () => {
|
|
1475
|
-
|
|
1537
|
+
j[this.src] = i, t?.(i), this.redraw?.();
|
|
1476
1538
|
}, i;
|
|
1477
1539
|
}
|
|
1478
1540
|
}
|
|
@@ -1483,7 +1545,7 @@ class At {
|
|
|
1483
1545
|
}
|
|
1484
1546
|
}
|
|
1485
1547
|
const X = {};
|
|
1486
|
-
class
|
|
1548
|
+
class Yt {
|
|
1487
1549
|
type = "marker";
|
|
1488
1550
|
x;
|
|
1489
1551
|
y;
|
|
@@ -1537,7 +1599,7 @@ class Xt {
|
|
|
1537
1599
|
}
|
|
1538
1600
|
}
|
|
1539
1601
|
}
|
|
1540
|
-
class
|
|
1602
|
+
class Gt {
|
|
1541
1603
|
type = "radar";
|
|
1542
1604
|
x;
|
|
1543
1605
|
y;
|
|
@@ -1567,7 +1629,7 @@ class Ft {
|
|
|
1567
1629
|
r.addColorStop(0, "rgba(180, 42, 42, 1)"), r.addColorStop(1, "rgba(180, 42, 42, 0.5)"), t.beginPath(), t.moveTo(this.x, this.y), t.arc(this.x, this.y, this.r * i, n, o), t.closePath(), t.fillStyle = r, t.fill(), t.restore();
|
|
1568
1630
|
}
|
|
1569
1631
|
}
|
|
1570
|
-
class
|
|
1632
|
+
class Bt {
|
|
1571
1633
|
type = "region";
|
|
1572
1634
|
x;
|
|
1573
1635
|
y;
|
|
@@ -1599,32 +1661,33 @@ class Ut {
|
|
|
1599
1661
|
}
|
|
1600
1662
|
}
|
|
1601
1663
|
export {
|
|
1602
|
-
|
|
1664
|
+
st as APP_SETTING,
|
|
1603
1665
|
m as AppError,
|
|
1604
1666
|
y as AppErrorCode,
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1667
|
+
et as AppObsType,
|
|
1668
|
+
jt as CanvasElement,
|
|
1669
|
+
Xt as CanvasImageElement,
|
|
1670
|
+
Ut as CanvasIssueElement,
|
|
1671
|
+
Yt as CanvasMarkerElement,
|
|
1672
|
+
Ft as CanvasPointElement,
|
|
1673
|
+
Gt as CanvasRadarElement,
|
|
1674
|
+
Bt as CanvasRegionElement,
|
|
1675
|
+
Rt as Coordinate,
|
|
1676
|
+
tt as CoordinateLevel,
|
|
1677
|
+
D as CoordinateModelType,
|
|
1678
|
+
C as CoordinateStatus,
|
|
1679
|
+
v as CoordinateType,
|
|
1680
|
+
At as DataHelper,
|
|
1618
1681
|
w as DataSource,
|
|
1619
1682
|
N as GeoPoint,
|
|
1620
1683
|
f as Point,
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1684
|
+
Q as Position,
|
|
1685
|
+
x as RelativeMap,
|
|
1686
|
+
R as RequestContentType,
|
|
1687
|
+
M as RequestMethod,
|
|
1625
1688
|
F as RequestResultCode,
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1689
|
+
K as Vector3,
|
|
1690
|
+
Lt as api,
|
|
1691
|
+
Ot as http,
|
|
1692
|
+
kt as utils
|
|
1630
1693
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(l=typeof globalThis<"u"?globalThis:l||self,f(l.Shared={}))})(this,(function(l){"use strict";class f extends Error{constructor(t,e,i){super(e),this.code=t,this.message=e,this.details=i,this.name="Apprror",Object.setPrototypeOf(this,f.prototype)}toJSON(){return{code:this.code,message:this.message,details:this.details,timestamp:new Date().toISOString()}}}var T=(s=>(s[s.CADModel=5]="CADModel",s[s.BIMModel=6]="BIMModel",s[s.ForgeModel=7]="ForgeModel",s[s.ThreeDModel=8]="ThreeDModel",s[s.SkyMapModel=9]="SkyMapModel",s[s.ScaleModel=10]="ScaleModel",s))(T||{}),U=(s=>(s[s.Global=0]="Global",s))(U||{}),x=(s=>(s[s.Space=0]="Space",s[s.Model=1]="Model",s[s.Data=2]="Data",s))(x||{}),I=(s=>(s[s.Used=0]="Used",s[s.Enabled=1]="Enabled",s[s.Disabled=2]="Disabled",s))(I||{}),R=(s=>(s[s.SUCCESS=200]="SUCCESS",s[s.ERROR=-1]="ERROR",s[s.TIMEOUT=401]="TIMEOUT",s))(R||{}),p=(s=>(s.GET="GET",s.POST="POST",s))(p||{}),z=(s=>(s.JSON="application/json",s.FORM_URLENCODED="application/x-www-form-urlencoded;charset=UTF-8",s.FORM_DATA="multipart/form-data;charset=UTF-8",s.OCTET_STREAM="'application/octet-stream",s))(z||{}),Y=(s=>(s.Hw="huawei",s.Ali="aliyun",s.Hs="hs",s.Aws="amazon",s.Minio="minio",s))(Y||{}),w=(s=>(s[s.GeoPointNoPlane=9e3]="GeoPointNoPlane",s[s.PointUnmappedGIS=9010]="PointUnmappedGIS",s[s.PointNoXYZ=9011]="PointNoXYZ",s[s.PointNoPlane=9012]="PointNoPlane",s[s.RelativePlaneUnmatch=9020]="RelativePlaneUnmatch",s[s.RelativeNoPlane=9021]="RelativeNoPlane",s[s.RelativeJsonError=9022]="RelativeJsonError",s[s.RequestCodeError=9030]="RequestCodeError",s[s.RequestResultError=9031]="RequestResultError",s[s.RequestUnknownError=9032]="RequestUnknownError",s))(w||{});const G={baseUrl:"https://vsleem.com/api",obsType:"hs",authorizeCode:""},nt={isTransformResponse:!0,joinBaseUrl:!0,withAuthorize:!0},ot={url:"",method:p.GET,headers:{}},B={...G};function rt(s){Object.assign(B,s)}async function S(s,t){const e={...nt,...t},i={...ot,...s};try{const n=at(i,e),{url:o,...r}=n,h=await(await window.fetch(o,r)).json();return ht(h,e)}catch(n){return ct(n)}}function at(s,t){const{baseUrl:e,authorizeCode:i}=B,{joinBaseUrl:n,withAuthorize:o}=t;let{url:r,method:a,headers:h={},params:u,data:c}=s;n&&e&&(r=`${e}${r}`),a=a?.toUpperCase();const d={...h};if(/^https?:\/\/.+$/i.test(e??"")?d.PlatForm=new URL(e??"").host:d.PlatForm=new URL(window.location.href).host,o&&i&&(d.AuthorizationCode=i),a===p.POST&&!d["Content-Type"]&&(d["Content-Type"]=z.JSON),a===p.GET&&u){const v=new URLSearchParams(u);r+=`?${v.toString()}`}let m;return a===p.POST&&(m=d["Content-Type"]===z.JSON?JSON.stringify(c||{}):c),{url:r,method:a,headers:d,body:m}}function ht(s,t){if(!t.isTransformResponse)return s;if(!s)throw new f(w.RequestResultError,"请求返回的结果错误");const{code:e,data:i,msg:n}=s;if(e===R.SUCCESS)return i;throw new f(w.RequestCodeError,n||"请求返回的Code错误")}function ct(s){throw s instanceof Error?s:new f(w.RequestUnknownError,typeof s=="string"?s:"未知的请求错误")}const lt=Object.freeze(Object.defineProperty({__proto__:null,request:S,setRequestGlobalConfig:rt},Symbol.toStringTag,{value:"Module"}));function $(s,t){return S({url:"/project/jssdk/cs/list",method:p.GET,params:s},t)}function _(s,t){return S({url:"/project/jssdk/cs/bind",method:p.POST,data:s},t)}function O(s,t){return S({url:"/project/jssdk/cs/save",method:p.POST,data:s},t)}function q(s,t){return S({url:"/project/jssdk/cs/delete",method:p.POST,data:s},t)}function Z(s,t){return S({url:"/project/jssdk/cs/mapping",method:p.POST,data:s},t)}function J(s,t){return S({url:"/project/jssdk/cs/mapping/query",method:p.GET,params:s},t)}function ut(s,t={isTransformResponse:!1,joinBaseUrl:!1,withAuthorize:!1}){return S({url:s,method:p.GET},t)}const dt=Object.freeze(Object.defineProperty({__proto__:null,bindCoordinate:_,getCoordinateList:$,getImageInfo:ut,getMappingRelation:J,mapingCoordinate:Z,removeCoordinate:q,saveCoordinate:O},Symbol.toStringTag,{value:"Module"})),ft=typeof window<"u",mt=Object.prototype.toString;function b(s,t){return mt.call(s)===`[object ${t}]`}function H(s){return typeof s<"u"}function V(s){return!H(s)}function L(s){return s!==null&&b(s,"Object")}function W(s){return s===null}function yt(s){return b(s,"Date")}function wt(s){return b(s,"String")}function j(s){return typeof s=="function"}function gt(s){return b(s,"Boolean")}function pt(s){return b(s,"RegExp")}function P(s){return s&&Array.isArray(s)}function Mt(s){return typeof window<"u"&&b(s,"Window")}function vt(s){return L(s)&&!!s.tagName}function xt(s){return typeof s=="number"||/^\d+(\.\d+)?$/.test(s)}function N(s){return b(Number(s),"Number")}function bt(s,t){return JSON.stringify(s)===JSON.stringify(t)}function St(s){return V(s)||W(s)}function Tt(s){return b(s,"Promise")&&L(s)&&j(s.then)&&j(s.catch)}function Q(s){return E(s,new WeakMap)}function E(s,t){if(typeof s!="object"||s===null)return s;if(t.has(s))return t.get(s);let e;if(s instanceof Date)return e=new Date(s),t.set(s,e),e;if(s instanceof RegExp)return e=new RegExp(s),t.set(s,e),e;if(s instanceof Map)return e=new Map,t.set(s,e),s.forEach((n,o)=>{e.set(o,E(n,t))}),e;if(s instanceof Set)return e=new Set,t.set(s,e),s.forEach(n=>{e.add(E(n,t))}),e;if(ArrayBuffer.isView(s))return e=new s.constructor(s.buffer.slice(0),s.byteOffset,s.byteLength),t.set(s,e),e;if(s instanceof ArrayBuffer)return e=s.slice(0),t.set(s,e),e;if(Array.isArray(s)){e=[],t.set(s,e);for(let n=0;n<s.length;n++)n in s&&(e[n]=E(s[n],t));return e}e=Object.create(Object.getPrototypeOf(s)),t.set(s,e);for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=E(s[n],t));const i=Object.getOwnPropertySymbols(s);for(const n of i)Object.prototype.propertyIsEnumerable.call(s,n)&&(e[n]=E(s[n],t));return e}function Pt(s,t,e=!1){let i;const n=function(...o){const r=this,a=e&&!i;i&&clearTimeout(i),i=setTimeout(()=>{i=void 0,e||s.apply(r,o)},t),a&&s.apply(r,o)};return n.cancel=()=>{i&&clearTimeout(i),i=void 0},n}function Et(s,t,e=!1){let i,n;const o=function(...r){const a=this;n?(clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=t&&(s.apply(a,r),n=Date.now())},t-(Date.now()-n))):(e&&s.apply(a,r),n=Date.now())};return o.cancel=()=>{clearTimeout(i),i=void 0,n=void 0},o}function A(s,...t){if(!t.length)return s;const e=t.shift();return e===void 0?s:(D(s)&&D(e)&&Object.keys(e).forEach(i=>{const n=s[i],o=e[i];Array.isArray(n)&&Array.isArray(o)?s[i]=[...n,...o]:D(n)&&D(o)?s[i]=A({...n},o):o!==void 0&&(s[i]=o)}),A(s,...t))}function D(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function K(s,...t){if(!t.length)return s;for(const e of t)e!=null&&typeof e=="object"&&Object.keys(e).forEach(i=>{const n=e[i],o=s[i];n!==null&&typeof n=="object"&&!Array.isArray(n)?((!o||typeof o!="object")&&(s[i]={}),K(s[i],n)):s[i]=n});return s}function Ct(s,t={}){return new Promise((e,i)=>{const n=k(s);if(Nt(n)){e(!0);return}const o=document.createElement("script");o.src=s,Object.entries(t).forEach(([r,a])=>{a!==!1&&o.setAttribute(r,a===!0?"":String(a))}),o.onload=()=>{e(!0)},o.onerror=()=>{document.head.removeChild(o),i(new Error(`Failed to load script: ${s}`))},document.head.appendChild(o)})}function Nt(s){const t=k(s);return Array.from(document.scripts).some(e=>k(e.src)===t)}function k(s){try{const t=new URL(s,window.location.href);return`${t.origin}${t.pathname}`}catch{return s}}function It(s,t,e,i){const n=Math.min(s/e,t/i),o=e*n,r=i*n;return{scale:n,x:(s-o)/2,y:(t-r)/2,sw:o,sh:r}}function zt(s,t,e){return{x:s*e.scale+e.x,y:t*e.scale+e.y}}function Dt(s,t,e){return{x:(s-e.x)/e.scale,y:(t-e.y)/e.scale}}function Rt(s){console.warn(`[warn]:${s}`)}function Ot(s){throw new Error(`[error]:${s}`)}const Lt=Object.freeze(Object.defineProperty({__proto__:null,cloneDeep:Q,debounce:Pt,deepMerge:A,deepMergeProps:K,error:Ot,getImageTransform:It,inBrowser:ft,is:b,isArray:P,isBoolean:gt,isDate:yt,isDef:H,isElement:vt,isFunction:j,isNull:W,isNullOrUnDef:St,isNumber:N,isNumeric:xt,isObject:L,isPromise:Tt,isRegExp:pt,isSameValue:bt,isString:wt,isUnDef:V,isWindow:Mt,loadScript:Ct,throttle:Et,toCanvasCoord:zt,toModelCoord:Dt,warn:Rt},Symbol.toStringTag,{value:"Module"}));class y{x=0;y=0;z=0;lat=0;lon=0;alt=0;yaw=0;pitch=0;roll=0;hasXYZ=!1;hasGeo=!1;hasAngle=!1;plane="xy";constructor(t){const{x:e,y:i,z:n,lat:o,lon:r,alt:a,yaw:h,pitch:u,roll:c,plane:d="xy"}=t||{};N(e)&&N(i)&&(this.x=Number(e)||0,this.y=Number(i)||0,this.z=Number(n)||0,this.plane=d,this.hasXYZ=!0),N(o)&&N(r)&&Number(o)!==0&&Number(r)!==0&&(this.lat=Number(o)||0,this.lon=Number(r)||0,this.alt=Number(a)||0,this.hasGeo=!0),(h!==void 0||u!==void 0||c!==void 0)&&(this.yaw=Number(h)||0,this.pitch=Number(u)||0,this.roll=Number(c)||0,this.hasAngle=!0)}static dist(t,e){return Math.hypot(t.x-e.x,t.y-e.y,t.z-e.z)}static distXZ(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}static distXY(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}static toRadians(t){return(Number(t)||0)*Math.PI/180}static toDegrees(t){return(Number(t)||0)*180/Math.PI}static angleXZ(t,e,i){const n={x:t.x-e.x,z:t.z-e.z},o={x:i.x-e.x,z:i.z-e.z},r=n.x*o.x+n.z*o.z,a=Math.sqrt(n.x**2+n.z**2),h=Math.sqrt(o.x**2+o.z**2),u=Math.max(-1,Math.min(1,r/(a*h))),d=Math.acos(u)*180/Math.PI;return Math.min(d,360-d)}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new y({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}projection(t,e,i){try{if(e?.id===i?.id)return new y(this);if(e?.modelType===T.SkyMapModel){const{refPoint:n}=e?.relativeMap||{};if(this.hasGeo&&n){const o=C.LLHToXYZ(this,n);return this.x=o.x,this.y=o.y,this.z=o.z,this.hasXYZ=!0,this.project(t)}throw new f(w.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}if(i?.modelType===T.SkyMapModel){const{refPoint:n}=i?.relativeMap||{},o=this.project(t);if(o?.hasXYZ&&n){const r=C.XYZToLLH(o,n);return o.lat=r.lat,o.lon=r.lon,o.alt=r.alt,o.hasGeo=!0,o}throw new f(w.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}return this.project(t)}catch{return}}project(t){if(!this.hasXYZ)throw new f(w.PointNoXYZ,"点没有xxz坐标信息");if(this.plane==="xz")return this.projectXZ(t);if(this.plane==="xy")return this.projectXY(t);throw new f(w.PointNoPlane,"点的plane应为xz或xy")}projectXZ(t){const e=new y(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const i=e.x*Math.cos(t.yaw)-e.z*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.z*Math.cos(t.yaw);return e.x=i+t.x,e.y+=t.y,e.z=n+t.z,e}projectXY(t){const e=new y(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const i=e.x*Math.cos(t.yaw)-e.y*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.y*Math.cos(t.yaw);return e.x=i+t.x,e.y=n+t.y,e.z+=t.z,e}}class C{lat=0;lon=0;alt=0;constructor(t){const{lat:e=0,lon:i=0,alt:n=0}=t||{};this.lat=e,this.lon=i,this.alt=n}static XYZToLLH(t,e){const n=.0033528106647474805,o=n*(2-n),r=y.toRadians(e.lat),a=6378137/Math.sqrt(1-o*Math.sin(r)**2)+e.alt;let h,u,c;if(t.plane==="xz"){const d=t.x/1e3/(a*Math.cos(r)),m=t.z/1e3/a;h=e.lon+y.toDegrees(d),u=e.lat-y.toDegrees(m),c=e.alt+t.y/1e3}else if(t.plane==="xy"){const d=t.x/1e3/(a*Math.cos(r)),m=t.y/1e3/a;h=e.lon+y.toDegrees(d),u=e.lat-y.toDegrees(m),c=e.alt+t.z/1e3}else throw new f(w.GeoPointNoPlane,"点的plane应为xz或xy");return new C({lat:u,lon:h,alt:c})}static LLHToXYZ(t,e){const n=.0033528106647474805,o=n*(2-n),r=y.toRadians(e.lat),a=6378137/Math.sqrt(1-o*Math.sin(r)**2)+e.alt,h=y.toRadians(t.lon-e.lon),u=y.toRadians(e.lat-t.lat),c=a*h*Math.cos(r),d=a*u;if(t.plane==="xz")return new y({x:c*1e3,y:(t.alt-e.alt)*1e3,z:d*1e3,plane:"xz"});if(t.plane==="xy")return new y({x:c*1e3,y:d*1e3,z:(t.alt-e.alt)*1e3,plane:"xy"});throw new f(w.GeoPointNoPlane,"点的plane应为xz或xy")}}class M{scale=1;yaw=0;x=0;y=0;z=0;start=0;end=-1;plane="xy";refPoint;constructor(t){const{refPoint:e,...i}=t||{};e&&(this.refPoint=new C(e)),Object.assign(this,i)}static addRelativeMap(t,e){if(t.plane!==e.plane)throw new f(w.RelativePlaneUnmatch,"两个映射关系的plane应该相同");const i=t.scale*e.scale,n=t.yaw+e.yaw,o=Math.cos(e.yaw),r=Math.sin(e.yaw);let a=0,h=0,u=0;if(t.plane==="xz"){const c=t.x*o-t.z*r,d=t.y,m=t.x*r+t.z*o;a=e.x+c*e.scale,h=e.y+d*e.scale,u=e.z+m*e.scale}else if(t.plane==="xy"){const c=t.x*o-t.y*r,d=t.x*r+t.y*o,m=t.z;a=e.x+c*e.scale,h=e.y+d*e.scale,u=e.z+m*e.scale}else throw new f(w.RelativeNoPlane,"映射关系的plane应为xz或xy");return new M({scale:i,yaw:n,x:a,y:h,z:u,start:t.start,end:t.end,plane:t.plane})}static inverseRelativeMap(t){const e=1/t.scale,i=-t.yaw,n=Math.cos(-i),o=Math.sin(-i);let r=0,a=0,h=0;if(t.plane==="xz")r=-(t.x*n+t.z*o)*e,a=-t.y*e,h=-(t.z*n-t.x*o)*e;else if(t.plane==="xy")r=-(t.x*n+t.y*o)*e,a=-(t.y*n-t.x*o)*e,h=-t.z*e;else throw new f(w.RelativeNoPlane,"映射关系的plane应为xz或xy");return new M({scale:e,yaw:i,x:r,y:a,z:h,start:t.start,end:t.end,plane:t.plane})}static toParse(t){try{let e=t?JSON.parse(t):void 0;const{reference_point:i}=e||{};return i&&(e={refPoint:i}),e?new M(e):void 0}catch{throw new f(w.RelativeJsonError,"relativeMap格式化失败")}}static toStringify(t){return t?JSON.stringify(t):void 0}}class g{static async getCoordinateTree(t){const e=await $({projectId:t});if(e.length){const i=g.handleCoordinateList(e);return g.buildCoordinateTree(i,0)}}static async addCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{type:h,modelType:u,relativeMap:c,level:d,...m}=a,v=c?JSON.stringify(c):void 0;return{...m,projectId:i,parentId:n,coordinateType:h,renderType:u,relativePosition:v}}),r=await O(o);return g.handleCoordinateList(r)}static async removeCoordinate(t,e){const i=e.map(n=>n.id??-1);return await q(i)}static async updateCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{type:h,relativeMap:u,level:c,...d}=a,m=M.toStringify(u);return{...d,relativePosition:m,projectId:i,parentId:n}}),r=await O(o);return g.handleCoordinateList(r)}static async bindCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{modelId:h}=a;return{modelId:h,parentId:n,projectId:i}}),r=await _(o);return g.handleCoordinateList(r)}static handleCoordinateList(t){return t?.map(e=>{const{coordinateType:i,modelKey:n,renderType:o,relativePosition:r,...a}=e,h=M.toParse(r);return new tt({...a,type:i,modelType:o,modelValue:n,relativeMap:h})})}static buildCoordinateTree(t,e){const i=new Map,n=[];return t.forEach(o=>{i.set(String(o.id),o)}),t.forEach(o=>{const r=i.get(String(o.id));if(r)if(o.parentId===e)r.level=0,n.push(r);else{const a=i.get(String(o.parentId??-1));a&&(r.level=(Number(a.level)||0)+1,r.parent=a,a.children?.push(r))}}),n.forEach(g.sortCoordinateTree),n[0]}static sortCoordinateTree(t){t.children&&(t.children.sort((e,i)=>{if(e.type===x.Space){const n=Number(i?.relativeMap?.z)-Number(e?.relativeMap?.z);return n!==0?n:Number(i.createTime)-Number(e.createTime)}else return e.status===0&&i.status!==0?-1:i.status===0&&e.status!==0?1:Number(i.createTime)-Number(e.createTime)}),t.children.forEach(g.sortCoordinateTree))}static filterSpaceTree(t){const e=[];return t.forEach(i=>{const n=g.filterSpaceTree(i.children);i.children=n,i.disabled=i.disabled??!1,i.type!==x.Model&&e.push(i)}),e}}class tt{id=0;type=0;children=[];level;relativeMap;no;name;shortName;status;modelId;modelType;modelValue;projectId;parentId;parent;groupUuid;z;createTime;disabled;constructor(t){this.setOptions(t)}get spaceList(){return this.children.filter(t=>t.type===x.Space)}get modelList(){return this.children.filter(t=>t.type===x.Model)}get fullName(){const t=this.name?`(${this.name})`:"";return this.shortName?`${this.shortName}${t}`:this.name??""}setOptions(t){const{relativeMap:e,parent:i,children:n,...o}=t||{};e&&(this.relativeMap=new M(e)),i&&(this.parent=i),n?.length&&(this.children=n),Object.assign(this,o)}async addChild(t){const e=P(t)?t:[t],i=await g.addCoordinate(this,e);this.mergeChild(i)}async removeChild(t){const e=P(t)?t:[t];await g.removeCoordinate(this,e);for(const i of e){const n=this.children.findIndex(o=>o.id===i.id);n!==-1&&this.children.splice(n,1)}}async updateChild(t){const e=P(t)?t:[t],i=await g.updateCoordinate(this,e);this.mergeChild(i)}async bindChild(t){const e=P(t)?t:[t],i=await g.bindCoordinate(this,e);this.mergeChild(i)}async mergeChild(t){t?.length&&t.forEach(e=>{const i=this.children.find(n=>n.id===e.id);if(i){const{relativeMap:n,no:o,name:r,shortName:a,status:h,modelId:u,modelValue:c}=e;Object.assign(i,{relativeMap:n,no:o,name:r,shortName:a,status:h,modelId:u,modelValue:c})}else this.id===e.parentId&&(e.parent=this,this.children.unshift(e))})}async mappingTo(t){await Z(t)}async fromMapping(){const t=await J({srcCsId:this.id});return t[t.length-1]}findRoot(t=!1){let e=this;for(;e.parent&&!(t&&!e.relativeMap);)e=e.parent;return e}findChildModel(t=[T.CADModel,T.SkyMapModel],e=!0){const i=P(t)?t:[t];return i.includes(this.modelType??-1)&&this.status!==I.Disabled?this:([x.Data,x.Model].includes(this.type)?this.findParentSpace():this)?.modelList?.filter(a=>i.includes(a.modelType??-1)?e?!!a.relativeMap:!0:!1)?.sort((a,h)=>Number(a.status)-Number(h.status))?.[0]}findClosestModel(t=T.CADModel,e){const i=new Set;for(const u of e??[])i.add(String(u.id));const n=[{node:this,distance:0}],o=P(t)?t:[t],r=new Set;let a,h=1/0;for(;n.length>0;){const u=n.shift();if(!u)break;const{node:c,distance:d}=u;if(i.has(String(c.id)))continue;if(o.includes(c.modelType??-1)){if(d<h&&(a=c,h=d,d<=1))break;continue}r.add(c);const m=[];if(c.children)for(const v of c.children)r.has(v)||m.push(v);if(c.parent?.children)for(const v of c.parent.children)v!==c&&!r.has(v)&&m.push(v);c.parent&&!r.has(c.parent)&&m.push(c.parent);for(const v of m)n.push({node:v,distance:d+1})}return a}findParentSpace(){let t=this;for(;t&&t.type!==x.Space;)t=t.parent;return t}findParentSpaceNames(t=2){const e=[];let i=this;for(;i&&t>0;)i.type===x.Space&&(e.unshift(i.fullName),t--),i=i.parent;return e}findCsGroup(){const{groupUuid:t,parent:e}=this;return t?e?.children?.filter(i=>i.groupUuid===t)||[]:[this]}findCsByLevel(t){if(this.level===t)return this;if(this.children.length)for(const e of this.children){const i=e.findCsByLevel(t);if(i)return i}}findCsById(t){if(t){if(this.id===t)return this;for(const e of this.children){const i=e.findCsById(t);if(i)return i}}}getCsRoutes(t=!1){let e=this;const i=[e];for(;e?.parent&&!(t&&!e.relativeMap);)e=e.parent,e&&i.push(e);return i}getMappedCsTree(){function t(n){return n.children?.length&&(n.children=n.children.filter(o=>!!o?.relativeMap&&o.status!==I.Disabled).map(o=>t(o))),n}const e=Q(this.findRoot(!0)),i=t(e);return i.parentId=0,i.parent=void 0,i}getDestRelativeMap(t){if(this.id===t.id)return new M;const e=this.getRelativeMaps(),i=t.getRelativeMaps();let n=new M;return e?.forEach(o=>{n=M.addRelativeMap(n,o)}),i?.reverse()?.forEach(o=>{n=M.addRelativeMap(n,M.inverseRelativeMap(o))}),n}getRelativeMaps(){let t=this;const e=[];for(;t?.parent&&t.relativeMap;)e.push(t.relativeMap),t=t.parent;return e}static filterCoordinateTree(t,e=[],i=[]){if(i.includes(t.id)||e.includes(t.type))return;const n=t.children?.map(o=>this.filterCoordinateTree(o,e,i)).filter(o=>o!==void 0);return{...t,children:n}}static getCommonCoordinate(t){let e;const i=t.map(n=>n.getCsRoutes(!0).filter(r=>r.id&&r.type===x.Space));for(;this.checkSameCoordinate(i);){const o=i.shift();o?.length&&(e=o[0])}return e}static checkSameCoordinate(t){if(t.length){if(t.length===1)return!0;for(let e=0;e<t.length-1;e++){const i=t[e];if(!i?.length)return!1;const n=t[e+1];if(!n?.length||i[0].id!==n[0].id)return!1}return!0}else return!1}}class X{yaw=0;pitch=0;roll=0;constructor(t){const{yaw:e=0,pitch:i=0,roll:n=0}=t||{};this.yaw=Number(e)||0,this.pitch=Number(i)||0,this.roll=Number(n)||0}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new X({yaw:e[0],pitch:e[1],roll:e[2]})}}static toStringify(t){return t?`${t.yaw},${t.pitch},${t.roll}`:""}}class F{x=0;y=0;z=0;constructor(t){const{x:e=0,y:i=0,z:n=0}=t||{};this.x=Number(e)||0,this.y=Number(i)||0,this.z=Number(n)||0}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new F({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}}class jt{canvas;ctx;options;offset={x:0,y:0};curOffset={x:0,y:0};mousePosition={x:-1,y:-1};MAX_SCALE=60;MIN_SCALE=1;STEP_SCALE=.5;scale=1;preScale=1;width=0;height=0;x=0;y=0;timeout=0;lastTouch;initialDistance=0;touchMode=0;isMouseover=!1;isBindEvent=!0;isDrawAssist=!1;customDrawAssist;isMoveRedrawing;afterDraw;screenPos={screenX:0,screenY:0};constructor(t){const{container:e,width:i=300,height:n=300,isBindEvent:o=!0,isDrawAssist:r=!1,isMoveRedrawing:a,customDrawAssist:h,afterDraw:u,...c}=t;this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.width=i,this.height=n,this.canvas.width=i,this.canvas.height=n,this.isBindEvent=o,this.isDrawAssist=r,this.customDrawAssist=h,this.isMoveRedrawing=a??r,this.options=c,this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMousemoveTemp=this.onMousemoveTemp.bind(this),this.onMouseup=this.onMouseup.bind(this),this.onMousewheel=this.onMousewheel.bind(this),this.onDblclick=this.onDblclick.bind(this),this.onTouchstart=this.onTouchstart.bind(this),this.onTouchmove=this.onTouchmove.bind(this),this.onTouchend=this.onTouchend.bind(this),this.onMouseout=this.onMouseout.bind(this),this.afterDraw=this.afterDraw,o&&(this.canvas.addEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.addEventListener("mousewheel",this.onMousewheel),this.canvas.addEventListener("mousedown",this.onMousedown),this.canvas.addEventListener("mousemove",this.onMousemove),this.canvas.addEventListener("mouseout",this.onMouseout),this.canvas.addEventListener("dblclick",this.onDblclick),this.canvas.addEventListener("touchstart",this.onTouchstart))}onClick(t){const{screenX:e,screenY:i}=t;this.timeout&&clearTimeout(this.timeout);const n=this.getPos(t);this.x=n.x,this.y=n.y,this.screenPos={screenX:e,screenY:i},this.options.onClick&&(this.timeout=setTimeout(()=>{const o=parseFloat(((this.x-this.offset.x)/this.scale).toFixed(2)),r=parseFloat(((this.y-this.offset.y)/this.scale).toFixed(2));this.options.onClick(o,r)},200))}onMouseout(t){this.isMouseover=!1,this.draw()}onTouchstart(t){t.preventDefault(),t.touches.length==1?this.touchMode===0&&(this.touchMode=1):t.touches.length>=2&&this.touchMode<2&&(this.touchMode=2),this.touchMode==1&&t.touches.length==1?this.onTouch(t.touches[0]):this.touchMode==2&&t.touches.length==2&&this.onBothTouchstart(t),this.canvas.addEventListener("touchmove",this.onTouchmove),this.canvas.addEventListener("touchend",this.onTouchend)}onMousedown(t){this.onClick(t),this.canvas.addEventListener("mousemove",this.onMousemoveTemp),this.canvas.addEventListener("mouseup",this.onMouseup)}onBothTouchstart(t){t.preventDefault();const e={x:t.touches[0].clientX,y:t.touches[0].clientY},i={x:t.touches[1].clientX,y:t.touches[1].clientY},n=this.getPos({clientX:(e.x+i.x)/2,clientY:(e.y+i.y)/2});this.x=n.x,this.y=n.y,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.initialDistance=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2))}onTouchmove(t){t.preventDefault(),this.touchMode==1&&t.touches.length==1?(this.onMousemoveTemp(t.touches[0]),this.onMousemove(t.touches[0])):this.touchMode==2&&t.touches.length==2&&this.onBothTouchmove(t)}onMousemove(t){const e=this.getPos(t);this.mousePosition.x=e.x,this.mousePosition.y=e.y,this.isMouseover=!0,this.isMoveRedrawing&&this.draw()}onMousemoveTemp(t){const{screenX:e,screenY:i}=this.screenPos;(Math.abs(e-t.screenX)>10||Math.abs(i-t.screenY)>10)&&(this.timeout&&clearTimeout(this.timeout),this.offset.x=this.curOffset.x+(this.mousePosition.x-this.x),this.offset.y=this.curOffset.y+(this.mousePosition.y-this.y),!this.isMoveRedrawing&&this.draw())}onBothTouchmove(t){if(t.preventDefault(),this.initialDistance){const e={x:t.touches[0].clientX,y:t.touches[0].clientY},i={x:t.touches[1].clientX,y:t.touches[1].clientY},n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));if(this.scale+=(n-this.initialDistance)/30*this.STEP_SCALE,this.initialDistance=n,this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}}onTouchend(){this.touchMode=0,this.onMouseup()}onMouseup(){this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.canvas.removeEventListener("mousemove",this.onMousemoveTemp),this.canvas.removeEventListener("mouseup",this.onMouseup),this.canvas.removeEventListener("touchmove",this.onTouchmove),this.canvas.removeEventListener("touchend",this.onTouchend)}onMousewheel(t){this.timeout&&clearTimeout(this.timeout),t.preventDefault();const e=this.getPos(t);this.x=e.x,this.y=e.y;const i=t.wheelDelta>0||t.detail<0?this.STEP_SCALE:-this.STEP_SCALE;if(this.scale=parseFloat((this.scale+i).toFixed(2)),this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}onTouch(t){const e=Date.now(),{lastTouchTime:i=0,lastTouchX:n=0,lastTouchY:o=0}=this.lastTouch||{};e-i<300&&Math.abs(t.clientX-n)<30&&Math.abs(t.clientY-o)<30?(this.onDblclick(t),this.lastTouch={lastTouchTime:0,lastTouchX:0,lastTouchY:0}):(this.onClick(t),this.lastTouch={lastTouchTime:e,lastTouchX:t.clientX,lastTouchY:t.clientY})}onDblclick(t){this.timeout&&clearTimeout(this.timeout),this.reset(),this.draw()}zoom(){this.offset.x=this.x-(this.x-this.offset.x)*this.scale/this.preScale,this.offset.y=this.y-(this.y-this.offset.y)*this.scale/this.preScale,this.draw(),this.preScale=this.scale,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y}reset(t){const{width:e=this.width,height:i=this.height,scale:n=1,preScale:o=1,offset:r={x:0,y:0},curOffset:a={x:0,y:0}}=t||{};this.width=e,this.height=i,this.canvas.width=e,this.canvas.height=i,this.scale=n,this.preScale=o,this.offset=r,this.curOffset=a}drawAssist(){const t=this.ctx;t.save(),t.beginPath(),t.lineWidth=1,t.strokeStyle="#C656D5",t.moveTo(0,this.mousePosition.y),t.lineTo(this.width,this.mousePosition.y),t.closePath(),t.stroke(),t.beginPath(),t.moveTo(this.mousePosition.x,0),t.lineTo(this.mousePosition.x,this.height),t.closePath(),t.stroke(),t.restore()}draw(){this.ctx.clearRect(0,0,this.width,this.height),this.ctx.save(),this.ctx.translate(this.offset.x,this.offset.y),this.ctx.scale(this.scale,this.scale),this.options.draw(this.ctx,this),this.ctx.restore(),this.isDrawAssist&&this.isMouseover&&(this.customDrawAssist?this.customDrawAssist():this.drawAssist()),this.afterDraw?.(this.ctx,this)}getPos(t){const e=this.canvas.getBoundingClientRect();let i=parseFloat((t.clientX-e.left).toFixed(2)),n=parseFloat((t.clientY-e.top).toFixed(2));return i=i<0?0:i,n=n<0?0:n,{x:i,y:n}}unBindEvent(){this.isBindEvent&&(this.canvas.removeEventListener("mousemove",this.onMousemove),this.canvas.removeEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.removeEventListener("mousewheel",this.onMousewheel),this.canvas.removeEventListener("mousedown",this.onMousedown),this.canvas.removeEventListener("mouseout",this.onMouseout),this.canvas.removeEventListener("dblclick",this.onDblclick))}}const et={};class At{type="image";x;y;width;height;img;src;redraw;constructor(t){this.x=t.x||0,this.y=t.y||0,this.width=t.width||0,this.height=t.height||0,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=et[this.src];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.crossOrigin="anonymous",i.src=this.src,i.onload=()=>{et[this.src]=i,t?.(i),this.redraw?.()},i}}draw(t){try{if(!this.img.complete)return;t.save(),t.drawImage(this.img,this.x,this.y,this.width,this.height),t.restore()}catch(e){console.error(e)}}}class kt{id="";type="point";x;y;r;text;backgroundColor;index;pIndex;parentId;constructor(t){this.id=t.id,this.x=t.x,this.y=t.y,this.r=t.r||15,this.text=t.text||"",this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.backgroundColor=t.backgroundColor||"rgba(91, 179, 111, 0.8)"}draw(t,e){t.save();const i=1/e.scale;t.beginPath(),t.arc(this.x,this.y,this.r*i,0,2*Math.PI),t.fillStyle=this.backgroundColor,t.fill(),t.font=`${this.r*i}px Microsoft YaHei`,t.textAlign="center",t.fillStyle="#FFFFFF",t.fillText(this.text,this.x,this.y+this.r*i/3),t.restore()}}const st={};class Xt{id="";type="issue";x;y;width;height;src;img;index;pIndex;parentId;count;badgeR;redraw;constructor(t){this.id=t.id,this.x=t.x,this.y=t.y,this.width=t.width||0,this.height=t.height||0,this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.count=t.count||0,this.badgeR=3,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=st[this.src];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.src=this.src,i.crossOrigin="anonymous",i.onload=()=>{st[this.src]=i,t?.(i),this.redraw?.()},i}}draw(t,e){if(!this.img.complete)return;const i=1/e.scale,n=this.width*i,o=this.height*i,r=this.x-n/2,a=this.y-o,h=this.badgeR*i,u=h*1.5;t.save(),t.drawImage(this.img,r,a,n,o),t.beginPath(),this.count>1&&(t.arc(this.x+n*.3,this.y-o*.8,h,0,2*Math.PI),t.fillStyle="red",t.fill(),t.font=`${u}px Microsoft YaHei`,t.textAlign="center",t.fillStyle="#FFFFFF",t.fillText(this.count.toString(),this.x+n*.3,this.y-o*.8+h/2)),t.restore()}}const it={};class Ft{type="marker";x;y;url;width;height;anchor;img;scale;redraw;beforeDraw;constructor(t){this.x=t.x,this.y=t.y,this.url=t.url,this.width=t.width??0,this.height=t.height??0,this.anchor=t.anchor,this.scale=t.scale??1,t.redraw&&(this.redraw=t.redraw),t.beforeDraw&&(this.beforeDraw=t.beforeDraw),this.img=this.loadImage(t.onload)}loadImage(t){const e=it[this.url];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.src=this.url,i.crossOrigin="anonymous",i.onload=()=>{it[this.url]=i,t?.(i),this.redraw?.()},i}}calculateIconPosition(){const t=this.anchor?.x??this.width/2,e=this.anchor?.y??this.height/2;return{iconStartX:this.x-t*this.scale,iconStartY:this.y-e*this.scale}}draw(t,e){if(this.beforeDraw?.(t,e),!this.img?.complete)return;const{iconStartX:i,iconStartY:n}=this.calculateIconPosition();t.save();try{t.drawImage(this.img,i,n,this.width*this.scale,this.height*this.scale)}catch(o){console.error("绘制标记时出错:",o)}finally{t.restore()}}}class Ut{type="radar";x;y;r;angle;text;hFov=90;beforeDraw;constructor(t){this.x=t.x,this.y=t.y,this.r=t.r||15,this.angle=t.angle||0,this.text=t.text||"",this.hFov=t.fovh||90,this.beforeDraw=t.beforeDraw}draw(t,e){this.beforeDraw?.(t,e);const i=1/e.scale,[n,o]=[(this.angle-this.hFov/2)/180*Math.PI,(this.angle+this.hFov/2)/180*Math.PI];t.save();const r=t.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r*i);r.addColorStop(0,"rgba(180, 42, 42, 1)"),r.addColorStop(1,"rgba(180, 42, 42, 0.5)"),t.beginPath(),t.moveTo(this.x,this.y),t.arc(this.x,this.y,this.r*i,n,o),t.closePath(),t.fillStyle=r,t.fill(),t.restore()}}class Yt{type="region";x;y;shape;areaPoints;backgroundColor;constructor(t){if(this.x=t.x,this.y=t.y,this.shape=t.shape||"",this.backgroundColor=t.backgroundColor,t.areaPoints.length===2){const[{x:e,y:i},{},{x:n,y:o}]=t.areaPoints;this.areaPoints=[{x:Math.min(e,n),y:Math.min(i,o)},{x:Math.max(e,n),y:Math.min(i,o)},{x:Math.max(e,n),y:Math.max(i,o)},{x:Math.min(e,n),y:Math.max(i,o)}]}else this.areaPoints=t.areaPoints}draw(t,e){if(t.save(),t.beginPath(),t.globalAlpha=.3,t.fillStyle=this.backgroundColor,this.shape==="circle"){const[{x:i,y:n},{},{x:o,y:r}]=this.areaPoints,a=Math.abs(o-i)/2,h=i+(o-i)/2,u=n+(r-n)/2;t.arc(h,u,a,0,2*Math.PI)}else this.areaPoints.forEach((i,n)=>{const{x:o,y:r}=i;n===0?t.moveTo(o,r):t.lineTo(o,r)});t.fill(),t.restore()}}l.APP_SETTING=G,l.AppError=f,l.AppErrorCode=w,l.AppObsType=Y,l.CanvasElement=jt,l.CanvasImageElement=At,l.CanvasIssueElement=Xt,l.CanvasMarkerElement=Ft,l.CanvasPointElement=kt,l.CanvasRadarElement=Ut,l.CanvasRegionElement=Yt,l.Coordinate=tt,l.CoordinateLevel=U,l.CoordinateModelType=T,l.CoordinateStatus=I,l.CoordinateType=x,l.DataSource=g,l.GeoPoint=C,l.Point=y,l.Position=X,l.RelativeMap=M,l.RequestContentType=z,l.RequestMethod=p,l.RequestResultCode=R,l.Vector3=F,l.api=dt,l.http=lt,l.utils=Lt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(l,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(l=typeof globalThis<"u"?globalThis:l||self,f(l.Shared={}))})(this,(function(l){"use strict";class f extends Error{constructor(t,e,i){super(e),this.code=t,this.message=e,this.details=i,this.name="Apprror",Object.setPrototypeOf(this,f.prototype)}toJSON(){return{code:this.code,message:this.message,details:this.details,timestamp:new Date().toISOString()}}}var C=(s=>(s[s.CADModel=5]="CADModel",s[s.BIMModel=6]="BIMModel",s[s.ForgeModel=7]="ForgeModel",s[s.ThreeDModel=8]="ThreeDModel",s[s.SkyMapModel=9]="SkyMapModel",s[s.ScaleModel=10]="ScaleModel",s))(C||{}),U=(s=>(s[s.Global=0]="Global",s))(U||{}),b=(s=>(s[s.Space=0]="Space",s[s.Model=1]="Model",s[s.Data=2]="Data",s))(b||{}),I=(s=>(s[s.Used=0]="Used",s[s.Enabled=1]="Enabled",s[s.Disabled=2]="Disabled",s))(I||{}),L=(s=>(s[s.SUCCESS=200]="SUCCESS",s[s.ERROR=-1]="ERROR",s[s.TIMEOUT=401]="TIMEOUT",s))(L||{}),g=(s=>(s.GET="GET",s.POST="POST",s))(g||{}),R=(s=>(s.JSON="application/json",s.FORM_URLENCODED="application/x-www-form-urlencoded;charset=UTF-8",s.FORM_DATA="multipart/form-data;charset=UTF-8",s.OCTET_STREAM="'application/octet-stream",s))(R||{}),Y=(s=>(s.Hw="huawei",s.Ali="aliyun",s.Hs="hs",s.Aws="amazon",s.Minio="minio",s))(Y||{}),w=(s=>(s[s.GeoPointNoPlane=9e3]="GeoPointNoPlane",s[s.PointUnmappedGIS=9010]="PointUnmappedGIS",s[s.PointNoXYZ=9011]="PointNoXYZ",s[s.PointNoPlane=9012]="PointNoPlane",s[s.RelativePlaneUnmatch=9020]="RelativePlaneUnmatch",s[s.RelativeNoPlane=9021]="RelativeNoPlane",s[s.RelativeJsonError=9022]="RelativeJsonError",s[s.RequestCodeError=9030]="RequestCodeError",s[s.RequestResultError=9031]="RequestResultError",s[s.RequestUnknownError=9032]="RequestUnknownError",s))(w||{});const G={baseUrl:"https://vsleem.com/api",obsType:"hs",authorizeCode:""},ot={isTransformResponse:!0,joinBaseUrl:!0,withAuthorize:!0},rt={url:"",method:g.GET,headers:{}},B={...G};function at(s){Object.assign(B,s)}async function S(s,t){const e={...ot,...t},i={...rt,...s};try{const n=ht(i,e),{url:o,...r}=n,h=await(await window.fetch(o,r)).json();return ct(h,e)}catch(n){return lt(n)}}function ht(s,t){const{baseUrl:e,authorizeCode:i}=B,{joinBaseUrl:n,withAuthorize:o}=t;let{url:r,method:a,headers:h={},params:u,data:c}=s;n&&e&&(r=`${e}${r}`),a=a?.toUpperCase();const d={...h};if(/^https?:\/\/.+$/i.test(e??"")?d.PlatForm=new URL(e??"").host:d.PlatForm=new URL(window.location.href).host,o&&i&&(d.AuthorizationCode=i),a===g.POST&&!d["Content-Type"]&&(d["Content-Type"]=R.JSON),a===g.GET&&u){const x=new URLSearchParams(u);r+=`?${x.toString()}`}let m;return a===g.POST&&(m=d["Content-Type"]===R.JSON?JSON.stringify(c||{}):c),{url:r,method:a,headers:d,body:m}}function ct(s,t){if(!t.isTransformResponse)return s;if(!s)throw new f(w.RequestResultError,"请求返回的结果错误");const{code:e,data:i,msg:n}=s;if(e===L.SUCCESS)return i;throw new f(w.RequestCodeError,n||"请求返回的Code错误")}function lt(s){throw s instanceof Error?s:new f(w.RequestUnknownError,typeof s=="string"?s:"未知的请求错误")}const ut=Object.freeze(Object.defineProperty({__proto__:null,request:S,setRequestGlobalConfig:at},Symbol.toStringTag,{value:"Module"}));function $(s,t){return S({url:"/project/jssdk/cs/list",method:g.GET,params:s},t)}function _(s,t){return S({url:"/project/jssdk/cs/bind",method:g.POST,data:s},t)}function k(s,t){return S({url:"/project/jssdk/cs/save",method:g.POST,data:s},t)}function q(s,t){return S({url:"/project/jssdk/cs/delete",method:g.POST,data:s},t)}function Z(s,t){return S({url:"/project/jssdk/cs/mapping",method:g.POST,data:s},t)}function J(s,t){return S({url:"/project/jssdk/cs/mapping/query",method:g.GET,params:s},t)}function dt(s,t={isTransformResponse:!1,joinBaseUrl:!1,withAuthorize:!1}){return S({url:s,method:g.GET},t)}const ft=Object.freeze(Object.defineProperty({__proto__:null,bindCoordinate:_,getCoordinateList:$,getImageInfo:dt,getMappingRelation:J,mapingCoordinate:Z,removeCoordinate:q,saveCoordinate:k},Symbol.toStringTag,{value:"Module"})),mt=typeof window<"u",yt=Object.prototype.toString;function T(s,t){return yt.call(s)===`[object ${t}]`}function H(s){return typeof s<"u"}function V(s){return!H(s)}function P(s){return s!==null&&T(s,"Object")}function W(s){return s===null}function wt(s){return T(s,"Date")}function pt(s){return T(s,"String")}function A(s){return typeof s=="function"}function gt(s){return T(s,"Boolean")}function Mt(s){return T(s,"RegExp")}function v(s){return s&&Array.isArray(s)}function vt(s){return typeof window<"u"&&T(s,"Window")}function xt(s){return P(s)&&!!s.tagName}function E(s){return typeof s=="number"||/^\d+(\.\d+)?$/.test(String(s??""))}function bt(s,t){return JSON.stringify(s)===JSON.stringify(t)}function St(s){return V(s)||W(s)}function Tt(s){return T(s,"Promise")&&P(s)&&A(s.then)&&A(s.catch)}function Q(s){return D(s,new WeakMap)}function D(s,t){if(typeof s!="object"||s===null)return s;if(t.has(s))return t.get(s);let e;if(s instanceof Date)return e=new Date(s),t.set(s,e),e;if(s instanceof RegExp)return e=new RegExp(s),t.set(s,e),e;if(s instanceof Map)return e=new Map,t.set(s,e),s.forEach((n,o)=>{e.set(o,D(n,t))}),e;if(s instanceof Set)return e=new Set,t.set(s,e),s.forEach(n=>{e.add(D(n,t))}),e;if(ArrayBuffer.isView(s))return e=new s.constructor(s.buffer.slice(0),s.byteOffset,s.byteLength),t.set(s,e),e;if(s instanceof ArrayBuffer)return e=s.slice(0),t.set(s,e),e;if(Array.isArray(s)){e=[],t.set(s,e);for(let n=0;n<s.length;n++)n in s&&(e[n]=D(s[n],t));return e}e=Object.create(Object.getPrototypeOf(s)),t.set(s,e);for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=D(s[n],t));const i=Object.getOwnPropertySymbols(s);for(const n of i)Object.prototype.propertyIsEnumerable.call(s,n)&&(e[n]=D(s[n],t));return e}function Pt(s,t,e=!1){let i;const n=function(...o){const r=this,a=e&&!i;i&&clearTimeout(i),i=setTimeout(()=>{i=void 0,e||s.apply(r,o)},t),a&&s.apply(r,o)};return n.cancel=()=>{i&&clearTimeout(i),i=void 0},n}function Et(s,t,e=!1){let i,n;const o=function(...r){const a=this;n?(clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=t&&(s.apply(a,r),n=Date.now())},t-(Date.now()-n))):(e&&s.apply(a,r),n=Date.now())};return o.cancel=()=>{clearTimeout(i),i=void 0,n=void 0},o}function j(s,...t){if(!t.length)return s;const e=t.shift();return e===void 0?s:(O(s)&&O(e)&&Object.keys(e).forEach(i=>{const n=s[i],o=e[i];Array.isArray(n)&&Array.isArray(o)?s[i]=[...n,...o]:O(n)&&O(o)?s[i]=j({...n},o):o!==void 0&&(s[i]=o)}),j(s,...t))}function O(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function K(s,...t){if(!t.length)return s;for(const e of t)e!=null&&typeof e=="object"&&Object.keys(e).forEach(i=>{const n=e[i],o=s[i];n!==null&&typeof n=="object"&&!Array.isArray(n)?((!o||typeof o!="object")&&(s[i]={}),K(s[i],n)):s[i]=n});return s}function tt(s,t){const e={};if(P(s)&&!v(s)){for(const i in s)if(Object.prototype.hasOwnProperty.call(s,i)){const n=s[i],o=P(t)&&!v(t)?t[i]:void 0;if(!(i in(t||{})))e[i]=n;else if(v(n)&&v(o))JSON.stringify(n)!==JSON.stringify(o)&&(e[i]=n);else if(P(n)&&P(o)){const r=tt(n,o);r&&Object.keys(r).length>0&&(e[i]=r)}else n!==o&&(e[i]=n)}}if(P(t)&&v(t))for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&!(i in(s||{}))&&(e[i]=void 0);return e}function Ct(s,t={}){return new Promise((e,i)=>{const n=N(s);if(Dt(n)){e(!0);return}const o=document.createElement("script");o.src=s,Object.entries(t).forEach(([r,a])=>{a!==!1&&o.setAttribute(r,a===!0?"":String(a))}),o.onload=()=>{e(!0)},o.onerror=()=>{document.head.removeChild(o),i(new Error(`Failed to load script: ${s}`))},document.head.appendChild(o)})}function Dt(s){const t=N(s);return Array.from(document.scripts).some(e=>N(e.src)===t)}function Nt(s){return new Promise((t,e)=>{const i=N(s);if(zt(i)){t(!0);return}const n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=s,n.onload=()=>{t(!0)},n.onerror=()=>{document.head.removeChild(n),e(new Error(`Failed to load link: ${s}`))},document.head.appendChild(n)})}function zt(s){const t=N(s);return Array.from(document.links).some(e=>N(e.href)===t)}function N(s){try{const t=new URL(s,window.location.href);return`${t.origin}${t.pathname}`}catch{return s}}function It(s,t,e,i){const n=Math.min(s/e,t/i),o=e*n,r=i*n;return{scale:n,x:(s-o)/2,y:(t-r)/2,sw:o,sh:r}}function Rt(s,t,e){return{x:s*e.scale+e.x,y:t*e.scale+e.y}}function Ot(s,t,e){return{x:(s-e.x)/e.scale,y:(t-e.y)/e.scale}}function Lt(s){console.warn(`[warn]:${s}`)}function kt(s){throw new Error(`[error]:${s}`)}const At=Object.freeze(Object.defineProperty({__proto__:null,cloneDeep:Q,debounce:Pt,deepMerge:j,deepMergeProps:K,error:kt,getDiffProps:tt,getImageTransform:It,inBrowser:mt,is:T,isArray:v,isBoolean:gt,isDate:wt,isDef:H,isElement:xt,isFunction:A,isNull:W,isNullOrUnDef:St,isNumber:E,isObject:P,isPromise:Tt,isRegExp:Mt,isSameValue:bt,isString:pt,isUnDef:V,isWindow:vt,loadCss:Nt,loadScript:Ct,throttle:Et,toCanvasCoord:Rt,toModelCoord:Ot,warn:Lt},Symbol.toStringTag,{value:"Module"}));class y{x=0;y=0;z=0;lat=0;lon=0;alt=0;yaw=0;pitch=0;roll=0;hasXYZ=!1;hasGeo=!1;hasAngle=!1;plane="xy";constructor(t){const{x:e,y:i,z:n,lat:o,lon:r,alt:a,yaw:h,pitch:u,roll:c,plane:d="xy"}=t||{};E(e)&&E(i)&&Number(e)!==0&&Number(i)!==0&&(this.x=Number(e)||0,this.y=Number(i)||0,this.z=Number(n)||0,this.plane=d,this.hasXYZ=!0),E(o)&&E(r)&&Number(o)!==0&&Number(r)!==0&&(this.lat=Number(o)||0,this.lon=Number(r)||0,this.alt=Number(a)||0,this.hasGeo=!0),(E(h)||E(u)||E(c))&&(this.yaw=Number(h)||0,this.pitch=Number(u)||0,this.roll=Number(c)||0,this.hasAngle=!0)}static dist(t,e){return Math.hypot(t.x-e.x,t.y-e.y,t.z-e.z)}static distXZ(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}static distXY(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}static toRadians(t){return(Number(t)||0)*Math.PI/180}static toDegrees(t){return(Number(t)||0)*180/Math.PI}static angleXZ(t,e,i){const n={x:t.x-e.x,z:t.z-e.z},o={x:i.x-e.x,z:i.z-e.z},r=n.x*o.x+n.z*o.z,a=Math.sqrt(n.x**2+n.z**2),h=Math.sqrt(o.x**2+o.z**2),u=Math.max(-1,Math.min(1,r/(a*h))),d=Math.acos(u)*180/Math.PI;return Math.min(d,360-d)}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new y({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}projection(t,e,i){try{if(e?.id===i?.id)return new y(this);if(e?.modelType===C.SkyMapModel){const{refPoint:n}=e?.relativeMap||{};if(this?.hasXYZ)return this.project(t);if(this.hasGeo&&n){const o=z.LLHToXYZ(this,n);return this.x=o.x,this.y=o.y,this.z=o.z,this.hasXYZ=!0,this.project(t)}throw new f(w.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}if(i?.modelType===C.SkyMapModel){const{refPoint:n}=i?.relativeMap||{};if(this?.hasGeo)return new y(this);const o=this.project(t);if(o?.hasXYZ&&n){const r=z.XYZToLLH(o,n);return o.lat=r.lat,o.lon=r.lon,o.alt=r.alt,o.hasGeo=!0,o}throw new f(w.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}return this.project(t)}catch{return}}project(t){if(!this.hasXYZ)throw new f(w.PointNoXYZ,"点没有xxz坐标信息");if(this.plane==="xz")return this.projectXZ(t);if(this.plane==="xy")return this.projectXY(t);throw new f(w.PointNoPlane,"点的plane应为xz或xy")}projectXZ(t){const e=new y(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const i=e.x*Math.cos(t.yaw)-e.z*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.z*Math.cos(t.yaw);return e.x=i+t.x,e.y+=t.y,e.z=n+t.z,e}projectXY(t){const e=new y(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const i=e.x*Math.cos(t.yaw)-e.y*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.y*Math.cos(t.yaw);return e.x=i+t.x,e.y=n+t.y,e.z+=t.z,e}}class z{lat=0;lon=0;alt=0;constructor(t){const{lat:e=0,lon:i=0,alt:n=0}=t||{};this.lat=e,this.lon=i,this.alt=n}static XYZToLLH(t,e){const n=.0033528106647474805,o=n*(2-n),r=y.toRadians(e.lat),a=6378137/Math.sqrt(1-o*Math.sin(r)**2)+e.alt;let h,u,c;if(t.plane==="xz"){const d=t.x/1e3/(a*Math.cos(r)),m=t.z/1e3/a;h=e.lon+y.toDegrees(d),u=e.lat-y.toDegrees(m),c=e.alt+t.y/1e3}else if(t.plane==="xy"){const d=t.x/1e3/(a*Math.cos(r)),m=t.y/1e3/a;h=e.lon+y.toDegrees(d),u=e.lat-y.toDegrees(m),c=e.alt+t.z/1e3}else throw new f(w.GeoPointNoPlane,"点的plane应为xz或xy");return new z({lat:u,lon:h,alt:c})}static LLHToXYZ(t,e){const n=.0033528106647474805,o=n*(2-n),r=y.toRadians(e.lat),a=6378137/Math.sqrt(1-o*Math.sin(r)**2)+e.alt,h=y.toRadians(t.lon-e.lon),u=y.toRadians(e.lat-t.lat),c=a*h*Math.cos(r),d=a*u;if(t.plane==="xz")return new y({x:c*1e3,y:(t.alt-e.alt)*1e3,z:d*1e3,plane:"xz"});if(t.plane==="xy")return new y({x:c*1e3,y:d*1e3,z:(t.alt-e.alt)*1e3,plane:"xy"});throw new f(w.GeoPointNoPlane,"点的plane应为xz或xy")}}class M{scale=1;yaw=0;x=0;y=0;z=0;start=0;end=-1;plane="xy";refPoint;constructor(t){const{refPoint:e,...i}=t||{};e&&(this.refPoint=new z(e)),Object.assign(this,i)}static addRelativeMap(t,e){if(t.plane!==e.plane)throw new f(w.RelativePlaneUnmatch,"两个映射关系的plane应该相同");const i=t.scale*e.scale,n=t.yaw+e.yaw,o=Math.cos(e.yaw),r=Math.sin(e.yaw);let a=0,h=0,u=0;if(t.plane==="xz"){const c=t.x*o-t.z*r,d=t.y,m=t.x*r+t.z*o;a=e.x+c*e.scale,h=e.y+d*e.scale,u=e.z+m*e.scale}else if(t.plane==="xy"){const c=t.x*o-t.y*r,d=t.x*r+t.y*o,m=t.z;a=e.x+c*e.scale,h=e.y+d*e.scale,u=e.z+m*e.scale}else throw new f(w.RelativeNoPlane,"映射关系的plane应为xz或xy");return new M({scale:i,yaw:n,x:a,y:h,z:u,start:t.start,end:t.end,plane:t.plane})}static inverseRelativeMap(t){const e=1/t.scale,i=-t.yaw,n=Math.cos(-i),o=Math.sin(-i);let r=0,a=0,h=0;if(t.plane==="xz")r=-(t.x*n+t.z*o)*e,a=-t.y*e,h=-(t.z*n-t.x*o)*e;else if(t.plane==="xy")r=-(t.x*n+t.y*o)*e,a=-(t.y*n-t.x*o)*e,h=-t.z*e;else throw new f(w.RelativeNoPlane,"映射关系的plane应为xz或xy");return new M({scale:e,yaw:i,x:r,y:a,z:h,start:t.start,end:t.end,plane:t.plane})}static toParse(t){try{let e=t?JSON.parse(t):void 0;const{reference_point:i}=e||{};return i&&(e={refPoint:i}),e?new M(e):void 0}catch{throw new f(w.RelativeJsonError,"relativeMap格式化失败")}}static toStringify(t){return t?JSON.stringify(t):void 0}}class p{static async getCoordinateTree(t){const e=await $({projectId:t});if(e.length){const i=p.handleCoordinateList(e);return p.buildCoordinateTree(i,0)}}static async addCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{type:h,modelType:u,relativeMap:c,level:d,...m}=a,x=c?JSON.stringify(c):void 0;return{...m,projectId:i,parentId:n,coordinateType:h,renderType:u,relativePosition:x}}),r=await k(o);return p.handleCoordinateList(r)}static async removeCoordinate(t,e){const i=e.map(n=>n.id??-1);return await q(i)}static async updateCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{type:h,relativeMap:u,level:c,...d}=a,m=M.toStringify(u);return{...d,relativePosition:m,projectId:i,parentId:n}}),r=await k(o);return p.handleCoordinateList(r)}static async bindCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{modelId:h}=a;return{modelId:h,parentId:n,projectId:i}}),r=await _(o);return p.handleCoordinateList(r)}static handleCoordinateList(t){return t?.map(e=>{const{coordinateType:i,modelKey:n,renderType:o,relativePosition:r,...a}=e,h=M.toParse(r);return new et({...a,type:i,modelType:o,modelValue:n,relativeMap:h})})}static buildCoordinateTree(t,e){const i=new Map,n=[];return t.forEach(o=>{i.set(String(o.id),o)}),t.forEach(o=>{const r=i.get(String(o.id));if(r)if(o.parentId===e)r.level=0,n.push(r);else{const a=i.get(String(o.parentId??-1));a&&(r.level=(Number(a.level)||0)+1,r.parent=a,a.children?.push(r))}}),n.forEach(p.sortCoordinateTree),n[0]}static sortCoordinateTree(t){t.children&&(t.children.sort((e,i)=>{if(e.type===b.Space){const n=Number(i?.relativeMap?.z)-Number(e?.relativeMap?.z);return n!==0?n:Number(i.createTime)-Number(e.createTime)}else return e.status===0&&i.status!==0?-1:i.status===0&&e.status!==0?1:Number(i.createTime)-Number(e.createTime)}),t.children.forEach(p.sortCoordinateTree))}static filterSpaceTree(t){const e=[];return t.forEach(i=>{const n=p.filterSpaceTree(i.children);i.children=n,i.disabled=i.disabled??!1,i.type!==b.Model&&e.push(i)}),e}}class et{id=0;type=0;children=[];level;relativeMap;no;name;shortName;status;modelId;modelType;modelValue;projectId;parentId;parent;groupUuid;z;createTime;disabled;constructor(t){this.setOptions(t)}get spaceList(){return this.children.filter(t=>t.type===b.Space)}get modelList(){return this.children.filter(t=>t.type===b.Model)}get fullName(){const t=this.name?`(${this.name})`:"";return this.shortName?`${this.shortName}${t}`:this.name??""}setOptions(t){const{relativeMap:e,parent:i,children:n,...o}=t||{};e&&(this.relativeMap=new M(e)),i&&(this.parent=i),n?.length&&(this.children=n),Object.assign(this,o)}async addChild(t){const e=v(t)?t:[t],i=await p.addCoordinate(this,e);this.mergeChild(i)}async removeChild(t){const e=v(t)?t:[t];await p.removeCoordinate(this,e);for(const i of e){const n=this.children.findIndex(o=>o.id===i.id);n!==-1&&this.children.splice(n,1)}}async updateChild(t){const e=v(t)?t:[t],i=await p.updateCoordinate(this,e);this.mergeChild(i)}async bindChild(t){const e=v(t)?t:[t],i=await p.bindCoordinate(this,e);this.mergeChild(i)}async mergeChild(t){t?.length&&t.forEach(e=>{const i=this.children.find(n=>n.id===e.id);if(i){const{relativeMap:n,no:o,name:r,shortName:a,status:h,modelId:u,modelValue:c}=e;Object.assign(i,{relativeMap:n,no:o,name:r,shortName:a,status:h,modelId:u,modelValue:c})}else this.id===e.parentId&&(e.parent=this,this.children.unshift(e))})}async mappingTo(t){await Z(t)}async fromMapping(){const t=await J({srcCsId:this.id});return t[t.length-1]}findRoot(t=!1){let e=this;for(;e.parent&&!(t&&!e.relativeMap);)e=e.parent;return e}findChildModel(t=[C.CADModel,C.SkyMapModel],e=!0){const i=v(t)?t:[t];return i.includes(this.modelType??-1)&&this.status!==I.Disabled?this:([b.Data,b.Model].includes(this.type)?this.findParentSpace():this)?.modelList?.filter(a=>i.includes(a.modelType??-1)?e?!!a.relativeMap:!0:!1)?.sort((a,h)=>Number(a.status)-Number(h.status))?.[0]}findClosestModel(t=C.CADModel,e){const i=new Set;for(const u of e??[])i.add(String(u.id));const n=[{node:this,distance:0}],o=v(t)?t:[t],r=new Set;let a,h=1/0;for(;n.length>0;){const u=n.shift();if(!u)break;const{node:c,distance:d}=u;if(i.has(String(c.id)))continue;if(o.includes(c.modelType??-1)){if(d<h&&(a=c,h=d,d<=1))break;continue}r.add(c);const m=[];if(c.children)for(const x of c.children)r.has(x)||m.push(x);if(c.parent?.children)for(const x of c.parent.children)x!==c&&!r.has(x)&&m.push(x);c.parent&&!r.has(c.parent)&&m.push(c.parent);for(const x of m)n.push({node:x,distance:d+1})}return a}findParentSpace(){let t=this;for(;t&&t.type!==b.Space;)t=t.parent;return t}findParentSpaceNames(t=2){const e=[];let i=this;for(;i&&t>0;)i.type===b.Space&&(e.unshift(i.fullName),t--),i=i.parent;return e}findCsGroup(){const{groupUuid:t,parent:e}=this;return t?e?.children?.filter(i=>i.groupUuid===t)||[]:[this]}findCsByLevel(t){if(this.level===t)return this;if(this.children.length)for(const e of this.children){const i=e.findCsByLevel(t);if(i)return i}}findCsById(t){if(t){if(this.id===t)return this;for(const e of this.children){const i=e.findCsById(t);if(i)return i}}}getCsRoutes(t=!1){let e=this;const i=[e];for(;e?.parent&&!(t&&!e.relativeMap);)e=e.parent,e&&i.push(e);return i}getMappedCsTree(){function t(n){return n.children?.length&&(n.children=n.children.filter(o=>!!o?.relativeMap&&o.status!==I.Disabled).map(o=>t(o))),n}const e=Q(this.findRoot(!0)),i=t(e);return i.parentId=0,i.parent=void 0,i}getDestRelativeMap(t){if(this.id===t.id)return new M;const e=this.getRelativeMaps(),i=t.getRelativeMaps();let n=new M;return e?.forEach(o=>{n=M.addRelativeMap(n,o)}),i?.reverse()?.forEach(o=>{n=M.addRelativeMap(n,M.inverseRelativeMap(o))}),n}getRelativeMaps(){let t=this;const e=[];for(;t?.parent&&t.relativeMap;)e.push(t.relativeMap),t=t.parent;return e}static filterCoordinateTree(t,e=[],i=[]){if(i.includes(t.id)||e.includes(t.type))return;const n=t.children?.map(o=>this.filterCoordinateTree(o,e,i)).filter(o=>o!==void 0);return{...t,children:n}}static getCommonCoordinate(t){let e;const i=t.map(n=>n.getCsRoutes(!0).filter(r=>r.id&&r.type===b.Space));for(;this.checkSameCoordinate(i);){const o=i.shift();o?.length&&(e=o[0])}return e}static checkSameCoordinate(t){if(t.length){if(t.length===1)return!0;for(let e=0;e<t.length-1;e++){const i=t[e];if(!i?.length)return!1;const n=t[e+1];if(!n?.length||i[0].id!==n[0].id)return!1}return!0}else return!1}}class X{yaw=0;pitch=0;roll=0;constructor(t){const{yaw:e=0,pitch:i=0,roll:n=0}=t||{};this.yaw=Number(e)||0,this.pitch=Number(i)||0,this.roll=Number(n)||0}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new X({yaw:e[0],pitch:e[1],roll:e[2]})}}static toStringify(t){return t?`${t.yaw},${t.pitch},${t.roll}`:""}}class F{x=0;y=0;z=0;constructor(t){const{x:e=0,y:i=0,z:n=0}=t||{};this.x=Number(e)||0,this.y=Number(i)||0,this.z=Number(n)||0}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new F({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}}class jt{static srcPointToDstPoint(t,e,i){if(!e||!i||!t?.length)return[];const n=e?.getDestRelativeMap(i);if(!n)return[];const o=[];return t.forEach(r=>{const a=r.projection(n,e,i);a&&o.push(a)}),o}}class Xt{canvas;ctx;options;offset={x:0,y:0};curOffset={x:0,y:0};mousePosition={x:-1,y:-1};MAX_SCALE=60;MIN_SCALE=1;STEP_SCALE=.5;scale=1;preScale=1;width=0;height=0;x=0;y=0;timeout=0;lastTouch;initialDistance=0;touchMode=0;isMouseover=!1;isBindEvent=!0;isDrawAssist=!1;customDrawAssist;isMoveRedrawing;afterDraw;screenPos={screenX:0,screenY:0};constructor(t){const{container:e,width:i=300,height:n=300,isBindEvent:o=!0,isDrawAssist:r=!1,isMoveRedrawing:a,customDrawAssist:h,afterDraw:u,...c}=t;this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.width=i,this.height=n,this.canvas.width=i,this.canvas.height=n,this.isBindEvent=o,this.isDrawAssist=r,this.customDrawAssist=h,this.isMoveRedrawing=a??r,this.options=c,this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMousemoveTemp=this.onMousemoveTemp.bind(this),this.onMouseup=this.onMouseup.bind(this),this.onMousewheel=this.onMousewheel.bind(this),this.onDblclick=this.onDblclick.bind(this),this.onTouchstart=this.onTouchstart.bind(this),this.onTouchmove=this.onTouchmove.bind(this),this.onTouchend=this.onTouchend.bind(this),this.onMouseout=this.onMouseout.bind(this),this.afterDraw=this.afterDraw,o&&(this.canvas.addEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.addEventListener("mousewheel",this.onMousewheel),this.canvas.addEventListener("mousedown",this.onMousedown),this.canvas.addEventListener("mousemove",this.onMousemove),this.canvas.addEventListener("mouseout",this.onMouseout),this.canvas.addEventListener("dblclick",this.onDblclick),this.canvas.addEventListener("touchstart",this.onTouchstart))}onClick(t){const{screenX:e,screenY:i}=t;this.timeout&&clearTimeout(this.timeout);const n=this.getPos(t);this.x=n.x,this.y=n.y,this.screenPos={screenX:e,screenY:i},this.options.onClick&&(this.timeout=setTimeout(()=>{const o=parseFloat(((this.x-this.offset.x)/this.scale).toFixed(2)),r=parseFloat(((this.y-this.offset.y)/this.scale).toFixed(2));this.options.onClick(o,r)},200))}onMouseout(t){this.isMouseover=!1,this.draw()}onTouchstart(t){t.preventDefault(),t.touches.length==1?this.touchMode===0&&(this.touchMode=1):t.touches.length>=2&&this.touchMode<2&&(this.touchMode=2),this.touchMode==1&&t.touches.length==1?this.onTouch(t.touches[0]):this.touchMode==2&&t.touches.length==2&&this.onBothTouchstart(t),this.canvas.addEventListener("touchmove",this.onTouchmove),this.canvas.addEventListener("touchend",this.onTouchend)}onMousedown(t){this.onClick(t),this.canvas.addEventListener("mousemove",this.onMousemoveTemp),this.canvas.addEventListener("mouseup",this.onMouseup)}onBothTouchstart(t){t.preventDefault();const e={x:t.touches[0].clientX,y:t.touches[0].clientY},i={x:t.touches[1].clientX,y:t.touches[1].clientY},n=this.getPos({clientX:(e.x+i.x)/2,clientY:(e.y+i.y)/2});this.x=n.x,this.y=n.y,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.initialDistance=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2))}onTouchmove(t){t.preventDefault(),this.touchMode==1&&t.touches.length==1?(this.onMousemoveTemp(t.touches[0]),this.onMousemove(t.touches[0])):this.touchMode==2&&t.touches.length==2&&this.onBothTouchmove(t)}onMousemove(t){const e=this.getPos(t);this.mousePosition.x=e.x,this.mousePosition.y=e.y,this.isMouseover=!0,this.isMoveRedrawing&&this.draw()}onMousemoveTemp(t){const{screenX:e,screenY:i}=this.screenPos;(Math.abs(e-t.screenX)>10||Math.abs(i-t.screenY)>10)&&(this.timeout&&clearTimeout(this.timeout),this.offset.x=this.curOffset.x+(this.mousePosition.x-this.x),this.offset.y=this.curOffset.y+(this.mousePosition.y-this.y),!this.isMoveRedrawing&&this.draw())}onBothTouchmove(t){if(t.preventDefault(),this.initialDistance){const e={x:t.touches[0].clientX,y:t.touches[0].clientY},i={x:t.touches[1].clientX,y:t.touches[1].clientY},n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));if(this.scale+=(n-this.initialDistance)/30*this.STEP_SCALE,this.initialDistance=n,this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}}onTouchend(){this.touchMode=0,this.onMouseup()}onMouseup(){this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.canvas.removeEventListener("mousemove",this.onMousemoveTemp),this.canvas.removeEventListener("mouseup",this.onMouseup),this.canvas.removeEventListener("touchmove",this.onTouchmove),this.canvas.removeEventListener("touchend",this.onTouchend)}onMousewheel(t){this.timeout&&clearTimeout(this.timeout),t.preventDefault();const e=this.getPos(t);this.x=e.x,this.y=e.y;const i=t.wheelDelta>0||t.detail<0?this.STEP_SCALE:-this.STEP_SCALE;if(this.scale=parseFloat((this.scale+i).toFixed(2)),this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}onTouch(t){const e=Date.now(),{lastTouchTime:i=0,lastTouchX:n=0,lastTouchY:o=0}=this.lastTouch||{};e-i<300&&Math.abs(t.clientX-n)<30&&Math.abs(t.clientY-o)<30?(this.onDblclick(t),this.lastTouch={lastTouchTime:0,lastTouchX:0,lastTouchY:0}):(this.onClick(t),this.lastTouch={lastTouchTime:e,lastTouchX:t.clientX,lastTouchY:t.clientY})}onDblclick(t){this.timeout&&clearTimeout(this.timeout),this.reset(),this.draw()}zoom(){this.offset.x=this.x-(this.x-this.offset.x)*this.scale/this.preScale,this.offset.y=this.y-(this.y-this.offset.y)*this.scale/this.preScale,this.draw(),this.preScale=this.scale,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y}reset(t){const{width:e=this.width,height:i=this.height,scale:n=1,preScale:o=1,offset:r={x:0,y:0},curOffset:a={x:0,y:0}}=t||{};this.width=e,this.height=i,this.canvas.width=e,this.canvas.height=i,this.scale=n,this.preScale=o,this.offset=r,this.curOffset=a}drawAssist(){const t=this.ctx;t.save(),t.beginPath(),t.lineWidth=1,t.strokeStyle="#C656D5",t.moveTo(0,this.mousePosition.y),t.lineTo(this.width,this.mousePosition.y),t.closePath(),t.stroke(),t.beginPath(),t.moveTo(this.mousePosition.x,0),t.lineTo(this.mousePosition.x,this.height),t.closePath(),t.stroke(),t.restore()}draw(){this.ctx.clearRect(0,0,this.width,this.height),this.ctx.save(),this.ctx.translate(this.offset.x,this.offset.y),this.ctx.scale(this.scale,this.scale),this.options.draw(this.ctx,this),this.ctx.restore(),this.isDrawAssist&&this.isMouseover&&(this.customDrawAssist?this.customDrawAssist():this.drawAssist()),this.afterDraw?.(this.ctx,this)}getPos(t){const e=this.canvas.getBoundingClientRect();let i=parseFloat((t.clientX-e.left).toFixed(2)),n=parseFloat((t.clientY-e.top).toFixed(2));return i=i<0?0:i,n=n<0?0:n,{x:i,y:n}}unBindEvent(){this.isBindEvent&&(this.canvas.removeEventListener("mousemove",this.onMousemove),this.canvas.removeEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.removeEventListener("mousewheel",this.onMousewheel),this.canvas.removeEventListener("mousedown",this.onMousedown),this.canvas.removeEventListener("mouseout",this.onMouseout),this.canvas.removeEventListener("dblclick",this.onDblclick))}}const st={};class Ft{type="image";x;y;width;height;img;src;redraw;constructor(t){this.x=t.x||0,this.y=t.y||0,this.width=t.width||0,this.height=t.height||0,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=st[this.src];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.crossOrigin="anonymous",i.src=this.src,i.onload=()=>{st[this.src]=i,t?.(i),this.redraw?.()},i}}draw(t){try{if(!this.img.complete)return;t.save(),t.drawImage(this.img,this.x,this.y,this.width,this.height),t.restore()}catch(e){console.error(e)}}}class Ut{id="";type="point";x;y;r;text;backgroundColor;index;pIndex;parentId;constructor(t){this.id=t.id,this.x=t.x,this.y=t.y,this.r=t.r||15,this.text=t.text||"",this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.backgroundColor=t.backgroundColor||"rgba(91, 179, 111, 0.8)"}draw(t,e){t.save();const i=1/e.scale;t.beginPath(),t.arc(this.x,this.y,this.r*i,0,2*Math.PI),t.fillStyle=this.backgroundColor,t.fill(),t.font=`${this.r*i}px Microsoft YaHei`,t.textAlign="center",t.fillStyle="#FFFFFF",t.fillText(this.text,this.x,this.y+this.r*i/3),t.restore()}}const it={};class Yt{id="";type="issue";x;y;width;height;src;img;index;pIndex;parentId;count;badgeR;redraw;constructor(t){this.id=t.id,this.x=t.x,this.y=t.y,this.width=t.width||0,this.height=t.height||0,this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.count=t.count||0,this.badgeR=3,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=it[this.src];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.src=this.src,i.crossOrigin="anonymous",i.onload=()=>{it[this.src]=i,t?.(i),this.redraw?.()},i}}draw(t,e){if(!this.img.complete)return;const i=1/e.scale,n=this.width*i,o=this.height*i,r=this.x-n/2,a=this.y-o,h=this.badgeR*i,u=h*1.5;t.save(),t.drawImage(this.img,r,a,n,o),t.beginPath(),this.count>1&&(t.arc(this.x+n*.3,this.y-o*.8,h,0,2*Math.PI),t.fillStyle="red",t.fill(),t.font=`${u}px Microsoft YaHei`,t.textAlign="center",t.fillStyle="#FFFFFF",t.fillText(this.count.toString(),this.x+n*.3,this.y-o*.8+h/2)),t.restore()}}const nt={};class Gt{type="marker";x;y;url;width;height;anchor;img;scale;redraw;beforeDraw;constructor(t){this.x=t.x,this.y=t.y,this.url=t.url,this.width=t.width??0,this.height=t.height??0,this.anchor=t.anchor,this.scale=t.scale??1,t.redraw&&(this.redraw=t.redraw),t.beforeDraw&&(this.beforeDraw=t.beforeDraw),this.img=this.loadImage(t.onload)}loadImage(t){const e=nt[this.url];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.src=this.url,i.crossOrigin="anonymous",i.onload=()=>{nt[this.url]=i,t?.(i),this.redraw?.()},i}}calculateIconPosition(){const t=this.anchor?.x??this.width/2,e=this.anchor?.y??this.height/2;return{iconStartX:this.x-t*this.scale,iconStartY:this.y-e*this.scale}}draw(t,e){if(this.beforeDraw?.(t,e),!this.img?.complete)return;const{iconStartX:i,iconStartY:n}=this.calculateIconPosition();t.save();try{t.drawImage(this.img,i,n,this.width*this.scale,this.height*this.scale)}catch(o){console.error("绘制标记时出错:",o)}finally{t.restore()}}}class Bt{type="radar";x;y;r;angle;text;hFov=90;beforeDraw;constructor(t){this.x=t.x,this.y=t.y,this.r=t.r||15,this.angle=t.angle||0,this.text=t.text||"",this.hFov=t.fovh||90,this.beforeDraw=t.beforeDraw}draw(t,e){this.beforeDraw?.(t,e);const i=1/e.scale,[n,o]=[(this.angle-this.hFov/2)/180*Math.PI,(this.angle+this.hFov/2)/180*Math.PI];t.save();const r=t.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r*i);r.addColorStop(0,"rgba(180, 42, 42, 1)"),r.addColorStop(1,"rgba(180, 42, 42, 0.5)"),t.beginPath(),t.moveTo(this.x,this.y),t.arc(this.x,this.y,this.r*i,n,o),t.closePath(),t.fillStyle=r,t.fill(),t.restore()}}class $t{type="region";x;y;shape;areaPoints;backgroundColor;constructor(t){if(this.x=t.x,this.y=t.y,this.shape=t.shape||"",this.backgroundColor=t.backgroundColor,t.areaPoints.length===2){const[{x:e,y:i},{},{x:n,y:o}]=t.areaPoints;this.areaPoints=[{x:Math.min(e,n),y:Math.min(i,o)},{x:Math.max(e,n),y:Math.min(i,o)},{x:Math.max(e,n),y:Math.max(i,o)},{x:Math.min(e,n),y:Math.max(i,o)}]}else this.areaPoints=t.areaPoints}draw(t,e){if(t.save(),t.beginPath(),t.globalAlpha=.3,t.fillStyle=this.backgroundColor,this.shape==="circle"){const[{x:i,y:n},{},{x:o,y:r}]=this.areaPoints,a=Math.abs(o-i)/2,h=i+(o-i)/2,u=n+(r-n)/2;t.arc(h,u,a,0,2*Math.PI)}else this.areaPoints.forEach((i,n)=>{const{x:o,y:r}=i;n===0?t.moveTo(o,r):t.lineTo(o,r)});t.fill(),t.restore()}}l.APP_SETTING=G,l.AppError=f,l.AppErrorCode=w,l.AppObsType=Y,l.CanvasElement=Xt,l.CanvasImageElement=Ft,l.CanvasIssueElement=Yt,l.CanvasMarkerElement=Gt,l.CanvasPointElement=Ut,l.CanvasRadarElement=Bt,l.CanvasRegionElement=$t,l.Coordinate=et,l.CoordinateLevel=U,l.CoordinateModelType=C,l.CoordinateStatus=I,l.CoordinateType=b,l.DataHelper=jt,l.DataSource=p,l.GeoPoint=z,l.Point=y,l.Position=X,l.RelativeMap=M,l.RequestContentType=R,l.RequestMethod=g,l.RequestResultCode=L,l.Vector3=F,l.api=ft,l.http=ut,l.utils=At,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|