@vsleem-realsee-viewer/shared 2.0.4 → 2.0.6
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.mjs +764 -788
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class y extends Error {
|
|
5
|
-
constructor(t, e, s) {
|
|
6
|
-
super(e), this.code = t, this.message = e, this.details = s, this.name = "Apprror", Object.setPrototypeOf(this, y.prototype);
|
|
1
|
+
class m extends Error {
|
|
2
|
+
constructor(t, e, i) {
|
|
3
|
+
super(e), this.code = t, this.message = e, this.details = i, this.name = "Apprror", Object.setPrototypeOf(this, m.prototype);
|
|
7
4
|
}
|
|
8
5
|
// 可选的:转换成 JSON 格式,方便返回给调用方
|
|
9
6
|
toJSON() {
|
|
@@ -15,421 +12,421 @@ class y extends Error {
|
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
var
|
|
19
|
-
const
|
|
15
|
+
var P = /* @__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))(P || {}), K = /* @__PURE__ */ ((s) => (s[s.Global = 0] = "Global", s))(K || {}), M = /* @__PURE__ */ ((s) => (s[s.Space = 0] = "Space", s[s.Model = 1] = "Model", s[s.Data = 2] = "Data", s))(M || {}), D = /* @__PURE__ */ ((s) => (s[s.Used = 0] = "Used", s[s.Enabled = 1] = "Enabled", s[s.Disabled = 2] = "Disabled", s))(D || {}), F = /* @__PURE__ */ ((s) => (s[s.SUCCESS = 200] = "SUCCESS", s[s.ERROR = -1] = "ERROR", s[s.TIMEOUT = 401] = "TIMEOUT", s))(F || {}), x = /* @__PURE__ */ ((s) => (s.GET = "GET", s.POST = "POST", s))(x || {}), I = /* @__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))(I || {}), tt = /* @__PURE__ */ ((s) => (s.Hw = "huawei", s.Ali = "aliyun", s.Hs = "hs", s.Aws = "amazon", s.Minio = "minio", s))(tt || {}), 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 et = {
|
|
20
17
|
baseUrl: "https://vsleem.com/api",
|
|
21
18
|
obsType: "hs"
|
|
22
|
-
},
|
|
19
|
+
}, st = {
|
|
23
20
|
isTransformResponse: !0,
|
|
24
21
|
joinBaseUrl: !0,
|
|
25
22
|
withAuthorize: !0
|
|
26
|
-
},
|
|
23
|
+
}, it = {
|
|
27
24
|
url: "",
|
|
28
25
|
method: x.GET,
|
|
29
26
|
headers: {}
|
|
30
|
-
},
|
|
31
|
-
function
|
|
32
|
-
Object.assign(
|
|
27
|
+
}, U = { ...et };
|
|
28
|
+
function nt(s) {
|
|
29
|
+
Object.assign(U, s);
|
|
33
30
|
}
|
|
34
|
-
async function
|
|
35
|
-
const e = { ...
|
|
31
|
+
async function b(s, t) {
|
|
32
|
+
const e = { ...st, ...t }, i = { ...it, ...s };
|
|
36
33
|
try {
|
|
37
|
-
const n =
|
|
38
|
-
return
|
|
34
|
+
const n = ot(i, e), { url: o, ...r } = n, h = await (await window.fetch(o, r)).json();
|
|
35
|
+
return rt(h, e);
|
|
39
36
|
} catch (n) {
|
|
40
|
-
return
|
|
37
|
+
return at(n);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
function
|
|
44
|
-
const { baseUrl: e, authorizeCode:
|
|
45
|
-
let { url:
|
|
46
|
-
n && e && (
|
|
47
|
-
const
|
|
48
|
-
if (/^https?:\/\/.+$/i.test(e ?? "") ?
|
|
49
|
-
const
|
|
50
|
-
|
|
40
|
+
function ot(s, t) {
|
|
41
|
+
const { baseUrl: e, authorizeCode: i } = U, { joinBaseUrl: n, withAuthorize: o } = t;
|
|
42
|
+
let { url: r, method: a, headers: h = {}, params: l, data: c } = s;
|
|
43
|
+
n && e && (r = `${e}${r}`), a = a?.toUpperCase();
|
|
44
|
+
const u = { ...h };
|
|
45
|
+
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 === x.POST && !u["Content-Type"] && (u["Content-Type"] = I.JSON), a === x.GET && l) {
|
|
46
|
+
const p = new URLSearchParams(l);
|
|
47
|
+
r += `?${p.toString()}`;
|
|
51
48
|
}
|
|
52
49
|
let d;
|
|
53
|
-
return
|
|
54
|
-
url:
|
|
55
|
-
method:
|
|
56
|
-
headers:
|
|
50
|
+
return a === x.POST && (d = u["Content-Type"] === I.JSON ? JSON.stringify(c || {}) : c), {
|
|
51
|
+
url: r,
|
|
52
|
+
method: a,
|
|
53
|
+
headers: u,
|
|
57
54
|
body: d
|
|
58
55
|
};
|
|
59
56
|
}
|
|
60
|
-
function
|
|
57
|
+
function rt(s, t) {
|
|
61
58
|
if (!t.isTransformResponse)
|
|
62
|
-
return i;
|
|
63
|
-
if (!i)
|
|
64
|
-
throw new y(w.RequestResultError, "请求返回的结果错误");
|
|
65
|
-
const { code: e, data: s, msg: n } = i;
|
|
66
|
-
if (e === Y.SUCCESS)
|
|
67
59
|
return s;
|
|
68
|
-
|
|
60
|
+
if (!s)
|
|
61
|
+
throw new m(y.RequestResultError, "请求返回的结果错误");
|
|
62
|
+
const { code: e, data: i, msg: n } = s;
|
|
63
|
+
if (e === F.SUCCESS)
|
|
64
|
+
return i;
|
|
65
|
+
throw new m(y.RequestCodeError, n || "请求返回的Code错误");
|
|
69
66
|
}
|
|
70
|
-
function
|
|
71
|
-
throw
|
|
72
|
-
|
|
73
|
-
typeof
|
|
67
|
+
function at(s) {
|
|
68
|
+
throw s instanceof Error ? s : new m(
|
|
69
|
+
y.RequestUnknownError,
|
|
70
|
+
typeof s == "string" ? s : "未知的请求错误"
|
|
74
71
|
);
|
|
75
72
|
}
|
|
76
73
|
const Ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
77
74
|
__proto__: null,
|
|
78
|
-
request:
|
|
79
|
-
setRequestGlobalConfig:
|
|
75
|
+
request: b,
|
|
76
|
+
setRequestGlobalConfig: nt
|
|
80
77
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
81
|
-
function
|
|
82
|
-
return
|
|
78
|
+
function Y(s, t) {
|
|
79
|
+
return b(
|
|
83
80
|
{
|
|
84
81
|
url: "/project/jssdk/cs/list",
|
|
85
82
|
method: x.GET,
|
|
86
|
-
params:
|
|
83
|
+
params: s
|
|
87
84
|
},
|
|
88
85
|
t
|
|
89
86
|
);
|
|
90
87
|
}
|
|
91
|
-
function
|
|
92
|
-
return
|
|
88
|
+
function B(s, t) {
|
|
89
|
+
return b(
|
|
93
90
|
{
|
|
94
91
|
url: "/project/jssdk/cs/bind",
|
|
95
92
|
method: x.POST,
|
|
96
|
-
data:
|
|
93
|
+
data: s
|
|
97
94
|
},
|
|
98
95
|
t
|
|
99
96
|
);
|
|
100
97
|
}
|
|
101
|
-
function
|
|
102
|
-
return
|
|
98
|
+
function C(s, t) {
|
|
99
|
+
return b(
|
|
103
100
|
{
|
|
104
101
|
url: "/project/jssdk/cs/save",
|
|
105
102
|
method: x.POST,
|
|
106
|
-
data:
|
|
103
|
+
data: s
|
|
107
104
|
},
|
|
108
105
|
t
|
|
109
106
|
);
|
|
110
107
|
}
|
|
111
|
-
function
|
|
112
|
-
return
|
|
108
|
+
function G(s, t) {
|
|
109
|
+
return b(
|
|
113
110
|
{
|
|
114
111
|
url: "/project/jssdk/cs/delete",
|
|
115
112
|
method: x.POST,
|
|
116
|
-
data:
|
|
113
|
+
data: s
|
|
117
114
|
},
|
|
118
115
|
t
|
|
119
116
|
);
|
|
120
117
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
118
|
+
function $(s, t) {
|
|
119
|
+
return b(
|
|
123
120
|
{
|
|
124
121
|
url: "/project/jssdk/cs/mapping",
|
|
125
122
|
method: x.POST,
|
|
126
|
-
data:
|
|
123
|
+
data: s
|
|
127
124
|
},
|
|
128
125
|
t
|
|
129
126
|
);
|
|
130
127
|
}
|
|
131
|
-
function
|
|
132
|
-
return
|
|
128
|
+
function _(s, t) {
|
|
129
|
+
return b(
|
|
133
130
|
{
|
|
134
131
|
url: "/project/jssdk/cs/mapping/query",
|
|
135
132
|
method: x.GET,
|
|
136
|
-
params:
|
|
133
|
+
params: s
|
|
137
134
|
},
|
|
138
135
|
t
|
|
139
136
|
);
|
|
140
137
|
}
|
|
141
|
-
function
|
|
138
|
+
function ht(s, t = {
|
|
142
139
|
isTransformResponse: !1,
|
|
143
140
|
joinBaseUrl: !1,
|
|
144
141
|
withAuthorize: !1
|
|
145
142
|
}) {
|
|
146
|
-
return
|
|
143
|
+
return b(
|
|
147
144
|
{
|
|
148
|
-
url:
|
|
145
|
+
url: s,
|
|
149
146
|
method: x.GET
|
|
150
147
|
},
|
|
151
148
|
t
|
|
152
149
|
);
|
|
153
150
|
}
|
|
154
|
-
const
|
|
151
|
+
const Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
155
152
|
__proto__: null,
|
|
156
|
-
bindCoordinate:
|
|
157
|
-
getCoordinateList:
|
|
158
|
-
getImageInfo:
|
|
159
|
-
getMappingRelation:
|
|
160
|
-
mapingCoordinate:
|
|
161
|
-
removeCoordinate:
|
|
162
|
-
saveCoordinate:
|
|
163
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
164
|
-
function v(
|
|
165
|
-
return
|
|
153
|
+
bindCoordinate: B,
|
|
154
|
+
getCoordinateList: Y,
|
|
155
|
+
getImageInfo: ht,
|
|
156
|
+
getMappingRelation: _,
|
|
157
|
+
mapingCoordinate: $,
|
|
158
|
+
removeCoordinate: G,
|
|
159
|
+
saveCoordinate: C
|
|
160
|
+
}, Symbol.toStringTag, { value: "Module" })), ct = typeof window < "u", lt = Object.prototype.toString;
|
|
161
|
+
function v(s, t) {
|
|
162
|
+
return lt.call(s) === `[object ${t}]`;
|
|
166
163
|
}
|
|
167
|
-
function
|
|
168
|
-
return typeof
|
|
164
|
+
function Z(s) {
|
|
165
|
+
return typeof s < "u";
|
|
169
166
|
}
|
|
170
|
-
function
|
|
171
|
-
return !
|
|
167
|
+
function q(s) {
|
|
168
|
+
return !Z(s);
|
|
172
169
|
}
|
|
173
|
-
function
|
|
174
|
-
return
|
|
170
|
+
function j(s) {
|
|
171
|
+
return s !== null && v(s, "Object");
|
|
175
172
|
}
|
|
176
|
-
function
|
|
177
|
-
return
|
|
173
|
+
function J(s) {
|
|
174
|
+
return s === null;
|
|
178
175
|
}
|
|
179
|
-
function
|
|
180
|
-
return v(
|
|
176
|
+
function ut(s) {
|
|
177
|
+
return v(s, "Date");
|
|
181
178
|
}
|
|
182
|
-
function
|
|
183
|
-
return v(
|
|
179
|
+
function dt(s) {
|
|
180
|
+
return v(s, "String");
|
|
184
181
|
}
|
|
185
|
-
function
|
|
186
|
-
return typeof
|
|
182
|
+
function O(s) {
|
|
183
|
+
return typeof s == "function";
|
|
187
184
|
}
|
|
188
|
-
function
|
|
189
|
-
return v(
|
|
185
|
+
function ft(s) {
|
|
186
|
+
return v(s, "Boolean");
|
|
190
187
|
}
|
|
191
|
-
function
|
|
192
|
-
return v(
|
|
188
|
+
function mt(s) {
|
|
189
|
+
return v(s, "RegExp");
|
|
193
190
|
}
|
|
194
|
-
function
|
|
195
|
-
return
|
|
191
|
+
function S(s) {
|
|
192
|
+
return s && Array.isArray(s);
|
|
196
193
|
}
|
|
197
|
-
function
|
|
198
|
-
return typeof window < "u" && v(
|
|
194
|
+
function yt(s) {
|
|
195
|
+
return typeof window < "u" && v(s, "Window");
|
|
199
196
|
}
|
|
200
|
-
function
|
|
201
|
-
return
|
|
197
|
+
function wt(s) {
|
|
198
|
+
return j(s) && !!s.tagName;
|
|
202
199
|
}
|
|
203
|
-
function
|
|
204
|
-
return typeof
|
|
200
|
+
function pt(s) {
|
|
201
|
+
return typeof s == "number" || /^\d+(\.\d+)?$/.test(s);
|
|
205
202
|
}
|
|
206
|
-
function
|
|
207
|
-
return v(Number(
|
|
203
|
+
function E(s) {
|
|
204
|
+
return v(Number(s), "Number");
|
|
208
205
|
}
|
|
209
|
-
function
|
|
210
|
-
return JSON.stringify(
|
|
206
|
+
function gt(s, t) {
|
|
207
|
+
return JSON.stringify(s) === JSON.stringify(t);
|
|
211
208
|
}
|
|
212
|
-
function
|
|
213
|
-
return
|
|
209
|
+
function xt(s) {
|
|
210
|
+
return q(s) || J(s);
|
|
214
211
|
}
|
|
215
|
-
function
|
|
216
|
-
return v(
|
|
212
|
+
function Mt(s) {
|
|
213
|
+
return v(s, "Promise") && j(s) && O(s.then) && O(s.catch);
|
|
217
214
|
}
|
|
218
|
-
function
|
|
219
|
-
return
|
|
215
|
+
function H(s) {
|
|
216
|
+
return T(s, /* @__PURE__ */ new WeakMap());
|
|
220
217
|
}
|
|
221
|
-
function
|
|
222
|
-
if (typeof
|
|
223
|
-
return
|
|
224
|
-
if (t.has(
|
|
225
|
-
return t.get(
|
|
218
|
+
function T(s, t) {
|
|
219
|
+
if (typeof s != "object" || s === null)
|
|
220
|
+
return s;
|
|
221
|
+
if (t.has(s))
|
|
222
|
+
return t.get(s);
|
|
226
223
|
let e;
|
|
227
|
-
if (
|
|
228
|
-
return e = new Date(
|
|
229
|
-
if (
|
|
230
|
-
return e = new RegExp(
|
|
231
|
-
if (
|
|
232
|
-
return e = /* @__PURE__ */ new Map(), t.set(
|
|
233
|
-
e.set(
|
|
224
|
+
if (s instanceof Date)
|
|
225
|
+
return e = new Date(s), t.set(s, e), e;
|
|
226
|
+
if (s instanceof RegExp)
|
|
227
|
+
return e = new RegExp(s), t.set(s, e), e;
|
|
228
|
+
if (s instanceof Map)
|
|
229
|
+
return e = /* @__PURE__ */ new Map(), t.set(s, e), s.forEach((n, o) => {
|
|
230
|
+
e.set(o, T(n, t));
|
|
234
231
|
}), e;
|
|
235
|
-
if (
|
|
236
|
-
return e = /* @__PURE__ */ new Set(), t.set(
|
|
237
|
-
e.add(
|
|
232
|
+
if (s instanceof Set)
|
|
233
|
+
return e = /* @__PURE__ */ new Set(), t.set(s, e), s.forEach((n) => {
|
|
234
|
+
e.add(T(n, t));
|
|
238
235
|
}), e;
|
|
239
|
-
if (ArrayBuffer.isView(
|
|
240
|
-
return e = new
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
), t.set(
|
|
245
|
-
if (
|
|
246
|
-
return e =
|
|
247
|
-
if (Array.isArray(
|
|
248
|
-
e = [], t.set(
|
|
249
|
-
for (let n = 0; n <
|
|
250
|
-
n in
|
|
236
|
+
if (ArrayBuffer.isView(s))
|
|
237
|
+
return e = new s.constructor(
|
|
238
|
+
s.buffer.slice(0),
|
|
239
|
+
s.byteOffset,
|
|
240
|
+
s.byteLength
|
|
241
|
+
), t.set(s, e), e;
|
|
242
|
+
if (s instanceof ArrayBuffer)
|
|
243
|
+
return e = s.slice(0), t.set(s, e), e;
|
|
244
|
+
if (Array.isArray(s)) {
|
|
245
|
+
e = [], t.set(s, e);
|
|
246
|
+
for (let n = 0; n < s.length; n++)
|
|
247
|
+
n in s && (e[n] = T(s[n], t));
|
|
251
248
|
return e;
|
|
252
249
|
}
|
|
253
|
-
e = Object.create(Object.getPrototypeOf(
|
|
254
|
-
for (const n in
|
|
255
|
-
Object.prototype.hasOwnProperty.call(
|
|
256
|
-
const
|
|
257
|
-
for (const n of
|
|
258
|
-
Object.prototype.propertyIsEnumerable.call(
|
|
250
|
+
e = Object.create(Object.getPrototypeOf(s)), t.set(s, e);
|
|
251
|
+
for (const n in s)
|
|
252
|
+
Object.prototype.hasOwnProperty.call(s, n) && (e[n] = T(s[n], t));
|
|
253
|
+
const i = Object.getOwnPropertySymbols(s);
|
|
254
|
+
for (const n of i)
|
|
255
|
+
Object.prototype.propertyIsEnumerable.call(s, n) && (e[n] = T(s[n], t));
|
|
259
256
|
return e;
|
|
260
257
|
}
|
|
261
|
-
function
|
|
262
|
-
let
|
|
263
|
-
const n = function(...
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}, t),
|
|
258
|
+
function vt(s, t, e = !1) {
|
|
259
|
+
let i;
|
|
260
|
+
const n = function(...o) {
|
|
261
|
+
const r = this, a = e && !i;
|
|
262
|
+
i && clearTimeout(i), i = setTimeout(() => {
|
|
263
|
+
i = void 0, e || s.apply(r, o);
|
|
264
|
+
}, t), a && s.apply(r, o);
|
|
268
265
|
};
|
|
269
266
|
return n.cancel = () => {
|
|
270
|
-
|
|
267
|
+
i && clearTimeout(i), i = void 0;
|
|
271
268
|
}, n;
|
|
272
269
|
}
|
|
273
|
-
function
|
|
274
|
-
let
|
|
275
|
-
const
|
|
276
|
-
const
|
|
277
|
-
n ? (clearTimeout(
|
|
270
|
+
function bt(s, t, e = !1) {
|
|
271
|
+
let i, n;
|
|
272
|
+
const o = function(...r) {
|
|
273
|
+
const a = this;
|
|
274
|
+
n ? (clearTimeout(i), i = setTimeout(
|
|
278
275
|
() => {
|
|
279
|
-
Date.now() - n >= t && (
|
|
276
|
+
Date.now() - n >= t && (s.apply(a, r), n = Date.now());
|
|
280
277
|
},
|
|
281
278
|
t - (Date.now() - n)
|
|
282
|
-
)) : (e &&
|
|
279
|
+
)) : (e && s.apply(a, r), n = Date.now());
|
|
283
280
|
};
|
|
284
|
-
return
|
|
285
|
-
clearTimeout(
|
|
286
|
-
},
|
|
281
|
+
return o.cancel = () => {
|
|
282
|
+
clearTimeout(i), i = void 0, n = void 0;
|
|
283
|
+
}, o;
|
|
287
284
|
}
|
|
288
|
-
function
|
|
289
|
-
if (!t.length) return
|
|
285
|
+
function R(s, ...t) {
|
|
286
|
+
if (!t.length) return s;
|
|
290
287
|
const e = t.shift();
|
|
291
|
-
return e === void 0 ?
|
|
292
|
-
const n = i
|
|
293
|
-
Array.isArray(n) && Array.isArray(
|
|
294
|
-
}),
|
|
288
|
+
return e === void 0 ? s : (z(s) && z(e) && Object.keys(e).forEach((i) => {
|
|
289
|
+
const n = s[i], o = e[i];
|
|
290
|
+
Array.isArray(n) && Array.isArray(o) ? s[i] = [...n, ...o] : z(n) && z(o) ? s[i] = R({ ...n }, o) : o !== void 0 && (s[i] = o);
|
|
291
|
+
}), R(s, ...t));
|
|
295
292
|
}
|
|
296
|
-
function
|
|
297
|
-
return
|
|
293
|
+
function z(s) {
|
|
294
|
+
return s !== null && typeof s == "object" && !Array.isArray(s);
|
|
298
295
|
}
|
|
299
|
-
function
|
|
300
|
-
if (!t.length) return
|
|
296
|
+
function V(s, ...t) {
|
|
297
|
+
if (!t.length) return s;
|
|
301
298
|
for (const e of t)
|
|
302
|
-
e != null && typeof e == "object" && Object.keys(e).forEach((
|
|
303
|
-
const n = e[
|
|
304
|
-
n !== null && typeof n == "object" && !Array.isArray(n) ? ((!
|
|
299
|
+
e != null && typeof e == "object" && Object.keys(e).forEach((i) => {
|
|
300
|
+
const n = e[i], o = s[i];
|
|
301
|
+
n !== null && typeof n == "object" && !Array.isArray(n) ? ((!o || typeof o != "object") && (s[i] = {}), V(s[i], n)) : s[i] = n;
|
|
305
302
|
});
|
|
306
|
-
return
|
|
303
|
+
return s;
|
|
307
304
|
}
|
|
308
|
-
function
|
|
309
|
-
return new Promise((e,
|
|
310
|
-
const n =
|
|
311
|
-
if (
|
|
305
|
+
function St(s, t = {}) {
|
|
306
|
+
return new Promise((e, i) => {
|
|
307
|
+
const n = L(s);
|
|
308
|
+
if (Tt(n)) {
|
|
312
309
|
e(!0);
|
|
313
310
|
return;
|
|
314
311
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}),
|
|
312
|
+
const o = document.createElement("script");
|
|
313
|
+
o.src = s, Object.entries(t).forEach(([r, a]) => {
|
|
314
|
+
a !== !1 && o.setAttribute(r, a === !0 ? "" : String(a));
|
|
315
|
+
}), o.onload = () => {
|
|
319
316
|
e(!0);
|
|
320
|
-
},
|
|
321
|
-
document.head.removeChild(
|
|
322
|
-
}, document.head.appendChild(
|
|
317
|
+
}, o.onerror = () => {
|
|
318
|
+
document.head.removeChild(o), i(new Error(`Failed to load script: ${s}`));
|
|
319
|
+
}, document.head.appendChild(o);
|
|
323
320
|
});
|
|
324
321
|
}
|
|
325
|
-
function
|
|
326
|
-
const t =
|
|
327
|
-
return Array.from(document.scripts).some((e) =>
|
|
322
|
+
function Tt(s) {
|
|
323
|
+
const t = L(s);
|
|
324
|
+
return Array.from(document.scripts).some((e) => L(e.src) === t);
|
|
328
325
|
}
|
|
329
|
-
function
|
|
326
|
+
function L(s) {
|
|
330
327
|
try {
|
|
331
|
-
const t = new URL(
|
|
328
|
+
const t = new URL(s, window.location.href);
|
|
332
329
|
return `${t.origin}${t.pathname}`;
|
|
333
330
|
} catch {
|
|
334
|
-
return
|
|
331
|
+
return s;
|
|
335
332
|
}
|
|
336
333
|
}
|
|
337
|
-
function
|
|
338
|
-
const n = Math.min(
|
|
334
|
+
function Pt(s, t, e, i) {
|
|
335
|
+
const n = Math.min(s / e, t / i), o = e * n, r = i * n;
|
|
339
336
|
return {
|
|
340
337
|
scale: n,
|
|
341
|
-
x: (
|
|
338
|
+
x: (s - o) / 2,
|
|
342
339
|
// 居中计算的X起点
|
|
343
|
-
y: (t -
|
|
340
|
+
y: (t - r) / 2,
|
|
344
341
|
// 居中计算的Y起点
|
|
345
|
-
sw:
|
|
346
|
-
sh:
|
|
342
|
+
sw: o,
|
|
343
|
+
sh: r
|
|
347
344
|
};
|
|
348
345
|
}
|
|
349
|
-
function
|
|
346
|
+
function Et(s, t, e) {
|
|
350
347
|
return {
|
|
351
|
-
x:
|
|
348
|
+
x: s * e.scale + e.x,
|
|
352
349
|
// 缩放后加上偏移量
|
|
353
350
|
y: t * e.scale + e.y
|
|
354
351
|
};
|
|
355
352
|
}
|
|
356
|
-
function
|
|
353
|
+
function Nt(s, t, e) {
|
|
357
354
|
return {
|
|
358
|
-
x: (
|
|
355
|
+
x: (s - e.x) / e.scale,
|
|
359
356
|
// 减去偏移量后缩放到模型尺寸
|
|
360
357
|
y: (t - e.y) / e.scale
|
|
361
358
|
};
|
|
362
359
|
}
|
|
363
|
-
function
|
|
364
|
-
console.warn(`[warn]:${
|
|
360
|
+
function zt(s) {
|
|
361
|
+
console.warn(`[warn]:${s}`);
|
|
365
362
|
}
|
|
366
|
-
function
|
|
367
|
-
throw new Error(`[error]:${
|
|
363
|
+
function Dt(s) {
|
|
364
|
+
throw new Error(`[error]:${s}`);
|
|
368
365
|
}
|
|
369
|
-
const
|
|
366
|
+
const Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
370
367
|
__proto__: null,
|
|
371
|
-
cloneDeep:
|
|
372
|
-
debounce:
|
|
373
|
-
deepMerge:
|
|
374
|
-
deepMergeProps:
|
|
375
|
-
error:
|
|
376
|
-
getImageTransform:
|
|
377
|
-
inBrowser:
|
|
368
|
+
cloneDeep: H,
|
|
369
|
+
debounce: vt,
|
|
370
|
+
deepMerge: R,
|
|
371
|
+
deepMergeProps: V,
|
|
372
|
+
error: Dt,
|
|
373
|
+
getImageTransform: Pt,
|
|
374
|
+
inBrowser: ct,
|
|
378
375
|
is: v,
|
|
379
|
-
isArray:
|
|
380
|
-
isBoolean:
|
|
381
|
-
isDate:
|
|
382
|
-
isDef:
|
|
383
|
-
isElement:
|
|
384
|
-
isFunction:
|
|
385
|
-
isNull:
|
|
386
|
-
isNullOrUnDef:
|
|
387
|
-
isNumber:
|
|
388
|
-
isNumeric:
|
|
389
|
-
isObject:
|
|
390
|
-
isPromise:
|
|
391
|
-
isRegExp:
|
|
392
|
-
isSameValue:
|
|
393
|
-
isString:
|
|
394
|
-
isUnDef:
|
|
395
|
-
isWindow:
|
|
396
|
-
loadScript:
|
|
397
|
-
throttle:
|
|
398
|
-
toCanvasCoord:
|
|
399
|
-
toModelCoord:
|
|
400
|
-
warn:
|
|
376
|
+
isArray: S,
|
|
377
|
+
isBoolean: ft,
|
|
378
|
+
isDate: ut,
|
|
379
|
+
isDef: Z,
|
|
380
|
+
isElement: wt,
|
|
381
|
+
isFunction: O,
|
|
382
|
+
isNull: J,
|
|
383
|
+
isNullOrUnDef: xt,
|
|
384
|
+
isNumber: E,
|
|
385
|
+
isNumeric: pt,
|
|
386
|
+
isObject: j,
|
|
387
|
+
isPromise: Mt,
|
|
388
|
+
isRegExp: mt,
|
|
389
|
+
isSameValue: gt,
|
|
390
|
+
isString: dt,
|
|
391
|
+
isUnDef: q,
|
|
392
|
+
isWindow: yt,
|
|
393
|
+
loadScript: St,
|
|
394
|
+
throttle: bt,
|
|
395
|
+
toCanvasCoord: Et,
|
|
396
|
+
toModelCoord: Nt,
|
|
397
|
+
warn: zt
|
|
401
398
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
402
|
-
class
|
|
399
|
+
class f {
|
|
400
|
+
// 直角坐标系坐标
|
|
401
|
+
x = 0;
|
|
402
|
+
y = 0;
|
|
403
|
+
z = 0;
|
|
404
|
+
// 地理坐标系坐标
|
|
405
|
+
lat = 0;
|
|
406
|
+
// 经度 (longitude)
|
|
407
|
+
lon = 0;
|
|
408
|
+
// 纬度 (latitude)
|
|
409
|
+
alt = 0;
|
|
410
|
+
// 高度 (altitude)
|
|
411
|
+
// 欧拉角
|
|
412
|
+
yaw = 0;
|
|
413
|
+
// 偏航角
|
|
414
|
+
pitch = 0;
|
|
415
|
+
// 俯仰角
|
|
416
|
+
roll = 0;
|
|
417
|
+
// 翻滚角
|
|
418
|
+
// 状态标志
|
|
419
|
+
hasXYZ = !1;
|
|
420
|
+
// 是否有直角坐标
|
|
421
|
+
hasGeo = !1;
|
|
422
|
+
// 是否有地理坐标
|
|
423
|
+
hasAngle = !1;
|
|
424
|
+
// 是否有角度信息
|
|
425
|
+
plane = "xy";
|
|
403
426
|
// 默认平面 ('xy' 或 'xz')
|
|
404
427
|
constructor(t) {
|
|
405
|
-
|
|
406
|
-
o(this,
|
|
407
|
-
o(this, "y", 0);
|
|
408
|
-
o(this, "z", 0);
|
|
409
|
-
// 地理坐标系坐标
|
|
410
|
-
o(this, "lat", 0);
|
|
411
|
-
// 经度 (longitude)
|
|
412
|
-
o(this, "lon", 0);
|
|
413
|
-
// 纬度 (latitude)
|
|
414
|
-
o(this, "alt", 0);
|
|
415
|
-
// 高度 (altitude)
|
|
416
|
-
// 欧拉角
|
|
417
|
-
o(this, "yaw", 0);
|
|
418
|
-
// 偏航角
|
|
419
|
-
o(this, "pitch", 0);
|
|
420
|
-
// 俯仰角
|
|
421
|
-
o(this, "roll", 0);
|
|
422
|
-
// 翻滚角
|
|
423
|
-
// 状态标志
|
|
424
|
-
o(this, "hasXYZ", !1);
|
|
425
|
-
// 是否有直角坐标
|
|
426
|
-
o(this, "hasGeo", !1);
|
|
427
|
-
// 是否有地理坐标
|
|
428
|
-
o(this, "hasAngle", !1);
|
|
429
|
-
// 是否有角度信息
|
|
430
|
-
o(this, "plane", "xy");
|
|
431
|
-
const { x: e, y: s, z: n, lat: r, lon: a, alt: h, yaw: c, pitch: u, roll: f, plane: l = "xy" } = t || {};
|
|
432
|
-
z(e) && z(s) && (this.x = Number(e) || 0, this.y = Number(s) || 0, this.z = Number(n) || 0, this.plane = l, this.hasXYZ = !0), z(r) && z(a) && Number(r) !== 0 && Number(a) !== 0 && (this.lat = Number(r) || 0, this.lon = Number(a) || 0, this.alt = Number(h) || 0, this.hasGeo = !0), (c !== void 0 || u !== void 0 || f !== void 0) && (this.yaw = Number(c) || 0, this.pitch = Number(u) || 0, this.roll = Number(f) || 0, this.hasAngle = !0);
|
|
428
|
+
const { x: e, y: i, z: n, lat: o, lon: r, alt: a, yaw: h, pitch: l, roll: c, plane: u = "xy" } = t || {};
|
|
429
|
+
E(e) && E(i) && (this.x = Number(e) || 0, this.y = Number(i) || 0, this.z = Number(n) || 0, this.plane = u, 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), (h !== void 0 || l !== void 0 || c !== void 0) && (this.yaw = Number(h) || 0, this.pitch = Number(l) || 0, this.roll = Number(c) || 0, this.hasAngle = !0);
|
|
433
430
|
}
|
|
434
431
|
/**
|
|
435
432
|
* 计算两点之间的三维距离
|
|
@@ -481,9 +478,9 @@ class m {
|
|
|
481
478
|
* @param pc 点C
|
|
482
479
|
* @returns 夹角角度 (0-180度)
|
|
483
480
|
*/
|
|
484
|
-
static angleXZ(t, e,
|
|
485
|
-
const n = { x: t.x - e.x, z: t.z - e.z },
|
|
486
|
-
return Math.min(
|
|
481
|
+
static angleXZ(t, e, i) {
|
|
482
|
+
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), l = Math.max(-1, Math.min(1, r / (a * h))), u = Math.acos(l) * 180 / Math.PI;
|
|
483
|
+
return Math.min(u, 360 - u);
|
|
487
484
|
}
|
|
488
485
|
/**
|
|
489
486
|
* 从字符串解析点坐标 ("x,y,z")
|
|
@@ -492,8 +489,8 @@ class m {
|
|
|
492
489
|
*/
|
|
493
490
|
static toParse(t) {
|
|
494
491
|
if (t) {
|
|
495
|
-
const e = t
|
|
496
|
-
return new
|
|
492
|
+
const e = t?.split(",").map((i) => Number(i) || 0);
|
|
493
|
+
return new f({ x: e[0], y: e[1], z: e[2] });
|
|
497
494
|
}
|
|
498
495
|
}
|
|
499
496
|
/**
|
|
@@ -512,25 +509,25 @@ class m {
|
|
|
512
509
|
* @returns 转换后的点
|
|
513
510
|
* @throws AppError 当转换失败时抛出异常
|
|
514
511
|
*/
|
|
515
|
-
projection(t, e,
|
|
512
|
+
projection(t, e, i) {
|
|
516
513
|
try {
|
|
517
|
-
if (
|
|
518
|
-
return new
|
|
519
|
-
if (
|
|
520
|
-
const { refPoint: n } =
|
|
514
|
+
if (e?.id === i?.id)
|
|
515
|
+
return new f(this);
|
|
516
|
+
if (e?.modelType === P.SkyMapModel) {
|
|
517
|
+
const { refPoint: n } = e?.relativeMap || {};
|
|
521
518
|
if (this.hasGeo && n) {
|
|
522
|
-
const
|
|
523
|
-
return this.x =
|
|
519
|
+
const o = N.LLHToXYZ(this, n);
|
|
520
|
+
return this.x = o.x, this.y = o.y, this.z = o.z, this.hasXYZ = !0, this.project(t);
|
|
524
521
|
}
|
|
525
|
-
throw new y
|
|
522
|
+
throw new m(y.PointUnmappedGIS, "没有完成GIS与其他空间的映射");
|
|
526
523
|
}
|
|
527
|
-
if (
|
|
528
|
-
const { refPoint: n } =
|
|
529
|
-
if (
|
|
530
|
-
const
|
|
531
|
-
return
|
|
524
|
+
if (i?.modelType === P.SkyMapModel) {
|
|
525
|
+
const { refPoint: n } = i?.relativeMap || {}, o = this.project(t);
|
|
526
|
+
if (o?.hasXYZ && n) {
|
|
527
|
+
const r = N.XYZToLLH(o, n);
|
|
528
|
+
return o.lat = r.lat, o.lon = r.lon, o.alt = r.alt, o.hasGeo = !0, o;
|
|
532
529
|
}
|
|
533
|
-
throw new y
|
|
530
|
+
throw new m(y.PointUnmappedGIS, "没有完成GIS与其他空间的映射");
|
|
534
531
|
}
|
|
535
532
|
return this.project(t);
|
|
536
533
|
} catch {
|
|
@@ -545,12 +542,12 @@ class m {
|
|
|
545
542
|
*/
|
|
546
543
|
project(t) {
|
|
547
544
|
if (!this.hasXYZ)
|
|
548
|
-
throw new y
|
|
545
|
+
throw new m(y.PointNoXYZ, "点没有xxz坐标信息");
|
|
549
546
|
if (this.plane === "xz")
|
|
550
547
|
return this.projectXZ(t);
|
|
551
548
|
if (this.plane === "xy")
|
|
552
549
|
return this.projectXY(t);
|
|
553
|
-
throw new y
|
|
550
|
+
throw new m(y.PointNoPlane, "点的plane应为xz或xy");
|
|
554
551
|
}
|
|
555
552
|
/**
|
|
556
553
|
* XZ平面投影转换
|
|
@@ -558,10 +555,10 @@ class m {
|
|
|
558
555
|
* @returns 转换后的点
|
|
559
556
|
*/
|
|
560
557
|
projectXZ(t) {
|
|
561
|
-
const e = new
|
|
558
|
+
const e = new f(this);
|
|
562
559
|
e.x *= t.scale, e.y *= t.scale, e.z *= t.scale, e.yaw !== void 0 && (e.yaw += t.yaw);
|
|
563
|
-
const
|
|
564
|
-
return e.x =
|
|
560
|
+
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);
|
|
561
|
+
return e.x = i + t.x, e.y += t.y, e.z = n + t.z, e;
|
|
565
562
|
}
|
|
566
563
|
/**
|
|
567
564
|
* XY平面投影转换
|
|
@@ -569,73 +566,73 @@ class m {
|
|
|
569
566
|
* @returns 转换后的点
|
|
570
567
|
*/
|
|
571
568
|
projectXY(t) {
|
|
572
|
-
const e = new
|
|
569
|
+
const e = new f(this);
|
|
573
570
|
e.x *= t.scale, e.y *= t.scale, e.z *= t.scale, e.yaw !== void 0 && (e.yaw += t.yaw);
|
|
574
|
-
const
|
|
575
|
-
return e.x =
|
|
571
|
+
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);
|
|
572
|
+
return e.x = i + t.x, e.y = n + t.y, e.z += t.z, e;
|
|
576
573
|
}
|
|
577
574
|
}
|
|
578
|
-
class
|
|
575
|
+
class N {
|
|
576
|
+
lat = 0;
|
|
577
|
+
//经度
|
|
578
|
+
lon = 0;
|
|
579
|
+
//纬度
|
|
580
|
+
alt = 0;
|
|
579
581
|
//高度
|
|
580
582
|
constructor(t) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
o(this, "lon", 0);
|
|
584
|
-
//纬度
|
|
585
|
-
o(this, "alt", 0);
|
|
586
|
-
const { lat: e = 0, lon: s = 0, alt: n = 0 } = t || {};
|
|
587
|
-
this.lat = e, this.lon = s, this.alt = n;
|
|
583
|
+
const { lat: e = 0, lon: i = 0, alt: n = 0 } = t || {};
|
|
584
|
+
this.lat = e, this.lon = i, this.alt = n;
|
|
588
585
|
}
|
|
589
586
|
static XYZToLLH(t, e) {
|
|
590
|
-
const n = 0.0033528106647474805,
|
|
591
|
-
let
|
|
587
|
+
const n = 0.0033528106647474805, o = n * (2 - n), r = f.toRadians(e.lat), a = 6378137 / Math.sqrt(1 - o * Math.sin(r) ** 2) + e.alt;
|
|
588
|
+
let h, l, c;
|
|
592
589
|
if (t.plane === "xz") {
|
|
593
|
-
const
|
|
594
|
-
|
|
590
|
+
const u = t.x / 1e3 / (a * Math.cos(r)), d = t.z / 1e3 / a;
|
|
591
|
+
h = e.lon + f.toDegrees(u), l = e.lat - f.toDegrees(d), c = e.alt + t.y / 1e3;
|
|
595
592
|
} else if (t.plane === "xy") {
|
|
596
|
-
const
|
|
597
|
-
|
|
593
|
+
const u = t.x / 1e3 / (a * Math.cos(r)), d = t.y / 1e3 / a;
|
|
594
|
+
h = e.lon + f.toDegrees(u), l = e.lat - f.toDegrees(d), c = e.alt + t.z / 1e3;
|
|
598
595
|
} else
|
|
599
|
-
throw new y
|
|
600
|
-
return new
|
|
601
|
-
lat:
|
|
602
|
-
lon:
|
|
603
|
-
alt:
|
|
596
|
+
throw new m(y.GeoPointNoPlane, "点的plane应为xz或xy");
|
|
597
|
+
return new N({
|
|
598
|
+
lat: l,
|
|
599
|
+
lon: h,
|
|
600
|
+
alt: c
|
|
604
601
|
});
|
|
605
602
|
}
|
|
606
603
|
static LLHToXYZ(t, e) {
|
|
607
|
-
const n = 0.0033528106647474805,
|
|
604
|
+
const n = 0.0033528106647474805, o = n * (2 - n), r = f.toRadians(e.lat), a = 6378137 / Math.sqrt(1 - o * Math.sin(r) ** 2) + e.alt, h = f.toRadians(t.lon - e.lon), l = f.toRadians(e.lat - t.lat), c = a * h * Math.cos(r), u = a * l;
|
|
608
605
|
if (t.plane === "xz")
|
|
609
|
-
return new
|
|
610
|
-
x:
|
|
606
|
+
return new f({
|
|
607
|
+
x: c * 1e3,
|
|
611
608
|
y: (t.alt - e.alt) * 1e3,
|
|
612
|
-
z:
|
|
609
|
+
z: u * 1e3,
|
|
613
610
|
plane: "xz"
|
|
614
611
|
});
|
|
615
612
|
if (t.plane === "xy")
|
|
616
|
-
return new
|
|
617
|
-
x:
|
|
618
|
-
y:
|
|
613
|
+
return new f({
|
|
614
|
+
x: c * 1e3,
|
|
615
|
+
y: u * 1e3,
|
|
619
616
|
z: (t.alt - e.alt) * 1e3,
|
|
620
617
|
plane: "xy"
|
|
621
618
|
});
|
|
622
|
-
throw new y
|
|
619
|
+
throw new m(y.GeoPointNoPlane, "点的plane应为xz或xy");
|
|
623
620
|
}
|
|
624
621
|
}
|
|
625
|
-
class
|
|
622
|
+
class g {
|
|
623
|
+
scale = 1;
|
|
624
|
+
yaw = 0;
|
|
625
|
+
x = 0;
|
|
626
|
+
y = 0;
|
|
627
|
+
z = 0;
|
|
628
|
+
start = 0;
|
|
629
|
+
end = -1;
|
|
630
|
+
plane = "xy";
|
|
631
|
+
refPoint;
|
|
626
632
|
//参考点
|
|
627
633
|
constructor(t) {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
o(this, "x", 0);
|
|
631
|
-
o(this, "y", 0);
|
|
632
|
-
o(this, "z", 0);
|
|
633
|
-
o(this, "start", 0);
|
|
634
|
-
o(this, "end", -1);
|
|
635
|
-
o(this, "plane", "xy");
|
|
636
|
-
o(this, "refPoint");
|
|
637
|
-
const { refPoint: e, ...s } = t || {};
|
|
638
|
-
e && (this.refPoint = new D(e)), Object.assign(this, s);
|
|
634
|
+
const { refPoint: e, ...i } = t || {};
|
|
635
|
+
e && (this.refPoint = new N(e)), Object.assign(this, i);
|
|
639
636
|
}
|
|
640
637
|
/**
|
|
641
638
|
* 合并两个相对坐标系的映射关系
|
|
@@ -645,23 +642,23 @@ class p {
|
|
|
645
642
|
*/
|
|
646
643
|
static addRelativeMap(t, e) {
|
|
647
644
|
if (t.plane !== e.plane)
|
|
648
|
-
throw new y
|
|
649
|
-
const
|
|
650
|
-
let
|
|
645
|
+
throw new m(y.RelativePlaneUnmatch, "两个映射关系的plane应该相同");
|
|
646
|
+
const i = t.scale * e.scale, n = t.yaw + e.yaw, o = Math.cos(e.yaw), r = Math.sin(e.yaw);
|
|
647
|
+
let a = 0, h = 0, l = 0;
|
|
651
648
|
if (t.plane === "xz") {
|
|
652
|
-
const
|
|
653
|
-
|
|
649
|
+
const c = t.x * o - t.z * r, u = t.y, d = t.x * r + t.z * o;
|
|
650
|
+
a = e.x + c * e.scale, h = e.y + u * e.scale, l = e.z + d * e.scale;
|
|
654
651
|
} else if (t.plane === "xy") {
|
|
655
|
-
const
|
|
656
|
-
|
|
652
|
+
const c = t.x * o - t.y * r, u = t.x * r + t.y * o, d = t.z;
|
|
653
|
+
a = e.x + c * e.scale, h = e.y + u * e.scale, l = e.z + d * e.scale;
|
|
657
654
|
} else
|
|
658
|
-
throw new y
|
|
659
|
-
return new
|
|
660
|
-
scale:
|
|
655
|
+
throw new m(y.RelativeNoPlane, "映射关系的plane应为xz或xy");
|
|
656
|
+
return new g({
|
|
657
|
+
scale: i,
|
|
661
658
|
yaw: n,
|
|
662
|
-
x:
|
|
663
|
-
y:
|
|
664
|
-
z:
|
|
659
|
+
x: a,
|
|
660
|
+
y: h,
|
|
661
|
+
z: l,
|
|
665
662
|
start: t.start,
|
|
666
663
|
end: t.end,
|
|
667
664
|
plane: t.plane
|
|
@@ -673,20 +670,20 @@ class p {
|
|
|
673
670
|
* @returns 逆映射
|
|
674
671
|
*/
|
|
675
672
|
static inverseRelativeMap(t) {
|
|
676
|
-
const e = 1 / t.scale,
|
|
677
|
-
let
|
|
673
|
+
const e = 1 / t.scale, i = -t.yaw, n = Math.cos(-i), o = Math.sin(-i);
|
|
674
|
+
let r = 0, a = 0, h = 0;
|
|
678
675
|
if (t.plane === "xz")
|
|
679
|
-
|
|
676
|
+
r = -(t.x * n + t.z * o) * e, a = -t.y * e, h = -(t.z * n - t.x * o) * e;
|
|
680
677
|
else if (t.plane === "xy")
|
|
681
|
-
|
|
678
|
+
r = -(t.x * n + t.y * o) * e, a = -(t.y * n - t.x * o) * e, h = -t.z * e;
|
|
682
679
|
else
|
|
683
|
-
throw new y
|
|
684
|
-
return new
|
|
680
|
+
throw new m(y.RelativeNoPlane, "映射关系的plane应为xz或xy");
|
|
681
|
+
return new g({
|
|
685
682
|
scale: e,
|
|
686
|
-
yaw:
|
|
687
|
-
x:
|
|
688
|
-
y:
|
|
689
|
-
z:
|
|
683
|
+
yaw: i,
|
|
684
|
+
x: r,
|
|
685
|
+
y: a,
|
|
686
|
+
z: h,
|
|
690
687
|
start: t.start,
|
|
691
688
|
end: t.end,
|
|
692
689
|
plane: t.plane
|
|
@@ -695,27 +692,27 @@ class p {
|
|
|
695
692
|
static toParse(t) {
|
|
696
693
|
try {
|
|
697
694
|
let e = t ? JSON.parse(t) : void 0;
|
|
698
|
-
const { reference_point:
|
|
699
|
-
return
|
|
695
|
+
const { reference_point: i } = e || {};
|
|
696
|
+
return i && (e = { refPoint: i }), e ? new g(e) : void 0;
|
|
700
697
|
} catch {
|
|
701
|
-
throw new y
|
|
698
|
+
throw new m(y.RelativeJsonError, "relativeMap格式化失败");
|
|
702
699
|
}
|
|
703
700
|
}
|
|
704
701
|
static toStringify(t) {
|
|
705
702
|
return t ? JSON.stringify(t) : void 0;
|
|
706
703
|
}
|
|
707
704
|
}
|
|
708
|
-
class
|
|
705
|
+
class w {
|
|
709
706
|
/**
|
|
710
707
|
* 获取坐标系树
|
|
711
708
|
* @param projectId 项目id
|
|
712
709
|
* @returns
|
|
713
710
|
*/
|
|
714
711
|
static async getCoordinateTree(t) {
|
|
715
|
-
const e = await
|
|
712
|
+
const e = await Y({ projectId: t });
|
|
716
713
|
if (e.length) {
|
|
717
|
-
const
|
|
718
|
-
return
|
|
714
|
+
const i = w.handleCoordinateList(e);
|
|
715
|
+
return w.buildCoordinateTree(i, 0);
|
|
719
716
|
}
|
|
720
717
|
}
|
|
721
718
|
/**
|
|
@@ -725,18 +722,18 @@ class g {
|
|
|
725
722
|
* @returns
|
|
726
723
|
*/
|
|
727
724
|
static async addCoordinate(t, e) {
|
|
728
|
-
const { projectId:
|
|
729
|
-
const { type:
|
|
725
|
+
const { projectId: i, id: n } = t, o = e.map((a) => {
|
|
726
|
+
const { type: h, modelType: l, relativeMap: c, level: u, ...d } = a, p = c ? JSON.stringify(c) : void 0;
|
|
730
727
|
return {
|
|
731
728
|
...d,
|
|
732
|
-
projectId:
|
|
729
|
+
projectId: i,
|
|
733
730
|
parentId: n,
|
|
734
|
-
coordinateType:
|
|
735
|
-
renderType:
|
|
736
|
-
relativePosition:
|
|
731
|
+
coordinateType: h,
|
|
732
|
+
renderType: l,
|
|
733
|
+
relativePosition: p
|
|
737
734
|
};
|
|
738
|
-
}),
|
|
739
|
-
return
|
|
735
|
+
}), r = await C(o);
|
|
736
|
+
return w.handleCoordinateList(r);
|
|
740
737
|
}
|
|
741
738
|
/**
|
|
742
739
|
* 删除坐标系
|
|
@@ -745,8 +742,8 @@ class g {
|
|
|
745
742
|
* @returns
|
|
746
743
|
*/
|
|
747
744
|
static async removeCoordinate(t, e) {
|
|
748
|
-
const
|
|
749
|
-
return await
|
|
745
|
+
const i = e.map((n) => n.id ?? -1);
|
|
746
|
+
return await G(i);
|
|
750
747
|
}
|
|
751
748
|
/**
|
|
752
749
|
* 更新坐标系
|
|
@@ -755,11 +752,11 @@ class g {
|
|
|
755
752
|
* @returns
|
|
756
753
|
*/
|
|
757
754
|
static async updateCoordinate(t, e) {
|
|
758
|
-
const { projectId:
|
|
759
|
-
const { type:
|
|
760
|
-
return { ...
|
|
761
|
-
}),
|
|
762
|
-
return
|
|
755
|
+
const { projectId: i, id: n } = t, o = e.map((a) => {
|
|
756
|
+
const { type: h, relativeMap: l, level: c, ...u } = a, d = g.toStringify(l);
|
|
757
|
+
return { ...u, relativePosition: d, projectId: i, parentId: n };
|
|
758
|
+
}), r = await C(o);
|
|
759
|
+
return w.handleCoordinateList(r);
|
|
763
760
|
}
|
|
764
761
|
/**
|
|
765
762
|
* 绑定坐标系
|
|
@@ -768,11 +765,11 @@ class g {
|
|
|
768
765
|
* @returns
|
|
769
766
|
*/
|
|
770
767
|
static async bindCoordinate(t, e) {
|
|
771
|
-
const { projectId:
|
|
772
|
-
const { modelId:
|
|
773
|
-
return { modelId:
|
|
774
|
-
}),
|
|
775
|
-
return
|
|
768
|
+
const { projectId: i, id: n } = t, o = e.map((a) => {
|
|
769
|
+
const { modelId: h } = a;
|
|
770
|
+
return { modelId: h, parentId: n, projectId: i };
|
|
771
|
+
}), r = await B(o);
|
|
772
|
+
return w.handleCoordinateList(r);
|
|
776
773
|
}
|
|
777
774
|
/**
|
|
778
775
|
* 处理坐标系数据
|
|
@@ -780,20 +777,20 @@ class g {
|
|
|
780
777
|
* @returns 处理后的坐标系数据
|
|
781
778
|
*/
|
|
782
779
|
static handleCoordinateList(t) {
|
|
783
|
-
return t
|
|
780
|
+
return t?.map((e) => {
|
|
784
781
|
const {
|
|
785
|
-
coordinateType:
|
|
782
|
+
coordinateType: i,
|
|
786
783
|
modelKey: n,
|
|
787
|
-
renderType:
|
|
788
|
-
relativePosition:
|
|
789
|
-
...
|
|
790
|
-
} = e,
|
|
791
|
-
return new
|
|
792
|
-
...
|
|
793
|
-
type:
|
|
794
|
-
modelType:
|
|
784
|
+
renderType: o,
|
|
785
|
+
relativePosition: r,
|
|
786
|
+
...a
|
|
787
|
+
} = e, h = g.toParse(r);
|
|
788
|
+
return new It({
|
|
789
|
+
...a,
|
|
790
|
+
type: i,
|
|
791
|
+
modelType: o,
|
|
795
792
|
modelValue: n,
|
|
796
|
-
relativeMap:
|
|
793
|
+
relativeMap: h
|
|
797
794
|
});
|
|
798
795
|
});
|
|
799
796
|
}
|
|
@@ -804,20 +801,19 @@ class g {
|
|
|
804
801
|
* @returns
|
|
805
802
|
*/
|
|
806
803
|
static buildCoordinateTree(t, e) {
|
|
807
|
-
const
|
|
808
|
-
return t.forEach((
|
|
809
|
-
|
|
810
|
-
}), t.forEach((
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
a.level = 0, n.push(a);
|
|
804
|
+
const i = /* @__PURE__ */ new Map(), n = [];
|
|
805
|
+
return t.forEach((o) => {
|
|
806
|
+
i.set(String(o.id), o);
|
|
807
|
+
}), t.forEach((o) => {
|
|
808
|
+
const r = i.get(String(o.id));
|
|
809
|
+
if (r)
|
|
810
|
+
if (o.parentId === e)
|
|
811
|
+
r.level = 0, n.push(r);
|
|
816
812
|
else {
|
|
817
|
-
const
|
|
818
|
-
|
|
813
|
+
const a = i.get(String(o.parentId ?? -1));
|
|
814
|
+
a && (r.level = (Number(a.level) || 0) + 1, r.parent = a, a.children?.push(r));
|
|
819
815
|
}
|
|
820
|
-
}), n.forEach(
|
|
816
|
+
}), n.forEach(w.sortCoordinateTree), n[0];
|
|
821
817
|
}
|
|
822
818
|
/**
|
|
823
819
|
* 对子节点进行排序,首先按 status=0 升序,然后按 type=0 升序,最后按 createTime 降序
|
|
@@ -825,14 +821,13 @@ class g {
|
|
|
825
821
|
* @returns 无返回值
|
|
826
822
|
*/
|
|
827
823
|
static sortCoordinateTree(t) {
|
|
828
|
-
t.children && (t.children.sort((e,
|
|
829
|
-
var n, r;
|
|
824
|
+
t.children && (t.children.sort((e, i) => {
|
|
830
825
|
if (e.type === M.Space) {
|
|
831
|
-
const
|
|
832
|
-
return
|
|
826
|
+
const n = Number(i?.relativeMap?.z) - Number(e?.relativeMap?.z);
|
|
827
|
+
return n !== 0 ? n : Number(i.createTime) - Number(e.createTime);
|
|
833
828
|
} else
|
|
834
|
-
return e.status === 0 &&
|
|
835
|
-
}), t.children.forEach(
|
|
829
|
+
return e.status === 0 && i.status !== 0 ? -1 : i.status === 0 && e.status !== 0 ? 1 : Number(i.createTime) - Number(e.createTime);
|
|
830
|
+
}), t.children.forEach(w.sortCoordinateTree));
|
|
836
831
|
}
|
|
837
832
|
/**
|
|
838
833
|
* 过滤空间坐标系树
|
|
@@ -840,51 +835,51 @@ class g {
|
|
|
840
835
|
*/
|
|
841
836
|
static filterSpaceTree(t) {
|
|
842
837
|
const e = [];
|
|
843
|
-
return t.forEach((
|
|
844
|
-
const n =
|
|
845
|
-
|
|
838
|
+
return t.forEach((i) => {
|
|
839
|
+
const n = w.filterSpaceTree(i.children);
|
|
840
|
+
i.children = n, i.disabled = i.disabled ?? !1, i.type !== M.Model && e.push(i);
|
|
846
841
|
}), e;
|
|
847
842
|
}
|
|
848
843
|
}
|
|
849
|
-
class
|
|
844
|
+
class It {
|
|
845
|
+
id = 0;
|
|
846
|
+
//id
|
|
847
|
+
type = 0;
|
|
848
|
+
//0空间,1模型
|
|
849
|
+
children = [];
|
|
850
|
+
//子节点
|
|
851
|
+
level;
|
|
852
|
+
//空间的层级
|
|
853
|
+
relativeMap;
|
|
854
|
+
//相对位置关系
|
|
855
|
+
no;
|
|
856
|
+
//坐标系编号
|
|
857
|
+
name;
|
|
858
|
+
//名称
|
|
859
|
+
shortName;
|
|
860
|
+
//简称
|
|
861
|
+
status;
|
|
862
|
+
//使用状态
|
|
863
|
+
modelId;
|
|
864
|
+
// 模型ID
|
|
865
|
+
modelType;
|
|
866
|
+
//模型的类型
|
|
867
|
+
modelValue;
|
|
868
|
+
// 模型value
|
|
869
|
+
projectId;
|
|
870
|
+
//项目id
|
|
871
|
+
parentId;
|
|
872
|
+
//父节点id
|
|
873
|
+
parent;
|
|
874
|
+
//父节点
|
|
875
|
+
groupUuid;
|
|
876
|
+
//分组uuid
|
|
877
|
+
z;
|
|
878
|
+
//坐标系高度
|
|
879
|
+
createTime;
|
|
880
|
+
// 创建时间
|
|
881
|
+
disabled;
|
|
850
882
|
constructor(t) {
|
|
851
|
-
o(this, "id", 0);
|
|
852
|
-
//id
|
|
853
|
-
o(this, "type", 0);
|
|
854
|
-
//0空间,1模型
|
|
855
|
-
o(this, "children", []);
|
|
856
|
-
//子节点
|
|
857
|
-
o(this, "level");
|
|
858
|
-
//空间的层级
|
|
859
|
-
o(this, "relativeMap");
|
|
860
|
-
//相对位置关系
|
|
861
|
-
o(this, "no");
|
|
862
|
-
//坐标系编号
|
|
863
|
-
o(this, "name");
|
|
864
|
-
//名称
|
|
865
|
-
o(this, "shortName");
|
|
866
|
-
//简称
|
|
867
|
-
o(this, "status");
|
|
868
|
-
//使用状态
|
|
869
|
-
o(this, "modelId");
|
|
870
|
-
// 模型ID
|
|
871
|
-
o(this, "modelType");
|
|
872
|
-
//模型的类型
|
|
873
|
-
o(this, "modelValue");
|
|
874
|
-
// 模型value
|
|
875
|
-
o(this, "projectId");
|
|
876
|
-
//项目id
|
|
877
|
-
o(this, "parentId");
|
|
878
|
-
//父节点id
|
|
879
|
-
o(this, "parent");
|
|
880
|
-
//父节点
|
|
881
|
-
o(this, "groupUuid");
|
|
882
|
-
//分组uuid
|
|
883
|
-
o(this, "z");
|
|
884
|
-
//坐标系高度
|
|
885
|
-
o(this, "createTime");
|
|
886
|
-
// 创建时间
|
|
887
|
-
o(this, "disabled");
|
|
888
883
|
this.setOptions(t);
|
|
889
884
|
}
|
|
890
885
|
get spaceList() {
|
|
@@ -899,58 +894,58 @@ class jt {
|
|
|
899
894
|
}
|
|
900
895
|
//设置参数
|
|
901
896
|
setOptions(t) {
|
|
902
|
-
const { relativeMap: e, parent:
|
|
903
|
-
e && (this.relativeMap = new
|
|
897
|
+
const { relativeMap: e, parent: i, children: n, ...o } = t || {};
|
|
898
|
+
e && (this.relativeMap = new g(e)), i && (this.parent = i), n?.length && (this.children = n), Object.assign(this, o);
|
|
904
899
|
}
|
|
905
900
|
//添加子节点
|
|
906
901
|
async addChild(t) {
|
|
907
|
-
const e =
|
|
908
|
-
this.mergeChild(
|
|
902
|
+
const e = S(t) ? t : [t], i = await w.addCoordinate(this, e);
|
|
903
|
+
this.mergeChild(i);
|
|
909
904
|
}
|
|
910
905
|
//删除子节点
|
|
911
906
|
async removeChild(t) {
|
|
912
|
-
const e =
|
|
913
|
-
await
|
|
914
|
-
for (const
|
|
915
|
-
const n = this.children.findIndex((
|
|
907
|
+
const e = S(t) ? t : [t];
|
|
908
|
+
await w.removeCoordinate(this, e);
|
|
909
|
+
for (const i of e) {
|
|
910
|
+
const n = this.children.findIndex((o) => o.id === i.id);
|
|
916
911
|
n !== -1 && this.children.splice(n, 1);
|
|
917
912
|
}
|
|
918
913
|
}
|
|
919
914
|
//更新子节点
|
|
920
915
|
async updateChild(t) {
|
|
921
|
-
const e =
|
|
922
|
-
this.mergeChild(
|
|
916
|
+
const e = S(t) ? t : [t], i = await w.updateCoordinate(this, e);
|
|
917
|
+
this.mergeChild(i);
|
|
923
918
|
}
|
|
924
919
|
//绑定子节点,不建立映射关系
|
|
925
920
|
async bindChild(t) {
|
|
926
|
-
const e =
|
|
927
|
-
this.mergeChild(
|
|
921
|
+
const e = S(t) ? t : [t], i = await w.bindCoordinate(this, e);
|
|
922
|
+
this.mergeChild(i);
|
|
928
923
|
}
|
|
929
924
|
// 合并子节点,没有查询到节点就插入
|
|
930
925
|
async mergeChild(t) {
|
|
931
|
-
t
|
|
932
|
-
const
|
|
933
|
-
if (
|
|
934
|
-
const { relativeMap: n, no:
|
|
935
|
-
Object.assign(
|
|
926
|
+
t?.length && t.forEach((e) => {
|
|
927
|
+
const i = this.children.find((n) => n.id === e.id);
|
|
928
|
+
if (i) {
|
|
929
|
+
const { relativeMap: n, no: o, name: r, shortName: a, status: h, modelId: l, modelValue: c } = e;
|
|
930
|
+
Object.assign(i, {
|
|
936
931
|
relativeMap: n,
|
|
937
|
-
no:
|
|
938
|
-
name:
|
|
939
|
-
shortName:
|
|
940
|
-
status:
|
|
941
|
-
modelId:
|
|
942
|
-
modelValue:
|
|
932
|
+
no: o,
|
|
933
|
+
name: r,
|
|
934
|
+
shortName: a,
|
|
935
|
+
status: h,
|
|
936
|
+
modelId: l,
|
|
937
|
+
modelValue: c
|
|
943
938
|
});
|
|
944
939
|
} else this.id === e.parentId && (e.parent = this, this.children.unshift(e));
|
|
945
940
|
});
|
|
946
941
|
}
|
|
947
942
|
//映射到(模型映射到空间,空间映射到空间)
|
|
948
943
|
async mappingTo(t) {
|
|
949
|
-
await
|
|
944
|
+
await $(t);
|
|
950
945
|
}
|
|
951
946
|
// 来自映射(被映射过的源坐标系关系)
|
|
952
947
|
async fromMapping() {
|
|
953
|
-
const t = await
|
|
948
|
+
const t = await _({ srcCsId: this.id });
|
|
954
949
|
return t[t.length - 1];
|
|
955
950
|
}
|
|
956
951
|
/**
|
|
@@ -969,13 +964,9 @@ class jt {
|
|
|
969
964
|
* @param mapped 是否被映射
|
|
970
965
|
* @returns
|
|
971
966
|
*/
|
|
972
|
-
findChildModel(t = [
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
if (s.includes(this.modelType ?? -1) && this.status !== O.Disabled)
|
|
976
|
-
return this;
|
|
977
|
-
const r = [M.Data, M.Model].includes(this.type) ? this.findParentSpace() : this, a = (c = (h = r == null ? void 0 : r.modelList) == null ? void 0 : h.filter((u) => s.includes(u.modelType ?? -1) ? e ? !!u.relativeMap : !0 : !1)) == null ? void 0 : c.sort((u, f) => Number(u.status) - Number(f.status));
|
|
978
|
-
return a == null ? void 0 : a[0];
|
|
967
|
+
findChildModel(t = [P.CADModel, P.SkyMapModel], e = !0) {
|
|
968
|
+
const i = S(t) ? t : [t];
|
|
969
|
+
return i.includes(this.modelType ?? -1) && this.status !== D.Disabled ? this : ([M.Data, M.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];
|
|
979
970
|
}
|
|
980
971
|
/**
|
|
981
972
|
* 寻找与当前节点最近的一个模型节点,从当前节点遍历到根节点-广度优先遍历
|
|
@@ -983,37 +974,36 @@ class jt {
|
|
|
983
974
|
* @param excludeNodes //排除的坐标系
|
|
984
975
|
* @returns
|
|
985
976
|
*/
|
|
986
|
-
findClosestModel(t =
|
|
987
|
-
|
|
988
|
-
const
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
let h, c = 1 / 0;
|
|
977
|
+
findClosestModel(t = P.CADModel, e) {
|
|
978
|
+
const i = /* @__PURE__ */ new Set();
|
|
979
|
+
for (const l of e ?? [])
|
|
980
|
+
i.add(String(l.id));
|
|
981
|
+
const n = [{ node: this, distance: 0 }], o = S(t) ? t : [t], r = /* @__PURE__ */ new Set();
|
|
982
|
+
let a, h = 1 / 0;
|
|
993
983
|
for (; n.length > 0; ) {
|
|
994
|
-
const
|
|
995
|
-
if (!
|
|
996
|
-
const { node:
|
|
997
|
-
if (
|
|
984
|
+
const l = n.shift();
|
|
985
|
+
if (!l) break;
|
|
986
|
+
const { node: c, distance: u } = l;
|
|
987
|
+
if (i.has(String(c.id)))
|
|
998
988
|
continue;
|
|
999
|
-
if (
|
|
1000
|
-
if (
|
|
989
|
+
if (o.includes(c.modelType ?? -1)) {
|
|
990
|
+
if (u < h && (a = c, h = u, u <= 1))
|
|
1001
991
|
break;
|
|
1002
992
|
continue;
|
|
1003
993
|
}
|
|
1004
|
-
|
|
1005
|
-
const
|
|
1006
|
-
if (
|
|
1007
|
-
for (const
|
|
1008
|
-
|
|
1009
|
-
if (
|
|
1010
|
-
for (const
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
for (const
|
|
1014
|
-
n.push({ node:
|
|
994
|
+
r.add(c);
|
|
995
|
+
const d = [];
|
|
996
|
+
if (c.children)
|
|
997
|
+
for (const p of c.children)
|
|
998
|
+
r.has(p) || d.push(p);
|
|
999
|
+
if (c.parent?.children)
|
|
1000
|
+
for (const p of c.parent.children)
|
|
1001
|
+
p !== c && !r.has(p) && d.push(p);
|
|
1002
|
+
c.parent && !r.has(c.parent) && d.push(c.parent);
|
|
1003
|
+
for (const p of d)
|
|
1004
|
+
n.push({ node: p, distance: u + 1 });
|
|
1015
1005
|
}
|
|
1016
|
-
return
|
|
1006
|
+
return a;
|
|
1017
1007
|
}
|
|
1018
1008
|
/**
|
|
1019
1009
|
*向上寻找到子节点的空间坐标系
|
|
@@ -1032,16 +1022,15 @@ class jt {
|
|
|
1032
1022
|
*/
|
|
1033
1023
|
findParentSpaceNames(t = 2) {
|
|
1034
1024
|
const e = [];
|
|
1035
|
-
let
|
|
1036
|
-
for (;
|
|
1037
|
-
|
|
1025
|
+
let i = this;
|
|
1026
|
+
for (; i && t > 0; )
|
|
1027
|
+
i.type === M.Space && (e.unshift(i.fullName), t--), i = i.parent;
|
|
1038
1028
|
return e;
|
|
1039
1029
|
}
|
|
1040
1030
|
// 寻找坐标系组, 有groupUuid表示坐标系组
|
|
1041
1031
|
findCsGroup() {
|
|
1042
|
-
var s;
|
|
1043
1032
|
const { groupUuid: t, parent: e } = this;
|
|
1044
|
-
return t ?
|
|
1033
|
+
return t ? e?.children?.filter((i) => i.groupUuid === t) || [] : [this];
|
|
1045
1034
|
}
|
|
1046
1035
|
/**
|
|
1047
1036
|
* 递归寻找到相应的层级
|
|
@@ -1053,9 +1042,9 @@ class jt {
|
|
|
1053
1042
|
return this;
|
|
1054
1043
|
if (this.children.length)
|
|
1055
1044
|
for (const e of this.children) {
|
|
1056
|
-
const
|
|
1057
|
-
if (
|
|
1058
|
-
return
|
|
1045
|
+
const i = e.findCsByLevel(t);
|
|
1046
|
+
if (i)
|
|
1047
|
+
return i;
|
|
1059
1048
|
}
|
|
1060
1049
|
}
|
|
1061
1050
|
/**
|
|
@@ -1067,8 +1056,8 @@ class jt {
|
|
|
1067
1056
|
if (t) {
|
|
1068
1057
|
if (this.id === t) return this;
|
|
1069
1058
|
for (const e of this.children) {
|
|
1070
|
-
const
|
|
1071
|
-
if (
|
|
1059
|
+
const i = e.findCsById(t);
|
|
1060
|
+
if (i) return i;
|
|
1072
1061
|
}
|
|
1073
1062
|
}
|
|
1074
1063
|
}
|
|
@@ -1079,10 +1068,10 @@ class jt {
|
|
|
1079
1068
|
*/
|
|
1080
1069
|
getCsRoutes(t = !1) {
|
|
1081
1070
|
let e = this;
|
|
1082
|
-
const
|
|
1083
|
-
for (; e
|
|
1084
|
-
e = e.parent, e &&
|
|
1085
|
-
return
|
|
1071
|
+
const i = [e];
|
|
1072
|
+
for (; e?.parent && !(t && !e.relativeMap); )
|
|
1073
|
+
e = e.parent, e && i.push(e);
|
|
1074
|
+
return i;
|
|
1086
1075
|
}
|
|
1087
1076
|
/**
|
|
1088
1077
|
* 通过当前坐标系,获取新的映射坐标树
|
|
@@ -1090,11 +1079,10 @@ class jt {
|
|
|
1090
1079
|
*/
|
|
1091
1080
|
getMappedCsTree() {
|
|
1092
1081
|
function t(n) {
|
|
1093
|
-
|
|
1094
|
-
return (r = n.children) != null && r.length && (n.children = n.children.filter((a) => !!(a != null && a.relativeMap) && a.status !== O.Disabled).map((a) => t(a))), n;
|
|
1082
|
+
return n.children?.length && (n.children = n.children.filter((o) => !!o?.relativeMap && o.status !== D.Disabled).map((o) => t(o))), n;
|
|
1095
1083
|
}
|
|
1096
|
-
const e =
|
|
1097
|
-
return
|
|
1084
|
+
const e = H(this.findRoot(!0)), i = t(e);
|
|
1085
|
+
return i.parentId = 0, i.parent = void 0, i;
|
|
1098
1086
|
}
|
|
1099
1087
|
/**
|
|
1100
1088
|
* 获取该坐标系到目标坐标系的映射关系,两个坐标系必须是同一树的坐标系
|
|
@@ -1102,15 +1090,14 @@ class jt {
|
|
|
1102
1090
|
* @returns
|
|
1103
1091
|
*/
|
|
1104
1092
|
getDestRelativeMap(t) {
|
|
1105
|
-
var r;
|
|
1106
1093
|
if (this.id === t.id)
|
|
1107
|
-
return new
|
|
1108
|
-
const e = this.getRelativeMaps(),
|
|
1109
|
-
let n = new
|
|
1110
|
-
return e
|
|
1111
|
-
n =
|
|
1112
|
-
}),
|
|
1113
|
-
n =
|
|
1094
|
+
return new g();
|
|
1095
|
+
const e = this.getRelativeMaps(), i = t.getRelativeMaps();
|
|
1096
|
+
let n = new g();
|
|
1097
|
+
return e?.forEach((o) => {
|
|
1098
|
+
n = g.addRelativeMap(n, o);
|
|
1099
|
+
}), i?.reverse()?.forEach((o) => {
|
|
1100
|
+
n = g.addRelativeMap(n, g.inverseRelativeMap(o));
|
|
1114
1101
|
}), n;
|
|
1115
1102
|
}
|
|
1116
1103
|
/**
|
|
@@ -1120,7 +1107,7 @@ class jt {
|
|
|
1120
1107
|
getRelativeMaps() {
|
|
1121
1108
|
let t = this;
|
|
1122
1109
|
const e = [];
|
|
1123
|
-
for (; t
|
|
1110
|
+
for (; t?.parent && t.relativeMap; )
|
|
1124
1111
|
e.push(t.relativeMap), t = t.parent;
|
|
1125
1112
|
return e;
|
|
1126
1113
|
}
|
|
@@ -1131,11 +1118,10 @@ class jt {
|
|
|
1131
1118
|
* @param excludeTypes 要排除的模型Type数组 (可选)
|
|
1132
1119
|
* @returns
|
|
1133
1120
|
*/
|
|
1134
|
-
static filterCoordinateTree(t, e = [],
|
|
1135
|
-
|
|
1136
|
-
if (s.includes(t.id) || e.includes(t.type))
|
|
1121
|
+
static filterCoordinateTree(t, e = [], i = []) {
|
|
1122
|
+
if (i.includes(t.id) || e.includes(t.type))
|
|
1137
1123
|
return;
|
|
1138
|
-
const n =
|
|
1124
|
+
const n = t.children?.map((o) => this.filterCoordinateTree(o, e, i)).filter((o) => o !== void 0);
|
|
1139
1125
|
return { ...t, children: n };
|
|
1140
1126
|
}
|
|
1141
1127
|
/**
|
|
@@ -1145,10 +1131,10 @@ class jt {
|
|
|
1145
1131
|
*/
|
|
1146
1132
|
static getCommonCoordinate(t) {
|
|
1147
1133
|
let e;
|
|
1148
|
-
const
|
|
1149
|
-
for (; this.checkSameCoordinate(
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1134
|
+
const i = t.map((n) => n.getCsRoutes(!0).filter((r) => r.id && r.type === M.Space));
|
|
1135
|
+
for (; this.checkSameCoordinate(i); ) {
|
|
1136
|
+
const o = i.shift();
|
|
1137
|
+
o?.length && (e = o[0]);
|
|
1152
1138
|
}
|
|
1153
1139
|
return e;
|
|
1154
1140
|
}
|
|
@@ -1162,124 +1148,124 @@ class jt {
|
|
|
1162
1148
|
if (t.length === 1)
|
|
1163
1149
|
return !0;
|
|
1164
1150
|
for (let e = 0; e < t.length - 1; e++) {
|
|
1165
|
-
const
|
|
1166
|
-
if (!
|
|
1151
|
+
const i = t[e];
|
|
1152
|
+
if (!i?.length)
|
|
1167
1153
|
return !1;
|
|
1168
1154
|
const n = t[e + 1];
|
|
1169
|
-
if (!
|
|
1155
|
+
if (!n?.length || i[0].id !== n[0].id)
|
|
1170
1156
|
return !1;
|
|
1171
1157
|
}
|
|
1172
1158
|
return !0;
|
|
1173
1159
|
} else return !1;
|
|
1174
1160
|
}
|
|
1175
1161
|
}
|
|
1176
|
-
class
|
|
1162
|
+
class W {
|
|
1163
|
+
yaw = 0;
|
|
1164
|
+
//偏航角
|
|
1165
|
+
pitch = 0;
|
|
1166
|
+
//俯仰角
|
|
1167
|
+
roll = 0;
|
|
1177
1168
|
//横滚角
|
|
1178
1169
|
constructor(t) {
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
o(this, "pitch", 0);
|
|
1182
|
-
//俯仰角
|
|
1183
|
-
o(this, "roll", 0);
|
|
1184
|
-
const { yaw: e = 0, pitch: s = 0, roll: n = 0 } = t || {};
|
|
1185
|
-
this.yaw = Number(e) || 0, this.pitch = Number(s) || 0, this.roll = Number(n) || 0;
|
|
1170
|
+
const { yaw: e = 0, pitch: i = 0, roll: n = 0 } = t || {};
|
|
1171
|
+
this.yaw = Number(e) || 0, this.pitch = Number(i) || 0, this.roll = Number(n) || 0;
|
|
1186
1172
|
}
|
|
1187
1173
|
static toParse(t) {
|
|
1188
1174
|
if (t) {
|
|
1189
|
-
const e = t
|
|
1190
|
-
return new
|
|
1175
|
+
const e = t?.split(",").map((i) => Number(i) || 0);
|
|
1176
|
+
return new W({ yaw: e[0], pitch: e[1], roll: e[2] });
|
|
1191
1177
|
}
|
|
1192
1178
|
}
|
|
1193
1179
|
static toStringify(t) {
|
|
1194
1180
|
return t ? `${t.yaw},${t.pitch},${t.roll}` : "";
|
|
1195
1181
|
}
|
|
1196
1182
|
}
|
|
1197
|
-
class
|
|
1183
|
+
class Q {
|
|
1184
|
+
x = 0;
|
|
1185
|
+
//x轴
|
|
1186
|
+
y = 0;
|
|
1187
|
+
//y轴
|
|
1188
|
+
z = 0;
|
|
1198
1189
|
//z轴
|
|
1199
1190
|
constructor(t) {
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
o(this, "y", 0);
|
|
1203
|
-
//y轴
|
|
1204
|
-
o(this, "z", 0);
|
|
1205
|
-
const { x: e = 0, y: s = 0, z: n = 0 } = t || {};
|
|
1206
|
-
this.x = Number(e) || 0, this.y = Number(s) || 0, this.z = Number(n) || 0;
|
|
1191
|
+
const { x: e = 0, y: i = 0, z: n = 0 } = t || {};
|
|
1192
|
+
this.x = Number(e) || 0, this.y = Number(i) || 0, this.z = Number(n) || 0;
|
|
1207
1193
|
}
|
|
1208
1194
|
static toParse(t) {
|
|
1209
1195
|
if (t) {
|
|
1210
|
-
const e = t
|
|
1211
|
-
return new
|
|
1196
|
+
const e = t?.split(",").map((i) => Number(i) || 0);
|
|
1197
|
+
return new Q({ x: e[0], y: e[1], z: e[2] });
|
|
1212
1198
|
}
|
|
1213
1199
|
}
|
|
1214
1200
|
static toStringify(t) {
|
|
1215
1201
|
return t ? `${t.x},${t.y},${t.z}` : "";
|
|
1216
1202
|
}
|
|
1217
1203
|
}
|
|
1218
|
-
class
|
|
1204
|
+
class Lt {
|
|
1205
|
+
canvas;
|
|
1206
|
+
ctx;
|
|
1207
|
+
options;
|
|
1208
|
+
offset = { x: 0, y: 0 };
|
|
1209
|
+
// 拖动偏移
|
|
1210
|
+
curOffset = { x: 0, y: 0 };
|
|
1211
|
+
// 记录上一次的偏移量
|
|
1212
|
+
mousePosition = { x: -1, y: -1 };
|
|
1213
|
+
// 记录鼠标坐标位置
|
|
1214
|
+
// 缩放
|
|
1215
|
+
MAX_SCALE = 60;
|
|
1216
|
+
MIN_SCALE = 1;
|
|
1217
|
+
STEP_SCALE = 0.5;
|
|
1218
|
+
// 暂存缩放值
|
|
1219
|
+
scale = 1;
|
|
1220
|
+
preScale = 1;
|
|
1221
|
+
// 画布大小
|
|
1222
|
+
width = 0;
|
|
1223
|
+
height = 0;
|
|
1224
|
+
x = 0;
|
|
1225
|
+
// 记录鼠标点击时的横坐标
|
|
1226
|
+
y = 0;
|
|
1227
|
+
// 记录鼠标点击时的纵坐标
|
|
1228
|
+
timeout = 0;
|
|
1229
|
+
// 单击
|
|
1230
|
+
// 移动端相关参数
|
|
1231
|
+
lastTouch;
|
|
1232
|
+
initialDistance = 0;
|
|
1233
|
+
//初始距离
|
|
1234
|
+
touchMode = 0;
|
|
1235
|
+
isMouseover = !1;
|
|
1236
|
+
//鼠标是否在元素上
|
|
1237
|
+
isBindEvent = !0;
|
|
1238
|
+
// 是否绘制辅助线
|
|
1239
|
+
isDrawAssist = !1;
|
|
1240
|
+
// 是否绑定事件
|
|
1241
|
+
customDrawAssist;
|
|
1242
|
+
// 绘制辅助线的方法
|
|
1243
|
+
isMoveRedrawing;
|
|
1244
|
+
// 移动过程中是否重绘
|
|
1245
|
+
afterDraw;
|
|
1246
|
+
screenPos = { screenX: 0, screenY: 0 };
|
|
1219
1247
|
//屏幕位置
|
|
1220
1248
|
constructor(t) {
|
|
1221
|
-
o(this, "canvas");
|
|
1222
|
-
o(this, "ctx");
|
|
1223
|
-
o(this, "options");
|
|
1224
|
-
o(this, "offset", { x: 0, y: 0 });
|
|
1225
|
-
// 拖动偏移
|
|
1226
|
-
o(this, "curOffset", { x: 0, y: 0 });
|
|
1227
|
-
// 记录上一次的偏移量
|
|
1228
|
-
o(this, "mousePosition", { x: -1, y: -1 });
|
|
1229
|
-
// 记录鼠标坐标位置
|
|
1230
|
-
// 缩放
|
|
1231
|
-
o(this, "MAX_SCALE", 60);
|
|
1232
|
-
o(this, "MIN_SCALE", 1);
|
|
1233
|
-
o(this, "STEP_SCALE", 0.5);
|
|
1234
|
-
// 暂存缩放值
|
|
1235
|
-
o(this, "scale", 1);
|
|
1236
|
-
o(this, "preScale", 1);
|
|
1237
|
-
// 画布大小
|
|
1238
|
-
o(this, "width", 0);
|
|
1239
|
-
o(this, "height", 0);
|
|
1240
|
-
o(this, "x", 0);
|
|
1241
|
-
// 记录鼠标点击时的横坐标
|
|
1242
|
-
o(this, "y", 0);
|
|
1243
|
-
// 记录鼠标点击时的纵坐标
|
|
1244
|
-
o(this, "timeout", 0);
|
|
1245
|
-
// 单击
|
|
1246
|
-
// 移动端相关参数
|
|
1247
|
-
o(this, "lastTouch");
|
|
1248
|
-
o(this, "initialDistance", 0);
|
|
1249
|
-
//初始距离
|
|
1250
|
-
o(this, "touchMode", 0);
|
|
1251
|
-
o(this, "isMouseover", !1);
|
|
1252
|
-
//鼠标是否在元素上
|
|
1253
|
-
o(this, "isBindEvent", !0);
|
|
1254
|
-
// 是否绘制辅助线
|
|
1255
|
-
o(this, "isDrawAssist", !1);
|
|
1256
|
-
// 是否绑定事件
|
|
1257
|
-
o(this, "customDrawAssist");
|
|
1258
|
-
// 绘制辅助线的方法
|
|
1259
|
-
o(this, "isMoveRedrawing");
|
|
1260
|
-
// 移动过程中是否重绘
|
|
1261
|
-
o(this, "afterDraw");
|
|
1262
|
-
o(this, "screenPos", { screenX: 0, screenY: 0 });
|
|
1263
1249
|
const {
|
|
1264
1250
|
container: e,
|
|
1265
|
-
width:
|
|
1251
|
+
width: i = 300,
|
|
1266
1252
|
height: n = 300,
|
|
1267
|
-
isBindEvent:
|
|
1268
|
-
isDrawAssist:
|
|
1269
|
-
isMoveRedrawing:
|
|
1270
|
-
customDrawAssist:
|
|
1271
|
-
afterDraw:
|
|
1272
|
-
...
|
|
1253
|
+
isBindEvent: o = !0,
|
|
1254
|
+
isDrawAssist: r = !1,
|
|
1255
|
+
isMoveRedrawing: a,
|
|
1256
|
+
customDrawAssist: h,
|
|
1257
|
+
afterDraw: l,
|
|
1258
|
+
...c
|
|
1273
1259
|
} = t;
|
|
1274
|
-
this.canvas = e, this.ctx = this.canvas.getContext("2d"), this.width =
|
|
1260
|
+
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));
|
|
1275
1261
|
}
|
|
1276
1262
|
onClick(t) {
|
|
1277
|
-
const { screenX: e, screenY:
|
|
1263
|
+
const { screenX: e, screenY: i } = t;
|
|
1278
1264
|
this.timeout && clearTimeout(this.timeout);
|
|
1279
1265
|
const n = this.getPos(t);
|
|
1280
|
-
this.x = n.x, this.y = n.y, this.screenPos = { screenX: e, screenY:
|
|
1281
|
-
const
|
|
1282
|
-
this.options.onClick(
|
|
1266
|
+
this.x = n.x, this.y = n.y, this.screenPos = { screenX: e, screenY: i }, this.options.onClick && (this.timeout = setTimeout(() => {
|
|
1267
|
+
const o = parseFloat(((this.x - this.offset.x) / this.scale).toFixed(2)), r = parseFloat(((this.y - this.offset.y) / this.scale).toFixed(2));
|
|
1268
|
+
this.options.onClick(o, r);
|
|
1283
1269
|
}, 200));
|
|
1284
1270
|
}
|
|
1285
1271
|
onMouseout(t) {
|
|
@@ -1293,12 +1279,12 @@ class Ft {
|
|
|
1293
1279
|
}
|
|
1294
1280
|
onBothTouchstart(t) {
|
|
1295
1281
|
t.preventDefault();
|
|
1296
|
-
const e = { x: t.touches[0].clientX, y: t.touches[0].clientY },
|
|
1297
|
-
clientX: (e.x +
|
|
1298
|
-
clientY: (e.y +
|
|
1282
|
+
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({
|
|
1283
|
+
clientX: (e.x + i.x) / 2,
|
|
1284
|
+
clientY: (e.y + i.y) / 2
|
|
1299
1285
|
});
|
|
1300
1286
|
this.x = n.x, this.y = n.y, this.curOffset.x = this.offset.x, this.curOffset.y = this.offset.y, this.initialDistance = Math.sqrt(
|
|
1301
|
-
Math.pow(
|
|
1287
|
+
Math.pow(i.x - e.x, 2) + Math.pow(i.y - e.y, 2)
|
|
1302
1288
|
);
|
|
1303
1289
|
}
|
|
1304
1290
|
onTouchmove(t) {
|
|
@@ -1311,13 +1297,13 @@ class Ft {
|
|
|
1311
1297
|
}
|
|
1312
1298
|
// 监听点击的持久move
|
|
1313
1299
|
onMousemoveTemp(t) {
|
|
1314
|
-
const { screenX: e, screenY:
|
|
1315
|
-
(Math.abs(e - t.screenX) > 10 || Math.abs(
|
|
1300
|
+
const { screenX: e, screenY: i } = this.screenPos;
|
|
1301
|
+
(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());
|
|
1316
1302
|
}
|
|
1317
1303
|
onBothTouchmove(t) {
|
|
1318
1304
|
if (t.preventDefault(), this.initialDistance) {
|
|
1319
|
-
const e = { x: t.touches[0].clientX, y: t.touches[0].clientY },
|
|
1320
|
-
Math.pow(
|
|
1305
|
+
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(
|
|
1306
|
+
Math.pow(i.x - e.x, 2) + Math.pow(i.y - e.y, 2)
|
|
1321
1307
|
);
|
|
1322
1308
|
if (this.scale += (n - this.initialDistance) / 30 * this.STEP_SCALE, this.initialDistance = n, this.scale > this.MAX_SCALE) {
|
|
1323
1309
|
this.scale = this.MAX_SCALE;
|
|
@@ -1340,8 +1326,8 @@ class Ft {
|
|
|
1340
1326
|
this.timeout && clearTimeout(this.timeout), t.preventDefault();
|
|
1341
1327
|
const e = this.getPos(t);
|
|
1342
1328
|
this.x = e.x, this.y = e.y;
|
|
1343
|
-
const
|
|
1344
|
-
if (this.scale = parseFloat((this.scale +
|
|
1329
|
+
const i = t.wheelDelta > 0 || t.detail < 0 ? this.STEP_SCALE : -this.STEP_SCALE;
|
|
1330
|
+
if (this.scale = parseFloat((this.scale + i).toFixed(2)), this.scale > this.MAX_SCALE) {
|
|
1345
1331
|
this.scale = this.MAX_SCALE;
|
|
1346
1332
|
return;
|
|
1347
1333
|
}
|
|
@@ -1353,8 +1339,8 @@ class Ft {
|
|
|
1353
1339
|
}
|
|
1354
1340
|
// 触摸
|
|
1355
1341
|
onTouch(t) {
|
|
1356
|
-
const e = Date.now(), { lastTouchTime:
|
|
1357
|
-
e -
|
|
1342
|
+
const e = Date.now(), { lastTouchTime: i = 0, lastTouchX: n = 0, lastTouchY: o = 0 } = this.lastTouch || {};
|
|
1343
|
+
e - i < 300 && Math.abs(t.clientX - n) < 30 && Math.abs(t.clientY - o) < 30 ? (this.onDblclick(t), this.lastTouch = {
|
|
1358
1344
|
lastTouchTime: 0,
|
|
1359
1345
|
lastTouchX: 0,
|
|
1360
1346
|
lastTouchY: 0
|
|
@@ -1374,13 +1360,13 @@ class Ft {
|
|
|
1374
1360
|
reset(t) {
|
|
1375
1361
|
const {
|
|
1376
1362
|
width: e = this.width,
|
|
1377
|
-
height:
|
|
1363
|
+
height: i = this.height,
|
|
1378
1364
|
scale: n = 1,
|
|
1379
|
-
preScale:
|
|
1380
|
-
offset:
|
|
1381
|
-
curOffset:
|
|
1365
|
+
preScale: o = 1,
|
|
1366
|
+
offset: r = { x: 0, y: 0 },
|
|
1367
|
+
curOffset: a = { x: 0, y: 0 }
|
|
1382
1368
|
} = t || {};
|
|
1383
|
-
this.width = e, this.height =
|
|
1369
|
+
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;
|
|
1384
1370
|
}
|
|
1385
1371
|
// 辅助内容
|
|
1386
1372
|
drawAssist() {
|
|
@@ -1389,45 +1375,42 @@ class Ft {
|
|
|
1389
1375
|
}
|
|
1390
1376
|
// 绘制
|
|
1391
1377
|
draw() {
|
|
1392
|
-
|
|
1393
|
-
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);
|
|
1378
|
+
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);
|
|
1394
1379
|
}
|
|
1395
1380
|
getPos(t) {
|
|
1396
1381
|
const e = this.canvas.getBoundingClientRect();
|
|
1397
|
-
let
|
|
1398
|
-
return
|
|
1382
|
+
let i = parseFloat((t.clientX - e.left).toFixed(2)), n = parseFloat((t.clientY - e.top).toFixed(2));
|
|
1383
|
+
return i = i < 0 ? 0 : i, n = n < 0 ? 0 : n, { x: i, y: n };
|
|
1399
1384
|
}
|
|
1400
1385
|
unBindEvent() {
|
|
1401
1386
|
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));
|
|
1402
1387
|
}
|
|
1403
1388
|
}
|
|
1404
|
-
const
|
|
1405
|
-
class
|
|
1389
|
+
const k = {};
|
|
1390
|
+
class jt {
|
|
1391
|
+
type = "image";
|
|
1392
|
+
// 修改为更通用的名称
|
|
1393
|
+
x;
|
|
1394
|
+
y;
|
|
1395
|
+
width;
|
|
1396
|
+
height;
|
|
1397
|
+
img;
|
|
1398
|
+
src;
|
|
1399
|
+
redraw;
|
|
1406
1400
|
constructor(t) {
|
|
1407
|
-
o(this, "type", "image");
|
|
1408
|
-
// 修改为更通用的名称
|
|
1409
|
-
o(this, "x");
|
|
1410
|
-
o(this, "y");
|
|
1411
|
-
o(this, "width");
|
|
1412
|
-
o(this, "height");
|
|
1413
|
-
o(this, "img");
|
|
1414
|
-
o(this, "src");
|
|
1415
|
-
o(this, "redraw");
|
|
1416
1401
|
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);
|
|
1417
1402
|
}
|
|
1418
1403
|
loadImage(t) {
|
|
1419
|
-
const e =
|
|
1404
|
+
const e = k[this.src];
|
|
1420
1405
|
if (e)
|
|
1421
1406
|
return queueMicrotask(() => {
|
|
1422
|
-
|
|
1423
|
-
t == null || t(e), (s = this.redraw) == null || s.call(this);
|
|
1407
|
+
t?.(e), this.redraw?.();
|
|
1424
1408
|
}), e;
|
|
1425
1409
|
{
|
|
1426
|
-
const
|
|
1427
|
-
return
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
}, s;
|
|
1410
|
+
const i = new Image();
|
|
1411
|
+
return i.crossOrigin = "anonymous", i.src = this.src, i.onload = () => {
|
|
1412
|
+
k[this.src] = i, t?.(i), this.redraw?.();
|
|
1413
|
+
}, i;
|
|
1431
1414
|
}
|
|
1432
1415
|
}
|
|
1433
1416
|
draw(t) {
|
|
@@ -1439,215 +1422,208 @@ class Ut {
|
|
|
1439
1422
|
}
|
|
1440
1423
|
}
|
|
1441
1424
|
}
|
|
1442
|
-
class
|
|
1425
|
+
class kt {
|
|
1426
|
+
id = "";
|
|
1427
|
+
type = "point";
|
|
1428
|
+
x;
|
|
1429
|
+
y;
|
|
1430
|
+
r;
|
|
1431
|
+
text;
|
|
1432
|
+
backgroundColor;
|
|
1433
|
+
index;
|
|
1434
|
+
pIndex;
|
|
1435
|
+
parentId;
|
|
1443
1436
|
constructor(t) {
|
|
1444
|
-
o(this, "id", "");
|
|
1445
|
-
o(this, "type", "point");
|
|
1446
|
-
o(this, "x");
|
|
1447
|
-
o(this, "y");
|
|
1448
|
-
o(this, "r");
|
|
1449
|
-
o(this, "text");
|
|
1450
|
-
o(this, "backgroundColor");
|
|
1451
|
-
o(this, "index");
|
|
1452
|
-
o(this, "pIndex");
|
|
1453
|
-
o(this, "parentId");
|
|
1454
1437
|
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)";
|
|
1455
1438
|
}
|
|
1456
1439
|
draw(t, e) {
|
|
1457
1440
|
t.save();
|
|
1458
|
-
const
|
|
1459
|
-
t.beginPath(), t.arc(this.x, this.y, this.r *
|
|
1441
|
+
const i = 1 / e.scale;
|
|
1442
|
+
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();
|
|
1460
1443
|
}
|
|
1461
1444
|
}
|
|
1462
|
-
const
|
|
1463
|
-
class
|
|
1445
|
+
const A = {};
|
|
1446
|
+
class At {
|
|
1447
|
+
id = "";
|
|
1448
|
+
type = "issue";
|
|
1449
|
+
//轨迹点上的事件
|
|
1450
|
+
x;
|
|
1451
|
+
y;
|
|
1452
|
+
width;
|
|
1453
|
+
height;
|
|
1454
|
+
src;
|
|
1455
|
+
img;
|
|
1456
|
+
index;
|
|
1457
|
+
pIndex;
|
|
1458
|
+
parentId;
|
|
1459
|
+
count;
|
|
1460
|
+
badgeR;
|
|
1461
|
+
redraw;
|
|
1464
1462
|
constructor(t) {
|
|
1465
|
-
o(this, "id", "");
|
|
1466
|
-
o(this, "type", "issue");
|
|
1467
|
-
//轨迹点上的事件
|
|
1468
|
-
o(this, "x");
|
|
1469
|
-
o(this, "y");
|
|
1470
|
-
o(this, "width");
|
|
1471
|
-
o(this, "height");
|
|
1472
|
-
o(this, "src");
|
|
1473
|
-
o(this, "img");
|
|
1474
|
-
o(this, "index");
|
|
1475
|
-
o(this, "pIndex");
|
|
1476
|
-
o(this, "parentId");
|
|
1477
|
-
o(this, "count");
|
|
1478
|
-
o(this, "badgeR");
|
|
1479
|
-
o(this, "redraw");
|
|
1480
1463
|
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);
|
|
1481
1464
|
}
|
|
1482
1465
|
loadImage(t) {
|
|
1483
|
-
const e =
|
|
1466
|
+
const e = A[this.src];
|
|
1484
1467
|
if (e)
|
|
1485
1468
|
return queueMicrotask(() => {
|
|
1486
|
-
|
|
1487
|
-
t == null || t(e), (s = this.redraw) == null || s.call(this);
|
|
1469
|
+
t?.(e), this.redraw?.();
|
|
1488
1470
|
}), e;
|
|
1489
1471
|
{
|
|
1490
|
-
const
|
|
1491
|
-
return
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
}, s;
|
|
1472
|
+
const i = new Image();
|
|
1473
|
+
return i.src = this.src, i.crossOrigin = "anonymous", i.onload = () => {
|
|
1474
|
+
A[this.src] = i, t?.(i), this.redraw?.();
|
|
1475
|
+
}, i;
|
|
1495
1476
|
}
|
|
1496
1477
|
}
|
|
1497
1478
|
draw(t, e) {
|
|
1498
1479
|
if (!this.img.complete) return;
|
|
1499
|
-
const
|
|
1500
|
-
t.save(), t.drawImage(this.img,
|
|
1480
|
+
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, l = h * 1.5;
|
|
1481
|
+
t.save(), t.drawImage(this.img, r, a, n, o), t.beginPath(), this.count > 1 && (t.arc(this.x + n * 0.3, this.y - o * 0.8, h, 0, 2 * Math.PI), t.fillStyle = "red", t.fill(), t.font = `${l}px Microsoft YaHei`, t.textAlign = "center", t.fillStyle = "#FFFFFF", t.fillText(this.count.toString(), this.x + n * 0.3, this.y - o * 0.8 + h / 2)), t.restore();
|
|
1501
1482
|
}
|
|
1502
1483
|
}
|
|
1503
|
-
const
|
|
1504
|
-
class
|
|
1484
|
+
const X = {};
|
|
1485
|
+
class Xt {
|
|
1486
|
+
type = "marker";
|
|
1487
|
+
x;
|
|
1488
|
+
y;
|
|
1489
|
+
url;
|
|
1490
|
+
width;
|
|
1491
|
+
height;
|
|
1492
|
+
anchor;
|
|
1493
|
+
img;
|
|
1494
|
+
scale;
|
|
1495
|
+
redraw;
|
|
1496
|
+
beforeDraw;
|
|
1505
1497
|
constructor(t) {
|
|
1506
|
-
o(this, "type", "marker");
|
|
1507
|
-
o(this, "x");
|
|
1508
|
-
o(this, "y");
|
|
1509
|
-
o(this, "url");
|
|
1510
|
-
o(this, "width");
|
|
1511
|
-
o(this, "height");
|
|
1512
|
-
o(this, "anchor");
|
|
1513
|
-
o(this, "img");
|
|
1514
|
-
o(this, "scale");
|
|
1515
|
-
o(this, "redraw");
|
|
1516
|
-
o(this, "beforeDraw");
|
|
1517
1498
|
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);
|
|
1518
1499
|
}
|
|
1519
1500
|
loadImage(t) {
|
|
1520
|
-
const e =
|
|
1501
|
+
const e = X[this.url];
|
|
1521
1502
|
if (e)
|
|
1522
1503
|
return queueMicrotask(() => {
|
|
1523
|
-
|
|
1524
|
-
t == null || t(e), (s = this.redraw) == null || s.call(this);
|
|
1504
|
+
t?.(e), this.redraw?.();
|
|
1525
1505
|
}), e;
|
|
1526
1506
|
{
|
|
1527
|
-
const
|
|
1528
|
-
return
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
}, s;
|
|
1507
|
+
const i = new Image();
|
|
1508
|
+
return i.src = this.url, i.crossOrigin = "anonymous", i.onload = () => {
|
|
1509
|
+
X[this.url] = i, t?.(i), this.redraw?.();
|
|
1510
|
+
}, i;
|
|
1532
1511
|
}
|
|
1533
1512
|
}
|
|
1534
1513
|
calculateIconPosition() {
|
|
1535
|
-
|
|
1536
|
-
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;
|
|
1514
|
+
const t = this.anchor?.x ?? this.width / 2, e = this.anchor?.y ?? this.height / 2;
|
|
1537
1515
|
return {
|
|
1538
1516
|
iconStartX: this.x - t * this.scale,
|
|
1539
1517
|
iconStartY: this.y - e * this.scale
|
|
1540
1518
|
};
|
|
1541
1519
|
}
|
|
1542
1520
|
draw(t, e) {
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
const { iconStartX: s, iconStartY: n } = this.calculateIconPosition();
|
|
1521
|
+
if (this.beforeDraw?.(t, e), !this.img?.complete) return;
|
|
1522
|
+
const { iconStartX: i, iconStartY: n } = this.calculateIconPosition();
|
|
1546
1523
|
t.save();
|
|
1547
1524
|
try {
|
|
1548
1525
|
t.drawImage(
|
|
1549
1526
|
this.img,
|
|
1550
|
-
|
|
1527
|
+
i,
|
|
1551
1528
|
n,
|
|
1552
1529
|
this.width * this.scale,
|
|
1553
1530
|
this.height * this.scale
|
|
1554
1531
|
);
|
|
1555
|
-
} catch (
|
|
1556
|
-
console.error("绘制标记时出错:",
|
|
1532
|
+
} catch (o) {
|
|
1533
|
+
console.error("绘制标记时出错:", o);
|
|
1557
1534
|
} finally {
|
|
1558
1535
|
t.restore();
|
|
1559
1536
|
}
|
|
1560
1537
|
}
|
|
1561
1538
|
}
|
|
1562
|
-
class
|
|
1539
|
+
class Ft {
|
|
1540
|
+
type = "radar";
|
|
1541
|
+
x;
|
|
1542
|
+
y;
|
|
1543
|
+
r;
|
|
1544
|
+
angle;
|
|
1545
|
+
text;
|
|
1546
|
+
hFov = 90;
|
|
1547
|
+
beforeDraw;
|
|
1563
1548
|
constructor(t) {
|
|
1564
|
-
o(this, "type", "radar");
|
|
1565
|
-
o(this, "x");
|
|
1566
|
-
o(this, "y");
|
|
1567
|
-
o(this, "r");
|
|
1568
|
-
o(this, "angle");
|
|
1569
|
-
o(this, "text");
|
|
1570
|
-
o(this, "hFov", 90);
|
|
1571
|
-
o(this, "beforeDraw");
|
|
1572
1549
|
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;
|
|
1573
1550
|
}
|
|
1574
1551
|
draw(t, e) {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
const s = 1 / e.scale, [n, r] = [
|
|
1552
|
+
this.beforeDraw?.(t, e);
|
|
1553
|
+
const i = 1 / e.scale, [n, o] = [
|
|
1578
1554
|
(this.angle - this.hFov / 2) / 180 * Math.PI,
|
|
1579
1555
|
(this.angle + this.hFov / 2) / 180 * Math.PI
|
|
1580
1556
|
];
|
|
1581
1557
|
t.save();
|
|
1582
|
-
const
|
|
1558
|
+
const r = t.createRadialGradient(
|
|
1583
1559
|
this.x,
|
|
1584
1560
|
this.y,
|
|
1585
1561
|
0,
|
|
1586
1562
|
this.x,
|
|
1587
1563
|
this.y,
|
|
1588
|
-
this.r *
|
|
1564
|
+
this.r * i
|
|
1589
1565
|
);
|
|
1590
|
-
|
|
1566
|
+
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();
|
|
1591
1567
|
}
|
|
1592
1568
|
}
|
|
1593
|
-
class
|
|
1569
|
+
class Ut {
|
|
1570
|
+
type = "region";
|
|
1571
|
+
x;
|
|
1572
|
+
y;
|
|
1573
|
+
shape;
|
|
1574
|
+
areaPoints;
|
|
1575
|
+
backgroundColor;
|
|
1594
1576
|
constructor(t) {
|
|
1595
|
-
o(this, "type", "region");
|
|
1596
|
-
o(this, "x");
|
|
1597
|
-
o(this, "y");
|
|
1598
|
-
o(this, "shape");
|
|
1599
|
-
o(this, "areaPoints");
|
|
1600
|
-
o(this, "backgroundColor");
|
|
1601
1577
|
if (this.x = t.x, this.y = t.y, this.shape = t.shape || "", this.backgroundColor = t.backgroundColor, t.areaPoints.length === 2) {
|
|
1602
|
-
const [{ x: e, y:
|
|
1578
|
+
const [{ x: e, y: i }, {}, { x: n, y: o }] = t.areaPoints;
|
|
1603
1579
|
this.areaPoints = [
|
|
1604
|
-
{ x: Math.min(e, n), y: Math.min(
|
|
1605
|
-
{ x: Math.max(e, n), y: Math.min(
|
|
1606
|
-
{ x: Math.max(e, n), y: Math.max(
|
|
1607
|
-
{ x: Math.min(e, n), y: Math.max(
|
|
1580
|
+
{ x: Math.min(e, n), y: Math.min(i, o) },
|
|
1581
|
+
{ x: Math.max(e, n), y: Math.min(i, o) },
|
|
1582
|
+
{ x: Math.max(e, n), y: Math.max(i, o) },
|
|
1583
|
+
{ x: Math.min(e, n), y: Math.max(i, o) }
|
|
1608
1584
|
];
|
|
1609
1585
|
} else
|
|
1610
1586
|
this.areaPoints = t.areaPoints;
|
|
1611
1587
|
}
|
|
1612
1588
|
draw(t, e) {
|
|
1613
1589
|
if (t.save(), t.beginPath(), t.globalAlpha = 0.3, t.fillStyle = this.backgroundColor, this.shape === "circle") {
|
|
1614
|
-
const [{ x:
|
|
1615
|
-
t.arc(
|
|
1590
|
+
const [{ x: i, y: n }, {}, { x: o, y: r }] = this.areaPoints, a = Math.abs(o - i) / 2, h = i + (o - i) / 2, l = n + (r - n) / 2;
|
|
1591
|
+
t.arc(h, l, a, 0, 2 * Math.PI);
|
|
1616
1592
|
} else
|
|
1617
|
-
this.areaPoints.forEach((
|
|
1618
|
-
const { x:
|
|
1619
|
-
n === 0 ? t.moveTo(
|
|
1593
|
+
this.areaPoints.forEach((i, n) => {
|
|
1594
|
+
const { x: o, y: r } = i;
|
|
1595
|
+
n === 0 ? t.moveTo(o, r) : t.lineTo(o, r);
|
|
1620
1596
|
});
|
|
1621
1597
|
t.fill(), t.restore();
|
|
1622
1598
|
}
|
|
1623
1599
|
}
|
|
1624
1600
|
export {
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1601
|
+
et as APP_SETTING,
|
|
1602
|
+
m as AppError,
|
|
1603
|
+
y as AppErrorCode,
|
|
1604
|
+
tt as AppObsType,
|
|
1605
|
+
Lt as CanvasElement,
|
|
1606
|
+
jt as CanvasImageElement,
|
|
1607
|
+
At as CanvasIssueElement,
|
|
1608
|
+
Xt as CanvasMarkerElement,
|
|
1609
|
+
kt as CanvasPointElement,
|
|
1610
|
+
Ft as CanvasRadarElement,
|
|
1611
|
+
Ut as CanvasRegionElement,
|
|
1612
|
+
It as Coordinate,
|
|
1613
|
+
K as CoordinateLevel,
|
|
1614
|
+
P as CoordinateModelType,
|
|
1615
|
+
D as CoordinateStatus,
|
|
1640
1616
|
M as CoordinateType,
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1617
|
+
w as DataSource,
|
|
1618
|
+
N as GeoPoint,
|
|
1619
|
+
f as Point,
|
|
1620
|
+
W as Position,
|
|
1621
|
+
g as RelativeMap,
|
|
1622
|
+
I as RequestContentType,
|
|
1647
1623
|
x as RequestMethod,
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1624
|
+
F as RequestResultCode,
|
|
1625
|
+
Q as Vector3,
|
|
1626
|
+
Ot as api,
|
|
1651
1627
|
Ct as http,
|
|
1652
|
-
|
|
1628
|
+
Rt as utils
|
|
1653
1629
|
};
|