@vsleem-realsee-viewer/shared 2.0.24 → 2.0.26
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/README.internal.md +2 -2
- package/dist/index.d.ts +4 -3
- package/dist/index.mjs +18 -21
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/README.internal.md
CHANGED
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
| ----- | -------- | ------ | -------- |
|
|
96
96
|
| `lat` | `number` | 0 | 经度(°) |
|
|
97
97
|
| `lon` | `number` | 0 | 纬度(°) |
|
|
98
|
-
| `alt` | `number` | 0 |
|
|
98
|
+
| `alt` | `number` | 0 | 海拔(mm) |
|
|
99
99
|
|
|
100
100
|
## 3.3 方法说明
|
|
101
101
|
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
| `z` | `number` | 0 | Z轴坐标 |
|
|
151
151
|
| `lat` | `number` | 0 | 经度 |
|
|
152
152
|
| `lon` | `number` | 0 | 纬度 |
|
|
153
|
-
| `alt` | `number` | 0 |
|
|
153
|
+
| `alt` | `number` | 0 | 海拔 |
|
|
154
154
|
| `yaw` | `number` | 0 | 偏航角 |
|
|
155
155
|
| `pitch` | `number` | 0 | 俯仰角 |
|
|
156
156
|
| `roll` | `number` | 0 | 翻滚角 |
|
package/dist/index.d.ts
CHANGED
|
@@ -569,7 +569,7 @@ declare function error(message: string): void;
|
|
|
569
569
|
export declare class GeoPoint {
|
|
570
570
|
lat: number; /** 经度 */
|
|
571
571
|
lon: number; /** 纬度 */
|
|
572
|
-
alt: number; /**
|
|
572
|
+
alt: number; /** 海拔 */
|
|
573
573
|
constructor(options?: Partial<GeoPoint>);
|
|
574
574
|
static XYZToLLH(p: Point, refPoint: GeoPoint): GeoPoint;
|
|
575
575
|
static LLHToXYZ(p: Point, refPoint: GeoPoint): Point;
|
|
@@ -690,7 +690,7 @@ declare type MappingRecord = {
|
|
|
690
690
|
|
|
691
691
|
/**
|
|
692
692
|
* 点类,表示二维或三维空间中的点
|
|
693
|
-
* 支持直角坐标系(x,y,z)和地理坐标系(
|
|
693
|
+
* 支持直角坐标系(x,y,z)和地理坐标系(经度,纬度,海拔)
|
|
694
694
|
*/
|
|
695
695
|
export declare class Point {
|
|
696
696
|
/** 直角坐标系坐标 */
|
|
@@ -700,7 +700,7 @@ export declare class Point {
|
|
|
700
700
|
/** 地理坐标系坐标 */
|
|
701
701
|
lat: number; /** 经度 (longitude) */
|
|
702
702
|
lon: number; /** 纬度 (latitude) */
|
|
703
|
-
alt: number; /**
|
|
703
|
+
alt: number; /** 海拔 (altitude) */
|
|
704
704
|
/** 欧拉角 */
|
|
705
705
|
yaw: number; /** 偏航角 */
|
|
706
706
|
pitch: number; /** 俯仰角 */
|
|
@@ -844,6 +844,7 @@ export declare class RelativeMap {
|
|
|
844
844
|
static inverseRelativeMap(r: RelativeMap): RelativeMap;
|
|
845
845
|
static toParse(r?: string): RelativeMap | undefined;
|
|
846
846
|
static toStringify(r?: RelativeMap): string | undefined;
|
|
847
|
+
static isValid(val?: string): boolean | "" | undefined;
|
|
847
848
|
}
|
|
848
849
|
|
|
849
850
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -181,7 +181,7 @@ function mt(s) {
|
|
|
181
181
|
function yt(s) {
|
|
182
182
|
return E(s, "String");
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function k(s) {
|
|
185
185
|
return typeof s == "function";
|
|
186
186
|
}
|
|
187
187
|
function wt(s) {
|
|
@@ -209,7 +209,7 @@ function vt(s) {
|
|
|
209
209
|
return H(s) || V(s);
|
|
210
210
|
}
|
|
211
211
|
function bt(s) {
|
|
212
|
-
return E(s, "Promise") && S(s) &&
|
|
212
|
+
return E(s, "Promise") && S(s) && k(s.then) && k(s.catch);
|
|
213
213
|
}
|
|
214
214
|
function W(s) {
|
|
215
215
|
return z(s, /* @__PURE__ */ new WeakMap());
|
|
@@ -281,13 +281,13 @@ function St(s, t, e = !1) {
|
|
|
281
281
|
clearTimeout(i), i = void 0, n = void 0;
|
|
282
282
|
}, o;
|
|
283
283
|
}
|
|
284
|
-
function
|
|
284
|
+
function j(s, ...t) {
|
|
285
285
|
if (!t.length) return s;
|
|
286
286
|
const e = t.shift();
|
|
287
287
|
return e === void 0 ? s : (C(s) && C(e) && Object.keys(e).forEach((i) => {
|
|
288
288
|
const n = s[i], o = e[i];
|
|
289
|
-
Array.isArray(n) && Array.isArray(o) ? s[i] = [...n, ...o] : C(n) && C(o) ? s[i] =
|
|
290
|
-
}),
|
|
289
|
+
Array.isArray(n) && Array.isArray(o) ? s[i] = [...n, ...o] : C(n) && C(o) ? s[i] = j({ ...n }, o) : o !== void 0 && (s[i] = o);
|
|
290
|
+
}), j(s, ...t));
|
|
291
291
|
}
|
|
292
292
|
function C(s) {
|
|
293
293
|
return s !== null && typeof s == "object" && !Array.isArray(s);
|
|
@@ -404,11 +404,11 @@ function Rt(s) {
|
|
|
404
404
|
function Ot(s) {
|
|
405
405
|
throw new Error(`[error]:${s}`);
|
|
406
406
|
}
|
|
407
|
-
const
|
|
407
|
+
const kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
408
408
|
__proto__: null,
|
|
409
409
|
cloneDeep: W,
|
|
410
410
|
debounce: Tt,
|
|
411
|
-
deepMerge:
|
|
411
|
+
deepMerge: j,
|
|
412
412
|
deepMergeProps: Q,
|
|
413
413
|
error: Ot,
|
|
414
414
|
getDiffProps: K,
|
|
@@ -420,7 +420,7 @@ const jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
420
420
|
isDate: mt,
|
|
421
421
|
isDef: J,
|
|
422
422
|
isElement: xt,
|
|
423
|
-
isFunction:
|
|
423
|
+
isFunction: k,
|
|
424
424
|
isNull: V,
|
|
425
425
|
isNullOrUnDef: vt,
|
|
426
426
|
isNumeric: I,
|
|
@@ -449,7 +449,7 @@ class f {
|
|
|
449
449
|
lon = 0;
|
|
450
450
|
/** 纬度 (latitude) */
|
|
451
451
|
alt = 0;
|
|
452
|
-
/**
|
|
452
|
+
/** 海拔 (altitude) */
|
|
453
453
|
/** 欧拉角 */
|
|
454
454
|
yaw = 0;
|
|
455
455
|
/** 偏航角 */
|
|
@@ -557,8 +557,6 @@ class f {
|
|
|
557
557
|
return new f(this);
|
|
558
558
|
if (e?.modelType === b.GeoModel) {
|
|
559
559
|
const { refPoint: n } = e?.relativeMap || {};
|
|
560
|
-
if (this?.hasXYZ)
|
|
561
|
-
return this.project(t);
|
|
562
560
|
if (this.hasGeo && n) {
|
|
563
561
|
const o = N.LLHToXYZ(this, n);
|
|
564
562
|
return this.x = o.x, this.y = o.y, this.z = o.z, this.hasXYZ = !0, this.project(t);
|
|
@@ -566,10 +564,7 @@ class f {
|
|
|
566
564
|
throw new w(p.PointUnmappedGIS, "没有完成GIS与其他空间的映射");
|
|
567
565
|
}
|
|
568
566
|
if (i?.modelType === b.GeoModel) {
|
|
569
|
-
const { refPoint: n } = i?.relativeMap || {};
|
|
570
|
-
if (this?.hasGeo)
|
|
571
|
-
return new f(this);
|
|
572
|
-
const o = this.project(t);
|
|
567
|
+
const { refPoint: n } = i?.relativeMap || {}, o = this.project(t);
|
|
573
568
|
if (o?.hasXYZ && n) {
|
|
574
569
|
const r = N.XYZToLLH(o, n);
|
|
575
570
|
return o.lat = r.lat, o.lon = r.lon, o.alt = r.alt, o.hasGeo = !0, o;
|
|
@@ -626,7 +621,7 @@ class N {
|
|
|
626
621
|
lon = 0;
|
|
627
622
|
/** 纬度 */
|
|
628
623
|
alt = 0;
|
|
629
|
-
/**
|
|
624
|
+
/** 海拔 */
|
|
630
625
|
constructor(t) {
|
|
631
626
|
const { lat: e = 0, lon: i = 0, alt: n = 0 } = t || {};
|
|
632
627
|
this.lat = Number(e) || 0, this.lon = Number(i) || 0, this.alt = Number(n) || 0;
|
|
@@ -749,6 +744,9 @@ class y {
|
|
|
749
744
|
static toStringify(t) {
|
|
750
745
|
return t ? JSON.stringify(t) : void 0;
|
|
751
746
|
}
|
|
747
|
+
static isValid(t) {
|
|
748
|
+
return t && t !== '{"scale":1.0, "yaw":0.0, "x":0.0, "y":0.0, "z":0.0}';
|
|
749
|
+
}
|
|
752
750
|
}
|
|
753
751
|
class m {
|
|
754
752
|
/**
|
|
@@ -1022,8 +1020,7 @@ class R {
|
|
|
1022
1020
|
}
|
|
1023
1021
|
/** 来自映射(被映射过的源坐标系关系) */
|
|
1024
1022
|
async getMapping() {
|
|
1025
|
-
|
|
1026
|
-
return t[t.length - 1];
|
|
1023
|
+
return (await q({ srcCsId: this.id }))[0];
|
|
1027
1024
|
}
|
|
1028
1025
|
/**
|
|
1029
1026
|
* 递归寻找到根坐标系
|
|
@@ -1281,7 +1278,7 @@ class et {
|
|
|
1281
1278
|
return t ? `${t.x},${t.y},${t.z}` : "";
|
|
1282
1279
|
}
|
|
1283
1280
|
}
|
|
1284
|
-
class
|
|
1281
|
+
class jt {
|
|
1285
1282
|
/**
|
|
1286
1283
|
* 将源坐标系中的点转换到目标坐标系中
|
|
1287
1284
|
* @param points 需要转换的点数组
|
|
@@ -1713,7 +1710,7 @@ export {
|
|
|
1713
1710
|
b as CoordinateModelType,
|
|
1714
1711
|
O as CoordinateStatus,
|
|
1715
1712
|
M as CoordinateType,
|
|
1716
|
-
|
|
1713
|
+
jt as DataHelper,
|
|
1717
1714
|
m as DataSource,
|
|
1718
1715
|
N as GeoPoint,
|
|
1719
1716
|
f as Point,
|
|
@@ -1727,5 +1724,5 @@ export {
|
|
|
1727
1724
|
et as Vector3,
|
|
1728
1725
|
At as api,
|
|
1729
1726
|
Lt as http,
|
|
1730
|
-
|
|
1727
|
+
kt as utils
|
|
1731
1728
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(l=typeof globalThis<"u"?globalThis:l||self,M(l.Shared={}))})(this,(function(l){"use strict";var M=(s=>(s[s.CADModel=5]="CADModel",s[s.BIMModel=6]="BIMModel",s[s.ForgeModel=7]="ForgeModel",s[s.ThreeDModel=8]="ThreeDModel",s[s.GeoModel=9]="GeoModel",s[s.ScaleModel=101]="ScaleModel",s))(M||{}),Y=(s=>(s[s.Global=0]="Global",s))(Y||{}),x=(s=>(s[s.Space=0]="Space",s[s.Model=1]="Model",s[s.Data=2]="Data",s))(x||{}),N=(s=>(s[s.Used=0]="Used",s[s.Enabled=1]="Enabled",s[s.Disabled=2]="Disabled",s))(N||{}),j=(s=>(s[s.SUCCESS=200]="SUCCESS",s[s.ERROR=-1]="ERROR",s[s.TIMEOUT=401]="TIMEOUT",s))(j||{}),v=(s=>(s.GET="GET",s.POST="POST",s))(v||{}),R=(s=>(s.JSON="application/json",s.FORM_URLENCODED="application/x-www-form-urlencoded;charset=UTF-8",s.FORM_DATA="multipart/form-data;charset=UTF-8",s.OCTET_STREAM="'application/octet-stream",s))(R||{}),B=(s=>(s.Hw="huawei",s.Ali="aliyun",s.Hs="hs",s.Aws="amazon",s.Minio="minio",s))(B||{}),g=(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))(g||{});const $={baseUrl:"https://vsleem.com/api",authorizeCode:""},_={isTransformResponse:!0,joinBaseUrl:!0,withAuthorize:!0},q={url:"",method:v.GET,headers:{}};class y extends Error{constructor(t,e,i){super(e),this.code=t,this.message=e,this.details=i,this.name="Apprror",Object.setPrototypeOf(this,y.prototype)}toJSON(){return{code:this.code,message:this.message,details:this.details,timestamp:new Date().toISOString()}}}const Z={...$};function ht(s){const{baseUrl:t,authorizeCode:e}=s;Object.assign(Z,{baseUrl:t,authorizeCode:e})}async function S(s,t){const e={..._,...t},i={...q,...s};try{const n=ct(i,e),{url:o,...r}=n,c=await(await window.fetch(o,r)).json();return lt(c,e)}catch(n){return ut(n)}}function ct(s,t){const{baseUrl:e,authorizeCode:i}=Z,{joinBaseUrl:n,withAuthorize:o}=t;let{url:r,method:a,headers:c={},params:u,data:h}=s;n&&e&&(r=`${e}${r}`),a=a?.toUpperCase();const d={...c};if(/^https?:\/\/.+$/i.test(e??"")?d.PlatForm=new URL(e??"").host:d.PlatForm=new URL(window.location.href).host,o&&i&&(d.AuthorizationCode=i),a===v.POST&&!d["Content-Type"]&&(d["Content-Type"]=R.JSON),a===v.GET&&u){const C=new URLSearchParams(u),b=r.includes("?")?"&":"?";r+=b+`${C.toString()}`}let m;return a===v.POST&&(m=d["Content-Type"]===R.JSON?JSON.stringify(h||{}):h),{url:r,method:a,headers:d,body:m}}function lt(s,t){if(!t.isTransformResponse)return s;if(!s)throw new y(g.RequestResultError,"请求返回的结果错误");const{code:e,data:i,msg:n}=s;if(e===j.SUCCESS)return i;throw new y(g.RequestCodeError,n||"请求返回的Code错误")}function ut(s){throw s instanceof Error?s:new y(g.RequestUnknownError,typeof s=="string"?s:"未知的请求错误")}const dt=Object.freeze(Object.defineProperty({__proto__:null,request:S,setRequestGlobalConfig:ht},Symbol.toStringTag,{value:"Module"}));function J(s,t){return S({url:"/project/jssdk/cs/list",method:v.GET,params:s},t)}function H(s,t){return S({url:"/project/jssdk/cs/bind",method:v.POST,data:s},t)}function k(s,t){return S({url:"/project/jssdk/cs/save",method:v.POST,data:s},t)}function V(s,t){return S({url:"/project/jssdk/cs/delete",method:v.POST,data:s},t)}function Q(s,t){return S({url:"/project/jssdk/cs/mapping",method:v.POST,data:s},t)}function W(s,t){return S({url:"/project/jssdk/cs/mapping/query",method:v.GET,params:s},t)}function ft(s,t={isTransformResponse:!1,joinBaseUrl:!1,withAuthorize:!1}){return S({url:s,method:v.GET},t)}const mt=Object.freeze(Object.defineProperty({__proto__:null,bindCoordinate:H,getCoordinateList:J,getImageInfo:ft,getMappingRelation:W,mapingCoordinate:Q,removeCoordinate:V,saveCoordinate:k},Symbol.toStringTag,{value:"Module"})),yt=typeof window<"u",wt=Object.prototype.toString;function P(s,t){return wt.call(s)===`[object ${t}]`}function K(s){return typeof s<"u"}function tt(s){return!K(s)}function E(s){return s!==null&&P(s,"Object")}function et(s){return s===null}function pt(s){return P(s,"Date")}function gt(s){return P(s,"String")}function X(s){return typeof s=="function"}function Mt(s){return P(s,"Boolean")}function vt(s){return P(s,"RegExp")}function T(s){return s&&Array.isArray(s)}function xt(s){return typeof window<"u"&&P(s,"Window")}function Tt(s){return E(s)&&!!s.tagName}function O(s){return typeof s=="number"?!0:typeof s!="string"?!1:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/.test(s)}function bt(s,t){return JSON.stringify(s)===JSON.stringify(t)}function St(s){return tt(s)||et(s)}function Pt(s){return P(s,"Promise")&&E(s)&&X(s.then)&&X(s.catch)}function st(s){return D(s,new WeakMap)}function D(s,t){if(typeof s!="object"||s===null)return s;if(t.has(s))return t.get(s);let e;if(s instanceof Date)return e=new Date(s),t.set(s,e),e;if(s instanceof RegExp)return e=new RegExp(s),t.set(s,e),e;if(s instanceof Map)return e=new Map,t.set(s,e),s.forEach((n,o)=>{e.set(o,D(n,t))}),e;if(s instanceof Set)return e=new Set,t.set(s,e),s.forEach(n=>{e.add(D(n,t))}),e;if(ArrayBuffer.isView(s))return e=new s.constructor(s.buffer.slice(0),s.byteOffset,s.byteLength),t.set(s,e),e;if(s instanceof ArrayBuffer)return e=s.slice(0),t.set(s,e),e;if(Array.isArray(s)){e=[],t.set(s,e);for(let n=0;n<s.length;n++)n in s&&(e[n]=D(s[n],t));return e}e=Object.create(Object.getPrototypeOf(s)),t.set(s,e);for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=D(s[n],t));const i=Object.getOwnPropertySymbols(s);for(const n of i)Object.prototype.propertyIsEnumerable.call(s,n)&&(e[n]=D(s[n],t));return e}function Et(s,t,e=!1){let i;const n=function(...o){const r=this,a=e&&!i;i&&clearTimeout(i),i=setTimeout(()=>{i=void 0,e||s.apply(r,o)},t),a&&s.apply(r,o)};return n.cancel=()=>{i&&clearTimeout(i),i=void 0},n}function Ct(s,t,e=!1){let i,n;const o=function(...r){const a=this;n?(clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=t&&(s.apply(a,r),n=Date.now())},t-(Date.now()-n))):(e&&s.apply(a,r),n=Date.now())};return o.cancel=()=>{clearTimeout(i),i=void 0,n=void 0},o}function F(s,...t){if(!t.length)return s;const e=t.shift();return e===void 0?s:(L(s)&&L(e)&&Object.keys(e).forEach(i=>{const n=s[i],o=e[i];Array.isArray(n)&&Array.isArray(o)?s[i]=[...n,...o]:L(n)&&L(o)?s[i]=F({...n},o):o!==void 0&&(s[i]=o)}),F(s,...t))}function L(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function it(s,...t){if(!t.length)return s;for(const e of t)e!=null&&typeof e=="object"&&Object.keys(e).forEach(i=>{const n=e[i],o=s[i];n!==null&&typeof n=="object"&&!Array.isArray(n)?((!o||typeof o!="object")&&(s[i]={}),it(s[i],n)):s[i]=n});return s}function nt(s,t){const e={};if(E(s)&&!T(s)){for(const i in s)if(Object.prototype.hasOwnProperty.call(s,i)){const n=s[i],o=E(t)&&!T(t)?t[i]:void 0;if(!(i in(t||{})))e[i]=n;else if(T(n)&&T(o))JSON.stringify(n)!==JSON.stringify(o)&&(e[i]=n);else if(E(n)&&E(o)){const r=nt(n,o);r&&Object.keys(r).length>0&&(e[i]=r)}else n!==o&&(e[i]=n)}}if(E(t)&&T(t))for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&!(i in(s||{}))&&(e[i]=void 0);return e}function Dt(s,t={}){return new Promise((e,i)=>{const n=z(s);if(zt(n)){e(!0);return}const o=document.createElement("script");o.src=s,Object.entries(t).forEach(([r,a])=>{a!==!1&&o.setAttribute(r,a===!0?"":String(a))}),o.onload=()=>{e(!0)},o.onerror=()=>{document.head.removeChild(o),i(new Error(`Failed to load script: ${s}`))},document.head.appendChild(o)})}function zt(s){const t=z(s);return Array.from(document.scripts).some(e=>z(e.src)===t)}function It(s){return new Promise((t,e)=>{const i=z(s);if(Nt(i)){t(!0);return}const n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=s,n.onload=()=>{t(!0)},n.onerror=()=>{document.head.removeChild(n),e(new Error(`Failed to load link: ${s}`))},document.head.appendChild(n)})}function Nt(s){const t=z(s);return Array.from(document.querySelectorAll('link[rel="stylesheet"]')).some(e=>z(e.href)===t)}function z(s){try{const t=new URL(s,window.location.href);return`${t.origin}${t.pathname}`}catch{return s}}function Rt(s,t,e,i){const n=Math.min(s/e,t/i),o=e*n,r=i*n;return{scale:n,x:(s-o)/2,y:(t-r)/2,sw:o,sh:r}}function Ot(s,t,e){return{x:s*e.scale+e.x,y:t*e.scale+e.y}}function Lt(s,t,e){return{x:(s-e.x)/e.scale,y:(t-e.y)/e.scale}}function At(s){console.warn(`[warn]:${s}`)}function jt(s){throw new Error(`[error]:${s}`)}const kt=Object.freeze(Object.defineProperty({__proto__:null,cloneDeep:st,debounce:Et,deepMerge:F,deepMergeProps:it,error:jt,getDiffProps:nt,getImageTransform:Rt,inBrowser:yt,is:P,isArray:T,isBoolean:Mt,isDate:pt,isDef:K,isElement:Tt,isFunction:X,isNull:et,isNullOrUnDef:St,isNumeric:O,isObject:E,isPromise:Pt,isRegExp:vt,isSameValue:bt,isString:gt,isUnDef:tt,isWindow:xt,loadCss:It,loadScript:Dt,throttle:Ct,toCanvasCoord:Ot,toModelCoord:Lt,warn:At},Symbol.toStringTag,{value:"Module"}));class f{x=0;y=0;z=0;lat=0;lon=0;alt=0;yaw=0;pitch=0;roll=0;hasXYZ=!1;hasGeo=!1;hasAngle=!1;plane="xy";constructor(t){const{x:e,y:i,z:n,lat:o,lon:r,alt:a,yaw:c,pitch:u,roll:h,plane:d="xy"}=t||{};this.x=Number(e)||0,this.y=Number(i)||0,this.z=Number(n)||0,(this.x!==0||this.y!==0||this.z!==0)&&(this.plane=d,this.hasXYZ=!0),this.lat=Number(o)||0,this.lon=Number(r)||0,this.alt=Number(a)||0,(this.lat!==0||this.lon!==0||this.alt!==0)&&(this.hasGeo=!0),this.yaw=Number(c)||0,this.pitch=Number(u)||0,this.roll=Number(h)||0,(O(c)||O(u)||O(h))&&(this.hasAngle=!0)}static dist(t,e){return Math.hypot(t.x-e.x,t.y-e.y,t.z-e.z)}static distXZ(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}static distXY(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}static toRadians(t){return(Number(t)||0)*Math.PI/180}static toDegrees(t){return(Number(t)||0)*180/Math.PI}static angleXZ(t,e,i){const n={x:t.x-e.x,z:t.z-e.z},o={x:i.x-e.x,z:i.z-e.z},r=n.x*o.x+n.z*o.z,a=Math.sqrt(n.x**2+n.z**2),c=Math.sqrt(o.x**2+o.z**2),u=Math.max(-1,Math.min(1,r/(a*c))),d=Math.acos(u)*180/Math.PI;return Math.min(d,360-d)}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new f({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}projection(t,e,i){try{if(e?.id===i?.id)return new f(this);if(e?.modelType===M.GeoModel){const{refPoint:n}=e?.relativeMap||{};if(this?.hasXYZ)return this.project(t);if(this.hasGeo&&n){const o=I.LLHToXYZ(this,n);return this.x=o.x,this.y=o.y,this.z=o.z,this.hasXYZ=!0,this.project(t)}throw new y(g.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}if(i?.modelType===M.GeoModel){const{refPoint:n}=i?.relativeMap||{};if(this?.hasGeo)return new f(this);const o=this.project(t);if(o?.hasXYZ&&n){const r=I.XYZToLLH(o,n);return o.lat=r.lat,o.lon=r.lon,o.alt=r.alt,o.hasGeo=!0,o}throw new y(g.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}return this.project(t)}catch(n){console.error(n);return}}project(t){if(!this.hasXYZ)throw new y(g.PointNoXYZ,"点没有xxz坐标信息");if(this.plane==="xz")return this.projectXZ(t);if(this.plane==="xy")return this.projectXY(t);throw new y(g.PointNoPlane,"点的plane应为xz或xy")}projectXZ(t){const e=new f(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const i=e.x*Math.cos(t.yaw)-e.z*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.z*Math.cos(t.yaw);return e.x=i+t.x,e.y+=t.y,e.z=n+t.z,e}projectXY(t){const e=new f(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const i=e.x*Math.cos(t.yaw)-e.y*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.y*Math.cos(t.yaw);return e.x=i+t.x,e.y=n+t.y,e.z+=t.z,e}}class I{lat=0;lon=0;alt=0;constructor(t){const{lat:e=0,lon:i=0,alt:n=0}=t||{};this.lat=Number(e)||0,this.lon=Number(i)||0,this.alt=Number(n)||0}static XYZToLLH(t,e){const n=.0033528106647474805,o=n*(2-n),r=f.toRadians(e.lat),a=6378137/Math.sqrt(1-o*Math.sin(r)**2)+e.alt;let c,u,h;if(t.plane==="xz"){const d=t.x/1e3/(a*Math.cos(r)),m=t.z/1e3/a;c=e.lon+f.toDegrees(d),u=e.lat-f.toDegrees(m),h=e.alt+t.y/1e3}else if(t.plane==="xy"){const d=t.x/1e3/(a*Math.cos(r)),m=t.y/1e3/a;c=e.lon+f.toDegrees(d),u=e.lat-f.toDegrees(m),h=e.alt+t.z/1e3}else throw new y(g.GeoPointNoPlane,"点的plane应为xz或xy");return new I({lat:u,lon:c,alt:h})}static LLHToXYZ(t,e){const n=.0033528106647474805,o=n*(2-n),r=f.toRadians(e.lat),a=6378137/Math.sqrt(1-o*Math.sin(r)**2)+e.alt,c=f.toRadians(t.lon-e.lon),u=f.toRadians(e.lat-t.lat),h=a*c*Math.cos(r),d=a*u;if(t.plane==="xz")return new f({x:h*1e3,y:(t.alt-e.alt)*1e3,z:d*1e3,plane:"xz"});if(t.plane==="xy")return new f({x:h*1e3,y:d*1e3,z:(t.alt-e.alt)*1e3,plane:"xy"});throw new y(g.GeoPointNoPlane,"点的plane应为xz或xy")}}class w{scale=1;yaw=0;x=0;y=0;z=0;start=0;end=-1;plane="xy";refPoint;constructor(t){const{refPoint:e,...i}=t||{};e&&(this.refPoint=new I(e)),Object.assign(this,i)}static addRelativeMap(t,e){if(t.plane!==e.plane)throw new y(g.RelativePlaneUnmatch,"两个映射关系的plane应该相同");const i=t.scale*e.scale,n=t.yaw+e.yaw,o=Math.cos(e.yaw),r=Math.sin(e.yaw);let a=0,c=0,u=0;if(t.plane==="xz"){const h=t.x*o-t.z*r,d=t.y,m=t.x*r+t.z*o;a=e.x+h*e.scale,c=e.y+d*e.scale,u=e.z+m*e.scale}else if(t.plane==="xy"){const h=t.x*o-t.y*r,d=t.x*r+t.y*o,m=t.z;a=e.x+h*e.scale,c=e.y+d*e.scale,u=e.z+m*e.scale}else throw new y(g.RelativeNoPlane,"映射关系的plane应为xz或xy");return new w({scale:i,yaw:n,x:a,y:c,z:u,start:t.start,end:t.end,plane:t.plane})}static inverseRelativeMap(t){const e=1/t.scale,i=-t.yaw,n=Math.cos(-i),o=Math.sin(-i);let r=0,a=0,c=0;if(t.plane==="xz")r=-(t.x*n+t.z*o)*e,a=-t.y*e,c=-(t.z*n-t.x*o)*e;else if(t.plane==="xy")r=-(t.x*n+t.y*o)*e,a=-(t.y*n-t.x*o)*e,c=-t.z*e;else throw new y(g.RelativeNoPlane,"映射关系的plane应为xz或xy");return new w({scale:e,yaw:i,x:r,y:a,z:c,start:t.start,end:t.end,plane:t.plane})}static toParse(t){try{let e=t?JSON.parse(t):void 0;const{reference_point:i}=e||{};return i&&(e={refPoint:i}),e?new w(e):void 0}catch{throw new y(g.RelativeJsonError,"relativeMap格式化失败")}}static toStringify(t){return t?JSON.stringify(t):void 0}}class p{static async getCoordinateTree(t){const e=await J({projectId:t});if(e.length){const i=p.handleCoordinateList(e);return p.buildCoordinateTree(i,0)}}static parsedCoordinateTree(t){const e=p.flattenCoordinateTree(t);return p.buildCoordinateTree(e,0)}static async addCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{type:c,modelType:u,relativeMap:h,level:d,...m}=a,C=h?JSON.stringify(h):void 0;return{...m,projectId:i,parentId:n,coordinateType:c,renderType:u,relativePosition:C}}),r=await k(o);return p.handleCoordinateList(r)}static async removeCoordinate(t,e){const i=e.map(n=>n.id??-1);return await V(i)}static async updateCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{type:c,relativeMap:u,level:h,...d}=a,m=w.toStringify(u);return{...d,relativePosition:m,projectId:i,parentId:n}}),r=await k(o);return p.handleCoordinateList(r)}static async bindCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{modelId:c}=a;return{modelId:c,parentId:n,projectId:i}}),r=await H(o);return p.handleCoordinateList(r)}static handleCoordinateList(t){return t?.map(e=>{const{coordinateType:i,modelKey:n,renderType:o,relativePosition:r,...a}=e,c=o===M.GeoModel?new w(w.toParse(r)):w.toParse(r);return new A({...a,type:i,modelType:o,modelValue:n,relativeMap:c})})}static flattenCoordinateTree(t){const e=Array.isArray(t)?t:[t],i=[];function n(o){for(const r of o){const{level:a,parent:c,relativeMap:u,...h}=r,d=new A({...h,relativeMap:new w(u)});i.push(d),r.children&&r.children.length>0&&n(r.children)}}return n(e),i}static buildCoordinateTree(t,e=0){const i=new Map,n=[];return t.forEach(o=>{i.set(String(o.id),o)}),t.forEach(o=>{const r=i.get(String(o.id));if(r)if(o.parentId===e)r.level=0,n.push(r);else{const a=i.get(String(o.parentId??-1));a&&(r.type===x.Space&&(r.level=(Number(a.level)||0)+1),r.parent=a,a.children?.push(r))}}),n.forEach(p.sortCoordinateTree),n[0]}static sortCoordinateTree(t){t.children&&(t.children.sort((e,i)=>{if(e.type===x.Space){const n=Number(i?.relativeMap?.z)-Number(e?.relativeMap?.z);return n!==0?n:Number(i.createTime)-Number(e.createTime)}else return e.status===0&&i.status!==0?-1:i.status===0&&e.status!==0?1:Number(i.createTime)-Number(e.createTime)}),t.children.forEach(p.sortCoordinateTree))}static filterSpaceTree(t,e){const i=[];return t.forEach(n=>{const o=new A(n);e&&(o.parent=e);const r=p.filterSpaceTree(o.children,o);o.children=r,o.disabled=o.disabled??!1,o.type!==x.Model&&i.push(o)}),i}}class A{id=0;type=0;children=[];level;relativeMap;no;name;shortName;status;modelId;modelType;modelValue;projectId;parentId;parent;groupUuid;z;createTime;disabled;constructor(t){this.setOptions(t)}get spaceList(){return this.children.filter(t=>t.type===x.Space)}get modelList(){return this.children.filter(t=>t.type===x.Model)}get fullName(){const t=this.name?`(${this.name})`:"";return this.shortName?`${this.shortName}${t}`:this.name??""}setOptions(t){const{relativeMap:e,parent:i,children:n,...o}=t||{};e&&(this.relativeMap=new w(e)),i&&(this.parent=i),n?.length&&(this.children=n),Object.assign(this,o)}async addChild(t){const e=T(t)?t:[t],i=await p.addCoordinate(this,e);return this.mergeChild(i),i}async removeChild(t){const e=T(t)?t:[t];await p.removeCoordinate(this,e);for(const i of e){const n=this.children.findIndex(o=>o.id===i.id);n!==-1&&this.children.splice(n,1)}}async updateChild(t){const e=T(t)?t:[t],i=await p.updateCoordinate(this,e);return this.mergeChild(i),i}async bindChild(t){const e=T(t)?t:[t],i=await p.bindCoordinate(this,e);return this.mergeChild(i),i}async mergeChild(t){t?.length&&t.forEach(e=>{const i=this.children.find(n=>n.id===e.id);if(i){const{relativeMap:n,no:o,name:r,shortName:a,status:c,modelId:u,modelValue:h}=e;Object.assign(i,{relativeMap:n,no:o,name:r,shortName:a,status:c,modelId:u,modelValue:h})}else this.id===e.parentId&&(e.parent=this,this.children.unshift(e))})}async mappingTo(t){await Q(t)}async getMapping(){const t=await W({srcCsId:this.id});return t[t.length-1]}findRoot(t=!1){let e=this;for(;e.parent&&!(t&&!e.relativeMap);)e=e.parent;return e}findChildModel(t,e=!0){const i=T(t)?t:[t];return i.includes(this.modelType??-1)&&this.status!==N.Disabled?this:([x.Data,x.Model].includes(this.type)?this.findParentSpace():this)?.modelList?.filter(a=>i.includes(a.modelType??-1)?e?!!a.relativeMap:!0:!1)?.sort((a,c)=>Number(a.status)-Number(c.status))?.[0]}findClosestModel(t=[M.CADModel,M.BIMModel,M.ForgeModel,M.ThreeDModel,M.GeoModel],e){const i=T(t)?t:[t],n=new Set;e?.forEach(h=>{n.add(String(h.id))});const o=[{node:this,distance:0}],r=new Set,a=[];for(;o.length>0;){const{node:h,distance:d}=o.shift();if(n.has(String(h.id))||r.has(h))continue;const m=h.modelType??-1;i.includes(m)&&a.push({node:h,distance:d,modelType:m}),r.add(h);const C=[];if(h.children)for(const b of h.children)r.has(b)||C.push(b);if(h.parent?.children)for(const b of h.parent.children)b!==h&&!r.has(b)&&C.push(b);h.parent&&!r.has(h.parent)&&C.push(h.parent);for(const b of C)o.push({node:b,distance:d+1})}if(a.length===0)return;const c=Math.min(...a.map(h=>h.distance)),u=a.filter(h=>h.distance===c);return u.sort((h,d)=>h.modelType-d.modelType),u[0]?.node}findParentSpace(){let t=this;for(;t&&t.type!==x.Space;)t=t.parent;return t}findParentSpaceNames(t=2){const e=[];let i=this;for(;i&&t>0;)i.type===x.Space&&(e.unshift(i.fullName),t--),i=i.parent;return e}findCsGroup(){const{groupUuid:t,parent:e}=this;return t?e?.children?.filter(i=>i.groupUuid===t)||[]:[]}findCsByLevel(t){if(this.level===t)return this;if(this.children.length)for(const e of this.children){const i=e.findCsByLevel(t);if(i)return i}}findCsById(t){if(t){if(this.id===t)return this;for(const e of this.children){const i=e.findCsById(t);if(i)return i}}}getCsRoutes(t=!1){let e=this;const i=[e];for(;e?.parent&&!(t&&!e.relativeMap);)e=e.parent,e&&i.push(e);return i}getMappedCsTree(){function t(n){return n.children?.length&&(n.children=n.children.filter(o=>!!o?.relativeMap&&o.status!==N.Disabled).map(o=>t(o))),n}const e=st(this.findRoot(!0)),i=t(e);return i.parentId=0,i.parent=void 0,i}getDestRelativeMap(t){if(this.id===t.id)return new w;const e=this.getRelativeMaps(),i=t.getRelativeMaps();let n=new w;return e?.forEach(o=>{n=w.addRelativeMap(n,o)}),i?.reverse()?.forEach(o=>{n=w.addRelativeMap(n,w.inverseRelativeMap(o))}),n}getRelativeMaps(){let t=this;const e=[];for(;t?.parent&&t.relativeMap;)e.push(t.relativeMap),t=t.parent;return e}static filterCoordinateTree(t,e=[],i=[]){if(i.includes(t.id)||e.includes(t.type))return;const n=t.children?.map(o=>this.filterCoordinateTree(o,e,i)).filter(o=>o!==void 0);return{...t,children:n}}static getCommonCoordinate(t){let e;const i=t.map(n=>n.getCsRoutes(!0).filter(r=>r.id&&r.type===x.Space));for(;this.checkSameCoordinate(i);){const o=i.shift();o?.length&&(e=o[0])}return e}static checkSameCoordinate(t){if(t.length){if(t.length===1)return!0;for(let e=0;e<t.length-1;e++){const i=t[e];if(!i?.length)return!1;const n=t[e+1];if(!n?.length||i[0].id!==n[0].id)return!1}return!0}else return!1}}class U{yaw=0;pitch=0;roll=0;constructor(t){const{yaw:e=0,pitch:i=0,roll:n=0}=t||{};this.yaw=Number(e)||0,this.pitch=Number(i)||0,this.roll=Number(n)||0}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new U({yaw:e[0],pitch:e[1],roll:e[2]})}}static toStringify(t){return t?`${t.yaw},${t.pitch},${t.roll}`:""}}class G{x=0;y=0;z=0;constructor(t){const{x:e=0,y:i=0,z:n=0}=t||{};this.x=Number(e)||0,this.y=Number(i)||0,this.z=Number(n)||0}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new G({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}}class Xt{static srcPointToDstPoint(t,e,i){if(!e||!i||!t?.length)return[];const n=e?.getDestRelativeMap(i);if(!n)return[];const o=[];return t.forEach(r=>{const a=r.projection(n,e,i);a&&o.push(a)}),o}}class Ft{canvas;ctx;options;offset={x:0,y:0};curOffset={x:0,y:0};mousePosition={x:-1,y:-1};MAX_SCALE=60;MIN_SCALE=1;STEP_SCALE=.5;scale=1;preScale=1;width=0;height=0;x=0;y=0;timeout=0;lastTouch;initialDistance=0;touchMode=0;isMouseover=!1;isBindEvent=!0;isDrawAssist=!1;customDrawAssist;isMoveRedrawing;afterDraw;screenPos={screenX:0,screenY:0};constructor(t){const{container:e,width:i=300,height:n=300,isBindEvent:o=!0,isDrawAssist:r=!1,isMoveRedrawing:a,customDrawAssist:c,afterDraw:u,...h}=t;this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.width=i,this.height=n,this.canvas.width=i,this.canvas.height=n,this.isBindEvent=o,this.isDrawAssist=r,this.customDrawAssist=c,this.isMoveRedrawing=a??r,this.options=h,this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMousemoveTemp=this.onMousemoveTemp.bind(this),this.onMouseup=this.onMouseup.bind(this),this.onMousewheel=this.onMousewheel.bind(this),this.onDblclick=this.onDblclick.bind(this),this.onTouchstart=this.onTouchstart.bind(this),this.onTouchmove=this.onTouchmove.bind(this),this.onTouchend=this.onTouchend.bind(this),this.onMouseout=this.onMouseout.bind(this),this.afterDraw=this.afterDraw,o&&(this.canvas.addEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.addEventListener("mousewheel",this.onMousewheel),this.canvas.addEventListener("mousedown",this.onMousedown),this.canvas.addEventListener("mousemove",this.onMousemove),this.canvas.addEventListener("mouseout",this.onMouseout),this.canvas.addEventListener("dblclick",this.onDblclick),this.canvas.addEventListener("touchstart",this.onTouchstart))}onClick(t){const{screenX:e,screenY:i}=t;this.timeout&&clearTimeout(this.timeout);const n=this.getPos(t);this.x=n.x,this.y=n.y,this.screenPos={screenX:e,screenY:i},this.options.onClick&&(this.timeout=setTimeout(()=>{const o=parseFloat(((this.x-this.offset.x)/this.scale).toFixed(2)),r=parseFloat(((this.y-this.offset.y)/this.scale).toFixed(2));this.options.onClick(o,r)},200))}onMouseout(t){this.isMouseover=!1,this.draw()}onTouchstart(t){t.preventDefault(),t.touches.length==1?this.touchMode===0&&(this.touchMode=1):t.touches.length>=2&&this.touchMode<2&&(this.touchMode=2),this.touchMode==1&&t.touches.length==1?this.onTouch(t.touches[0]):this.touchMode==2&&t.touches.length==2&&this.onBothTouchstart(t),this.canvas.addEventListener("touchmove",this.onTouchmove),this.canvas.addEventListener("touchend",this.onTouchend)}onMousedown(t){this.onClick(t),this.canvas.addEventListener("mousemove",this.onMousemoveTemp),this.canvas.addEventListener("mouseup",this.onMouseup)}onBothTouchstart(t){t.preventDefault();const e={x:t.touches[0].clientX,y:t.touches[0].clientY},i={x:t.touches[1].clientX,y:t.touches[1].clientY},n=this.getPos({clientX:(e.x+i.x)/2,clientY:(e.y+i.y)/2});this.x=n.x,this.y=n.y,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.initialDistance=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2))}onTouchmove(t){t.preventDefault(),this.touchMode==1&&t.touches.length==1?(this.onMousemoveTemp(t.touches[0]),this.onMousemove(t.touches[0])):this.touchMode==2&&t.touches.length==2&&this.onBothTouchmove(t)}onMousemove(t){const e=this.getPos(t);this.mousePosition.x=e.x,this.mousePosition.y=e.y,this.isMouseover=!0,this.isMoveRedrawing&&this.draw()}onMousemoveTemp(t){const{screenX:e,screenY:i}=this.screenPos;(Math.abs(e-t.screenX)>10||Math.abs(i-t.screenY)>10)&&(this.timeout&&clearTimeout(this.timeout),this.offset.x=this.curOffset.x+(this.mousePosition.x-this.x),this.offset.y=this.curOffset.y+(this.mousePosition.y-this.y),!this.isMoveRedrawing&&this.draw())}onBothTouchmove(t){if(t.preventDefault(),this.initialDistance){const e={x:t.touches[0].clientX,y:t.touches[0].clientY},i={x:t.touches[1].clientX,y:t.touches[1].clientY},n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));if(this.scale+=(n-this.initialDistance)/30*this.STEP_SCALE,this.initialDistance=n,this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}}onTouchend(){this.touchMode=0,this.onMouseup()}onMouseup(){this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.canvas.removeEventListener("mousemove",this.onMousemoveTemp),this.canvas.removeEventListener("mouseup",this.onMouseup),this.canvas.removeEventListener("touchmove",this.onTouchmove),this.canvas.removeEventListener("touchend",this.onTouchend)}onMousewheel(t){this.timeout&&clearTimeout(this.timeout),t.preventDefault();const e=this.getPos(t);this.x=e.x,this.y=e.y;const i=t.wheelDelta>0||t.detail<0?this.STEP_SCALE:-this.STEP_SCALE;if(this.scale=parseFloat((this.scale+i).toFixed(2)),this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}onTouch(t){const e=Date.now(),{lastTouchTime:i=0,lastTouchX:n=0,lastTouchY:o=0}=this.lastTouch||{};e-i<300&&Math.abs(t.clientX-n)<30&&Math.abs(t.clientY-o)<30?(this.onDblclick(t),this.lastTouch={lastTouchTime:0,lastTouchX:0,lastTouchY:0}):(this.onClick(t),this.lastTouch={lastTouchTime:e,lastTouchX:t.clientX,lastTouchY:t.clientY})}onDblclick(t){this.timeout&&clearTimeout(this.timeout),this.reset(),this.draw()}zoom(){this.offset.x=this.x-(this.x-this.offset.x)*this.scale/this.preScale,this.offset.y=this.y-(this.y-this.offset.y)*this.scale/this.preScale,this.draw(),this.preScale=this.scale,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y}reset(t){const{width:e=this.width,height:i=this.height,scale:n=1,preScale:o=1,offset:r={x:0,y:0},curOffset:a={x:0,y:0}}=t||{};this.width=e,this.height=i,this.canvas.width=e,this.canvas.height=i,this.scale=n,this.preScale=o,this.offset=r,this.curOffset=a}drawAssist(){const t=this.ctx;t.save(),t.beginPath(),t.lineWidth=1,t.strokeStyle="#C656D5",t.moveTo(0,this.mousePosition.y),t.lineTo(this.width,this.mousePosition.y),t.closePath(),t.stroke(),t.beginPath(),t.moveTo(this.mousePosition.x,0),t.lineTo(this.mousePosition.x,this.height),t.closePath(),t.stroke(),t.restore()}draw(){this.ctx.clearRect(0,0,this.width,this.height),this.ctx.save(),this.ctx.translate(this.offset.x,this.offset.y),this.ctx.scale(this.scale,this.scale),this.options.draw(this.ctx,this),this.ctx.restore(),this.isDrawAssist&&this.isMouseover&&(this.customDrawAssist?this.customDrawAssist():this.drawAssist()),this.afterDraw?.(this.ctx,this)}getPos(t){const e=this.canvas.getBoundingClientRect();let i=parseFloat((t.clientX-e.left).toFixed(2)),n=parseFloat((t.clientY-e.top).toFixed(2));return i=i<0?0:i,n=n<0?0:n,{x:i,y:n}}unBindEvent(){this.isBindEvent&&(this.canvas.removeEventListener("mousemove",this.onMousemove),this.canvas.removeEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.removeEventListener("mousewheel",this.onMousewheel),this.canvas.removeEventListener("mousedown",this.onMousedown),this.canvas.removeEventListener("mouseout",this.onMouseout),this.canvas.removeEventListener("dblclick",this.onDblclick))}}const ot={};class Ut{type="image";x;y;width;height;img;src;redraw;constructor(t){this.x=t.x||0,this.y=t.y||0,this.width=t.width||0,this.height=t.height||0,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=ot[this.src];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.crossOrigin="anonymous",i.src=this.src,i.onload=()=>{ot[this.src]=i,t?.(i),this.redraw?.()},i}}draw(t){try{if(!this.img.complete)return;t.save(),t.drawImage(this.img,this.x,this.y,this.width,this.height),t.restore()}catch(e){console.error(e)}}}class Gt{id="";type="point";x;y;r;text;backgroundColor;index;pIndex;parentId;constructor(t){this.id=t.id,this.x=t.x,this.y=t.y,this.r=t.r||15,this.text=t.text||"",this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.backgroundColor=t.backgroundColor||"rgba(91, 179, 111, 0.8)"}draw(t,e){t.save();const i=1/e.scale;t.beginPath(),t.arc(this.x,this.y,this.r*i,0,2*Math.PI),t.fillStyle=this.backgroundColor,t.fill(),t.font=`${this.r*i}px Microsoft YaHei`,t.textAlign="center",t.fillStyle="#FFFFFF",t.fillText(this.text,this.x,this.y+this.r*i/3),t.restore()}}const rt={};class Yt{id="";type="issue";x;y;width;height;src;img;index;pIndex;parentId;count;badgeR;redraw;constructor(t){this.id=t.id,this.x=t.x,this.y=t.y,this.width=t.width||0,this.height=t.height||0,this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.count=t.count||0,this.badgeR=3,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=rt[this.src];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.src=this.src,i.crossOrigin="anonymous",i.onload=()=>{rt[this.src]=i,t?.(i),this.redraw?.()},i}}draw(t,e){if(!this.img.complete)return;const i=1/e.scale,n=this.width*i,o=this.height*i,r=this.x-n/2,a=this.y-o,c=this.badgeR*i,u=c*1.5;t.save(),t.drawImage(this.img,r,a,n,o),t.beginPath(),this.count>1&&(t.arc(this.x+n*.3,this.y-o*.8,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*.3,this.y-o*.8+c/2)),t.restore()}}const at={};class Bt{type="marker";x;y;url;width;height;anchor;img;scale;redraw;beforeDraw;constructor(t){this.x=t.x,this.y=t.y,this.url=t.url,this.width=t.width??0,this.height=t.height??0,this.anchor=t.anchor,this.scale=t.scale??1,t.redraw&&(this.redraw=t.redraw),t.beforeDraw&&(this.beforeDraw=t.beforeDraw),this.img=this.loadImage(t.onload)}loadImage(t){const e=at[this.url];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.src=this.url,i.crossOrigin="anonymous",i.onload=()=>{at[this.url]=i,t?.(i),this.redraw?.()},i}}calculateIconPosition(){const t=this.anchor?.x??this.width/2,e=this.anchor?.y??this.height/2;return{iconStartX:this.x-t*this.scale,iconStartY:this.y-e*this.scale}}draw(t,e){if(this.beforeDraw?.(t,e),!this.img?.complete)return;const{iconStartX:i,iconStartY:n}=this.calculateIconPosition();t.save();try{t.drawImage(this.img,i,n,this.width*this.scale,this.height*this.scale)}catch(o){console.error("绘制标记时出错:",o)}finally{t.restore()}}}class $t{type="radar";x;y;r;angle;text;hFov=90;beforeDraw;constructor(t){this.x=t.x,this.y=t.y,this.r=t.r||15,this.angle=t.angle||0,this.text=t.text||"",this.hFov=t.fovh||90,this.beforeDraw=t.beforeDraw}draw(t,e){this.beforeDraw?.(t,e);const i=1/e.scale,[n,o]=[(this.angle-this.hFov/2)/180*Math.PI,(this.angle+this.hFov/2)/180*Math.PI];t.save();const r=t.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r*i);r.addColorStop(0,"rgba(180, 42, 42, 1)"),r.addColorStop(1,"rgba(180, 42, 42, 0.5)"),t.beginPath(),t.moveTo(this.x,this.y),t.arc(this.x,this.y,this.r*i,n,o),t.closePath(),t.fillStyle=r,t.fill(),t.restore()}}class _t{type="region";x;y;shape;areaPoints;backgroundColor;constructor(t){if(this.x=t.x,this.y=t.y,this.shape=t.shape||"",this.backgroundColor=t.backgroundColor,t.areaPoints.length===2){const[{x:e,y:i},{},{x:n,y:o}]=t.areaPoints;this.areaPoints=[{x:Math.min(e,n),y:Math.min(i,o)},{x:Math.max(e,n),y:Math.min(i,o)},{x:Math.max(e,n),y:Math.max(i,o)},{x:Math.min(e,n),y:Math.max(i,o)}]}else this.areaPoints=t.areaPoints}draw(t,e){if(t.save(),t.beginPath(),t.globalAlpha=.3,t.fillStyle=this.backgroundColor,this.shape==="circle"){const[{x:i,y:n},{},{x:o,y:r}]=this.areaPoints,a=Math.abs(o-i)/2,c=i+(o-i)/2,u=n+(r-n)/2;t.arc(c,u,a,0,2*Math.PI)}else this.areaPoints.forEach((i,n)=>{const{x:o,y:r}=i;n===0?t.moveTo(o,r):t.lineTo(o,r)});t.fill(),t.restore()}}l.APP_SETTING=$,l.AppError=y,l.AppErrorCode=g,l.AppObsType=B,l.CanvasElement=Ft,l.CanvasImageElement=Ut,l.CanvasIssueElement=Yt,l.CanvasMarkerElement=Bt,l.CanvasPointElement=Gt,l.CanvasRadarElement=$t,l.CanvasRegionElement=_t,l.Coordinate=A,l.CoordinateLevel=Y,l.CoordinateModelType=M,l.CoordinateStatus=N,l.CoordinateType=x,l.DataHelper=Xt,l.DataSource=p,l.GeoPoint=I,l.Point=f,l.Position=U,l.REQUEST_CONFIG=q,l.REQUEST_OPTIONS=_,l.RelativeMap=w,l.RequestContentType=R,l.RequestMethod=v,l.RequestResultCode=j,l.Vector3=G,l.api=mt,l.http=dt,l.utils=kt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(l,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(l=typeof globalThis<"u"?globalThis:l||self,M(l.Shared={}))})(this,(function(l){"use strict";var M=(s=>(s[s.CADModel=5]="CADModel",s[s.BIMModel=6]="BIMModel",s[s.ForgeModel=7]="ForgeModel",s[s.ThreeDModel=8]="ThreeDModel",s[s.GeoModel=9]="GeoModel",s[s.ScaleModel=101]="ScaleModel",s))(M||{}),Y=(s=>(s[s.Global=0]="Global",s))(Y||{}),x=(s=>(s[s.Space=0]="Space",s[s.Model=1]="Model",s[s.Data=2]="Data",s))(x||{}),N=(s=>(s[s.Used=0]="Used",s[s.Enabled=1]="Enabled",s[s.Disabled=2]="Disabled",s))(N||{}),j=(s=>(s[s.SUCCESS=200]="SUCCESS",s[s.ERROR=-1]="ERROR",s[s.TIMEOUT=401]="TIMEOUT",s))(j||{}),v=(s=>(s.GET="GET",s.POST="POST",s))(v||{}),R=(s=>(s.JSON="application/json",s.FORM_URLENCODED="application/x-www-form-urlencoded;charset=UTF-8",s.FORM_DATA="multipart/form-data;charset=UTF-8",s.OCTET_STREAM="'application/octet-stream",s))(R||{}),B=(s=>(s.Hw="huawei",s.Ali="aliyun",s.Hs="hs",s.Aws="amazon",s.Minio="minio",s))(B||{}),g=(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))(g||{});const $={baseUrl:"https://vsleem.com/api",authorizeCode:""},_={isTransformResponse:!0,joinBaseUrl:!0,withAuthorize:!0},q={url:"",method:v.GET,headers:{}};class m extends Error{constructor(t,e,i){super(e),this.code=t,this.message=e,this.details=i,this.name="Apprror",Object.setPrototypeOf(this,m.prototype)}toJSON(){return{code:this.code,message:this.message,details:this.details,timestamp:new Date().toISOString()}}}const Z={...$};function ht(s){const{baseUrl:t,authorizeCode:e}=s;Object.assign(Z,{baseUrl:t,authorizeCode:e})}async function S(s,t){const e={..._,...t},i={...q,...s};try{const n=ct(i,e),{url:o,...r}=n,c=await(await window.fetch(o,r)).json();return lt(c,e)}catch(n){return ut(n)}}function ct(s,t){const{baseUrl:e,authorizeCode:i}=Z,{joinBaseUrl:n,withAuthorize:o}=t;let{url:r,method:a,headers:c={},params:u,data:h}=s;n&&e&&(r=`${e}${r}`),a=a?.toUpperCase();const d={...c};if(/^https?:\/\/.+$/i.test(e??"")?d.PlatForm=new URL(e??"").host:d.PlatForm=new URL(window.location.href).host,o&&i&&(d.AuthorizationCode=i),a===v.POST&&!d["Content-Type"]&&(d["Content-Type"]=R.JSON),a===v.GET&&u){const C=new URLSearchParams(u),b=r.includes("?")?"&":"?";r+=b+`${C.toString()}`}let f;return a===v.POST&&(f=d["Content-Type"]===R.JSON?JSON.stringify(h||{}):h),{url:r,method:a,headers:d,body:f}}function lt(s,t){if(!t.isTransformResponse)return s;if(!s)throw new m(g.RequestResultError,"请求返回的结果错误");const{code:e,data:i,msg:n}=s;if(e===j.SUCCESS)return i;throw new m(g.RequestCodeError,n||"请求返回的Code错误")}function ut(s){throw s instanceof Error?s:new m(g.RequestUnknownError,typeof s=="string"?s:"未知的请求错误")}const dt=Object.freeze(Object.defineProperty({__proto__:null,request:S,setRequestGlobalConfig:ht},Symbol.toStringTag,{value:"Module"}));function J(s,t){return S({url:"/project/jssdk/cs/list",method:v.GET,params:s},t)}function H(s,t){return S({url:"/project/jssdk/cs/bind",method:v.POST,data:s},t)}function k(s,t){return S({url:"/project/jssdk/cs/save",method:v.POST,data:s},t)}function V(s,t){return S({url:"/project/jssdk/cs/delete",method:v.POST,data:s},t)}function Q(s,t){return S({url:"/project/jssdk/cs/mapping",method:v.POST,data:s},t)}function W(s,t){return S({url:"/project/jssdk/cs/mapping/query",method:v.GET,params:s},t)}function ft(s,t={isTransformResponse:!1,joinBaseUrl:!1,withAuthorize:!1}){return S({url:s,method:v.GET},t)}const mt=Object.freeze(Object.defineProperty({__proto__:null,bindCoordinate:H,getCoordinateList:J,getImageInfo:ft,getMappingRelation:W,mapingCoordinate:Q,removeCoordinate:V,saveCoordinate:k},Symbol.toStringTag,{value:"Module"})),yt=typeof window<"u",wt=Object.prototype.toString;function P(s,t){return wt.call(s)===`[object ${t}]`}function K(s){return typeof s<"u"}function tt(s){return!K(s)}function E(s){return s!==null&&P(s,"Object")}function et(s){return s===null}function pt(s){return P(s,"Date")}function gt(s){return P(s,"String")}function X(s){return typeof s=="function"}function Mt(s){return P(s,"Boolean")}function vt(s){return P(s,"RegExp")}function T(s){return s&&Array.isArray(s)}function xt(s){return typeof window<"u"&&P(s,"Window")}function Tt(s){return E(s)&&!!s.tagName}function O(s){return typeof s=="number"?!0:typeof s!="string"?!1:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/.test(s)}function bt(s,t){return JSON.stringify(s)===JSON.stringify(t)}function St(s){return tt(s)||et(s)}function Pt(s){return P(s,"Promise")&&E(s)&&X(s.then)&&X(s.catch)}function st(s){return z(s,new WeakMap)}function z(s,t){if(typeof s!="object"||s===null)return s;if(t.has(s))return t.get(s);let e;if(s instanceof Date)return e=new Date(s),t.set(s,e),e;if(s instanceof RegExp)return e=new RegExp(s),t.set(s,e),e;if(s instanceof Map)return e=new Map,t.set(s,e),s.forEach((n,o)=>{e.set(o,z(n,t))}),e;if(s instanceof Set)return e=new Set,t.set(s,e),s.forEach(n=>{e.add(z(n,t))}),e;if(ArrayBuffer.isView(s))return e=new s.constructor(s.buffer.slice(0),s.byteOffset,s.byteLength),t.set(s,e),e;if(s instanceof ArrayBuffer)return e=s.slice(0),t.set(s,e),e;if(Array.isArray(s)){e=[],t.set(s,e);for(let n=0;n<s.length;n++)n in s&&(e[n]=z(s[n],t));return e}e=Object.create(Object.getPrototypeOf(s)),t.set(s,e);for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=z(s[n],t));const i=Object.getOwnPropertySymbols(s);for(const n of i)Object.prototype.propertyIsEnumerable.call(s,n)&&(e[n]=z(s[n],t));return e}function Et(s,t,e=!1){let i;const n=function(...o){const r=this,a=e&&!i;i&&clearTimeout(i),i=setTimeout(()=>{i=void 0,e||s.apply(r,o)},t),a&&s.apply(r,o)};return n.cancel=()=>{i&&clearTimeout(i),i=void 0},n}function Ct(s,t,e=!1){let i,n;const o=function(...r){const a=this;n?(clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=t&&(s.apply(a,r),n=Date.now())},t-(Date.now()-n))):(e&&s.apply(a,r),n=Date.now())};return o.cancel=()=>{clearTimeout(i),i=void 0,n=void 0},o}function F(s,...t){if(!t.length)return s;const e=t.shift();return e===void 0?s:(L(s)&&L(e)&&Object.keys(e).forEach(i=>{const n=s[i],o=e[i];Array.isArray(n)&&Array.isArray(o)?s[i]=[...n,...o]:L(n)&&L(o)?s[i]=F({...n},o):o!==void 0&&(s[i]=o)}),F(s,...t))}function L(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function it(s,...t){if(!t.length)return s;for(const e of t)e!=null&&typeof e=="object"&&Object.keys(e).forEach(i=>{const n=e[i],o=s[i];n!==null&&typeof n=="object"&&!Array.isArray(n)?((!o||typeof o!="object")&&(s[i]={}),it(s[i],n)):s[i]=n});return s}function nt(s,t){const e={};if(E(s)&&!T(s)){for(const i in s)if(Object.prototype.hasOwnProperty.call(s,i)){const n=s[i],o=E(t)&&!T(t)?t[i]:void 0;if(!(i in(t||{})))e[i]=n;else if(T(n)&&T(o))JSON.stringify(n)!==JSON.stringify(o)&&(e[i]=n);else if(E(n)&&E(o)){const r=nt(n,o);r&&Object.keys(r).length>0&&(e[i]=r)}else n!==o&&(e[i]=n)}}if(E(t)&&T(t))for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&!(i in(s||{}))&&(e[i]=void 0);return e}function zt(s,t={}){return new Promise((e,i)=>{const n=D(s);if(Dt(n)){e(!0);return}const o=document.createElement("script");o.src=s,Object.entries(t).forEach(([r,a])=>{a!==!1&&o.setAttribute(r,a===!0?"":String(a))}),o.onload=()=>{e(!0)},o.onerror=()=>{document.head.removeChild(o),i(new Error(`Failed to load script: ${s}`))},document.head.appendChild(o)})}function Dt(s){const t=D(s);return Array.from(document.scripts).some(e=>D(e.src)===t)}function It(s){return new Promise((t,e)=>{const i=D(s);if(Nt(i)){t(!0);return}const n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=s,n.onload=()=>{t(!0)},n.onerror=()=>{document.head.removeChild(n),e(new Error(`Failed to load link: ${s}`))},document.head.appendChild(n)})}function Nt(s){const t=D(s);return Array.from(document.querySelectorAll('link[rel="stylesheet"]')).some(e=>D(e.href)===t)}function D(s){try{const t=new URL(s,window.location.href);return`${t.origin}${t.pathname}`}catch{return s}}function Rt(s,t,e,i){const n=Math.min(s/e,t/i),o=e*n,r=i*n;return{scale:n,x:(s-o)/2,y:(t-r)/2,sw:o,sh:r}}function Ot(s,t,e){return{x:s*e.scale+e.x,y:t*e.scale+e.y}}function Lt(s,t,e){return{x:(s-e.x)/e.scale,y:(t-e.y)/e.scale}}function At(s){console.warn(`[warn]:${s}`)}function jt(s){throw new Error(`[error]:${s}`)}const kt=Object.freeze(Object.defineProperty({__proto__:null,cloneDeep:st,debounce:Et,deepMerge:F,deepMergeProps:it,error:jt,getDiffProps:nt,getImageTransform:Rt,inBrowser:yt,is:P,isArray:T,isBoolean:Mt,isDate:pt,isDef:K,isElement:Tt,isFunction:X,isNull:et,isNullOrUnDef:St,isNumeric:O,isObject:E,isPromise:Pt,isRegExp:vt,isSameValue:bt,isString:gt,isUnDef:tt,isWindow:xt,loadCss:It,loadScript:zt,throttle:Ct,toCanvasCoord:Ot,toModelCoord:Lt,warn:At},Symbol.toStringTag,{value:"Module"}));class y{x=0;y=0;z=0;lat=0;lon=0;alt=0;yaw=0;pitch=0;roll=0;hasXYZ=!1;hasGeo=!1;hasAngle=!1;plane="xy";constructor(t){const{x:e,y:i,z:n,lat:o,lon:r,alt:a,yaw:c,pitch:u,roll:h,plane:d="xy"}=t||{};this.x=Number(e)||0,this.y=Number(i)||0,this.z=Number(n)||0,(this.x!==0||this.y!==0||this.z!==0)&&(this.plane=d,this.hasXYZ=!0),this.lat=Number(o)||0,this.lon=Number(r)||0,this.alt=Number(a)||0,(this.lat!==0||this.lon!==0||this.alt!==0)&&(this.hasGeo=!0),this.yaw=Number(c)||0,this.pitch=Number(u)||0,this.roll=Number(h)||0,(O(c)||O(u)||O(h))&&(this.hasAngle=!0)}static dist(t,e){return Math.hypot(t.x-e.x,t.y-e.y,t.z-e.z)}static distXZ(t,e){return Math.hypot(t.x-e.x,t.z-e.z)}static distXY(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}static toRadians(t){return(Number(t)||0)*Math.PI/180}static toDegrees(t){return(Number(t)||0)*180/Math.PI}static angleXZ(t,e,i){const n={x:t.x-e.x,z:t.z-e.z},o={x:i.x-e.x,z:i.z-e.z},r=n.x*o.x+n.z*o.z,a=Math.sqrt(n.x**2+n.z**2),c=Math.sqrt(o.x**2+o.z**2),u=Math.max(-1,Math.min(1,r/(a*c))),d=Math.acos(u)*180/Math.PI;return Math.min(d,360-d)}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new y({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}projection(t,e,i){try{if(e?.id===i?.id)return new y(this);if(e?.modelType===M.GeoModel){const{refPoint:n}=e?.relativeMap||{};if(this.hasGeo&&n){const o=I.LLHToXYZ(this,n);return this.x=o.x,this.y=o.y,this.z=o.z,this.hasXYZ=!0,this.project(t)}throw new m(g.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}if(i?.modelType===M.GeoModel){const{refPoint:n}=i?.relativeMap||{},o=this.project(t);if(o?.hasXYZ&&n){const r=I.XYZToLLH(o,n);return o.lat=r.lat,o.lon=r.lon,o.alt=r.alt,o.hasGeo=!0,o}throw new m(g.PointUnmappedGIS,"没有完成GIS与其他空间的映射")}return this.project(t)}catch(n){console.error(n);return}}project(t){if(!this.hasXYZ)throw new m(g.PointNoXYZ,"点没有xxz坐标信息");if(this.plane==="xz")return this.projectXZ(t);if(this.plane==="xy")return this.projectXY(t);throw new m(g.PointNoPlane,"点的plane应为xz或xy")}projectXZ(t){const e=new y(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const i=e.x*Math.cos(t.yaw)-e.z*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.z*Math.cos(t.yaw);return e.x=i+t.x,e.y+=t.y,e.z=n+t.z,e}projectXY(t){const e=new y(this);e.x*=t.scale,e.y*=t.scale,e.z*=t.scale,e.yaw!==void 0&&(e.yaw+=t.yaw);const i=e.x*Math.cos(t.yaw)-e.y*Math.sin(t.yaw),n=e.x*Math.sin(t.yaw)+e.y*Math.cos(t.yaw);return e.x=i+t.x,e.y=n+t.y,e.z+=t.z,e}}class I{lat=0;lon=0;alt=0;constructor(t){const{lat:e=0,lon:i=0,alt:n=0}=t||{};this.lat=Number(e)||0,this.lon=Number(i)||0,this.alt=Number(n)||0}static XYZToLLH(t,e){const n=.0033528106647474805,o=n*(2-n),r=y.toRadians(e.lat),a=6378137/Math.sqrt(1-o*Math.sin(r)**2)+e.alt;let c,u,h;if(t.plane==="xz"){const d=t.x/1e3/(a*Math.cos(r)),f=t.z/1e3/a;c=e.lon+y.toDegrees(d),u=e.lat-y.toDegrees(f),h=e.alt+t.y/1e3}else if(t.plane==="xy"){const d=t.x/1e3/(a*Math.cos(r)),f=t.y/1e3/a;c=e.lon+y.toDegrees(d),u=e.lat-y.toDegrees(f),h=e.alt+t.z/1e3}else throw new m(g.GeoPointNoPlane,"点的plane应为xz或xy");return new I({lat:u,lon:c,alt:h})}static LLHToXYZ(t,e){const n=.0033528106647474805,o=n*(2-n),r=y.toRadians(e.lat),a=6378137/Math.sqrt(1-o*Math.sin(r)**2)+e.alt,c=y.toRadians(t.lon-e.lon),u=y.toRadians(e.lat-t.lat),h=a*c*Math.cos(r),d=a*u;if(t.plane==="xz")return new y({x:h*1e3,y:(t.alt-e.alt)*1e3,z:d*1e3,plane:"xz"});if(t.plane==="xy")return new y({x:h*1e3,y:d*1e3,z:(t.alt-e.alt)*1e3,plane:"xy"});throw new m(g.GeoPointNoPlane,"点的plane应为xz或xy")}}class w{scale=1;yaw=0;x=0;y=0;z=0;start=0;end=-1;plane="xy";refPoint;constructor(t){const{refPoint:e,...i}=t||{};e&&(this.refPoint=new I(e)),Object.assign(this,i)}static addRelativeMap(t,e){if(t.plane!==e.plane)throw new m(g.RelativePlaneUnmatch,"两个映射关系的plane应该相同");const i=t.scale*e.scale,n=t.yaw+e.yaw,o=Math.cos(e.yaw),r=Math.sin(e.yaw);let a=0,c=0,u=0;if(t.plane==="xz"){const h=t.x*o-t.z*r,d=t.y,f=t.x*r+t.z*o;a=e.x+h*e.scale,c=e.y+d*e.scale,u=e.z+f*e.scale}else if(t.plane==="xy"){const h=t.x*o-t.y*r,d=t.x*r+t.y*o,f=t.z;a=e.x+h*e.scale,c=e.y+d*e.scale,u=e.z+f*e.scale}else throw new m(g.RelativeNoPlane,"映射关系的plane应为xz或xy");return new w({scale:i,yaw:n,x:a,y:c,z:u,start:t.start,end:t.end,plane:t.plane})}static inverseRelativeMap(t){const e=1/t.scale,i=-t.yaw,n=Math.cos(-i),o=Math.sin(-i);let r=0,a=0,c=0;if(t.plane==="xz")r=-(t.x*n+t.z*o)*e,a=-t.y*e,c=-(t.z*n-t.x*o)*e;else if(t.plane==="xy")r=-(t.x*n+t.y*o)*e,a=-(t.y*n-t.x*o)*e,c=-t.z*e;else throw new m(g.RelativeNoPlane,"映射关系的plane应为xz或xy");return new w({scale:e,yaw:i,x:r,y:a,z:c,start:t.start,end:t.end,plane:t.plane})}static toParse(t){try{let e=t?JSON.parse(t):void 0;const{reference_point:i}=e||{};return i&&(e={refPoint:i}),e?new w(e):void 0}catch{throw new m(g.RelativeJsonError,"relativeMap格式化失败")}}static toStringify(t){return t?JSON.stringify(t):void 0}static isValid(t){return t&&t!=='{"scale":1.0, "yaw":0.0, "x":0.0, "y":0.0, "z":0.0}'}}class p{static async getCoordinateTree(t){const e=await J({projectId:t});if(e.length){const i=p.handleCoordinateList(e);return p.buildCoordinateTree(i,0)}}static parsedCoordinateTree(t){const e=p.flattenCoordinateTree(t);return p.buildCoordinateTree(e,0)}static async addCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{type:c,modelType:u,relativeMap:h,level:d,...f}=a,C=h?JSON.stringify(h):void 0;return{...f,projectId:i,parentId:n,coordinateType:c,renderType:u,relativePosition:C}}),r=await k(o);return p.handleCoordinateList(r)}static async removeCoordinate(t,e){const i=e.map(n=>n.id??-1);return await V(i)}static async updateCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{type:c,relativeMap:u,level:h,...d}=a,f=w.toStringify(u);return{...d,relativePosition:f,projectId:i,parentId:n}}),r=await k(o);return p.handleCoordinateList(r)}static async bindCoordinate(t,e){const{projectId:i,id:n}=t,o=e.map(a=>{const{modelId:c}=a;return{modelId:c,parentId:n,projectId:i}}),r=await H(o);return p.handleCoordinateList(r)}static handleCoordinateList(t){return t?.map(e=>{const{coordinateType:i,modelKey:n,renderType:o,relativePosition:r,...a}=e,c=o===M.GeoModel?new w(w.toParse(r)):w.toParse(r);return new A({...a,type:i,modelType:o,modelValue:n,relativeMap:c})})}static flattenCoordinateTree(t){const e=Array.isArray(t)?t:[t],i=[];function n(o){for(const r of o){const{level:a,parent:c,relativeMap:u,...h}=r,d=new A({...h,relativeMap:new w(u)});i.push(d),r.children&&r.children.length>0&&n(r.children)}}return n(e),i}static buildCoordinateTree(t,e=0){const i=new Map,n=[];return t.forEach(o=>{i.set(String(o.id),o)}),t.forEach(o=>{const r=i.get(String(o.id));if(r)if(o.parentId===e)r.level=0,n.push(r);else{const a=i.get(String(o.parentId??-1));a&&(r.type===x.Space&&(r.level=(Number(a.level)||0)+1),r.parent=a,a.children?.push(r))}}),n.forEach(p.sortCoordinateTree),n[0]}static sortCoordinateTree(t){t.children&&(t.children.sort((e,i)=>{if(e.type===x.Space){const n=Number(i?.relativeMap?.z)-Number(e?.relativeMap?.z);return n!==0?n:Number(i.createTime)-Number(e.createTime)}else return e.status===0&&i.status!==0?-1:i.status===0&&e.status!==0?1:Number(i.createTime)-Number(e.createTime)}),t.children.forEach(p.sortCoordinateTree))}static filterSpaceTree(t,e){const i=[];return t.forEach(n=>{const o=new A(n);e&&(o.parent=e);const r=p.filterSpaceTree(o.children,o);o.children=r,o.disabled=o.disabled??!1,o.type!==x.Model&&i.push(o)}),i}}class A{id=0;type=0;children=[];level;relativeMap;no;name;shortName;status;modelId;modelType;modelValue;projectId;parentId;parent;groupUuid;z;createTime;disabled;constructor(t){this.setOptions(t)}get spaceList(){return this.children.filter(t=>t.type===x.Space)}get modelList(){return this.children.filter(t=>t.type===x.Model)}get fullName(){const t=this.name?`(${this.name})`:"";return this.shortName?`${this.shortName}${t}`:this.name??""}setOptions(t){const{relativeMap:e,parent:i,children:n,...o}=t||{};e&&(this.relativeMap=new w(e)),i&&(this.parent=i),n?.length&&(this.children=n),Object.assign(this,o)}async addChild(t){const e=T(t)?t:[t],i=await p.addCoordinate(this,e);return this.mergeChild(i),i}async removeChild(t){const e=T(t)?t:[t];await p.removeCoordinate(this,e);for(const i of e){const n=this.children.findIndex(o=>o.id===i.id);n!==-1&&this.children.splice(n,1)}}async updateChild(t){const e=T(t)?t:[t],i=await p.updateCoordinate(this,e);return this.mergeChild(i),i}async bindChild(t){const e=T(t)?t:[t],i=await p.bindCoordinate(this,e);return this.mergeChild(i),i}async mergeChild(t){t?.length&&t.forEach(e=>{const i=this.children.find(n=>n.id===e.id);if(i){const{relativeMap:n,no:o,name:r,shortName:a,status:c,modelId:u,modelValue:h}=e;Object.assign(i,{relativeMap:n,no:o,name:r,shortName:a,status:c,modelId:u,modelValue:h})}else this.id===e.parentId&&(e.parent=this,this.children.unshift(e))})}async mappingTo(t){await Q(t)}async getMapping(){return(await W({srcCsId:this.id}))[0]}findRoot(t=!1){let e=this;for(;e.parent&&!(t&&!e.relativeMap);)e=e.parent;return e}findChildModel(t,e=!0){const i=T(t)?t:[t];return i.includes(this.modelType??-1)&&this.status!==N.Disabled?this:([x.Data,x.Model].includes(this.type)?this.findParentSpace():this)?.modelList?.filter(a=>i.includes(a.modelType??-1)?e?!!a.relativeMap:!0:!1)?.sort((a,c)=>Number(a.status)-Number(c.status))?.[0]}findClosestModel(t=[M.CADModel,M.BIMModel,M.ForgeModel,M.ThreeDModel,M.GeoModel],e){const i=T(t)?t:[t],n=new Set;e?.forEach(h=>{n.add(String(h.id))});const o=[{node:this,distance:0}],r=new Set,a=[];for(;o.length>0;){const{node:h,distance:d}=o.shift();if(n.has(String(h.id))||r.has(h))continue;const f=h.modelType??-1;i.includes(f)&&a.push({node:h,distance:d,modelType:f}),r.add(h);const C=[];if(h.children)for(const b of h.children)r.has(b)||C.push(b);if(h.parent?.children)for(const b of h.parent.children)b!==h&&!r.has(b)&&C.push(b);h.parent&&!r.has(h.parent)&&C.push(h.parent);for(const b of C)o.push({node:b,distance:d+1})}if(a.length===0)return;const c=Math.min(...a.map(h=>h.distance)),u=a.filter(h=>h.distance===c);return u.sort((h,d)=>h.modelType-d.modelType),u[0]?.node}findParentSpace(){let t=this;for(;t&&t.type!==x.Space;)t=t.parent;return t}findParentSpaceNames(t=2){const e=[];let i=this;for(;i&&t>0;)i.type===x.Space&&(e.unshift(i.fullName),t--),i=i.parent;return e}findCsGroup(){const{groupUuid:t,parent:e}=this;return t?e?.children?.filter(i=>i.groupUuid===t)||[]:[]}findCsByLevel(t){if(this.level===t)return this;if(this.children.length)for(const e of this.children){const i=e.findCsByLevel(t);if(i)return i}}findCsById(t){if(t){if(this.id===t)return this;for(const e of this.children){const i=e.findCsById(t);if(i)return i}}}getCsRoutes(t=!1){let e=this;const i=[e];for(;e?.parent&&!(t&&!e.relativeMap);)e=e.parent,e&&i.push(e);return i}getMappedCsTree(){function t(n){return n.children?.length&&(n.children=n.children.filter(o=>!!o?.relativeMap&&o.status!==N.Disabled).map(o=>t(o))),n}const e=st(this.findRoot(!0)),i=t(e);return i.parentId=0,i.parent=void 0,i}getDestRelativeMap(t){if(this.id===t.id)return new w;const e=this.getRelativeMaps(),i=t.getRelativeMaps();let n=new w;return e?.forEach(o=>{n=w.addRelativeMap(n,o)}),i?.reverse()?.forEach(o=>{n=w.addRelativeMap(n,w.inverseRelativeMap(o))}),n}getRelativeMaps(){let t=this;const e=[];for(;t?.parent&&t.relativeMap;)e.push(t.relativeMap),t=t.parent;return e}static filterCoordinateTree(t,e=[],i=[]){if(i.includes(t.id)||e.includes(t.type))return;const n=t.children?.map(o=>this.filterCoordinateTree(o,e,i)).filter(o=>o!==void 0);return{...t,children:n}}static getCommonCoordinate(t){let e;const i=t.map(n=>n.getCsRoutes(!0).filter(r=>r.id&&r.type===x.Space));for(;this.checkSameCoordinate(i);){const o=i.shift();o?.length&&(e=o[0])}return e}static checkSameCoordinate(t){if(t.length){if(t.length===1)return!0;for(let e=0;e<t.length-1;e++){const i=t[e];if(!i?.length)return!1;const n=t[e+1];if(!n?.length||i[0].id!==n[0].id)return!1}return!0}else return!1}}class U{yaw=0;pitch=0;roll=0;constructor(t){const{yaw:e=0,pitch:i=0,roll:n=0}=t||{};this.yaw=Number(e)||0,this.pitch=Number(i)||0,this.roll=Number(n)||0}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new U({yaw:e[0],pitch:e[1],roll:e[2]})}}static toStringify(t){return t?`${t.yaw},${t.pitch},${t.roll}`:""}}class G{x=0;y=0;z=0;constructor(t){const{x:e=0,y:i=0,z:n=0}=t||{};this.x=Number(e)||0,this.y=Number(i)||0,this.z=Number(n)||0}static toParse(t){if(t){const e=t?.split(",").map(i=>Number(i)||0);return new G({x:e[0],y:e[1],z:e[2]})}}static toStringify(t){return t?`${t.x},${t.y},${t.z}`:""}}class Xt{static srcPointToDstPoint(t,e,i){if(!e||!i||!t?.length)return[];const n=e?.getDestRelativeMap(i);if(!n)return[];const o=[];return t.forEach(r=>{const a=r.projection(n,e,i);a&&o.push(a)}),o}}class Ft{canvas;ctx;options;offset={x:0,y:0};curOffset={x:0,y:0};mousePosition={x:-1,y:-1};MAX_SCALE=60;MIN_SCALE=1;STEP_SCALE=.5;scale=1;preScale=1;width=0;height=0;x=0;y=0;timeout=0;lastTouch;initialDistance=0;touchMode=0;isMouseover=!1;isBindEvent=!0;isDrawAssist=!1;customDrawAssist;isMoveRedrawing;afterDraw;screenPos={screenX:0,screenY:0};constructor(t){const{container:e,width:i=300,height:n=300,isBindEvent:o=!0,isDrawAssist:r=!1,isMoveRedrawing:a,customDrawAssist:c,afterDraw:u,...h}=t;this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.width=i,this.height=n,this.canvas.width=i,this.canvas.height=n,this.isBindEvent=o,this.isDrawAssist=r,this.customDrawAssist=c,this.isMoveRedrawing=a??r,this.options=h,this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMousemoveTemp=this.onMousemoveTemp.bind(this),this.onMouseup=this.onMouseup.bind(this),this.onMousewheel=this.onMousewheel.bind(this),this.onDblclick=this.onDblclick.bind(this),this.onTouchstart=this.onTouchstart.bind(this),this.onTouchmove=this.onTouchmove.bind(this),this.onTouchend=this.onTouchend.bind(this),this.onMouseout=this.onMouseout.bind(this),this.afterDraw=this.afterDraw,o&&(this.canvas.addEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.addEventListener("mousewheel",this.onMousewheel),this.canvas.addEventListener("mousedown",this.onMousedown),this.canvas.addEventListener("mousemove",this.onMousemove),this.canvas.addEventListener("mouseout",this.onMouseout),this.canvas.addEventListener("dblclick",this.onDblclick),this.canvas.addEventListener("touchstart",this.onTouchstart))}onClick(t){const{screenX:e,screenY:i}=t;this.timeout&&clearTimeout(this.timeout);const n=this.getPos(t);this.x=n.x,this.y=n.y,this.screenPos={screenX:e,screenY:i},this.options.onClick&&(this.timeout=setTimeout(()=>{const o=parseFloat(((this.x-this.offset.x)/this.scale).toFixed(2)),r=parseFloat(((this.y-this.offset.y)/this.scale).toFixed(2));this.options.onClick(o,r)},200))}onMouseout(t){this.isMouseover=!1,this.draw()}onTouchstart(t){t.preventDefault(),t.touches.length==1?this.touchMode===0&&(this.touchMode=1):t.touches.length>=2&&this.touchMode<2&&(this.touchMode=2),this.touchMode==1&&t.touches.length==1?this.onTouch(t.touches[0]):this.touchMode==2&&t.touches.length==2&&this.onBothTouchstart(t),this.canvas.addEventListener("touchmove",this.onTouchmove),this.canvas.addEventListener("touchend",this.onTouchend)}onMousedown(t){this.onClick(t),this.canvas.addEventListener("mousemove",this.onMousemoveTemp),this.canvas.addEventListener("mouseup",this.onMouseup)}onBothTouchstart(t){t.preventDefault();const e={x:t.touches[0].clientX,y:t.touches[0].clientY},i={x:t.touches[1].clientX,y:t.touches[1].clientY},n=this.getPos({clientX:(e.x+i.x)/2,clientY:(e.y+i.y)/2});this.x=n.x,this.y=n.y,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.initialDistance=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2))}onTouchmove(t){t.preventDefault(),this.touchMode==1&&t.touches.length==1?(this.onMousemoveTemp(t.touches[0]),this.onMousemove(t.touches[0])):this.touchMode==2&&t.touches.length==2&&this.onBothTouchmove(t)}onMousemove(t){const e=this.getPos(t);this.mousePosition.x=e.x,this.mousePosition.y=e.y,this.isMouseover=!0,this.isMoveRedrawing&&this.draw()}onMousemoveTemp(t){const{screenX:e,screenY:i}=this.screenPos;(Math.abs(e-t.screenX)>10||Math.abs(i-t.screenY)>10)&&(this.timeout&&clearTimeout(this.timeout),this.offset.x=this.curOffset.x+(this.mousePosition.x-this.x),this.offset.y=this.curOffset.y+(this.mousePosition.y-this.y),!this.isMoveRedrawing&&this.draw())}onBothTouchmove(t){if(t.preventDefault(),this.initialDistance){const e={x:t.touches[0].clientX,y:t.touches[0].clientY},i={x:t.touches[1].clientX,y:t.touches[1].clientY},n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));if(this.scale+=(n-this.initialDistance)/30*this.STEP_SCALE,this.initialDistance=n,this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}}onTouchend(){this.touchMode=0,this.onMouseup()}onMouseup(){this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y,this.canvas.removeEventListener("mousemove",this.onMousemoveTemp),this.canvas.removeEventListener("mouseup",this.onMouseup),this.canvas.removeEventListener("touchmove",this.onTouchmove),this.canvas.removeEventListener("touchend",this.onTouchend)}onMousewheel(t){this.timeout&&clearTimeout(this.timeout),t.preventDefault();const e=this.getPos(t);this.x=e.x,this.y=e.y;const i=t.wheelDelta>0||t.detail<0?this.STEP_SCALE:-this.STEP_SCALE;if(this.scale=parseFloat((this.scale+i).toFixed(2)),this.scale>this.MAX_SCALE){this.scale=this.MAX_SCALE;return}if(this.scale<this.MIN_SCALE){this.scale=this.MIN_SCALE;return}this.zoom()}onTouch(t){const e=Date.now(),{lastTouchTime:i=0,lastTouchX:n=0,lastTouchY:o=0}=this.lastTouch||{};e-i<300&&Math.abs(t.clientX-n)<30&&Math.abs(t.clientY-o)<30?(this.onDblclick(t),this.lastTouch={lastTouchTime:0,lastTouchX:0,lastTouchY:0}):(this.onClick(t),this.lastTouch={lastTouchTime:e,lastTouchX:t.clientX,lastTouchY:t.clientY})}onDblclick(t){this.timeout&&clearTimeout(this.timeout),this.reset(),this.draw()}zoom(){this.offset.x=this.x-(this.x-this.offset.x)*this.scale/this.preScale,this.offset.y=this.y-(this.y-this.offset.y)*this.scale/this.preScale,this.draw(),this.preScale=this.scale,this.curOffset.x=this.offset.x,this.curOffset.y=this.offset.y}reset(t){const{width:e=this.width,height:i=this.height,scale:n=1,preScale:o=1,offset:r={x:0,y:0},curOffset:a={x:0,y:0}}=t||{};this.width=e,this.height=i,this.canvas.width=e,this.canvas.height=i,this.scale=n,this.preScale=o,this.offset=r,this.curOffset=a}drawAssist(){const t=this.ctx;t.save(),t.beginPath(),t.lineWidth=1,t.strokeStyle="#C656D5",t.moveTo(0,this.mousePosition.y),t.lineTo(this.width,this.mousePosition.y),t.closePath(),t.stroke(),t.beginPath(),t.moveTo(this.mousePosition.x,0),t.lineTo(this.mousePosition.x,this.height),t.closePath(),t.stroke(),t.restore()}draw(){this.ctx.clearRect(0,0,this.width,this.height),this.ctx.save(),this.ctx.translate(this.offset.x,this.offset.y),this.ctx.scale(this.scale,this.scale),this.options.draw(this.ctx,this),this.ctx.restore(),this.isDrawAssist&&this.isMouseover&&(this.customDrawAssist?this.customDrawAssist():this.drawAssist()),this.afterDraw?.(this.ctx,this)}getPos(t){const e=this.canvas.getBoundingClientRect();let i=parseFloat((t.clientX-e.left).toFixed(2)),n=parseFloat((t.clientY-e.top).toFixed(2));return i=i<0?0:i,n=n<0?0:n,{x:i,y:n}}unBindEvent(){this.isBindEvent&&(this.canvas.removeEventListener("mousemove",this.onMousemove),this.canvas.removeEventListener("DOMMouseScroll",this.onMousewheel),this.canvas.removeEventListener("mousewheel",this.onMousewheel),this.canvas.removeEventListener("mousedown",this.onMousedown),this.canvas.removeEventListener("mouseout",this.onMouseout),this.canvas.removeEventListener("dblclick",this.onDblclick))}}const ot={};class Ut{type="image";x;y;width;height;img;src;redraw;constructor(t){this.x=t.x||0,this.y=t.y||0,this.width=t.width||0,this.height=t.height||0,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=ot[this.src];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.crossOrigin="anonymous",i.src=this.src,i.onload=()=>{ot[this.src]=i,t?.(i),this.redraw?.()},i}}draw(t){try{if(!this.img.complete)return;t.save(),t.drawImage(this.img,this.x,this.y,this.width,this.height),t.restore()}catch(e){console.error(e)}}}class Gt{id="";type="point";x;y;r;text;backgroundColor;index;pIndex;parentId;constructor(t){this.id=t.id,this.x=t.x,this.y=t.y,this.r=t.r||15,this.text=t.text||"",this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.backgroundColor=t.backgroundColor||"rgba(91, 179, 111, 0.8)"}draw(t,e){t.save();const i=1/e.scale;t.beginPath(),t.arc(this.x,this.y,this.r*i,0,2*Math.PI),t.fillStyle=this.backgroundColor,t.fill(),t.font=`${this.r*i}px Microsoft YaHei`,t.textAlign="center",t.fillStyle="#FFFFFF",t.fillText(this.text,this.x,this.y+this.r*i/3),t.restore()}}const rt={};class Yt{id="";type="issue";x;y;width;height;src;img;index;pIndex;parentId;count;badgeR;redraw;constructor(t){this.id=t.id,this.x=t.x,this.y=t.y,this.width=t.width||0,this.height=t.height||0,this.index=t.index,this.pIndex=t.pIndex,this.parentId=t.parentId,this.count=t.count||0,this.badgeR=3,this.src=t.src,this.redraw=t.redraw,this.img=this.loadImage(t.onload)}loadImage(t){const e=rt[this.src];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.src=this.src,i.crossOrigin="anonymous",i.onload=()=>{rt[this.src]=i,t?.(i),this.redraw?.()},i}}draw(t,e){if(!this.img.complete)return;const i=1/e.scale,n=this.width*i,o=this.height*i,r=this.x-n/2,a=this.y-o,c=this.badgeR*i,u=c*1.5;t.save(),t.drawImage(this.img,r,a,n,o),t.beginPath(),this.count>1&&(t.arc(this.x+n*.3,this.y-o*.8,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*.3,this.y-o*.8+c/2)),t.restore()}}const at={};class Bt{type="marker";x;y;url;width;height;anchor;img;scale;redraw;beforeDraw;constructor(t){this.x=t.x,this.y=t.y,this.url=t.url,this.width=t.width??0,this.height=t.height??0,this.anchor=t.anchor,this.scale=t.scale??1,t.redraw&&(this.redraw=t.redraw),t.beforeDraw&&(this.beforeDraw=t.beforeDraw),this.img=this.loadImage(t.onload)}loadImage(t){const e=at[this.url];if(e)return queueMicrotask(()=>{t?.(e),this.redraw?.()}),e;{const i=new Image;return i.src=this.url,i.crossOrigin="anonymous",i.onload=()=>{at[this.url]=i,t?.(i),this.redraw?.()},i}}calculateIconPosition(){const t=this.anchor?.x??this.width/2,e=this.anchor?.y??this.height/2;return{iconStartX:this.x-t*this.scale,iconStartY:this.y-e*this.scale}}draw(t,e){if(this.beforeDraw?.(t,e),!this.img?.complete)return;const{iconStartX:i,iconStartY:n}=this.calculateIconPosition();t.save();try{t.drawImage(this.img,i,n,this.width*this.scale,this.height*this.scale)}catch(o){console.error("绘制标记时出错:",o)}finally{t.restore()}}}class $t{type="radar";x;y;r;angle;text;hFov=90;beforeDraw;constructor(t){this.x=t.x,this.y=t.y,this.r=t.r||15,this.angle=t.angle||0,this.text=t.text||"",this.hFov=t.fovh||90,this.beforeDraw=t.beforeDraw}draw(t,e){this.beforeDraw?.(t,e);const i=1/e.scale,[n,o]=[(this.angle-this.hFov/2)/180*Math.PI,(this.angle+this.hFov/2)/180*Math.PI];t.save();const r=t.createRadialGradient(this.x,this.y,0,this.x,this.y,this.r*i);r.addColorStop(0,"rgba(180, 42, 42, 1)"),r.addColorStop(1,"rgba(180, 42, 42, 0.5)"),t.beginPath(),t.moveTo(this.x,this.y),t.arc(this.x,this.y,this.r*i,n,o),t.closePath(),t.fillStyle=r,t.fill(),t.restore()}}class _t{type="region";x;y;shape;areaPoints;backgroundColor;constructor(t){if(this.x=t.x,this.y=t.y,this.shape=t.shape||"",this.backgroundColor=t.backgroundColor,t.areaPoints.length===2){const[{x:e,y:i},{},{x:n,y:o}]=t.areaPoints;this.areaPoints=[{x:Math.min(e,n),y:Math.min(i,o)},{x:Math.max(e,n),y:Math.min(i,o)},{x:Math.max(e,n),y:Math.max(i,o)},{x:Math.min(e,n),y:Math.max(i,o)}]}else this.areaPoints=t.areaPoints}draw(t,e){if(t.save(),t.beginPath(),t.globalAlpha=.3,t.fillStyle=this.backgroundColor,this.shape==="circle"){const[{x:i,y:n},{},{x:o,y:r}]=this.areaPoints,a=Math.abs(o-i)/2,c=i+(o-i)/2,u=n+(r-n)/2;t.arc(c,u,a,0,2*Math.PI)}else this.areaPoints.forEach((i,n)=>{const{x:o,y:r}=i;n===0?t.moveTo(o,r):t.lineTo(o,r)});t.fill(),t.restore()}}l.APP_SETTING=$,l.AppError=m,l.AppErrorCode=g,l.AppObsType=B,l.CanvasElement=Ft,l.CanvasImageElement=Ut,l.CanvasIssueElement=Yt,l.CanvasMarkerElement=Bt,l.CanvasPointElement=Gt,l.CanvasRadarElement=$t,l.CanvasRegionElement=_t,l.Coordinate=A,l.CoordinateLevel=Y,l.CoordinateModelType=M,l.CoordinateStatus=N,l.CoordinateType=x,l.DataHelper=Xt,l.DataSource=p,l.GeoPoint=I,l.Point=y,l.Position=U,l.REQUEST_CONFIG=q,l.REQUEST_OPTIONS=_,l.RelativeMap=w,l.RequestContentType=R,l.RequestMethod=v,l.RequestResultCode=j,l.Vector3=G,l.api=mt,l.http=dt,l.utils=kt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|