leiting-bim 2.1.144 → 2.1.145
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/leiting-bim.es.js +1 -1
- package/leiting-bim.umd.js +1 -1
- package/leitingbim.css +1 -1
- package/package.json +1 -1
- package/plugins/cesium-core/dist/cesium-core.mjs +38 -20
- package/plugins/cesium-core/dist/cesium-core.mjs.map +1 -1
- package/plugins/cesium-core/dist/cesium-core.umd.js +1 -1
- package/plugins/cesium-core/dist/cesium-core.umd.js.map +1 -1
- package/plugins/cesium-core/dist/components/draw/handlers/PolygonDrawer.d.ts +3 -0
- package/plugins/cesium-vue/dist/HtmlOverlayLabelPool-CbiNlyAM.js.map +1 -1
- package/plugins/cesium-vue/dist/cesium-vue/src/components/basic-audio/index.d.ts +1 -11
- package/plugins/cesium-vue/dist/cesium-vue/src/components/basic-video/index.d.ts +1 -95
- package/plugins/cesium-vue/dist/cesium-vue/src/components/card-carousel/index.d.ts +1 -144
- package/plugins/cesium-vue/dist/cesium-vue/src/components/card-content/index.d.ts +1 -13
- package/plugins/cesium-vue/dist/cesium-vue/src/components/card-page/index.d.ts +1 -61
- package/plugins/cesium-vue/dist/cesium-vue/src/components/carousel-img/index.d.ts +1 -31
- package/plugins/cesium-vue/dist/cesium-vue/src/components/echarts-pro/index.d.ts +1 -60
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-bubble/index.d.ts +2 -173
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-default/index.d.ts +1 -49
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-html/index.d.ts +1 -40
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-manage/index.d.ts +1 -166
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-text/index.d.ts +1 -22
- package/plugins/cesium-vue/dist/cesium-vue/src/components/measurement/index.d.ts +1 -70
- package/plugins/cesium-vue/dist/cesium-vue/src/components/position-picker/index.d.ts +1 -55
- package/plugins/cesium-vue/dist/components/marker-bubble.js.map +1 -1
- package/plugins/cesium-vue/dist/components/marker-manage.js.map +1 -1
- package/plugins/cesium-vue/dist/components/measurement.js.map +1 -1
- package/plugins/cesium-vue/dist/components/position-picker.js.map +1 -1
- package/plugins/cesium-vue/dist/index-Kqi_S6KA.js.map +1 -1
- package/plugins/cesium-vue/dist/index-McKGafjp.js.map +1 -1
- package/plugins/cesium-vue/dist/index.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(S,te){typeof exports=="object"&&typeof module<"u"?te(exports):typeof define=="function"&&define.amd?define(["exports"],te):(S=typeof globalThis<"u"?globalThis:S||self,te(S.CesiumCore={}))})(this,(function(S){"use strict";var kn=Object.defineProperty;var Fn=(S,te,V)=>te in S?kn(S,te,{enumerable:!0,configurable:!0,writable:!0,value:V}):S[te]=V;var h=(S,te,V)=>Fn(S,typeof te!="symbol"?te+"":te,V);class te{constructor(t,e,i){h(this,"Cesium");h(this,"viewer");h(this,"labelPool");h(this,"threshold");h(this,"displayLimit");h(this,"maxLevel");h(this,"debugCurrentGrids");h(this,"levels");h(this,"points",[]);h(this,"gridLayers",new Map);h(this,"debugGrids",[]);h(this,"_updateFn");h(this,"clusterTheme");h(this,"pointTheme");h(this,"centralPointMode");h(this,"minGlobalPointCount");h(this,"groupByTheme");h(this,"tilingScheme");h(this,"terrainLevelOffset");h(this,"debugTileCoordLayer",null);h(this,"levelIndexByTileLevel",new Map);h(this,"_lastTileProvider",null);h(this,"_updateTimer",null);h(this,"_updateDelay",100);h(this,"_tilesRetryCount",0);h(this,"_tilesRetryMax",100);h(this,"_cameraDirty",!1);h(this,"_tileLoadListener",null);h(this,"_cameraChangedHandler",null);h(this,"defaultMinLevel",0);h(this,"defaultMaxLevel",28);h(this,"maxRefineLevels",2);this.Cesium=t,this.viewer=e,this.labelPool=i.labelPool,this.threshold=i.threshold??10,this.displayLimit=i.displayLimit??100,this.maxLevel=i.maxLevel??5,this.debugCurrentGrids=i.debugCurrentGrids??!1,this.clusterTheme=i.clusterTheme??"cluster-label",this.pointTheme=i.pointTheme??"point-label",this.centralPointMode=i.centralPointMode??"central",this.minGlobalPointCount=i.minGlobalPointCount??0,this.groupByTheme=i.groupByTheme??!1,this.terrainLevelOffset=i.terrainLevelOffset??2;const n=this.viewer.scene&&this.viewer.scene.globe,s=n&&n._surface,o=s&&s._tileProvider,r=(o==null?void 0:o.tilingScheme)||new this.Cesium.GeographicTilingScheme;this._lastTileProvider=o,this.tilingScheme=r,this.levels=this._createLevels(),this._buildLevels(),this._updateFn=this._update.bind(this),this.debugCurrentGrids&&this._ensureDebugImageryLayer(),n&&(this._tileLoadListener=l=>{l===0&&this._cameraDirty&&(this._cameraDirty=!1,this._scheduleUpdate())},n.tileLoadProgressEvent.addEventListener(this._tileLoadListener)),this._cameraChangedHandler=()=>{this._update()},this.viewer.camera.changed.addEventListener(this._cameraChangedHandler)}setGroupByTheme(t,e=!0,i=!0){if(this.groupByTheme===t){i&&this._update();return}this.groupByTheme=t,e&&this._buildLevels(),i&&this._update()}setMinGlobalPointCount(t,e=!0){this.minGlobalPointCount=t,e&&this._update()}setThreshold(t,e=!0){this.threshold=t,e&&this._update()}setDebugCurrentGrids(t,e=!0){this.debugCurrentGrids=t,t?this._ensureDebugImageryLayer():(this._clearDebugGrids(),this._removeDebugImageryLayer()),e&&this._update()}_syncTilingSchemeAndLevels(){const t=this.viewer.scene&&this.viewer.scene.globe,e=t&&t._surface,i=e&&e._tileProvider,n=(i==null?void 0:i.tilingScheme)||new this.Cesium.GeographicTilingScheme,s=i!==this._lastTileProvider,o=this.tilingScheme!==n;!s&&!o&&this.levels&&this.levels.length>0||(this._lastTileProvider=i,this.tilingScheme=n,this.levels=this._createLevels(),this._buildLevels(),this.debugCurrentGrids&&(this._removeDebugImageryLayer(),this._ensureDebugImageryLayer()))}_createLevels(){const t=[];this.levelIndexByTileLevel=new Map;const e=0,i=this.maxLevel;let n=0;for(let s=e;s<=i;s++,n++){const o=360/Math.pow(2,s);t.push({level:s,size:o,minViewWidth:o*4}),this.levelIndexByTileLevel.set(s,n)}return t}addPoints(t){this.points=t,this._buildLevels()}appendPoints(t,e=!0){for(const i of t)this._preparePointLevelRange(i),this.points.push(i);for(const i of t)this._addPointToGrid(i);e&&this._scheduleUpdate()}_scheduleUpdate(){this._updateTimer!==null&&clearTimeout(this._updateTimer),this._updateTimer=window.setTimeout(()=>{this._update(),this._cameraDirty=!0,this._updateTimer=null},this._updateDelay)}updatePoint(t){var s,o,r,l;const e=this.points.findIndex(c=>c.id===t.id);if(e===-1)return;const i=this.points[e];for(const c of this.levels){const d=c.level,u=this.gridLayers.get(d);if(!u)continue;const m=this.Cesium.Cartographic.fromDegrees(i.lon,i.lat),g=this.tilingScheme.positionToTileXY(m,d,new this.Cesium.Cartesian2);if(!g)continue;const p=`${g.x}_${g.y}`,f=u.get(p);if(f){const w=f.allPoints.findIndex(y=>y.id===t.id);if(w!==-1&&f.allPoints.splice(w,1),(r=(o=(s=i.data)==null?void 0:s.billboard)==null?void 0:o[0])!=null&&r.skipAggregation){const y=f.skipPoints.findIndex(v=>v.id===t.id);y!==-1&&f.skipPoints.splice(y,1)}else{const y=this.groupByTheme?(l=i.data)==null?void 0:l.theme:this.clusterTheme,v=f.groups.get(y);if(v){const C=v.findIndex(b=>b.id===t.id);C!==-1&&v.splice(C,1),v.length===0&&f.groups.delete(y)}}}}const n={...i,...t};this.points[e]=n,this._addPointToGrid(n),this._update()}removePointsById(t){const e=new Set(t);this.points=this.points.filter(i=>!e.has(i.id));for(const i of this.levels){const n=this.gridLayers.get(i.level);if(n)for(const[s,o]of n.entries()){o.allPoints=o.allPoints.filter(r=>!e.has(r.id)),o.skipPoints=o.skipPoints.filter(r=>!e.has(r.id));for(const[r,l]of o.groups.entries()){const c=l.filter(d=>!e.has(d.id));c.length===0?o.groups.delete(r):o.groups.set(r,c)}o.allPoints.length===0&&n.delete(s)}}this._update()}_buildLevels(){this.gridLayers.clear();for(const t of this.levels)this.gridLayers.set(t.level,new Map);for(const t of this.points)this._addPointToGrid(t)}_addPointToGrid(t){var e,i,n,s,o,r;for(const l of this.levels){const c=l.level,d=this.gridLayers.get(c);if(!d)continue;const u=this.Cesium.Cartographic.fromDegrees(t.lon,t.lat),m=this.tilingScheme.positionToTileXY(u,c,new this.Cesium.Cartesian2);if(!m)continue;const g=`${m.x}_${m.y}`;let p=d.get(g);if(p||(p={allPoints:[],groups:new Map,skipPoints:[]},d.set(g,p)),p.allPoints.push(t),(n=(i=(e=t.data)==null?void 0:e.billboard)==null?void 0:i[0])!=null&&n.skipAggregation)p.skipPoints.push(t);else{const f=this.groupByTheme?(r=(o=(s=t.data)==null?void 0:s.billboard)==null?void 0:o[0])==null?void 0:r.theme:this.clusterTheme;p.groups.has(f)||p.groups.set(f,[]),p.groups.get(f).push(t)}}}_preparePointLevelRange(t){const e=t.data||{};let i=e.minLevel,n=e.maxLevel;const s=e.levelRange;Array.isArray(s)?(s.length>0&&i==null&&(i=s[0]),s.length>1&&n==null&&(n=s[1])):s&&typeof s=="object"&&(i==null&&typeof s.min=="number"&&(i=s.min),n==null&&typeof s.max=="number"&&(n=s.max));const o=i==null?this.defaultMinLevel:Number(i)||this.defaultMinLevel,r=n==null?this.defaultMaxLevel:Number(n)||this.defaultMaxLevel;t.__minLevel=o,t.__maxLevel=r}_isVisibleAtLevel(t,e){if(e==null)return!0;(t.__minLevel===void 0||t.__maxLevel===void 0)&&this._preparePointLevelRange(t);const i=t.__minLevel??this.defaultMinLevel,n=t.__maxLevel??this.defaultMaxLevel;return e>=i&&e<=n}_update(){if(!this.labelPool)return;this._syncTilingSchemeAndLevels(),this.labelPool.reset(),this.debugCurrentGrids&&this._clearDebugGrids();const t=this.points.length<this.minGlobalPointCount?1/0:this.threshold;let e=0;const i=(n,s,o,r)=>{e=this._processCell(n,s,o,r,t,e)};try{const n=this._getSurfaceTiles();if(!n||n.length===0){this._handleNoSurfaceTiles(e);return}this._tilesRetryCount=0,this._processTiles(n,i)}catch{this.labelPool.cleanup();return}this.labelPool.cleanup()}_getSurfaceTiles(){const t=this.viewer.scene&&this.viewer.scene.globe,e=t&&t._surface;if(e)return e._tilesToRender||e._tilesToRenderByTextureCount}_handleNoSurfaceTiles(t){var e,i,n,s;for(const o of this.points){if(t>=this.displayLimit)break;((e=o.data)==null?void 0:e.show)!==!1&&(this.labelPool.add(o.data,{id:`point-${o.id}`,lon:o.lon,lat:o.lat,height:o.height,theme:((s=(n=(i=o.data)==null?void 0:i.billboard)==null?void 0:n[0])==null?void 0:s.theme)||this.pointTheme,style:o.style}),t++)}this.labelPool.cleanup(),this.points.length>0&&this._tilesRetryCount<this._tilesRetryMax&&(this._tilesRetryCount++,this._scheduleUpdate())}_resolveLevelIndex(t){let e=this.levelIndexByTileLevel.get(t);if(e!==void 0)return e;if(this.levels.length===0)return;const i=this.levels[0].level,n=this.levels[this.levels.length-1].level;if(t>n)return this.levels.length-1;if(t<i)return 0;let s=0,o=1/0;for(let r=0;r<this.levels.length;r++){const l=Math.abs(this.levels[r].level-t);l<o&&(o=l,s=r)}return s}_isTerrainEnabled(){const t=this.viewer.terrainProvider,e=this.viewer.scene,i=e&&e.globe,n=i&&i.terrainProvider,s=t||n;return s?!(s instanceof this.Cesium.EllipsoidTerrainProvider):!1}_getGridRefLevel(t){let e=t;if(this._isTerrainEnabled()&&(e+=this.terrainLevelOffset),this.levels.length>0){const i=this.levels[this.levels.length-1].level;e>i&&(e=i)}return e}_processTiles(t,e){const i=new Set,n=!this._isTerrainEnabled(),s=this.viewer.scene,o=s&&s.globe,r=o&&o.ellipsoid,l=r&&s.camera.computeViewRectangle(r),c=(d,u,m)=>{if(!n||!l)return!0;const g=this.tilingScheme.tileXYToRectangle(d,u,m);return!(!g||g.east<=l.west||g.west>=l.east||g.north<=l.south||g.south>=l.north)};for(const d of t){const u=d.rectangle,m=d._level??d.level;if(!u||typeof m!="number")continue;const g=this._getGridRefLevel(m),p=this._resolveLevelIndex(g);if(p===void 0)continue;const f=this.levels[p].level,w=d._x??d.x,y=d._y??d.y;if(typeof w=="number"&&typeof y=="number"){const T=m-f;if(T>=0){const $=1<<T,D=Math.floor(w/$),k=Math.floor(y/$),_=`${f}_${D}_${k}`;if(i.has(_))continue;i.add(_),e(p,D,k,m)}else{const D=1<<Math.min(-T,this.maxRefineLevels),k=w*D,_=y*D;for(let O=0;O<D;O++)for(let R=0;R<D;R++){const G=k+O,B=_+R;if(!c(G,B,f))continue;const j=`${f}_${G}_${B}`;i.has(j)||(i.add(j),e(p,G,B,m))}}continue}const C=this.levels[p].size,b=this.Cesium.Math.toDegrees(u.west),M=this.Cesium.Math.toDegrees(u.east),P=this.Cesium.Math.toDegrees(u.south),L=this.Cesium.Math.toDegrees(u.north),E=Math.floor((b- -180)/C),I=Math.floor((M- -180)/C),A=Math.floor((P- -90)/C),x=Math.floor((L- -90)/C);for(let T=E;T<=I;T++)for(let $=A;$<=x;$++){if(!c(T,$,f))continue;const D=`${f}_${T}_${$}`;i.has(D)||(i.add(D),e(p,T,$,m))}}}_processCell(t,e,i,n,s,o){if(o>=this.displayLimit||t<0)return o;t>=this.levels.length&&(t=this.levels.length-1);const r=this._getCellContext(t,e,i,n);return r?(o=this._processCellSkipPoints(r,o),o>=this.displayLimit?(this._debugDrawCell(r),o):(o=this._processCellGroups(r,s,o),this._debugDrawCell(r),o)):o}_getCellContext(t,e,i,n){const o=this.levels[t].level,r=this.gridLayers.get(o);if(!r)return null;const l=`${e}_${i}`,c=r.get(l);if(!c)return null;const d=this.tilingScheme.tileXYToRectangle(e,i,o),u=this.Cesium.Math.toDegrees(d.west),m=this.Cesium.Math.toDegrees(d.south),g=this.Cesium.Math.toDegrees(d.east),p=this.Cesium.Math.toDegrees(d.north),f=(u+g)/2,w=(m+p)/2;return{levelIdx:t,tileLevel:o,lonIdx:e,latIdx:i,key:l,cell:c,rect:d,west:u,south:m,east:g,north:p,centerLon:f,centerLat:w,viewTileLevel:n}}_processCellSkipPoints(t,e){var o,r,l,c;const{cell:i,viewTileLevel:n}=t,s=n;for(const d of i.skipPoints)if(((o=d.data)==null?void 0:o.show)!==!1){if(e>=this.displayLimit)break;this._isVisibleAtLevel(d,s)&&(this.labelPool.add(d.data,{id:`point-${d.id}`,lon:d.lon,lat:d.lat,height:d.height,theme:((c=(l=(r=d.data)==null?void 0:r.billboard)==null?void 0:l[0])==null?void 0:c.theme)||this.pointTheme,style:d.style}),e++)}return e}_processCellGroups(t,e,i){var m,g,p,f,w,y,v,C,b,M,P,L,E;const{levelIdx:n,lonIdx:s,latIdx:o,cell:r,centerLon:l,centerLat:c,viewTileLevel:d}=t,u=d;for(const[I,A]of r.groups){const x=A.filter(_=>{var O;return((O=_.data)==null?void 0:O.show)!==!1});if(x.length===0)continue;let T=l,$=c,D=((m=x[0])==null?void 0:m.height)||0;if(this.centralPointMode=="firstPoint"&&(T=((g=x[0])==null?void 0:g.lon)||0,$=((p=x[0])==null?void 0:p.lat)||0,D=((f=x[0])==null?void 0:f.height)||0),n===this.levels.length-1||x.length<e)for(const _ of x){if(i>=this.displayLimit)break;this._isVisibleAtLevel(_,u)&&(this.labelPool.add(_.data,{id:`point-${_.id}`,lon:_.lon,lat:_.lat,height:_.height,theme:((v=(y=(w=_.data)==null?void 0:w.billboard)==null?void 0:y[0])==null?void 0:v.theme)||this.pointTheme,style:_.style}),i++)}else{if(i>=this.displayLimit)return i;const _=u==null?x:x.filter(B=>this._isVisibleAtLevel(B,u));if(!_.length)return i;const R=((P=(M=(b=(C=_[0])==null?void 0:C.data)==null?void 0:b.billboard)==null?void 0:M[0])==null?void 0:P.theme)||this.clusterTheme,G=this.groupByTheme?`cluster-${n}-${s}-${o}-${I}`:`cluster-${n}-${s}-${o}`;this.labelPool.add({id:G,billboard:((E=(L=_[0])==null?void 0:L.data)==null?void 0:E.billboard)||[],count:_.length,gridKey:`${s}_${o}`,points:_,aggregationGroup:I},{id:G,lon:T,lat:$,height:D,theme:R}),i++}}return i}_debugDrawCell(t){if(!this.debugCurrentGrids)return;const{levelIdx:e,west:i,south:n,east:s,north:o,lonIdx:r,latIdx:l}=t,c=this.levels[e].level;this._drawDebugGrid(i,n,s,o,`L:${c} X:${r} Y:${l}`)}refresh(){this._update()}_drawDebugGrid(t,e,i,n,s){const o=this.Cesium.Rectangle.fromDegrees(t,e,i,n),r=this.Cesium.Cartesian3.fromDegreesArray([t,e,i,e,i,n,t,n,t,e]),l=this.viewer.entities.add({rectangle:{coordinates:o,material:this.Cesium.Color.YELLOW.withAlpha(.2),outline:!0,outlineColor:this.Cesium.Color.RED,heightReference:this.Cesium.HeightReference.CLAMP_TO_GROUND,classificationType:this.Cesium.ClassificationType.TERRAIN},polyline:{positions:r,width:2,material:this.Cesium.Color.RED,clampToGround:!0},label:{text:s,font:"14px sans-serif",fillColor:this.Cesium.Color.BLACK,outlineColor:this.Cesium.Color.WHITE,outlineWidth:2,style:this.Cesium.LabelStyle.FILL_AND_OUTLINE,verticalOrigin:this.Cesium.VerticalOrigin.CENTER,horizontalOrigin:this.Cesium.HorizontalOrigin.CENTER}});this.debugGrids.push(l)}_clearDebugGrids(){for(const t of this.debugGrids)this.viewer.entities.remove(t);this.debugGrids=[]}_ensureDebugImageryLayer(){if(this.debugTileCoordLayer||!this.viewer||!this.viewer.imageryLayers)return;const t={tilingScheme:this.tilingScheme};this.debugTileCoordLayer=this.viewer.imageryLayers.addImageryProvider(new this.Cesium.TileCoordinatesImageryProvider(t))}_removeDebugImageryLayer(){if(!(!this.debugTileCoordLayer||!this.viewer||!this.viewer.imageryLayers)){try{this.viewer.imageryLayers.remove(this.debugTileCoordLayer,!1)}catch{}this.debugTileCoordLayer=null}}destroy(){this._cameraChangedHandler&&(this.viewer.camera.changed.removeEventListener(this._cameraChangedHandler),this._cameraChangedHandler=null);const t=this.viewer.scene,e=t&&t.globe;e&&this._tileLoadListener&&(e.tileLoadProgressEvent.removeEventListener(this._tileLoadListener),this._tileLoadListener=null),this._updateTimer!==null&&(clearTimeout(this._updateTimer),this._updateTimer=null),this.labelPool.reset(),this._clearDebugGrids(),this._removeDebugImageryLayer()}}var V=(a=>(a.Click="marker:click",a.DoubleClick="marker:dblclick",a.RightClick="marker:rightclick",a.MouseEnter="marker:mouseenter",a.MouseLeave="marker:mouseleave",a.MouseDown="marker:mousedown",a.MouseUp="marker:mouseup",a))(V||{});class tt{constructor(){h(this,"listenerMap",new Map)}addListener(t,e,i=!1){let n=this.listenerMap.get(t);return n||(n=new Map,this.listenerMap.set(t,n)),n.has(e.name)?i?(console.warn(`[MarkerEventBus] Overwriting listener "${e.name}" for event "${t}".`),n.set(e.name,e),!0):(console.warn(`[MarkerEventBus] Listener "${e.name}" for event "${t}" already exists. Use overwrite=true to replace it.`),!1):(n.set(e.name,e),!0)}removeListenerByKey(t){const e=this.listenerMap.has(t);return this.listenerMap.set(t,new Map),e}removeListenerByKeyAndName(t,e){const i=this.listenerMap.get(t);return i?i.delete(e):!1}runListener(t,e,i){const n=this.listenerMap.get(t);if(n)for(const[s,o]of n.entries()){try{o.fn(e,i)}catch(r){console.error(`Error in listener "${s}" for event "${t}":`,r)}o.once&&n.delete(s)}}}const it={[V.Click]:"click",[V.DoubleClick]:"dblclick",[V.RightClick]:"contextmenu",[V.MouseEnter]:"mouseenter",[V.MouseLeave]:"mouseleave",[V.MouseDown]:"mousedown",[V.MouseUp]:"mouseup"};class N{constructor(t,e,i="html-label-container",n,s=!0){h(this,"viewer");h(this,"Cesium");h(this,"container");h(this,"labels",new Map);h(this,"activeIds",new Set);h(this,"occludedIds",new Set);h(this,"_updateFn");h(this,"_cameraChangedFn");h(this,"themes",{});h(this,"occlusionCheckLogs",[]);h(this,"occlusionLogEnabled",!1);h(this,"occlusionLogMax",1e4);h(this,"occlusionOptions",{enabled:!1,throttleMs:120,distanceEpsilon:1});h(this,"_occlusionTimer",null);h(this,"_lastOcclusionAt",0);h(this,"_occlusionChecking",!1);h(this,"_occlusionPending",!1);h(this,"eventBus");h(this,"openWheel",!0);this.Cesium=t,this.viewer=e,this.container=this._createContainer(i),this._updateFn=this._update.bind(this),this.viewer.scene.postRender.addEventListener(this._updateFn),this._cameraChangedFn=this._scheduleOcclusionCheck.bind(this),this.viewer.camera.changed.addEventListener(this._cameraChangedFn),this.eventBus=n||new tt,this.openWheel=s,this.runOcclusionCheckNow()}_createContainer(t){let e=document.getElementById(t);return e||(e=document.createElement("div"),e.id=t,Object.assign(e.style,{position:"absolute",top:"0",left:"0",pointerEvents:"none",width:"100%",height:"100%",zIndex:"100",overflow:"hidden"}),document.body.appendChild(e)),e}registerTheme(t,e){this.themes[t]=e}add(t,e){const{id:i,lon:n,lat:s,height:o=0,theme:r,show:l=!0,notCreateElement:c=!1,style:d}=e,u=this.themes[r];if(!u){console.warn(`Theme "${r}" not registered`);return}let m=this.labels.get(i);if(m){m.theme=r,m.data=t,m.notCreateElement=c;try{m.unload=u.createElement(m.el,{id:i,theme:r,data:t},u),(!c||l)&&this.container.appendChild(m.el)}catch(g){console.error(`Error updating label element for id "${i}":`,g)}}else{const g=document.createElement("div");Object.assign(g.style,{position:"absolute",transform:"translate(0, 0)",pointerEvents:"auto",...e.style||{}});for(const[f,w]of Object.entries(it)){g.addEventListener(w,v=>{v.stopPropagation();const C=this.labels.get(i);this.eventBus.runListener(f,C,v)});let y=0;g.addEventListener("wheel",v=>{if(!this.openWheel)return;const C=v.currentTarget;y=Date.now();const b=y;C.style.pointerEvents="none",setTimeout(()=>{y===b&&(C.style.pointerEvents="auto")},2e3)})}let p=null;if(!c||l){try{p=u.createElement(g,{id:i,theme:r,data:t},u)||{}}catch(f){console.error(`Error updating label element for id "${i}":`,f)}this.container.appendChild(g)}m={id:i,el:g,theme:r,data:t,notCreateElement:c,unload:p},this.labels.set(i,m)}m.el.dataset.lon=String(n),m.el.dataset.lat=String(s),m.el.dataset.height=String(o),m.el.style.zIndex=(d==null?void 0:d.zIndex)||"1",m.el.style.display=l?"block":"none",l&&this.activeIds.add(i),l?this._scheduleOcclusionCheck():this.occludedIds.delete(i)}addBatch(t){for(const{data:e,options:i}of t)this.add(e,i)}removeByIds(t){for(const e of t){const i=this.labels.get(e);i&&(this.unloadByLabel(i),this.labels.delete(e),this.activeIds.delete(e),this.occludedIds.delete(e))}}unloadByLabel(t){t.el.remove(),t!=null&&t.unload&&typeof t.unload=="function"&&(t==null||t.unload()),t.unload=null}removeAll(){for(const t of this.labels.values())this.unloadByLabel(t);this.labels.clear(),this.activeIds.clear(),this.occludedIds.clear()}update(t,e){const i=this.labels.get(t);if(!i){console.warn(`Label with id "${t}" not found for update.`);return}const n=this.themes[i.theme];if(!n){console.warn(`Theme "${i.theme}" not registered.`);return}try{n.createElement(i.el,{id:t,theme:i.theme,data:e},n)}catch(s){console.error(`Failed to update label "${t}":`,s)}}hideByIds(t){for(const e of t){const i=this.labels.get(e);i&&(i.notCreateElement&&this.unloadByLabel(i),i.el.style.display="none",this.activeIds.delete(e),this.occludedIds.delete(e))}}hideAll(){for(const t of this.labels.values())t.notCreateElement&&this.unloadByLabel(t),t.el.style.display="none",this.activeIds.delete(t.id),this.occludedIds.delete(t.id)}hideFilter(t){for(const e of this.labels.values())t(e.data)&&(e.notCreateElement&&this.unloadByLabel(e),e.el.style.display="none",this.activeIds.delete(e.id),this.occludedIds.delete(e.id))}showByIds(t){for(const e of t){const i=this.labels.get(e);if(i){if((i.notCreateElement||!i.el.parentNode)&&this.container.appendChild(i.el),!i.unload)try{const n=this.themes[i.theme];if(!n){console.warn(`Theme "${i.theme}" not registered`);return}i.unload=n.createElement(i.el,{id:e,theme:i.theme,data:i.data},n)||{}}catch(n){console.error(`Error creating label element for theme "${i.theme}":`,n);return}i.el.style.display="block",this.activeIds.add(e),this.occludedIds.delete(e)}}this._scheduleOcclusionCheck()}has(t){return this.labels.has(t)}reset(){for(const t of this.activeIds.values()){let e=this.labels.get(t);e&&this.unloadByLabel(e)}this.activeIds.clear()}cleanup(){for(const[t,e]of this.labels.entries())this.activeIds.has(t)||(e.el.style.display="none",this.occludedIds.delete(t))}async toWindowPositionByLonLat(t,e){const i=this.Cesium,n=this.viewer.scene,s=[i.Cartographic.fromDegrees(t,e)];let o;try{o=await n.clampToHeightMostDetailed(s)}catch{console.warn("clampToHeightMostDetailed failed, fallback to ellipsoid height.")}let r=0;o&&o[0]&&o[0].height!=null?r=o[0].height:r=0;const l=i.Cartesian3.fromDegrees(t,e,r);return this.toWindowCoordinates(l)}toWindowCoordinates(t){const e=this.viewer.scene,i=this.Cesium.SceneTransforms;if(typeof(i==null?void 0:i.wgs84ToWindowCoordinates)=="function")return i.wgs84ToWindowCoordinates(e,t);if(typeof(i==null?void 0:i.worldToWindowCoordinates)=="function")return i.worldToWindowCoordinates(e,t);console.warn("No compatible window coordinate transform function found.")}_isValidCoordinate(t,e){return!(Number.isNaN(t)||Number.isNaN(e)||t===0&&e===0||t<-180||t>180||e<-90||e>90)}async _update(){var t;for(const e of this.activeIds){const i=this.labels.get(e);if(!i)continue;const n=parseFloat(i.el.dataset.lon),s=parseFloat(i.el.dataset.lat),o=parseFloat(i.el.dataset.height||"0");if(!this._isValidCoordinate(n,s)){i.el.style.display="none";continue}const r=this.Cesium.Cartesian3.fromDegrees(n,s,o),l=this.toWindowCoordinates(r);if(this.Cesium.defined(l)){const d=((t=this.themes[i.theme].options)==null?void 0:t.offset)||{},u=d.x||0,m=d.y||0,g=this.occludedIds.has(e);i.el.style.left=`${l.x}px`,i.el.style.top=`${l.y}px`,i.el.style.transform=`translate(${u}px, ${m}px)`,i.el.style.display=g?"none":"block"}else i.el.style.display="none"}}_scheduleOcclusionCheck(){if(!this.occlusionOptions.enabled)return;const t=Date.now(),e=Math.max(0,Number(this.occlusionOptions.throttleMs)||0),i=t-this._lastOcclusionAt,n=Math.max(0,e-i);if(n===0){this.runOcclusionCheckNow();return}this._occlusionTimer===null&&(this._occlusionTimer=window.setTimeout(()=>{this._occlusionTimer=null,this.runOcclusionCheckNow()},n))}_pushOcclusionLog(t){this.occlusionLogEnabled&&(this.occlusionCheckLogs.push(t),this.occlusionCheckLogs.length>this.occlusionLogMax&&this.occlusionCheckLogs.splice(0,this.occlusionCheckLogs.length-this.occlusionLogMax))}_computeLabelOccluded(t,e,i,n,s,o){var d,u;const r=(d=this.viewer)==null?void 0:d.scene,l=(u=this.viewer)==null?void 0:u.camera,c=this.Cesium;if(!r||!l||!c)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"runtime-missing"}),!0;if(!r.pickPositionSupported||!i)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-unsupported"}),!0;try{const m=r.pickPosition(i);if(!m||!l.positionWC)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-empty"}),!0;const g=Number(this.occlusionOptions.distanceEpsilon)||0,p=c.Cartesian3.distance(l.positionWC,e),f=c.Cartesian3.distance(l.positionWC,m),w=f+g<p;return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:w,reason:"distance-compare",epsilon:g,labelDistance:p,pickedDistance:f}),w}catch{return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-error"}),!0}}runOcclusionCheckNow(){if(!this.occlusionOptions.enabled){this.occludedIds.clear();return}if(this._occlusionChecking){this._occlusionPending=!0;return}this._occlusionChecking=!0;try{for(const t of this.activeIds){const e=this.labels.get(t);if(!e){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,occluded:!1,reason:"label-missing"});continue}const i=parseFloat(e.el.dataset.lon),n=parseFloat(e.el.dataset.lat),s=parseFloat(e.el.dataset.height||"0");if(!this._isValidCoordinate(i,n)){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:i,lat:n,height:s,occluded:!1,reason:"invalid-coordinate"});continue}const o=this.Cesium.Cartesian3.fromDegrees(i,n,s),r=this.toWindowCoordinates(o);if(!this.Cesium.defined(r)){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:i,lat:n,height:s,occluded:!1,reason:"screen-position-undefined"});continue}this._computeLabelOccluded(t,o,r,i,n,s)?this.occludedIds.add(t):this.occludedIds.delete(t)}}finally{this._lastOcclusionAt=Date.now(),this._occlusionChecking=!1,this._occlusionPending&&(this._occlusionPending=!1,this._scheduleOcclusionCheck())}}setOcclusionEnabled(t){this.occlusionOptions.enabled=!!t,this.occlusionOptions.enabled?this.runOcclusionCheckNow():(this.occludedIds.clear(),this._occlusionTimer!==null&&(clearTimeout(this._occlusionTimer),this._occlusionTimer=null))}getOcclusionOptions(){return{enabled:this.occlusionOptions.enabled,throttleMs:this.occlusionOptions.throttleMs,distanceEpsilon:this.occlusionOptions.distanceEpsilon}}setOcclusionOptions(t){t.throttleMs!=null&&(this.occlusionOptions.throttleMs=Math.max(0,Number(t.throttleMs)||0)),t.distanceEpsilon!=null&&(this.occlusionOptions.distanceEpsilon=Math.max(0,Number(t.distanceEpsilon)||0)),this.occlusionOptions.enabled&&this._scheduleOcclusionCheck()}setOcclusionLogEnabled(t,e=!1){this.occlusionLogEnabled=!!t,e&&(this.occlusionCheckLogs=[])}destroy(){this.viewer.scene.postRender.removeEventListener(this._updateFn),this.viewer.camera.changed.removeEventListener(this._cameraChangedFn),this._occlusionTimer!==null&&(clearTimeout(this._occlusionTimer),this._occlusionTimer=null),this.labels.clear(),this.activeIds.clear(),this.occludedIds.clear()}}class _e{constructor(){h(this,"tooltipEl");h(this,"visible",!1);h(this,"offsetX",10);h(this,"offsetY",-20);h(this,"onMouseMove",null);this.tooltipEl=document.createElement("div"),this.tooltipEl.style.position="fixed",this.tooltipEl.style.pointerEvents="none",this.tooltipEl.style.zIndex="10000",this.tooltipEl.style.padding="4px 8px",this.tooltipEl.style.borderRadius="4px",this.tooltipEl.style.background="rgba(0, 0, 0, 0.7)",this.tooltipEl.style.color="#fff",this.tooltipEl.style.fontSize="13px",this.tooltipEl.style.transition="opacity 0.1s ease",this.tooltipEl.style.opacity="0",document.body.appendChild(this.tooltipEl),this.onMouseMove=t=>{this.visible&&(this.tooltipEl.style.left=`${t.clientX+this.offsetX}px`,this.tooltipEl.style.top=`${t.clientY+this.offsetY}px`)},window.addEventListener("mousemove",this.onMouseMove)}show(t){this.tooltipEl.innerText=t,this.tooltipEl.style.opacity="1",this.visible=!0}hide(){this.tooltipEl.style.opacity="0",this.visible=!1}destroy(){this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.tooltipEl.parentElement&&this.tooltipEl.parentElement.removeChild(this.tooltipEl)}}class Gt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"tooltip",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.tooltip=new _e,this.tooltip.show("左键添加点"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var m,g;const s=i.scene.pickPosition(n.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(o.longitude),l=e.Math.toDegrees(o.latitude),c=o.height,d=i.entities.add({position:s,point:{pixelSize:10,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.entity=d;const u={entity:d,position:s,lnglat:{lng:r,lat:l,height:c},clear:()=>{this.clear()}};(m=t.onComplete)==null||m.call(t,u),this.stopDrawing(),(g=this.tooltip)==null||g.hide(),this.tooltip=null},e.ScreenSpaceEventType.LEFT_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.stopDrawing()}}class Bt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}getPickPosition(t){var s,o,r,l;const{viewer:e}=this,i=e==null?void 0:e.scene;if(!i||!t)return null;let n=null;try{i.pickPositionSupported&&(n=i.pickPosition(t))}catch(c){console.warn("[LineDrawer] pickPosition failed:",c)}if(!n){const c=(o=(s=e.camera)==null?void 0:s.getPickRay)==null?void 0:o.call(s,t);c&&(n=((l=(r=i.globe)==null?void 0:r.pick)==null?void 0:l.call(r,c,i))||null)}return n}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.entity=null,this.tooltip=new _e,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var r,l;const s=this.getPickPosition(n.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(o),this.entity?this.entity.polyline.positions=this.positions.slice():this.entity=i.entities.add({polyline:{positions:this.positions.slice(),width:3,material:t.color||e.Color.YELLOW,depthFailMaterial:((l=(r=t.color)==null?void 0:r.withAlpha)==null?void 0:l.call(r,.5))||e.Color.YELLOW.withAlpha(.5)}})},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var o,r;if(this.stopDrawing(),(o=this.tooltip)==null||o.hide(),this.tooltip=null,this.positions.length<2)return;this.positions.length=this.positions.length-1,this.entity&&(this.entity.polyline.positions=this.positions.slice());const n=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:n,clear:()=>{this.clear()}};(r=t.onComplete)==null||r.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class jt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"startPoint",null);h(this,"endPoint",null);h(this,"entity",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var o;const s=i.scene.pickPosition(n.position);if(s)if(!this.startPoint)this.startPoint=s,this.entity=i.entities.add({rectangle:{coordinates:new e.CallbackProperty(()=>{if(!(!this.startPoint||!this.endPoint))try{const r=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c=Math.min(r.longitude,l.longitude),d=Math.max(r.longitude,l.longitude),u=Math.min(r.latitude,l.latitude),m=Math.max(r.latitude,l.latitude);return new e.Rectangle(c,u,d,m)}catch(r){console.warn("Rectangle calculation error:",r);return}},!1),material:t.color||e.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:e.Color.BLACK,disableDepthTestDistance:Number.POSITIVE_INFINITY}});else{this.stopDrawing();const r=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c={lng:e.Math.toDegrees(Math.min(r.longitude,l.longitude)),lat:e.Math.toDegrees(Math.min(r.latitude,l.latitude)),height:0},d={lng:e.Math.toDegrees(Math.max(r.longitude,l.longitude)),lat:e.Math.toDegrees(Math.max(r.latitude,l.latitude)),height:0},u={entity:this.entity,position:this.startPoint,lnglat:{lng:e.Math.toDegrees(r.longitude),lat:e.Math.toDegrees(r.latitude),height:r.height},positions:[this.startPoint,this.endPoint],lnglats:[c,d],clear:()=>{this.clear()}};(o=t.onComplete)==null||o.call(t,u)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{if(!this.startPoint)return;const s=i.scene.pickPosition(n.endPosition);s&&(this.endPoint=s)},e.ScreenSpaceEventType.MOUSE_MOVE)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.startPoint=null,this.endPoint=null,this.stopDrawing()}}class Yt{constructor(t,e){h(this,"viewer");h(this,"Cesium");h(this,"handler",null);h(this,"entity",null);h(this,"positions",[]);h(this,"_isDrawing",!1);h(this,"currentRadius",0);this.Cesium=t,this.viewer=e}startDrawing(t){this.clear(),this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.canvas),this._isDrawing=!0,this.handler.setInputAction(e=>{const i=this.viewer.scene.pickPosition(e.position);i&&(this.positions.push(i),this.positions.length===2&&(this.stopDrawing(),this.drawFinalCircle(t)))},this.Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(e=>{if(this.positions.length!==1)return;const i=this.positions[0],n=this.viewer.camera.getPickRay(e.endPosition),s=this.viewer.scene.globe.pick(n,this.viewer.scene);s&&this.drawPreviewCircle(i,s,t)},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}drawPreviewCircle(t,e,i){const n=this.Cesium.Cartesian3.distance(t,e);if(this.entity)Math.abs(this.currentRadius-n)>.5&&(this.currentRadius=n);else{this.currentRadius=n;const s=new this.Cesium.CallbackProperty(()=>this.currentRadius,!1);this.entity=this.viewer.entities.add({position:t,ellipse:{semiMajorAxis:s,semiMinorAxis:s,material:i.color||this.Cesium.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:i.color||this.Cesium.Color.YELLOW,heightReference:this.Cesium.HeightReference.NONE,disableDepthTestDistance:Number.POSITIVE_INFINITY}})}}drawFinalCircle(t){var u;const[e,i]=this.positions,n=this.Cesium.Cartesian3.distance(e,i),s=this.Cesium.Cartographic.fromCartesian(e),o={lng:this.Cesium.Math.toDegrees(s.longitude),lat:this.Cesium.Math.toDegrees(s.latitude),height:s.height},r=(t==null?void 0:t.step)||1,l=[],c=[];for(let m=0;m<360;m+=r){const g=this.Cesium.Math.toRadians(m),p=new this.Cesium.EllipsoidGeodesic;p.setEndPoints(s,new this.Cesium.Cartographic(s.longitude+1e-4*Math.cos(g),s.latitude+1e-4*Math.sin(g)));const f=p.interpolateUsingSurfaceDistance(n),w=this.Cesium.Ellipsoid.WGS84.cartographicToCartesian(f);l.push(w);const y=this.Cesium.Cartographic.fromCartesian(w);c.push({lng:this.Cesium.Math.toDegrees(y.longitude),lat:this.Cesium.Math.toDegrees(y.latitude),height:y.height})}c.push(c[0]);const d=this.positions.map(m=>{const g=this.Cesium.Cartographic.fromCartesian(m);return{lng:this.Cesium.Math.toDegrees(g.longitude),lat:this.Cesium.Math.toDegrees(g.latitude),height:g.height}});(u=t.onComplete)==null||u.call(t,{entity:this.entity,positions:this.positions,lnglats:d,circlePoints:l,circleLnglats:c,center:o,radius:n,clear:()=>{this.clear()}})}stopDrawing(){this.handler&&(this.handler.destroy(),this.handler=null),this._isDrawing=!1}clear(){this.stopDrawing(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.positions=[],this.currentRadius=0}}class Vt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}getPickPosition(t){var s,o,r,l;const{viewer:e}=this,i=e==null?void 0:e.scene;if(!i||!t)return null;let n=null;try{i.pickPositionSupported&&(n=i.pickPosition(t))}catch(c){console.warn("[PolygonDrawer] pickPosition failed:",c)}if(!n){const c=(o=(s=e.camera)==null?void 0:s.getPickRay)==null?void 0:o.call(s,t);c&&(n=((l=(r=i.globe)==null?void 0:r.pick)==null?void 0:l.call(r,c,i))||null)}return n}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.entity=null,this.tooltip=new _e,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{const s=this.getPickPosition(n.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(o),this.entity||(this.entity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>({positions:this.positions}),!1),material:t.color||e.Color.YELLOW.withAlpha(.5)}}))},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var o,r;if(this.stopDrawing(),(o=this.tooltip)==null||o.hide(),this.tooltip=null,this.positions.length<3)return;this.positions.length=this.positions.length-1;const n=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:n,clear:()=>{this.clear()}};(r=t.onComplete)==null||r.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class Wt{constructor(t,e){h(this,"viewer");h(this,"Cesium");h(this,"activeDrawer",null);this.viewer=e,this.Cesium=t}draw(t,e){var i;switch(this.clear(),t){case"point":this.activeDrawer=new Gt(this.Cesium,this.viewer);break;case"line":this.activeDrawer=new Bt(this.Cesium,this.viewer);break;case"rectangle":this.activeDrawer=new jt(this.Cesium,this.viewer);break;case"circle":this.activeDrawer=new Yt(this.Cesium,this.viewer);break;case"polygon":this.activeDrawer=new Vt(this.Cesium,this.viewer);break;default:throw new Error(`Unsupported draw type: ${t}`)}(i=this.activeDrawer)==null||i.startDrawing(e)}clear(){this.activeDrawer&&(this.activeDrawer.stopDrawing(),this.activeDrawer.clear(),this.activeDrawer=null)}cancel(){this.clear()}}var st=typeof global=="object"&&global&&global.Object===Object&&global,Ut=typeof self=="object"&&self&&self.Object===Object&&self,se=st||Ut||Function("return this")(),me=se.Symbol,ot=Object.prototype,Kt=ot.hasOwnProperty,qt=ot.toString,be=me?me.toStringTag:void 0;function Xt(a){var t=Kt.call(a,be),e=a[be];try{a[be]=void 0;var i=!0}catch{}var n=qt.call(a);return i&&(t?a[be]=e:delete a[be]),n}var Jt=Object.prototype,Qt=Jt.toString;function Zt(a){return Qt.call(a)}var ei="[object Null]",ti="[object Undefined]",nt=me?me.toStringTag:void 0;function Pe(a){return a==null?a===void 0?ti:ei:nt&&nt in Object(a)?Xt(a):Zt(a)}function Le(a){return a!=null&&typeof a=="object"}var xe=Array.isArray;function De(a){var t=typeof a;return a!=null&&(t=="object"||t=="function")}var ii="[object AsyncFunction]",si="[object Function]",oi="[object GeneratorFunction]",ni="[object Proxy]";function rt(a){if(!De(a))return!1;var t=Pe(a);return t==si||t==oi||t==ii||t==ni}var Fe=se["__core-js_shared__"],at=(function(){var a=/[^.]+$/.exec(Fe&&Fe.keys&&Fe.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""})();function ri(a){return!!at&&at in a}var ai=Function.prototype,li=ai.toString;function ce(a){if(a!=null){try{return li.call(a)}catch{}try{return a+""}catch{}}return""}var hi=/[\\^$.*+?()[\]{}|]/g,ci=/^\[object .+?Constructor\]$/,di=Function.prototype,pi=Object.prototype,ui=di.toString,mi=pi.hasOwnProperty,gi=RegExp("^"+ui.call(mi).replace(hi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fi(a){if(!De(a)||ri(a))return!1;var t=rt(a)?gi:ci;return t.test(ce(a))}function yi(a,t){return a==null?void 0:a[t]}function de(a,t){var e=yi(a,t);return fi(e)?e:void 0}var Re=de(se,"WeakMap"),lt=Object.create,wi=(function(){function a(){}return function(t){if(!De(t))return{};if(lt)return lt(t);a.prototype=t;var e=new a;return a.prototype=void 0,e}})(),ht=(function(){try{var a=de(Object,"defineProperty");return a({},"",{}),a}catch{}})();function vi(a,t){for(var e=-1,i=a==null?0:a.length;++e<i&&t(a[e],e,a)!==!1;);return a}var Ci=9007199254740991,bi=/^(?:0|[1-9]\d*)$/;function Pi(a,t){var e=typeof a;return t=t??Ci,!!t&&(e=="number"||e!="symbol"&&bi.test(a))&&a>-1&&a%1==0&&a<t}function Li(a,t,e){t=="__proto__"&&ht?ht(a,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):a[t]=e}function ct(a,t){return a===t||a!==a&&t!==t}var Ei=Object.prototype,Mi=Ei.hasOwnProperty;function Ii(a,t,e){var i=a[t];(!(Mi.call(a,t)&&ct(i,e))||e===void 0&&!(t in a))&&Li(a,t,e)}var Ti=9007199254740991;function dt(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=Ti}function _i(a){return a!=null&&dt(a.length)&&!rt(a)}var xi=Object.prototype;function pt(a){var t=a&&a.constructor,e=typeof t=="function"&&t.prototype||xi;return a===e}function Di(a,t){for(var e=-1,i=Array(a);++e<a;)i[e]=t(e);return i}var Si="[object Arguments]";function ut(a){return Le(a)&&Pe(a)==Si}var mt=Object.prototype,Ai=mt.hasOwnProperty,$i=mt.propertyIsEnumerable,Oi=ut((function(){return arguments})())?ut:function(a){return Le(a)&&Ai.call(a,"callee")&&!$i.call(a,"callee")};function ki(){return!1}var gt=typeof S=="object"&&S&&!S.nodeType&&S,ft=gt&&typeof module=="object"&&module&&!module.nodeType&&module,Fi=ft&&ft.exports===gt,yt=Fi?se.Buffer:void 0,Ri=yt?yt.isBuffer:void 0,wt=Ri||ki,Hi="[object Arguments]",zi="[object Array]",Ni="[object Boolean]",Gi="[object Date]",Bi="[object Error]",ji="[object Function]",Yi="[object Map]",Vi="[object Number]",Wi="[object Object]",Ui="[object RegExp]",Ki="[object Set]",qi="[object String]",Xi="[object WeakMap]",Ji="[object ArrayBuffer]",Qi="[object DataView]",Zi="[object Float32Array]",es="[object Float64Array]",ts="[object Int8Array]",is="[object Int16Array]",ss="[object Int32Array]",os="[object Uint8Array]",ns="[object Uint8ClampedArray]",rs="[object Uint16Array]",as="[object Uint32Array]",z={};z[Zi]=z[es]=z[ts]=z[is]=z[ss]=z[os]=z[ns]=z[rs]=z[as]=!0,z[Hi]=z[zi]=z[Ji]=z[Ni]=z[Qi]=z[Gi]=z[Bi]=z[ji]=z[Yi]=z[Vi]=z[Wi]=z[Ui]=z[Ki]=z[qi]=z[Xi]=!1;function ls(a){return Le(a)&&dt(a.length)&&!!z[Pe(a)]}function He(a){return function(t){return a(t)}}var vt=typeof S=="object"&&S&&!S.nodeType&&S,Ee=vt&&typeof module=="object"&&module&&!module.nodeType&&module,hs=Ee&&Ee.exports===vt,ze=hs&&st.process,ge=(function(){try{var a=Ee&&Ee.require&&Ee.require("util").types;return a||ze&&ze.binding&&ze.binding("util")}catch{}})(),Ct=ge&&ge.isTypedArray,cs=Ct?He(Ct):ls,ds=Object.prototype,ps=ds.hasOwnProperty;function us(a,t){var e=xe(a),i=!e&&Oi(a),n=!e&&!i&&wt(a),s=!e&&!i&&!n&&cs(a),o=e||i||n||s,r=o?Di(a.length,String):[],l=r.length;for(var c in a)ps.call(a,c)&&!(o&&(c=="length"||n&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Pi(c,l)))&&r.push(c);return r}function bt(a,t){return function(e){return a(t(e))}}var ms=bt(Object.keys,Object),gs=Object.prototype,fs=gs.hasOwnProperty;function ys(a){if(!pt(a))return ms(a);var t=[];for(var e in Object(a))fs.call(a,e)&&e!="constructor"&&t.push(e);return t}function ws(a){return _i(a)?us(a):ys(a)}var Me=de(Object,"create");function vs(){this.__data__=Me?Me(null):{},this.size=0}function Cs(a){var t=this.has(a)&&delete this.__data__[a];return this.size-=t?1:0,t}var bs="__lodash_hash_undefined__",Ps=Object.prototype,Ls=Ps.hasOwnProperty;function Es(a){var t=this.__data__;if(Me){var e=t[a];return e===bs?void 0:e}return Ls.call(t,a)?t[a]:void 0}var Ms=Object.prototype,Is=Ms.hasOwnProperty;function Ts(a){var t=this.__data__;return Me?t[a]!==void 0:Is.call(t,a)}var _s="__lodash_hash_undefined__";function xs(a,t){var e=this.__data__;return this.size+=this.has(a)?0:1,e[a]=Me&&t===void 0?_s:t,this}function pe(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}pe.prototype.clear=vs,pe.prototype.delete=Cs,pe.prototype.get=Es,pe.prototype.has=Ts,pe.prototype.set=xs;function Ds(){this.__data__=[],this.size=0}function Se(a,t){for(var e=a.length;e--;)if(ct(a[e][0],t))return e;return-1}var Ss=Array.prototype,As=Ss.splice;function $s(a){var t=this.__data__,e=Se(t,a);if(e<0)return!1;var i=t.length-1;return e==i?t.pop():As.call(t,e,1),--this.size,!0}function Os(a){var t=this.__data__,e=Se(t,a);return e<0?void 0:t[e][1]}function ks(a){return Se(this.__data__,a)>-1}function Fs(a,t){var e=this.__data__,i=Se(e,a);return i<0?(++this.size,e.push([a,t])):e[i][1]=t,this}function ne(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}ne.prototype.clear=Ds,ne.prototype.delete=$s,ne.prototype.get=Os,ne.prototype.has=ks,ne.prototype.set=Fs;var Ie=de(se,"Map");function Rs(){this.size=0,this.__data__={hash:new pe,map:new(Ie||ne),string:new pe}}function Hs(a){var t=typeof a;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?a!=="__proto__":a===null}function Ae(a,t){var e=a.__data__;return Hs(t)?e[typeof t=="string"?"string":"hash"]:e.map}function zs(a){var t=Ae(this,a).delete(a);return this.size-=t?1:0,t}function Ns(a){return Ae(this,a).get(a)}function Gs(a){return Ae(this,a).has(a)}function Bs(a,t){var e=Ae(this,a),i=e.size;return e.set(a,t),this.size+=e.size==i?0:1,this}function fe(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}fe.prototype.clear=Rs,fe.prototype.delete=zs,fe.prototype.get=Ns,fe.prototype.has=Gs,fe.prototype.set=Bs;function js(a,t){for(var e=-1,i=t.length,n=a.length;++e<i;)a[n+e]=t[e];return a}var Ys=bt(Object.getPrototypeOf,Object);function Vs(){this.__data__=new ne,this.size=0}function Ws(a){var t=this.__data__,e=t.delete(a);return this.size=t.size,e}function Us(a){return this.__data__.get(a)}function Ks(a){return this.__data__.has(a)}var qs=200;function Xs(a,t){var e=this.__data__;if(e instanceof ne){var i=e.__data__;if(!Ie||i.length<qs-1)return i.push([a,t]),this.size=++e.size,this;e=this.__data__=new fe(i)}return e.set(a,t),this.size=e.size,this}function ye(a){var t=this.__data__=new ne(a);this.size=t.size}ye.prototype.clear=Vs,ye.prototype.delete=Ws,ye.prototype.get=Us,ye.prototype.has=Ks,ye.prototype.set=Xs;var Pt=typeof S=="object"&&S&&!S.nodeType&&S,Lt=Pt&&typeof module=="object"&&module&&!module.nodeType&&module,Js=Lt&&Lt.exports===Pt,Et=Js?se.Buffer:void 0;Et&&Et.allocUnsafe;function Qs(a,t){return a.slice()}function Zs(a,t){for(var e=-1,i=a==null?0:a.length,n=0,s=[];++e<i;){var o=a[e];t(o,e,a)&&(s[n++]=o)}return s}function eo(){return[]}var to=Object.prototype,io=to.propertyIsEnumerable,Mt=Object.getOwnPropertySymbols,so=Mt?function(a){return a==null?[]:(a=Object(a),Zs(Mt(a),function(t){return io.call(a,t)}))}:eo;function oo(a,t,e){var i=t(a);return xe(a)?i:js(i,e(a))}function no(a){return oo(a,ws,so)}var Ne=de(se,"DataView"),Ge=de(se,"Promise"),Be=de(se,"Set"),It="[object Map]",ro="[object Object]",Tt="[object Promise]",_t="[object Set]",xt="[object WeakMap]",Dt="[object DataView]",ao=ce(Ne),lo=ce(Ie),ho=ce(Ge),co=ce(Be),po=ce(Re),re=Pe;(Ne&&re(new Ne(new ArrayBuffer(1)))!=Dt||Ie&&re(new Ie)!=It||Ge&&re(Ge.resolve())!=Tt||Be&&re(new Be)!=_t||Re&&re(new Re)!=xt)&&(re=function(a){var t=Pe(a),e=t==ro?a.constructor:void 0,i=e?ce(e):"";if(i)switch(i){case ao:return Dt;case lo:return It;case ho:return Tt;case co:return _t;case po:return xt}return t});var uo=Object.prototype,mo=uo.hasOwnProperty;function go(a){var t=a.length,e=new a.constructor(t);return t&&typeof a[0]=="string"&&mo.call(a,"index")&&(e.index=a.index,e.input=a.input),e}var St=se.Uint8Array;function je(a){var t=new a.constructor(a.byteLength);return new St(t).set(new St(a)),t}function fo(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.byteLength)}var yo=/\w*$/;function wo(a){var t=new a.constructor(a.source,yo.exec(a));return t.lastIndex=a.lastIndex,t}var At=me?me.prototype:void 0,$t=At?At.valueOf:void 0;function vo(a){return $t?Object($t.call(a)):{}}function Co(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.length)}var bo="[object Boolean]",Po="[object Date]",Lo="[object Map]",Eo="[object Number]",Mo="[object RegExp]",Io="[object Set]",To="[object String]",_o="[object Symbol]",xo="[object ArrayBuffer]",Do="[object DataView]",So="[object Float32Array]",Ao="[object Float64Array]",$o="[object Int8Array]",Oo="[object Int16Array]",ko="[object Int32Array]",Fo="[object Uint8Array]",Ro="[object Uint8ClampedArray]",Ho="[object Uint16Array]",zo="[object Uint32Array]";function No(a,t,e){var i=a.constructor;switch(t){case xo:return je(a);case bo:case Po:return new i(+a);case Do:return fo(a);case So:case Ao:case $o:case Oo:case ko:case Fo:case Ro:case Ho:case zo:return Co(a);case Lo:return new i;case Eo:case To:return new i(a);case Mo:return wo(a);case Io:return new i;case _o:return vo(a)}}function Go(a){return typeof a.constructor=="function"&&!pt(a)?wi(Ys(a)):{}}var Bo="[object Map]";function jo(a){return Le(a)&&re(a)==Bo}var Ot=ge&&ge.isMap,Yo=Ot?He(Ot):jo,Vo="[object Set]";function Wo(a){return Le(a)&&re(a)==Vo}var kt=ge&&ge.isSet,Uo=kt?He(kt):Wo,Ft="[object Arguments]",Ko="[object Array]",qo="[object Boolean]",Xo="[object Date]",Jo="[object Error]",Rt="[object Function]",Qo="[object GeneratorFunction]",Zo="[object Map]",en="[object Number]",Ht="[object Object]",tn="[object RegExp]",sn="[object Set]",on="[object String]",nn="[object Symbol]",rn="[object WeakMap]",an="[object ArrayBuffer]",ln="[object DataView]",hn="[object Float32Array]",cn="[object Float64Array]",dn="[object Int8Array]",pn="[object Int16Array]",un="[object Int32Array]",mn="[object Uint8Array]",gn="[object Uint8ClampedArray]",fn="[object Uint16Array]",yn="[object Uint32Array]",H={};H[Ft]=H[Ko]=H[an]=H[ln]=H[qo]=H[Xo]=H[hn]=H[cn]=H[dn]=H[pn]=H[un]=H[Zo]=H[en]=H[Ht]=H[tn]=H[sn]=H[on]=H[nn]=H[mn]=H[gn]=H[fn]=H[yn]=!0,H[Jo]=H[Rt]=H[rn]=!1;function $e(a,t,e,i,n,s){var o;if(o!==void 0)return o;if(!De(a))return a;var r=xe(a);if(r)o=go(a);else{var l=re(a),c=l==Rt||l==Qo;if(wt(a))return Qs(a);if(l==Ht||l==Ft||c&&!n)o=c?{}:Go(a);else{if(!H[l])return n?a:{};o=No(a,l)}}s||(s=new ye);var d=s.get(a);if(d)return d;s.set(a,o),Uo(a)?a.forEach(function(g){o.add($e(g,t,e,g,a,s))}):Yo(a)&&a.forEach(function(g,p){o.set(p,$e(g,t,e,p,a,s))});var u=no,m=r?void 0:u(a);return vi(m||a,function(g,p){m&&(p=g,g=a[p]),Ii(o,p,$e(g,t,e,p,a,s))}),o}var wn=1,vn=4;function Oe(a){return $e(a,wn|vn)}var zt=(a=>(a.Rotate="rotate",a.Move="move",a.Scale="scale",a.MoveHeight="moveHeight",a.Empty="",a))(zt||{}),Nt=(a=>(a.Scale="addScale",a.Rotate="rotate",a.Translation="translation",a.Remove="removeById",a.Add="add",a))(Nt||{});class Cn{constructor(t){h(this,"primitives",new Map);h(this,"eventListener",new Map);h(this,"Cesium");h(this,"viewer");h(this,"handler");h(this,"rotationRing");h(this,"translationSquare");h(this,"heightArrow");h(this,"editMode","");h(this,"dragEndCallbackMap",new Map);this.Cesium=t.Cesium,this.viewer=t.viewer,this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)}init(t,e=!1){const i=this.viewer;this.primitives.forEach(n=>{i.scene.primitives.remove(n)}),t.forEach(n=>{this.primitives.has(n.id)||this.add(n,e)})}get(t){return this.primitives.get(t)}add(t,e=!0){var u,m,g;const i=this.viewer,n=this.Cesium,s=n.Math.toRadians(((u=t.headingPitchRoll)==null?void 0:u.heading)||0),o=n.Math.toRadians(((m=t.headingPitchRoll)==null?void 0:m.pitch)||0),r=n.Math.toRadians(((g=t.headingPitchRoll)==null?void 0:g.roll)||0),l=new n.HeadingPitchRoll(s,o,r),c=n.Transforms.headingPitchRollToFixedFrame(t.position,l,i.scene.globe.ellipsoid,n.Transforms.eastNorthUpToFixedFrame,new n.Matrix4);let d=i.scene.primitives.add(n.Model.fromGltf({id:t.id,...t.model,modelMatrix:c}));d.scale=t.scale||1,this.primitives.set(t.id,d),d.show=e,this.runEventListener("add",{info:t,gltf:d})}flyTo(t){const e=this.viewer,i=this.Cesium;let n=this.primitives.get(t);const s=n.boundingSphere,o=i.Matrix4.multiplyByPoint(n.modelMatrix,s.center,new i.Cartesian3),r=new i.BoundingSphere(o,s.radius);e.camera.flyToBoundingSphere(r,{duration:1.5,offset:new i.HeadingPitchRange(0,-.5,s.radius*2)})}removeById(t){var n;const e=this.viewer;let i=this.primitives.get(t);if(!i){console.error(`No model found with id: ${t}`);return}e.scene.primitives.remove(i),this.primitives.delete(t),(!((n=this.rotationRing)!=null&&n._instanceIds.includes(`rotationRing_${t}`))||!this.rotationRing)&&this.removeTool(),this.runEventListener("removeById",{id:t,gltf:i})}show(t){let e=this.primitives.get(t);e&&(e.show=!0)}hide(t){let e=this.primitives.get(t);e&&(e.show=!1)}addScale(t,e=.1){let i=this.primitives.get(t.id);i&&(i.scale=i.scale+e,this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t.id,scale:i.scale}))}setScale(t,e=.1){let i=this.primitives.get(t);i&&(i.scale=e,this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t,scale:i.scale}))}setEditMode(t){this.editMode=t}lockCamera(){const t=this.viewer.scene.screenSpaceCameraController;t.enableRotate=!1,t.enableTranslate=!1,t.enableZoom=!1}unlockCamera(){const t=this.viewer.scene.screenSpaceCameraController;t.enableRotate=!0,t.enableTranslate=!0,t.enableZoom=!0}toCartographic(t){const e=this.Cesium.Cartographic.fromCartesian(t);return{longitude:e.longitude,latitude:e.latitude}}calculateHeading(t,e){const i=e.longitude-t.longitude,n=e.latitude-t.latitude;return Math.atan2(n,i)}getModelHeadingPitchRoll(t){const e=this.Cesium,i=this.viewer,n=e.Transforms.eastNorthUpToFixedFrame(e.Matrix4.getTranslation(t,new e.Cartesian3),i.scene.globe.ellipsoid,new e.Matrix4),s=e.Matrix4.multiply(e.Matrix4.inverse(n,new e.Matrix4),t,new e.Matrix4),o=e.Matrix4.getRotation(s,new e.Matrix3),r=e.Quaternion.fromRotationMatrix(o);return e.HeadingPitchRoll.fromQuaternion(r)}addEventListener(t,e,i){let n={f:e,options:i};return this.eventListener.get(t)?(this.eventListener.get(t)||[]).push(n):this.eventListener.set(t,[n]),n}removeEventListener(t,e){let i=this.eventListener.get(t);if(!i)return console.error("key不存在");let n=i.findIndex(s=>s==e);n>=0?i.splice(n,1):console.error("instantiation不存在")}runEventListener(t,e){let i=this.eventListener.get(t);return i?(i.forEach(n=>{typeof n.f=="function"&&n.f(e)}),!0):!1}initEditBox(t){const e=this.Cesium,i=this.viewer,n=i.scene;let s=null,o=null,r=null,l=null,c=null;const d=()=>{s=null,o=null,r=null,c=null,l=null,this.setEditMode(""),this.unlockCamera()},u=(m,g)=>{if(s=this.primitives.get(m),s){o=e.Matrix4.clone(s.modelMatrix);const p=e.Matrix4.getTranslation(o,new e.Cartesian3);r=this.toCartographic(p),c=g.position;const f=n.globe.pick(i.camera.getPickRay(g.position),n);l=this.toCartographic(f),this.lockCamera()}};this.handler.setInputAction(m=>{var f,w,y,v,C,b,M,P,L,E;if(!t())return;const p=n.pick(m.position);if(p&&p.id&&((f=p.id)!=null&&f.includes("rotationRing"))){let I=p.id.split("rotationRing_")[1];this.setEditMode("rotate"),u(I,m)}else if(p&&p.id&&((w=p.id)!=null&&w.includes("translationSquare_"))){let I=p.id.split("translationSquare_")[1];this.setEditMode("move"),u(I,m)}else if(p&&p.id&&((y=p.id)!=null&&y.includes("heightArrow-line_"))){let I=p.id.split("heightArrow-line_")[1];this.setEditMode("moveHeight"),u(I,m)}else if(p&&p.id&&((v=p.id)!=null&&v.includes("heightArrow-arrow_"))){let I=p.id.split("heightArrow-arrow_")[1];this.setEditMode("moveHeight"),u(I,m)}else if(p&&p.id){if(s=this.primitives.get(p.id),!s)return;(!this.rotationRing||!((b=(C=this.rotationRing)==null?void 0:C._instanceIds)!=null&&b.includes(`rotationRing_${s.id}`)))&&this.createRotationRing(s),(!this.translationSquare||!((P=(M=this.translationSquare)==null?void 0:M._instanceIds)!=null&&P.includes(`translationSquare_${s.id}`)))&&this.createTranslationSquare(s),(!this.heightArrow||!((E=(L=this.heightArrow)==null?void 0:L._instanceIds)!=null&&E.includes(`heightArrow_${s.id}`)))&&this.createHeightArrow(s)}else d()},e.ScreenSpaceEventType.LEFT_DOWN),this.handler.setInputAction(m=>{if(t()&&this.editMode!=""&&s){const p=n.globe.pick(i.camera.getPickRay(m.endPosition),n),f=this.toCartographic(p);let w=0;if(this.editMode==="rotate"){let y=this.calculateHeading(r,f);w=this.calculateHeading(r,l)-y,this.rotateModel(s,o,w)}else this.editMode==="move"?this.moveModel(s,o,m):this.editMode==="moveHeight"&&this.moveModelHeight(s,o,m,c)}},e.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(()=>{if(!t())return;let g=this.dragEndCallbackMap.get(s==null?void 0:s.id);if(g&&(this.editMode==="move"||this.editMode==="moveHeight")){let p=g.get("translation");p&&(this.runEventListener("translation",p),g.delete("translation"))}else if(g&&this.editMode==="rotate"){let p=g.get("rotate");p&&(this.runEventListener("rotate",p),g.delete("rotate"))}d()},e.ScreenSpaceEventType.LEFT_UP),this.handler.setInputAction(()=>{this.removeTool()},e.ScreenSpaceEventType.RIGHT_UP)}createRotationRing(t){const e=this.Cesium,i=this.viewer;this.rotationRing&&i.scene.primitives.remove(this.rotationRing);const n=[];for(let r=0;r<=360;r+=3){const l=Math.sin(e.Math.toRadians(r)),c=Math.cos(e.Math.toRadians(r)),d=t.boundingSphere.radius*c,u=t.boundingSphere.radius*l;n.push(new e.Cartesian3(d,u,0))}const s=new e.PolylineGeometry({positions:n,width:Math.max(t.boundingSphere.radius*.05,1)}),o=new e.GeometryInstance({id:`rotationRing_${t.id}`,geometry:s,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.RED)}});this.rotationRing=new e.Primitive({geometryInstances:o,appearance:new e.PolylineColorAppearance({translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.RED.withAlpha(.3)}),translucent:!0}),modelMatrix:t.modelMatrix,cull:!1}),i.scene.primitives.add(this.rotationRing)}createTranslationSquare(t){const e=this.Cesium,i=this.viewer;this.translationSquare&&i.scene.primitives.remove(this.translationSquare);const s=Math.max(t.boundingSphere.radius*.2,1)/2,o=new e.BoxGeometry({maximum:new e.Cartesian3(s,s,s),minimum:new e.Cartesian3(-s,-s,-s)}),r=new e.GeometryInstance({id:`translationSquare_${t.id}`,geometry:o,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.BLUE)}});this.translationSquare=new e.Primitive({geometryInstances:r,appearance:new e.PolylineColorAppearance({translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.BLUE.withAlpha(.3)}),translucent:!0}),cull:!1,modelMatrix:t.modelMatrix}),i.scene.primitives.add(this.translationSquare)}createHeightArrow(t){const e=this.Cesium,i=this.viewer;this.heightArrow&&i.scene.primitives.remove(this.heightArrow);let n=e.Color.GREEN,s=Math.max(t.boundingSphere.radius*.025,1),o=2*s,r=t.boundingSphere.radius+50,l=r*.1;const c=Math.max(t.boundingSphere.radius*.2,1),d=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:r,topRadius:s,bottomRadius:s})),u=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:l,topRadius:0,bottomRadius:o}));let m=r+c,g=(r+c)/2;this.translate(d,[0,0,g]),this.translate(u,[0,0,m]),this.heightArrow=new e.Primitive({modelMatrix:t.modelMatrix,geometryInstances:[new e.GeometryInstance({id:`heightArrow-line_${t.id}`,geometry:d}),new e.GeometryInstance({id:`heightArrow-arrow_${t.id}`,geometry:u})],appearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:n}),translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:n.withAlpha(.3)}),translucent:!0}),cull:!1}),i.scene.primitives.add(this.heightArrow)}translate(t,e){let i=this.Cesium;const n=new i.Cartesian3;xe(e)?(n.x=e[0],n.y=e[1],n.z=e[2]):i.Cartesian3.clone(e,n);for(let s=0;s<t.attributes.position.values.length;s+=3)t.attributes.position.values[s]+=n.x,t.attributes.position.values[s+1]+=n.y,t.attributes.position.values[s+2]+=n.z}removeTool(){this.rotationRing&&this.viewer.scene.primitives.remove(this.rotationRing),this.translationSquare&&this.viewer.scene.primitives.remove(this.translationSquare),this.heightArrow&&this.viewer.scene.primitives.remove(this.heightArrow)}updatedTool(t){this.rotationRing&&(this.rotationRing.modelMatrix=t),this.translationSquare&&(this.translationSquare.modelMatrix=t),this.heightArrow&&(this.heightArrow.modelMatrix=t)}moveModel(t,e,i){const n=this.Cesium,s=this.viewer,o=s.scene,r=o.globe.pick(s.camera.getPickRay(i.endPosition),o);if(r){const l=n.Matrix4.getTranslation(e,new n.Cartesian3),c=n.Cartographic.fromCartesian(l),d=n.Cartographic.fromCartesian(r),u=new n.Cartographic(d.longitude,d.latitude,c.height),m=n.Cartographic.toCartesian(u),g=n.Matrix4.getRotation(e,new n.Matrix3),p=n.Matrix4.fromRotationTranslation(g,m);t.modelMatrix=p,this.updatedTool(p);let f=new n.Cartesian3(p[12],p[13],p[14]),w=this.dragEndCallbackMap.get(t.id);w||(w=new Map,this.dragEndCallbackMap.set(t.id,w)),w.set("translation",{id:t.id,position:f})}}moveModelHeight(t,e,i,n){const s=this.Cesium,o=this.viewer,r=o.scene,l=n.y-i.endPosition.y;if(r.globe.pick(o.camera.getPickRay(i.endPosition),r)){const d=s.Matrix4.getTranslation(e,new s.Cartesian3),u=s.Cartographic.fromCartesian(d),m=new s.Cartographic(u.longitude,u.latitude,u.height+l*.001*Math.max(o.camera.positionCartographic.height,1)),g=s.Cartographic.toCartesian(m),p=s.Matrix4.getRotation(e,new s.Matrix3),f=s.Matrix4.fromRotationTranslation(p,g);t.modelMatrix=f,this.updatedTool(f);let w=new s.Cartesian3(f[12],f[13],f[14]),y=this.dragEndCallbackMap.get(t.id);y||(y=new Map,this.dragEndCallbackMap.set(t.id,y)),y.set("translation",{id:t.id,position:w})}}rotateModel(t,e,i){const n=this.Cesium,s=this.viewer,o=this.getModelHeadingPitchRoll(e),r=o.heading+i,l=new n.HeadingPitchRoll(r,o.pitch,o.roll),c=n.Transforms.headingPitchRollToFixedFrame(n.Matrix4.getTranslation(t.modelMatrix,new n.Cartesian3),l,s.scene.globe.ellipsoid,n.Transforms.eastNorthUpToFixedFrame,new n.Matrix4);t.modelMatrix=c;let d=this.dragEndCallbackMap.get(t.id);d||(d=new Map,this.dragEndCallbackMap.set(t.id,d)),d.set("rotate",{id:t.id,headingPitchRoll:{heading:n.Math.toDegrees(r),pitch:n.Math.toDegrees(o.pitch),roll:n.Math.toDegrees(o.roll)}})}cleanup(){this.handler&&(this.handler.destroy(),this.handler=null)}}function bn(a,t){const e=t.materialType||"DynamicImgMaterial"+Date.now()+Math.floor(Math.random()*1e3);function i(s){this._definitionChanged=new a.Event,this._color=s.color,this._colorSubscription=void 0,this.color=s.color,this.duration=s.duration,this._time=Date.now()}Object.defineProperties(i.prototype,{isConstant:{get(){return!1}},definitionChanged:{get(){return this._definitionChanged}},color:a.createPropertyDescriptor("color")}),i.prototype.getType=function(){return e},i.prototype.getValue=function(s,o){return a.defined(o)||(o={}),o.color=a.Property.getValueOrClonedDefault(this._color,s,a.Color.WHITE,o.color),o.image=t.image,o},i.prototype.equals=function(s){return this===s||s instanceof i&&a.Property.equals(this._color,s._color)};const n=function(s){return`
|
|
1
|
+
(function(S,te){typeof exports=="object"&&typeof module<"u"?te(exports):typeof define=="function"&&define.amd?define(["exports"],te):(S=typeof globalThis<"u"?globalThis:S||self,te(S.CesiumCore={}))})(this,(function(S){"use strict";var kn=Object.defineProperty;var Fn=(S,te,V)=>te in S?kn(S,te,{enumerable:!0,configurable:!0,writable:!0,value:V}):S[te]=V;var h=(S,te,V)=>Fn(S,typeof te!="symbol"?te+"":te,V);class te{constructor(t,e,i){h(this,"Cesium");h(this,"viewer");h(this,"labelPool");h(this,"threshold");h(this,"displayLimit");h(this,"maxLevel");h(this,"debugCurrentGrids");h(this,"levels");h(this,"points",[]);h(this,"gridLayers",new Map);h(this,"debugGrids",[]);h(this,"_updateFn");h(this,"clusterTheme");h(this,"pointTheme");h(this,"centralPointMode");h(this,"minGlobalPointCount");h(this,"groupByTheme");h(this,"tilingScheme");h(this,"terrainLevelOffset");h(this,"debugTileCoordLayer",null);h(this,"levelIndexByTileLevel",new Map);h(this,"_lastTileProvider",null);h(this,"_updateTimer",null);h(this,"_updateDelay",100);h(this,"_tilesRetryCount",0);h(this,"_tilesRetryMax",100);h(this,"_cameraDirty",!1);h(this,"_tileLoadListener",null);h(this,"_cameraChangedHandler",null);h(this,"defaultMinLevel",0);h(this,"defaultMaxLevel",28);h(this,"maxRefineLevels",2);this.Cesium=t,this.viewer=e,this.labelPool=i.labelPool,this.threshold=i.threshold??10,this.displayLimit=i.displayLimit??100,this.maxLevel=i.maxLevel??5,this.debugCurrentGrids=i.debugCurrentGrids??!1,this.clusterTheme=i.clusterTheme??"cluster-label",this.pointTheme=i.pointTheme??"point-label",this.centralPointMode=i.centralPointMode??"central",this.minGlobalPointCount=i.minGlobalPointCount??0,this.groupByTheme=i.groupByTheme??!1,this.terrainLevelOffset=i.terrainLevelOffset??2;const n=this.viewer.scene&&this.viewer.scene.globe,s=n&&n._surface,o=s&&s._tileProvider,r=(o==null?void 0:o.tilingScheme)||new this.Cesium.GeographicTilingScheme;this._lastTileProvider=o,this.tilingScheme=r,this.levels=this._createLevels(),this._buildLevels(),this._updateFn=this._update.bind(this),this.debugCurrentGrids&&this._ensureDebugImageryLayer(),n&&(this._tileLoadListener=l=>{l===0&&this._cameraDirty&&(this._cameraDirty=!1,this._scheduleUpdate())},n.tileLoadProgressEvent.addEventListener(this._tileLoadListener)),this._cameraChangedHandler=()=>{this._update()},this.viewer.camera.changed.addEventListener(this._cameraChangedHandler)}setGroupByTheme(t,e=!0,i=!0){if(this.groupByTheme===t){i&&this._update();return}this.groupByTheme=t,e&&this._buildLevels(),i&&this._update()}setMinGlobalPointCount(t,e=!0){this.minGlobalPointCount=t,e&&this._update()}setThreshold(t,e=!0){this.threshold=t,e&&this._update()}setDebugCurrentGrids(t,e=!0){this.debugCurrentGrids=t,t?this._ensureDebugImageryLayer():(this._clearDebugGrids(),this._removeDebugImageryLayer()),e&&this._update()}_syncTilingSchemeAndLevels(){const t=this.viewer.scene&&this.viewer.scene.globe,e=t&&t._surface,i=e&&e._tileProvider,n=(i==null?void 0:i.tilingScheme)||new this.Cesium.GeographicTilingScheme,s=i!==this._lastTileProvider,o=this.tilingScheme!==n;!s&&!o&&this.levels&&this.levels.length>0||(this._lastTileProvider=i,this.tilingScheme=n,this.levels=this._createLevels(),this._buildLevels(),this.debugCurrentGrids&&(this._removeDebugImageryLayer(),this._ensureDebugImageryLayer()))}_createLevels(){const t=[];this.levelIndexByTileLevel=new Map;const e=0,i=this.maxLevel;let n=0;for(let s=e;s<=i;s++,n++){const o=360/Math.pow(2,s);t.push({level:s,size:o,minViewWidth:o*4}),this.levelIndexByTileLevel.set(s,n)}return t}addPoints(t){this.points=t,this._buildLevels()}appendPoints(t,e=!0){for(const i of t)this._preparePointLevelRange(i),this.points.push(i);for(const i of t)this._addPointToGrid(i);e&&this._scheduleUpdate()}_scheduleUpdate(){this._updateTimer!==null&&clearTimeout(this._updateTimer),this._updateTimer=window.setTimeout(()=>{this._update(),this._cameraDirty=!0,this._updateTimer=null},this._updateDelay)}updatePoint(t){var s,o,r,l;const e=this.points.findIndex(c=>c.id===t.id);if(e===-1)return;const i=this.points[e];for(const c of this.levels){const d=c.level,u=this.gridLayers.get(d);if(!u)continue;const m=this.Cesium.Cartographic.fromDegrees(i.lon,i.lat),g=this.tilingScheme.positionToTileXY(m,d,new this.Cesium.Cartesian2);if(!g)continue;const p=`${g.x}_${g.y}`,f=u.get(p);if(f){const w=f.allPoints.findIndex(y=>y.id===t.id);if(w!==-1&&f.allPoints.splice(w,1),(r=(o=(s=i.data)==null?void 0:s.billboard)==null?void 0:o[0])!=null&&r.skipAggregation){const y=f.skipPoints.findIndex(v=>v.id===t.id);y!==-1&&f.skipPoints.splice(y,1)}else{const y=this.groupByTheme?(l=i.data)==null?void 0:l.theme:this.clusterTheme,v=f.groups.get(y);if(v){const C=v.findIndex(b=>b.id===t.id);C!==-1&&v.splice(C,1),v.length===0&&f.groups.delete(y)}}}}const n={...i,...t};this.points[e]=n,this._addPointToGrid(n),this._update()}removePointsById(t){const e=new Set(t);this.points=this.points.filter(i=>!e.has(i.id));for(const i of this.levels){const n=this.gridLayers.get(i.level);if(n)for(const[s,o]of n.entries()){o.allPoints=o.allPoints.filter(r=>!e.has(r.id)),o.skipPoints=o.skipPoints.filter(r=>!e.has(r.id));for(const[r,l]of o.groups.entries()){const c=l.filter(d=>!e.has(d.id));c.length===0?o.groups.delete(r):o.groups.set(r,c)}o.allPoints.length===0&&n.delete(s)}}this._update()}_buildLevels(){this.gridLayers.clear();for(const t of this.levels)this.gridLayers.set(t.level,new Map);for(const t of this.points)this._addPointToGrid(t)}_addPointToGrid(t){var e,i,n,s,o,r;for(const l of this.levels){const c=l.level,d=this.gridLayers.get(c);if(!d)continue;const u=this.Cesium.Cartographic.fromDegrees(t.lon,t.lat),m=this.tilingScheme.positionToTileXY(u,c,new this.Cesium.Cartesian2);if(!m)continue;const g=`${m.x}_${m.y}`;let p=d.get(g);if(p||(p={allPoints:[],groups:new Map,skipPoints:[]},d.set(g,p)),p.allPoints.push(t),(n=(i=(e=t.data)==null?void 0:e.billboard)==null?void 0:i[0])!=null&&n.skipAggregation)p.skipPoints.push(t);else{const f=this.groupByTheme?(r=(o=(s=t.data)==null?void 0:s.billboard)==null?void 0:o[0])==null?void 0:r.theme:this.clusterTheme;p.groups.has(f)||p.groups.set(f,[]),p.groups.get(f).push(t)}}}_preparePointLevelRange(t){const e=t.data||{};let i=e.minLevel,n=e.maxLevel;const s=e.levelRange;Array.isArray(s)?(s.length>0&&i==null&&(i=s[0]),s.length>1&&n==null&&(n=s[1])):s&&typeof s=="object"&&(i==null&&typeof s.min=="number"&&(i=s.min),n==null&&typeof s.max=="number"&&(n=s.max));const o=i==null?this.defaultMinLevel:Number(i)||this.defaultMinLevel,r=n==null?this.defaultMaxLevel:Number(n)||this.defaultMaxLevel;t.__minLevel=o,t.__maxLevel=r}_isVisibleAtLevel(t,e){if(e==null)return!0;(t.__minLevel===void 0||t.__maxLevel===void 0)&&this._preparePointLevelRange(t);const i=t.__minLevel??this.defaultMinLevel,n=t.__maxLevel??this.defaultMaxLevel;return e>=i&&e<=n}_update(){if(!this.labelPool)return;this._syncTilingSchemeAndLevels(),this.labelPool.reset(),this.debugCurrentGrids&&this._clearDebugGrids();const t=this.points.length<this.minGlobalPointCount?1/0:this.threshold;let e=0;const i=(n,s,o,r)=>{e=this._processCell(n,s,o,r,t,e)};try{const n=this._getSurfaceTiles();if(!n||n.length===0){this._handleNoSurfaceTiles(e);return}this._tilesRetryCount=0,this._processTiles(n,i)}catch{this.labelPool.cleanup();return}this.labelPool.cleanup()}_getSurfaceTiles(){const t=this.viewer.scene&&this.viewer.scene.globe,e=t&&t._surface;if(e)return e._tilesToRender||e._tilesToRenderByTextureCount}_handleNoSurfaceTiles(t){var e,i,n,s;for(const o of this.points){if(t>=this.displayLimit)break;((e=o.data)==null?void 0:e.show)!==!1&&(this.labelPool.add(o.data,{id:`point-${o.id}`,lon:o.lon,lat:o.lat,height:o.height,theme:((s=(n=(i=o.data)==null?void 0:i.billboard)==null?void 0:n[0])==null?void 0:s.theme)||this.pointTheme,style:o.style}),t++)}this.labelPool.cleanup(),this.points.length>0&&this._tilesRetryCount<this._tilesRetryMax&&(this._tilesRetryCount++,this._scheduleUpdate())}_resolveLevelIndex(t){let e=this.levelIndexByTileLevel.get(t);if(e!==void 0)return e;if(this.levels.length===0)return;const i=this.levels[0].level,n=this.levels[this.levels.length-1].level;if(t>n)return this.levels.length-1;if(t<i)return 0;let s=0,o=1/0;for(let r=0;r<this.levels.length;r++){const l=Math.abs(this.levels[r].level-t);l<o&&(o=l,s=r)}return s}_isTerrainEnabled(){const t=this.viewer.terrainProvider,e=this.viewer.scene,i=e&&e.globe,n=i&&i.terrainProvider,s=t||n;return s?!(s instanceof this.Cesium.EllipsoidTerrainProvider):!1}_getGridRefLevel(t){let e=t;if(this._isTerrainEnabled()&&(e+=this.terrainLevelOffset),this.levels.length>0){const i=this.levels[this.levels.length-1].level;e>i&&(e=i)}return e}_processTiles(t,e){const i=new Set,n=!this._isTerrainEnabled(),s=this.viewer.scene,o=s&&s.globe,r=o&&o.ellipsoid,l=r&&s.camera.computeViewRectangle(r),c=(d,u,m)=>{if(!n||!l)return!0;const g=this.tilingScheme.tileXYToRectangle(d,u,m);return!(!g||g.east<=l.west||g.west>=l.east||g.north<=l.south||g.south>=l.north)};for(const d of t){const u=d.rectangle,m=d._level??d.level;if(!u||typeof m!="number")continue;const g=this._getGridRefLevel(m),p=this._resolveLevelIndex(g);if(p===void 0)continue;const f=this.levels[p].level,w=d._x??d.x,y=d._y??d.y;if(typeof w=="number"&&typeof y=="number"){const T=m-f;if(T>=0){const $=1<<T,D=Math.floor(w/$),k=Math.floor(y/$),_=`${f}_${D}_${k}`;if(i.has(_))continue;i.add(_),e(p,D,k,m)}else{const D=1<<Math.min(-T,this.maxRefineLevels),k=w*D,_=y*D;for(let O=0;O<D;O++)for(let R=0;R<D;R++){const G=k+O,B=_+R;if(!c(G,B,f))continue;const j=`${f}_${G}_${B}`;i.has(j)||(i.add(j),e(p,G,B,m))}}continue}const C=this.levels[p].size,b=this.Cesium.Math.toDegrees(u.west),M=this.Cesium.Math.toDegrees(u.east),P=this.Cesium.Math.toDegrees(u.south),L=this.Cesium.Math.toDegrees(u.north),E=Math.floor((b- -180)/C),I=Math.floor((M- -180)/C),A=Math.floor((P- -90)/C),x=Math.floor((L- -90)/C);for(let T=E;T<=I;T++)for(let $=A;$<=x;$++){if(!c(T,$,f))continue;const D=`${f}_${T}_${$}`;i.has(D)||(i.add(D),e(p,T,$,m))}}}_processCell(t,e,i,n,s,o){if(o>=this.displayLimit||t<0)return o;t>=this.levels.length&&(t=this.levels.length-1);const r=this._getCellContext(t,e,i,n);return r?(o=this._processCellSkipPoints(r,o),o>=this.displayLimit?(this._debugDrawCell(r),o):(o=this._processCellGroups(r,s,o),this._debugDrawCell(r),o)):o}_getCellContext(t,e,i,n){const o=this.levels[t].level,r=this.gridLayers.get(o);if(!r)return null;const l=`${e}_${i}`,c=r.get(l);if(!c)return null;const d=this.tilingScheme.tileXYToRectangle(e,i,o),u=this.Cesium.Math.toDegrees(d.west),m=this.Cesium.Math.toDegrees(d.south),g=this.Cesium.Math.toDegrees(d.east),p=this.Cesium.Math.toDegrees(d.north),f=(u+g)/2,w=(m+p)/2;return{levelIdx:t,tileLevel:o,lonIdx:e,latIdx:i,key:l,cell:c,rect:d,west:u,south:m,east:g,north:p,centerLon:f,centerLat:w,viewTileLevel:n}}_processCellSkipPoints(t,e){var o,r,l,c;const{cell:i,viewTileLevel:n}=t,s=n;for(const d of i.skipPoints)if(((o=d.data)==null?void 0:o.show)!==!1){if(e>=this.displayLimit)break;this._isVisibleAtLevel(d,s)&&(this.labelPool.add(d.data,{id:`point-${d.id}`,lon:d.lon,lat:d.lat,height:d.height,theme:((c=(l=(r=d.data)==null?void 0:r.billboard)==null?void 0:l[0])==null?void 0:c.theme)||this.pointTheme,style:d.style}),e++)}return e}_processCellGroups(t,e,i){var m,g,p,f,w,y,v,C,b,M,P,L,E;const{levelIdx:n,lonIdx:s,latIdx:o,cell:r,centerLon:l,centerLat:c,viewTileLevel:d}=t,u=d;for(const[I,A]of r.groups){const x=A.filter(_=>{var O;return((O=_.data)==null?void 0:O.show)!==!1});if(x.length===0)continue;let T=l,$=c,D=((m=x[0])==null?void 0:m.height)||0;if(this.centralPointMode=="firstPoint"&&(T=((g=x[0])==null?void 0:g.lon)||0,$=((p=x[0])==null?void 0:p.lat)||0,D=((f=x[0])==null?void 0:f.height)||0),n===this.levels.length-1||x.length<e)for(const _ of x){if(i>=this.displayLimit)break;this._isVisibleAtLevel(_,u)&&(this.labelPool.add(_.data,{id:`point-${_.id}`,lon:_.lon,lat:_.lat,height:_.height,theme:((v=(y=(w=_.data)==null?void 0:w.billboard)==null?void 0:y[0])==null?void 0:v.theme)||this.pointTheme,style:_.style}),i++)}else{if(i>=this.displayLimit)return i;const _=u==null?x:x.filter(B=>this._isVisibleAtLevel(B,u));if(!_.length)return i;const R=((P=(M=(b=(C=_[0])==null?void 0:C.data)==null?void 0:b.billboard)==null?void 0:M[0])==null?void 0:P.theme)||this.clusterTheme,G=this.groupByTheme?`cluster-${n}-${s}-${o}-${I}`:`cluster-${n}-${s}-${o}`;this.labelPool.add({id:G,billboard:((E=(L=_[0])==null?void 0:L.data)==null?void 0:E.billboard)||[],count:_.length,gridKey:`${s}_${o}`,points:_,aggregationGroup:I},{id:G,lon:T,lat:$,height:D,theme:R}),i++}}return i}_debugDrawCell(t){if(!this.debugCurrentGrids)return;const{levelIdx:e,west:i,south:n,east:s,north:o,lonIdx:r,latIdx:l}=t,c=this.levels[e].level;this._drawDebugGrid(i,n,s,o,`L:${c} X:${r} Y:${l}`)}refresh(){this._update()}_drawDebugGrid(t,e,i,n,s){const o=this.Cesium.Rectangle.fromDegrees(t,e,i,n),r=this.Cesium.Cartesian3.fromDegreesArray([t,e,i,e,i,n,t,n,t,e]),l=this.viewer.entities.add({rectangle:{coordinates:o,material:this.Cesium.Color.YELLOW.withAlpha(.2),outline:!0,outlineColor:this.Cesium.Color.RED,heightReference:this.Cesium.HeightReference.CLAMP_TO_GROUND,classificationType:this.Cesium.ClassificationType.TERRAIN},polyline:{positions:r,width:2,material:this.Cesium.Color.RED,clampToGround:!0},label:{text:s,font:"14px sans-serif",fillColor:this.Cesium.Color.BLACK,outlineColor:this.Cesium.Color.WHITE,outlineWidth:2,style:this.Cesium.LabelStyle.FILL_AND_OUTLINE,verticalOrigin:this.Cesium.VerticalOrigin.CENTER,horizontalOrigin:this.Cesium.HorizontalOrigin.CENTER}});this.debugGrids.push(l)}_clearDebugGrids(){for(const t of this.debugGrids)this.viewer.entities.remove(t);this.debugGrids=[]}_ensureDebugImageryLayer(){if(this.debugTileCoordLayer||!this.viewer||!this.viewer.imageryLayers)return;const t={tilingScheme:this.tilingScheme};this.debugTileCoordLayer=this.viewer.imageryLayers.addImageryProvider(new this.Cesium.TileCoordinatesImageryProvider(t))}_removeDebugImageryLayer(){if(!(!this.debugTileCoordLayer||!this.viewer||!this.viewer.imageryLayers)){try{this.viewer.imageryLayers.remove(this.debugTileCoordLayer,!1)}catch{}this.debugTileCoordLayer=null}}destroy(){this._cameraChangedHandler&&(this.viewer.camera.changed.removeEventListener(this._cameraChangedHandler),this._cameraChangedHandler=null);const t=this.viewer.scene,e=t&&t.globe;e&&this._tileLoadListener&&(e.tileLoadProgressEvent.removeEventListener(this._tileLoadListener),this._tileLoadListener=null),this._updateTimer!==null&&(clearTimeout(this._updateTimer),this._updateTimer=null),this.labelPool.reset(),this._clearDebugGrids(),this._removeDebugImageryLayer()}}var V=(a=>(a.Click="marker:click",a.DoubleClick="marker:dblclick",a.RightClick="marker:rightclick",a.MouseEnter="marker:mouseenter",a.MouseLeave="marker:mouseleave",a.MouseDown="marker:mousedown",a.MouseUp="marker:mouseup",a))(V||{});class tt{constructor(){h(this,"listenerMap",new Map)}addListener(t,e,i=!1){let n=this.listenerMap.get(t);return n||(n=new Map,this.listenerMap.set(t,n)),n.has(e.name)?i?(console.warn(`[MarkerEventBus] Overwriting listener "${e.name}" for event "${t}".`),n.set(e.name,e),!0):(console.warn(`[MarkerEventBus] Listener "${e.name}" for event "${t}" already exists. Use overwrite=true to replace it.`),!1):(n.set(e.name,e),!0)}removeListenerByKey(t){const e=this.listenerMap.has(t);return this.listenerMap.set(t,new Map),e}removeListenerByKeyAndName(t,e){const i=this.listenerMap.get(t);return i?i.delete(e):!1}runListener(t,e,i){const n=this.listenerMap.get(t);if(n)for(const[s,o]of n.entries()){try{o.fn(e,i)}catch(r){console.error(`Error in listener "${s}" for event "${t}":`,r)}o.once&&n.delete(s)}}}const it={[V.Click]:"click",[V.DoubleClick]:"dblclick",[V.RightClick]:"contextmenu",[V.MouseEnter]:"mouseenter",[V.MouseLeave]:"mouseleave",[V.MouseDown]:"mousedown",[V.MouseUp]:"mouseup"};class N{constructor(t,e,i="html-label-container",n,s=!0){h(this,"viewer");h(this,"Cesium");h(this,"container");h(this,"labels",new Map);h(this,"activeIds",new Set);h(this,"occludedIds",new Set);h(this,"_updateFn");h(this,"_cameraChangedFn");h(this,"themes",{});h(this,"occlusionCheckLogs",[]);h(this,"occlusionLogEnabled",!1);h(this,"occlusionLogMax",1e4);h(this,"occlusionOptions",{enabled:!1,throttleMs:120,distanceEpsilon:1});h(this,"_occlusionTimer",null);h(this,"_lastOcclusionAt",0);h(this,"_occlusionChecking",!1);h(this,"_occlusionPending",!1);h(this,"eventBus");h(this,"openWheel",!0);this.Cesium=t,this.viewer=e,this.container=this._createContainer(i),this._updateFn=this._update.bind(this),this.viewer.scene.postRender.addEventListener(this._updateFn),this._cameraChangedFn=this._scheduleOcclusionCheck.bind(this),this.viewer.camera.changed.addEventListener(this._cameraChangedFn),this.eventBus=n||new tt,this.openWheel=s,this.runOcclusionCheckNow()}_createContainer(t){let e=document.getElementById(t);return e||(e=document.createElement("div"),e.id=t,Object.assign(e.style,{position:"absolute",top:"0",left:"0",pointerEvents:"none",width:"100%",height:"100%",zIndex:"100",overflow:"hidden"}),document.body.appendChild(e)),e}registerTheme(t,e){this.themes[t]=e}add(t,e){const{id:i,lon:n,lat:s,height:o=0,theme:r,show:l=!0,notCreateElement:c=!1,style:d}=e,u=this.themes[r];if(!u){console.warn(`Theme "${r}" not registered`);return}let m=this.labels.get(i);if(m){m.theme=r,m.data=t,m.notCreateElement=c;try{m.unload=u.createElement(m.el,{id:i,theme:r,data:t},u),(!c||l)&&this.container.appendChild(m.el)}catch(g){console.error(`Error updating label element for id "${i}":`,g)}}else{const g=document.createElement("div");Object.assign(g.style,{position:"absolute",transform:"translate(0, 0)",pointerEvents:"auto",...e.style||{}});for(const[f,w]of Object.entries(it)){g.addEventListener(w,v=>{v.stopPropagation();const C=this.labels.get(i);this.eventBus.runListener(f,C,v)});let y=0;g.addEventListener("wheel",v=>{if(!this.openWheel)return;const C=v.currentTarget;y=Date.now();const b=y;C.style.pointerEvents="none",setTimeout(()=>{y===b&&(C.style.pointerEvents="auto")},2e3)})}let p=null;if(!c||l){try{p=u.createElement(g,{id:i,theme:r,data:t},u)||{}}catch(f){console.error(`Error updating label element for id "${i}":`,f)}this.container.appendChild(g)}m={id:i,el:g,theme:r,data:t,notCreateElement:c,unload:p},this.labels.set(i,m)}m.el.dataset.lon=String(n),m.el.dataset.lat=String(s),m.el.dataset.height=String(o),m.el.style.zIndex=(d==null?void 0:d.zIndex)||"1",m.el.style.display=l?"block":"none",l&&this.activeIds.add(i),l?this._scheduleOcclusionCheck():this.occludedIds.delete(i)}addBatch(t){for(const{data:e,options:i}of t)this.add(e,i)}removeByIds(t){for(const e of t){const i=this.labels.get(e);i&&(this.unloadByLabel(i),this.labels.delete(e),this.activeIds.delete(e),this.occludedIds.delete(e))}}unloadByLabel(t){t.el.remove(),t!=null&&t.unload&&typeof t.unload=="function"&&(t==null||t.unload()),t.unload=null}removeAll(){for(const t of this.labels.values())this.unloadByLabel(t);this.labels.clear(),this.activeIds.clear(),this.occludedIds.clear()}update(t,e){const i=this.labels.get(t);if(!i){console.warn(`Label with id "${t}" not found for update.`);return}const n=this.themes[i.theme];if(!n){console.warn(`Theme "${i.theme}" not registered.`);return}try{n.createElement(i.el,{id:t,theme:i.theme,data:e},n)}catch(s){console.error(`Failed to update label "${t}":`,s)}}hideByIds(t){for(const e of t){const i=this.labels.get(e);i&&(i.notCreateElement&&this.unloadByLabel(i),i.el.style.display="none",this.activeIds.delete(e),this.occludedIds.delete(e))}}hideAll(){for(const t of this.labels.values())t.notCreateElement&&this.unloadByLabel(t),t.el.style.display="none",this.activeIds.delete(t.id),this.occludedIds.delete(t.id)}hideFilter(t){for(const e of this.labels.values())t(e.data)&&(e.notCreateElement&&this.unloadByLabel(e),e.el.style.display="none",this.activeIds.delete(e.id),this.occludedIds.delete(e.id))}showByIds(t){for(const e of t){const i=this.labels.get(e);if(i){if((i.notCreateElement||!i.el.parentNode)&&this.container.appendChild(i.el),!i.unload)try{const n=this.themes[i.theme];if(!n){console.warn(`Theme "${i.theme}" not registered`);return}i.unload=n.createElement(i.el,{id:e,theme:i.theme,data:i.data},n)||{}}catch(n){console.error(`Error creating label element for theme "${i.theme}":`,n);return}i.el.style.display="block",this.activeIds.add(e),this.occludedIds.delete(e)}}this._scheduleOcclusionCheck()}has(t){return this.labels.has(t)}reset(){for(const t of this.activeIds.values()){let e=this.labels.get(t);e&&this.unloadByLabel(e)}this.activeIds.clear()}cleanup(){for(const[t,e]of this.labels.entries())this.activeIds.has(t)||(e.el.style.display="none",this.occludedIds.delete(t))}async toWindowPositionByLonLat(t,e){const i=this.Cesium,n=this.viewer.scene,s=[i.Cartographic.fromDegrees(t,e)];let o;try{o=await n.clampToHeightMostDetailed(s)}catch{console.warn("clampToHeightMostDetailed failed, fallback to ellipsoid height.")}let r=0;o&&o[0]&&o[0].height!=null?r=o[0].height:r=0;const l=i.Cartesian3.fromDegrees(t,e,r);return this.toWindowCoordinates(l)}toWindowCoordinates(t){const e=this.viewer.scene,i=this.Cesium.SceneTransforms;if(typeof(i==null?void 0:i.wgs84ToWindowCoordinates)=="function")return i.wgs84ToWindowCoordinates(e,t);if(typeof(i==null?void 0:i.worldToWindowCoordinates)=="function")return i.worldToWindowCoordinates(e,t);console.warn("No compatible window coordinate transform function found.")}_isValidCoordinate(t,e){return!(Number.isNaN(t)||Number.isNaN(e)||t===0&&e===0||t<-180||t>180||e<-90||e>90)}async _update(){var t;for(const e of this.activeIds){const i=this.labels.get(e);if(!i)continue;const n=parseFloat(i.el.dataset.lon),s=parseFloat(i.el.dataset.lat),o=parseFloat(i.el.dataset.height||"0");if(!this._isValidCoordinate(n,s)){i.el.style.display="none";continue}const r=this.Cesium.Cartesian3.fromDegrees(n,s,o),l=this.toWindowCoordinates(r);if(this.Cesium.defined(l)){const d=((t=this.themes[i.theme].options)==null?void 0:t.offset)||{},u=d.x||0,m=d.y||0,g=this.occludedIds.has(e);i.el.style.left=`${l.x}px`,i.el.style.top=`${l.y}px`,i.el.style.transform=`translate(${u}px, ${m}px)`,i.el.style.display=g?"none":"block"}else i.el.style.display="none"}}_scheduleOcclusionCheck(){if(!this.occlusionOptions.enabled)return;const t=Date.now(),e=Math.max(0,Number(this.occlusionOptions.throttleMs)||0),i=t-this._lastOcclusionAt,n=Math.max(0,e-i);if(n===0){this.runOcclusionCheckNow();return}this._occlusionTimer===null&&(this._occlusionTimer=window.setTimeout(()=>{this._occlusionTimer=null,this.runOcclusionCheckNow()},n))}_pushOcclusionLog(t){this.occlusionLogEnabled&&(this.occlusionCheckLogs.push(t),this.occlusionCheckLogs.length>this.occlusionLogMax&&this.occlusionCheckLogs.splice(0,this.occlusionCheckLogs.length-this.occlusionLogMax))}_computeLabelOccluded(t,e,i,n,s,o){var d,u;const r=(d=this.viewer)==null?void 0:d.scene,l=(u=this.viewer)==null?void 0:u.camera,c=this.Cesium;if(!r||!l||!c)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"runtime-missing"}),!0;if(!r.pickPositionSupported||!i)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-unsupported"}),!0;try{const m=r.pickPosition(i);if(!m||!l.positionWC)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-empty"}),!0;const g=Number(this.occlusionOptions.distanceEpsilon)||0,p=c.Cartesian3.distance(l.positionWC,e),f=c.Cartesian3.distance(l.positionWC,m),w=f+g<p;return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:w,reason:"distance-compare",epsilon:g,labelDistance:p,pickedDistance:f}),w}catch{return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:n,lat:s,height:o,occluded:!0,reason:"pick-error"}),!0}}runOcclusionCheckNow(){if(!this.occlusionOptions.enabled){this.occludedIds.clear();return}if(this._occlusionChecking){this._occlusionPending=!0;return}this._occlusionChecking=!0;try{for(const t of this.activeIds){const e=this.labels.get(t);if(!e){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,occluded:!1,reason:"label-missing"});continue}const i=parseFloat(e.el.dataset.lon),n=parseFloat(e.el.dataset.lat),s=parseFloat(e.el.dataset.height||"0");if(!this._isValidCoordinate(i,n)){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:i,lat:n,height:s,occluded:!1,reason:"invalid-coordinate"});continue}const o=this.Cesium.Cartesian3.fromDegrees(i,n,s),r=this.toWindowCoordinates(o);if(!this.Cesium.defined(r)){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:i,lat:n,height:s,occluded:!1,reason:"screen-position-undefined"});continue}this._computeLabelOccluded(t,o,r,i,n,s)?this.occludedIds.add(t):this.occludedIds.delete(t)}}finally{this._lastOcclusionAt=Date.now(),this._occlusionChecking=!1,this._occlusionPending&&(this._occlusionPending=!1,this._scheduleOcclusionCheck())}}setOcclusionEnabled(t){this.occlusionOptions.enabled=!!t,this.occlusionOptions.enabled?this.runOcclusionCheckNow():(this.occludedIds.clear(),this._occlusionTimer!==null&&(clearTimeout(this._occlusionTimer),this._occlusionTimer=null))}getOcclusionOptions(){return{enabled:this.occlusionOptions.enabled,throttleMs:this.occlusionOptions.throttleMs,distanceEpsilon:this.occlusionOptions.distanceEpsilon}}setOcclusionOptions(t){t.throttleMs!=null&&(this.occlusionOptions.throttleMs=Math.max(0,Number(t.throttleMs)||0)),t.distanceEpsilon!=null&&(this.occlusionOptions.distanceEpsilon=Math.max(0,Number(t.distanceEpsilon)||0)),this.occlusionOptions.enabled&&this._scheduleOcclusionCheck()}setOcclusionLogEnabled(t,e=!1){this.occlusionLogEnabled=!!t,e&&(this.occlusionCheckLogs=[])}destroy(){this.viewer.scene.postRender.removeEventListener(this._updateFn),this.viewer.camera.changed.removeEventListener(this._cameraChangedFn),this._occlusionTimer!==null&&(clearTimeout(this._occlusionTimer),this._occlusionTimer=null),this.labels.clear(),this.activeIds.clear(),this.occludedIds.clear()}}class _e{constructor(){h(this,"tooltipEl");h(this,"visible",!1);h(this,"offsetX",10);h(this,"offsetY",-20);h(this,"onMouseMove",null);this.tooltipEl=document.createElement("div"),this.tooltipEl.style.position="fixed",this.tooltipEl.style.pointerEvents="none",this.tooltipEl.style.zIndex="10000",this.tooltipEl.style.padding="4px 8px",this.tooltipEl.style.borderRadius="4px",this.tooltipEl.style.background="rgba(0, 0, 0, 0.7)",this.tooltipEl.style.color="#fff",this.tooltipEl.style.fontSize="13px",this.tooltipEl.style.transition="opacity 0.1s ease",this.tooltipEl.style.opacity="0",document.body.appendChild(this.tooltipEl),this.onMouseMove=t=>{this.visible&&(this.tooltipEl.style.left=`${t.clientX+this.offsetX}px`,this.tooltipEl.style.top=`${t.clientY+this.offsetY}px`)},window.addEventListener("mousemove",this.onMouseMove)}show(t){this.tooltipEl.innerText=t,this.tooltipEl.style.opacity="1",this.visible=!0}hide(){this.tooltipEl.style.opacity="0",this.visible=!1}destroy(){this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.tooltipEl.parentElement&&this.tooltipEl.parentElement.removeChild(this.tooltipEl)}}class Gt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"tooltip",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.tooltip=new _e,this.tooltip.show("左键添加点"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var m,g;const s=i.scene.pickPosition(n.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(o.longitude),l=e.Math.toDegrees(o.latitude),c=o.height,d=i.entities.add({position:s,point:{pixelSize:10,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.entity=d;const u={entity:d,position:s,lnglat:{lng:r,lat:l,height:c},clear:()=>{this.clear()}};(m=t.onComplete)==null||m.call(t,u),this.stopDrawing(),(g=this.tooltip)==null||g.hide(),this.tooltip=null},e.ScreenSpaceEventType.LEFT_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.stopDrawing()}}class Bt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}getPickPosition(t){var s,o,r,l;const{viewer:e}=this,i=e==null?void 0:e.scene;if(!i||!t)return null;let n=null;try{i.pickPositionSupported&&(n=i.pickPosition(t))}catch(c){console.warn("[LineDrawer] pickPosition failed:",c)}if(!n){const c=(o=(s=e.camera)==null?void 0:s.getPickRay)==null?void 0:o.call(s,t);c&&(n=((l=(r=i.globe)==null?void 0:r.pick)==null?void 0:l.call(r,c,i))||null)}return n}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.entity=null,this.tooltip=new _e,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var r,l;const s=this.getPickPosition(n.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(o),this.entity?this.entity.polyline.positions=this.positions.slice():this.entity=i.entities.add({polyline:{positions:this.positions.slice(),width:3,material:t.color||e.Color.YELLOW,depthFailMaterial:((l=(r=t.color)==null?void 0:r.withAlpha)==null?void 0:l.call(r,.5))||e.Color.YELLOW.withAlpha(.5)}})},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var o,r;if(this.stopDrawing(),(o=this.tooltip)==null||o.hide(),this.tooltip=null,this.positions.length<2)return;this.positions.length=this.positions.length-1,this.entity&&(this.entity.polyline.positions=this.positions.slice());const n=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:n,clear:()=>{this.clear()}};(r=t.onComplete)==null||r.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class jt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"startPoint",null);h(this,"endPoint",null);h(this,"entity",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var o;const s=i.scene.pickPosition(n.position);if(s)if(!this.startPoint)this.startPoint=s,this.entity=i.entities.add({rectangle:{coordinates:new e.CallbackProperty(()=>{if(!(!this.startPoint||!this.endPoint))try{const r=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c=Math.min(r.longitude,l.longitude),d=Math.max(r.longitude,l.longitude),u=Math.min(r.latitude,l.latitude),m=Math.max(r.latitude,l.latitude);return new e.Rectangle(c,u,d,m)}catch(r){console.warn("Rectangle calculation error:",r);return}},!1),material:t.color||e.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:e.Color.BLACK,disableDepthTestDistance:Number.POSITIVE_INFINITY}});else{this.stopDrawing();const r=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c={lng:e.Math.toDegrees(Math.min(r.longitude,l.longitude)),lat:e.Math.toDegrees(Math.min(r.latitude,l.latitude)),height:0},d={lng:e.Math.toDegrees(Math.max(r.longitude,l.longitude)),lat:e.Math.toDegrees(Math.max(r.latitude,l.latitude)),height:0},u={entity:this.entity,position:this.startPoint,lnglat:{lng:e.Math.toDegrees(r.longitude),lat:e.Math.toDegrees(r.latitude),height:r.height},positions:[this.startPoint,this.endPoint],lnglats:[c,d],clear:()=>{this.clear()}};(o=t.onComplete)==null||o.call(t,u)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{if(!this.startPoint)return;const s=i.scene.pickPosition(n.endPosition);s&&(this.endPoint=s)},e.ScreenSpaceEventType.MOUSE_MOVE)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.startPoint=null,this.endPoint=null,this.stopDrawing()}}class Yt{constructor(t,e){h(this,"viewer");h(this,"Cesium");h(this,"handler",null);h(this,"entity",null);h(this,"positions",[]);h(this,"_isDrawing",!1);h(this,"currentRadius",0);this.Cesium=t,this.viewer=e}startDrawing(t){this.clear(),this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.canvas),this._isDrawing=!0,this.handler.setInputAction(e=>{const i=this.viewer.scene.pickPosition(e.position);i&&(this.positions.push(i),this.positions.length===2&&(this.stopDrawing(),this.drawFinalCircle(t)))},this.Cesium.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(e=>{if(this.positions.length!==1)return;const i=this.positions[0],n=this.viewer.camera.getPickRay(e.endPosition),s=this.viewer.scene.globe.pick(n,this.viewer.scene);s&&this.drawPreviewCircle(i,s,t)},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}drawPreviewCircle(t,e,i){const n=this.Cesium.Cartesian3.distance(t,e);if(this.entity)Math.abs(this.currentRadius-n)>.5&&(this.currentRadius=n);else{this.currentRadius=n;const s=new this.Cesium.CallbackProperty(()=>this.currentRadius,!1);this.entity=this.viewer.entities.add({position:t,ellipse:{semiMajorAxis:s,semiMinorAxis:s,material:i.color||this.Cesium.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:i.color||this.Cesium.Color.YELLOW,heightReference:this.Cesium.HeightReference.NONE,disableDepthTestDistance:Number.POSITIVE_INFINITY}})}}drawFinalCircle(t){var u;const[e,i]=this.positions,n=this.Cesium.Cartesian3.distance(e,i),s=this.Cesium.Cartographic.fromCartesian(e),o={lng:this.Cesium.Math.toDegrees(s.longitude),lat:this.Cesium.Math.toDegrees(s.latitude),height:s.height},r=(t==null?void 0:t.step)||1,l=[],c=[];for(let m=0;m<360;m+=r){const g=this.Cesium.Math.toRadians(m),p=new this.Cesium.EllipsoidGeodesic;p.setEndPoints(s,new this.Cesium.Cartographic(s.longitude+1e-4*Math.cos(g),s.latitude+1e-4*Math.sin(g)));const f=p.interpolateUsingSurfaceDistance(n),w=this.Cesium.Ellipsoid.WGS84.cartographicToCartesian(f);l.push(w);const y=this.Cesium.Cartographic.fromCartesian(w);c.push({lng:this.Cesium.Math.toDegrees(y.longitude),lat:this.Cesium.Math.toDegrees(y.latitude),height:y.height})}c.push(c[0]);const d=this.positions.map(m=>{const g=this.Cesium.Cartographic.fromCartesian(m);return{lng:this.Cesium.Math.toDegrees(g.longitude),lat:this.Cesium.Math.toDegrees(g.latitude),height:g.height}});(u=t.onComplete)==null||u.call(t,{entity:this.entity,positions:this.positions,lnglats:d,circlePoints:l,circleLnglats:c,center:o,radius:n,clear:()=>{this.clear()}})}stopDrawing(){this.handler&&(this.handler.destroy(),this.handler=null),this._isDrawing=!1}clear(){this.stopDrawing(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.positions=[],this.currentRadius=0}}class Vt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"lnglats",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}isHelperPick(t){var e;return((e=t==null?void 0:t.id)==null?void 0:e._drawHelper)===!0}withHiddenHelpers(t){const e=[this.entity,...this.tempPoints].filter(Boolean),i=e.map(n=>n.show);e.forEach(n=>{n.show=!1});try{return t()}finally{e.forEach((n,s)=>{n.show=i[s]})}}getPickPosition(t){var r,l,c,d;const{viewer:e}=this,i=e==null?void 0:e.scene;if(!i||!t)return null;let n=null;const s=i.pick(t),o=this.isHelperPick(s);try{i.pickPositionSupported&&(n=o?this.withHiddenHelpers(()=>i.pickPosition(t)):i.pickPosition(t))}catch(u){console.warn("[PolygonDrawer] pickPosition failed:",u)}if(!n){const u=(l=(r=e.camera)==null?void 0:r.getPickRay)==null?void 0:l.call(r,t);u&&(n=((d=(c=i.globe)==null?void 0:c.pick)==null?void 0:d.call(c,u,i))||null)}return n}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.lnglats=[],this.tempPoints=[],this.entity=null,this.tooltip=new _e,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{const s=this.getPickPosition(n.position);if(!s)return;this.positions.push(s);const o=e.Cartographic.fromCartesian(s);this.lnglats.push({lng:e.Math.toDegrees(o.longitude),lat:e.Math.toDegrees(o.latitude),height:Number.isFinite(o.height)?o.height:0});const r=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});r._drawHelper=!0,this.tempPoints.push(r),this.entity||(this.entity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>({positions:this.positions}),!1),material:t.color||e.Color.YELLOW.withAlpha(.5)}}),this.entity._drawHelper=!0)},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var o,r;if(this.stopDrawing(),(o=this.tooltip)==null||o.hide(),this.tooltip=null,this.positions.length<3)return;this.positions.length=this.positions.length-1,this.lnglats.length=this.lnglats.length-1;const n=this.lnglats.slice(),s={entity:this.entity,positions:this.positions,lnglats:n,clear:()=>{this.clear()}};(r=t.onComplete)==null||r.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.lnglats=[],this.stopDrawing()}}class Wt{constructor(t,e){h(this,"viewer");h(this,"Cesium");h(this,"activeDrawer",null);this.viewer=e,this.Cesium=t}draw(t,e){var i;switch(this.clear(),t){case"point":this.activeDrawer=new Gt(this.Cesium,this.viewer);break;case"line":this.activeDrawer=new Bt(this.Cesium,this.viewer);break;case"rectangle":this.activeDrawer=new jt(this.Cesium,this.viewer);break;case"circle":this.activeDrawer=new Yt(this.Cesium,this.viewer);break;case"polygon":this.activeDrawer=new Vt(this.Cesium,this.viewer);break;default:throw new Error(`Unsupported draw type: ${t}`)}(i=this.activeDrawer)==null||i.startDrawing(e)}clear(){this.activeDrawer&&(this.activeDrawer.stopDrawing(),this.activeDrawer.clear(),this.activeDrawer=null)}cancel(){this.clear()}}var st=typeof global=="object"&&global&&global.Object===Object&&global,Ut=typeof self=="object"&&self&&self.Object===Object&&self,se=st||Ut||Function("return this")(),me=se.Symbol,ot=Object.prototype,Kt=ot.hasOwnProperty,qt=ot.toString,be=me?me.toStringTag:void 0;function Xt(a){var t=Kt.call(a,be),e=a[be];try{a[be]=void 0;var i=!0}catch{}var n=qt.call(a);return i&&(t?a[be]=e:delete a[be]),n}var Jt=Object.prototype,Qt=Jt.toString;function Zt(a){return Qt.call(a)}var ei="[object Null]",ti="[object Undefined]",nt=me?me.toStringTag:void 0;function Pe(a){return a==null?a===void 0?ti:ei:nt&&nt in Object(a)?Xt(a):Zt(a)}function Le(a){return a!=null&&typeof a=="object"}var xe=Array.isArray;function De(a){var t=typeof a;return a!=null&&(t=="object"||t=="function")}var ii="[object AsyncFunction]",si="[object Function]",oi="[object GeneratorFunction]",ni="[object Proxy]";function rt(a){if(!De(a))return!1;var t=Pe(a);return t==si||t==oi||t==ii||t==ni}var Fe=se["__core-js_shared__"],at=(function(){var a=/[^.]+$/.exec(Fe&&Fe.keys&&Fe.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""})();function ri(a){return!!at&&at in a}var ai=Function.prototype,li=ai.toString;function ce(a){if(a!=null){try{return li.call(a)}catch{}try{return a+""}catch{}}return""}var hi=/[\\^$.*+?()[\]{}|]/g,ci=/^\[object .+?Constructor\]$/,di=Function.prototype,pi=Object.prototype,ui=di.toString,mi=pi.hasOwnProperty,gi=RegExp("^"+ui.call(mi).replace(hi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fi(a){if(!De(a)||ri(a))return!1;var t=rt(a)?gi:ci;return t.test(ce(a))}function yi(a,t){return a==null?void 0:a[t]}function de(a,t){var e=yi(a,t);return fi(e)?e:void 0}var Re=de(se,"WeakMap"),lt=Object.create,wi=(function(){function a(){}return function(t){if(!De(t))return{};if(lt)return lt(t);a.prototype=t;var e=new a;return a.prototype=void 0,e}})(),ht=(function(){try{var a=de(Object,"defineProperty");return a({},"",{}),a}catch{}})();function vi(a,t){for(var e=-1,i=a==null?0:a.length;++e<i&&t(a[e],e,a)!==!1;);return a}var Ci=9007199254740991,bi=/^(?:0|[1-9]\d*)$/;function Pi(a,t){var e=typeof a;return t=t??Ci,!!t&&(e=="number"||e!="symbol"&&bi.test(a))&&a>-1&&a%1==0&&a<t}function Li(a,t,e){t=="__proto__"&&ht?ht(a,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):a[t]=e}function ct(a,t){return a===t||a!==a&&t!==t}var Ei=Object.prototype,Mi=Ei.hasOwnProperty;function Ii(a,t,e){var i=a[t];(!(Mi.call(a,t)&&ct(i,e))||e===void 0&&!(t in a))&&Li(a,t,e)}var Ti=9007199254740991;function dt(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=Ti}function _i(a){return a!=null&&dt(a.length)&&!rt(a)}var xi=Object.prototype;function pt(a){var t=a&&a.constructor,e=typeof t=="function"&&t.prototype||xi;return a===e}function Di(a,t){for(var e=-1,i=Array(a);++e<a;)i[e]=t(e);return i}var Si="[object Arguments]";function ut(a){return Le(a)&&Pe(a)==Si}var mt=Object.prototype,Ai=mt.hasOwnProperty,$i=mt.propertyIsEnumerable,Oi=ut((function(){return arguments})())?ut:function(a){return Le(a)&&Ai.call(a,"callee")&&!$i.call(a,"callee")};function ki(){return!1}var gt=typeof S=="object"&&S&&!S.nodeType&&S,ft=gt&&typeof module=="object"&&module&&!module.nodeType&&module,Fi=ft&&ft.exports===gt,yt=Fi?se.Buffer:void 0,Ri=yt?yt.isBuffer:void 0,wt=Ri||ki,Hi="[object Arguments]",zi="[object Array]",Ni="[object Boolean]",Gi="[object Date]",Bi="[object Error]",ji="[object Function]",Yi="[object Map]",Vi="[object Number]",Wi="[object Object]",Ui="[object RegExp]",Ki="[object Set]",qi="[object String]",Xi="[object WeakMap]",Ji="[object ArrayBuffer]",Qi="[object DataView]",Zi="[object Float32Array]",es="[object Float64Array]",ts="[object Int8Array]",is="[object Int16Array]",ss="[object Int32Array]",os="[object Uint8Array]",ns="[object Uint8ClampedArray]",rs="[object Uint16Array]",as="[object Uint32Array]",z={};z[Zi]=z[es]=z[ts]=z[is]=z[ss]=z[os]=z[ns]=z[rs]=z[as]=!0,z[Hi]=z[zi]=z[Ji]=z[Ni]=z[Qi]=z[Gi]=z[Bi]=z[ji]=z[Yi]=z[Vi]=z[Wi]=z[Ui]=z[Ki]=z[qi]=z[Xi]=!1;function ls(a){return Le(a)&&dt(a.length)&&!!z[Pe(a)]}function He(a){return function(t){return a(t)}}var vt=typeof S=="object"&&S&&!S.nodeType&&S,Ee=vt&&typeof module=="object"&&module&&!module.nodeType&&module,hs=Ee&&Ee.exports===vt,ze=hs&&st.process,ge=(function(){try{var a=Ee&&Ee.require&&Ee.require("util").types;return a||ze&&ze.binding&&ze.binding("util")}catch{}})(),Ct=ge&&ge.isTypedArray,cs=Ct?He(Ct):ls,ds=Object.prototype,ps=ds.hasOwnProperty;function us(a,t){var e=xe(a),i=!e&&Oi(a),n=!e&&!i&&wt(a),s=!e&&!i&&!n&&cs(a),o=e||i||n||s,r=o?Di(a.length,String):[],l=r.length;for(var c in a)ps.call(a,c)&&!(o&&(c=="length"||n&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Pi(c,l)))&&r.push(c);return r}function bt(a,t){return function(e){return a(t(e))}}var ms=bt(Object.keys,Object),gs=Object.prototype,fs=gs.hasOwnProperty;function ys(a){if(!pt(a))return ms(a);var t=[];for(var e in Object(a))fs.call(a,e)&&e!="constructor"&&t.push(e);return t}function ws(a){return _i(a)?us(a):ys(a)}var Me=de(Object,"create");function vs(){this.__data__=Me?Me(null):{},this.size=0}function Cs(a){var t=this.has(a)&&delete this.__data__[a];return this.size-=t?1:0,t}var bs="__lodash_hash_undefined__",Ps=Object.prototype,Ls=Ps.hasOwnProperty;function Es(a){var t=this.__data__;if(Me){var e=t[a];return e===bs?void 0:e}return Ls.call(t,a)?t[a]:void 0}var Ms=Object.prototype,Is=Ms.hasOwnProperty;function Ts(a){var t=this.__data__;return Me?t[a]!==void 0:Is.call(t,a)}var _s="__lodash_hash_undefined__";function xs(a,t){var e=this.__data__;return this.size+=this.has(a)?0:1,e[a]=Me&&t===void 0?_s:t,this}function pe(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}pe.prototype.clear=vs,pe.prototype.delete=Cs,pe.prototype.get=Es,pe.prototype.has=Ts,pe.prototype.set=xs;function Ds(){this.__data__=[],this.size=0}function Se(a,t){for(var e=a.length;e--;)if(ct(a[e][0],t))return e;return-1}var Ss=Array.prototype,As=Ss.splice;function $s(a){var t=this.__data__,e=Se(t,a);if(e<0)return!1;var i=t.length-1;return e==i?t.pop():As.call(t,e,1),--this.size,!0}function Os(a){var t=this.__data__,e=Se(t,a);return e<0?void 0:t[e][1]}function ks(a){return Se(this.__data__,a)>-1}function Fs(a,t){var e=this.__data__,i=Se(e,a);return i<0?(++this.size,e.push([a,t])):e[i][1]=t,this}function ne(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}ne.prototype.clear=Ds,ne.prototype.delete=$s,ne.prototype.get=Os,ne.prototype.has=ks,ne.prototype.set=Fs;var Ie=de(se,"Map");function Rs(){this.size=0,this.__data__={hash:new pe,map:new(Ie||ne),string:new pe}}function Hs(a){var t=typeof a;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?a!=="__proto__":a===null}function Ae(a,t){var e=a.__data__;return Hs(t)?e[typeof t=="string"?"string":"hash"]:e.map}function zs(a){var t=Ae(this,a).delete(a);return this.size-=t?1:0,t}function Ns(a){return Ae(this,a).get(a)}function Gs(a){return Ae(this,a).has(a)}function Bs(a,t){var e=Ae(this,a),i=e.size;return e.set(a,t),this.size+=e.size==i?0:1,this}function fe(a){var t=-1,e=a==null?0:a.length;for(this.clear();++t<e;){var i=a[t];this.set(i[0],i[1])}}fe.prototype.clear=Rs,fe.prototype.delete=zs,fe.prototype.get=Ns,fe.prototype.has=Gs,fe.prototype.set=Bs;function js(a,t){for(var e=-1,i=t.length,n=a.length;++e<i;)a[n+e]=t[e];return a}var Ys=bt(Object.getPrototypeOf,Object);function Vs(){this.__data__=new ne,this.size=0}function Ws(a){var t=this.__data__,e=t.delete(a);return this.size=t.size,e}function Us(a){return this.__data__.get(a)}function Ks(a){return this.__data__.has(a)}var qs=200;function Xs(a,t){var e=this.__data__;if(e instanceof ne){var i=e.__data__;if(!Ie||i.length<qs-1)return i.push([a,t]),this.size=++e.size,this;e=this.__data__=new fe(i)}return e.set(a,t),this.size=e.size,this}function ye(a){var t=this.__data__=new ne(a);this.size=t.size}ye.prototype.clear=Vs,ye.prototype.delete=Ws,ye.prototype.get=Us,ye.prototype.has=Ks,ye.prototype.set=Xs;var Pt=typeof S=="object"&&S&&!S.nodeType&&S,Lt=Pt&&typeof module=="object"&&module&&!module.nodeType&&module,Js=Lt&&Lt.exports===Pt,Et=Js?se.Buffer:void 0;Et&&Et.allocUnsafe;function Qs(a,t){return a.slice()}function Zs(a,t){for(var e=-1,i=a==null?0:a.length,n=0,s=[];++e<i;){var o=a[e];t(o,e,a)&&(s[n++]=o)}return s}function eo(){return[]}var to=Object.prototype,io=to.propertyIsEnumerable,Mt=Object.getOwnPropertySymbols,so=Mt?function(a){return a==null?[]:(a=Object(a),Zs(Mt(a),function(t){return io.call(a,t)}))}:eo;function oo(a,t,e){var i=t(a);return xe(a)?i:js(i,e(a))}function no(a){return oo(a,ws,so)}var Ne=de(se,"DataView"),Ge=de(se,"Promise"),Be=de(se,"Set"),It="[object Map]",ro="[object Object]",Tt="[object Promise]",_t="[object Set]",xt="[object WeakMap]",Dt="[object DataView]",ao=ce(Ne),lo=ce(Ie),ho=ce(Ge),co=ce(Be),po=ce(Re),re=Pe;(Ne&&re(new Ne(new ArrayBuffer(1)))!=Dt||Ie&&re(new Ie)!=It||Ge&&re(Ge.resolve())!=Tt||Be&&re(new Be)!=_t||Re&&re(new Re)!=xt)&&(re=function(a){var t=Pe(a),e=t==ro?a.constructor:void 0,i=e?ce(e):"";if(i)switch(i){case ao:return Dt;case lo:return It;case ho:return Tt;case co:return _t;case po:return xt}return t});var uo=Object.prototype,mo=uo.hasOwnProperty;function go(a){var t=a.length,e=new a.constructor(t);return t&&typeof a[0]=="string"&&mo.call(a,"index")&&(e.index=a.index,e.input=a.input),e}var St=se.Uint8Array;function je(a){var t=new a.constructor(a.byteLength);return new St(t).set(new St(a)),t}function fo(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.byteLength)}var yo=/\w*$/;function wo(a){var t=new a.constructor(a.source,yo.exec(a));return t.lastIndex=a.lastIndex,t}var At=me?me.prototype:void 0,$t=At?At.valueOf:void 0;function vo(a){return $t?Object($t.call(a)):{}}function Co(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.length)}var bo="[object Boolean]",Po="[object Date]",Lo="[object Map]",Eo="[object Number]",Mo="[object RegExp]",Io="[object Set]",To="[object String]",_o="[object Symbol]",xo="[object ArrayBuffer]",Do="[object DataView]",So="[object Float32Array]",Ao="[object Float64Array]",$o="[object Int8Array]",Oo="[object Int16Array]",ko="[object Int32Array]",Fo="[object Uint8Array]",Ro="[object Uint8ClampedArray]",Ho="[object Uint16Array]",zo="[object Uint32Array]";function No(a,t,e){var i=a.constructor;switch(t){case xo:return je(a);case bo:case Po:return new i(+a);case Do:return fo(a);case So:case Ao:case $o:case Oo:case ko:case Fo:case Ro:case Ho:case zo:return Co(a);case Lo:return new i;case Eo:case To:return new i(a);case Mo:return wo(a);case Io:return new i;case _o:return vo(a)}}function Go(a){return typeof a.constructor=="function"&&!pt(a)?wi(Ys(a)):{}}var Bo="[object Map]";function jo(a){return Le(a)&&re(a)==Bo}var Ot=ge&&ge.isMap,Yo=Ot?He(Ot):jo,Vo="[object Set]";function Wo(a){return Le(a)&&re(a)==Vo}var kt=ge&&ge.isSet,Uo=kt?He(kt):Wo,Ft="[object Arguments]",Ko="[object Array]",qo="[object Boolean]",Xo="[object Date]",Jo="[object Error]",Rt="[object Function]",Qo="[object GeneratorFunction]",Zo="[object Map]",en="[object Number]",Ht="[object Object]",tn="[object RegExp]",sn="[object Set]",on="[object String]",nn="[object Symbol]",rn="[object WeakMap]",an="[object ArrayBuffer]",ln="[object DataView]",hn="[object Float32Array]",cn="[object Float64Array]",dn="[object Int8Array]",pn="[object Int16Array]",un="[object Int32Array]",mn="[object Uint8Array]",gn="[object Uint8ClampedArray]",fn="[object Uint16Array]",yn="[object Uint32Array]",H={};H[Ft]=H[Ko]=H[an]=H[ln]=H[qo]=H[Xo]=H[hn]=H[cn]=H[dn]=H[pn]=H[un]=H[Zo]=H[en]=H[Ht]=H[tn]=H[sn]=H[on]=H[nn]=H[mn]=H[gn]=H[fn]=H[yn]=!0,H[Jo]=H[Rt]=H[rn]=!1;function $e(a,t,e,i,n,s){var o;if(o!==void 0)return o;if(!De(a))return a;var r=xe(a);if(r)o=go(a);else{var l=re(a),c=l==Rt||l==Qo;if(wt(a))return Qs(a);if(l==Ht||l==Ft||c&&!n)o=c?{}:Go(a);else{if(!H[l])return n?a:{};o=No(a,l)}}s||(s=new ye);var d=s.get(a);if(d)return d;s.set(a,o),Uo(a)?a.forEach(function(g){o.add($e(g,t,e,g,a,s))}):Yo(a)&&a.forEach(function(g,p){o.set(p,$e(g,t,e,p,a,s))});var u=no,m=r?void 0:u(a);return vi(m||a,function(g,p){m&&(p=g,g=a[p]),Ii(o,p,$e(g,t,e,p,a,s))}),o}var wn=1,vn=4;function Oe(a){return $e(a,wn|vn)}var zt=(a=>(a.Rotate="rotate",a.Move="move",a.Scale="scale",a.MoveHeight="moveHeight",a.Empty="",a))(zt||{}),Nt=(a=>(a.Scale="addScale",a.Rotate="rotate",a.Translation="translation",a.Remove="removeById",a.Add="add",a))(Nt||{});class Cn{constructor(t){h(this,"primitives",new Map);h(this,"eventListener",new Map);h(this,"Cesium");h(this,"viewer");h(this,"handler");h(this,"rotationRing");h(this,"translationSquare");h(this,"heightArrow");h(this,"editMode","");h(this,"dragEndCallbackMap",new Map);this.Cesium=t.Cesium,this.viewer=t.viewer,this.handler=new this.Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)}init(t,e=!1){const i=this.viewer;this.primitives.forEach(n=>{i.scene.primitives.remove(n)}),t.forEach(n=>{this.primitives.has(n.id)||this.add(n,e)})}get(t){return this.primitives.get(t)}add(t,e=!0){var u,m,g;const i=this.viewer,n=this.Cesium,s=n.Math.toRadians(((u=t.headingPitchRoll)==null?void 0:u.heading)||0),o=n.Math.toRadians(((m=t.headingPitchRoll)==null?void 0:m.pitch)||0),r=n.Math.toRadians(((g=t.headingPitchRoll)==null?void 0:g.roll)||0),l=new n.HeadingPitchRoll(s,o,r),c=n.Transforms.headingPitchRollToFixedFrame(t.position,l,i.scene.globe.ellipsoid,n.Transforms.eastNorthUpToFixedFrame,new n.Matrix4);let d=i.scene.primitives.add(n.Model.fromGltf({id:t.id,...t.model,modelMatrix:c}));d.scale=t.scale||1,this.primitives.set(t.id,d),d.show=e,this.runEventListener("add",{info:t,gltf:d})}flyTo(t){const e=this.viewer,i=this.Cesium;let n=this.primitives.get(t);const s=n.boundingSphere,o=i.Matrix4.multiplyByPoint(n.modelMatrix,s.center,new i.Cartesian3),r=new i.BoundingSphere(o,s.radius);e.camera.flyToBoundingSphere(r,{duration:1.5,offset:new i.HeadingPitchRange(0,-.5,s.radius*2)})}removeById(t){var n;const e=this.viewer;let i=this.primitives.get(t);if(!i){console.error(`No model found with id: ${t}`);return}e.scene.primitives.remove(i),this.primitives.delete(t),(!((n=this.rotationRing)!=null&&n._instanceIds.includes(`rotationRing_${t}`))||!this.rotationRing)&&this.removeTool(),this.runEventListener("removeById",{id:t,gltf:i})}show(t){let e=this.primitives.get(t);e&&(e.show=!0)}hide(t){let e=this.primitives.get(t);e&&(e.show=!1)}addScale(t,e=.1){let i=this.primitives.get(t.id);i&&(i.scale=i.scale+e,this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t.id,scale:i.scale}))}setScale(t,e=.1){let i=this.primitives.get(t);i&&(i.scale=e,this.updatedTool(i.modelMatrix),this.runEventListener("addScale",{id:t,scale:i.scale}))}setEditMode(t){this.editMode=t}lockCamera(){const t=this.viewer.scene.screenSpaceCameraController;t.enableRotate=!1,t.enableTranslate=!1,t.enableZoom=!1}unlockCamera(){const t=this.viewer.scene.screenSpaceCameraController;t.enableRotate=!0,t.enableTranslate=!0,t.enableZoom=!0}toCartographic(t){const e=this.Cesium.Cartographic.fromCartesian(t);return{longitude:e.longitude,latitude:e.latitude}}calculateHeading(t,e){const i=e.longitude-t.longitude,n=e.latitude-t.latitude;return Math.atan2(n,i)}getModelHeadingPitchRoll(t){const e=this.Cesium,i=this.viewer,n=e.Transforms.eastNorthUpToFixedFrame(e.Matrix4.getTranslation(t,new e.Cartesian3),i.scene.globe.ellipsoid,new e.Matrix4),s=e.Matrix4.multiply(e.Matrix4.inverse(n,new e.Matrix4),t,new e.Matrix4),o=e.Matrix4.getRotation(s,new e.Matrix3),r=e.Quaternion.fromRotationMatrix(o);return e.HeadingPitchRoll.fromQuaternion(r)}addEventListener(t,e,i){let n={f:e,options:i};return this.eventListener.get(t)?(this.eventListener.get(t)||[]).push(n):this.eventListener.set(t,[n]),n}removeEventListener(t,e){let i=this.eventListener.get(t);if(!i)return console.error("key不存在");let n=i.findIndex(s=>s==e);n>=0?i.splice(n,1):console.error("instantiation不存在")}runEventListener(t,e){let i=this.eventListener.get(t);return i?(i.forEach(n=>{typeof n.f=="function"&&n.f(e)}),!0):!1}initEditBox(t){const e=this.Cesium,i=this.viewer,n=i.scene;let s=null,o=null,r=null,l=null,c=null;const d=()=>{s=null,o=null,r=null,c=null,l=null,this.setEditMode(""),this.unlockCamera()},u=(m,g)=>{if(s=this.primitives.get(m),s){o=e.Matrix4.clone(s.modelMatrix);const p=e.Matrix4.getTranslation(o,new e.Cartesian3);r=this.toCartographic(p),c=g.position;const f=n.globe.pick(i.camera.getPickRay(g.position),n);l=this.toCartographic(f),this.lockCamera()}};this.handler.setInputAction(m=>{var f,w,y,v,C,b,M,P,L,E;if(!t())return;const p=n.pick(m.position);if(p&&p.id&&((f=p.id)!=null&&f.includes("rotationRing"))){let I=p.id.split("rotationRing_")[1];this.setEditMode("rotate"),u(I,m)}else if(p&&p.id&&((w=p.id)!=null&&w.includes("translationSquare_"))){let I=p.id.split("translationSquare_")[1];this.setEditMode("move"),u(I,m)}else if(p&&p.id&&((y=p.id)!=null&&y.includes("heightArrow-line_"))){let I=p.id.split("heightArrow-line_")[1];this.setEditMode("moveHeight"),u(I,m)}else if(p&&p.id&&((v=p.id)!=null&&v.includes("heightArrow-arrow_"))){let I=p.id.split("heightArrow-arrow_")[1];this.setEditMode("moveHeight"),u(I,m)}else if(p&&p.id){if(s=this.primitives.get(p.id),!s)return;(!this.rotationRing||!((b=(C=this.rotationRing)==null?void 0:C._instanceIds)!=null&&b.includes(`rotationRing_${s.id}`)))&&this.createRotationRing(s),(!this.translationSquare||!((P=(M=this.translationSquare)==null?void 0:M._instanceIds)!=null&&P.includes(`translationSquare_${s.id}`)))&&this.createTranslationSquare(s),(!this.heightArrow||!((E=(L=this.heightArrow)==null?void 0:L._instanceIds)!=null&&E.includes(`heightArrow_${s.id}`)))&&this.createHeightArrow(s)}else d()},e.ScreenSpaceEventType.LEFT_DOWN),this.handler.setInputAction(m=>{if(t()&&this.editMode!=""&&s){const p=n.globe.pick(i.camera.getPickRay(m.endPosition),n),f=this.toCartographic(p);let w=0;if(this.editMode==="rotate"){let y=this.calculateHeading(r,f);w=this.calculateHeading(r,l)-y,this.rotateModel(s,o,w)}else this.editMode==="move"?this.moveModel(s,o,m):this.editMode==="moveHeight"&&this.moveModelHeight(s,o,m,c)}},e.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(()=>{if(!t())return;let g=this.dragEndCallbackMap.get(s==null?void 0:s.id);if(g&&(this.editMode==="move"||this.editMode==="moveHeight")){let p=g.get("translation");p&&(this.runEventListener("translation",p),g.delete("translation"))}else if(g&&this.editMode==="rotate"){let p=g.get("rotate");p&&(this.runEventListener("rotate",p),g.delete("rotate"))}d()},e.ScreenSpaceEventType.LEFT_UP),this.handler.setInputAction(()=>{this.removeTool()},e.ScreenSpaceEventType.RIGHT_UP)}createRotationRing(t){const e=this.Cesium,i=this.viewer;this.rotationRing&&i.scene.primitives.remove(this.rotationRing);const n=[];for(let r=0;r<=360;r+=3){const l=Math.sin(e.Math.toRadians(r)),c=Math.cos(e.Math.toRadians(r)),d=t.boundingSphere.radius*c,u=t.boundingSphere.radius*l;n.push(new e.Cartesian3(d,u,0))}const s=new e.PolylineGeometry({positions:n,width:Math.max(t.boundingSphere.radius*.05,1)}),o=new e.GeometryInstance({id:`rotationRing_${t.id}`,geometry:s,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.RED)}});this.rotationRing=new e.Primitive({geometryInstances:o,appearance:new e.PolylineColorAppearance({translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.RED.withAlpha(.3)}),translucent:!0}),modelMatrix:t.modelMatrix,cull:!1}),i.scene.primitives.add(this.rotationRing)}createTranslationSquare(t){const e=this.Cesium,i=this.viewer;this.translationSquare&&i.scene.primitives.remove(this.translationSquare);const s=Math.max(t.boundingSphere.radius*.2,1)/2,o=new e.BoxGeometry({maximum:new e.Cartesian3(s,s,s),minimum:new e.Cartesian3(-s,-s,-s)}),r=new e.GeometryInstance({id:`translationSquare_${t.id}`,geometry:o,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.BLUE)}});this.translationSquare=new e.Primitive({geometryInstances:r,appearance:new e.PolylineColorAppearance({translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.BLUE.withAlpha(.3)}),translucent:!0}),cull:!1,modelMatrix:t.modelMatrix}),i.scene.primitives.add(this.translationSquare)}createHeightArrow(t){const e=this.Cesium,i=this.viewer;this.heightArrow&&i.scene.primitives.remove(this.heightArrow);let n=e.Color.GREEN,s=Math.max(t.boundingSphere.radius*.025,1),o=2*s,r=t.boundingSphere.radius+50,l=r*.1;const c=Math.max(t.boundingSphere.radius*.2,1),d=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:r,topRadius:s,bottomRadius:s})),u=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:l,topRadius:0,bottomRadius:o}));let m=r+c,g=(r+c)/2;this.translate(d,[0,0,g]),this.translate(u,[0,0,m]),this.heightArrow=new e.Primitive({modelMatrix:t.modelMatrix,geometryInstances:[new e.GeometryInstance({id:`heightArrow-line_${t.id}`,geometry:d}),new e.GeometryInstance({id:`heightArrow-arrow_${t.id}`,geometry:u})],appearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:n}),translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:n.withAlpha(.3)}),translucent:!0}),cull:!1}),i.scene.primitives.add(this.heightArrow)}translate(t,e){let i=this.Cesium;const n=new i.Cartesian3;xe(e)?(n.x=e[0],n.y=e[1],n.z=e[2]):i.Cartesian3.clone(e,n);for(let s=0;s<t.attributes.position.values.length;s+=3)t.attributes.position.values[s]+=n.x,t.attributes.position.values[s+1]+=n.y,t.attributes.position.values[s+2]+=n.z}removeTool(){this.rotationRing&&this.viewer.scene.primitives.remove(this.rotationRing),this.translationSquare&&this.viewer.scene.primitives.remove(this.translationSquare),this.heightArrow&&this.viewer.scene.primitives.remove(this.heightArrow)}updatedTool(t){this.rotationRing&&(this.rotationRing.modelMatrix=t),this.translationSquare&&(this.translationSquare.modelMatrix=t),this.heightArrow&&(this.heightArrow.modelMatrix=t)}moveModel(t,e,i){const n=this.Cesium,s=this.viewer,o=s.scene,r=o.globe.pick(s.camera.getPickRay(i.endPosition),o);if(r){const l=n.Matrix4.getTranslation(e,new n.Cartesian3),c=n.Cartographic.fromCartesian(l),d=n.Cartographic.fromCartesian(r),u=new n.Cartographic(d.longitude,d.latitude,c.height),m=n.Cartographic.toCartesian(u),g=n.Matrix4.getRotation(e,new n.Matrix3),p=n.Matrix4.fromRotationTranslation(g,m);t.modelMatrix=p,this.updatedTool(p);let f=new n.Cartesian3(p[12],p[13],p[14]),w=this.dragEndCallbackMap.get(t.id);w||(w=new Map,this.dragEndCallbackMap.set(t.id,w)),w.set("translation",{id:t.id,position:f})}}moveModelHeight(t,e,i,n){const s=this.Cesium,o=this.viewer,r=o.scene,l=n.y-i.endPosition.y;if(r.globe.pick(o.camera.getPickRay(i.endPosition),r)){const d=s.Matrix4.getTranslation(e,new s.Cartesian3),u=s.Cartographic.fromCartesian(d),m=new s.Cartographic(u.longitude,u.latitude,u.height+l*.001*Math.max(o.camera.positionCartographic.height,1)),g=s.Cartographic.toCartesian(m),p=s.Matrix4.getRotation(e,new s.Matrix3),f=s.Matrix4.fromRotationTranslation(p,g);t.modelMatrix=f,this.updatedTool(f);let w=new s.Cartesian3(f[12],f[13],f[14]),y=this.dragEndCallbackMap.get(t.id);y||(y=new Map,this.dragEndCallbackMap.set(t.id,y)),y.set("translation",{id:t.id,position:w})}}rotateModel(t,e,i){const n=this.Cesium,s=this.viewer,o=this.getModelHeadingPitchRoll(e),r=o.heading+i,l=new n.HeadingPitchRoll(r,o.pitch,o.roll),c=n.Transforms.headingPitchRollToFixedFrame(n.Matrix4.getTranslation(t.modelMatrix,new n.Cartesian3),l,s.scene.globe.ellipsoid,n.Transforms.eastNorthUpToFixedFrame,new n.Matrix4);t.modelMatrix=c;let d=this.dragEndCallbackMap.get(t.id);d||(d=new Map,this.dragEndCallbackMap.set(t.id,d)),d.set("rotate",{id:t.id,headingPitchRoll:{heading:n.Math.toDegrees(r),pitch:n.Math.toDegrees(o.pitch),roll:n.Math.toDegrees(o.roll)}})}cleanup(){this.handler&&(this.handler.destroy(),this.handler=null)}}function bn(a,t){const e=t.materialType||"DynamicImgMaterial"+Date.now()+Math.floor(Math.random()*1e3);function i(s){this._definitionChanged=new a.Event,this._color=s.color,this._colorSubscription=void 0,this.color=s.color,this.duration=s.duration,this._time=Date.now()}Object.defineProperties(i.prototype,{isConstant:{get(){return!1}},definitionChanged:{get(){return this._definitionChanged}},color:a.createPropertyDescriptor("color")}),i.prototype.getType=function(){return e},i.prototype.getValue=function(s,o){return a.defined(o)||(o={}),o.color=a.Property.getValueOrClonedDefault(this._color,s,a.Color.WHITE,o.color),o.image=t.image,o},i.prototype.equals=function(s){return this===s||s instanceof i&&a.Property.equals(this._color,s._color)};const n=function(s){return`
|
|
2
2
|
czm_material czm_getMaterial(czm_materialInput materialInput)
|
|
3
3
|
{
|
|
4
4
|
czm_material material = czm_getDefaultMaterial(materialInput);
|