@vsleem-realsee-viewer/shared 1.0.0
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 +749 -0
- package/dist/index.mjs +1428 -0
- package/dist/index.umd.js +1 -0
- package/package.json +25 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1428 @@
|
|
|
1
|
+
var Z = Object.defineProperty;
|
|
2
|
+
var H = (i, t, e) => t in i ? Z(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var r = (i, t, e) => H(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
var E = /* @__PURE__ */ ((i) => (i[i.CADModel = 5] = "CADModel", i[i.BimfaceModel = 6] = "BimfaceModel", i[i.ForgeModel = 7] = "ForgeModel", i[i.ThreeDModel = 8] = "ThreeDModel", i[i.SkyMapModel = 9] = "SkyMapModel", i[i.ScaleModel = 10] = "ScaleModel", i))(E || {}), V = /* @__PURE__ */ ((i) => (i[i.Global = 0] = "Global", i))(V || {}), g = /* @__PURE__ */ ((i) => (i[i.Space = 0] = "Space", i[i.Model = 1] = "Model", i[i.Data = 2] = "Data", i))(g || {}), z = /* @__PURE__ */ ((i) => (i[i.Used = 0] = "Used", i[i.Enabled = 1] = "Enabled", i[i.Disabled = 2] = "Disabled", i))(z || {}), k = /* @__PURE__ */ ((i) => (i[i.SUCCESS = 200] = "SUCCESS", i[i.ERROR = -1] = "ERROR", i[i.TIMEOUT = 401] = "TIMEOUT", i))(k || {}), w = /* @__PURE__ */ ((i) => (i.GET = "GET", i.POST = "POST", i))(w || {}), P = /* @__PURE__ */ ((i) => (i.JSON = "application/json", i.FORM_URLENCODED = "application/x-www-form-urlencoded;charset=UTF-8", i.FORM_DATA = "multipart/form-data;charset=UTF-8", i.OCTET_STREAM = "'application/octet-stream", i))(P || {});
|
|
5
|
+
const W = {
|
|
6
|
+
baseUrl: "https://vsleem.com/api"
|
|
7
|
+
}, Q = {
|
|
8
|
+
isTransformResponse: !0,
|
|
9
|
+
joinBaseUrl: !0,
|
|
10
|
+
withAuthorize: !0
|
|
11
|
+
}, K = {
|
|
12
|
+
url: "",
|
|
13
|
+
method: w.GET,
|
|
14
|
+
headers: {}
|
|
15
|
+
}, X = { ...W };
|
|
16
|
+
function tt(i) {
|
|
17
|
+
Object.assign(X, i);
|
|
18
|
+
}
|
|
19
|
+
async function b(i, t) {
|
|
20
|
+
const e = { ...Q, ...t }, s = { ...K, ...i };
|
|
21
|
+
try {
|
|
22
|
+
const n = et(s, e), { url: o, ...a } = n, c = await (await window.fetch(o, a)).json();
|
|
23
|
+
return st(c, e);
|
|
24
|
+
} catch (n) {
|
|
25
|
+
return it(n);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function et(i, t) {
|
|
29
|
+
const { baseUrl: e, authorizeCode: s } = X, { joinBaseUrl: n, withAuthorize: o } = t;
|
|
30
|
+
let { url: a, method: h, headers: c = {}, params: u, data: d } = i;
|
|
31
|
+
n && e && (a = `${e}${a}`), h = h == null ? void 0 : h.toUpperCase();
|
|
32
|
+
const l = { ...c };
|
|
33
|
+
if (o && s && (l.Authorization = `Bearer ${s}`), h === w.POST && !l["Content-Type"] && (l["Content-Type"] = P.JSON), h === w.GET && u) {
|
|
34
|
+
const M = new URLSearchParams(u);
|
|
35
|
+
a += `?${M.toString()}`;
|
|
36
|
+
}
|
|
37
|
+
let f;
|
|
38
|
+
return h === w.POST && (f = l["Content-Type"] === P.JSON ? JSON.stringify(d || {}) : d), {
|
|
39
|
+
url: a,
|
|
40
|
+
method: h,
|
|
41
|
+
headers: l,
|
|
42
|
+
body: f
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function st(i, t) {
|
|
46
|
+
if (!t.isTransformResponse)
|
|
47
|
+
return i;
|
|
48
|
+
if (!i)
|
|
49
|
+
throw new Error("Request no return data!");
|
|
50
|
+
const { code: e, data: s, msg: n } = i;
|
|
51
|
+
if (e === k.SUCCESS)
|
|
52
|
+
return s;
|
|
53
|
+
throw new Error(n || "Request error!");
|
|
54
|
+
}
|
|
55
|
+
function it(i) {
|
|
56
|
+
throw i instanceof Error ? i : new Error(typeof i == "string" ? i : "Unknown request error");
|
|
57
|
+
}
|
|
58
|
+
const Dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
59
|
+
__proto__: null,
|
|
60
|
+
request: b,
|
|
61
|
+
setRequestGlobalConfig: tt
|
|
62
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
63
|
+
function F(i, t) {
|
|
64
|
+
return b(
|
|
65
|
+
{
|
|
66
|
+
url: "/project/jssdk/cs/list",
|
|
67
|
+
method: w.GET,
|
|
68
|
+
params: i
|
|
69
|
+
},
|
|
70
|
+
t
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function Y(i, t) {
|
|
74
|
+
return b(
|
|
75
|
+
{
|
|
76
|
+
url: "/project/jssdk/cs/bind",
|
|
77
|
+
method: w.POST,
|
|
78
|
+
data: i
|
|
79
|
+
},
|
|
80
|
+
t
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
function I(i, t) {
|
|
84
|
+
return b(
|
|
85
|
+
{
|
|
86
|
+
url: "/project/jssdk/cs/save",
|
|
87
|
+
method: w.POST,
|
|
88
|
+
data: i
|
|
89
|
+
},
|
|
90
|
+
t
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function _(i, t) {
|
|
94
|
+
return b(
|
|
95
|
+
{
|
|
96
|
+
url: "/project/jssdk/cs/delete",
|
|
97
|
+
method: w.POST,
|
|
98
|
+
data: i
|
|
99
|
+
},
|
|
100
|
+
t
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
function B(i, t) {
|
|
104
|
+
return b(
|
|
105
|
+
{
|
|
106
|
+
url: "/project/jssdk/cs/mapping",
|
|
107
|
+
method: w.POST,
|
|
108
|
+
data: i
|
|
109
|
+
},
|
|
110
|
+
t
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
function U(i, t) {
|
|
114
|
+
return b(
|
|
115
|
+
{
|
|
116
|
+
url: "/project/jssdk/cs/mapping/query",
|
|
117
|
+
method: w.GET,
|
|
118
|
+
params: i
|
|
119
|
+
},
|
|
120
|
+
t
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
function nt(i, t = {
|
|
124
|
+
isTransformResponse: !1,
|
|
125
|
+
joinBaseUrl: !1,
|
|
126
|
+
withAuthorize: !1
|
|
127
|
+
}) {
|
|
128
|
+
return b(
|
|
129
|
+
{
|
|
130
|
+
url: i,
|
|
131
|
+
method: w.GET
|
|
132
|
+
},
|
|
133
|
+
t
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
const Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
137
|
+
__proto__: null,
|
|
138
|
+
bindCoordinate: Y,
|
|
139
|
+
getCoordinateList: F,
|
|
140
|
+
getImageInfo: nt,
|
|
141
|
+
getMappingRelation: U,
|
|
142
|
+
mapingCoordinate: B,
|
|
143
|
+
removeCoordinate: _,
|
|
144
|
+
saveCoordinate: I
|
|
145
|
+
}, Symbol.toStringTag, { value: "Module" })), rt = typeof window < "u", ot = Object.prototype.toString;
|
|
146
|
+
function x(i, t) {
|
|
147
|
+
return ot.call(i) === `[object ${t}]`;
|
|
148
|
+
}
|
|
149
|
+
function q(i) {
|
|
150
|
+
return typeof i < "u";
|
|
151
|
+
}
|
|
152
|
+
function G(i) {
|
|
153
|
+
return !q(i);
|
|
154
|
+
}
|
|
155
|
+
function A(i) {
|
|
156
|
+
return i !== null && x(i, "Object");
|
|
157
|
+
}
|
|
158
|
+
function $(i) {
|
|
159
|
+
return i === null;
|
|
160
|
+
}
|
|
161
|
+
function at(i) {
|
|
162
|
+
return x(i, "Date");
|
|
163
|
+
}
|
|
164
|
+
function ht(i) {
|
|
165
|
+
return x(i, "String");
|
|
166
|
+
}
|
|
167
|
+
function L(i) {
|
|
168
|
+
return typeof i == "function";
|
|
169
|
+
}
|
|
170
|
+
function ct(i) {
|
|
171
|
+
return x(i, "Boolean");
|
|
172
|
+
}
|
|
173
|
+
function lt(i) {
|
|
174
|
+
return x(i, "RegExp");
|
|
175
|
+
}
|
|
176
|
+
function T(i) {
|
|
177
|
+
return i && Array.isArray(i);
|
|
178
|
+
}
|
|
179
|
+
function ut(i) {
|
|
180
|
+
return typeof window < "u" && x(i, "Window");
|
|
181
|
+
}
|
|
182
|
+
function dt(i) {
|
|
183
|
+
return A(i) && !!i.tagName;
|
|
184
|
+
}
|
|
185
|
+
function ft(i) {
|
|
186
|
+
return typeof i == "number" || /^\d+(\.\d+)?$/.test(i);
|
|
187
|
+
}
|
|
188
|
+
function D(i) {
|
|
189
|
+
return x(Number(i), "Number");
|
|
190
|
+
}
|
|
191
|
+
function mt(i, t) {
|
|
192
|
+
return JSON.stringify(i) === JSON.stringify(t);
|
|
193
|
+
}
|
|
194
|
+
function yt(i) {
|
|
195
|
+
return G(i) || $(i);
|
|
196
|
+
}
|
|
197
|
+
function pt(i) {
|
|
198
|
+
return x(i, "Promise") && A(i) && L(i.then) && L(i.catch);
|
|
199
|
+
}
|
|
200
|
+
function J(i) {
|
|
201
|
+
return S(i, /* @__PURE__ */ new WeakMap());
|
|
202
|
+
}
|
|
203
|
+
function S(i, t) {
|
|
204
|
+
if (typeof i != "object" || i === null)
|
|
205
|
+
return i;
|
|
206
|
+
if (t.has(i))
|
|
207
|
+
return t.get(i);
|
|
208
|
+
let e;
|
|
209
|
+
if (i instanceof Date)
|
|
210
|
+
return e = new Date(i), t.set(i, e), e;
|
|
211
|
+
if (i instanceof RegExp)
|
|
212
|
+
return e = new RegExp(i), t.set(i, e), e;
|
|
213
|
+
if (i instanceof Map)
|
|
214
|
+
return e = /* @__PURE__ */ new Map(), t.set(i, e), i.forEach((n, o) => {
|
|
215
|
+
e.set(o, S(n, t));
|
|
216
|
+
}), e;
|
|
217
|
+
if (i instanceof Set)
|
|
218
|
+
return e = /* @__PURE__ */ new Set(), t.set(i, e), i.forEach((n) => {
|
|
219
|
+
e.add(S(n, t));
|
|
220
|
+
}), e;
|
|
221
|
+
if (ArrayBuffer.isView(i))
|
|
222
|
+
return e = new i.constructor(
|
|
223
|
+
i.buffer.slice(0),
|
|
224
|
+
i.byteOffset,
|
|
225
|
+
i.byteLength
|
|
226
|
+
), t.set(i, e), e;
|
|
227
|
+
if (i instanceof ArrayBuffer)
|
|
228
|
+
return e = i.slice(0), t.set(i, e), e;
|
|
229
|
+
if (Array.isArray(i)) {
|
|
230
|
+
e = [], t.set(i, e);
|
|
231
|
+
for (let n = 0; n < i.length; n++)
|
|
232
|
+
n in i && (e[n] = S(i[n], t));
|
|
233
|
+
return e;
|
|
234
|
+
}
|
|
235
|
+
e = Object.create(Object.getPrototypeOf(i)), t.set(i, e);
|
|
236
|
+
for (const n in i)
|
|
237
|
+
Object.prototype.hasOwnProperty.call(i, n) && (e[n] = S(i[n], t));
|
|
238
|
+
const s = Object.getOwnPropertySymbols(i);
|
|
239
|
+
for (const n of s)
|
|
240
|
+
Object.prototype.propertyIsEnumerable.call(i, n) && (e[n] = S(i[n], t));
|
|
241
|
+
return e;
|
|
242
|
+
}
|
|
243
|
+
function wt(i, t, e = !1) {
|
|
244
|
+
let s;
|
|
245
|
+
const n = function(...o) {
|
|
246
|
+
const a = this, h = e && !s;
|
|
247
|
+
s && clearTimeout(s), s = setTimeout(() => {
|
|
248
|
+
s = void 0, e || i.apply(a, o);
|
|
249
|
+
}, t), h && i.apply(a, o);
|
|
250
|
+
};
|
|
251
|
+
return n.cancel = () => {
|
|
252
|
+
s && clearTimeout(s), s = void 0;
|
|
253
|
+
}, n;
|
|
254
|
+
}
|
|
255
|
+
function gt(i, t, e = !1) {
|
|
256
|
+
let s, n;
|
|
257
|
+
const o = function(...a) {
|
|
258
|
+
const h = this;
|
|
259
|
+
n ? (clearTimeout(s), s = setTimeout(
|
|
260
|
+
() => {
|
|
261
|
+
Date.now() - n >= t && (i.apply(h, a), n = Date.now());
|
|
262
|
+
},
|
|
263
|
+
t - (Date.now() - n)
|
|
264
|
+
)) : (e && i.apply(h, a), n = Date.now());
|
|
265
|
+
};
|
|
266
|
+
return o.cancel = () => {
|
|
267
|
+
clearTimeout(s), s = void 0, n = void 0;
|
|
268
|
+
}, o;
|
|
269
|
+
}
|
|
270
|
+
function xt(i, t = {}) {
|
|
271
|
+
return new Promise((e, s) => {
|
|
272
|
+
const n = N(i);
|
|
273
|
+
if (Mt(n)) {
|
|
274
|
+
e(!0);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const o = document.createElement("script");
|
|
278
|
+
o.src = i, Object.entries(t).forEach(([a, h]) => {
|
|
279
|
+
h !== !1 && o.setAttribute(a, h === !0 ? "" : String(h));
|
|
280
|
+
}), o.onload = () => {
|
|
281
|
+
e(!0);
|
|
282
|
+
}, o.onerror = () => {
|
|
283
|
+
document.head.removeChild(o), s(new Error(`Failed to load script: ${i}`));
|
|
284
|
+
}, document.head.appendChild(o);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
function Mt(i) {
|
|
288
|
+
const t = N(i);
|
|
289
|
+
return Array.from(document.scripts).some((e) => N(e.src) === t);
|
|
290
|
+
}
|
|
291
|
+
function N(i) {
|
|
292
|
+
try {
|
|
293
|
+
const t = new URL(i, window.location.href);
|
|
294
|
+
return `${t.origin}${t.pathname}`;
|
|
295
|
+
} catch {
|
|
296
|
+
return i;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function vt(i, t, e, s) {
|
|
300
|
+
const n = Math.min(i / e, t / s), o = e * n, a = s * n;
|
|
301
|
+
return {
|
|
302
|
+
scale: n,
|
|
303
|
+
x: (i - o) / 2,
|
|
304
|
+
// 居中计算的X起点
|
|
305
|
+
y: (t - a) / 2,
|
|
306
|
+
// 居中计算的Y起点
|
|
307
|
+
sw: o,
|
|
308
|
+
sh: a
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function bt(i, t, e) {
|
|
312
|
+
return {
|
|
313
|
+
x: i * e.scale + e.x,
|
|
314
|
+
// 缩放后加上偏移量
|
|
315
|
+
y: t * e.scale + e.y
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function Tt(i, t, e) {
|
|
319
|
+
return {
|
|
320
|
+
x: (i - e.x) / e.scale,
|
|
321
|
+
// 减去偏移量后缩放到模型尺寸
|
|
322
|
+
y: (t - e.y) / e.scale
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
const zt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
326
|
+
__proto__: null,
|
|
327
|
+
cloneDeep: J,
|
|
328
|
+
debounce: wt,
|
|
329
|
+
getImageTransform: vt,
|
|
330
|
+
inBrowser: rt,
|
|
331
|
+
is: x,
|
|
332
|
+
isArray: T,
|
|
333
|
+
isBoolean: ct,
|
|
334
|
+
isDate: at,
|
|
335
|
+
isDef: q,
|
|
336
|
+
isElement: dt,
|
|
337
|
+
isFunction: L,
|
|
338
|
+
isNull: $,
|
|
339
|
+
isNullOrUnDef: yt,
|
|
340
|
+
isNumber: D,
|
|
341
|
+
isNumeric: ft,
|
|
342
|
+
isObject: A,
|
|
343
|
+
isPromise: pt,
|
|
344
|
+
isRegExp: lt,
|
|
345
|
+
isSameValue: mt,
|
|
346
|
+
isString: ht,
|
|
347
|
+
isUnDef: G,
|
|
348
|
+
isWindow: ut,
|
|
349
|
+
loadScript: xt,
|
|
350
|
+
throttle: gt,
|
|
351
|
+
toCanvasCoord: bt,
|
|
352
|
+
toModelCoord: Tt
|
|
353
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
354
|
+
class m {
|
|
355
|
+
constructor(t) {
|
|
356
|
+
r(this, "x", 0);
|
|
357
|
+
r(this, "y", 0);
|
|
358
|
+
r(this, "z", 0);
|
|
359
|
+
r(this, "lat", 0);
|
|
360
|
+
//经度
|
|
361
|
+
r(this, "lon", 0);
|
|
362
|
+
//纬度
|
|
363
|
+
r(this, "alt", 0);
|
|
364
|
+
//高度
|
|
365
|
+
r(this, "yaw", 0);
|
|
366
|
+
r(this, "pitch", 0);
|
|
367
|
+
r(this, "roll", 0);
|
|
368
|
+
r(this, "hasXYZ", !1);
|
|
369
|
+
r(this, "hasGeo", !1);
|
|
370
|
+
r(this, "hasAngle", !1);
|
|
371
|
+
r(this, "plane", "xy");
|
|
372
|
+
const { x: e, y: s, z: n, lat: o, lon: a, alt: h, yaw: c, pitch: u, roll: d, plane: l = "xy" } = t || {};
|
|
373
|
+
D(e) && D(s) && (this.x = Number(e) || 0, this.y = Number(s) || 0, this.z = Number(n) || 0, this.plane = l, this.hasXYZ = !0), D(o) && D(a) && Number(o) !== 0 && Number(a) !== 0 && (this.lat = Number(o) || 0, this.lon = Number(a) || 0, this.alt = Number(h) || 0, this.hasGeo = !0), (c !== void 0 || u !== void 0 || d !== void 0) && (this.yaw = Number(c) || 0, this.pitch = Number(u) || 0, this.roll = Number(d) || 0, this.hasAngle = !0);
|
|
374
|
+
}
|
|
375
|
+
static dist(t, e) {
|
|
376
|
+
return Math.sqrt((t.x - e.x) ** 2 + (t.y - e.y) ** 2 + (t.z - e.z) ** 2);
|
|
377
|
+
}
|
|
378
|
+
static distXZ(t, e) {
|
|
379
|
+
return Math.sqrt((t.x - e.x) ** 2 + (t.z - e.z) ** 2);
|
|
380
|
+
}
|
|
381
|
+
static distXY(t, e) {
|
|
382
|
+
return Math.sqrt((t.x - e.x) ** 2 + (t.y - e.y) ** 2);
|
|
383
|
+
}
|
|
384
|
+
static toRadians(t) {
|
|
385
|
+
return (Number(t) || 0) * Math.PI / 180;
|
|
386
|
+
}
|
|
387
|
+
static toDegrees(t) {
|
|
388
|
+
return (Number(t) || 0) * 180 / Math.PI;
|
|
389
|
+
}
|
|
390
|
+
static angleXZ(t, e, s) {
|
|
391
|
+
const n = { x: t.x - e.x, z: t.z - e.z }, o = { x: s.x - e.x, z: s.z - e.z }, a = n.x * o.x + n.z * o.z, h = Math.sqrt(n.x ** 2 + n.z ** 2), c = Math.sqrt(o.x ** 2 + o.z ** 2), u = Math.max(-1, Math.min(1, a / (h * c))), l = Math.acos(u) * 180 / Math.PI;
|
|
392
|
+
return Math.min(l, 360 - l);
|
|
393
|
+
}
|
|
394
|
+
static JSONParse(t) {
|
|
395
|
+
if (t) {
|
|
396
|
+
const e = t == null ? void 0 : t.split(",").map((s) => Number(s) || 0);
|
|
397
|
+
return new m({ x: e[0], y: e[1], z: e[2] });
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
static JSONStringify(t) {
|
|
401
|
+
return t ? `${t.x},${t.y},${t.z}` : "";
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* 点的投射
|
|
405
|
+
* @param r //
|
|
406
|
+
* @param srcCoordinate 源坐标系
|
|
407
|
+
* @param dstCoordinate 目标坐标系
|
|
408
|
+
*/
|
|
409
|
+
projection(t, e, s) {
|
|
410
|
+
try {
|
|
411
|
+
if ((e == null ? void 0 : e.id) === (s == null ? void 0 : s.id))
|
|
412
|
+
return new m(this);
|
|
413
|
+
if ((e == null ? void 0 : e.modelType) === E.SkyMapModel) {
|
|
414
|
+
const { refPoint: n } = (e == null ? void 0 : e.relativeMap) || {};
|
|
415
|
+
if (this.hasGeo && n) {
|
|
416
|
+
const o = O.LLHToXYZ(this, n);
|
|
417
|
+
return this.x = o.x, this.y = o.y, this.z = o.z, this.hasXYZ = !0, this.project(t);
|
|
418
|
+
} else
|
|
419
|
+
throw new Error("没有完成gis与其他空间的映射");
|
|
420
|
+
} else if ((s == null ? void 0 : s.modelType) === E.SkyMapModel) {
|
|
421
|
+
const { refPoint: n } = (s == null ? void 0 : s.relativeMap) || {}, o = this.project(t);
|
|
422
|
+
if (o != null && o.hasXYZ && n) {
|
|
423
|
+
const a = O.XYZToLLH(o, n);
|
|
424
|
+
return o.lat = a.lat, o.lon = a.lon, o.alt = a.alt, o.hasGeo = !0, o;
|
|
425
|
+
} else
|
|
426
|
+
throw new Error("没有完成gis与其他空间的映射");
|
|
427
|
+
} else
|
|
428
|
+
return this.project(t);
|
|
429
|
+
} catch {
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
project(t) {
|
|
433
|
+
if (this.hasXYZ) {
|
|
434
|
+
if (this.plane === "xz")
|
|
435
|
+
return this.projectXZ(t);
|
|
436
|
+
if (this.plane === "xy")
|
|
437
|
+
return this.projectXY(t);
|
|
438
|
+
throw new Error("plane should be xz or xy");
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
projectXZ(t) {
|
|
442
|
+
const e = new m(this);
|
|
443
|
+
e.x *= t.scale, e.y *= t.scale, e.z *= t.scale, e.yaw !== void 0 && (e.yaw += t.yaw);
|
|
444
|
+
const s = 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);
|
|
445
|
+
return e.x = s + t.x, e.y += t.y, e.z = n + t.z, e;
|
|
446
|
+
}
|
|
447
|
+
projectXY(t) {
|
|
448
|
+
const e = new m(this);
|
|
449
|
+
e.x *= t.scale, e.y *= t.scale, e.z *= t.scale, e.yaw !== void 0 && (e.yaw += t.yaw);
|
|
450
|
+
const s = 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);
|
|
451
|
+
return e.x = s + t.x, e.y = n + t.y, e.z += t.z, e;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
class O {
|
|
455
|
+
//高度
|
|
456
|
+
constructor(t) {
|
|
457
|
+
r(this, "lat", 0);
|
|
458
|
+
//经度
|
|
459
|
+
r(this, "lon", 0);
|
|
460
|
+
//纬度
|
|
461
|
+
r(this, "alt", 0);
|
|
462
|
+
const { lat: e = 0, lon: s = 0, alt: n = 0 } = t || {};
|
|
463
|
+
this.lat = e, this.lon = s, this.alt = n;
|
|
464
|
+
}
|
|
465
|
+
static XYZToLLH(t, e) {
|
|
466
|
+
const n = 0.0033528106647474805, o = n * (2 - n), a = m.toRadians(e.lat), h = 6378137 / Math.sqrt(1 - o * Math.sin(a) ** 2) + e.alt;
|
|
467
|
+
let c, u, d;
|
|
468
|
+
if (t.plane === "xz") {
|
|
469
|
+
const l = t.x / 1e3 / (h * Math.cos(a)), f = t.z / 1e3 / h;
|
|
470
|
+
c = e.lon + m.toDegrees(l), u = e.lat - m.toDegrees(f), d = e.alt + t.y / 1e3;
|
|
471
|
+
} else if (t.plane === "xy") {
|
|
472
|
+
const l = t.x / 1e3 / (h * Math.cos(a)), f = t.y / 1e3 / h;
|
|
473
|
+
c = e.lon + m.toDegrees(l), u = e.lat - m.toDegrees(f), d = e.alt + t.z / 1e3;
|
|
474
|
+
} else
|
|
475
|
+
throw new Error("Point's plane should be xz or xy");
|
|
476
|
+
return new O({
|
|
477
|
+
lat: u,
|
|
478
|
+
lon: c,
|
|
479
|
+
alt: d
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
static LLHToXYZ(t, e) {
|
|
483
|
+
const n = 0.0033528106647474805, o = n * (2 - n), a = m.toRadians(e.lat), h = 6378137 / Math.sqrt(1 - o * Math.sin(a) ** 2) + e.alt, c = m.toRadians(t.lon - e.lon), u = m.toRadians(e.lat - t.lat), d = h * c * Math.cos(a), l = h * u;
|
|
484
|
+
if (t.plane === "xz")
|
|
485
|
+
return new m({
|
|
486
|
+
x: d * 1e3,
|
|
487
|
+
y: (t.alt - e.alt) * 1e3,
|
|
488
|
+
z: l * 1e3,
|
|
489
|
+
plane: "xz"
|
|
490
|
+
});
|
|
491
|
+
if (t.plane === "xy")
|
|
492
|
+
return new m({
|
|
493
|
+
x: d * 1e3,
|
|
494
|
+
y: l * 1e3,
|
|
495
|
+
z: (t.alt - e.alt) * 1e3,
|
|
496
|
+
plane: "xy"
|
|
497
|
+
});
|
|
498
|
+
throw new Error("Point's plane must be xz or xy");
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
class p {
|
|
502
|
+
//参考点
|
|
503
|
+
constructor(t) {
|
|
504
|
+
r(this, "scale", 1);
|
|
505
|
+
r(this, "yaw", 0);
|
|
506
|
+
r(this, "x", 0);
|
|
507
|
+
r(this, "y", 0);
|
|
508
|
+
r(this, "z", 0);
|
|
509
|
+
r(this, "start", 0);
|
|
510
|
+
r(this, "end", -1);
|
|
511
|
+
r(this, "plane", "xy");
|
|
512
|
+
r(this, "refPoint");
|
|
513
|
+
const { refPoint: e, ...s } = t || {};
|
|
514
|
+
e && (this.refPoint = new O(e)), Object.assign(this, s);
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* 合并两个相对坐标系的映射关系
|
|
518
|
+
* @param r1 先进行的映射关系
|
|
519
|
+
* @param r2 后进行的映射关系
|
|
520
|
+
* @returns 合并后的映射关系
|
|
521
|
+
*/
|
|
522
|
+
static addRelativeMap(t, e) {
|
|
523
|
+
if (t.plane !== e.plane)
|
|
524
|
+
throw new Error("The plane of two relative maps should be the same");
|
|
525
|
+
const s = t.scale * e.scale, n = t.yaw + e.yaw, o = Math.cos(e.yaw), a = Math.sin(e.yaw);
|
|
526
|
+
let h = 0, c = 0, u = 0;
|
|
527
|
+
if (t.plane === "xz") {
|
|
528
|
+
const d = t.x * o - t.z * a, l = t.y, f = t.x * a + t.z * o;
|
|
529
|
+
h = e.x + d * e.scale, c = e.y + l * e.scale, u = e.z + f * e.scale;
|
|
530
|
+
} else if (t.plane === "xy") {
|
|
531
|
+
const d = t.x * o - t.y * a, l = t.x * a + t.y * o, f = t.z;
|
|
532
|
+
h = e.x + d * e.scale, c = e.y + l * e.scale, u = e.z + f * e.scale;
|
|
533
|
+
} else
|
|
534
|
+
throw new Error("plane should be xz or xy");
|
|
535
|
+
return new p({
|
|
536
|
+
scale: s,
|
|
537
|
+
yaw: n,
|
|
538
|
+
x: h,
|
|
539
|
+
y: c,
|
|
540
|
+
z: u,
|
|
541
|
+
start: t.start,
|
|
542
|
+
end: t.end,
|
|
543
|
+
plane: t.plane
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* 逆映射
|
|
548
|
+
* @param r 原映射
|
|
549
|
+
* @returns 逆映射
|
|
550
|
+
*/
|
|
551
|
+
static inverseRelativeMap(t) {
|
|
552
|
+
const e = 1 / t.scale, s = -t.yaw, n = Math.cos(-s), o = Math.sin(-s);
|
|
553
|
+
let a = 0, h = 0, c = 0;
|
|
554
|
+
if (t.plane === "xz")
|
|
555
|
+
a = -(t.x * n + t.z * o) * e, h = -t.y * e, c = -(t.z * n - t.x * o) * e;
|
|
556
|
+
else if (t.plane === "xy")
|
|
557
|
+
a = -(t.x * n + t.y * o) * e, h = -(t.y * n - t.x * o) * e, c = -t.z * e;
|
|
558
|
+
else
|
|
559
|
+
throw new Error("plane should be xz or xy");
|
|
560
|
+
return new p({
|
|
561
|
+
scale: e,
|
|
562
|
+
yaw: s,
|
|
563
|
+
x: a,
|
|
564
|
+
y: h,
|
|
565
|
+
z: c,
|
|
566
|
+
start: t.start,
|
|
567
|
+
end: t.end,
|
|
568
|
+
plane: t.plane
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
static JSONParse(t) {
|
|
572
|
+
try {
|
|
573
|
+
let e = t ? JSON.parse(t) : void 0;
|
|
574
|
+
const { reference_point: s } = e || {};
|
|
575
|
+
return s && (e = { refPoint: s }), e ? new p(e) : void 0;
|
|
576
|
+
} catch {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
static JSONStringify(t) {
|
|
581
|
+
return t ? JSON.stringify(t) : void 0;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
class y {
|
|
585
|
+
/**
|
|
586
|
+
* 获取坐标系树
|
|
587
|
+
* @param projectId 项目id
|
|
588
|
+
* @returns
|
|
589
|
+
*/
|
|
590
|
+
static async getCoordinateTree(t) {
|
|
591
|
+
const e = await F({ projectId: t });
|
|
592
|
+
if (e.length) {
|
|
593
|
+
const s = y.handleCoordinateList(e);
|
|
594
|
+
return y.buildCoordinateTree(s, 0);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* 添加坐标系
|
|
599
|
+
* @param parent 添加到的父级
|
|
600
|
+
* @param children 添加的坐标系
|
|
601
|
+
* @returns
|
|
602
|
+
*/
|
|
603
|
+
static async addCoordinate(t, e) {
|
|
604
|
+
const { projectId: s, id: n } = t, o = e.map((h) => {
|
|
605
|
+
const { type: c, modelType: u, relativeMap: d, level: l, ...f } = h, M = d ? JSON.stringify(d) : void 0;
|
|
606
|
+
return {
|
|
607
|
+
...f,
|
|
608
|
+
projectId: s,
|
|
609
|
+
parentId: n,
|
|
610
|
+
coordinateType: c,
|
|
611
|
+
renderType: u,
|
|
612
|
+
relativePosition: M
|
|
613
|
+
};
|
|
614
|
+
}), a = await I(o);
|
|
615
|
+
return y.handleCoordinateList(a);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* 删除坐标系
|
|
619
|
+
* @param parent 删除的父级
|
|
620
|
+
* @param child 删除的坐标系
|
|
621
|
+
* @returns
|
|
622
|
+
*/
|
|
623
|
+
static async removeCoordinate(t, e) {
|
|
624
|
+
const s = e.map((n) => n.id ?? -1);
|
|
625
|
+
return await _(s);
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* 更新坐标系
|
|
629
|
+
* @param parent 更新的父级
|
|
630
|
+
* @param children 更新的坐标系
|
|
631
|
+
* @returns
|
|
632
|
+
*/
|
|
633
|
+
static async updateCoordinate(t, e) {
|
|
634
|
+
const { projectId: s, id: n } = t, o = e.map((h) => {
|
|
635
|
+
const { type: c, relativeMap: u, level: d, ...l } = h, f = p.JSONStringify(u);
|
|
636
|
+
return { ...l, relativePosition: f, projectId: s, parentId: n };
|
|
637
|
+
}), a = await I(o);
|
|
638
|
+
return y.handleCoordinateList(a);
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* 绑定坐标系
|
|
642
|
+
* @param parent 绑定的父级
|
|
643
|
+
* @param children 绑定的坐标系
|
|
644
|
+
* @returns
|
|
645
|
+
*/
|
|
646
|
+
static async bindCoordinate(t, e) {
|
|
647
|
+
const { projectId: s, id: n } = t, o = e.map((h) => {
|
|
648
|
+
const { modelId: c } = h;
|
|
649
|
+
return { modelId: c, parentId: n, projectId: s };
|
|
650
|
+
}), a = await Y(o);
|
|
651
|
+
return y.handleCoordinateList(a);
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* 处理坐标系数据
|
|
655
|
+
* @param array 坐标系数据
|
|
656
|
+
* @returns 处理后的坐标系数据
|
|
657
|
+
*/
|
|
658
|
+
static handleCoordinateList(t) {
|
|
659
|
+
return t == null ? void 0 : t.map((e) => {
|
|
660
|
+
const {
|
|
661
|
+
coordinateType: s,
|
|
662
|
+
modelKey: n,
|
|
663
|
+
renderType: o,
|
|
664
|
+
relativePosition: a,
|
|
665
|
+
...h
|
|
666
|
+
} = e, c = p.JSONParse(a);
|
|
667
|
+
return new St({
|
|
668
|
+
...h,
|
|
669
|
+
type: s,
|
|
670
|
+
modelType: o,
|
|
671
|
+
modelValue: n,
|
|
672
|
+
relativeMap: c
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* 递归函数将扁平列表转化为树形结构
|
|
678
|
+
* @param flatNodes // 扁平列表
|
|
679
|
+
* @param rootId // 根id
|
|
680
|
+
* @returns
|
|
681
|
+
*/
|
|
682
|
+
static buildCoordinateTree(t, e) {
|
|
683
|
+
const s = /* @__PURE__ */ new Map(), n = [];
|
|
684
|
+
return t.forEach((o) => {
|
|
685
|
+
s.set(String(o.id), o);
|
|
686
|
+
}), t.forEach((o) => {
|
|
687
|
+
var h;
|
|
688
|
+
const a = s.get(String(o.id));
|
|
689
|
+
if (a)
|
|
690
|
+
if (o.parentId === e)
|
|
691
|
+
a.level = 0, n.push(a);
|
|
692
|
+
else {
|
|
693
|
+
const c = s.get(String(o.parentId ?? -1));
|
|
694
|
+
c && (a.level = (Number(c.level) || 0) + 1, a.parent = c, (h = c.children) == null || h.push(a));
|
|
695
|
+
}
|
|
696
|
+
}), n.forEach(y.sortCoordinateTree), n[0];
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* 对子节点进行排序,首先按 status=0 升序,然后按 type=0 升序,最后按 createTime 降序
|
|
700
|
+
* @param node // 节点
|
|
701
|
+
* @returns 无返回值
|
|
702
|
+
*/
|
|
703
|
+
static sortCoordinateTree(t) {
|
|
704
|
+
t.children && (t.children.sort((e, s) => {
|
|
705
|
+
var n, o;
|
|
706
|
+
if (e.type === g.Space) {
|
|
707
|
+
const a = Number((n = s == null ? void 0 : s.relativeMap) == null ? void 0 : n.z) - Number((o = e == null ? void 0 : e.relativeMap) == null ? void 0 : o.z);
|
|
708
|
+
return a !== 0 ? a : Number(s.createTime) - Number(e.createTime);
|
|
709
|
+
} else
|
|
710
|
+
return e.status === 0 && s.status !== 0 ? -1 : s.status === 0 && e.status !== 0 ? 1 : Number(s.createTime) - Number(e.createTime);
|
|
711
|
+
}), t.children.forEach(y.sortCoordinateTree));
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* 过滤空间坐标系树
|
|
715
|
+
* @param tree
|
|
716
|
+
*/
|
|
717
|
+
static filterSpaceTree(t) {
|
|
718
|
+
const e = [];
|
|
719
|
+
return t.forEach((s) => {
|
|
720
|
+
const n = y.filterSpaceTree(s.children);
|
|
721
|
+
s.children = n, s.disabled = s.disabled ?? !1, s.type !== g.Model && e.push(s);
|
|
722
|
+
}), e;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
class St {
|
|
726
|
+
// 创建时间
|
|
727
|
+
constructor(t) {
|
|
728
|
+
r(this, "id", 0);
|
|
729
|
+
//id
|
|
730
|
+
r(this, "type", 0);
|
|
731
|
+
//0空间,1模型
|
|
732
|
+
r(this, "level");
|
|
733
|
+
//空间的层级
|
|
734
|
+
r(this, "relativeMap");
|
|
735
|
+
//相对位置关系
|
|
736
|
+
r(this, "no");
|
|
737
|
+
//坐标系编号
|
|
738
|
+
r(this, "name");
|
|
739
|
+
//名称
|
|
740
|
+
r(this, "shortName");
|
|
741
|
+
//简称
|
|
742
|
+
r(this, "status");
|
|
743
|
+
//使用状态
|
|
744
|
+
r(this, "modelId");
|
|
745
|
+
// 模型ID
|
|
746
|
+
r(this, "modelType");
|
|
747
|
+
//模型的类型
|
|
748
|
+
r(this, "modelValue");
|
|
749
|
+
// 模型value
|
|
750
|
+
r(this, "projectId");
|
|
751
|
+
//项目id
|
|
752
|
+
r(this, "parentId");
|
|
753
|
+
//父节点id
|
|
754
|
+
r(this, "parent");
|
|
755
|
+
//父节点
|
|
756
|
+
r(this, "groupUuid");
|
|
757
|
+
//分组uuid
|
|
758
|
+
r(this, "children", []);
|
|
759
|
+
//子节点
|
|
760
|
+
r(this, "z");
|
|
761
|
+
//坐标系高度
|
|
762
|
+
r(this, "disabled");
|
|
763
|
+
//禁用
|
|
764
|
+
r(this, "createTime");
|
|
765
|
+
const { relativeMap: e, parent: s, children: n, ...o } = t || {};
|
|
766
|
+
e && (this.relativeMap = new p(e)), s && (this.parent = s), n != null && n.length && (this.children = n), Object.assign(this, o);
|
|
767
|
+
}
|
|
768
|
+
get spaceList() {
|
|
769
|
+
return this.children.filter((t) => t.type === g.Space);
|
|
770
|
+
}
|
|
771
|
+
get modelList() {
|
|
772
|
+
return this.children.filter((t) => t.type === g.Model);
|
|
773
|
+
}
|
|
774
|
+
get fullName() {
|
|
775
|
+
const t = this.name ? `(${this.name})` : "";
|
|
776
|
+
return this.shortName ? `${this.shortName}${t}` : this.name ?? "";
|
|
777
|
+
}
|
|
778
|
+
//添加子节点
|
|
779
|
+
async addChild(t) {
|
|
780
|
+
const e = T(t) ? t : [t], s = await y.addCoordinate(this, e);
|
|
781
|
+
this.mergeChild(s);
|
|
782
|
+
}
|
|
783
|
+
//删除子节点
|
|
784
|
+
async removeChild(t) {
|
|
785
|
+
const e = T(t) ? t : [t];
|
|
786
|
+
await y.removeCoordinate(this, e);
|
|
787
|
+
for (const s of e) {
|
|
788
|
+
const n = this.children.findIndex((o) => o.id === s.id);
|
|
789
|
+
n !== -1 && this.children.splice(n, 1);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
//更新子节点
|
|
793
|
+
async updateChild(t) {
|
|
794
|
+
const e = T(t) ? t : [t], s = await y.updateCoordinate(this, e);
|
|
795
|
+
this.mergeChild(s);
|
|
796
|
+
}
|
|
797
|
+
//绑定子节点,不建立映射关系
|
|
798
|
+
async bindChild(t) {
|
|
799
|
+
const e = T(t) ? t : [t], s = await y.bindCoordinate(this, e);
|
|
800
|
+
this.mergeChild(s);
|
|
801
|
+
}
|
|
802
|
+
// 合并子节点,没有查询到节点就插入
|
|
803
|
+
async mergeChild(t) {
|
|
804
|
+
t != null && t.length && t.forEach((e) => {
|
|
805
|
+
const s = this.children.find((n) => n.id === e.id);
|
|
806
|
+
if (s) {
|
|
807
|
+
const { relativeMap: n, no: o, name: a, shortName: h, status: c, modelId: u, modelValue: d } = e;
|
|
808
|
+
Object.assign(s, {
|
|
809
|
+
relativeMap: n,
|
|
810
|
+
no: o,
|
|
811
|
+
name: a,
|
|
812
|
+
shortName: h,
|
|
813
|
+
status: c,
|
|
814
|
+
modelId: u,
|
|
815
|
+
modelValue: d
|
|
816
|
+
});
|
|
817
|
+
} else this.id === e.parentId && (e.parent = this, this.children.unshift(e));
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
//映射到(模型映射到空间,空间映射到空间)
|
|
821
|
+
async mappingTo(t) {
|
|
822
|
+
await B(t);
|
|
823
|
+
}
|
|
824
|
+
// 来自映射(被映射过的源坐标系关系)
|
|
825
|
+
async fromMapping() {
|
|
826
|
+
const t = await U({ srcCsId: this.id });
|
|
827
|
+
return t[t.length - 1];
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* 递归寻找到根坐标系
|
|
831
|
+
* @returns
|
|
832
|
+
*/
|
|
833
|
+
findRoot(t = !1) {
|
|
834
|
+
let e = this;
|
|
835
|
+
for (; e.parent && !(t && !e.relativeMap); )
|
|
836
|
+
e = e.parent;
|
|
837
|
+
return e;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
*寻找到符合要求的子节点模型坐标系
|
|
841
|
+
* @param type 模型类型 默认包含CADModel,SkyMapModel
|
|
842
|
+
* @param mapped 是否被映射
|
|
843
|
+
* @returns
|
|
844
|
+
*/
|
|
845
|
+
findChildModel(t = [E.CADModel, E.SkyMapModel], e = !0) {
|
|
846
|
+
var h, c;
|
|
847
|
+
const s = T(t) ? t : [t];
|
|
848
|
+
if (s.includes(this.modelType ?? -1) && this.status !== z.Disabled)
|
|
849
|
+
return this;
|
|
850
|
+
const o = [g.Data, g.Model].includes(this.type) ? this.findParentSpace() : this, a = (c = (h = o == null ? void 0 : o.modelList) == null ? void 0 : h.filter((u) => s.includes(this.modelType ?? -1) ? e ? !!u.relativeMap : !0 : !1)) == null ? void 0 : c.sort((u, d) => Number(u.status) - Number(d.status));
|
|
851
|
+
return a == null ? void 0 : a[0];
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* 寻找与当前节点最近的一个模型节点,从当前节点遍历到根节点-广度优先遍历
|
|
855
|
+
* @param type 允许的模型类型
|
|
856
|
+
* @param excludeNodes //排除的坐标系
|
|
857
|
+
* @returns
|
|
858
|
+
*/
|
|
859
|
+
findLatestModel(t = E.CADModel, e) {
|
|
860
|
+
var u;
|
|
861
|
+
const s = /* @__PURE__ */ new Set();
|
|
862
|
+
for (const d of e ?? [])
|
|
863
|
+
s.add(String(d.id));
|
|
864
|
+
const n = [{ node: this, distance: 0 }], o = T(t) ? t : [t], a = /* @__PURE__ */ new Set();
|
|
865
|
+
let h, c = 1 / 0;
|
|
866
|
+
for (; n.length > 0; ) {
|
|
867
|
+
const d = n.shift();
|
|
868
|
+
if (!d) break;
|
|
869
|
+
const { node: l, distance: f } = d;
|
|
870
|
+
if (s.has(String(l.id)))
|
|
871
|
+
continue;
|
|
872
|
+
if (o.includes(l.modelType ?? -1)) {
|
|
873
|
+
if (f < c && (h = l, c = f, f <= 1))
|
|
874
|
+
break;
|
|
875
|
+
continue;
|
|
876
|
+
}
|
|
877
|
+
a.add(l);
|
|
878
|
+
const M = [];
|
|
879
|
+
if ((u = l.parent) != null && u.children)
|
|
880
|
+
for (const v of l.parent.children)
|
|
881
|
+
v !== l && !a.has(v) && M.push(v);
|
|
882
|
+
if (l.children)
|
|
883
|
+
for (const v of l.children)
|
|
884
|
+
a.has(v) || M.push(v);
|
|
885
|
+
l.parent && !a.has(l.parent) && M.push(l.parent);
|
|
886
|
+
for (const v of M)
|
|
887
|
+
n.push({ node: v, distance: f + 1 });
|
|
888
|
+
}
|
|
889
|
+
return h;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
*向上寻找到子节点的空间坐标系
|
|
893
|
+
* @returns
|
|
894
|
+
*/
|
|
895
|
+
findParentSpace() {
|
|
896
|
+
let t = this;
|
|
897
|
+
for (; t && t.type !== g.Space; )
|
|
898
|
+
t = t.parent;
|
|
899
|
+
return t;
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* 通过当前坐标系,获取父级空间坐标系名称
|
|
903
|
+
* @param level 向上找多少级
|
|
904
|
+
* @returns
|
|
905
|
+
*/
|
|
906
|
+
findParentSpaceNames(t = 2) {
|
|
907
|
+
const e = [];
|
|
908
|
+
let s = this;
|
|
909
|
+
for (; s && t > 0; )
|
|
910
|
+
s.type === g.Space && (e.unshift(s.fullName), t--), s = s.parent;
|
|
911
|
+
return e;
|
|
912
|
+
}
|
|
913
|
+
// 寻找坐标系组, 有groupUuid表示坐标系组
|
|
914
|
+
findCsGroup() {
|
|
915
|
+
var s;
|
|
916
|
+
const { groupUuid: t, parent: e } = this;
|
|
917
|
+
return t ? ((s = e == null ? void 0 : e.children) == null ? void 0 : s.filter((n) => n.groupUuid === t)) || [] : [this];
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* 递归寻找到相应的层级
|
|
921
|
+
* @param level //坐标系的层级
|
|
922
|
+
* @returns
|
|
923
|
+
*/
|
|
924
|
+
findCsByLevel(t) {
|
|
925
|
+
if (this.level === t)
|
|
926
|
+
return this;
|
|
927
|
+
if (this.children.length)
|
|
928
|
+
for (const e of this.children) {
|
|
929
|
+
const s = e.findCsByLevel(t);
|
|
930
|
+
if (s)
|
|
931
|
+
return s;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* 递归寻找到相应的坐标系 - 深度优先
|
|
936
|
+
* @param id 坐标系id
|
|
937
|
+
* @returns
|
|
938
|
+
*/
|
|
939
|
+
findCsById(t) {
|
|
940
|
+
if (t) {
|
|
941
|
+
if (this.id === t) return this;
|
|
942
|
+
for (const e of this.children) {
|
|
943
|
+
const s = e.findCsById(t);
|
|
944
|
+
if (s) return s;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* 获取路径,递归向上寻找父节点坐标系扁平列表
|
|
950
|
+
* @param mapped 是否被映射
|
|
951
|
+
* @returns
|
|
952
|
+
*/
|
|
953
|
+
getCsRoutes(t = !1) {
|
|
954
|
+
let e = this;
|
|
955
|
+
const s = [e];
|
|
956
|
+
for (; e != null && e.parent && !(t && !e.relativeMap); )
|
|
957
|
+
e = e.parent, e && s.push(e);
|
|
958
|
+
return s;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* 通过当前坐标系,获取新的映射坐标树
|
|
962
|
+
* @returns
|
|
963
|
+
*/
|
|
964
|
+
getMappedCsTree() {
|
|
965
|
+
function t(n) {
|
|
966
|
+
var o;
|
|
967
|
+
return (o = n.children) != null && o.length && (n.children = n.children.filter((a) => !!(a != null && a.relativeMap) && a.status !== z.Disabled).map((a) => t(a))), n;
|
|
968
|
+
}
|
|
969
|
+
const e = J(this.findRoot(!0)), s = t(e);
|
|
970
|
+
return s.parentId = 0, s.parent = void 0, s;
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* 获取该坐标系到目标坐标系的映射关系,两个坐标系必须是同一树的坐标系
|
|
974
|
+
* @param dstCoordinate 目标坐标系
|
|
975
|
+
* @returns
|
|
976
|
+
*/
|
|
977
|
+
getDestRelativeMap(t) {
|
|
978
|
+
var o;
|
|
979
|
+
if (this.id === t.id)
|
|
980
|
+
return new p();
|
|
981
|
+
const e = this.getRelativeMaps(), s = t.getRelativeMaps();
|
|
982
|
+
let n = new p();
|
|
983
|
+
return e == null || e.forEach((a) => {
|
|
984
|
+
n = p.addRelativeMap(n, a);
|
|
985
|
+
}), (o = s == null ? void 0 : s.reverse()) == null || o.forEach((a) => {
|
|
986
|
+
n = p.addRelativeMap(n, p.inverseRelativeMap(a));
|
|
987
|
+
}), n;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* 递归向上寻找父级的映射关系
|
|
991
|
+
* @returns
|
|
992
|
+
*/
|
|
993
|
+
getRelativeMaps() {
|
|
994
|
+
let t = this;
|
|
995
|
+
const e = [];
|
|
996
|
+
for (; t != null && t.parent && t.relativeMap; )
|
|
997
|
+
e.push(t.relativeMap), t = t.parent;
|
|
998
|
+
return e;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
class Pt {
|
|
1002
|
+
//屏幕位置
|
|
1003
|
+
constructor(t) {
|
|
1004
|
+
r(this, "canvas");
|
|
1005
|
+
r(this, "ctx");
|
|
1006
|
+
r(this, "options");
|
|
1007
|
+
r(this, "offset", { x: 0, y: 0 });
|
|
1008
|
+
// 拖动偏移
|
|
1009
|
+
r(this, "curOffset", { x: 0, y: 0 });
|
|
1010
|
+
// 记录上一次的偏移量
|
|
1011
|
+
r(this, "mousePosition", { x: -1, y: -1 });
|
|
1012
|
+
// 记录鼠标坐标位置
|
|
1013
|
+
// 缩放
|
|
1014
|
+
r(this, "MAX_SCALE", 60);
|
|
1015
|
+
r(this, "MIN_SCALE", 1);
|
|
1016
|
+
r(this, "STEP_SCALE", 0.5);
|
|
1017
|
+
// 暂存缩放值
|
|
1018
|
+
r(this, "scale", 1);
|
|
1019
|
+
r(this, "preScale", 1);
|
|
1020
|
+
// 画布大小
|
|
1021
|
+
r(this, "width", 0);
|
|
1022
|
+
r(this, "height", 0);
|
|
1023
|
+
r(this, "x", 0);
|
|
1024
|
+
// 记录鼠标点击时的横坐标
|
|
1025
|
+
r(this, "y", 0);
|
|
1026
|
+
// 记录鼠标点击时的纵坐标
|
|
1027
|
+
r(this, "timeout", 0);
|
|
1028
|
+
// 单击
|
|
1029
|
+
// 移动端相关参数
|
|
1030
|
+
r(this, "lastTouch");
|
|
1031
|
+
r(this, "initialDistance", 0);
|
|
1032
|
+
//初始距离
|
|
1033
|
+
r(this, "touchMode", 0);
|
|
1034
|
+
r(this, "isMouseover", !1);
|
|
1035
|
+
//鼠标是否在元素上
|
|
1036
|
+
r(this, "isBindEvent", !0);
|
|
1037
|
+
// 是否绘制辅助线
|
|
1038
|
+
r(this, "isDrawAssist", !1);
|
|
1039
|
+
// 是否绑定事件
|
|
1040
|
+
r(this, "customDrawAssist");
|
|
1041
|
+
// 绘制辅助线的方法
|
|
1042
|
+
r(this, "isMoveRedrawing");
|
|
1043
|
+
// 移动过程中是否重绘
|
|
1044
|
+
r(this, "afterDraw");
|
|
1045
|
+
r(this, "screenPos", { screenX: 0, screenY: 0 });
|
|
1046
|
+
const {
|
|
1047
|
+
container: e,
|
|
1048
|
+
width: s = 300,
|
|
1049
|
+
height: n = 300,
|
|
1050
|
+
isBindEvent: o = !0,
|
|
1051
|
+
isDrawAssist: a = !1,
|
|
1052
|
+
isMoveRedrawing: h,
|
|
1053
|
+
customDrawAssist: c,
|
|
1054
|
+
afterDraw: u,
|
|
1055
|
+
...d
|
|
1056
|
+
} = t;
|
|
1057
|
+
this.canvas = e, this.ctx = this.canvas.getContext("2d"), this.width = s, this.height = n, this.canvas.width = s, this.canvas.height = n, this.isBindEvent = o, this.isDrawAssist = a, this.customDrawAssist = c, this.isMoveRedrawing = h ?? a, this.options = d, 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));
|
|
1058
|
+
}
|
|
1059
|
+
onClick(t) {
|
|
1060
|
+
const { screenX: e, screenY: s } = t;
|
|
1061
|
+
this.timeout && clearTimeout(this.timeout);
|
|
1062
|
+
const n = this.getPos(t);
|
|
1063
|
+
this.x = n.x, this.y = n.y, this.screenPos = { screenX: e, screenY: s }, this.options.onClick && (this.timeout = setTimeout(() => {
|
|
1064
|
+
const o = parseFloat(((this.x - this.offset.x) / this.scale).toFixed(2)), a = parseFloat(((this.y - this.offset.y) / this.scale).toFixed(2));
|
|
1065
|
+
this.options.onClick(o, a);
|
|
1066
|
+
}, 200));
|
|
1067
|
+
}
|
|
1068
|
+
onMouseout(t) {
|
|
1069
|
+
this.isMouseover = !1, this.draw();
|
|
1070
|
+
}
|
|
1071
|
+
onTouchstart(t) {
|
|
1072
|
+
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);
|
|
1073
|
+
}
|
|
1074
|
+
onMousedown(t) {
|
|
1075
|
+
this.onClick(t), this.canvas.addEventListener("mousemove", this.onMousemoveTemp), this.canvas.addEventListener("mouseup", this.onMouseup);
|
|
1076
|
+
}
|
|
1077
|
+
onBothTouchstart(t) {
|
|
1078
|
+
t.preventDefault();
|
|
1079
|
+
const e = { x: t.touches[0].clientX, y: t.touches[0].clientY }, s = { x: t.touches[1].clientX, y: t.touches[1].clientY }, n = this.getPos({
|
|
1080
|
+
clientX: (e.x + s.x) / 2,
|
|
1081
|
+
clientY: (e.y + s.y) / 2
|
|
1082
|
+
});
|
|
1083
|
+
this.x = n.x, this.y = n.y, this.curOffset.x = this.offset.x, this.curOffset.y = this.offset.y, this.initialDistance = Math.sqrt(
|
|
1084
|
+
Math.pow(s.x - e.x, 2) + Math.pow(s.y - e.y, 2)
|
|
1085
|
+
);
|
|
1086
|
+
}
|
|
1087
|
+
onTouchmove(t) {
|
|
1088
|
+
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);
|
|
1089
|
+
}
|
|
1090
|
+
// 持久订阅
|
|
1091
|
+
onMousemove(t) {
|
|
1092
|
+
const e = this.getPos(t);
|
|
1093
|
+
this.mousePosition.x = e.x, this.mousePosition.y = e.y, this.isMouseover = !0, this.isMoveRedrawing && this.draw();
|
|
1094
|
+
}
|
|
1095
|
+
// 监听点击的持久move
|
|
1096
|
+
onMousemoveTemp(t) {
|
|
1097
|
+
const { screenX: e, screenY: s } = this.screenPos;
|
|
1098
|
+
(Math.abs(e - t.screenX) > 10 || Math.abs(s - 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());
|
|
1099
|
+
}
|
|
1100
|
+
onBothTouchmove(t) {
|
|
1101
|
+
if (t.preventDefault(), this.initialDistance) {
|
|
1102
|
+
const e = { x: t.touches[0].clientX, y: t.touches[0].clientY }, s = { x: t.touches[1].clientX, y: t.touches[1].clientY }, n = Math.sqrt(
|
|
1103
|
+
Math.pow(s.x - e.x, 2) + Math.pow(s.y - e.y, 2)
|
|
1104
|
+
);
|
|
1105
|
+
if (this.scale += (n - this.initialDistance) / 30 * this.STEP_SCALE, this.initialDistance = n, this.scale > this.MAX_SCALE) {
|
|
1106
|
+
this.scale = this.MAX_SCALE;
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
if (this.scale < this.MIN_SCALE) {
|
|
1110
|
+
this.scale = this.MIN_SCALE;
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
this.zoom();
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
onTouchend() {
|
|
1117
|
+
this.touchMode = 0, this.onMouseup();
|
|
1118
|
+
}
|
|
1119
|
+
onMouseup() {
|
|
1120
|
+
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);
|
|
1121
|
+
}
|
|
1122
|
+
onMousewheel(t) {
|
|
1123
|
+
this.timeout && clearTimeout(this.timeout), t.preventDefault();
|
|
1124
|
+
const e = this.getPos(t);
|
|
1125
|
+
this.x = e.x, this.y = e.y;
|
|
1126
|
+
const s = t.wheelDelta > 0 || t.detail < 0 ? this.STEP_SCALE : -this.STEP_SCALE;
|
|
1127
|
+
if (this.scale = parseFloat((this.scale + s).toFixed(2)), this.scale > this.MAX_SCALE) {
|
|
1128
|
+
this.scale = this.MAX_SCALE;
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
if (this.scale < this.MIN_SCALE) {
|
|
1132
|
+
this.scale = this.MIN_SCALE;
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
this.zoom();
|
|
1136
|
+
}
|
|
1137
|
+
// 触摸
|
|
1138
|
+
onTouch(t) {
|
|
1139
|
+
const e = Date.now(), { lastTouchTime: s = 0, lastTouchX: n = 0, lastTouchY: o = 0 } = this.lastTouch || {};
|
|
1140
|
+
e - s < 300 && Math.abs(t.clientX - n) < 30 && Math.abs(t.clientY - o) < 30 ? (this.onDblclick(t), this.lastTouch = {
|
|
1141
|
+
lastTouchTime: 0,
|
|
1142
|
+
lastTouchX: 0,
|
|
1143
|
+
lastTouchY: 0
|
|
1144
|
+
}) : (this.onClick(t), this.lastTouch = {
|
|
1145
|
+
lastTouchTime: e,
|
|
1146
|
+
lastTouchX: t.clientX,
|
|
1147
|
+
lastTouchY: t.clientY
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
onDblclick(t) {
|
|
1151
|
+
this.timeout && clearTimeout(this.timeout), this.reset(), this.draw();
|
|
1152
|
+
}
|
|
1153
|
+
zoom() {
|
|
1154
|
+
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;
|
|
1155
|
+
}
|
|
1156
|
+
// 重置
|
|
1157
|
+
reset(t) {
|
|
1158
|
+
const {
|
|
1159
|
+
width: e = this.width,
|
|
1160
|
+
height: s = this.height,
|
|
1161
|
+
scale: n = 1,
|
|
1162
|
+
preScale: o = 1,
|
|
1163
|
+
offset: a = { x: 0, y: 0 },
|
|
1164
|
+
curOffset: h = { x: 0, y: 0 }
|
|
1165
|
+
} = t || {};
|
|
1166
|
+
this.width = e, this.height = s, this.canvas.width = e, this.canvas.height = s, this.scale = n, this.preScale = o, this.offset = a, this.curOffset = h;
|
|
1167
|
+
}
|
|
1168
|
+
// 辅助内容
|
|
1169
|
+
drawAssist() {
|
|
1170
|
+
const t = this.ctx;
|
|
1171
|
+
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();
|
|
1172
|
+
}
|
|
1173
|
+
// 绘制
|
|
1174
|
+
draw() {
|
|
1175
|
+
var t;
|
|
1176
|
+
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()), (t = this.afterDraw) == null || t.call(this, this.ctx, this);
|
|
1177
|
+
}
|
|
1178
|
+
getPos(t) {
|
|
1179
|
+
const e = this.canvas.getBoundingClientRect();
|
|
1180
|
+
let s = parseFloat((t.clientX - e.left).toFixed(2)), n = parseFloat((t.clientY - e.top).toFixed(2));
|
|
1181
|
+
return s = s < 0 ? 0 : s, n = n < 0 ? 0 : n, { x: s, y: n };
|
|
1182
|
+
}
|
|
1183
|
+
unBindEvent() {
|
|
1184
|
+
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));
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
const C = {};
|
|
1188
|
+
class It {
|
|
1189
|
+
constructor(t) {
|
|
1190
|
+
r(this, "type", "image");
|
|
1191
|
+
// 修改为更通用的名称
|
|
1192
|
+
r(this, "x");
|
|
1193
|
+
r(this, "y");
|
|
1194
|
+
r(this, "width");
|
|
1195
|
+
r(this, "height");
|
|
1196
|
+
r(this, "img");
|
|
1197
|
+
r(this, "src");
|
|
1198
|
+
r(this, "redraw");
|
|
1199
|
+
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);
|
|
1200
|
+
}
|
|
1201
|
+
loadImage(t) {
|
|
1202
|
+
const e = C[this.src];
|
|
1203
|
+
if (e)
|
|
1204
|
+
return queueMicrotask(() => {
|
|
1205
|
+
var s;
|
|
1206
|
+
t == null || t(e), (s = this.redraw) == null || s.call(this);
|
|
1207
|
+
}), e;
|
|
1208
|
+
{
|
|
1209
|
+
const s = new Image();
|
|
1210
|
+
return s.crossOrigin = "anonymous", s.src = this.src, s.onload = () => {
|
|
1211
|
+
var n;
|
|
1212
|
+
C[this.src] = s, t == null || t(s), (n = this.redraw) == null || n.call(this);
|
|
1213
|
+
}, s;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
draw(t) {
|
|
1217
|
+
try {
|
|
1218
|
+
if (!this.img.complete) return;
|
|
1219
|
+
t.save(), t.drawImage(this.img, this.x, this.y, this.width, this.height), t.restore();
|
|
1220
|
+
} catch (e) {
|
|
1221
|
+
console.error(e);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
class Lt {
|
|
1226
|
+
constructor(t) {
|
|
1227
|
+
r(this, "id", "");
|
|
1228
|
+
r(this, "type", "point");
|
|
1229
|
+
r(this, "x");
|
|
1230
|
+
r(this, "y");
|
|
1231
|
+
r(this, "r");
|
|
1232
|
+
r(this, "text");
|
|
1233
|
+
r(this, "backgroundColor");
|
|
1234
|
+
r(this, "index");
|
|
1235
|
+
r(this, "pIndex");
|
|
1236
|
+
r(this, "parentId");
|
|
1237
|
+
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)";
|
|
1238
|
+
}
|
|
1239
|
+
draw(t, e) {
|
|
1240
|
+
t.save();
|
|
1241
|
+
const s = 1 / e.scale;
|
|
1242
|
+
t.beginPath(), t.arc(this.x, this.y, this.r * s, 0, 2 * Math.PI), t.fillStyle = this.backgroundColor, t.fill(), t.font = `${this.r * s}px Microsoft YaHei`, t.textAlign = "center", t.fillStyle = "#FFFFFF", t.fillText(this.text, this.x, this.y + this.r * s / 3), t.restore();
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
const R = {};
|
|
1246
|
+
class Nt {
|
|
1247
|
+
constructor(t) {
|
|
1248
|
+
r(this, "id", "");
|
|
1249
|
+
r(this, "type", "issue");
|
|
1250
|
+
//轨迹点上的事件
|
|
1251
|
+
r(this, "x");
|
|
1252
|
+
r(this, "y");
|
|
1253
|
+
r(this, "width");
|
|
1254
|
+
r(this, "height");
|
|
1255
|
+
r(this, "src");
|
|
1256
|
+
r(this, "img");
|
|
1257
|
+
r(this, "index");
|
|
1258
|
+
r(this, "pIndex");
|
|
1259
|
+
r(this, "parentId");
|
|
1260
|
+
r(this, "count");
|
|
1261
|
+
r(this, "badgeR");
|
|
1262
|
+
r(this, "redraw");
|
|
1263
|
+
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);
|
|
1264
|
+
}
|
|
1265
|
+
loadImage(t) {
|
|
1266
|
+
const e = R[this.src];
|
|
1267
|
+
if (e)
|
|
1268
|
+
return queueMicrotask(() => {
|
|
1269
|
+
var s;
|
|
1270
|
+
t == null || t(e), (s = this.redraw) == null || s.call(this);
|
|
1271
|
+
}), e;
|
|
1272
|
+
{
|
|
1273
|
+
const s = new Image();
|
|
1274
|
+
return s.src = this.src, s.crossOrigin = "anonymous", s.onload = () => {
|
|
1275
|
+
var n;
|
|
1276
|
+
R[this.src] = s, t == null || t(s), (n = this.redraw) == null || n.call(this);
|
|
1277
|
+
}, s;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
draw(t, e) {
|
|
1281
|
+
if (!this.img.complete) return;
|
|
1282
|
+
const s = 1 / e.scale, n = this.width * s, o = this.height * s, a = this.x - n / 2, h = this.y - o, c = this.badgeR * s, u = c * 1.5;
|
|
1283
|
+
t.save(), t.drawImage(this.img, a, h, n, o), t.beginPath(), this.count > 1 && (t.arc(this.x + n * 0.3, this.y - o * 0.8, c, 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 * 0.3, this.y - o * 0.8 + c / 2)), t.restore();
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
const j = {};
|
|
1287
|
+
class At {
|
|
1288
|
+
constructor(t) {
|
|
1289
|
+
r(this, "type", "marker");
|
|
1290
|
+
r(this, "x");
|
|
1291
|
+
r(this, "y");
|
|
1292
|
+
r(this, "url");
|
|
1293
|
+
r(this, "width");
|
|
1294
|
+
r(this, "height");
|
|
1295
|
+
r(this, "anchor");
|
|
1296
|
+
r(this, "img");
|
|
1297
|
+
r(this, "scale");
|
|
1298
|
+
r(this, "redraw");
|
|
1299
|
+
r(this, "beforeDraw");
|
|
1300
|
+
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);
|
|
1301
|
+
}
|
|
1302
|
+
loadImage(t) {
|
|
1303
|
+
const e = j[this.url];
|
|
1304
|
+
if (e)
|
|
1305
|
+
return queueMicrotask(() => {
|
|
1306
|
+
var s;
|
|
1307
|
+
t == null || t(e), (s = this.redraw) == null || s.call(this);
|
|
1308
|
+
}), e;
|
|
1309
|
+
{
|
|
1310
|
+
const s = new Image();
|
|
1311
|
+
return s.src = this.url, s.crossOrigin = "anonymous", s.onload = () => {
|
|
1312
|
+
var n;
|
|
1313
|
+
j[this.url] = s, t == null || t(s), (n = this.redraw) == null || n.call(this);
|
|
1314
|
+
}, s;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
calculateIconPosition() {
|
|
1318
|
+
var s, n;
|
|
1319
|
+
const t = ((s = this.anchor) == null ? void 0 : s.x) ?? this.width / 2, e = ((n = this.anchor) == null ? void 0 : n.y) ?? this.height / 2;
|
|
1320
|
+
return {
|
|
1321
|
+
iconStartX: this.x - t * this.scale,
|
|
1322
|
+
iconStartY: this.y - e * this.scale
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
draw(t, e) {
|
|
1326
|
+
var o, a;
|
|
1327
|
+
if ((o = this.beforeDraw) == null || o.call(this, t, e), !((a = this.img) != null && a.complete)) return;
|
|
1328
|
+
const { iconStartX: s, iconStartY: n } = this.calculateIconPosition();
|
|
1329
|
+
t.save();
|
|
1330
|
+
try {
|
|
1331
|
+
t.drawImage(
|
|
1332
|
+
this.img,
|
|
1333
|
+
s,
|
|
1334
|
+
n,
|
|
1335
|
+
this.width * this.scale,
|
|
1336
|
+
this.height * this.scale
|
|
1337
|
+
);
|
|
1338
|
+
} catch (h) {
|
|
1339
|
+
console.error("绘制标记时出错:", h);
|
|
1340
|
+
} finally {
|
|
1341
|
+
t.restore();
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
class Ct {
|
|
1346
|
+
constructor(t) {
|
|
1347
|
+
r(this, "type", "radar");
|
|
1348
|
+
r(this, "x");
|
|
1349
|
+
r(this, "y");
|
|
1350
|
+
r(this, "r");
|
|
1351
|
+
r(this, "angle");
|
|
1352
|
+
r(this, "text");
|
|
1353
|
+
r(this, "hFov", 90);
|
|
1354
|
+
r(this, "beforeDraw");
|
|
1355
|
+
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;
|
|
1356
|
+
}
|
|
1357
|
+
draw(t, e) {
|
|
1358
|
+
var h;
|
|
1359
|
+
(h = this.beforeDraw) == null || h.call(this, t, e);
|
|
1360
|
+
const s = 1 / e.scale, [n, o] = [
|
|
1361
|
+
(this.angle - this.hFov / 2) / 180 * Math.PI,
|
|
1362
|
+
(this.angle + this.hFov / 2) / 180 * Math.PI
|
|
1363
|
+
];
|
|
1364
|
+
t.save();
|
|
1365
|
+
const a = t.createRadialGradient(
|
|
1366
|
+
this.x,
|
|
1367
|
+
this.y,
|
|
1368
|
+
0,
|
|
1369
|
+
this.x,
|
|
1370
|
+
this.y,
|
|
1371
|
+
this.r * s
|
|
1372
|
+
);
|
|
1373
|
+
a.addColorStop(0, "rgba(180, 42, 42, 1)"), a.addColorStop(1, "rgba(180, 42, 42, 0.5)"), t.beginPath(), t.moveTo(this.x, this.y), t.arc(this.x, this.y, this.r * s, n, o), t.closePath(), t.fillStyle = a, t.fill(), t.restore();
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
class Rt {
|
|
1377
|
+
constructor(t) {
|
|
1378
|
+
r(this, "type", "region");
|
|
1379
|
+
r(this, "x");
|
|
1380
|
+
r(this, "y");
|
|
1381
|
+
r(this, "shape");
|
|
1382
|
+
r(this, "areaPoints");
|
|
1383
|
+
r(this, "backgroundColor");
|
|
1384
|
+
if (this.x = t.x, this.y = t.y, this.shape = t.shape || "", this.backgroundColor = t.backgroundColor, t.areaPoints.length === 2) {
|
|
1385
|
+
const [{ x: e, y: s }, {}, { x: n, y: o }] = t.areaPoints;
|
|
1386
|
+
this.areaPoints = [
|
|
1387
|
+
{ x: Math.min(e, n), y: Math.min(s, o) },
|
|
1388
|
+
{ x: Math.max(e, n), y: Math.min(s, o) },
|
|
1389
|
+
{ x: Math.max(e, n), y: Math.max(s, o) },
|
|
1390
|
+
{ x: Math.min(e, n), y: Math.max(s, o) }
|
|
1391
|
+
];
|
|
1392
|
+
} else
|
|
1393
|
+
this.areaPoints = t.areaPoints;
|
|
1394
|
+
}
|
|
1395
|
+
draw(t, e) {
|
|
1396
|
+
if (t.save(), t.beginPath(), t.globalAlpha = 0.3, t.fillStyle = this.backgroundColor, this.shape === "circle") {
|
|
1397
|
+
const [{ x: s, y: n }, {}, { x: o, y: a }] = this.areaPoints, h = Math.abs(o - s) / 2, c = s + (o - s) / 2, u = n + (a - n) / 2;
|
|
1398
|
+
t.arc(c, u, h, 0, 2 * Math.PI);
|
|
1399
|
+
} else
|
|
1400
|
+
this.areaPoints.forEach((s, n) => {
|
|
1401
|
+
const { x: o, y: a } = s;
|
|
1402
|
+
n === 0 ? t.moveTo(o, a) : t.lineTo(o, a);
|
|
1403
|
+
});
|
|
1404
|
+
t.fill(), t.restore();
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
export {
|
|
1408
|
+
Pt as CanvasElement,
|
|
1409
|
+
It as CanvasImageElement,
|
|
1410
|
+
Nt as CanvasIssueElement,
|
|
1411
|
+
At as CanvasMarkerElement,
|
|
1412
|
+
Lt as CanvasPointElement,
|
|
1413
|
+
Ct as CanvasRadarElement,
|
|
1414
|
+
Rt as CanvasRegionElement,
|
|
1415
|
+
St as Coordinate,
|
|
1416
|
+
V as CoordinateLevel,
|
|
1417
|
+
E as CoordinateModelType,
|
|
1418
|
+
z as CoordinateStatus,
|
|
1419
|
+
g as CoordinateType,
|
|
1420
|
+
y as DataSource,
|
|
1421
|
+
O as GeoPoint,
|
|
1422
|
+
m as Point,
|
|
1423
|
+
p as RelativeMap,
|
|
1424
|
+
w as RequestEnum,
|
|
1425
|
+
Ot as api,
|
|
1426
|
+
Dt as http,
|
|
1427
|
+
zt as utils
|
|
1428
|
+
};
|