leiting-bim 2.1.160 → 2.1.161

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.
@@ -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 ko=Object.defineProperty;var Fo=(S,te,V)=>te in S?ko(S,te,{enumerable:!0,configurable:!0,writable:!0,value:V}):S[te]=V;var h=(S,te,V)=>Fo(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 o=this.viewer.scene&&this.viewer.scene.globe,s=o&&o._surface,n=s&&s._tileProvider,r=(n==null?void 0:n.tilingScheme)||new this.Cesium.GeographicTilingScheme;this._lastTileProvider=n,this.tilingScheme=r,this.levels=this._createLevels(),this._buildLevels(),this._updateFn=this._update.bind(this),this.debugCurrentGrids&&this._ensureDebugImageryLayer(),o&&(this._tileLoadListener=l=>{l===0&&this._cameraDirty&&(this._cameraDirty=!1,this._scheduleUpdate())},o.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,o=(i==null?void 0:i.tilingScheme)||new this.Cesium.GeographicTilingScheme,s=i!==this._lastTileProvider,n=this.tilingScheme!==o;!s&&!n&&this.levels&&this.levels.length>0||(this._lastTileProvider=i,this.tilingScheme=o,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 o=0;for(let s=e;s<=i;s++,o++){const n=360/Math.pow(2,s);t.push({level:s,size:n,minViewWidth:n*4}),this.levelIndexByTileLevel.set(s,o)}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,n,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=(n=(s=i.data)==null?void 0:s.billboard)==null?void 0:n[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 o={...i,...t};this.points[e]=o,this._addPointToGrid(o),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 o=this.gridLayers.get(i.level);if(o)for(const[s,n]of o.entries()){n.allPoints=n.allPoints.filter(r=>!e.has(r.id)),n.skipPoints=n.skipPoints.filter(r=>!e.has(r.id));for(const[r,l]of n.groups.entries()){const c=l.filter(d=>!e.has(d.id));c.length===0?n.groups.delete(r):n.groups.set(r,c)}n.allPoints.length===0&&o.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,o,s,n,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),(o=(i=(e=t.data)==null?void 0:e.billboard)==null?void 0:i[0])!=null&&o.skipAggregation)p.skipPoints.push(t);else{const f=this.groupByTheme?(r=(n=(s=t.data)==null?void 0:s.billboard)==null?void 0:n[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,o=e.maxLevel;const s=e.levelRange;Array.isArray(s)?(s.length>0&&i==null&&(i=s[0]),s.length>1&&o==null&&(o=s[1])):s&&typeof s=="object"&&(i==null&&typeof s.min=="number"&&(i=s.min),o==null&&typeof s.max=="number"&&(o=s.max));const n=i==null?this.defaultMinLevel:Number(i)||this.defaultMinLevel,r=o==null?this.defaultMaxLevel:Number(o)||this.defaultMaxLevel;t.__minLevel=n,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,o=t.__maxLevel??this.defaultMaxLevel;return e>=i&&e<=o}_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=(o,s,n,r)=>{e=this._processCell(o,s,n,r,t,e)};try{const o=this._getSurfaceTiles();if(!o||o.length===0){this._handleNoSurfaceTiles(e);return}this._tilesRetryCount=0,this._processTiles(o,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,o,s;for(const n of this.points){if(t>=this.displayLimit)break;((e=n.data)==null?void 0:e.show)!==!1&&(this.labelPool.add(n.data,{id:`point-${n.id}`,lon:n.lon,lat:n.lat,height:n.height,theme:((s=(o=(i=n.data)==null?void 0:i.billboard)==null?void 0:o[0])==null?void 0:s.theme)||this.pointTheme,style:n.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,o=this.levels[this.levels.length-1].level;if(t>o)return this.levels.length-1;if(t<i)return 0;let s=0,n=1/0;for(let r=0;r<this.levels.length;r++){const l=Math.abs(this.levels[r].level-t);l<n&&(n=l,s=r)}return s}_isTerrainEnabled(){const t=this.viewer.terrainProvider,e=this.viewer.scene,i=e&&e.globe,o=i&&i.terrainProvider,s=t||o;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,o=!this._isTerrainEnabled(),s=this.viewer.scene,n=s&&s.globe,r=n&&n.ellipsoid,l=r&&s.camera.computeViewRectangle(r),c=(d,u,m)=>{if(!o||!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,o,s,n){if(n>=this.displayLimit||t<0)return n;t>=this.levels.length&&(t=this.levels.length-1);const r=this._getCellContext(t,e,i,o);return r?(n=this._processCellSkipPoints(r,n),n>=this.displayLimit?(this._debugDrawCell(r),n):(n=this._processCellGroups(r,s,n),this._debugDrawCell(r),n)):n}_getCellContext(t,e,i,o){const n=this.levels[t].level,r=this.gridLayers.get(n);if(!r)return null;const l=`${e}_${i}`,c=r.get(l);if(!c)return null;const d=this.tilingScheme.tileXYToRectangle(e,i,n),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:n,lonIdx:e,latIdx:i,key:l,cell:c,rect:d,west:u,south:m,east:g,north:p,centerLon:f,centerLat:w,viewTileLevel:o}}_processCellSkipPoints(t,e){var n,r,l,c;const{cell:i,viewTileLevel:o}=t,s=o;for(const d of i.skipPoints)if(((n=d.data)==null?void 0:n.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:o,lonIdx:s,latIdx:n,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),o===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-${o}-${s}-${n}-${I}`:`cluster-${o}-${s}-${n}`;this.labelPool.add({id:G,billboard:((E=(L=_[0])==null?void 0:L.data)==null?void 0:E.billboard)||[],count:_.length,gridKey:`${s}_${n}`,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:o,east:s,north:n,lonIdx:r,latIdx:l}=t,c=this.levels[e].level;this._drawDebugGrid(i,o,s,n,`L:${c} X:${r} Y:${l}`)}refresh(){this._update()}_drawDebugGrid(t,e,i,o,s){const n=this.Cesium.Rectangle.fromDegrees(t,e,i,o),r=this.Cesium.Cartesian3.fromDegreesArray([t,e,i,e,i,o,t,o,t,e]),l=this.viewer.entities.add({rectangle:{coordinates:n,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 o=this.listenerMap.get(t);return o||(o=new Map,this.listenerMap.set(t,o)),o.has(e.name)?i?(console.warn(`[MarkerEventBus] Overwriting listener "${e.name}" for event "${t}".`),o.set(e.name,e),!0):(console.warn(`[MarkerEventBus] Listener "${e.name}" for event "${t}" already exists. Use overwrite=true to replace it.`),!1):(o.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 o=this.listenerMap.get(t);if(o)for(const[s,n]of o.entries()){try{n.fn(e,i)}catch(r){console.error(`Error in listener "${s}" for event "${t}":`,r)}n.once&&o.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",o,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=o||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:o,lat:s,height:n=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(o),m.el.dataset.lat=String(s),m.el.dataset.height=String(n),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 o=this.themes[i.theme];if(!o){console.warn(`Theme "${i.theme}" not registered.`);return}try{o.createElement(i.el,{id:t,theme:i.theme,data:e},o)}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 o=this.themes[i.theme];if(!o){console.warn(`Theme "${i.theme}" not registered`);return}i.unload=o.createElement(i.el,{id:e,theme:i.theme,data:i.data},o)||{}}catch(o){console.error(`Error creating label element for theme "${i.theme}":`,o);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,o=this.viewer.scene,s=[i.Cartographic.fromDegrees(t,e)];let n;try{n=await o.clampToHeightMostDetailed(s)}catch{console.warn("clampToHeightMostDetailed failed, fallback to ellipsoid height.")}let r=0;n&&n[0]&&n[0].height!=null?r=n[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 o=parseFloat(i.el.dataset.lon),s=parseFloat(i.el.dataset.lat),n=parseFloat(i.el.dataset.height||"0");if(!this._isValidCoordinate(o,s)){i.el.style.display="none";continue}const r=this.Cesium.Cartesian3.fromDegrees(o,s,n),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,o=Math.max(0,e-i);if(o===0){this.runOcclusionCheckNow();return}this._occlusionTimer===null&&(this._occlusionTimer=window.setTimeout(()=>{this._occlusionTimer=null,this.runOcclusionCheckNow()},o))}_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,o,s,n){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:o,lat:s,height:n,occluded:!0,reason:"runtime-missing"}),!0;if(!r.pickPositionSupported||!i)return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:o,lat:s,height:n,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:o,lat:s,height:n,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:o,lat:s,height:n,occluded:w,reason:"distance-compare",epsilon:g,labelDistance:p,pickedDistance:f}),w}catch{return this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:o,lat:s,height:n,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),o=parseFloat(e.el.dataset.lat),s=parseFloat(e.el.dataset.height||"0");if(!this._isValidCoordinate(i,o)){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:i,lat:o,height:s,occluded:!1,reason:"invalid-coordinate"});continue}const n=this.Cesium.Cartesian3.fromDegrees(i,o,s),r=this.toWindowCoordinates(n);if(!this.Cesium.defined(r)){this.occludedIds.delete(t),this._pushOcclusionLog({timestamp:Date.now(),id:t,lon:i,lat:o,height:s,occluded:!1,reason:"screen-position-undefined"});continue}this._computeLabelOccluded(t,n,r,i,o,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(o=>{var m,g;const s=i.scene.pickPosition(o.position);if(!s)return;const n=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(n.longitude),l=e.Math.toDegrees(n.latitude),c=n.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",[]);h(this,"options",null);h(this,"keydownHandler",null);this.Cesium=t,this.viewer=e}getPickPosition(t){var s,n,r,l;const{viewer:e}=this,i=e==null?void 0:e.scene;if(!i||!t)return null;let o=null;try{i.pickPositionSupported&&(o=i.pickPosition(t))}catch(c){console.warn("[LineDrawer] pickPosition failed:",c)}if(!o){const c=(n=(s=e.camera)==null?void 0:s.getPickRay)==null?void 0:n.call(s,t);c&&(o=((l=(r=i.globe)==null?void 0:r.pick)==null?void 0:l.call(r,c,i))||null)}return o}syncEntity(){if(this.entity){if(this.positions.length===0){this.viewer.entities.remove(this.entity),this.entity=null;return}this.entity.polyline.positions=this.positions.slice()}}undoLastPoint(){if(this.positions.length===0)return;this.positions.pop();const t=this.tempPoints.pop();t&&this.viewer.entities.remove(t),this.syncEntity()}finishDrawing(t=!1){var s,n,r;const{Cesium:e}=this;if(t&&this.positions.length>0){this.positions.length=this.positions.length-1;const l=this.tempPoints.pop();l&&this.viewer.entities.remove(l)}if(this.syncEntity(),this.stopDrawing(),(s=this.tooltip)==null||s.hide(),this.tooltip=null,this.positions.length<2)return;const i=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}}),o={entity:this.entity,positions:this.positions,lnglats:i,clear:()=>{this.clear()}};(r=(n=this.options)==null?void 0:n.onComplete)==null||r.call(n,o)}bindKeyboardEvents(){this.unbindKeyboardEvents(),this.keydownHandler=t=>{t.key==="Escape"&&(t.preventDefault(),this.finishDrawing(!1))},document.addEventListener("keydown",this.keydownHandler)}unbindKeyboardEvents(){this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}startDrawing(t){const{Cesium:e,viewer:i}=this;this.options=t,this.positions=[],this.tempPoints=[],this.entity=null,this.tooltip=new _e,this.tooltip.show("单击左键添加点,右键撤销,双击左键或 Esc 结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.bindKeyboardEvents(),this.handler.setInputAction(o=>{var r,l;const s=this.getPickPosition(o.position);if(!s)return;this.positions.push(s);const n=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(n),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(()=>{this.undoLastPoint()},e.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(()=>{this.finishDrawing(!0)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;this.unbindKeyboardEvents(),(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.options=null,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(o=>{var n;const s=i.scene.pickPosition(o.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()}};(n=t.onComplete)==null||n.call(t,u)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(o=>{if(!this.startPoint)return;const s=i.scene.pickPosition(o.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],o=this.viewer.camera.getPickRay(e.endPosition),s=this.viewer.scene.globe.pick(o,this.viewer.scene);s&&this.drawPreviewCircle(i,s,t)},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}drawPreviewCircle(t,e,i){const o=this.Cesium.Cartesian3.distance(t,e);if(this.entity)Math.abs(this.currentRadius-o)>.5&&(this.currentRadius=o);else{this.currentRadius=o;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,o=this.Cesium.Cartesian3.distance(e,i),s=this.Cesium.Cartographic.fromCartesian(e),n={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(o),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:n,radius:o,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",[]);h(this,"options",null);h(this,"keydownHandler",null);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(o=>o.show);e.forEach(o=>{o.show=!1});try{return t()}finally{e.forEach((o,s)=>{o.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 o=null;const s=i.pick(t),n=this.isHelperPick(s);try{i.pickPositionSupported&&(o=n?this.withHiddenHelpers(()=>i.pickPosition(t)):i.pickPosition(t))}catch(u){console.warn("[PolygonDrawer] pickPosition failed:",u)}if(!o){const u=(l=(r=e.camera)==null?void 0:r.getPickRay)==null?void 0:l.call(r,t);u&&(o=((d=(c=i.globe)==null?void 0:c.pick)==null?void 0:d.call(c,u,i))||null)}return o}syncEntity(){this.entity&&this.positions.length===0&&(this.viewer.entities.remove(this.entity),this.entity=null)}undoLastPoint(){if(this.positions.length===0)return;this.positions.pop(),this.lnglats.pop();const t=this.tempPoints.pop();t&&this.viewer.entities.remove(t),this.syncEntity()}finishDrawing(t=!1){var i,o,s;if(t&&this.positions.length>0){this.positions.length=this.positions.length-1,this.lnglats.length=this.lnglats.length-1;const n=this.tempPoints.pop();n&&this.viewer.entities.remove(n)}if(this.syncEntity(),this.stopDrawing(),(i=this.tooltip)==null||i.hide(),this.tooltip=null,this.positions.length<3)return;const e={entity:this.entity,positions:this.positions,lnglats:this.lnglats.slice(),clear:()=>{this.clear()}};(s=(o=this.options)==null?void 0:o.onComplete)==null||s.call(o,e)}bindKeyboardEvents(){this.unbindKeyboardEvents(),this.keydownHandler=t=>{t.key==="Escape"&&(t.preventDefault(),this.finishDrawing(!1))},document.addEventListener("keydown",this.keydownHandler)}unbindKeyboardEvents(){this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}startDrawing(t){const{Cesium:e,viewer:i}=this;this.options=t,this.positions=[],this.lnglats=[],this.tempPoints=[],this.entity=null,this.tooltip=new _e,this.tooltip.show("单击左键添加点,右键撤销,双击左键或 Esc 结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.bindKeyboardEvents(),this.handler.setInputAction(o=>{const s=this.getPickPosition(o.position);if(!s)return;this.positions.push(s);const n=e.Cartographic.fromCartesian(s);this.lnglats.push({lng:e.Math.toDegrees(n.longitude),lat:e.Math.toDegrees(n.latitude),height:Number.isFinite(n.height)?n.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(()=>{this.undoLastPoint()},e.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(()=>{this.finishDrawing(!0)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;this.unbindKeyboardEvents(),(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.options=null,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,nt=Object.prototype,Kt=nt.hasOwnProperty,qt=nt.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 o=qt.call(a);return i&&(t?a[be]=e:delete a[be]),o}var Jt=Object.prototype,Zt=Jt.toString;function Qt(a){return Zt.call(a)}var ei="[object Null]",ti="[object Undefined]",ot=me?me.toStringTag:void 0;function Pe(a){return a==null?a===void 0?ti:ei:ot&&ot in Object(a)?Xt(a):Qt(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]",ni="[object GeneratorFunction]",oi="[object Proxy]";function rt(a){if(!De(a))return!1;var t=Pe(a);return t==si||t==ni||t==ii||t==oi}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]",Zi="[object DataView]",Qi="[object Float32Array]",es="[object Float64Array]",ts="[object Int8Array]",is="[object Int16Array]",ss="[object Int32Array]",ns="[object Uint8Array]",os="[object Uint8ClampedArray]",rs="[object Uint16Array]",as="[object Uint32Array]",z={};z[Qi]=z[es]=z[ts]=z[is]=z[ss]=z[ns]=z[os]=z[rs]=z[as]=!0,z[Hi]=z[zi]=z[Ji]=z[Ni]=z[Zi]=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),o=!e&&!i&&wt(a),s=!e&&!i&&!o&&cs(a),n=e||i||o||s,r=n?Di(a.length,String):[],l=r.length;for(var c in a)ps.call(a,c)&&!(n&&(c=="length"||o&&(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 oe(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])}}oe.prototype.clear=Ds,oe.prototype.delete=$s,oe.prototype.get=Os,oe.prototype.has=ks,oe.prototype.set=Fs;var Ie=de(se,"Map");function Rs(){this.size=0,this.__data__={hash:new pe,map:new(Ie||oe),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,o=a.length;++e<i;)a[o+e]=t[e];return a}var Ys=bt(Object.getPrototypeOf,Object);function Vs(){this.__data__=new oe,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 oe){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 oe(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 Zs(a,t){return a.slice()}function Qs(a,t){for(var e=-1,i=a==null?0:a.length,o=0,s=[];++e<i;){var n=a[e];t(n,e,a)&&(s[o++]=n)}return s}function en(){return[]}var tn=Object.prototype,sn=tn.propertyIsEnumerable,Mt=Object.getOwnPropertySymbols,nn=Mt?function(a){return a==null?[]:(a=Object(a),Qs(Mt(a),function(t){return sn.call(a,t)}))}:en;function on(a,t,e){var i=t(a);return xe(a)?i:js(i,e(a))}function rn(a){return on(a,ws,nn)}var Ne=de(se,"DataView"),Ge=de(se,"Promise"),Be=de(se,"Set"),It="[object Map]",an="[object Object]",Tt="[object Promise]",_t="[object Set]",xt="[object WeakMap]",Dt="[object DataView]",ln=ce(Ne),hn=ce(Ie),cn=ce(Ge),dn=ce(Be),pn=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==an?a.constructor:void 0,i=e?ce(e):"";if(i)switch(i){case ln:return Dt;case hn:return It;case cn:return Tt;case dn:return _t;case pn:return xt}return t});var un=Object.prototype,mn=un.hasOwnProperty;function gn(a){var t=a.length,e=new a.constructor(t);return t&&typeof a[0]=="string"&&mn.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 fn(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.byteLength)}var yn=/\w*$/;function wn(a){var t=new a.constructor(a.source,yn.exec(a));return t.lastIndex=a.lastIndex,t}var At=me?me.prototype:void 0,$t=At?At.valueOf:void 0;function vn(a){return $t?Object($t.call(a)):{}}function Cn(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.length)}var bn="[object Boolean]",Pn="[object Date]",Ln="[object Map]",En="[object Number]",Mn="[object RegExp]",In="[object Set]",Tn="[object String]",_n="[object Symbol]",xn="[object ArrayBuffer]",Dn="[object DataView]",Sn="[object Float32Array]",An="[object Float64Array]",$n="[object Int8Array]",On="[object Int16Array]",kn="[object Int32Array]",Fn="[object Uint8Array]",Rn="[object Uint8ClampedArray]",Hn="[object Uint16Array]",zn="[object Uint32Array]";function Nn(a,t,e){var i=a.constructor;switch(t){case xn:return je(a);case bn:case Pn:return new i(+a);case Dn:return fn(a);case Sn:case An:case $n:case On:case kn:case Fn:case Rn:case Hn:case zn:return Cn(a);case Ln:return new i;case En:case Tn:return new i(a);case Mn:return wn(a);case In:return new i;case _n:return vn(a)}}function Gn(a){return typeof a.constructor=="function"&&!pt(a)?wi(Ys(a)):{}}var Bn="[object Map]";function jn(a){return Le(a)&&re(a)==Bn}var Ot=ge&&ge.isMap,Yn=Ot?He(Ot):jn,Vn="[object Set]";function Wn(a){return Le(a)&&re(a)==Vn}var kt=ge&&ge.isSet,Un=kt?He(kt):Wn,Ft="[object Arguments]",Kn="[object Array]",qn="[object Boolean]",Xn="[object Date]",Jn="[object Error]",Rt="[object Function]",Zn="[object GeneratorFunction]",Qn="[object Map]",eo="[object Number]",Ht="[object Object]",to="[object RegExp]",io="[object Set]",so="[object String]",no="[object Symbol]",oo="[object WeakMap]",ro="[object ArrayBuffer]",ao="[object DataView]",lo="[object Float32Array]",ho="[object Float64Array]",co="[object Int8Array]",po="[object Int16Array]",uo="[object Int32Array]",mo="[object Uint8Array]",go="[object Uint8ClampedArray]",fo="[object Uint16Array]",yo="[object Uint32Array]",H={};H[Ft]=H[Kn]=H[ro]=H[ao]=H[qn]=H[Xn]=H[lo]=H[ho]=H[co]=H[po]=H[uo]=H[Qn]=H[eo]=H[Ht]=H[to]=H[io]=H[so]=H[no]=H[mo]=H[go]=H[fo]=H[yo]=!0,H[Jn]=H[Rt]=H[oo]=!1;function $e(a,t,e,i,o,s){var n;if(n!==void 0)return n;if(!De(a))return a;var r=xe(a);if(r)n=gn(a);else{var l=re(a),c=l==Rt||l==Zn;if(wt(a))return Zs(a);if(l==Ht||l==Ft||c&&!o)n=c?{}:Gn(a);else{if(!H[l])return o?a:{};n=Nn(a,l)}}s||(s=new ye);var d=s.get(a);if(d)return d;s.set(a,n),Un(a)?a.forEach(function(g){n.add($e(g,t,e,g,a,s))}):Yn(a)&&a.forEach(function(g,p){n.set(p,$e(g,t,e,p,a,s))});var u=rn,m=r?void 0:u(a);return vi(m||a,function(g,p){m&&(p=g,g=a[p]),Ii(n,p,$e(g,t,e,p,a,s))}),n}var wo=1,vo=4;function Oe(a){return $e(a,wo|vo)}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 Co{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(o=>{i.scene.primitives.remove(o)}),t.forEach(o=>{this.primitives.has(o.id)||this.add(o,e)})}get(t){return this.primitives.get(t)}add(t,e=!0){var u,m,g;const i=this.viewer,o=this.Cesium,s=o.Math.toRadians(((u=t.headingPitchRoll)==null?void 0:u.heading)||0),n=o.Math.toRadians(((m=t.headingPitchRoll)==null?void 0:m.pitch)||0),r=o.Math.toRadians(((g=t.headingPitchRoll)==null?void 0:g.roll)||0),l=new o.HeadingPitchRoll(s,n,r),c=o.Transforms.headingPitchRollToFixedFrame(t.position,l,i.scene.globe.ellipsoid,o.Transforms.eastNorthUpToFixedFrame,new o.Matrix4);let d=i.scene.primitives.add(o.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 o=this.primitives.get(t);const s=o.boundingSphere,n=i.Matrix4.multiplyByPoint(o.modelMatrix,s.center,new i.Cartesian3),r=new i.BoundingSphere(n,s.radius);e.camera.flyToBoundingSphere(r,{duration:1.5,offset:new i.HeadingPitchRange(0,-.5,s.radius*2)})}removeById(t){var o;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),(!((o=this.rotationRing)!=null&&o._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,o=e.latitude-t.latitude;return Math.atan2(o,i)}getModelHeadingPitchRoll(t){const e=this.Cesium,i=this.viewer,o=e.Transforms.eastNorthUpToFixedFrame(e.Matrix4.getTranslation(t,new e.Cartesian3),i.scene.globe.ellipsoid,new e.Matrix4),s=e.Matrix4.multiply(e.Matrix4.inverse(o,new e.Matrix4),t,new e.Matrix4),n=e.Matrix4.getRotation(s,new e.Matrix3),r=e.Quaternion.fromRotationMatrix(n);return e.HeadingPitchRoll.fromQuaternion(r)}addEventListener(t,e,i){let o={f:e,options:i};return this.eventListener.get(t)?(this.eventListener.get(t)||[]).push(o):this.eventListener.set(t,[o]),o}removeEventListener(t,e){let i=this.eventListener.get(t);if(!i)return console.error("key不存在");let o=i.findIndex(s=>s==e);o>=0?i.splice(o,1):console.error("instantiation不存在")}runEventListener(t,e){let i=this.eventListener.get(t);return i?(i.forEach(o=>{typeof o.f=="function"&&o.f(e)}),!0):!1}initEditBox(t){const e=this.Cesium,i=this.viewer,o=i.scene;let s=null,n=null,r=null,l=null,c=null;const d=()=>{s=null,n=null,r=null,c=null,l=null,this.setEditMode(""),this.unlockCamera()},u=(m,g)=>{if(s=this.primitives.get(m),s){n=e.Matrix4.clone(s.modelMatrix);const p=e.Matrix4.getTranslation(n,new e.Cartesian3);r=this.toCartographic(p),c=g.position;const f=o.globe.pick(i.camera.getPickRay(g.position),o);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=o.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=o.globe.pick(i.camera.getPickRay(m.endPosition),o),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,n,w)}else this.editMode==="move"?this.moveModel(s,n,m):this.editMode==="moveHeight"&&this.moveModelHeight(s,n,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 o=[];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;o.push(new e.Cartesian3(d,u,0))}const s=new e.PolylineGeometry({positions:o,width:Math.max(t.boundingSphere.radius*.05,1)}),n=new e.GeometryInstance({id:`rotationRing_${t.id}`,geometry:s,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.RED)}});this.rotationRing=new e.Primitive({geometryInstances:n,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,n=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:n,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 o=e.Color.GREEN,s=Math.max(t.boundingSphere.radius*.025,1),n=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:n}));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:o}),translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:o.withAlpha(.3)}),translucent:!0}),cull:!1}),i.scene.primitives.add(this.heightArrow)}translate(t,e){let i=this.Cesium;const o=new i.Cartesian3;xe(e)?(o.x=e[0],o.y=e[1],o.z=e[2]):i.Cartesian3.clone(e,o);for(let s=0;s<t.attributes.position.values.length;s+=3)t.attributes.position.values[s]+=o.x,t.attributes.position.values[s+1]+=o.y,t.attributes.position.values[s+2]+=o.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 o=this.Cesium,s=this.viewer,n=s.scene,r=n.globe.pick(s.camera.getPickRay(i.endPosition),n);if(r){const l=o.Matrix4.getTranslation(e,new o.Cartesian3),c=o.Cartographic.fromCartesian(l),d=o.Cartographic.fromCartesian(r),u=new o.Cartographic(d.longitude,d.latitude,c.height),m=o.Cartographic.toCartesian(u),g=o.Matrix4.getRotation(e,new o.Matrix3),p=o.Matrix4.fromRotationTranslation(g,m);t.modelMatrix=p,this.updatedTool(p);let f=new o.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,o){const s=this.Cesium,n=this.viewer,r=n.scene,l=o.y-i.endPosition.y;if(r.globe.pick(n.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(n.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 o=this.Cesium,s=this.viewer,n=this.getModelHeadingPitchRoll(e),r=n.heading+i,l=new o.HeadingPitchRoll(r,n.pitch,n.roll),c=o.Transforms.headingPitchRollToFixedFrame(o.Matrix4.getTranslation(t.modelMatrix,new o.Cartesian3),l,s.scene.globe.ellipsoid,o.Transforms.eastNorthUpToFixedFrame,new o.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:o.Math.toDegrees(r),pitch:o.Math.toDegrees(n.pitch),roll:o.Math.toDegrees(n.roll)}})}cleanup(){this.handler&&(this.handler.destroy(),this.handler=null)}}function bo(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,n){return a.defined(n)||(n={}),n.color=a.Property.getValueOrClonedDefault(this._color,s,a.Color.WHITE,n.color),n.image=t.image,n},i.prototype.equals=function(s){return this===s||s instanceof i&&a.Property.equals(this._color,s._color)};const o=function(s){return`
1
+ (function(A,te){typeof exports=="object"&&typeof module<"u"?te(exports):typeof define=="function"&&define.amd?define(["exports"],te):(A=typeof globalThis<"u"?globalThis:A||self,te(A.CesiumCore={}))})(this,(function(A){"use strict";var Ro=Object.defineProperty;var zo=(A,te,V)=>te in A?Ro(A,te,{enumerable:!0,configurable:!0,writable:!0,value:V}):A[te]=V;var l=(A,te,V)=>zo(A,typeof te!="symbol"?te+"":te,V);class te{constructor(t,e,i){l(this,"Cesium");l(this,"viewer");l(this,"labelPool");l(this,"threshold");l(this,"displayLimit");l(this,"maxLevel");l(this,"debugCurrentGrids");l(this,"levels");l(this,"points",[]);l(this,"gridLayers",new Map);l(this,"debugGrids",[]);l(this,"_updateFn");l(this,"clusterTheme");l(this,"pointTheme");l(this,"centralPointMode");l(this,"minGlobalPointCount");l(this,"groupByTheme");l(this,"tilingScheme");l(this,"terrainLevelOffset");l(this,"debugTileCoordLayer",null);l(this,"levelIndexByTileLevel",new Map);l(this,"_lastTileProvider",null);l(this,"_updateTimer",null);l(this,"_updateDelay",100);l(this,"_tilesRetryCount",0);l(this,"_tilesRetryMax",100);l(this,"_cameraDirty",!1);l(this,"_tileLoadListener",null);l(this,"_cameraChangedHandler",null);l(this,"defaultMinLevel",0);l(this,"defaultMaxLevel",28);l(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=h=>{h===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,h;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?(h=i.data)==null?void 0:h.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,h]of o.groups.entries()){const c=h.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 h of this.levels){const c=h.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 h=Math.abs(this.levels[r].level-t);h<o&&(o=h,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,h=r&&s.camera.computeViewRectangle(r),c=(d,u,m)=>{if(!n||!h)return!0;const g=this.tilingScheme.tileXYToRectangle(d,u,m);return!(!g||g.east<=h.west||g.west>=h.east||g.north<=h.south||g.south>=h.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,S=Math.floor(w/$),O=Math.floor(y/$),_=`${f}_${S}_${O}`;if(i.has(_))continue;i.add(_),e(p,S,O,m)}else{const S=1<<Math.min(-T,this.maxRefineLevels),O=w*S,_=y*S;for(let k=0;k<S;k++)for(let F=0;F<S;F++){const G=O+k,B=_+F;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),D=Math.floor((P- -90)/C),x=Math.floor((L- -90)/C);for(let T=E;T<=I;T++)for(let $=D;$<=x;$++){if(!c(T,$,f))continue;const S=`${f}_${T}_${$}`;i.has(S)||(i.add(S),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 h=`${e}_${i}`,c=r.get(h);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:h,cell:c,rect:d,west:u,south:m,east:g,north:p,centerLon:f,centerLat:w,viewTileLevel:n}}_processCellSkipPoints(t,e){var o,r,h,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=(h=(r=d.data)==null?void 0:r.billboard)==null?void 0:h[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:h,centerLat:c,viewTileLevel:d}=t,u=d;for(const[I,D]of r.groups){const x=D.filter(_=>{var k;return((k=_.data)==null?void 0:k.show)!==!1});if(x.length===0)continue;let T=h,$=c,S=((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,S=((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 F=((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:S,theme:F}),i++}}return i}_debugDrawCell(t){if(!this.debugCurrentGrids)return;const{levelIdx:e,west:i,south:n,east:s,north:o,lonIdx:r,latIdx:h}=t,c=this.levels[e].level;this._drawDebugGrid(i,n,s,o,`L:${c} X:${r} Y:${h}`)}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]),h=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(h)}_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 nt{constructor(){l(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 ot={[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){l(this,"viewer");l(this,"Cesium");l(this,"container");l(this,"labels",new Map);l(this,"activeIds",new Set);l(this,"occludedIds",new Set);l(this,"_updateFn");l(this,"_cameraChangedFn");l(this,"themes",{});l(this,"occlusionCheckLogs",[]);l(this,"occlusionLogEnabled",!1);l(this,"occlusionLogMax",1e4);l(this,"occlusionOptions",{enabled:!1,throttleMs:120,distanceEpsilon:1});l(this,"_occlusionTimer",null);l(this,"_lastOcclusionAt",0);l(this,"_occlusionChecking",!1);l(this,"_occlusionPending",!1);l(this,"eventBus");l(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 nt,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:h=!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||h)&&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(ot)){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||h){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=h?"block":"none",h&&this.activeIds.add(i),h?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 h=i.Cartesian3.fromDegrees(t,e,r);return this.toWindowCoordinates(h)}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),h=this.toWindowCoordinates(r);if(this.Cesium.defined(h)){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=`${h.x}px`,i.el.style.top=`${h.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,h=(u=this.viewer)==null?void 0:u.camera,c=this.Cesium;if(!r||!h||!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||!h.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(h.positionWC,e),f=c.Cartesian3.distance(h.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 ce{constructor(){l(this,"tooltipEl");l(this,"visible",!1);l(this,"offsetX",10);l(this,"offsetY",-20);l(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 Yt{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"entity",null);l(this,"tooltip",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.tooltip=new ce,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),h=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:h,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 Vt{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"positions",[]);l(this,"entity",null);l(this,"tooltip",null);l(this,"tempPoints",[]);l(this,"options",null);l(this,"keydownHandler",null);this.Cesium=t,this.viewer=e}getPickPosition(t){var s,o,r,h;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=((h=(r=i.globe)==null?void 0:r.pick)==null?void 0:h.call(r,c,i))||null)}return n}syncEntity(){if(this.entity){if(this.positions.length===0){this.viewer.entities.remove(this.entity),this.entity=null;return}this.entity.polyline.positions=this.positions.slice()}}undoLastPoint(){if(this.positions.length===0)return;this.positions.pop();const t=this.tempPoints.pop();t&&this.viewer.entities.remove(t),this.syncEntity()}finishDrawing(t=!1){var s,o,r;const{Cesium:e}=this;if(t&&this.positions.length>0){this.positions.length=this.positions.length-1;const h=this.tempPoints.pop();h&&this.viewer.entities.remove(h)}if(this.syncEntity(),this.stopDrawing(),(s=this.tooltip)==null||s.hide(),this.tooltip=null,this.positions.length<2)return;const i=this.positions.map(h=>{const c=e.Cartographic.fromCartesian(h);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),n={entity:this.entity,positions:this.positions,lnglats:i,clear:()=>{this.clear()}};(r=(o=this.options)==null?void 0:o.onComplete)==null||r.call(o,n)}bindKeyboardEvents(){this.unbindKeyboardEvents(),this.keydownHandler=t=>{t.key==="Escape"&&(t.preventDefault(),this.finishDrawing(!1))},document.addEventListener("keydown",this.keydownHandler)}unbindKeyboardEvents(){this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}startDrawing(t){const{Cesium:e,viewer:i}=this;this.options=t,this.positions=[],this.tempPoints=[],this.entity=null,this.tooltip=new ce,this.tooltip.show("单击左键添加点,右键撤销,双击左键或 Esc 结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.bindKeyboardEvents(),this.handler.setInputAction(n=>{var r,h;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:((h=(r=t.color)==null?void 0:r.withAlpha)==null?void 0:h.call(r,.5))||e.Color.YELLOW.withAlpha(.5)}})},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{this.undoLastPoint()},e.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(()=>{this.finishDrawing(!0)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;this.unbindKeyboardEvents(),(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.options=null,this.stopDrawing()}}class Wt{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"startPoint",null);l(this,"endPoint",null);l(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),h=e.Cartographic.fromCartesian(this.endPoint),c=Math.min(r.longitude,h.longitude),d=Math.max(r.longitude,h.longitude),u=Math.min(r.latitude,h.latitude),m=Math.max(r.latitude,h.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),h=e.Cartographic.fromCartesian(this.endPoint),c={lng:e.Math.toDegrees(Math.min(r.longitude,h.longitude)),lat:e.Math.toDegrees(Math.min(r.latitude,h.latitude)),height:0},d={lng:e.Math.toDegrees(Math.max(r.longitude,h.longitude)),lat:e.Math.toDegrees(Math.max(r.latitude,h.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 Ut{constructor(t,e){l(this,"viewer");l(this,"Cesium");l(this,"handler",null);l(this,"entity",null);l(this,"positions",[]);l(this,"_isDrawing",!1);l(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,h=[],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);h.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:h,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 Kt{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"positions",[]);l(this,"lnglats",[]);l(this,"entity",null);l(this,"tooltip",null);l(this,"tempPoints",[]);l(this,"options",null);l(this,"keydownHandler",null);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,h,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=(h=(r=e.camera)==null?void 0:r.getPickRay)==null?void 0:h.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}syncEntity(){this.entity&&this.positions.length===0&&(this.viewer.entities.remove(this.entity),this.entity=null)}undoLastPoint(){if(this.positions.length===0)return;this.positions.pop(),this.lnglats.pop();const t=this.tempPoints.pop();t&&this.viewer.entities.remove(t),this.syncEntity()}finishDrawing(t=!1){var i,n,s;if(t&&this.positions.length>0){this.positions.length=this.positions.length-1,this.lnglats.length=this.lnglats.length-1;const o=this.tempPoints.pop();o&&this.viewer.entities.remove(o)}if(this.syncEntity(),this.stopDrawing(),(i=this.tooltip)==null||i.hide(),this.tooltip=null,this.positions.length<3)return;const e={entity:this.entity,positions:this.positions,lnglats:this.lnglats.slice(),clear:()=>{this.clear()}};(s=(n=this.options)==null?void 0:n.onComplete)==null||s.call(n,e)}bindKeyboardEvents(){this.unbindKeyboardEvents(),this.keydownHandler=t=>{t.key==="Escape"&&(t.preventDefault(),this.finishDrawing(!1))},document.addEventListener("keydown",this.keydownHandler)}unbindKeyboardEvents(){this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}startDrawing(t){const{Cesium:e,viewer:i}=this;this.options=t,this.positions=[],this.lnglats=[],this.tempPoints=[],this.entity=null,this.tooltip=new ce,this.tooltip.show("单击左键添加点,右键撤销,双击左键或 Esc 结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.bindKeyboardEvents(),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(()=>{this.undoLastPoint()},e.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(()=>{this.finishDrawing(!0)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;this.unbindKeyboardEvents(),(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.options=null,this.stopDrawing()}}class qt{constructor(t,e){l(this,"viewer");l(this,"Cesium");l(this,"activeDrawer",null);this.viewer=e,this.Cesium=t}draw(t,e){var i;switch(this.clear(),t){case"point":this.activeDrawer=new Yt(this.Cesium,this.viewer);break;case"line":this.activeDrawer=new Vt(this.Cesium,this.viewer);break;case"rectangle":this.activeDrawer=new Wt(this.Cesium,this.viewer);break;case"circle":this.activeDrawer=new Ut(this.Cesium,this.viewer);break;case"polygon":this.activeDrawer=new Kt(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 rt=typeof global=="object"&&global&&global.Object===Object&&global,Xt=typeof self=="object"&&self&&self.Object===Object&&self,se=rt||Xt||Function("return this")(),ge=se.Symbol,at=Object.prototype,Jt=at.hasOwnProperty,Zt=at.toString,Pe=ge?ge.toStringTag:void 0;function Qt(a){var t=Jt.call(a,Pe),e=a[Pe];try{a[Pe]=void 0;var i=!0}catch{}var n=Zt.call(a);return i&&(t?a[Pe]=e:delete a[Pe]),n}var ei=Object.prototype,ti=ei.toString;function ii(a){return ti.call(a)}var si="[object Null]",ni="[object Undefined]",lt=ge?ge.toStringTag:void 0;function Le(a){return a==null?a===void 0?ni:si:lt&&lt in Object(a)?Qt(a):ii(a)}function Ee(a){return a!=null&&typeof a=="object"}var Ae=Array.isArray;function $e(a){var t=typeof a;return a!=null&&(t=="object"||t=="function")}var oi="[object AsyncFunction]",ri="[object Function]",ai="[object GeneratorFunction]",li="[object Proxy]";function ht(a){if(!$e(a))return!1;var t=Le(a);return t==ri||t==ai||t==oi||t==li}var Be=se["__core-js_shared__"],ct=(function(){var a=/[^.]+$/.exec(Be&&Be.keys&&Be.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""})();function hi(a){return!!ct&&ct in a}var ci=Function.prototype,di=ci.toString;function de(a){if(a!=null){try{return di.call(a)}catch{}try{return a+""}catch{}}return""}var pi=/[\\^$.*+?()[\]{}|]/g,ui=/^\[object .+?Constructor\]$/,mi=Function.prototype,gi=Object.prototype,fi=mi.toString,yi=gi.hasOwnProperty,wi=RegExp("^"+fi.call(yi).replace(pi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function vi(a){if(!$e(a)||hi(a))return!1;var t=ht(a)?wi:ui;return t.test(de(a))}function Ci(a,t){return a==null?void 0:a[t]}function pe(a,t){var e=Ci(a,t);return vi(e)?e:void 0}var je=pe(se,"WeakMap"),dt=Object.create,bi=(function(){function a(){}return function(t){if(!$e(t))return{};if(dt)return dt(t);a.prototype=t;var e=new a;return a.prototype=void 0,e}})(),pt=(function(){try{var a=pe(Object,"defineProperty");return a({},"",{}),a}catch{}})();function Pi(a,t){for(var e=-1,i=a==null?0:a.length;++e<i&&t(a[e],e,a)!==!1;);return a}var Li=9007199254740991,Ei=/^(?:0|[1-9]\d*)$/;function Mi(a,t){var e=typeof a;return t=t??Li,!!t&&(e=="number"||e!="symbol"&&Ei.test(a))&&a>-1&&a%1==0&&a<t}function Ii(a,t,e){t=="__proto__"&&pt?pt(a,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):a[t]=e}function ut(a,t){return a===t||a!==a&&t!==t}var Ti=Object.prototype,_i=Ti.hasOwnProperty;function xi(a,t,e){var i=a[t];(!(_i.call(a,t)&&ut(i,e))||e===void 0&&!(t in a))&&Ii(a,t,e)}var Di=9007199254740991;function mt(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=Di}function Si(a){return a!=null&&mt(a.length)&&!ht(a)}var Ai=Object.prototype;function gt(a){var t=a&&a.constructor,e=typeof t=="function"&&t.prototype||Ai;return a===e}function $i(a,t){for(var e=-1,i=Array(a);++e<a;)i[e]=t(e);return i}var ki="[object Arguments]";function ft(a){return Ee(a)&&Le(a)==ki}var yt=Object.prototype,Oi=yt.hasOwnProperty,Hi=yt.propertyIsEnumerable,Fi=ft((function(){return arguments})())?ft:function(a){return Ee(a)&&Oi.call(a,"callee")&&!Hi.call(a,"callee")};function Ri(){return!1}var wt=typeof A=="object"&&A&&!A.nodeType&&A,vt=wt&&typeof module=="object"&&module&&!module.nodeType&&module,zi=vt&&vt.exports===wt,Ct=zi?se.Buffer:void 0,Ni=Ct?Ct.isBuffer:void 0,bt=Ni||Ri,Gi="[object Arguments]",Bi="[object Array]",ji="[object Boolean]",Yi="[object Date]",Vi="[object Error]",Wi="[object Function]",Ui="[object Map]",Ki="[object Number]",qi="[object Object]",Xi="[object RegExp]",Ji="[object Set]",Zi="[object String]",Qi="[object WeakMap]",es="[object ArrayBuffer]",ts="[object DataView]",is="[object Float32Array]",ss="[object Float64Array]",ns="[object Int8Array]",os="[object Int16Array]",rs="[object Int32Array]",as="[object Uint8Array]",ls="[object Uint8ClampedArray]",hs="[object Uint16Array]",cs="[object Uint32Array]",z={};z[is]=z[ss]=z[ns]=z[os]=z[rs]=z[as]=z[ls]=z[hs]=z[cs]=!0,z[Gi]=z[Bi]=z[es]=z[ji]=z[ts]=z[Yi]=z[Vi]=z[Wi]=z[Ui]=z[Ki]=z[qi]=z[Xi]=z[Ji]=z[Zi]=z[Qi]=!1;function ds(a){return Ee(a)&&mt(a.length)&&!!z[Le(a)]}function Ye(a){return function(t){return a(t)}}var Pt=typeof A=="object"&&A&&!A.nodeType&&A,Me=Pt&&typeof module=="object"&&module&&!module.nodeType&&module,ps=Me&&Me.exports===Pt,Ve=ps&&rt.process,fe=(function(){try{var a=Me&&Me.require&&Me.require("util").types;return a||Ve&&Ve.binding&&Ve.binding("util")}catch{}})(),Lt=fe&&fe.isTypedArray,us=Lt?Ye(Lt):ds,ms=Object.prototype,gs=ms.hasOwnProperty;function fs(a,t){var e=Ae(a),i=!e&&Fi(a),n=!e&&!i&&bt(a),s=!e&&!i&&!n&&us(a),o=e||i||n||s,r=o?$i(a.length,String):[],h=r.length;for(var c in a)gs.call(a,c)&&!(o&&(c=="length"||n&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Mi(c,h)))&&r.push(c);return r}function Et(a,t){return function(e){return a(t(e))}}var ys=Et(Object.keys,Object),ws=Object.prototype,vs=ws.hasOwnProperty;function Cs(a){if(!gt(a))return ys(a);var t=[];for(var e in Object(a))vs.call(a,e)&&e!="constructor"&&t.push(e);return t}function bs(a){return Si(a)?fs(a):Cs(a)}var Ie=pe(Object,"create");function Ps(){this.__data__=Ie?Ie(null):{},this.size=0}function Ls(a){var t=this.has(a)&&delete this.__data__[a];return this.size-=t?1:0,t}var Es="__lodash_hash_undefined__",Ms=Object.prototype,Is=Ms.hasOwnProperty;function Ts(a){var t=this.__data__;if(Ie){var e=t[a];return e===Es?void 0:e}return Is.call(t,a)?t[a]:void 0}var _s=Object.prototype,xs=_s.hasOwnProperty;function Ds(a){var t=this.__data__;return Ie?t[a]!==void 0:xs.call(t,a)}var Ss="__lodash_hash_undefined__";function As(a,t){var e=this.__data__;return this.size+=this.has(a)?0:1,e[a]=Ie&&t===void 0?Ss:t,this}function ue(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])}}ue.prototype.clear=Ps,ue.prototype.delete=Ls,ue.prototype.get=Ts,ue.prototype.has=Ds,ue.prototype.set=As;function $s(){this.__data__=[],this.size=0}function ke(a,t){for(var e=a.length;e--;)if(ut(a[e][0],t))return e;return-1}var ks=Array.prototype,Os=ks.splice;function Hs(a){var t=this.__data__,e=ke(t,a);if(e<0)return!1;var i=t.length-1;return e==i?t.pop():Os.call(t,e,1),--this.size,!0}function Fs(a){var t=this.__data__,e=ke(t,a);return e<0?void 0:t[e][1]}function Rs(a){return ke(this.__data__,a)>-1}function zs(a,t){var e=this.__data__,i=ke(e,a);return i<0?(++this.size,e.push([a,t])):e[i][1]=t,this}function oe(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])}}oe.prototype.clear=$s,oe.prototype.delete=Hs,oe.prototype.get=Fs,oe.prototype.has=Rs,oe.prototype.set=zs;var Te=pe(se,"Map");function Ns(){this.size=0,this.__data__={hash:new ue,map:new(Te||oe),string:new ue}}function Gs(a){var t=typeof a;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?a!=="__proto__":a===null}function Oe(a,t){var e=a.__data__;return Gs(t)?e[typeof t=="string"?"string":"hash"]:e.map}function Bs(a){var t=Oe(this,a).delete(a);return this.size-=t?1:0,t}function js(a){return Oe(this,a).get(a)}function Ys(a){return Oe(this,a).has(a)}function Vs(a,t){var e=Oe(this,a),i=e.size;return e.set(a,t),this.size+=e.size==i?0:1,this}function ye(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])}}ye.prototype.clear=Ns,ye.prototype.delete=Bs,ye.prototype.get=js,ye.prototype.has=Ys,ye.prototype.set=Vs;function Ws(a,t){for(var e=-1,i=t.length,n=a.length;++e<i;)a[n+e]=t[e];return a}var Us=Et(Object.getPrototypeOf,Object);function Ks(){this.__data__=new oe,this.size=0}function qs(a){var t=this.__data__,e=t.delete(a);return this.size=t.size,e}function Xs(a){return this.__data__.get(a)}function Js(a){return this.__data__.has(a)}var Zs=200;function Qs(a,t){var e=this.__data__;if(e instanceof oe){var i=e.__data__;if(!Te||i.length<Zs-1)return i.push([a,t]),this.size=++e.size,this;e=this.__data__=new ye(i)}return e.set(a,t),this.size=e.size,this}function we(a){var t=this.__data__=new oe(a);this.size=t.size}we.prototype.clear=Ks,we.prototype.delete=qs,we.prototype.get=Xs,we.prototype.has=Js,we.prototype.set=Qs;var Mt=typeof A=="object"&&A&&!A.nodeType&&A,It=Mt&&typeof module=="object"&&module&&!module.nodeType&&module,en=It&&It.exports===Mt,Tt=en?se.Buffer:void 0;Tt&&Tt.allocUnsafe;function tn(a,t){return a.slice()}function sn(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 nn(){return[]}var on=Object.prototype,rn=on.propertyIsEnumerable,_t=Object.getOwnPropertySymbols,an=_t?function(a){return a==null?[]:(a=Object(a),sn(_t(a),function(t){return rn.call(a,t)}))}:nn;function ln(a,t,e){var i=t(a);return Ae(a)?i:Ws(i,e(a))}function hn(a){return ln(a,bs,an)}var We=pe(se,"DataView"),Ue=pe(se,"Promise"),Ke=pe(se,"Set"),xt="[object Map]",cn="[object Object]",Dt="[object Promise]",St="[object Set]",At="[object WeakMap]",$t="[object DataView]",dn=de(We),pn=de(Te),un=de(Ue),mn=de(Ke),gn=de(je),re=Le;(We&&re(new We(new ArrayBuffer(1)))!=$t||Te&&re(new Te)!=xt||Ue&&re(Ue.resolve())!=Dt||Ke&&re(new Ke)!=St||je&&re(new je)!=At)&&(re=function(a){var t=Le(a),e=t==cn?a.constructor:void 0,i=e?de(e):"";if(i)switch(i){case dn:return $t;case pn:return xt;case un:return Dt;case mn:return St;case gn:return At}return t});var fn=Object.prototype,yn=fn.hasOwnProperty;function wn(a){var t=a.length,e=new a.constructor(t);return t&&typeof a[0]=="string"&&yn.call(a,"index")&&(e.index=a.index,e.input=a.input),e}var kt=se.Uint8Array;function qe(a){var t=new a.constructor(a.byteLength);return new kt(t).set(new kt(a)),t}function vn(a,t){var e=qe(a.buffer);return new a.constructor(e,a.byteOffset,a.byteLength)}var Cn=/\w*$/;function bn(a){var t=new a.constructor(a.source,Cn.exec(a));return t.lastIndex=a.lastIndex,t}var Ot=ge?ge.prototype:void 0,Ht=Ot?Ot.valueOf:void 0;function Pn(a){return Ht?Object(Ht.call(a)):{}}function Ln(a,t){var e=qe(a.buffer);return new a.constructor(e,a.byteOffset,a.length)}var En="[object Boolean]",Mn="[object Date]",In="[object Map]",Tn="[object Number]",_n="[object RegExp]",xn="[object Set]",Dn="[object String]",Sn="[object Symbol]",An="[object ArrayBuffer]",$n="[object DataView]",kn="[object Float32Array]",On="[object Float64Array]",Hn="[object Int8Array]",Fn="[object Int16Array]",Rn="[object Int32Array]",zn="[object Uint8Array]",Nn="[object Uint8ClampedArray]",Gn="[object Uint16Array]",Bn="[object Uint32Array]";function jn(a,t,e){var i=a.constructor;switch(t){case An:return qe(a);case En:case Mn:return new i(+a);case $n:return vn(a);case kn:case On:case Hn:case Fn:case Rn:case zn:case Nn:case Gn:case Bn:return Ln(a);case In:return new i;case Tn:case Dn:return new i(a);case _n:return bn(a);case xn:return new i;case Sn:return Pn(a)}}function Yn(a){return typeof a.constructor=="function"&&!gt(a)?bi(Us(a)):{}}var Vn="[object Map]";function Wn(a){return Ee(a)&&re(a)==Vn}var Ft=fe&&fe.isMap,Un=Ft?Ye(Ft):Wn,Kn="[object Set]";function qn(a){return Ee(a)&&re(a)==Kn}var Rt=fe&&fe.isSet,Xn=Rt?Ye(Rt):qn,zt="[object Arguments]",Jn="[object Array]",Zn="[object Boolean]",Qn="[object Date]",eo="[object Error]",Nt="[object Function]",to="[object GeneratorFunction]",io="[object Map]",so="[object Number]",Gt="[object Object]",no="[object RegExp]",oo="[object Set]",ro="[object String]",ao="[object Symbol]",lo="[object WeakMap]",ho="[object ArrayBuffer]",co="[object DataView]",po="[object Float32Array]",uo="[object Float64Array]",mo="[object Int8Array]",go="[object Int16Array]",fo="[object Int32Array]",yo="[object Uint8Array]",wo="[object Uint8ClampedArray]",vo="[object Uint16Array]",Co="[object Uint32Array]",R={};R[zt]=R[Jn]=R[ho]=R[co]=R[Zn]=R[Qn]=R[po]=R[uo]=R[mo]=R[go]=R[fo]=R[io]=R[so]=R[Gt]=R[no]=R[oo]=R[ro]=R[ao]=R[yo]=R[wo]=R[vo]=R[Co]=!0,R[eo]=R[Nt]=R[lo]=!1;function He(a,t,e,i,n,s){var o;if(o!==void 0)return o;if(!$e(a))return a;var r=Ae(a);if(r)o=wn(a);else{var h=re(a),c=h==Nt||h==to;if(bt(a))return tn(a);if(h==Gt||h==zt||c&&!n)o=c?{}:Yn(a);else{if(!R[h])return n?a:{};o=jn(a,h)}}s||(s=new we);var d=s.get(a);if(d)return d;s.set(a,o),Xn(a)?a.forEach(function(g){o.add(He(g,t,e,g,a,s))}):Un(a)&&a.forEach(function(g,p){o.set(p,He(g,t,e,p,a,s))});var u=hn,m=r?void 0:u(a);return Pi(m||a,function(g,p){m&&(p=g,g=a[p]),xi(o,p,He(g,t,e,p,a,s))}),o}var bo=1,Po=4;function Fe(a){return He(a,bo|Po)}var Bt=(a=>(a.Rotate="rotate",a.Move="move",a.Scale="scale",a.MoveHeight="moveHeight",a.Empty="",a))(Bt||{}),jt=(a=>(a.Scale="addScale",a.Rotate="rotate",a.Translation="translation",a.Remove="removeById",a.Add="add",a))(jt||{});class Lo{constructor(t){l(this,"primitives",new Map);l(this,"eventListener",new Map);l(this,"Cesium");l(this,"viewer");l(this,"handler");l(this,"rotationRing");l(this,"translationSquare");l(this,"heightArrow");l(this,"editMode","");l(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),h=new n.HeadingPitchRoll(s,o,r),c=n.Transforms.headingPitchRollToFixedFrame(t.position,h,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,h=null,c=null;const d=()=>{s=null,o=null,r=null,c=null,h=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);h=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,h)-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 h=Math.sin(e.Math.toRadians(r)),c=Math.cos(e.Math.toRadians(r)),d=t.boundingSphere.radius*c,u=t.boundingSphere.radius*h;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,h=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:h,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;Ae(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 h=n.Matrix4.getTranslation(e,new n.Cartesian3),c=n.Cartographic.fromCartesian(h),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,h=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+h*.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,h=new n.HeadingPitchRoll(r,o.pitch,o.roll),c=n.Transforms.headingPitchRollToFixedFrame(n.Matrix4.getTranslation(t.modelMatrix,new n.Cartesian3),h,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 Eo(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);
@@ -8,23 +8,23 @@
8
8
  ${s.isCustomColor?"material.diffuse = color.rgb;":"material.diffuse = colorImage.rgb;"}
9
9
  material.alpha = colorImage.a;
10
10
  return material;
11
- }`};return a.Material._materialCache.addMaterial(e,{fabric:{type:e,uniforms:{color:t.color,image:t.image,time:1e3},source:o({count:t.count,freely:t.freely||"",direction:t.direction,duration:t.duration||100,isCustomColor:t.isCustomColor})},translucent(){return!0}}),new i(t)}function Po(a,t){const e=t.MaterialType||"wallType"+new Date().getTime()+parseInt(Math.random()*1e3+"");function i(s){this._definitionChanged=new a.Event,this._color=void 0,this._colorSubscription=void 0,this.color=s.color,this.duration=s.duration,this._time=new Date().getTime()}Object.defineProperties(i.prototype,{isConstant:{get:function(){return!1}},definitionChanged:{get:function(){return this._definitionChanged}},color:a.createPropertyDescriptor("color")}),i.prototype.getType=function(){return e},i.prototype.getValue=function(s,n){return a.defined(n)||(n={}),n.image=t.image,this.duration&&(n.time=(new Date().getTime()-this._time)%this.duration/this.duration),n},i.prototype.equals=function(s){return this===s||s instanceof i&&a.Property.equals(this._color,s._color)};const o=function(s){let n=`czm_material czm_getMaterial(czm_materialInput materialInput)
11
+ }`};return a.Material._materialCache.addMaterial(e,{fabric:{type:e,uniforms:{color:t.color,image:t.image,time:1e3},source:n({count:t.count,freely:t.freely||"",direction:t.direction,duration:t.duration||100,isCustomColor:t.isCustomColor})},translucent(){return!0}}),new i(t)}function Mo(a,t){const e=t.MaterialType||"wallType"+new Date().getTime()+parseInt(Math.random()*1e3+"");function i(s){this._definitionChanged=new a.Event,this._color=void 0,this._colorSubscription=void 0,this.color=s.color,this.duration=s.duration,this._time=new Date().getTime()}Object.defineProperties(i.prototype,{isConstant:{get:function(){return!1}},definitionChanged:{get:function(){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.image=t.image,this.duration&&(o.time=(new Date().getTime()-this._time)%this.duration/this.duration),o},i.prototype.equals=function(s){return this===s||s instanceof i&&a.Property.equals(this._color,s._color)};const n=function(s){let o=`czm_material czm_getMaterial(czm_materialInput materialInput)
12
12
  {
13
13
  czm_material material = czm_getDefaultMaterial(materialInput);
14
14
  vec2 st = materialInput.st;
15
15
 
16
- `;return s.freely=="vertical"?n+="vec4 colorImage = texture(image, vec2(fract(float("+s.count+")*st.t "+s.direction+` time), fract(st.s)));
17
- `:n+="vec4 colorImage = texture(image, vec2(fract(float("+s.count+")*st.s "+s.direction+` time), fract(st.t)));
18
- `,n+=`vec4 fragColor;
16
+ `;return s.freely=="vertical"?o+="vec4 colorImage = texture(image, vec2(fract(float("+s.count+")*st.t "+s.direction+` time), fract(st.s)));
17
+ `:o+="vec4 colorImage = texture(image, vec2(fract(float("+s.count+")*st.s "+s.direction+` time), fract(st.t)));
18
+ `,o+=`vec4 fragColor;
19
19
  fragColor.rgb = (color.rgb) / 1.0;
20
20
  fragColor = czm_gammaCorrect(fragColor);
21
- `,n+=` material.diffuse = color.rgb;
21
+ `,o+=` material.diffuse = color.rgb;
22
22
  material.alpha = colorImage.a * color.a;
23
23
  material.emission = fragColor.rgb;
24
24
 
25
25
  return material;
26
26
  }
27
- `,n};return a.Material._materialCache.addMaterial(e,{fabric:{type:e,uniforms:{color:t.color||new a.Color(1,1,1,1),image:t.image,time:0},source:o({count:t.count,freely:t.freely,direction:t.direction})},translucent:function(){return!0}}),new i(t)}function Lo(a,t){const e=a.Color,i=Object.defineProperties,o=a.Event,s=a.createPropertyDescriptor,n=a.Property,r=(u,m)=>u===void 0?m:u,l={};let c=t.materialType||"PolylineFlow"+Date.now()+Math.floor(Math.random()*1e3);function d(u){u=r(u,l),this._definitionChanged=new o,this._color=void 0,this._colorSubscription=void 0,this.color=u.color||e.fromBytes(0,255,255,255),this._duration=void 0,this._durationSubscription=void 0,this.duration=r(u.duration,45)}return i(d.prototype,{isConstant:{get(){return!1}},definitionChanged:{get(){return this._definitionChanged}}}),d.prototype.getType=function(u){return c},d.prototype.getValue=function(u,m){return m||(m={}),m.color=n.getValueOrClonedDefault(this._color,u,a.Color.WHITE,m.color),m.duration=this._duration,m},d.prototype.equals=function(u){return this===u||u instanceof d&&n.equals(this._color,u._color)},i(d.prototype,{color:s("color"),duration:s("duration")}),a.PolylineFlowMaterialProperty=d,a.Material._materialCache.addMaterial(c,{fabric:{type:c,uniforms:{color:new e(1,1,1,1),duration:45},source:(function(){return`uniform vec4 color;
27
+ `,o};return a.Material._materialCache.addMaterial(e,{fabric:{type:e,uniforms:{color:t.color||new a.Color(1,1,1,1),image:t.image,time:0},source:n({count:t.count,freely:t.freely,direction:t.direction})},translucent:function(){return!0}}),new i(t)}function Io(a,t){const e=a.Color,i=Object.defineProperties,n=a.Event,s=a.createPropertyDescriptor,o=a.Property,r=(u,m)=>u===void 0?m:u,h={};let c=t.materialType||"PolylineFlow"+Date.now()+Math.floor(Math.random()*1e3);function d(u){u=r(u,h),this._definitionChanged=new n,this._color=void 0,this._colorSubscription=void 0,this.color=u.color||e.fromBytes(0,255,255,255),this._duration=void 0,this._durationSubscription=void 0,this.duration=r(u.duration,45)}return i(d.prototype,{isConstant:{get(){return!1}},definitionChanged:{get(){return this._definitionChanged}}}),d.prototype.getType=function(u){return c},d.prototype.getValue=function(u,m){return m||(m={}),m.color=o.getValueOrClonedDefault(this._color,u,a.Color.WHITE,m.color),m.duration=this._duration,m},d.prototype.equals=function(u){return this===u||u instanceof d&&o.equals(this._color,u._color)},i(d.prototype,{color:s("color"),duration:s("duration")}),a.PolylineFlowMaterialProperty=d,a.Material._materialCache.addMaterial(c,{fabric:{type:c,uniforms:{color:new e(1,1,1,1),duration:45},source:(function(){return`uniform vec4 color;
28
28
  uniform float duration;
29
29
  czm_material czm_getMaterial(czm_materialInput materialInput){
30
30
  czm_material material = czm_getDefaultMaterial(materialInput);
@@ -40,38 +40,38 @@
40
40
  material.alpha = alpha;
41
41
  material.emission = fragColor.rgb;
42
42
  return material;
43
- }`})()},translucent(){return!0}}),new d(t)}class Eo{constructor(){h(this,"categoryMap",new Map);h(this,"CategoryGet",{})}registerCategoryGet(t,e){if(!t)return console.warn("分类不能为空");this.CategoryGet[t]=e}register(t){const{themeKey:e,material:i,force:o=!1,category:s="default"}=t;this.categoryMap.has(s)||this.categoryMap.set(s,new Map);const n=this.categoryMap.get(s);if(n.has(e))if(o)console.info(`[MaterialManager] themeKey '${e}' 在分类 '${s}' 已被覆盖`);else{console.warn(`[MaterialManager] 已存在 themeKey '${e}' 在分类 '${s}',如需覆盖请设置 force = true`);return}n.set(e,i)}get({themeKey:t,category:e,options:i}){var s;if(e=e||"default",this.CategoryGet[e])return this.CategoryGet[e]({themeKey:t,materialMap:this.categoryMap,options:i||{}});const o=(s=this.categoryMap.get(e))==null?void 0:s.get(t);return typeof o=="function"&&o.__materialFactory===!0?o(i||{}):o}has(t,e="default"){var i;return((i=this.categoryMap.get(e))==null?void 0:i.has(t))??!1}remove(t,e="default"){const i=this.categoryMap.get(e);if(!i)return;const o=i.get(t);o!=null&&o.destroy&&o.destroy(),i.delete(t),i.size===0&&this.categoryMap.delete(e)}keys(t="default"){var e;return[...((e=this.categoryMap.get(t))==null?void 0:e.keys())||[]]}clearCategory(t="default"){var i;const e=this.categoryMap.get(t);if(e){for(const o of e.values())(i=o==null?void 0:o.destroy)==null||i.call(o);e.clear(),this.categoryMap.delete(t)}}clearAll(){var t;for(const e of this.categoryMap.values())for(const i of e.values())(t=i==null?void 0:i.destroy)==null||t.call(i);this.categoryMap.clear()}categories(){return[...this.categoryMap.keys()]}}class Mo{constructor(t){h(this,"id");h(this,"entities",[]);h(this,"primitives",[]);h(this,"dataItem",{});h(this,"aggregator");h(this,"cardPool");const{id:e,entities:i=[],primitives:o=[],dataItem:s={},aggregator:n,cardPool:r}=t;this.id=e,this.entities=i,this.primitives=o,this.dataItem=s,this.aggregator=n,this.cardPool=r}setVisible(t){this.entities.forEach(e=>{e&&(e.show=t)}),this.primitives.forEach(e=>{e&&(e.show=t)}),this.aggregator&&Array.isArray(this.dataItem.billboard)&&this.dataItem.billboard.map((i,o)=>{var n;return{id:this.dataItem.id,data:{...this.dataItem,show:t&&(((n=i.data)==null?void 0:n.show)??!0)}}}).forEach(i=>{var o;(o=this.aggregator)==null||o.updatePoint(i)}),this.cardPool&&this.dataItem.card&&(t?this.cardPool.showByIds([this.dataItem.id]):this.cardPool.hideByIds([this.dataItem.id]))}removeAll(t,e=!0){return this.entities.forEach(i=>{i&&t.entities.remove(i)}),this.entities=[],this.primitives.forEach(i=>{i&&t.scene.primitives.remove(i)}),this.primitives=[],e&&this.aggregator&&Array.isArray(this.dataItem.billboard)&&this.aggregator.removePointsById([this.dataItem.id]),e&&this.cardPool&&this.dataItem.card&&this.cardPool.removeByIds([this.dataItem.id]),this.dataItem.id}}class Io{constructor(t,e,i,o,s,n){h(this,"id");h(this,"groupMap",new Map);h(this,"Cesium");h(this,"viewer");h(this,"materialManager");h(this,"aggregator");h(this,"cardPool");this.id=t,this.Cesium=e,this.viewer=i,this.materialManager=o,this.aggregator=s,this.cardPool=n,this.aggregator.labelPool.eventBus.addListener(V.Click,{name:"BufferedHierarchicalAggregator_maker_click",fn:(l,c)=>{this.cardPool.showByIds([l.data.id])}}),new e.ScreenSpaceEventHandler(i.scene.canvas).setInputAction(()=>{this.cardPool.hideFilter(l=>!l.initShow)},e.ScreenSpaceEventType.LEFT_CLICK)}createPolyline(t,e){if(!t.positions||t.positions.length<1)return null;const i=this.materialManager.get({themeKey:t.theme,category:"polyline",options:t}),o=Array.isArray(t.positions[0])?t.positions.flat():t.positions;let s={...t};return i&&(s.material=i),this.viewer.entities.add({polyline:{...s,positions:this.Cesium.Cartesian3.fromDegreesArrayHeights(o)},show:(t.show??!0)&&e})}createWall(t,e){if(!t.positions||t.positions.length<1)return null;const i=this.materialManager.get({themeKey:t.theme,category:"wall",options:t}),o=(v,C=0)=>{const b=Number(v);return Number.isFinite(b)?b:C},s=t.positions.map(v=>o(v==null?void 0:v[2],0)),n=o(t.minHeight,0),r=o(t.maxHeight,0),l=v=>Array.isArray(v)&&v.length===t.positions.length&&v.every(C=>Math.abs(o(C,0))<1e-6),c=s.some(v=>Math.abs(v)>1e-6),m=(Array.isArray(t.minimumHeights)&&t.minimumHeights.length===t.positions.length&&!(l(t.minimumHeights)&&c)?t.minimumHeights.map(v=>o(v,0)):s).map(v=>v-n),f=(Array.isArray(t.maximumHeights)&&t.maximumHeights.length===t.positions.length&&!(l(t.maximumHeights)&&c)?t.maximumHeights.map(v=>o(v,0)):s).map(v=>v+r),w=t.positions.map(v=>this.Cesium.Cartesian3.fromDegrees(v[0],v[1],v[2]||0));let y={...t};return i&&(y.material=i),this.viewer.entities.add({wall:{...y,positions:w,minimumHeights:m,maximumHeights:f},show:(t.show??!0)&&e})}createPolygon(t,e){var c;if(!t.hierarchy||t.hierarchy.length<1)return null;const i=this.materialManager.get({themeKey:t.theme,category:"polygon",options:t}),o=Array.isArray(t.hierarchy[0])?t.hierarchy.flat():t.hierarchy,s=this.Cesium.Cartesian3.fromDegreesArrayHeights(o),n=((c=t.holes)==null?void 0:c.map(d=>{let u=Array.isArray(d[0])?t.hierarchy.flat():t.hole;return this.Cesium.Cartesian3.fromDegreesArrayHeights(u.flat())}))||[],r=new this.Cesium.PolygonHierarchy(s,n);let l={...t};return i&&(l.material=i),this.viewer.entities.add({polygon:{...l,hierarchy:r},show:(t.show??!0)&&e})}createBillboardPoints(t){var e;return!((e=t.billboard)!=null&&e.length)||!this.aggregator?[]:t.billboard.map(i=>{var r;const[o,s,n=0]=i.position||[0,0,0];return{id:t.id,lon:o,lat:s,height:n,name:((r=i.options)==null?void 0:r.text)||"",data:t,style:{zIndex:t.zIndex||"1"}}})}createCard(t){var e,i,o;(i=(e=t.card)==null?void 0:e.data)!=null&&i.length&&this.cardPool.add(t.card,{id:t.id,lon:t.card.position[0],lat:t.card.position[1],height:t.card.position[3]||0,theme:t.card.theme,show:t.show?t.card.initShow??!1:!1,notCreateElement:!0,style:{width:"0",height:"0",zIndex:((o=t==null?void 0:t.card)==null?void 0:o.zIndex)||"110"}})}addGroup(t,e=!0){const i=t.id||`${Date.now()}`;this.removeGroup(i);const o=[],s=t.show!==!1;(t.polyline||[]).forEach(l=>{const c=this.createPolyline(l,s);c&&o.push(c)}),(t.wall||[]).forEach(l=>{const c=this.createWall(l,s);c&&o.push(c)}),(t.polygon||[]).forEach(l=>{const c=this.createPolygon(l,s);c&&o.push(c)});const n=this.createBillboardPoints(t);n.length&&e&&this.aggregator.appendPoints(n,!1),this.createCard(t);const r=new Mo({id:i,entities:o,primitives:[],dataItem:t,aggregator:this.aggregator,cardPool:this.cardPool});return this.groupMap.set(i,r),n}async addGroups(t){const i=t.map(o=>this.addGroup(o,!1)).flat();i.length>0&&this.aggregator&&this.aggregator.appendPoints(i,!1)}removeGroup(t){const e=this.groupMap.get(t);e&&(e.removeAll(this.viewer),this.groupMap.delete(t))}removeGroups(t){let e=[];for(const i of t){const o=this.groupMap.get(i);if(o){let s=o.removeAll(this.viewer,!1);this.groupMap.delete(i),e.push(s)}}this.aggregator.removePointsById(e),this.cardPool.removeByIds(e)}updateGroup(t){const e=this.groupMap.get(t.id);e&&(e.removeAll(this.viewer),this.groupMap.delete(t.id)),this.addGroup(t)}async updateGroups(t){this.aggregator.removePointsById(t.map(o=>o.id)),this.cardPool.removeByIds(t.map(o=>o.id));const i=t.map(o=>{const s=this.groupMap.get(o.id);return s&&(s.removeAll(this.viewer,!1),this.groupMap.delete(o.id)),this.addGroup(o,!1)}).flat();i.length>0&&this.aggregator&&this.aggregator.appendPoints(i,!1)}setGroupVisible(t,e){var i;(i=this.groupMap.get(t))==null||i.setVisible(e)}clearAllGroups(){this.groupMap.forEach(t=>t.removeAll(this.viewer)),this.groupMap.clear()}}class To{constructor(t,e,i,o,s){h(this,"Cesium");h(this,"viewer");h(this,"layerMap",new Map);h(this,"materialManager");h(this,"aggregator");h(this,"cardPool");this.Cesium=t,this.viewer=e,this.materialManager=i,this.aggregator=o,this.cardPool=s}addLayer(t){this.layerMap.has(t)||this.layerMap.set(t,new Io(t,this.Cesium,this.viewer,this.materialManager,this.aggregator,this.cardPool))}removeLayer(t){const e=this.layerMap.get(t);e&&(e.clearAllGroups(),this.layerMap.delete(t))}getLayer(t){return this.layerMap.get(t)}async addGroupsToLayer(t,e){const i=this.layerMap.get(t);i&&(i.addGroups(e),this.aggregator.refresh())}updateGroupToLayer(t,e){const i=this.layerMap.get(t);i&&(i.updateGroups(e),this.aggregator.refresh())}setGroupVisible(t,e,i){var o;(o=this.layerMap.get(t))==null||o.setGroupVisible(e,i)}removeGroup(t,e){var i;(i=this.layerMap.get(t))==null||i.removeGroup(e)}removeGroups(t,e){var i;(i=this.layerMap.get(t))==null||i.removeGroups(e)}}function _o(a){const t=[];return a.features.forEach((e,i)=>{if(e.geometry&&e.properties){const o=e.geometry,s=e.properties,n={id:s.id||`${Date.now()}`,show:!0,zIndex:s.zIndex||1,name:`${s.layer}_${i}`||"",billboard:[],polyline:[],wall:[],polygon:[],card:s.card||null};switch(o.type){case"Point":n.billboard.push({position:o.coordinates,options:s,name:`${s.layer}_${i}`});break;case"LineString":n.polyline.push({positions:o.coordinates,theme:s.theme||"default"});break;case"Polygon":n.polygon.push({hierarchy:o.coordinates[0],theme:s.theme||"default"});break;case"MultiLineString":o.coordinates.forEach(r=>{n.polyline.push({positions:r})});break;case"MultiPolygon":o.coordinates.forEach(r=>{n.polygon.push({hierarchy:r[0]})});break;case"GeometryCollection":o.geometries.forEach(r=>{r.type==="Point"?n.billboard.push({position:r.coordinates}):r.type==="LineString"?n.polyline.push({positions:r.coordinates}):r.type==="Polygon"&&n.polygon.push({hierarchy:r.coordinates[0]})});break;default:console.warn(`Unsupported geometry type: ${o.type}`);break}t.push(n)}}),t}class xo{constructor(t){h(this,"Cesium");h(this,"viewer");h(this,"layerMap");h(this,"hideLayerMap");h(this,"entityLayerManager");h(this,"PrimitiveThemeMap");h(this,"materialManager");let{Cesium:e,viewer:i,materialManager:o,entityLayerManager:s}=t;this.Cesium=e,this.viewer=i,this.layerMap=new Map,this.PrimitiveThemeMap=new Map,this.hideLayerMap=new Map,this.materialManager=o,this.entityLayerManager=s}createGeometryInstance(t){let e;return t.category==="polyline"&&t.positions?e=this.createPolyline(t):t.category==="polygon"&&t.hierarchy&&(e=this.createPolygon(t)),e}carateThemePrimitive(t){let e=Oe(t),i=this.PrimitiveThemeMap.get(e.theme);if(!i){this.initTheme(e);let o=this.createAppearance(e);i={Primitive:null,ids:new Map,appearance:o,geometryInstances:new Map},this.PrimitiveThemeMap.set(e.theme,i)}return i}initTheme(t){var o,s,n,r,l,c,d,u,m,g,p,f;let e=this.materialManager,i=this.Cesium;if(t.category=="polyline"){const w=((s=(o=t.properties)==null?void 0:o.lineType)==null?void 0:s.pattern)&&((r=(n=t.properties)==null?void 0:n.lineType)==null?void 0:r.patternLength);let y="";if(w){const v=((c=(l=t.properties)==null?void 0:l.lineType)==null?void 0:c.pattern)||[.25,-.125],C=((u=(d=t.properties)==null?void 0:d.lineType)==null?void 0:u.patternLength)||.375;let b=this.convertCadPatternToCesiumDash(v,C);y=`DashedLineMaterial_pattern_${b.dashPattern}_dashLength_${b.dashLength}_color_${(m=t.properties)==null?void 0:m.color}`,e.has(y)||e.register({themeKey:y,material:i.Material.fromType("PolylineDash",{color:i.Color.fromCssColorString(t.properties.color||"#FFFFFF").withAlpha(.8),dashLength:b.dashLength,dashPattern:b.dashPattern})})}else y=`LineMaterial_color_${(g=t.properties)==null?void 0:g.color}`,e.has(y)||e.register({themeKey:y,material:i.Material.fromType("Color",{color:i.Color.fromCssColorString(t.properties.color||"#FFFFFF").withAlpha(.8)})})}else if(t.category=="polygon"){let w=`polygonMaterial_color_${(p=t.properties)==null?void 0:p.color}`;e.has(w)||e.register({themeKey:w,material:i.Material.fromType("Color",{color:i.Color.fromCssColorString(((f=t.properties)==null?void 0:f.color)||"#FFFFFF").withAlpha(.8)})})}}convertCadPatternToCesiumDash(t,e){const o=e/16;let s=[],n=0;for(let l of t){const c=Math.floor(Math.abs(l)/o),d=l>=0?1:0;for(let u=0;u<c&&(s.push(d),n++,!(n>=16));u++);if(n>=16)break}for(;s.length<16;)s.push(0);s.length>16&&(s.length=16);let r=0;for(let l=0;l<16;l++)r=r<<1|s[l];return{dashPattern:r,dashLength:e}}async processBatch(t){const e=new Map;t.forEach(i=>{let{layerId:o,dataList:s}=i;Oe(s).forEach(r=>{let l=this.createGeometryInstance(r);if(l){let c=this.carateThemePrimitive(r);c.ids.set(r.id,r),c.geometryInstances.set(r.id,l);const d=this.layerMap.get(o);if(d)d.set(r.id,r);else{let u=new Map;this.layerMap.set(o,u),u.set(r.id,r)}e.set(r.theme,r)}})}),e.forEach(i=>{this.updatePrimitive(i)})}createPolyline(t){const e=Array.isArray(t.positions[0])?t.positions.flat():t.positions;return new this.Cesium.GeometryInstance({id:t.id,geometry:new this.Cesium.GroundPolylineGeometry({positions:this.Cesium.Cartesian3.fromDegreesArrayHeights(e),width:Math.max(t.width||2,2)})})}createPolygon(t){var n;const e=Array.isArray(t.hierarchy[0])?t.hierarchy.flat():t.hierarchy,i=this.Cesium.Cartesian3.fromDegreesArrayHeights(e),o=((n=t.holes)==null?void 0:n.map(r=>{let l=Array.isArray(r[0])?r.flat():r,c=this.Cesium.Cartesian3.fromDegreesArrayHeights(l.flat());return new this.Cesium.PolygonHierarchy(c)}))||[],s=new this.Cesium.PolygonHierarchy(i,o);return new this.Cesium.GeometryInstance({id:t.id,geometry:new this.Cesium.PolygonGeometry({polygonHierarchy:s})})}getMaterial(t){let e=this.materialManager.get({themeKey:t.theme,options:t});return e||(e=this.Cesium.Material.fromType("Color",{color:new this.Cesium.Color(1,0,0,1)})),e}updateGeometryInstance(t){let e=Oe(t);const i=this.layerMap.get(e.layerId);if(!i){console.warn(`没有找到图层 ${e.layerId}`);return}let o=i.get(e.id);if(i.set(e.id,e),!o){console.warn(`没有找到图元 ${e.id} 在图层 ${e.layerId} 中`);return}if(o.theme!==e.theme){let n=this.PrimitiveThemeMap.get(o.theme);n==null||n.geometryInstances.delete(e.id),n==null||n.ids.delete(e.id),this.updatePrimitive(o)}let s=this.carateThemePrimitive(e);if(s){const n=this.createGeometryInstance(e);s.geometryInstances.set(e.id,n),s.ids.set(e.id,e),this.updatePrimitive(e)}}deleteGeometryInstance(t){let e=new Set;t.forEach(i=>{let{layerId:o,ids:s}=i;const n=this.layerMap.get(o);if(!n){console.warn(`没有找到图层 ${o}`);return}s.forEach(r=>{let l=n.get(r);if(!l){console.warn(`没有找到图元 ${r} 在图层 ${o} 中`);return}let c=this.PrimitiveThemeMap.get(l.theme);c&&(c.geometryInstances.delete(l.id),c.ids.delete(l.id),e.add(l))})}),Array.from(e.values()).forEach(i=>{this.updatePrimitive(i)})}addGeometryInstance(t){let e=Oe(t);const i=this.layerMap.get(e.layerId);if(!i){console.warn(`没有找到图层 ${e.layerId}`);return}if(i.get(e.id)){console.warn(`图元 ${e.id} 已经存在图层 ${e.layerId} 中`);return}i.set(e.id,e);let s=this.carateThemePrimitive(e);if(s){const n=this.createGeometryInstance(e);s.geometryInstances.set(e.id,n),s.ids.set(e.id,e),this.updatePrimitive(e)}}createAppearance(t){let e=this.getMaterial({theme:t.theme}),i;return t.category==="polyline"?i=new this.Cesium.PolylineMaterialAppearance({material:e,translucent:!0}):t.category==="polygon"&&(i=new this.Cesium.MaterialAppearance({material:e,translucent:!0})),i}updatePrimitive(t){const e=this.PrimitiveThemeMap.get(t.theme);if(!e)return;e.Primitive&&(this.viewer.scene.primitives.remove(e.Primitive),e.Primitive=null);let o=Array.from(e.geometryInstances,([s,n])=>({key:s,value:n})).filter(s=>!Array.from(this.hideLayerMap.values()).some(n=>n.has(s.key))).map(s=>s.value);o.length<=0||(t.category==="polyline"?(e.Primitive=new this.Cesium.GroundPolylinePrimitive({geometryInstances:o,appearance:e.appearance}),this.viewer.scene.primitives.add(e.Primitive)):(e.Primitive=new this.Cesium.GroundPrimitive({geometryInstances:o,appearance:e.appearance}),this.viewer.scene.primitives.add(e.Primitive)))}hideByLayerAndId(t){let e=new Map;t.forEach(i=>{let{layerId:o,ids:s}=i,n=this.hideLayerMap.get(o);n||(n=new Set,this.hideLayerMap.set(o,n)),s.forEach(r=>{n.add(r);let l=this.getGeometryInstanceInfo(o,r);l&&e.set(l.theme,l)})}),Array.from(e.values()).forEach(i=>{this.updatePrimitive(i)})}showByLayerAndId(t){let e=new Map;t.forEach(i=>{let{layerId:o,ids:s}=i,n=this.hideLayerMap.get(o);n||(n=new Set,this.hideLayerMap.set(o,n)),s.forEach(r=>{n.delete(r);let l=this.getGeometryInstanceInfo(o,r);l&&e.set(l.theme,l)})}),Array.from(e.values()).forEach(i=>{this.updatePrimitive(i)})}hasGeometryInstance(t,e){const i=this.layerMap.get(t);if(!i)return!1;const o=i.get(e);if(!o)return!1;let s=this.PrimitiveThemeMap.get(o.theme);return!(!s||!s.geometryInstances.get(e))}getGeometryInstanceInfo(t,e){const i=this.layerMap.get(t);return i?i.get(e):null}focusOnGeometryInstance(t,e){const i=this.layerMap.get(t);if(!i){console.warn(`图层 ${t} 不存在`);return}const o=i.get(e);if(!o){console.warn(`没有找到图元 ${e} 在图层 ${t} 中`);return}let s=this.PrimitiveThemeMap.get(o.theme);if(!s){console.warn(`没有找到 ${e} 图元相关的Primitive`);return}const n=s.geometryInstances.get(e);if(!n){console.warn(`没有找到图元的几何体 ${e}`);return}const r=n.geometry,l=r._positions||r._polygonHierarchy.positions;if(l&&l.length>0){let c=l[0].x,d=l[0].y,u=l[0].z,m=l[0].x,g=l[0].y,p=l[0].z;l.forEach(C=>{c=Math.min(c,C.x),d=Math.min(d,C.y),u=Math.min(u,C.z),m=Math.max(m,C.x),g=Math.max(g,C.y),p=Math.max(p,C.z)});const f=new this.Cesium.Cartesian3((c+m)/2,(d+g)/2,(u+p)/2),y=new this.Cesium.Cartesian3(m-c,g-d,p-u).z,v=Math.abs(y||1)*1.5;this.viewer.camera.flyTo({destination:f,duration:2,complete:()=>{console.log(`已定位到图元 ${e}`)},offset:new this.Cesium.Cartesian3(0,0,v)})}else console.warn(`无法获取图元 ${e} 的顶点信息`)}}class Ye{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"tempPoints",[]);h(this,"segmentEntities",[]);h(this,"segmentLabelIds",[]);h(this,"previewEntity",null);h(this,"previewGroundEntity",null);h(this,"hoverPos",null);h(this,"htmlLabelPool",null);h(this,"totalLabelId",null);h(this,"previewLabelId",null);h(this,"labelEntity",null);h(this,"firstHeight",null);h(this,"groundLineEntities",[]);h(this,"previewPos",null);h(this,"previewGroundPos",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const o=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,o),this.htmlLabelPool.registerTheme("measure-horizontal-total",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-horizontal-seg",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var f,w,y,v;const s=i.scene.pickPosition(o.position);if(!s)return;const n=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(n.longitude),l=e.Math.toDegrees(n.latitude);this.positions.length===0&&(this.firstHeight=n.height||0);const c=e.Cartesian3.fromDegrees(r,l,this.firstHeight||0);this.positions.push(c);const d=i.entities.add({position:c,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(d);const u=i.scene.globe.getHeight(new e.Cartographic(n.longitude,n.latitude,0))||0,m=e.Cartesian3.fromDegrees(r,l,u),g=((w=(f=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:w.call(f,.9))||e.Color.RED,p=i.entities.add({polyline:{positions:[m,c],width:t.width||3,material:new e.PolylineDashMaterialProperty({color:g,dashLength:12,dashPattern:255})}});if(this.groundLineEntities.push(p),this.positions.length>=2){const C=this.positions[this.positions.length-2],b=this.positions[this.positions.length-1],M=e.Cartographic.fromCartesian(C),P=e.Cartographic.fromCartesian(b),L=i.entities.add({polyline:{positions:[C,b],width:t.width||3,material:t.lineColor||t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:((v=(y=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:v.call(y,.9))||e.Color.RED,dashLength:12,dashPattern:255})}});this.segmentEntities.push(L);const I=new e.EllipsoidGeodesic(M,P).surfaceDistance,A=new e.Cartesian3((C.x+b.x)/2,(C.y+b.y)/2,(C.z+b.z)/2),x=e.Cartographic.fromCartesian(A),T=`measure_horizontal_seg_${this.segmentLabelIds.length}_${Date.now()}`;this.segmentLabelIds.push(T),this.htmlLabelPool.add({text:`${I.toFixed(2)} m`},{id:T,lon:e.Math.toDegrees(x.longitude),lat:e.Math.toDegrees(x.latitude),height:x.height||this.firstHeight||0,theme:"measure-horizontal-seg",show:!0})}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var c;if(this.positions.length<2){this.stop();return}this.stop(),this.previewLabelId&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.hoverPos&&(this.hoverPos=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewGroundEntity&&(this.viewer.entities.remove(this.previewGroundEntity),this.previewGroundEntity=null);let o=0;for(let d=1;d<this.positions.length;d++){const u=this.positions[d-1],m=this.positions[d],g=e.Cartographic.fromCartesian(u),p=e.Cartographic.fromCartesian(m),f=new e.EllipsoidGeodesic(g,p);o+=f.surfaceDistance}const s=this.positions[this.positions.length-1],n=e.Cartographic.fromCartesian(s),r=this.totalLabelId||`measure_horizontal_total_${Date.now()}`;this.totalLabelId=r,this.htmlLabelPool.add({text:`${o.toFixed(2)} m`},{id:r,lon:e.Math.toDegrees(n.longitude),lat:e.Math.toDegrees(n.latitude),height:n.height||this.firstHeight||0,theme:"measure-horizontal-total",show:!0}),this.labelEntity=this.totalLabelId;const l={entity:this.segmentEntities,label:this.labelEntity,segmentLabels:this.segmentLabelIds,positions:this.positions,distance:o,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,l)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.handler.setInputAction(o=>{var M,P,L,E;if(this.positions.length===0)return;const s=i.scene.pickPosition(o.endPosition);if(!s)return;this.hoverPos=s;const n=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(n.longitude),l=e.Math.toDegrees(n.latitude),c=e.Cartesian3.fromDegrees(r,l,this.firstHeight||0);this.previewPos=c;const d=i.scene.globe.getHeight(new e.Cartographic(n.longitude,n.latitude,0))||0,u=e.Cartesian3.fromDegrees(r,l,d);this.previewGroundPos=u;const m=this.positions[this.positions.length-1],g=e.Cartographic.fromCartesian(m),p=e.Cartographic.fromCartesian(c),w=new e.EllipsoidGeodesic(g,p).surfaceDistance,y=new e.Cartesian3((m.x+c.x)/2,(m.y+c.y)/2,(m.z+c.z)/2),v=e.Cartographic.fromCartesian(y),C=this.previewLabelId||"measure_horizontal_preview";this.previewLabelId=C,this.htmlLabelPool.add({text:`${w.toFixed(2)} m`},{id:C,lon:e.Math.toDegrees(v.longitude),lat:e.Math.toDegrees(v.latitude),height:v.height||this.firstHeight||0,theme:"measure-horizontal-seg",show:!0});const b=((P=(M=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:P.call(M,.9))||e.Color.RED;this.previewGroundEntity||(this.previewGroundEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewPos||!this.previewGroundPos?[]:[this.previewGroundPos,this.previewPos],!1),width:t.width||3,material:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}})),this.previewEntity||(this.previewEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewPos||!this.positions.length?[]:[this.positions[this.positions.length-1],this.previewPos],!1),width:t.width||3,material:t.lineColor||t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:((E=(L=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:E.call(L,.9))||e.Color.RED,dashLength:12,dashPattern:255})}}))},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.segmentEntities.forEach(t=>this.viewer.entities.remove(t)),this.segmentEntities=[],this.groundLineEntities.forEach(t=>this.viewer.entities.remove(t)),this.groundLineEntities=[],this.tempPoints.forEach(t=>this.viewer.entities.remove(t)),this.tempPoints=[],this.totalLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.totalLabelId]),this.totalLabelId=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewGroundEntity&&(this.viewer.entities.remove(this.previewGroundEntity),this.previewGroundEntity=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.segmentLabelIds=[],this.positions=[],this.hoverPos=null,this.labelEntity=null,this.firstHeight=null,this.previewPos=null,this.previewGroundPos=null}rehydrate(t,e){var p,f;const i=this.Cesium,o=this.viewer,s=t.options||{},n=s.lineColor||s.color||i.Color.YELLOW,r=((f=(p=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:f.call(p,.9))||i.Color.RED,l=s.width||3,c=(t.positions||[]).map(w=>new i.Cartesian3(w[0],w[1],w[2]));if(!c.length)return;if(!this.htmlLabelPool){const w=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,w),this.htmlLabelPool.registerTheme("measure-horizontal-total",{createElement:(y,v)=>{var C;y.innerHTML=String(((C=v==null?void 0:v.data)==null?void 0:C.text)||""),y.style.background="rgba(0,0,0,0.6)",y.style.color="#fff",y.style.font="14px sans-serif",y.style.padding="4px 6px",y.style.borderRadius="4px",y.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-horizontal-seg",{createElement:(y,v)=>{var C;y.innerHTML=String(((C=v==null?void 0:v.data)==null?void 0:C.text)||""),y.style.background="rgba(0,0,0,0.6)",y.style.color="#fff",y.style.font="14px sans-serif",y.style.padding="4px 6px",y.style.borderRadius="4px",y.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}for(const w of c){const y=o.entities.add({position:w,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(y);const v=i.Cartographic.fromCartesian(w),C=i.Math.toDegrees(v.longitude),b=i.Math.toDegrees(v.latitude),M=o.scene.globe.getHeight(new i.Cartographic(v.longitude,v.latitude,0))||0,P=i.Cartesian3.fromDegrees(C,b,M),L=o.entities.add({polyline:{positions:[P,w],width:l,material:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});this.groundLineEntities.push(L)}for(let w=1;w<c.length;w++){const y=c[w-1],v=c[w],C=o.entities.add({polyline:{positions:[y,v],width:l,material:n,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});this.segmentEntities.push(C);const b=i.Cartographic.fromCartesian(y),M=i.Cartographic.fromCartesian(v),L=new i.EllipsoidGeodesic(b,M).surfaceDistance,E=new i.Cartesian3((y.x+v.x)/2,(y.y+v.y)/2,(y.z+v.z)/2),I=i.Cartographic.fromCartesian(E),A=t.id+`_seg_${w-1}`;this.segmentLabelIds.push(A),this.htmlLabelPool.add({text:`${L.toFixed(2)} m`},{id:A,lon:i.Math.toDegrees(I.longitude),lat:i.Math.toDegrees(I.latitude),height:I.height||0,theme:"measure-horizontal-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}let d=0;for(let w=1;w<c.length;w++){const y=i.Cartographic.fromCartesian(c[w-1]),v=i.Cartographic.fromCartesian(c[w]),C=new i.EllipsoidGeodesic(y,v);d+=C.surfaceDistance}const u=c[c.length-1],m=i.Cartographic.fromCartesian(u),g=t.id+"_total";this.totalLabelId=g,this.htmlLabelPool.add({text:`${d.toFixed(2)} m`},{id:g,lon:i.Math.toDegrees(m.longitude),lat:i.Math.toDegrees(m.latitude),height:m.height||0,theme:"measure-horizontal-total",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}}class Ve{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"labelEntity",null);h(this,"positions",[]);h(this,"htmlLabelPool",null);h(this,"htmlLabelId",null);h(this,"previewLabelId",null);h(this,"baseCarto",null);h(this,"baseUp",null);h(this,"tempPoints",[]);h(this,"previewPointEntity",null);h(this,"previewEntity",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const o=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,o),this.htmlLabelPool.registerTheme("measure-vertical",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var r,l,c,d,u;const s=i.camera.getPickRay(o.position);let n=s?i.scene.globe.pick(s,i.scene):null;if(n||(n=i.camera.pickEllipsoid(o.position,e.Ellipsoid.WGS84)),n||(n=i.scene.pickPosition(o.position)),!!n)if(this.positions.length===0){const m=e.Cartographic.fromCartesian(n);this.baseCarto=new e.Cartographic(m.longitude,m.latitude,0);const g=e.Ellipsoid.WGS84.cartographicToCartesian(this.baseCarto);this.baseUp=e.Ellipsoid.WGS84.geodeticSurfaceNormalCartographic(this.baseCarto),this.positions.push(g);const p=i.entities.add({position:g,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(p);const f=t.lineColor||t.color||e.Color.CYAN,w=((l=(r=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(r,.9))||e.Color.RED;this.previewEntity=i.entities.add({polyline:{positions:[g,g],width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}})}else{if(!this.baseCarto||!this.baseUp)return;const m=this.positions[0],g=i.camera.getPickRay(o.position);if(!g)return;const p=g.origin,f=e.Cartesian3.normalize(g.direction,new e.Cartesian3),w=m,y=this.baseUp,v=e.Cartesian3.subtract(p,w,new e.Cartesian3),C=e.Cartesian3.dot(f,f),b=-e.Cartesian3.dot(f,y),M=e.Cartesian3.dot(y,y),P=-e.Cartesian3.dot(f,v),L=e.Cartesian3.dot(y,v),E=C*M-b*b;if(Math.abs(E)<1e-6)return;const I=(C*L-b*P)/E,A=e.Cartesian3.add(w,e.Cartesian3.multiplyByScalar(y,I,new e.Cartesian3),new e.Cartesian3);this.positions[1]=A,this.stop(),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewPointEntity&&(this.viewer.entities.remove(this.previewPointEntity),this.previewPointEntity=null);const x=t.lineColor||t.color||e.Color.CYAN,T=((d=(c=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:d.call(c,.9))||e.Color.RED;this.entity=i.entities.add({polyline:{positions:[m,A],width:t.width||3,material:x,depthFailMaterial:new e.PolylineDashMaterialProperty({color:T,dashLength:12,dashPattern:255})}});const $=i.entities.add({position:A,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push($);const D=this.baseCarto,k=e.Cartographic.fromCartesian(A),_=Math.abs((k.height||0)-(D.height||0)),O=new e.Cartesian3((this.positions[0].x+this.positions[1].x)/2,(this.positions[0].y+this.positions[1].y)/2,(this.positions[0].z+this.positions[1].z)/2),R=e.Cartographic.fromCartesian(O);this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);const G=this.htmlLabelId||`measure_vertical_${Date.now()}`;this.htmlLabelId=G,this.htmlLabelPool.add({text:`${_.toFixed(2)} m`},{id:G,lon:e.Math.toDegrees(R.longitude),lat:e.Math.toDegrees(R.latitude),height:R.height||0,theme:"measure-vertical",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const B={entity:this.entity,label:this.labelEntity,positions:this.positions,vertical:_,clear:()=>this.clear()};(u=t.onComplete)==null||u.call(t,B)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(o=>{var A,x;if(this.positions.length<1)return;if(!this.baseCarto||!this.baseUp){const T=e.Cartographic.fromCartesian(this.positions[0]);this.baseCarto=new e.Cartographic(T.longitude,T.latitude,T.height||0),this.baseUp=e.Ellipsoid.WGS84.geodeticSurfaceNormalCartographic(this.baseCarto)}const s=this.positions[0],n=i.camera.getPickRay(o.endPosition);if(!n)return;const r=n.origin,l=e.Cartesian3.normalize(n.direction,new e.Cartesian3),c=s,d=this.baseUp,u=e.Cartesian3.subtract(r,c,new e.Cartesian3),m=e.Cartesian3.dot(l,l),g=-e.Cartesian3.dot(l,d),p=e.Cartesian3.dot(d,d),f=-e.Cartesian3.dot(l,u),w=e.Cartesian3.dot(d,u),y=m*p-g*g;if(Math.abs(y)<1e-6)return;const v=(m*w-g*f)/y,C=e.Cartesian3.add(c,e.Cartesian3.multiplyByScalar(d,v,new e.Cartesian3),new e.Cartesian3);if(this.positions[1]=C,!this.previewEntity){const T=t.lineColor||t.color||e.Color.CYAN,$=((x=(A=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:x.call(A,.9))||e.Color.RED;this.previewEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>this.positions.length<2?[]:[this.positions[0],this.positions[1]],!1),width:t.width||3,material:T,depthFailMaterial:new e.PolylineDashMaterialProperty({color:$,dashLength:12,dashPattern:255})}})}this.previewPointEntity?this.previewPointEntity.position=C:this.previewPointEntity=i.entities.add({position:C,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});const b=this.baseCarto,M=e.Cartographic.fromCartesian(C),P=Math.abs((M.height||0)-(b.height||0)),L=new e.Cartesian3((this.positions[0].x+C.x)/2,(this.positions[0].y+C.y)/2,(this.positions[0].z+C.z)/2),E=e.Cartographic.fromCartesian(L),I=this.previewLabelId||"measure_vertical_preview";this.previewLabelId=I,this.htmlLabelPool.add({text:`${P.toFixed(2)} m`},{id:I,lon:e.Math.toDegrees(E.longitude),lat:e.Math.toDegrees(E.latitude),height:E.height||0,theme:"measure-vertical",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.labelEntity&&(this.viewer.entities.remove(this.labelEntity),this.labelEntity=null),this.tempPoints.forEach(t=>this.viewer.entities.remove(t)),this.tempPoints=[],this.previewPointEntity&&(this.viewer.entities.remove(this.previewPointEntity),this.previewPointEntity=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.positions=[]}rehydrate(t,e){var b,M;const i=this.Cesium,o=this.viewer,s=t.options||{},n=s.lineColor||s.color||i.Color.CYAN,r=((M=(b=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:M.call(b,.9))||i.Color.RED,l=s.width||3,c=(t.positions||[]).map(P=>new i.Cartesian3(P[0],P[1],P[2]));if(c.length<2)return;if(!this.htmlLabelPool){const P=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,P),this.htmlLabelPool.registerTheme("measure-vertical",{createElement:(L,E)=>{var I;L.innerHTML=String(((I=E==null?void 0:E.data)==null?void 0:I.text)||""),L.style.background="rgba(0,0,0,0.6)",L.style.color="#fff",L.style.font="14px sans-serif",L.style.padding="4px 6px",L.style.borderRadius="4px",L.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const d=c[0],u=c[1],m=o.entities.add({position:d,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),g=o.entities.add({position:u,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(m),this.tempPoints.push(g),this.entity=o.entities.add({polyline:{positions:[d,u],width:l,material:n,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});const p=i.Cartographic.fromCartesian(d),f=i.Cartographic.fromCartesian(u),w=Math.abs((f.height||0)-(p.height||0)),y=new i.Cartesian3((d.x+u.x)/2,(d.y+u.y)/2,(d.z+u.z)/2),v=i.Cartographic.fromCartesian(y),C=t.id+"_label";this.htmlLabelId=C,this.htmlLabelPool.add({text:`${w.toFixed(2)} m`},{id:C,lon:i.Math.toDegrees(v.longitude),lat:i.Math.toDegrees(v.latitude),height:v.height||0,theme:"measure-vertical",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}}class We{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"htmlLabelPool",null);h(this,"htmlLabelId",null);h(this,"segmentEntities",[]);h(this,"angleMarkerEntities",[]);h(this,"pointEntities",[]);h(this,"segmentLabelIds",[]);h(this,"angleLabelIds",[]);h(this,"previewLabelId",null);h(this,"previewSegmentEntities",[]);h(this,"previewAngleMarkerEntities",[]);h(this,"previewPointEntity",null);h(this,"previewLow",null);h(this,"previewHigh",null);h(this,"previewThird",null);h(this,"previewMarkerP1",null);h(this,"previewMarkerP2",null);h(this,"previewMarkerCorner",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const o=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,o),this.htmlLabelPool.registerTheme("measure-triangle",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-seg",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-angle",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var r,l,c;const s=i.scene.pickPosition(o.position);if(!s)return;this.positions.push(s);const n=i.entities.add({position:s,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});if(this.pointEntities.push(n),this.positions.length===2){this.stop(),this.previewSegmentEntities.forEach(J=>i.entities.remove(J)),this.previewSegmentEntities=[],this.previewAngleMarkerEntities.forEach(J=>i.entities.remove(J)),this.previewAngleMarkerEntities=[],this.previewPointEntity&&(i.entities.remove(this.previewPointEntity),this.previewPointEntity=null);const d=e.Cartographic.fromCartesian(this.positions[0]),u=e.Cartographic.fromCartesian(this.positions[1]),m=d.height||0,g=u.height||0,p=m<=g?this.positions[0]:this.positions[1],f=m>g?this.positions[0]:this.positions[1],w=e.Cartographic.fromCartesian(p);e.Cartographic.fromCartesian(f);const y=Math.max(m,g),v=e.Cartesian3.fromDegrees(e.Math.toDegrees(w.longitude),e.Math.toDegrees(w.latitude),y),C=t.lineColor||t.color||e.Color.YELLOW,b=((l=(r=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(r,.9))||e.Color.RED,M=i.entities.add({polyline:{positions:[p,v],width:t.width||3,material:C,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}}),P=i.entities.add({polyline:{positions:[v,f],width:t.width||3,material:C,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}}),L=i.entities.add({polyline:{positions:[p,f],width:t.width||3,material:C,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}});this.segmentEntities.push(M,P,L);const E=e.Cartesian3.distance(p,v),I=e.Cartesian3.distance(v,f),A=e.Cartesian3.distance(p,f),x=new e.Cartesian3((p.x+v.x)/2,(p.y+v.y)/2,(p.z+v.z)/2),T=new e.Cartesian3((v.x+f.x)/2,(v.y+f.y)/2,(v.z+f.z)/2),$=new e.Cartesian3((p.x+f.x)/2,(p.y+f.y)/2,(p.z+f.z)/2),D=e.Cartographic.fromCartesian(x),k=e.Cartographic.fromCartesian(T),_=e.Cartographic.fromCartesian($),O="measure_triangle_seg_v",R="measure_triangle_seg_h",G="measure_triangle_seg_hyp";this.segmentLabelIds=[O,R,G],this.htmlLabelPool.add({text:`${E.toFixed(2)} m`},{id:O,lon:e.Math.toDegrees(D.longitude),lat:e.Math.toDegrees(D.latitude),height:D.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${I.toFixed(2)} m`},{id:R,lon:e.Math.toDegrees(k.longitude),lat:e.Math.toDegrees(k.latitude),height:k.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${A.toFixed(2)} m`},{id:G,lon:e.Math.toDegrees(_.longitude),lat:e.Math.toDegrees(_.latitude),height:_.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const B=e.Cartesian3.subtract(f,p,new e.Cartesian3),j=e.Cartesian3.subtract(v,p,new e.Cartesian3),X=e.Cartesian3.subtract(v,f,new e.Cartesian3),Z=e.Cartesian3.subtract(p,f,new e.Cartesian3),ae=e.Cartesian3.dot(B,j),we=Math.sqrt(e.Cartesian3.dot(B,B))*Math.sqrt(e.Cartesian3.dot(j,j)),ve=e.Cartesian3.dot(X,Z),Te=Math.sqrt(e.Cartesian3.dot(X,X))*Math.sqrt(e.Cartesian3.dot(Z,Z)),Y=Math.acos(Math.min(Math.max(ae/(we||1),-1),1)),ue=Math.acos(Math.min(Math.max(ve/(Te||1),-1),1)),ne=e.Cartographic.fromCartesian(p),W=e.Cartographic.fromCartesian(f),Q="measure_triangle_angle_a",le="measure_triangle_angle_b";this.angleLabelIds=[Q,le],this.htmlLabelPool.add({text:`${(Y*180/Math.PI).toFixed(2)}°`},{id:Q,lon:e.Math.toDegrees(ne.longitude),lat:e.Math.toDegrees(ne.latitude),height:ne.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${(ue*180/Math.PI).toFixed(2)}°`},{id:le,lon:e.Math.toDegrees(W.longitude),lat:e.Math.toDegrees(W.latitude),height:W.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const Ce=Math.max(.01,Math.min(.5,t.angleMarkerRatio??.2)),U=Math.min(E,I)*Ce;if(E>.001&&I>.001){const J=e.Cartesian3.normalize(e.Cartesian3.subtract(p,v,new e.Cartesian3),new e.Cartesian3),he=e.Cartesian3.normalize(e.Cartesian3.subtract(f,v,new e.Cartesian3),new e.Cartesian3),ee=new e.Cartesian3(v.x+J.x*U,v.y+J.y*U,v.z+J.z*U),F=new e.Cartesian3(v.x+he.x*U,v.y+he.y*U,v.z+he.z*U),q=new e.Cartesian3(v.x+J.x*U+he.x*U,v.y+J.y*U+he.y*U,v.z+J.z*U+he.z*U),ie=i.entities.add({polyline:{positions:[ee,q],width:t.width||3,material:C,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}}),ke=i.entities.add({polyline:{positions:[F,q],width:t.width||3,material:C,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}});this.angleMarkerEntities.push(ie,ke)}this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);const K={entity:this.segmentEntities,positions:[p,f,v],lengths:{vertical:E,horizontal:I,hypotenuse:A},angles:{acuteA:Y,acuteB:ue},clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,K)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(o=>{var ue,ne;if(this.positions.length!==1)return;const s=i.scene.pickPosition(o.endPosition);if(!s)return;const n=e.Cartographic.fromCartesian(this.positions[0]),r=e.Cartographic.fromCartesian(s),l=n.height||0,c=r.height||0,d=l<=c?this.positions[0]:s,u=l>c?this.positions[0]:s,m=e.Cartographic.fromCartesian(d),g=Math.max(l,c),p=e.Cartesian3.fromDegrees(this.Cesium.Math.toDegrees(m.longitude),this.Cesium.Math.toDegrees(m.latitude),g);this.previewLow=d,this.previewHigh=u,this.previewThird=p;const f=t.lineColor||t.color||e.Color.YELLOW,w=((ne=(ue=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:ne.call(ue,.9))||e.Color.RED;if(this.previewPointEntity?this.previewPointEntity.position=s:this.previewPointEntity=i.entities.add({position:s,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),!this.previewSegmentEntities.length){const W=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewLow||!this.previewThird?[]:[this.previewLow,this.previewThird],!1),width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}}),Q=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewThird||!this.previewHigh?[]:[this.previewThird,this.previewHigh],!1),width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}}),le=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewLow||!this.previewHigh?[]:[this.previewLow,this.previewHigh],!1),width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}});this.previewSegmentEntities.push(W,Q,le)}const y=e.Cartesian3.distance(d,p),v=e.Cartesian3.distance(p,u),C=e.Cartesian3.distance(d,u),b=e.Cartesian3.subtract(u,d,new e.Cartesian3),M=e.Cartesian3.subtract(p,d,new e.Cartesian3),P=e.Cartesian3.subtract(p,u,new e.Cartesian3),L=e.Cartesian3.subtract(d,u,new e.Cartesian3),E=e.Cartesian3.dot(b,M),I=Math.sqrt(e.Cartesian3.dot(b,b))*Math.sqrt(e.Cartesian3.dot(M,M)),A=e.Cartesian3.dot(P,L),x=Math.sqrt(e.Cartesian3.dot(P,P))*Math.sqrt(e.Cartesian3.dot(L,L)),T=Math.acos(Math.min(Math.max(E/(I||1),-1),1)),$=Math.acos(Math.min(Math.max(A/(x||1),-1),1)),D=new e.Cartesian3((d.x+p.x)/2,(d.y+p.y)/2,(d.z+p.z)/2),k=new e.Cartesian3((p.x+u.x)/2,(p.y+u.y)/2,(p.z+u.z)/2),_=new e.Cartesian3((d.x+u.x)/2,(d.y+u.y)/2,(d.z+u.z)/2),O=e.Cartographic.fromCartesian(D),R=e.Cartographic.fromCartesian(k),G=e.Cartographic.fromCartesian(_),B=e.Cartographic.fromCartesian(d),j=e.Cartographic.fromCartesian(u),X="measure_triangle_seg_v",Z="measure_triangle_seg_h",ae="measure_triangle_seg_hyp",we="measure_triangle_angle_a",ve="measure_triangle_angle_b";this.segmentLabelIds.length===0&&(this.segmentLabelIds=[X,Z,ae]),this.angleLabelIds.length===0&&(this.angleLabelIds=[we,ve]),this.htmlLabelPool.add({text:`${y.toFixed(2)} m`},{id:X,lon:e.Math.toDegrees(O.longitude),lat:e.Math.toDegrees(O.latitude),height:O.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${v.toFixed(2)} m`},{id:Z,lon:e.Math.toDegrees(R.longitude),lat:e.Math.toDegrees(R.latitude),height:R.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${C.toFixed(2)} m`},{id:ae,lon:e.Math.toDegrees(G.longitude),lat:e.Math.toDegrees(G.latitude),height:G.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${(T*180/Math.PI).toFixed(2)}°`},{id:we,lon:e.Math.toDegrees(B.longitude),lat:e.Math.toDegrees(B.latitude),height:B.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${($*180/Math.PI).toFixed(2)}°`},{id:ve,lon:e.Math.toDegrees(j.longitude),lat:e.Math.toDegrees(j.latitude),height:j.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const Te=Math.max(.01,Math.min(.5,t.angleMarkerRatio??.2)),Y=Math.min(y,v)*Te;if(y>.001&&v>.001){const W=e.Cartesian3.normalize(e.Cartesian3.subtract(d,p,new e.Cartesian3),new e.Cartesian3),Q=e.Cartesian3.normalize(e.Cartesian3.subtract(u,p,new e.Cartesian3),new e.Cartesian3),le=new e.Cartesian3(p.x+W.x*Y,p.y+W.y*Y,p.z+W.z*Y),Ce=new e.Cartesian3(p.x+Q.x*Y,p.y+Q.y*Y,p.z+Q.z*Y),U=new e.Cartesian3(p.x+W.x*Y+Q.x*Y,p.y+W.y*Y+Q.y*Y,p.z+W.z*Y+Q.z*Y);if(this.previewMarkerP1=le,this.previewMarkerP2=Ce,this.previewMarkerCorner=U,!this.previewAngleMarkerEntities.length){const K=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewMarkerP1||!this.previewMarkerCorner?[]:[this.previewMarkerP1,this.previewMarkerCorner],!1),width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}}),J=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewMarkerP2||!this.previewMarkerCorner?[]:[this.previewMarkerP2,this.previewMarkerCorner],!1),width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}});this.previewAngleMarkerEntities.push(K,J)}}},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.segmentEntities.forEach(t=>this.viewer.entities.remove(t)),this.segmentEntities=[],this.angleMarkerEntities.forEach(t=>this.viewer.entities.remove(t)),this.angleMarkerEntities=[],this.pointEntities.forEach(t=>this.viewer.entities.remove(t)),this.pointEntities=[],this.previewSegmentEntities.forEach(t=>this.viewer.entities.remove(t)),this.previewSegmentEntities=[],this.previewAngleMarkerEntities.forEach(t=>this.viewer.entities.remove(t)),this.previewAngleMarkerEntities=[],this.previewPointEntity&&(this.viewer.entities.remove(this.previewPointEntity),this.previewPointEntity=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.angleLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.angleLabelIds.slice()),this.segmentLabelIds=[],this.angleLabelIds=[],this.positions=[]}rehydrate(t,e){var J,he;const i=this.Cesium,o=this.viewer,s=t.options||{},n=s.lineColor||s.color||i.Color.YELLOW,r=((he=(J=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:he.call(J,.9))||i.Color.RED,l=s.width||3,c=(t.positions||[]).map(ee=>new i.Cartesian3(ee[0],ee[1],ee[2]));if(c.length<2)return;if(!this.htmlLabelPool){const ee=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,ee),this.htmlLabelPool.registerTheme("measure-triangle",{createElement:(F,q)=>{var ie;F.innerHTML=String(((ie=q==null?void 0:q.data)==null?void 0:ie.text)||""),F.style.background="rgba(0,0,0,0.6)",F.style.color="#fff",F.style.font="14px sans-serif",F.style.padding="4px 6px",F.style.borderRadius="4px",F.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-seg",{createElement:(F,q)=>{var ie;F.innerHTML=String(((ie=q==null?void 0:q.data)==null?void 0:ie.text)||""),F.style.background="rgba(0,0,0,0.6)",F.style.color="#fff",F.style.font="14px sans-serif",F.style.padding="4px 6px",F.style.borderRadius="4px",F.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-angle",{createElement:(F,q)=>{var ie;F.innerHTML=String(((ie=q==null?void 0:q.data)==null?void 0:ie.text)||""),F.style.background="rgba(0,0,0,0.6)",F.style.color="#fff",F.style.font="14px sans-serif",F.style.padding="4px 6px",F.style.borderRadius="4px",F.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const d=i.Cartographic.fromCartesian(c[0]),u=i.Cartographic.fromCartesian(c[1]),m=d.height||0,g=u.height||0,p=m<=g?c[0]:c[1],f=m>g?c[0]:c[1],w=o.entities.add({position:p,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),y=o.entities.add({position:f,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(w,y);const v=i.Cartographic.fromCartesian(p),C=Math.max(m,g),b=i.Cartesian3.fromDegrees(i.Math.toDegrees(v.longitude),i.Math.toDegrees(v.latitude),C),M=o.entities.add({polyline:{positions:[p,b],width:l,material:n,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}}),P=o.entities.add({polyline:{positions:[b,f],width:l,material:n,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}}),L=o.entities.add({polyline:{positions:[p,f],width:l,material:n,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});this.segmentEntities.push(M,P,L);const E=i.Cartesian3.distance(p,b),I=i.Cartesian3.distance(b,f),A=i.Cartesian3.distance(p,f),x=new i.Cartesian3((p.x+b.x)/2,(p.y+b.y)/2,(p.z+b.z)/2),T=new i.Cartesian3((b.x+f.x)/2,(b.y+f.y)/2,(b.z+f.z)/2),$=new i.Cartesian3((p.x+f.x)/2,(p.y+f.y)/2,(p.z+f.z)/2),D=i.Cartographic.fromCartesian(x),k=i.Cartographic.fromCartesian(T),_=i.Cartographic.fromCartesian($),O=t.id+"_tri_v",R=t.id+"_tri_h",G=t.id+"_tri_hyp";this.segmentLabelIds=[O,R,G],this.htmlLabelPool.add({text:`${E.toFixed(2)} m`},{id:O,lon:i.Math.toDegrees(D.longitude),lat:i.Math.toDegrees(D.latitude),height:D.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${I.toFixed(2)} m`},{id:R,lon:i.Math.toDegrees(k.longitude),lat:i.Math.toDegrees(k.latitude),height:k.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${A.toFixed(2)} m`},{id:G,lon:i.Math.toDegrees(_.longitude),lat:i.Math.toDegrees(_.latitude),height:_.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const B=i.Cartesian3.subtract(f,p,new i.Cartesian3),j=i.Cartesian3.subtract(b,p,new i.Cartesian3),X=i.Cartesian3.subtract(b,f,new i.Cartesian3),Z=i.Cartesian3.subtract(p,f,new i.Cartesian3),ae=i.Cartesian3.dot(B,j),we=Math.sqrt(i.Cartesian3.dot(B,B))*Math.sqrt(i.Cartesian3.dot(j,j)),ve=i.Cartesian3.dot(X,Z),Te=Math.sqrt(i.Cartesian3.dot(X,X))*Math.sqrt(i.Cartesian3.dot(Z,Z)),Y=Math.acos(Math.min(Math.max(ae/(we||1),-1),1)),ue=Math.acos(Math.min(Math.max(ve/(Te||1),-1),1)),ne=i.Cartographic.fromCartesian(p),W=i.Cartographic.fromCartesian(f),Q=s.labelText||{angle:"角度"},le=t.id+"_tri_angA",Ce=t.id+"_tri_angB";this.angleLabelIds=[le,Ce],this.htmlLabelPool.add({text:`${Q.angle}:${(Y*180/Math.PI).toFixed(2)}°`},{id:le,lon:i.Math.toDegrees(ne.longitude),lat:i.Math.toDegrees(ne.latitude),height:ne.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${Q.angle}:${(ue*180/Math.PI).toFixed(2)}°`},{id:Ce,lon:i.Math.toDegrees(W.longitude),lat:i.Math.toDegrees(W.latitude),height:W.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const U=Math.max(.01,Math.min(.5,s.angleMarkerRatio??.2)),K=Math.min(E,I)*U;if(E>.001&&I>.001){const ee=i.Cartesian3.normalize(i.Cartesian3.subtract(p,b,new i.Cartesian3),new i.Cartesian3),F=i.Cartesian3.normalize(i.Cartesian3.subtract(f,b,new i.Cartesian3),new i.Cartesian3),q=new i.Cartesian3(b.x+ee.x*K,b.y+ee.y*K,b.z+ee.z*K),ie=new i.Cartesian3(b.x+F.x*K,b.y+F.y*K,b.z+F.z*K),ke=new i.Cartesian3(b.x+ee.x*K+F.x*K,b.y+ee.y*K+F.y*K,b.z+ee.z*K+F.z*K),$o=o.entities.add({polyline:{positions:[q,ke],width:l,material:n,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}}),Oo=o.entities.add({polyline:{positions:[ie,ke],width:l,material:n,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});this.angleMarkerEntities.push($o,Oo)}}}class Ue{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"labelEntity",null);h(this,"positions",[]);h(this,"tempPoints",[]);h(this,"htmlLabelPool",null);h(this,"htmlLabelId",null);h(this,"previewEntity",null);h(this,"previewPos",null);h(this,"previewLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const o=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,o),this.htmlLabelPool.registerTheme("measure-space",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var r,l,c;const s=i.scene.pickPosition(o.position);if(!s)return;this.positions.push(s);const n=i.entities.add({position:s,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});if(this.tempPoints.push(n),this.positions.length===2){this.stop(),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);const d=this.positions[0],u=this.positions[1],m=t.lineColor||t.color||e.Color.YELLOW,g=((l=(r=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(r,.9))||e.Color.RED;this.entity=i.entities.add({polyline:{positions:[d,u],width:t.width||3,material:m,depthFailMaterial:new e.PolylineDashMaterialProperty({color:g,dashLength:12,dashPattern:255})}});const p=e.Cartesian3.distance(d,u),f=u,w=e.Cartographic.fromCartesian(f),y=this.htmlLabelId||`measure_space_${Date.now()}`;this.htmlLabelId=y,this.htmlLabelPool.add({text:`${p.toFixed(2)} m`},{id:y,lon:e.Math.toDegrees(w.longitude),lat:e.Math.toDegrees(w.latitude),height:w.height||0,theme:"measure-space",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const v={entity:this.entity,label:this.labelEntity,positions:this.positions,distance:p,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,v)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(o=>{var g,p;if(this.positions.length!==1)return;const s=i.scene.pickPosition(o.endPosition);if(!s)return;this.previewPos=s;const n=this.positions[0],r=e.Cartesian3.distance(n,s),l=new e.Cartesian3((n.x+s.x)/2,(n.y+s.y)/2,(n.z+s.z)/2),c=e.Cartographic.fromCartesian(l),d=this.previewLabelId||"measure_space_preview";this.previewLabelId=d,this.htmlLabelPool.add({text:`${r.toFixed(2)} m`},{id:d,lon:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height||0,theme:"measure-space",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const u=t.lineColor||t.color||e.Color.YELLOW,m=((p=(g=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:p.call(g,.9))||e.Color.RED;this.previewEntity||(this.previewEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewPos||!this.positions.length?[]:[this.positions[0],this.previewPos],!1),width:t.width||3,material:u,depthFailMaterial:new e.PolylineDashMaterialProperty({color:m,dashLength:12,dashPattern:255})}}))},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.labelEntity&&(this.viewer.entities.remove(this.labelEntity),this.labelEntity=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.tempPoints.forEach(t=>this.viewer.entities.remove(t)),this.tempPoints=[],this.positions=[]}rehydrate(t,e){var d,u;const i=this.Cesium,o=this.viewer,s=t.options||{},n=s.lineColor||s.color||i.Color.YELLOW,r=((u=(d=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:u.call(d,.9))||i.Color.RED,l=s.width||3,c=(t.positions||[]).map(m=>new i.Cartesian3(m[0],m[1],m[2]));if(c.length){if(!this.htmlLabelPool){const m=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,m),this.htmlLabelPool.registerTheme("measure-space",{createElement:(g,p)=>{var f;g.innerHTML=String(((f=p==null?void 0:p.data)==null?void 0:f.text)||""),g.style.background="rgba(0,0,0,0.6)",g.style.color="#fff",g.style.font="14px sans-serif",g.style.padding="4px 6px",g.style.borderRadius="4px",g.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}if(c.length>=1){const m=o.entities.add({position:c[0],point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(m)}if(c.length>=2){const m=o.entities.add({position:c[1],point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(m),this.entity=o.entities.add({polyline:{positions:[c[0],c[1]],width:l,material:n,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});const g=i.Cartesian3.distance(c[0],c[1]),p=i.Cartographic.fromCartesian(c[1]),f=t.id+"_label";this.htmlLabelId=f,this.htmlLabelPool.add({text:`${g.toFixed(2)} m`},{id:f,lon:i.Math.toDegrees(p.longitude),lat:i.Math.toDegrees(p.latitude),height:p.height||0,theme:"measure-space",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}}}}class Ke{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"labelEntity",null);h(this,"positions",[]);h(this,"tempPoints",[]);h(this,"primitive",null);h(this,"previewEntity",null);h(this,"previewPos",null);h(this,"edgeEntities",[]);h(this,"pointEntities",[]);h(this,"previewEdgeEntity",null);h(this,"previewPointEntities",[]);h(this,"htmlLabelPool",null);h(this,"htmlLabelId",null);h(this,"previewLabelId",null);h(this,"segmentLabelIds",[]);h(this,"angleLabelIds",[]);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const o=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,o),this.htmlLabelPool.registerTheme("measure-area",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-area-seg",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-area-angle",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var m,g;const s=i.scene.pickPosition(o.position);if(!s)return;this.positions.push(s);const n=i.entities.add({position:s,point:{pixelSize:8,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(n),this.primitive&&(i.scene.primitives.remove(this.primitive),this.primitive=null);const r=new e.PolygonHierarchy(this.positions.slice()),l=new e.PolygonGeometry({polygonHierarchy:r,vertexFormat:e.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:e.ArcType.NONE}),c=new e.GeometryInstance({geometry:l}),d=t.color||e.Color.YELLOW.withAlpha(.4),u=t.color&&t.color.withAlpha?t.color.withAlpha(.25):e.Color.RED.withAlpha(.4);if(this.primitive=new e.Primitive({geometryInstances:c,appearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:d}),translucent:!0,closed:!0}),depthFailAppearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:u}),translucent:!0,closed:!0})}),i.scene.primitives.add(this.primitive),this.positions.length>=2){if(this.edgeEntities.length){for(const v of this.edgeEntities)try{i.entities.remove(v)}catch{}this.edgeEntities=[]}const p=t.lineColor||t.color||e.Color.YELLOW,f=((g=(m=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:g.call(m,.9))||e.Color.RED,w=this.positions.concat([this.positions[0]]),y=i.entities.add({polyline:{positions:w,width:t.width||2,material:p,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:f,dashLength:12,dashPattern:255})}});this.edgeEntities.push(y)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(o=>{var p,f;if(this.positions.length===0)return;const s=i.scene.pickPosition(o.endPosition);if(!s)return;this.previewPos=s;const n=this.positions.concat([s]),r=new e.Cartesian3(n.reduce((w,y)=>w+y.x,0)/n.length,n.reduce((w,y)=>w+y.y,0)/n.length,n.reduce((w,y)=>w+y.z,0)/n.length),c=new e.EllipsoidTangentPlane(r,e.Ellipsoid.WGS84).projectPointsOntoPlane(n);let d=0;for(let w=0;w<c.length;w++){const y=(w+1)%c.length;d+=c[w].x*c[y].y-c[y].x*c[w].y}d=Math.abs(d)/2;const u=e.Cartographic.fromCartesian(r),m=this.previewLabelId||"measure_area_preview";this.previewLabelId=m;const g=t.labelText||{area:"面积"};if(this.htmlLabelPool.add({text:`${g.area}:${d.toFixed(2)} m²`},{id:m,lon:e.Math.toDegrees(u.longitude),lat:e.Math.toDegrees(u.latitude),height:u.height||0,theme:"measure-area",show:!0}),!this.previewEntity){const w=t.color||e.Color.YELLOW.withAlpha(.4);this.previewEntity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>{if(!this.previewPos||!this.positions.length)return;const M=this.positions.concat([this.previewPos]);return new e.PolygonHierarchy(M)},!1),material:w,perPositionHeight:!0,arcType:e.ArcType.NONE}});const y=t.lineColor||t.color||e.Color.YELLOW,v=((f=(p=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:f.call(p,.9))||e.Color.RED;this.previewEdgeEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewPos||!this.positions.length?[]:this.positions.concat([this.previewPos,this.positions[0]]),!1),width:t.width||2,material:y,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}});const C=t.pointColor||t.color||e.Color.YELLOW,b=i.entities.add({position:new e.CallbackProperty(()=>this.previewPos||this.positions[this.positions.length-1],!1),point:{pixelSize:8,color:C,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.previewPointEntities.push(b)}},e.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(()=>{var g;if(this.positions.length<3){this.stop();return}if(this.positions.length>=3){this.positions.pop();const p=this.tempPoints.pop();p&&this.viewer.entities.remove(p)}if(this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewEdgeEntity&&(this.viewer.entities.remove(this.previewEdgeEntity),this.previewEdgeEntity=null),this.previewPointEntities.length){for(const p of this.previewPointEntities)try{this.viewer.entities.remove(p)}catch{}this.previewPointEntities=[]}this.previewPos=null,this.stop();const o=new e.Cartesian3(this.positions.reduce((p,f)=>p+f.x,0)/this.positions.length,this.positions.reduce((p,f)=>p+f.y,0)/this.positions.length,this.positions.reduce((p,f)=>p+f.z,0)/this.positions.length),n=new e.EllipsoidTangentPlane(o,e.Ellipsoid.WGS84).projectPointsOntoPlane(this.positions);let r=0;for(let p=0;p<n.length;p++){const f=(p+1)%n.length;r+=n[p].x*n[f].y-n[f].x*n[p].y}r=Math.abs(r)/2;const l=e.Cartographic.fromCartesian(o),c=this.htmlLabelId||`measure_area_${Date.now()}`;this.htmlLabelId=c;const d=t.labelText||{area:"面积",side:"边长",angle:"角度"};this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.htmlLabelPool.add({text:`${d.area}:${r.toFixed(2)} m²`},{id:c,lon:e.Math.toDegrees(l.longitude),lat:e.Math.toDegrees(l.latitude),height:l.height||0,theme:"measure-area",show:!0}),this.labelEntity=this.htmlLabelId;for(let p=0;p<this.positions.length;p++){const f=(p+1)%this.positions.length,w=this.positions[p],y=this.positions[f],v=e.Cartographic.fromCartesian(w),C=e.Cartographic.fromCartesian(y),M=new e.EllipsoidGeodesic(v,C).surfaceDistance,P=new e.Cartesian3((w.x+y.x)/2,(w.y+y.y)/2,(w.z+y.z)/2),L=e.Cartographic.fromCartesian(P),E=`measure_area_seg_${Date.now()}_${p}`;this.segmentLabelIds.push(E),this.htmlLabelPool.add({text:`${d.side}:${M.toFixed(2)} m`},{id:E,lon:e.Math.toDegrees(L.longitude),lat:e.Math.toDegrees(L.latitude),height:L.height||0,theme:"measure-area-seg",show:!0})}const u=n;for(let p=0;p<u.length;p++){const f=u[(p-1+u.length)%u.length],w=u[p],y=u[(p+1)%u.length],v=f.x-w.x,C=f.y-w.y,b=y.x-w.x,M=y.y-w.y,P=Math.sqrt(v*v+C*C),L=Math.sqrt(b*b+M*M);if(!P||!L)continue;const E=v/P*(b/L)+C/P*(M/L),I=Math.acos(Math.min(1,Math.max(-1,E)))*(180/Math.PI),A=e.Cartographic.fromCartesian(this.positions[p]),x=`measure_area_angle_${Date.now()}_${p}`;this.angleLabelIds.push(x),this.htmlLabelPool.add({text:`${d.angle}:${I.toFixed(2)} °`},{id:x,lon:e.Math.toDegrees(A.longitude),lat:e.Math.toDegrees(A.latitude),height:A.height||0,theme:"measure-area-angle",show:!0})}const m={entity:this.primitive,label:this.labelEntity,positions:this.positions,area:r,clear:()=>this.clear()};(g=t.onComplete)==null||g.call(t,m)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){if(this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.primitive&&(this.viewer.scene.primitives.remove(this.primitive),this.primitive=null),this.edgeEntities.length){for(const t of this.edgeEntities)try{this.viewer.entities.remove(t)}catch{}this.edgeEntities=[]}if(this.pointEntities.length){for(const t of this.pointEntities)try{this.viewer.entities.remove(t)}catch{}this.pointEntities=[]}if(this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null,this.previewPos=null),this.previewEdgeEntity&&(this.viewer.entities.remove(this.previewEdgeEntity),this.previewEdgeEntity=null),this.previewPointEntities.length){for(const t of this.previewPointEntities)try{this.viewer.entities.remove(t)}catch{}this.previewPointEntities=[]}this.labelEntity&&(this.viewer.entities.remove(this.labelEntity),this.labelEntity=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.angleLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.angleLabelIds.slice()),this.segmentLabelIds=[],this.angleLabelIds=[],this.tempPoints.forEach(t=>this.viewer.entities.remove(t)),this.tempPoints=[],this.positions=[]}rehydrate(t,e){const i=this.Cesium,o=this.viewer,s=t.options||{},n=(t.positions||[]).map(M=>new i.Cartesian3(M[0],M[1],M[2]));if(n.length<3)return;if(!this.htmlLabelPool){const M=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,M),this.htmlLabelPool.registerTheme("measure-area",{createElement:(P,L)=>{var E;P.innerHTML=String(((E=L==null?void 0:L.data)==null?void 0:E.text)||""),P.style.background="rgba(0,0,0,0.6)",P.style.color="#fff",P.style.font="14px sans-serif",P.style.padding="4px 6px",P.style.borderRadius="4px",P.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-area-seg",{createElement:(P,L)=>{var E;P.innerHTML=String(((E=L==null?void 0:L.data)==null?void 0:E.text)||""),P.style.background="rgba(0,0,0,0.6)",P.style.color="#fff",P.style.font="14px sans-serif",P.style.padding="4px 6px",P.style.borderRadius="4px",P.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-area-angle",{createElement:(P,L)=>{var E;P.innerHTML=String(((E=L==null?void 0:L.data)==null?void 0:E.text)||""),P.style.background="rgba(0,0,0,0.6)",P.style.color="#fff",P.style.font="14px sans-serif",P.style.padding="4px 6px",P.style.borderRadius="4px",P.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}for(const M of n){const P=o.entities.add({position:M,point:{pixelSize:8,color:s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(P)}const r=new i.Cartesian3(n.reduce((M,P)=>M+P.x,0)/n.length,n.reduce((M,P)=>M+P.y,0)/n.length,n.reduce((M,P)=>M+P.z,0)/n.length),c=new i.EllipsoidTangentPlane(r,i.Ellipsoid.WGS84).projectPointsOntoPlane(n);let d=0;for(let M=0;M<c.length;M++){const P=(M+1)%c.length;d+=c[M].x*c[P].y-c[P].x*c[M].y}d=Math.abs(d)/2;const u=i.Cartographic.fromCartesian(r),m=t.id+"_area";this.htmlLabelId=m;const g=s.labelText||{area:"面积",side:"边长",angle:"角度"};this.htmlLabelPool.add({text:`${g.area}:${d.toFixed(2)} m²`},{id:m,lon:i.Math.toDegrees(u.longitude),lat:i.Math.toDegrees(u.latitude),height:u.height||0,theme:"measure-area",show:!0});const p=new i.PolygonHierarchy(n),f=new i.PolygonGeometry({polygonHierarchy:p,vertexFormat:i.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0}),w=new i.GeometryInstance({geometry:f}),y=s.color||i.Color.YELLOW.withAlpha(.4),v=s.color&&s.color.withAlpha?s.color.withAlpha(.25):i.Color.RED.withAlpha(.4),C=new i.Primitive({geometryInstances:w,appearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:y}),translucent:!0,closed:!0}),depthFailAppearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:v}),translucent:!0,closed:!0})});o.scene.primitives.add(C),this.primitive=C;for(let M=0;M<n.length;M++){const P=(M+1)%n.length,L=n[M],E=n[P],I=i.Cartographic.fromCartesian(L),A=i.Cartographic.fromCartesian(E),T=new i.EllipsoidGeodesic(I,A).surfaceDistance,$=new i.Cartesian3((L.x+E.x)/2,(L.y+E.y)/2,(L.z+E.z)/2),D=i.Cartographic.fromCartesian($),k=t.id+`_area_seg_${M}`;this.segmentLabelIds.push(k),this.htmlLabelPool.add({text:`${g.side}:${T.toFixed(2)} m`},{id:k,lon:i.Math.toDegrees(D.longitude),lat:i.Math.toDegrees(D.latitude),height:D.height||0,theme:"measure-area-seg",show:!0})}const b=c;for(let M=0;M<b.length;M++){const P=b[(M-1+b.length)%b.length],L=b[M],E=b[(M+1)%b.length],I=P.x-L.x,A=P.y-L.y,x=E.x-L.x,T=E.y-L.y,$=Math.sqrt(I*I+A*A),D=Math.sqrt(x*x+T*T);if(!$||!D)continue;const k=I/$*(x/D)+A/$*(T/D),_=Math.acos(Math.min(1,Math.max(-1,k)))*(180/Math.PI),O=i.Cartographic.fromCartesian(n[M]),R=t.id+`_area_angle_${M}`;this.angleLabelIds.push(R),this.htmlLabelPool.add({text:`${g.angle}:${_.toFixed(2)} °`},{id:R,lon:i.Math.toDegrees(O.longitude),lat:i.Math.toDegrees(O.latitude),height:O.height||0,theme:"measure-area-angle",show:!0})}}}class qe{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"positions",[]);h(this,"currentRadius",0);h(this,"labelEntity",null);h(this,"previewLabel",null);h(this,"ellipsePrimitive",null);h(this,"previewEntity",null);h(this,"isPrimitive",!1);h(this,"htmlLabelPool",null);h(this,"htmlLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const o=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,o),this.htmlLabelPool.registerTheme("measure-circle",{createElement:(s,n)=>{var l;const r=((l=n==null?void 0:n.data)==null?void 0:l.text)||"";s.innerHTML=String(r),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var n;const s=i.scene.pickPosition(o.position);if(s&&(this.positions.push(s),this.positions.length===2)){this.stop();const r=this.positions[0],l=this.positions[1],c=e.Cartesian3.distance(r,l),d=Math.PI*c*c,u=2*Math.PI*c,m=t.labelText||{radius:"半径",area:"面积",circumference:"周长"},g=r;this.labelEntity?(this.labelEntity.position=g,this.labelEntity.label.text=`${m.radius}:${c.toFixed(2)} m
43
+ }`})()},translucent(){return!0}}),new d(t)}class To{constructor(){l(this,"categoryMap",new Map);l(this,"CategoryGet",{})}registerCategoryGet(t,e){if(!t)return console.warn("分类不能为空");this.CategoryGet[t]=e}register(t){const{themeKey:e,material:i,force:n=!1,category:s="default"}=t;this.categoryMap.has(s)||this.categoryMap.set(s,new Map);const o=this.categoryMap.get(s);if(o.has(e))if(n)console.info(`[MaterialManager] themeKey '${e}' 在分类 '${s}' 已被覆盖`);else{console.warn(`[MaterialManager] 已存在 themeKey '${e}' 在分类 '${s}',如需覆盖请设置 force = true`);return}o.set(e,i)}get({themeKey:t,category:e,options:i}){var s;if(e=e||"default",this.CategoryGet[e])return this.CategoryGet[e]({themeKey:t,materialMap:this.categoryMap,options:i||{}});const n=(s=this.categoryMap.get(e))==null?void 0:s.get(t);return typeof n=="function"&&n.__materialFactory===!0?n(i||{}):n}has(t,e="default"){var i;return((i=this.categoryMap.get(e))==null?void 0:i.has(t))??!1}remove(t,e="default"){const i=this.categoryMap.get(e);if(!i)return;const n=i.get(t);n!=null&&n.destroy&&n.destroy(),i.delete(t),i.size===0&&this.categoryMap.delete(e)}keys(t="default"){var e;return[...((e=this.categoryMap.get(t))==null?void 0:e.keys())||[]]}clearCategory(t="default"){var i;const e=this.categoryMap.get(t);if(e){for(const n of e.values())(i=n==null?void 0:n.destroy)==null||i.call(n);e.clear(),this.categoryMap.delete(t)}}clearAll(){var t;for(const e of this.categoryMap.values())for(const i of e.values())(t=i==null?void 0:i.destroy)==null||t.call(i);this.categoryMap.clear()}categories(){return[...this.categoryMap.keys()]}}class _o{constructor(t){l(this,"id");l(this,"entities",[]);l(this,"primitives",[]);l(this,"dataItem",{});l(this,"aggregator");l(this,"cardPool");const{id:e,entities:i=[],primitives:n=[],dataItem:s={},aggregator:o,cardPool:r}=t;this.id=e,this.entities=i,this.primitives=n,this.dataItem=s,this.aggregator=o,this.cardPool=r}setVisible(t){this.entities.forEach(e=>{e&&(e.show=t)}),this.primitives.forEach(e=>{e&&(e.show=t)}),this.aggregator&&Array.isArray(this.dataItem.billboard)&&this.dataItem.billboard.map((i,n)=>{var o;return{id:this.dataItem.id,data:{...this.dataItem,show:t&&(((o=i.data)==null?void 0:o.show)??!0)}}}).forEach(i=>{var n;(n=this.aggregator)==null||n.updatePoint(i)}),this.cardPool&&this.dataItem.card&&(t?this.cardPool.showByIds([this.dataItem.id]):this.cardPool.hideByIds([this.dataItem.id]))}removeAll(t,e=!0){return this.entities.forEach(i=>{i&&t.entities.remove(i)}),this.entities=[],this.primitives.forEach(i=>{i&&t.scene.primitives.remove(i)}),this.primitives=[],e&&this.aggregator&&Array.isArray(this.dataItem.billboard)&&this.aggregator.removePointsById([this.dataItem.id]),e&&this.cardPool&&this.dataItem.card&&this.cardPool.removeByIds([this.dataItem.id]),this.dataItem.id}}class xo{constructor(t,e,i,n,s,o){l(this,"id");l(this,"groupMap",new Map);l(this,"Cesium");l(this,"viewer");l(this,"materialManager");l(this,"aggregator");l(this,"cardPool");this.id=t,this.Cesium=e,this.viewer=i,this.materialManager=n,this.aggregator=s,this.cardPool=o,this.aggregator.labelPool.eventBus.addListener(V.Click,{name:"BufferedHierarchicalAggregator_maker_click",fn:(h,c)=>{this.cardPool.showByIds([h.data.id])}}),new e.ScreenSpaceEventHandler(i.scene.canvas).setInputAction(()=>{this.cardPool.hideFilter(h=>!h.initShow)},e.ScreenSpaceEventType.LEFT_CLICK)}createPolyline(t,e){if(!t.positions||t.positions.length<1)return null;const i=this.materialManager.get({themeKey:t.theme,category:"polyline",options:t}),n=Array.isArray(t.positions[0])?t.positions.flat():t.positions;let s={...t};return i&&(s.material=i),this.viewer.entities.add({polyline:{...s,positions:this.Cesium.Cartesian3.fromDegreesArrayHeights(n)},show:(t.show??!0)&&e})}createWall(t,e){if(!t.positions||t.positions.length<1)return null;const i=this.materialManager.get({themeKey:t.theme,category:"wall",options:t}),n=(v,C=0)=>{const b=Number(v);return Number.isFinite(b)?b:C},s=t.positions.map(v=>n(v==null?void 0:v[2],0)),o=n(t.minHeight,0),r=n(t.maxHeight,0),h=v=>Array.isArray(v)&&v.length===t.positions.length&&v.every(C=>Math.abs(n(C,0))<1e-6),c=s.some(v=>Math.abs(v)>1e-6),m=(Array.isArray(t.minimumHeights)&&t.minimumHeights.length===t.positions.length&&!(h(t.minimumHeights)&&c)?t.minimumHeights.map(v=>n(v,0)):s).map(v=>v-o),f=(Array.isArray(t.maximumHeights)&&t.maximumHeights.length===t.positions.length&&!(h(t.maximumHeights)&&c)?t.maximumHeights.map(v=>n(v,0)):s).map(v=>v+r),w=t.positions.map(v=>this.Cesium.Cartesian3.fromDegrees(v[0],v[1],v[2]||0));let y={...t};return i&&(y.material=i),this.viewer.entities.add({wall:{...y,positions:w,minimumHeights:m,maximumHeights:f},show:(t.show??!0)&&e})}createPolygon(t,e){var c;if(!t.hierarchy||t.hierarchy.length<1)return null;const i=this.materialManager.get({themeKey:t.theme,category:"polygon",options:t}),n=Array.isArray(t.hierarchy[0])?t.hierarchy.flat():t.hierarchy,s=this.Cesium.Cartesian3.fromDegreesArrayHeights(n),o=((c=t.holes)==null?void 0:c.map(d=>{let u=Array.isArray(d[0])?t.hierarchy.flat():t.hole;return this.Cesium.Cartesian3.fromDegreesArrayHeights(u.flat())}))||[],r=new this.Cesium.PolygonHierarchy(s,o);let h={...t};return i&&(h.material=i),this.viewer.entities.add({polygon:{...h,hierarchy:r},show:(t.show??!0)&&e})}createBillboardPoints(t){var e;return!((e=t.billboard)!=null&&e.length)||!this.aggregator?[]:t.billboard.map(i=>{var r;const[n,s,o=0]=i.position||[0,0,0];return{id:t.id,lon:n,lat:s,height:o,name:((r=i.options)==null?void 0:r.text)||"",data:t,style:{zIndex:t.zIndex||"1"}}})}createCard(t){var e,i,n;(i=(e=t.card)==null?void 0:e.data)!=null&&i.length&&this.cardPool.add(t.card,{id:t.id,lon:t.card.position[0],lat:t.card.position[1],height:t.card.position[3]||0,theme:t.card.theme,show:t.show?t.card.initShow??!1:!1,notCreateElement:!0,style:{width:"0",height:"0",zIndex:((n=t==null?void 0:t.card)==null?void 0:n.zIndex)||"110"}})}addGroup(t,e=!0){const i=t.id||`${Date.now()}`;this.removeGroup(i);const n=[],s=t.show!==!1;(t.polyline||[]).forEach(h=>{const c=this.createPolyline(h,s);c&&n.push(c)}),(t.wall||[]).forEach(h=>{const c=this.createWall(h,s);c&&n.push(c)}),(t.polygon||[]).forEach(h=>{const c=this.createPolygon(h,s);c&&n.push(c)});const o=this.createBillboardPoints(t);o.length&&e&&this.aggregator.appendPoints(o,!1),this.createCard(t);const r=new _o({id:i,entities:n,primitives:[],dataItem:t,aggregator:this.aggregator,cardPool:this.cardPool});return this.groupMap.set(i,r),o}async addGroups(t){const i=t.map(n=>this.addGroup(n,!1)).flat();i.length>0&&this.aggregator&&this.aggregator.appendPoints(i,!1)}removeGroup(t){const e=this.groupMap.get(t);e&&(e.removeAll(this.viewer),this.groupMap.delete(t))}removeGroups(t){let e=[];for(const i of t){const n=this.groupMap.get(i);if(n){let s=n.removeAll(this.viewer,!1);this.groupMap.delete(i),e.push(s)}}this.aggregator.removePointsById(e),this.cardPool.removeByIds(e)}updateGroup(t){const e=this.groupMap.get(t.id);e&&(e.removeAll(this.viewer),this.groupMap.delete(t.id)),this.addGroup(t)}async updateGroups(t){this.aggregator.removePointsById(t.map(n=>n.id)),this.cardPool.removeByIds(t.map(n=>n.id));const i=t.map(n=>{const s=this.groupMap.get(n.id);return s&&(s.removeAll(this.viewer,!1),this.groupMap.delete(n.id)),this.addGroup(n,!1)}).flat();i.length>0&&this.aggregator&&this.aggregator.appendPoints(i,!1)}setGroupVisible(t,e){var i;(i=this.groupMap.get(t))==null||i.setVisible(e)}clearAllGroups(){this.groupMap.forEach(t=>t.removeAll(this.viewer)),this.groupMap.clear()}}class Do{constructor(t,e,i,n,s){l(this,"Cesium");l(this,"viewer");l(this,"layerMap",new Map);l(this,"materialManager");l(this,"aggregator");l(this,"cardPool");this.Cesium=t,this.viewer=e,this.materialManager=i,this.aggregator=n,this.cardPool=s}addLayer(t){this.layerMap.has(t)||this.layerMap.set(t,new xo(t,this.Cesium,this.viewer,this.materialManager,this.aggregator,this.cardPool))}removeLayer(t){const e=this.layerMap.get(t);e&&(e.clearAllGroups(),this.layerMap.delete(t))}getLayer(t){return this.layerMap.get(t)}async addGroupsToLayer(t,e){const i=this.layerMap.get(t);i&&(i.addGroups(e),this.aggregator.refresh())}updateGroupToLayer(t,e){const i=this.layerMap.get(t);i&&(i.updateGroups(e),this.aggregator.refresh())}setGroupVisible(t,e,i){var n;(n=this.layerMap.get(t))==null||n.setGroupVisible(e,i)}removeGroup(t,e){var i;(i=this.layerMap.get(t))==null||i.removeGroup(e)}removeGroups(t,e){var i;(i=this.layerMap.get(t))==null||i.removeGroups(e)}}function So(a){const t=[];return a.features.forEach((e,i)=>{if(e.geometry&&e.properties){const n=e.geometry,s=e.properties,o={id:s.id||`${Date.now()}`,show:!0,zIndex:s.zIndex||1,name:`${s.layer}_${i}`||"",billboard:[],polyline:[],wall:[],polygon:[],card:s.card||null};switch(n.type){case"Point":o.billboard.push({position:n.coordinates,options:s,name:`${s.layer}_${i}`});break;case"LineString":o.polyline.push({positions:n.coordinates,theme:s.theme||"default"});break;case"Polygon":o.polygon.push({hierarchy:n.coordinates[0],theme:s.theme||"default"});break;case"MultiLineString":n.coordinates.forEach(r=>{o.polyline.push({positions:r})});break;case"MultiPolygon":n.coordinates.forEach(r=>{o.polygon.push({hierarchy:r[0]})});break;case"GeometryCollection":n.geometries.forEach(r=>{r.type==="Point"?o.billboard.push({position:r.coordinates}):r.type==="LineString"?o.polyline.push({positions:r.coordinates}):r.type==="Polygon"&&o.polygon.push({hierarchy:r.coordinates[0]})});break;default:console.warn(`Unsupported geometry type: ${n.type}`);break}t.push(o)}}),t}class Ao{constructor(t){l(this,"Cesium");l(this,"viewer");l(this,"layerMap");l(this,"hideLayerMap");l(this,"entityLayerManager");l(this,"PrimitiveThemeMap");l(this,"materialManager");let{Cesium:e,viewer:i,materialManager:n,entityLayerManager:s}=t;this.Cesium=e,this.viewer=i,this.layerMap=new Map,this.PrimitiveThemeMap=new Map,this.hideLayerMap=new Map,this.materialManager=n,this.entityLayerManager=s}createGeometryInstance(t){let e;return t.category==="polyline"&&t.positions?e=this.createPolyline(t):t.category==="polygon"&&t.hierarchy&&(e=this.createPolygon(t)),e}carateThemePrimitive(t){let e=Fe(t),i=this.PrimitiveThemeMap.get(e.theme);if(!i){this.initTheme(e);let n=this.createAppearance(e);i={Primitive:null,ids:new Map,appearance:n,geometryInstances:new Map},this.PrimitiveThemeMap.set(e.theme,i)}return i}initTheme(t){var n,s,o,r,h,c,d,u,m,g,p,f;let e=this.materialManager,i=this.Cesium;if(t.category=="polyline"){const w=((s=(n=t.properties)==null?void 0:n.lineType)==null?void 0:s.pattern)&&((r=(o=t.properties)==null?void 0:o.lineType)==null?void 0:r.patternLength);let y="";if(w){const v=((c=(h=t.properties)==null?void 0:h.lineType)==null?void 0:c.pattern)||[.25,-.125],C=((u=(d=t.properties)==null?void 0:d.lineType)==null?void 0:u.patternLength)||.375;let b=this.convertCadPatternToCesiumDash(v,C);y=`DashedLineMaterial_pattern_${b.dashPattern}_dashLength_${b.dashLength}_color_${(m=t.properties)==null?void 0:m.color}`,e.has(y)||e.register({themeKey:y,material:i.Material.fromType("PolylineDash",{color:i.Color.fromCssColorString(t.properties.color||"#FFFFFF").withAlpha(.8),dashLength:b.dashLength,dashPattern:b.dashPattern})})}else y=`LineMaterial_color_${(g=t.properties)==null?void 0:g.color}`,e.has(y)||e.register({themeKey:y,material:i.Material.fromType("Color",{color:i.Color.fromCssColorString(t.properties.color||"#FFFFFF").withAlpha(.8)})})}else if(t.category=="polygon"){let w=`polygonMaterial_color_${(p=t.properties)==null?void 0:p.color}`;e.has(w)||e.register({themeKey:w,material:i.Material.fromType("Color",{color:i.Color.fromCssColorString(((f=t.properties)==null?void 0:f.color)||"#FFFFFF").withAlpha(.8)})})}}convertCadPatternToCesiumDash(t,e){const n=e/16;let s=[],o=0;for(let h of t){const c=Math.floor(Math.abs(h)/n),d=h>=0?1:0;for(let u=0;u<c&&(s.push(d),o++,!(o>=16));u++);if(o>=16)break}for(;s.length<16;)s.push(0);s.length>16&&(s.length=16);let r=0;for(let h=0;h<16;h++)r=r<<1|s[h];return{dashPattern:r,dashLength:e}}async processBatch(t){const e=new Map;t.forEach(i=>{let{layerId:n,dataList:s}=i;Fe(s).forEach(r=>{let h=this.createGeometryInstance(r);if(h){let c=this.carateThemePrimitive(r);c.ids.set(r.id,r),c.geometryInstances.set(r.id,h);const d=this.layerMap.get(n);if(d)d.set(r.id,r);else{let u=new Map;this.layerMap.set(n,u),u.set(r.id,r)}e.set(r.theme,r)}})}),e.forEach(i=>{this.updatePrimitive(i)})}createPolyline(t){const e=Array.isArray(t.positions[0])?t.positions.flat():t.positions;return new this.Cesium.GeometryInstance({id:t.id,geometry:new this.Cesium.GroundPolylineGeometry({positions:this.Cesium.Cartesian3.fromDegreesArrayHeights(e),width:Math.max(t.width||2,2)})})}createPolygon(t){var o;const e=Array.isArray(t.hierarchy[0])?t.hierarchy.flat():t.hierarchy,i=this.Cesium.Cartesian3.fromDegreesArrayHeights(e),n=((o=t.holes)==null?void 0:o.map(r=>{let h=Array.isArray(r[0])?r.flat():r,c=this.Cesium.Cartesian3.fromDegreesArrayHeights(h.flat());return new this.Cesium.PolygonHierarchy(c)}))||[],s=new this.Cesium.PolygonHierarchy(i,n);return new this.Cesium.GeometryInstance({id:t.id,geometry:new this.Cesium.PolygonGeometry({polygonHierarchy:s})})}getMaterial(t){let e=this.materialManager.get({themeKey:t.theme,options:t});return e||(e=this.Cesium.Material.fromType("Color",{color:new this.Cesium.Color(1,0,0,1)})),e}updateGeometryInstance(t){let e=Fe(t);const i=this.layerMap.get(e.layerId);if(!i){console.warn(`没有找到图层 ${e.layerId}`);return}let n=i.get(e.id);if(i.set(e.id,e),!n){console.warn(`没有找到图元 ${e.id} 在图层 ${e.layerId} 中`);return}if(n.theme!==e.theme){let o=this.PrimitiveThemeMap.get(n.theme);o==null||o.geometryInstances.delete(e.id),o==null||o.ids.delete(e.id),this.updatePrimitive(n)}let s=this.carateThemePrimitive(e);if(s){const o=this.createGeometryInstance(e);s.geometryInstances.set(e.id,o),s.ids.set(e.id,e),this.updatePrimitive(e)}}deleteGeometryInstance(t){let e=new Set;t.forEach(i=>{let{layerId:n,ids:s}=i;const o=this.layerMap.get(n);if(!o){console.warn(`没有找到图层 ${n}`);return}s.forEach(r=>{let h=o.get(r);if(!h){console.warn(`没有找到图元 ${r} 在图层 ${n} 中`);return}let c=this.PrimitiveThemeMap.get(h.theme);c&&(c.geometryInstances.delete(h.id),c.ids.delete(h.id),e.add(h))})}),Array.from(e.values()).forEach(i=>{this.updatePrimitive(i)})}addGeometryInstance(t){let e=Fe(t);const i=this.layerMap.get(e.layerId);if(!i){console.warn(`没有找到图层 ${e.layerId}`);return}if(i.get(e.id)){console.warn(`图元 ${e.id} 已经存在图层 ${e.layerId} 中`);return}i.set(e.id,e);let s=this.carateThemePrimitive(e);if(s){const o=this.createGeometryInstance(e);s.geometryInstances.set(e.id,o),s.ids.set(e.id,e),this.updatePrimitive(e)}}createAppearance(t){let e=this.getMaterial({theme:t.theme}),i;return t.category==="polyline"?i=new this.Cesium.PolylineMaterialAppearance({material:e,translucent:!0}):t.category==="polygon"&&(i=new this.Cesium.MaterialAppearance({material:e,translucent:!0})),i}updatePrimitive(t){const e=this.PrimitiveThemeMap.get(t.theme);if(!e)return;e.Primitive&&(this.viewer.scene.primitives.remove(e.Primitive),e.Primitive=null);let n=Array.from(e.geometryInstances,([s,o])=>({key:s,value:o})).filter(s=>!Array.from(this.hideLayerMap.values()).some(o=>o.has(s.key))).map(s=>s.value);n.length<=0||(t.category==="polyline"?(e.Primitive=new this.Cesium.GroundPolylinePrimitive({geometryInstances:n,appearance:e.appearance}),this.viewer.scene.primitives.add(e.Primitive)):(e.Primitive=new this.Cesium.GroundPrimitive({geometryInstances:n,appearance:e.appearance}),this.viewer.scene.primitives.add(e.Primitive)))}hideByLayerAndId(t){let e=new Map;t.forEach(i=>{let{layerId:n,ids:s}=i,o=this.hideLayerMap.get(n);o||(o=new Set,this.hideLayerMap.set(n,o)),s.forEach(r=>{o.add(r);let h=this.getGeometryInstanceInfo(n,r);h&&e.set(h.theme,h)})}),Array.from(e.values()).forEach(i=>{this.updatePrimitive(i)})}showByLayerAndId(t){let e=new Map;t.forEach(i=>{let{layerId:n,ids:s}=i,o=this.hideLayerMap.get(n);o||(o=new Set,this.hideLayerMap.set(n,o)),s.forEach(r=>{o.delete(r);let h=this.getGeometryInstanceInfo(n,r);h&&e.set(h.theme,h)})}),Array.from(e.values()).forEach(i=>{this.updatePrimitive(i)})}hasGeometryInstance(t,e){const i=this.layerMap.get(t);if(!i)return!1;const n=i.get(e);if(!n)return!1;let s=this.PrimitiveThemeMap.get(n.theme);return!(!s||!s.geometryInstances.get(e))}getGeometryInstanceInfo(t,e){const i=this.layerMap.get(t);return i?i.get(e):null}focusOnGeometryInstance(t,e){const i=this.layerMap.get(t);if(!i){console.warn(`图层 ${t} 不存在`);return}const n=i.get(e);if(!n){console.warn(`没有找到图元 ${e} 在图层 ${t} 中`);return}let s=this.PrimitiveThemeMap.get(n.theme);if(!s){console.warn(`没有找到 ${e} 图元相关的Primitive`);return}const o=s.geometryInstances.get(e);if(!o){console.warn(`没有找到图元的几何体 ${e}`);return}const r=o.geometry,h=r._positions||r._polygonHierarchy.positions;if(h&&h.length>0){let c=h[0].x,d=h[0].y,u=h[0].z,m=h[0].x,g=h[0].y,p=h[0].z;h.forEach(C=>{c=Math.min(c,C.x),d=Math.min(d,C.y),u=Math.min(u,C.z),m=Math.max(m,C.x),g=Math.max(g,C.y),p=Math.max(p,C.z)});const f=new this.Cesium.Cartesian3((c+m)/2,(d+g)/2,(u+p)/2),y=new this.Cesium.Cartesian3(m-c,g-d,p-u).z,v=Math.abs(y||1)*1.5;this.viewer.camera.flyTo({destination:f,duration:2,complete:()=>{console.log(`已定位到图元 ${e}`)},offset:new this.Cesium.Cartesian3(0,0,v)})}else console.warn(`无法获取图元 ${e} 的顶点信息`)}}const Re=class Re{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"positions",[]);l(this,"tempPoints",[]);l(this,"segmentEntities",[]);l(this,"segmentLabelIds",[]);l(this,"previewEntity",null);l(this,"previewGroundEntity",null);l(this,"hoverPos",null);l(this,"htmlLabelPool",null);l(this,"totalLabelId",null);l(this,"previewLabelId",null);l(this,"labelEntity",null);l(this,"firstHeight",null);l(this,"groundLineEntities",[]);l(this,"previewPos",null);l(this,"previewGroundPos",null);l(this,"tooltip",null);l(this,"moveFrameId",null);l(this,"pendingMove",null);l(this,"lastMoveKey",null);l(this,"keydownHandler",null);l(this,"contextMenuHandler",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const n=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,n),this.htmlLabelPool.registerTheme("measure-horizontal-total",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-horizontal-seg",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.tooltip=new ce,this.tooltip.show(Re.TIP_TEXT),this._bindGlobalEvents(t,e,i),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var p,f,w,y;const s=i.scene.pickPosition(n.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(o.longitude),h=e.Math.toDegrees(o.latitude);this.positions.length===0&&(this.firstHeight=o.height||0);const c=e.Cartesian3.fromDegrees(r,h,this.firstHeight||0);this.positions.push(c);const d=i.entities.add({position:c,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(d);const u=s,m=((f=(p=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:f.call(p,.9))||e.Color.RED,g=i.entities.add({polyline:{positions:[u,c],width:t.width||3,material:new e.PolylineDashMaterialProperty({color:m,dashLength:12,dashPattern:255})}});if(this.groundLineEntities.push(g),this.positions.length>=2){const v=this.positions[this.positions.length-2],C=this.positions[this.positions.length-1],b=e.Cartographic.fromCartesian(v),M=e.Cartographic.fromCartesian(C),P=i.entities.add({polyline:{positions:[v,C],width:t.width||3,material:t.lineColor||t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:((y=(w=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:y.call(w,.9))||e.Color.RED,dashLength:12,dashPattern:255})}});this.segmentEntities.push(P);const E=new e.EllipsoidGeodesic(b,M).surfaceDistance,I=new e.Cartesian3((v.x+C.x)/2,(v.y+C.y)/2,(v.z+C.z)/2),D=e.Cartographic.fromCartesian(I),x=`measure_horizontal_seg_${this.segmentLabelIds.length}_${Date.now()}`;this.segmentLabelIds.push(x),this.htmlLabelPool.add({text:`${E.toFixed(2)} m`},{id:x,lon:e.Math.toDegrees(D.longitude),lat:e.Math.toDegrees(D.latitude),height:D.height||this.firstHeight||0,theme:"measure-horizontal-seg",show:!0})}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{this._finishMeasurement(t,e)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.handler.setInputAction(()=>{this._undoLastPoint()},e.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(n=>{var s,o;this.pendingMove={endPosition:{x:(s=n.endPosition)==null?void 0:s.x,y:(o=n.endPosition)==null?void 0:o.y}},this.moveFrameId==null&&(this.moveFrameId=window.requestAnimationFrame(()=>{this.moveFrameId=null;const r=this.pendingMove;if(this.pendingMove=null,!(r!=null&&r.endPosition))return;const h=`${r.endPosition.x}_${r.endPosition.y}`;h!==this.lastMoveKey&&(this.lastMoveKey=h,this._handlePreviewMove(r,t,e,i))}))},e.ScreenSpaceEventType.MOUSE_MOVE)}_handlePreviewMove(t,e,i,n){var C,b,M,P;if(this.positions.length===0)return;const s=n.scene.pickPosition(t.endPosition);if(!s)return;this.hoverPos=s;const o=i.Cartographic.fromCartesian(s),r=i.Math.toDegrees(o.longitude),h=i.Math.toDegrees(o.latitude),c=i.Cartesian3.fromDegrees(r,h,this.firstHeight||0);this.previewPos=c,this.previewGroundPos=s;const d=this.positions[this.positions.length-1],u=i.Cartographic.fromCartesian(d),m=i.Cartographic.fromCartesian(c),p=new i.EllipsoidGeodesic(u,m).surfaceDistance,f=new i.Cartesian3((d.x+c.x)/2,(d.y+c.y)/2,(d.z+c.z)/2),w=i.Cartographic.fromCartesian(f),y=this.previewLabelId||"measure_horizontal_preview";this.previewLabelId=y,this.htmlLabelPool.add({text:`${p.toFixed(2)} m`},{id:y,lon:i.Math.toDegrees(w.longitude),lat:i.Math.toDegrees(w.latitude),height:w.height||this.firstHeight||0,theme:"measure-horizontal-seg",show:!0});const v=((b=(C=e.dashLineColor||e.lineColor||e.color||i.Color.RED).withAlpha)==null?void 0:b.call(C,.9))||i.Color.RED;this.previewGroundEntity||(this.previewGroundEntity=n.entities.add({polyline:{positions:new i.CallbackProperty(()=>!this.previewPos||!this.previewGroundPos?[]:[this.previewGroundPos,this.previewPos],!1),width:e.width||3,material:new i.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}})),this.previewEntity||(this.previewEntity=n.entities.add({polyline:{positions:new i.CallbackProperty(()=>!this.previewPos||!this.positions.length?[]:[this.positions[this.positions.length-1],this.previewPos],!1),width:e.width||3,material:e.lineColor||e.color||i.Color.YELLOW,depthFailMaterial:new i.PolylineDashMaterialProperty({color:((P=(M=e.dashLineColor||e.lineColor||e.color||i.Color.RED).withAlpha)==null?void 0:P.call(M,.9))||i.Color.RED,dashLength:12,dashPattern:255})}}))}_clearPreviewState(){this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewGroundEntity&&(this.viewer.entities.remove(this.previewGroundEntity),this.previewGroundEntity=null),this.previewPos=null,this.previewGroundPos=null,this.hoverPos=null}_undoLastPoint(){if(!this.positions.length)return;this.positions.pop();const t=this.tempPoints.pop();t&&this.viewer.entities.remove(t);const e=this.groundLineEntities.pop();if(e&&this.viewer.entities.remove(e),this.segmentEntities.length>this.positions.length-1){const i=this.segmentEntities.pop();i&&this.viewer.entities.remove(i)}if(this.segmentLabelIds.length>this.positions.length-1&&this.htmlLabelPool){const i=this.segmentLabelIds.pop();i&&this.htmlLabelPool.removeByIds([i])}if(!this.positions.length){this.firstHeight=null,this._clearPreviewState();return}this.totalLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.totalLabelId]),this.totalLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null)}_finishMeasurement(t,e){var h;if(this.positions.length<2){this.clear();return}this.stop(),this._clearPreviewState();let i=0;for(let c=1;c<this.positions.length;c++){const d=this.positions[c-1],u=this.positions[c],m=e.Cartographic.fromCartesian(d),g=e.Cartographic.fromCartesian(u),p=new e.EllipsoidGeodesic(m,g);i+=p.surfaceDistance}const n=this.positions[this.positions.length-1],s=e.Cartographic.fromCartesian(n),o=this.totalLabelId||`measure_horizontal_total_${Date.now()}`;this.totalLabelId=o,this.htmlLabelPool.add({text:`${i.toFixed(2)} m`},{id:o,lon:e.Math.toDegrees(s.longitude),lat:e.Math.toDegrees(s.latitude),height:s.height||this.firstHeight||0,theme:"measure-horizontal-total",show:!0}),this.labelEntity=this.totalLabelId;const r={entity:this.segmentEntities,label:this.labelEntity,segmentLabels:this.segmentLabelIds,positions:this.positions,distance:i,clear:()=>this.clear()};(h=t.onComplete)==null||h.call(t,r)}_bindGlobalEvents(t,e,i){this.keydownHandler=n=>{n.key==="Escape"&&(n.preventDefault(),this._finishMeasurement(t,e))},window.addEventListener("keydown",this.keydownHandler),this.contextMenuHandler=n=>{n.preventDefault()},i.canvas.addEventListener("contextmenu",this.contextMenuHandler)}stop(){this.moveFrameId!=null&&(cancelAnimationFrame(this.moveFrameId),this.moveFrameId=null),this.pendingMove=null,this.lastMoveKey=null,this.keydownHandler&&(window.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.contextMenuHandler&&(this.viewer.canvas.removeEventListener("contextmenu",this.contextMenuHandler),this.contextMenuHandler=null),this.handler&&(this.handler.destroy(),this.handler=null),this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}clear(){this.stop(),this.segmentEntities.forEach(t=>this.viewer.entities.remove(t)),this.segmentEntities=[],this.groundLineEntities.forEach(t=>this.viewer.entities.remove(t)),this.groundLineEntities=[],this.tempPoints.forEach(t=>this.viewer.entities.remove(t)),this.tempPoints=[],this.totalLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.totalLabelId]),this.totalLabelId=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewGroundEntity&&(this.viewer.entities.remove(this.previewGroundEntity),this.previewGroundEntity=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.segmentLabelIds=[],this.positions=[],this.hoverPos=null,this.labelEntity=null,this.firstHeight=null,this.previewPos=null,this.previewGroundPos=null}rehydrate(t,e){var p,f;const i=this.Cesium,n=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,r=((f=(p=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:f.call(p,.9))||i.Color.RED,h=s.width||3,c=(t.positions||[]).map(w=>new i.Cartesian3(w[0],w[1],w[2]));if(!c.length)return;if(!this.htmlLabelPool){const w=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,w),this.htmlLabelPool.registerTheme("measure-horizontal-total",{createElement:(y,v)=>{var C;y.innerHTML=String(((C=v==null?void 0:v.data)==null?void 0:C.text)||""),y.style.background="rgba(0,0,0,0.6)",y.style.color="#fff",y.style.font="14px sans-serif",y.style.padding="4px 6px",y.style.borderRadius="4px",y.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-horizontal-seg",{createElement:(y,v)=>{var C;y.innerHTML=String(((C=v==null?void 0:v.data)==null?void 0:C.text)||""),y.style.background="rgba(0,0,0,0.6)",y.style.color="#fff",y.style.font="14px sans-serif",y.style.padding="4px 6px",y.style.borderRadius="4px",y.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}for(const w of c){const y=n.entities.add({position:w,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(y);const v=i.Cartographic.fromCartesian(w),C=i.Math.toDegrees(v.longitude),b=i.Math.toDegrees(v.latitude),M=n.scene.globe.getHeight(new i.Cartographic(v.longitude,v.latitude,0))||0,P=i.Cartesian3.fromDegrees(C,b,M),L=n.entities.add({polyline:{positions:[P,w],width:h,material:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});this.groundLineEntities.push(L)}for(let w=1;w<c.length;w++){const y=c[w-1],v=c[w],C=n.entities.add({polyline:{positions:[y,v],width:h,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});this.segmentEntities.push(C);const b=i.Cartographic.fromCartesian(y),M=i.Cartographic.fromCartesian(v),L=new i.EllipsoidGeodesic(b,M).surfaceDistance,E=new i.Cartesian3((y.x+v.x)/2,(y.y+v.y)/2,(y.z+v.z)/2),I=i.Cartographic.fromCartesian(E),D=t.id+`_seg_${w-1}`;this.segmentLabelIds.push(D),this.htmlLabelPool.add({text:`${L.toFixed(2)} m`},{id:D,lon:i.Math.toDegrees(I.longitude),lat:i.Math.toDegrees(I.latitude),height:I.height||0,theme:"measure-horizontal-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}let d=0;for(let w=1;w<c.length;w++){const y=i.Cartographic.fromCartesian(c[w-1]),v=i.Cartographic.fromCartesian(c[w]),C=new i.EllipsoidGeodesic(y,v);d+=C.surfaceDistance}const u=c[c.length-1],m=i.Cartographic.fromCartesian(u),g=t.id+"_total";this.totalLabelId=g,this.htmlLabelPool.add({text:`${d.toFixed(2)} m`},{id:g,lon:i.Math.toDegrees(m.longitude),lat:i.Math.toDegrees(m.latitude),height:m.height||0,theme:"measure-horizontal-total",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}};l(Re,"TIP_TEXT","单击左键添加点,右键撤销,双击左键或Esc结束");let _e=Re;class Xe{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"entity",null);l(this,"labelEntity",null);l(this,"positions",[]);l(this,"htmlLabelPool",null);l(this,"htmlLabelId",null);l(this,"previewLabelId",null);l(this,"baseCarto",null);l(this,"baseUp",null);l(this,"tempPoints",[]);l(this,"previewPointEntity",null);l(this,"previewEntity",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const n=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,n),this.htmlLabelPool.registerTheme("measure-vertical",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var r,h,c,d,u;const s=i.camera.getPickRay(n.position);let o=s?i.scene.globe.pick(s,i.scene):null;if(o||(o=i.camera.pickEllipsoid(n.position,e.Ellipsoid.WGS84)),o||(o=i.scene.pickPosition(n.position)),!!o)if(this.positions.length===0){const m=e.Cartographic.fromCartesian(o);this.baseCarto=new e.Cartographic(m.longitude,m.latitude,0);const g=e.Ellipsoid.WGS84.cartographicToCartesian(this.baseCarto);this.baseUp=e.Ellipsoid.WGS84.geodeticSurfaceNormalCartographic(this.baseCarto),this.positions.push(g);const p=i.entities.add({position:g,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(p);const f=t.lineColor||t.color||e.Color.CYAN,w=((h=(r=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:h.call(r,.9))||e.Color.RED;this.previewEntity=i.entities.add({polyline:{positions:[g,g],width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}})}else{if(!this.baseCarto||!this.baseUp)return;const m=this.positions[0],g=i.camera.getPickRay(n.position);if(!g)return;const p=g.origin,f=e.Cartesian3.normalize(g.direction,new e.Cartesian3),w=m,y=this.baseUp,v=e.Cartesian3.subtract(p,w,new e.Cartesian3),C=e.Cartesian3.dot(f,f),b=-e.Cartesian3.dot(f,y),M=e.Cartesian3.dot(y,y),P=-e.Cartesian3.dot(f,v),L=e.Cartesian3.dot(y,v),E=C*M-b*b;if(Math.abs(E)<1e-6)return;const I=(C*L-b*P)/E,D=e.Cartesian3.add(w,e.Cartesian3.multiplyByScalar(y,I,new e.Cartesian3),new e.Cartesian3);this.positions[1]=D,this.stop(),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewPointEntity&&(this.viewer.entities.remove(this.previewPointEntity),this.previewPointEntity=null);const x=t.lineColor||t.color||e.Color.CYAN,T=((d=(c=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:d.call(c,.9))||e.Color.RED;this.entity=i.entities.add({polyline:{positions:[m,D],width:t.width||3,material:x,depthFailMaterial:new e.PolylineDashMaterialProperty({color:T,dashLength:12,dashPattern:255})}});const $=i.entities.add({position:D,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push($);const S=this.baseCarto,O=e.Cartographic.fromCartesian(D),_=Math.abs((O.height||0)-(S.height||0)),k=new e.Cartesian3((this.positions[0].x+this.positions[1].x)/2,(this.positions[0].y+this.positions[1].y)/2,(this.positions[0].z+this.positions[1].z)/2),F=e.Cartographic.fromCartesian(k);this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);const G=this.htmlLabelId||`measure_vertical_${Date.now()}`;this.htmlLabelId=G,this.htmlLabelPool.add({text:`${_.toFixed(2)} m`},{id:G,lon:e.Math.toDegrees(F.longitude),lat:e.Math.toDegrees(F.latitude),height:F.height||0,theme:"measure-vertical",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const B={entity:this.entity,label:this.labelEntity,positions:this.positions,vertical:_,clear:()=>this.clear()};(u=t.onComplete)==null||u.call(t,B)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{var D,x;if(this.positions.length<1)return;if(!this.baseCarto||!this.baseUp){const T=e.Cartographic.fromCartesian(this.positions[0]);this.baseCarto=new e.Cartographic(T.longitude,T.latitude,T.height||0),this.baseUp=e.Ellipsoid.WGS84.geodeticSurfaceNormalCartographic(this.baseCarto)}const s=this.positions[0],o=i.camera.getPickRay(n.endPosition);if(!o)return;const r=o.origin,h=e.Cartesian3.normalize(o.direction,new e.Cartesian3),c=s,d=this.baseUp,u=e.Cartesian3.subtract(r,c,new e.Cartesian3),m=e.Cartesian3.dot(h,h),g=-e.Cartesian3.dot(h,d),p=e.Cartesian3.dot(d,d),f=-e.Cartesian3.dot(h,u),w=e.Cartesian3.dot(d,u),y=m*p-g*g;if(Math.abs(y)<1e-6)return;const v=(m*w-g*f)/y,C=e.Cartesian3.add(c,e.Cartesian3.multiplyByScalar(d,v,new e.Cartesian3),new e.Cartesian3);if(this.positions[1]=C,!this.previewEntity){const T=t.lineColor||t.color||e.Color.CYAN,$=((x=(D=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:x.call(D,.9))||e.Color.RED;this.previewEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>this.positions.length<2?[]:[this.positions[0],this.positions[1]],!1),width:t.width||3,material:T,depthFailMaterial:new e.PolylineDashMaterialProperty({color:$,dashLength:12,dashPattern:255})}})}this.previewPointEntity?this.previewPointEntity.position=C:this.previewPointEntity=i.entities.add({position:C,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});const b=this.baseCarto,M=e.Cartographic.fromCartesian(C),P=Math.abs((M.height||0)-(b.height||0)),L=new e.Cartesian3((this.positions[0].x+C.x)/2,(this.positions[0].y+C.y)/2,(this.positions[0].z+C.z)/2),E=e.Cartographic.fromCartesian(L),I=this.previewLabelId||"measure_vertical_preview";this.previewLabelId=I,this.htmlLabelPool.add({text:`${P.toFixed(2)} m`},{id:I,lon:e.Math.toDegrees(E.longitude),lat:e.Math.toDegrees(E.latitude),height:E.height||0,theme:"measure-vertical",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.labelEntity&&(this.viewer.entities.remove(this.labelEntity),this.labelEntity=null),this.tempPoints.forEach(t=>this.viewer.entities.remove(t)),this.tempPoints=[],this.previewPointEntity&&(this.viewer.entities.remove(this.previewPointEntity),this.previewPointEntity=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.positions=[]}rehydrate(t,e){var b,M;const i=this.Cesium,n=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.CYAN,r=((M=(b=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:M.call(b,.9))||i.Color.RED,h=s.width||3,c=(t.positions||[]).map(P=>new i.Cartesian3(P[0],P[1],P[2]));if(c.length<2)return;if(!this.htmlLabelPool){const P=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,P),this.htmlLabelPool.registerTheme("measure-vertical",{createElement:(L,E)=>{var I;L.innerHTML=String(((I=E==null?void 0:E.data)==null?void 0:I.text)||""),L.style.background="rgba(0,0,0,0.6)",L.style.color="#fff",L.style.font="14px sans-serif",L.style.padding="4px 6px",L.style.borderRadius="4px",L.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const d=c[0],u=c[1],m=n.entities.add({position:d,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),g=n.entities.add({position:u,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(m),this.tempPoints.push(g),this.entity=n.entities.add({polyline:{positions:[d,u],width:h,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});const p=i.Cartographic.fromCartesian(d),f=i.Cartographic.fromCartesian(u),w=Math.abs((f.height||0)-(p.height||0)),y=new i.Cartesian3((d.x+u.x)/2,(d.y+u.y)/2,(d.z+u.z)/2),v=i.Cartographic.fromCartesian(y),C=t.id+"_label";this.htmlLabelId=C,this.htmlLabelPool.add({text:`${w.toFixed(2)} m`},{id:C,lon:i.Math.toDegrees(v.longitude),lat:i.Math.toDegrees(v.latitude),height:v.height||0,theme:"measure-vertical",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}}class Je{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"positions",[]);l(this,"htmlLabelPool",null);l(this,"htmlLabelId",null);l(this,"segmentEntities",[]);l(this,"angleMarkerEntities",[]);l(this,"pointEntities",[]);l(this,"segmentLabelIds",[]);l(this,"angleLabelIds",[]);l(this,"previewLabelId",null);l(this,"previewSegmentEntities",[]);l(this,"previewAngleMarkerEntities",[]);l(this,"previewPointEntity",null);l(this,"previewLow",null);l(this,"previewHigh",null);l(this,"previewThird",null);l(this,"previewMarkerP1",null);l(this,"previewMarkerP2",null);l(this,"previewMarkerCorner",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const n=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,n),this.htmlLabelPool.registerTheme("measure-triangle",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-seg",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-angle",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var r,h,c;const s=i.scene.pickPosition(n.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});if(this.pointEntities.push(o),this.positions.length===2){this.stop(),this.previewSegmentEntities.forEach(J=>i.entities.remove(J)),this.previewSegmentEntities=[],this.previewAngleMarkerEntities.forEach(J=>i.entities.remove(J)),this.previewAngleMarkerEntities=[],this.previewPointEntity&&(i.entities.remove(this.previewPointEntity),this.previewPointEntity=null);const d=e.Cartographic.fromCartesian(this.positions[0]),u=e.Cartographic.fromCartesian(this.positions[1]),m=d.height||0,g=u.height||0,p=m<=g?this.positions[0]:this.positions[1],f=m>g?this.positions[0]:this.positions[1],w=e.Cartographic.fromCartesian(p);e.Cartographic.fromCartesian(f);const y=Math.max(m,g),v=e.Cartesian3.fromDegrees(e.Math.toDegrees(w.longitude),e.Math.toDegrees(w.latitude),y),C=t.lineColor||t.color||e.Color.YELLOW,b=((h=(r=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:h.call(r,.9))||e.Color.RED,M=i.entities.add({polyline:{positions:[p,v],width:t.width||3,material:C,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}}),P=i.entities.add({polyline:{positions:[v,f],width:t.width||3,material:C,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}}),L=i.entities.add({polyline:{positions:[p,f],width:t.width||3,material:C,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}});this.segmentEntities.push(M,P,L);const E=e.Cartesian3.distance(p,v),I=e.Cartesian3.distance(v,f),D=e.Cartesian3.distance(p,f),x=new e.Cartesian3((p.x+v.x)/2,(p.y+v.y)/2,(p.z+v.z)/2),T=new e.Cartesian3((v.x+f.x)/2,(v.y+f.y)/2,(v.z+f.z)/2),$=new e.Cartesian3((p.x+f.x)/2,(p.y+f.y)/2,(p.z+f.z)/2),S=e.Cartographic.fromCartesian(x),O=e.Cartographic.fromCartesian(T),_=e.Cartographic.fromCartesian($),k="measure_triangle_seg_v",F="measure_triangle_seg_h",G="measure_triangle_seg_hyp";this.segmentLabelIds=[k,F,G],this.htmlLabelPool.add({text:`${E.toFixed(2)} m`},{id:k,lon:e.Math.toDegrees(S.longitude),lat:e.Math.toDegrees(S.latitude),height:S.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${I.toFixed(2)} m`},{id:F,lon:e.Math.toDegrees(O.longitude),lat:e.Math.toDegrees(O.latitude),height:O.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${D.toFixed(2)} m`},{id:G,lon:e.Math.toDegrees(_.longitude),lat:e.Math.toDegrees(_.latitude),height:_.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const B=e.Cartesian3.subtract(f,p,new e.Cartesian3),j=e.Cartesian3.subtract(v,p,new e.Cartesian3),X=e.Cartesian3.subtract(v,f,new e.Cartesian3),Z=e.Cartesian3.subtract(p,f,new e.Cartesian3),ae=e.Cartesian3.dot(B,j),ve=Math.sqrt(e.Cartesian3.dot(B,B))*Math.sqrt(e.Cartesian3.dot(j,j)),Ce=e.Cartesian3.dot(X,Z),Se=Math.sqrt(e.Cartesian3.dot(X,X))*Math.sqrt(e.Cartesian3.dot(Z,Z)),Y=Math.acos(Math.min(Math.max(ae/(ve||1),-1),1)),me=Math.acos(Math.min(Math.max(Ce/(Se||1),-1),1)),ne=e.Cartographic.fromCartesian(p),W=e.Cartographic.fromCartesian(f),Q="measure_triangle_angle_a",le="measure_triangle_angle_b";this.angleLabelIds=[Q,le],this.htmlLabelPool.add({text:`${(Y*180/Math.PI).toFixed(2)}°`},{id:Q,lon:e.Math.toDegrees(ne.longitude),lat:e.Math.toDegrees(ne.latitude),height:ne.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${(me*180/Math.PI).toFixed(2)}°`},{id:le,lon:e.Math.toDegrees(W.longitude),lat:e.Math.toDegrees(W.latitude),height:W.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const be=Math.max(.01,Math.min(.5,t.angleMarkerRatio??.2)),U=Math.min(E,I)*be;if(E>.001&&I>.001){const J=e.Cartesian3.normalize(e.Cartesian3.subtract(p,v,new e.Cartesian3),new e.Cartesian3),he=e.Cartesian3.normalize(e.Cartesian3.subtract(f,v,new e.Cartesian3),new e.Cartesian3),ee=new e.Cartesian3(v.x+J.x*U,v.y+J.y*U,v.z+J.z*U),H=new e.Cartesian3(v.x+he.x*U,v.y+he.y*U,v.z+he.z*U),q=new e.Cartesian3(v.x+J.x*U+he.x*U,v.y+J.y*U+he.y*U,v.z+J.z*U+he.z*U),ie=i.entities.add({polyline:{positions:[ee,q],width:t.width||3,material:C,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}}),Ge=i.entities.add({polyline:{positions:[H,q],width:t.width||3,material:C,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}});this.angleMarkerEntities.push(ie,Ge)}this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);const K={entity:this.segmentEntities,positions:[p,f,v],lengths:{vertical:E,horizontal:I,hypotenuse:D},angles:{acuteA:Y,acuteB:me},clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,K)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{var me,ne;if(this.positions.length!==1)return;const s=i.scene.pickPosition(n.endPosition);if(!s)return;const o=e.Cartographic.fromCartesian(this.positions[0]),r=e.Cartographic.fromCartesian(s),h=o.height||0,c=r.height||0,d=h<=c?this.positions[0]:s,u=h>c?this.positions[0]:s,m=e.Cartographic.fromCartesian(d),g=Math.max(h,c),p=e.Cartesian3.fromDegrees(this.Cesium.Math.toDegrees(m.longitude),this.Cesium.Math.toDegrees(m.latitude),g);this.previewLow=d,this.previewHigh=u,this.previewThird=p;const f=t.lineColor||t.color||e.Color.YELLOW,w=((ne=(me=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:ne.call(me,.9))||e.Color.RED;if(this.previewPointEntity?this.previewPointEntity.position=s:this.previewPointEntity=i.entities.add({position:s,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),!this.previewSegmentEntities.length){const W=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewLow||!this.previewThird?[]:[this.previewLow,this.previewThird],!1),width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}}),Q=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewThird||!this.previewHigh?[]:[this.previewThird,this.previewHigh],!1),width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}}),le=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewLow||!this.previewHigh?[]:[this.previewLow,this.previewHigh],!1),width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}});this.previewSegmentEntities.push(W,Q,le)}const y=e.Cartesian3.distance(d,p),v=e.Cartesian3.distance(p,u),C=e.Cartesian3.distance(d,u),b=e.Cartesian3.subtract(u,d,new e.Cartesian3),M=e.Cartesian3.subtract(p,d,new e.Cartesian3),P=e.Cartesian3.subtract(p,u,new e.Cartesian3),L=e.Cartesian3.subtract(d,u,new e.Cartesian3),E=e.Cartesian3.dot(b,M),I=Math.sqrt(e.Cartesian3.dot(b,b))*Math.sqrt(e.Cartesian3.dot(M,M)),D=e.Cartesian3.dot(P,L),x=Math.sqrt(e.Cartesian3.dot(P,P))*Math.sqrt(e.Cartesian3.dot(L,L)),T=Math.acos(Math.min(Math.max(E/(I||1),-1),1)),$=Math.acos(Math.min(Math.max(D/(x||1),-1),1)),S=new e.Cartesian3((d.x+p.x)/2,(d.y+p.y)/2,(d.z+p.z)/2),O=new e.Cartesian3((p.x+u.x)/2,(p.y+u.y)/2,(p.z+u.z)/2),_=new e.Cartesian3((d.x+u.x)/2,(d.y+u.y)/2,(d.z+u.z)/2),k=e.Cartographic.fromCartesian(S),F=e.Cartographic.fromCartesian(O),G=e.Cartographic.fromCartesian(_),B=e.Cartographic.fromCartesian(d),j=e.Cartographic.fromCartesian(u),X="measure_triangle_seg_v",Z="measure_triangle_seg_h",ae="measure_triangle_seg_hyp",ve="measure_triangle_angle_a",Ce="measure_triangle_angle_b";this.segmentLabelIds.length===0&&(this.segmentLabelIds=[X,Z,ae]),this.angleLabelIds.length===0&&(this.angleLabelIds=[ve,Ce]),this.htmlLabelPool.add({text:`${y.toFixed(2)} m`},{id:X,lon:e.Math.toDegrees(k.longitude),lat:e.Math.toDegrees(k.latitude),height:k.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${v.toFixed(2)} m`},{id:Z,lon:e.Math.toDegrees(F.longitude),lat:e.Math.toDegrees(F.latitude),height:F.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${C.toFixed(2)} m`},{id:ae,lon:e.Math.toDegrees(G.longitude),lat:e.Math.toDegrees(G.latitude),height:G.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${(T*180/Math.PI).toFixed(2)}°`},{id:ve,lon:e.Math.toDegrees(B.longitude),lat:e.Math.toDegrees(B.latitude),height:B.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${($*180/Math.PI).toFixed(2)}°`},{id:Ce,lon:e.Math.toDegrees(j.longitude),lat:e.Math.toDegrees(j.latitude),height:j.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const Se=Math.max(.01,Math.min(.5,t.angleMarkerRatio??.2)),Y=Math.min(y,v)*Se;if(y>.001&&v>.001){const W=e.Cartesian3.normalize(e.Cartesian3.subtract(d,p,new e.Cartesian3),new e.Cartesian3),Q=e.Cartesian3.normalize(e.Cartesian3.subtract(u,p,new e.Cartesian3),new e.Cartesian3),le=new e.Cartesian3(p.x+W.x*Y,p.y+W.y*Y,p.z+W.z*Y),be=new e.Cartesian3(p.x+Q.x*Y,p.y+Q.y*Y,p.z+Q.z*Y),U=new e.Cartesian3(p.x+W.x*Y+Q.x*Y,p.y+W.y*Y+Q.y*Y,p.z+W.z*Y+Q.z*Y);if(this.previewMarkerP1=le,this.previewMarkerP2=be,this.previewMarkerCorner=U,!this.previewAngleMarkerEntities.length){const K=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewMarkerP1||!this.previewMarkerCorner?[]:[this.previewMarkerP1,this.previewMarkerCorner],!1),width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}}),J=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewMarkerP2||!this.previewMarkerCorner?[]:[this.previewMarkerP2,this.previewMarkerCorner],!1),width:t.width||3,material:f,depthFailMaterial:new e.PolylineDashMaterialProperty({color:w,dashLength:12,dashPattern:255})}});this.previewAngleMarkerEntities.push(K,J)}}},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.segmentEntities.forEach(t=>this.viewer.entities.remove(t)),this.segmentEntities=[],this.angleMarkerEntities.forEach(t=>this.viewer.entities.remove(t)),this.angleMarkerEntities=[],this.pointEntities.forEach(t=>this.viewer.entities.remove(t)),this.pointEntities=[],this.previewSegmentEntities.forEach(t=>this.viewer.entities.remove(t)),this.previewSegmentEntities=[],this.previewAngleMarkerEntities.forEach(t=>this.viewer.entities.remove(t)),this.previewAngleMarkerEntities=[],this.previewPointEntity&&(this.viewer.entities.remove(this.previewPointEntity),this.previewPointEntity=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.angleLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.angleLabelIds.slice()),this.segmentLabelIds=[],this.angleLabelIds=[],this.positions=[]}rehydrate(t,e){var J,he;const i=this.Cesium,n=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,r=((he=(J=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:he.call(J,.9))||i.Color.RED,h=s.width||3,c=(t.positions||[]).map(ee=>new i.Cartesian3(ee[0],ee[1],ee[2]));if(c.length<2)return;if(!this.htmlLabelPool){const ee=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,ee),this.htmlLabelPool.registerTheme("measure-triangle",{createElement:(H,q)=>{var ie;H.innerHTML=String(((ie=q==null?void 0:q.data)==null?void 0:ie.text)||""),H.style.background="rgba(0,0,0,0.6)",H.style.color="#fff",H.style.font="14px sans-serif",H.style.padding="4px 6px",H.style.borderRadius="4px",H.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-seg",{createElement:(H,q)=>{var ie;H.innerHTML=String(((ie=q==null?void 0:q.data)==null?void 0:ie.text)||""),H.style.background="rgba(0,0,0,0.6)",H.style.color="#fff",H.style.font="14px sans-serif",H.style.padding="4px 6px",H.style.borderRadius="4px",H.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-angle",{createElement:(H,q)=>{var ie;H.innerHTML=String(((ie=q==null?void 0:q.data)==null?void 0:ie.text)||""),H.style.background="rgba(0,0,0,0.6)",H.style.color="#fff",H.style.font="14px sans-serif",H.style.padding="4px 6px",H.style.borderRadius="4px",H.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const d=i.Cartographic.fromCartesian(c[0]),u=i.Cartographic.fromCartesian(c[1]),m=d.height||0,g=u.height||0,p=m<=g?c[0]:c[1],f=m>g?c[0]:c[1],w=n.entities.add({position:p,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),y=n.entities.add({position:f,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(w,y);const v=i.Cartographic.fromCartesian(p),C=Math.max(m,g),b=i.Cartesian3.fromDegrees(i.Math.toDegrees(v.longitude),i.Math.toDegrees(v.latitude),C),M=n.entities.add({polyline:{positions:[p,b],width:h,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}}),P=n.entities.add({polyline:{positions:[b,f],width:h,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}}),L=n.entities.add({polyline:{positions:[p,f],width:h,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});this.segmentEntities.push(M,P,L);const E=i.Cartesian3.distance(p,b),I=i.Cartesian3.distance(b,f),D=i.Cartesian3.distance(p,f),x=new i.Cartesian3((p.x+b.x)/2,(p.y+b.y)/2,(p.z+b.z)/2),T=new i.Cartesian3((b.x+f.x)/2,(b.y+f.y)/2,(b.z+f.z)/2),$=new i.Cartesian3((p.x+f.x)/2,(p.y+f.y)/2,(p.z+f.z)/2),S=i.Cartographic.fromCartesian(x),O=i.Cartographic.fromCartesian(T),_=i.Cartographic.fromCartesian($),k=t.id+"_tri_v",F=t.id+"_tri_h",G=t.id+"_tri_hyp";this.segmentLabelIds=[k,F,G],this.htmlLabelPool.add({text:`${E.toFixed(2)} m`},{id:k,lon:i.Math.toDegrees(S.longitude),lat:i.Math.toDegrees(S.latitude),height:S.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${I.toFixed(2)} m`},{id:F,lon:i.Math.toDegrees(O.longitude),lat:i.Math.toDegrees(O.latitude),height:O.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${D.toFixed(2)} m`},{id:G,lon:i.Math.toDegrees(_.longitude),lat:i.Math.toDegrees(_.latitude),height:_.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const B=i.Cartesian3.subtract(f,p,new i.Cartesian3),j=i.Cartesian3.subtract(b,p,new i.Cartesian3),X=i.Cartesian3.subtract(b,f,new i.Cartesian3),Z=i.Cartesian3.subtract(p,f,new i.Cartesian3),ae=i.Cartesian3.dot(B,j),ve=Math.sqrt(i.Cartesian3.dot(B,B))*Math.sqrt(i.Cartesian3.dot(j,j)),Ce=i.Cartesian3.dot(X,Z),Se=Math.sqrt(i.Cartesian3.dot(X,X))*Math.sqrt(i.Cartesian3.dot(Z,Z)),Y=Math.acos(Math.min(Math.max(ae/(ve||1),-1),1)),me=Math.acos(Math.min(Math.max(Ce/(Se||1),-1),1)),ne=i.Cartographic.fromCartesian(p),W=i.Cartographic.fromCartesian(f),Q=s.labelText||{angle:"角度"},le=t.id+"_tri_angA",be=t.id+"_tri_angB";this.angleLabelIds=[le,be],this.htmlLabelPool.add({text:`${Q.angle}:${(Y*180/Math.PI).toFixed(2)}°`},{id:le,lon:i.Math.toDegrees(ne.longitude),lat:i.Math.toDegrees(ne.latitude),height:ne.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${Q.angle}:${(me*180/Math.PI).toFixed(2)}°`},{id:be,lon:i.Math.toDegrees(W.longitude),lat:i.Math.toDegrees(W.latitude),height:W.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const U=Math.max(.01,Math.min(.5,s.angleMarkerRatio??.2)),K=Math.min(E,I)*U;if(E>.001&&I>.001){const ee=i.Cartesian3.normalize(i.Cartesian3.subtract(p,b,new i.Cartesian3),new i.Cartesian3),H=i.Cartesian3.normalize(i.Cartesian3.subtract(f,b,new i.Cartesian3),new i.Cartesian3),q=new i.Cartesian3(b.x+ee.x*K,b.y+ee.y*K,b.z+ee.z*K),ie=new i.Cartesian3(b.x+H.x*K,b.y+H.y*K,b.z+H.z*K),Ge=new i.Cartesian3(b.x+ee.x*K+H.x*K,b.y+ee.y*K+H.y*K,b.z+ee.z*K+H.z*K),Ho=n.entities.add({polyline:{positions:[q,Ge],width:h,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}}),Fo=n.entities.add({polyline:{positions:[ie,Ge],width:h,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});this.angleMarkerEntities.push(Ho,Fo)}}}class Ze{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"entity",null);l(this,"labelEntity",null);l(this,"positions",[]);l(this,"tempPoints",[]);l(this,"htmlLabelPool",null);l(this,"htmlLabelId",null);l(this,"previewEntity",null);l(this,"previewPos",null);l(this,"previewLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const n=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,n),this.htmlLabelPool.registerTheme("measure-space",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var r,h,c;const s=i.scene.pickPosition(n.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});if(this.tempPoints.push(o),this.positions.length===2){this.stop(),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);const d=this.positions[0],u=this.positions[1],m=t.lineColor||t.color||e.Color.YELLOW,g=((h=(r=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:h.call(r,.9))||e.Color.RED;this.entity=i.entities.add({polyline:{positions:[d,u],width:t.width||3,material:m,depthFailMaterial:new e.PolylineDashMaterialProperty({color:g,dashLength:12,dashPattern:255})}});const p=e.Cartesian3.distance(d,u),f=u,w=e.Cartographic.fromCartesian(f),y=this.htmlLabelId||`measure_space_${Date.now()}`;this.htmlLabelId=y,this.htmlLabelPool.add({text:`${p.toFixed(2)} m`},{id:y,lon:e.Math.toDegrees(w.longitude),lat:e.Math.toDegrees(w.latitude),height:w.height||0,theme:"measure-space",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const v={entity:this.entity,label:this.labelEntity,positions:this.positions,distance:p,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,v)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{var g,p;if(this.positions.length!==1)return;const s=i.scene.pickPosition(n.endPosition);if(!s)return;this.previewPos=s;const o=this.positions[0],r=e.Cartesian3.distance(o,s),h=new e.Cartesian3((o.x+s.x)/2,(o.y+s.y)/2,(o.z+s.z)/2),c=e.Cartographic.fromCartesian(h),d=this.previewLabelId||"measure_space_preview";this.previewLabelId=d,this.htmlLabelPool.add({text:`${r.toFixed(2)} m`},{id:d,lon:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height||0,theme:"measure-space",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const u=t.lineColor||t.color||e.Color.YELLOW,m=((p=(g=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:p.call(g,.9))||e.Color.RED;this.previewEntity||(this.previewEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewPos||!this.positions.length?[]:[this.positions[0],this.previewPos],!1),width:t.width||3,material:u,depthFailMaterial:new e.PolylineDashMaterialProperty({color:m,dashLength:12,dashPattern:255})}}))},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.labelEntity&&(this.viewer.entities.remove(this.labelEntity),this.labelEntity=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.tempPoints.forEach(t=>this.viewer.entities.remove(t)),this.tempPoints=[],this.positions=[]}rehydrate(t,e){var d,u;const i=this.Cesium,n=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,r=((u=(d=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:u.call(d,.9))||i.Color.RED,h=s.width||3,c=(t.positions||[]).map(m=>new i.Cartesian3(m[0],m[1],m[2]));if(c.length){if(!this.htmlLabelPool){const m=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,m),this.htmlLabelPool.registerTheme("measure-space",{createElement:(g,p)=>{var f;g.innerHTML=String(((f=p==null?void 0:p.data)==null?void 0:f.text)||""),g.style.background="rgba(0,0,0,0.6)",g.style.color="#fff",g.style.font="14px sans-serif",g.style.padding="4px 6px",g.style.borderRadius="4px",g.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}if(c.length>=1){const m=n.entities.add({position:c[0],point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(m)}if(c.length>=2){const m=n.entities.add({position:c[1],point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(m),this.entity=n.entities.add({polyline:{positions:[c[0],c[1]],width:h,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});const g=i.Cartesian3.distance(c[0],c[1]),p=i.Cartographic.fromCartesian(c[1]),f=t.id+"_label";this.htmlLabelId=f,this.htmlLabelPool.add({text:`${g.toFixed(2)} m`},{id:f,lon:i.Math.toDegrees(p.longitude),lat:i.Math.toDegrees(p.latitude),height:p.height||0,theme:"measure-space",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}}}}const ze=class ze{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"entity",null);l(this,"labelEntity",null);l(this,"positions",[]);l(this,"tempPoints",[]);l(this,"primitive",null);l(this,"previewEntity",null);l(this,"previewPos",null);l(this,"edgeEntities",[]);l(this,"pointEntities",[]);l(this,"previewEdgeEntity",null);l(this,"previewPointEntities",[]);l(this,"htmlLabelPool",null);l(this,"htmlLabelId",null);l(this,"previewLabelId",null);l(this,"segmentLabelIds",[]);l(this,"angleLabelIds",[]);l(this,"tooltip",null);l(this,"keydownHandler",null);l(this,"contextMenuHandler",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const n=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,n),this.htmlLabelPool.registerTheme("measure-area",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-area-seg",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-area-angle",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.tooltip=new ce,this.tooltip.show(ze.TIP_TEXT),this._bindGlobalEvents(t,e,i),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var m,g;const s=i.scene.pickPosition(n.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(o),this.primitive&&(i.scene.primitives.remove(this.primitive),this.primitive=null);const r=new e.PolygonHierarchy(this.positions.slice()),h=new e.PolygonGeometry({polygonHierarchy:r,vertexFormat:e.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:e.ArcType.NONE}),c=new e.GeometryInstance({geometry:h}),d=t.color||e.Color.YELLOW.withAlpha(.4),u=t.color&&t.color.withAlpha?t.color.withAlpha(.25):e.Color.RED.withAlpha(.4);if(this.primitive=new e.Primitive({geometryInstances:c,appearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:d}),translucent:!0,closed:!0}),depthFailAppearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:u}),translucent:!0,closed:!0})}),i.scene.primitives.add(this.primitive),this.positions.length>=2){if(this.edgeEntities.length){for(const v of this.edgeEntities)try{i.entities.remove(v)}catch{}this.edgeEntities=[]}const p=t.lineColor||t.color||e.Color.YELLOW,f=((g=(m=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:g.call(m,.9))||e.Color.RED,w=this.positions.concat([this.positions[0]]),y=i.entities.add({polyline:{positions:w,width:t.width||2,material:p,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:f,dashLength:12,dashPattern:255})}});this.edgeEntities.push(y)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{var p,f;if(this.positions.length===0)return;const s=i.scene.pickPosition(n.endPosition);if(!s)return;this.previewPos=s;const o=this.positions.concat([s]),r=new e.Cartesian3(o.reduce((w,y)=>w+y.x,0)/o.length,o.reduce((w,y)=>w+y.y,0)/o.length,o.reduce((w,y)=>w+y.z,0)/o.length),c=new e.EllipsoidTangentPlane(r,e.Ellipsoid.WGS84).projectPointsOntoPlane(o);let d=0;for(let w=0;w<c.length;w++){const y=(w+1)%c.length;d+=c[w].x*c[y].y-c[y].x*c[w].y}d=Math.abs(d)/2;const u=e.Cartographic.fromCartesian(r),m=this.previewLabelId||"measure_area_preview";this.previewLabelId=m;const g=t.labelText||{area:"面积"};if(this.htmlLabelPool.add({text:`${g.area}:${d.toFixed(2)} m²`},{id:m,lon:e.Math.toDegrees(u.longitude),lat:e.Math.toDegrees(u.latitude),height:u.height||0,theme:"measure-area",show:!0}),!this.previewEntity){const w=t.color||e.Color.YELLOW.withAlpha(.4);this.previewEntity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>{if(!this.previewPos||!this.positions.length)return;const M=this.positions.concat([this.previewPos]);return new e.PolygonHierarchy(M)},!1),material:w,perPositionHeight:!0,arcType:e.ArcType.NONE}});const y=t.lineColor||t.color||e.Color.YELLOW,v=((f=(p=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:f.call(p,.9))||e.Color.RED;this.previewEdgeEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewPos||!this.positions.length?[]:this.positions.concat([this.previewPos,this.positions[0]]),!1),width:t.width||2,material:y,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}});const C=t.pointColor||t.color||e.Color.YELLOW,b=i.entities.add({position:new e.CallbackProperty(()=>this.previewPos||this.positions[this.positions.length-1],!1),point:{pixelSize:8,color:C,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.previewPointEntities.push(b)}},e.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(()=>{this._finishMeasurement(t,e,!0)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.handler.setInputAction(()=>{this._undoLastPoint(t,e,i)},e.ScreenSpaceEventType.RIGHT_CLICK)}stop(){this.keydownHandler&&(window.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.contextMenuHandler&&(this.viewer.canvas.removeEventListener("contextmenu",this.contextMenuHandler),this.contextMenuHandler=null),this.handler&&(this.handler.destroy(),this.handler=null),this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}clear(){if(this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.primitive&&(this.viewer.scene.primitives.remove(this.primitive),this.primitive=null),this.edgeEntities.length){for(const t of this.edgeEntities)try{this.viewer.entities.remove(t)}catch{}this.edgeEntities=[]}if(this.pointEntities.length){for(const t of this.pointEntities)try{this.viewer.entities.remove(t)}catch{}this.pointEntities=[]}if(this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null,this.previewPos=null),this.previewEdgeEntity&&(this.viewer.entities.remove(this.previewEdgeEntity),this.previewEdgeEntity=null),this.previewPointEntities.length){for(const t of this.previewPointEntities)try{this.viewer.entities.remove(t)}catch{}this.previewPointEntities=[]}this.labelEntity&&(this.viewer.entities.remove(this.labelEntity),this.labelEntity=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.angleLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.angleLabelIds.slice()),this.segmentLabelIds=[],this.angleLabelIds=[],this.tempPoints.forEach(t=>this.viewer.entities.remove(t)),this.tempPoints=[],this.positions=[]}_clearPreviewState(){if(this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewEdgeEntity&&(this.viewer.entities.remove(this.previewEdgeEntity),this.previewEdgeEntity=null),this.previewPointEntities.length){for(const t of this.previewPointEntities)try{this.viewer.entities.remove(t)}catch{}this.previewPointEntities=[]}this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.previewPos=null}_rebuildShape(t,e,i){var c,d;if(this.primitive&&(i.scene.primitives.remove(this.primitive),this.primitive=null),this.edgeEntities.length){for(const u of this.edgeEntities)try{i.entities.remove(u)}catch{}this.edgeEntities=[]}if(!this.positions.length)return;const n=new e.PolygonHierarchy(this.positions.slice()),s=new e.PolygonGeometry({polygonHierarchy:n,vertexFormat:e.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:e.ArcType.NONE}),o=new e.GeometryInstance({geometry:s}),r=t.color||e.Color.YELLOW.withAlpha(.4),h=t.color&&t.color.withAlpha?t.color.withAlpha(.25):e.Color.RED.withAlpha(.4);if(this.primitive=new e.Primitive({geometryInstances:o,appearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:r}),translucent:!0,closed:!0}),depthFailAppearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:h}),translucent:!0,closed:!0})}),i.scene.primitives.add(this.primitive),this.positions.length>=2){const u=t.lineColor||t.color||e.Color.YELLOW,m=((d=(c=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:d.call(c,.9))||e.Color.RED,g=this.positions.concat([this.positions[0]]),p=i.entities.add({polyline:{positions:g,width:t.width||2,material:u,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:m,dashLength:12,dashPattern:255})}});this.edgeEntities.push(p)}}_undoLastPoint(t,e,i){if(!this.positions.length)return;this.positions.pop();const n=this.tempPoints.pop();n&&i.entities.remove(n),this._clearPreviewState(),this._rebuildShape(t,e,i)}_finishMeasurement(t,e,i){var g;if(i&&this.positions.length>=3){this.positions.pop();const p=this.tempPoints.pop();p&&this.viewer.entities.remove(p)}if(this.positions.length<3){this.clear();return}this._clearPreviewState(),this.stop();const n=new e.Cartesian3(this.positions.reduce((p,f)=>p+f.x,0)/this.positions.length,this.positions.reduce((p,f)=>p+f.y,0)/this.positions.length,this.positions.reduce((p,f)=>p+f.z,0)/this.positions.length),o=new e.EllipsoidTangentPlane(n,e.Ellipsoid.WGS84).projectPointsOntoPlane(this.positions);let r=0;for(let p=0;p<o.length;p++){const f=(p+1)%o.length;r+=o[p].x*o[f].y-o[f].x*o[p].y}r=Math.abs(r)/2;const h=e.Cartographic.fromCartesian(n),c=this.htmlLabelId||`measure_area_${Date.now()}`;this.htmlLabelId=c;const d=t.labelText||{area:"面积",side:"边长",angle:"角度"};this.htmlLabelPool.add({text:`${d.area}:${r.toFixed(2)} m²`},{id:c,lon:e.Math.toDegrees(h.longitude),lat:e.Math.toDegrees(h.latitude),height:h.height||0,theme:"measure-area",show:!0}),this.labelEntity=this.htmlLabelId;for(let p=0;p<this.positions.length;p++){const f=(p+1)%this.positions.length,w=this.positions[p],y=this.positions[f],v=e.Cartographic.fromCartesian(w),C=e.Cartographic.fromCartesian(y),M=new e.EllipsoidGeodesic(v,C).surfaceDistance,P=new e.Cartesian3((w.x+y.x)/2,(w.y+y.y)/2,(w.z+y.z)/2),L=e.Cartographic.fromCartesian(P),E=`measure_area_seg_${Date.now()}_${p}`;this.segmentLabelIds.push(E),this.htmlLabelPool.add({text:`${d.side}:${M.toFixed(2)} m`},{id:E,lon:e.Math.toDegrees(L.longitude),lat:e.Math.toDegrees(L.latitude),height:L.height||0,theme:"measure-area-seg",show:!0})}const u=o;for(let p=0;p<u.length;p++){const f=u[(p-1+u.length)%u.length],w=u[p],y=u[(p+1)%u.length],v=f.x-w.x,C=f.y-w.y,b=y.x-w.x,M=y.y-w.y,P=Math.sqrt(v*v+C*C),L=Math.sqrt(b*b+M*M);if(!P||!L)continue;const E=v/P*(b/L)+C/P*(M/L),I=Math.acos(Math.min(1,Math.max(-1,E)))*(180/Math.PI),D=e.Cartographic.fromCartesian(this.positions[p]),x=`measure_area_angle_${Date.now()}_${p}`;this.angleLabelIds.push(x),this.htmlLabelPool.add({text:`${d.angle}:${I.toFixed(2)} °`},{id:x,lon:e.Math.toDegrees(D.longitude),lat:e.Math.toDegrees(D.latitude),height:D.height||0,theme:"measure-area-angle",show:!0})}const m={entity:this.primitive,label:this.labelEntity,positions:this.positions,area:r,clear:()=>this.clear()};(g=t.onComplete)==null||g.call(t,m)}_bindGlobalEvents(t,e,i){this.keydownHandler=n=>{n.key==="Escape"&&(n.preventDefault(),this._finishMeasurement(t,e,!1))},window.addEventListener("keydown",this.keydownHandler),this.contextMenuHandler=n=>{n.preventDefault()},i.canvas.addEventListener("contextmenu",this.contextMenuHandler)}rehydrate(t,e){const i=this.Cesium,n=this.viewer,s=t.options||{},o=(t.positions||[]).map(M=>new i.Cartesian3(M[0],M[1],M[2]));if(o.length<3)return;if(!this.htmlLabelPool){const M=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,M),this.htmlLabelPool.registerTheme("measure-area",{createElement:(P,L)=>{var E;P.innerHTML=String(((E=L==null?void 0:L.data)==null?void 0:E.text)||""),P.style.background="rgba(0,0,0,0.6)",P.style.color="#fff",P.style.font="14px sans-serif",P.style.padding="4px 6px",P.style.borderRadius="4px",P.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-area-seg",{createElement:(P,L)=>{var E;P.innerHTML=String(((E=L==null?void 0:L.data)==null?void 0:E.text)||""),P.style.background="rgba(0,0,0,0.6)",P.style.color="#fff",P.style.font="14px sans-serif",P.style.padding="4px 6px",P.style.borderRadius="4px",P.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-area-angle",{createElement:(P,L)=>{var E;P.innerHTML=String(((E=L==null?void 0:L.data)==null?void 0:E.text)||""),P.style.background="rgba(0,0,0,0.6)",P.style.color="#fff",P.style.font="14px sans-serif",P.style.padding="4px 6px",P.style.borderRadius="4px",P.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}for(const M of o){const P=n.entities.add({position:M,point:{pixelSize:8,color:s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(P)}const r=new i.Cartesian3(o.reduce((M,P)=>M+P.x,0)/o.length,o.reduce((M,P)=>M+P.y,0)/o.length,o.reduce((M,P)=>M+P.z,0)/o.length),c=new i.EllipsoidTangentPlane(r,i.Ellipsoid.WGS84).projectPointsOntoPlane(o);let d=0;for(let M=0;M<c.length;M++){const P=(M+1)%c.length;d+=c[M].x*c[P].y-c[P].x*c[M].y}d=Math.abs(d)/2;const u=i.Cartographic.fromCartesian(r),m=t.id+"_area";this.htmlLabelId=m;const g=s.labelText||{area:"面积",side:"边长",angle:"角度"};this.htmlLabelPool.add({text:`${g.area}:${d.toFixed(2)} m²`},{id:m,lon:i.Math.toDegrees(u.longitude),lat:i.Math.toDegrees(u.latitude),height:u.height||0,theme:"measure-area",show:!0});const p=new i.PolygonHierarchy(o),f=new i.PolygonGeometry({polygonHierarchy:p,vertexFormat:i.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0}),w=new i.GeometryInstance({geometry:f}),y=s.color||i.Color.YELLOW.withAlpha(.4),v=s.color&&s.color.withAlpha?s.color.withAlpha(.25):i.Color.RED.withAlpha(.4),C=new i.Primitive({geometryInstances:w,appearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:y}),translucent:!0,closed:!0}),depthFailAppearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:v}),translucent:!0,closed:!0})});n.scene.primitives.add(C),this.primitive=C;for(let M=0;M<o.length;M++){const P=(M+1)%o.length,L=o[M],E=o[P],I=i.Cartographic.fromCartesian(L),D=i.Cartographic.fromCartesian(E),T=new i.EllipsoidGeodesic(I,D).surfaceDistance,$=new i.Cartesian3((L.x+E.x)/2,(L.y+E.y)/2,(L.z+E.z)/2),S=i.Cartographic.fromCartesian($),O=t.id+`_area_seg_${M}`;this.segmentLabelIds.push(O),this.htmlLabelPool.add({text:`${g.side}:${T.toFixed(2)} m`},{id:O,lon:i.Math.toDegrees(S.longitude),lat:i.Math.toDegrees(S.latitude),height:S.height||0,theme:"measure-area-seg",show:!0})}const b=c;for(let M=0;M<b.length;M++){const P=b[(M-1+b.length)%b.length],L=b[M],E=b[(M+1)%b.length],I=P.x-L.x,D=P.y-L.y,x=E.x-L.x,T=E.y-L.y,$=Math.sqrt(I*I+D*D),S=Math.sqrt(x*x+T*T);if(!$||!S)continue;const O=I/$*(x/S)+D/$*(T/S),_=Math.acos(Math.min(1,Math.max(-1,O)))*(180/Math.PI),k=i.Cartographic.fromCartesian(o[M]),F=t.id+`_area_angle_${M}`;this.angleLabelIds.push(F),this.htmlLabelPool.add({text:`${g.angle}:${_.toFixed(2)} °`},{id:F,lon:i.Math.toDegrees(k.longitude),lat:i.Math.toDegrees(k.latitude),height:k.height||0,theme:"measure-area-angle",show:!0})}}};l(ze,"TIP_TEXT","单击左键添加点,右键撤销,双击左键或Esc结束");let xe=ze;class Qe{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"entity",null);l(this,"positions",[]);l(this,"currentRadius",0);l(this,"labelEntity",null);l(this,"previewLabel",null);l(this,"ellipsePrimitive",null);l(this,"previewEntity",null);l(this,"isPrimitive",!1);l(this,"htmlLabelPool",null);l(this,"htmlLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const n=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,n),this.htmlLabelPool.registerTheme("measure-circle",{createElement:(s,o)=>{var h;const r=((h=o==null?void 0:o.data)==null?void 0:h.text)||"";s.innerHTML=String(r),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var o;const s=i.scene.pickPosition(n.position);if(s&&(this.positions.push(s),this.positions.length===2)){this.stop();const r=this.positions[0],h=this.positions[1],c=e.Cartesian3.distance(r,h),d=Math.PI*c*c,u=2*Math.PI*c,m=t.labelText||{radius:"半径",area:"面积",circumference:"周长"},g=r;this.labelEntity?(this.labelEntity.position=g,this.labelEntity.label.text=`${m.radius}:${c.toFixed(2)} m
44
44
  ${m.area}:${d.toFixed(2)} m²
45
45
  ${m.circumference}:${u.toFixed(2)} m`):this.labelEntity=i.entities.add({position:g,label:{text:`${m.radius}:${c.toFixed(2)} m
46
46
  ${m.area}:${d.toFixed(2)} m²
47
47
  ${m.circumference}:${u.toFixed(2)} m`,font:"14px sans-serif",fillColor:e.Color.WHITE,outlineColor:e.Color.BLACK,outlineWidth:2,style:e.LabelStyle.FILL_AND_OUTLINE,verticalOrigin:e.VerticalOrigin.BOTTOM,pixelOffset:new e.Cartesian2(0,-10),disableDepthTestDistance:Number.POSITIVE_INFINITY,eyeOffset:new e.Cartesian3(0,0,-1e3),showBackground:!0,backgroundColor:e.Color.BLACK.withAlpha(.6),show:!1}}),this.previewEntity&&(i.entities.remove(this.previewEntity),this.previewEntity=null);const p=e.Cartographic.fromCartesian(r),f=new e.EllipseGeometry({center:r,semiMajorAxis:c,semiMinorAxis:c,height:p.height||0,vertexFormat:e.MaterialAppearance.VERTEX_FORMAT}),w=new e.GeometryInstance({geometry:f}),y=t.color||e.Color.YELLOW.withAlpha(.5),v=t.color&&t.color.withAlpha?t.color.withAlpha(.25):e.Color.RED.withAlpha(.4);this.ellipsePrimitive&&(i.scene.primitives.remove(this.ellipsePrimitive),this.ellipsePrimitive=null),this.ellipsePrimitive=new e.Primitive({geometryInstances:w,appearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:y}),translucent:!0,closed:!0}),depthFailAppearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:v}),translucent:!0,closed:!0})}),i.scene.primitives.add(this.ellipsePrimitive),this.entity=this.ellipsePrimitive,this.isPrimitive=!0;const C=e.Cartographic.fromCartesian(r),b=e.Math.toDegrees(C.longitude),M=e.Math.toDegrees(C.latitude),P=C.height||0,L=this.htmlLabelId||`measure_circle_${Date.now()}`;this.htmlLabelId=L;const E=`${m.radius}:${c.toFixed(2)} m
48
48
  ${m.area}:${d.toFixed(2)} m²
49
- ${m.circumference}:${u.toFixed(2)} m`;this.htmlLabelPool.add({text:E},{id:L,lon:b,lat:M,height:P,theme:"measure-circle",show:!0});const I={entity:this.entity,label:this.labelEntity,positions:this.positions,radius:c,area:d,perimeter:u,clear:()=>this.clear()};(n=t.onComplete)==null||n.call(t,I)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(o=>{if(this.positions.length!==1)return;const s=this.positions[0],n=i.camera.getPickRay(o.endPosition),r=i.scene.globe.pick(n,i.scene);if(!r)return;const l=e.Cartesian3.distance(s,r);this.currentRadius=l;const c=e.Cartographic.fromCartesian(s),d=Math.PI*l*l,u=2*Math.PI*l,m=t.labelText||{radius:"半径",area:"面积",circumference:"周长"},g=s;this.labelEntity?(this.labelEntity.position=g,this.labelEntity.label.text=`${m.radius}:${l.toFixed(2)} m
49
+ ${m.circumference}:${u.toFixed(2)} m`;this.htmlLabelPool.add({text:E},{id:L,lon:b,lat:M,height:P,theme:"measure-circle",show:!0});const I={entity:this.entity,label:this.labelEntity,positions:this.positions,radius:c,area:d,perimeter:u,clear:()=>this.clear()};(o=t.onComplete)==null||o.call(t,I)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{if(this.positions.length!==1)return;const s=this.positions[0],o=i.camera.getPickRay(n.endPosition),r=i.scene.globe.pick(o,i.scene);if(!r)return;const h=e.Cartesian3.distance(s,r);this.currentRadius=h;const c=e.Cartographic.fromCartesian(s),d=Math.PI*h*h,u=2*Math.PI*h,m=t.labelText||{radius:"半径",area:"面积",circumference:"周长"},g=s;this.labelEntity?(this.labelEntity.position=g,this.labelEntity.label.text=`${m.radius}:${h.toFixed(2)} m
50
50
  ${m.area}:${d.toFixed(2)} m²
51
- ${m.circumference}:${u.toFixed(2)} m`):this.labelEntity=i.entities.add({position:g,label:{text:`${m.radius}:${l.toFixed(2)} m
51
+ ${m.circumference}:${u.toFixed(2)} m`):this.labelEntity=i.entities.add({position:g,label:{text:`${m.radius}:${h.toFixed(2)} m
52
52
  ${m.area}:${d.toFixed(2)} m²
53
- ${m.circumference}:${u.toFixed(2)} m`,font:"14px sans-serif",fillColor:e.Color.WHITE,outlineColor:e.Color.BLACK,outlineWidth:2,style:e.LabelStyle.FILL_AND_OUTLINE,verticalOrigin:e.VerticalOrigin.BOTTOM,pixelOffset:new e.Cartesian2(0,-10),disableDepthTestDistance:Number.POSITIVE_INFINITY,eyeOffset:new e.Cartesian3(0,0,-1e3),showBackground:!0,backgroundColor:e.Color.BLACK.withAlpha(.6),show:!1}});const p=e.Cartographic.fromCartesian(s),f=e.Math.toDegrees(p.longitude),w=e.Math.toDegrees(p.latitude),y=p.height||0,v=this.htmlLabelId||`measure_circle_${Date.now()}`;this.htmlLabelId=v;const C=`${m.radius}:${l.toFixed(2)} m
53
+ ${m.circumference}:${u.toFixed(2)} m`,font:"14px sans-serif",fillColor:e.Color.WHITE,outlineColor:e.Color.BLACK,outlineWidth:2,style:e.LabelStyle.FILL_AND_OUTLINE,verticalOrigin:e.VerticalOrigin.BOTTOM,pixelOffset:new e.Cartesian2(0,-10),disableDepthTestDistance:Number.POSITIVE_INFINITY,eyeOffset:new e.Cartesian3(0,0,-1e3),showBackground:!0,backgroundColor:e.Color.BLACK.withAlpha(.6),show:!1}});const p=e.Cartographic.fromCartesian(s),f=e.Math.toDegrees(p.longitude),w=e.Math.toDegrees(p.latitude),y=p.height||0,v=this.htmlLabelId||`measure_circle_${Date.now()}`;this.htmlLabelId=v;const C=`${m.radius}:${h.toFixed(2)} m
54
54
  ${m.area}:${d.toFixed(2)} m²
55
- ${m.circumference}:${u.toFixed(2)} m`;if(this.htmlLabelPool.add({text:C},{id:v,lon:f,lat:w,height:y,theme:"measure-circle",show:!0}),!this.previewEntity){const b=t.color||e.Color.YELLOW.withAlpha(.5);this.previewEntity=i.entities.add({position:s,ellipse:{semiMajorAxis:new e.CallbackProperty(()=>this.currentRadius,!1),semiMinorAxis:new e.CallbackProperty(()=>this.currentRadius,!1),height:c.height||0,material:b}})}},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.entity&&(this.isPrimitive?this.viewer.scene.primitives.remove(this.entity):this.viewer.entities.remove(this.entity),this.entity=null,this.isPrimitive=!1),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.labelEntity&&(this.viewer.entities.remove(this.labelEntity),this.labelEntity=null),this.previewLabel&&(this.viewer.entities.remove(this.previewLabel),this.previewLabel=null),this.ellipsePrimitive&&(this.viewer.scene.primitives.remove(this.ellipsePrimitive),this.ellipsePrimitive=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.positions=[],this.currentRadius=0}rehydrate(t,e){const i=this.Cesium,o=this.viewer,s=t.options||{},n=(t.positions||[]).map(P=>new i.Cartesian3(P[0],P[1],P[2]));if(n.length<2)return;if(!this.htmlLabelPool){const P=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,P),this.htmlLabelPool.registerTheme("measure-circle",{createElement:(L,E)=>{var A;const I=((A=E==null?void 0:E.data)==null?void 0:A.text)||"";L.innerHTML=String(I),L.style.background="rgba(0,0,0,0.6)",L.style.color="#fff",L.style.font="14px sans-serif",L.style.padding="4px 6px",L.style.borderRadius="4px",L.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const r=n[0],l=n[1],c=i.Cartesian3.distance(r,l),d=Math.PI*c*c,u=2*Math.PI*c,m=i.Cartographic.fromCartesian(r),g=new i.EllipseGeometry({center:r,semiMajorAxis:c,semiMinorAxis:c,height:m.height||0,vertexFormat:i.MaterialAppearance.VERTEX_FORMAT}),p=new i.GeometryInstance({geometry:g}),f=s.color||i.Color.YELLOW.withAlpha(.5),w=s.color&&s.color.withAlpha?s.color.withAlpha(.25):i.Color.RED.withAlpha(.4),y=new i.Primitive({geometryInstances:p,appearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:f}),translucent:!0,closed:!0}),depthFailAppearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:w}),translucent:!0,closed:!0})});o.scene.primitives.add(y),this.ellipsePrimitive=y,this.entity=y,this.isPrimitive=!0;const v=i.Cartographic.fromCartesian(r),C=t.id+"_circle";this.htmlLabelId=C;const b=s.labelText||{radius:"半径",area:"面积",circumference:"周长"},M=`${b.radius}:${c.toFixed(2)} m
55
+ ${m.circumference}:${u.toFixed(2)} m`;if(this.htmlLabelPool.add({text:C},{id:v,lon:f,lat:w,height:y,theme:"measure-circle",show:!0}),!this.previewEntity){const b=t.color||e.Color.YELLOW.withAlpha(.5);this.previewEntity=i.entities.add({position:s,ellipse:{semiMajorAxis:new e.CallbackProperty(()=>this.currentRadius,!1),semiMinorAxis:new e.CallbackProperty(()=>this.currentRadius,!1),height:c.height||0,material:b}})}},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.entity&&(this.isPrimitive?this.viewer.scene.primitives.remove(this.entity):this.viewer.entities.remove(this.entity),this.entity=null,this.isPrimitive=!1),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.labelEntity&&(this.viewer.entities.remove(this.labelEntity),this.labelEntity=null),this.previewLabel&&(this.viewer.entities.remove(this.previewLabel),this.previewLabel=null),this.ellipsePrimitive&&(this.viewer.scene.primitives.remove(this.ellipsePrimitive),this.ellipsePrimitive=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.positions=[],this.currentRadius=0}rehydrate(t,e){const i=this.Cesium,n=this.viewer,s=t.options||{},o=(t.positions||[]).map(P=>new i.Cartesian3(P[0],P[1],P[2]));if(o.length<2)return;if(!this.htmlLabelPool){const P=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,P),this.htmlLabelPool.registerTheme("measure-circle",{createElement:(L,E)=>{var D;const I=((D=E==null?void 0:E.data)==null?void 0:D.text)||"";L.innerHTML=String(I),L.style.background="rgba(0,0,0,0.6)",L.style.color="#fff",L.style.font="14px sans-serif",L.style.padding="4px 6px",L.style.borderRadius="4px",L.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const r=o[0],h=o[1],c=i.Cartesian3.distance(r,h),d=Math.PI*c*c,u=2*Math.PI*c,m=i.Cartographic.fromCartesian(r),g=new i.EllipseGeometry({center:r,semiMajorAxis:c,semiMinorAxis:c,height:m.height||0,vertexFormat:i.MaterialAppearance.VERTEX_FORMAT}),p=new i.GeometryInstance({geometry:g}),f=s.color||i.Color.YELLOW.withAlpha(.5),w=s.color&&s.color.withAlpha?s.color.withAlpha(.25):i.Color.RED.withAlpha(.4),y=new i.Primitive({geometryInstances:p,appearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:f}),translucent:!0,closed:!0}),depthFailAppearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:w}),translucent:!0,closed:!0})});n.scene.primitives.add(y),this.ellipsePrimitive=y,this.entity=y,this.isPrimitive=!0;const v=i.Cartographic.fromCartesian(r),C=t.id+"_circle";this.htmlLabelId=C;const b=s.labelText||{radius:"半径",area:"面积",circumference:"周长"},M=`${b.radius}:${c.toFixed(2)} m
56
56
  ${b.area}:${d.toFixed(2)} m²
57
- ${b.circumference}:${u.toFixed(2)} m`;this.htmlLabelPool.add({text:M},{id:C,lon:i.Math.toDegrees(v.longitude),lat:i.Math.toDegrees(v.latitude),height:v.height||0,theme:"measure-circle",show:!0})}}class Xe{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"labelEntity",null);h(this,"positions",[]);h(this,"tempPoints",[]);h(this,"segmentLabels",[]);h(this,"hoverPos",null);h(this,"previewPos",null);h(this,"previewLabel",null);h(this,"previewEntity",null);h(this,"htmlLabelPool",null);h(this,"totalLabelId",null);h(this,"segmentLabelIds",[]);h(this,"previewLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const o=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,o),this.htmlLabelPool.registerTheme("measure-polyline-total",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-polyline-seg",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var r,l;const s=i.scene.pickPosition(o.position);if(!s)return;this.positions.push(s);const n=i.entities.add({position:s,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});if(this.tempPoints.push(n),this.entity?this.entity.polyline.positions=this.positions.slice():this.entity=i.entities.add({polyline:{positions:this.positions.slice(),width:t.width||3,material:t.lineColor||t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:((l=(r=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(r,.9))||e.Color.RED,dashLength:12,dashPattern:255})}}),this.positions.length>=2){const c=this.positions[this.positions.length-2],d=this.positions[this.positions.length-1],u=e.Cartographic.fromCartesian(c),m=e.Cartographic.fromCartesian(d),p=new e.EllipsoidGeodesic(u,m).surfaceDistance,f=new e.Cartesian3((c.x+d.x)/2,(c.y+d.y)/2,(c.z+d.z)/2),w=e.Cartographic.fromCartesian(f),y=`measure_polyline_seg_${this.segmentLabelIds.length}_${Date.now()}`;this.segmentLabelIds.push(y),this.htmlLabelPool.add({text:`${p.toFixed(2)} m`},{id:y,lon:e.Math.toDegrees(w.longitude),lat:e.Math.toDegrees(w.latitude),height:w.height||0,theme:"measure-polyline-seg",show:!0})}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var c;if(this.positions.length<2){this.stop();return}if(this.stop(),this.previewLabelId&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.hoverPos&&(this.hoverPos=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.positions.length>=2&&this.tempPoints.length>=2){const d=this.tempPoints[this.tempPoints.length-1];this.viewer.entities.remove(d),this.tempPoints.pop()}if(this.segmentLabelIds.length>=1){const d=this.segmentLabelIds[this.segmentLabelIds.length-1];d&&(this.htmlLabelPool.removeByIds([d]),this.segmentLabelIds.pop())}this.positions.length>=2&&this.positions.pop();let o=0;for(let d=1;d<this.positions.length;d++){const u=this.positions[d-1],m=this.positions[d],g=e.Cartographic.fromCartesian(u),p=e.Cartographic.fromCartesian(m),w=new e.EllipsoidGeodesic(g,p).surfaceDistance;o+=w}const s=this.positions[this.positions.length-1];this.entity&&this.entity.polyline&&(this.entity.polyline.positions=this.positions);const n=e.Cartographic.fromCartesian(s),r=this.totalLabelId||`measure_polyline_total_${Date.now()}`;this.totalLabelId=r,this.htmlLabelPool.add({text:`${o.toFixed(2)} m`},{id:r,lon:e.Math.toDegrees(n.longitude),lat:e.Math.toDegrees(n.latitude),height:n.height||0,theme:"measure-polyline-total",show:!0}),this.labelEntity=this.totalLabelId;const l={entity:this.entity,label:this.labelEntity,segmentLabels:this.segmentLabelIds,positions:this.positions,distance:o,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,l)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.handler.setInputAction(o=>{var p,f;if(this.positions.length===0)return;const s=i.scene.pickPosition(o.endPosition);if(!s)return;this.hoverPos=s,this.previewPos=s;const n=this.positions[this.positions.length-1],r=e.Cartographic.fromCartesian(n),l=e.Cartographic.fromCartesian(s),d=new e.EllipsoidGeodesic(r,l).surfaceDistance,u=new e.Cartesian3((n.x+s.x)/2,(n.y+s.y)/2,(n.z+s.z)/2),m=e.Cartographic.fromCartesian(u),g=this.previewLabelId||"measure_polyline_preview";this.previewLabelId=g,this.htmlLabelPool.add({text:`${d.toFixed(2)} m`},{id:g,lon:e.Math.toDegrees(m.longitude),lat:e.Math.toDegrees(m.latitude),height:m.height||0,theme:"measure-polyline-seg",show:!0}),this.previewEntity||(this.previewEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewPos||!this.positions.length?[]:[this.positions[this.positions.length-1],this.previewPos],!1),width:t.width||3,material:t.lineColor||t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:((f=(p=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:f.call(p,.9))||e.Color.RED,dashLength:12,dashPattern:255})}}))},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.totalLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.totalLabelId]),this.totalLabelId=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.hoverPos=null,this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.segmentLabelIds=[],this.tempPoints.forEach(t=>this.viewer.entities.remove(t)),this.tempPoints=[],this.positions=[]}rehydrate(t,e){var p,f;const i=this.Cesium,o=this.viewer,s=t.options||{},n=s.lineColor||s.color||i.Color.YELLOW,r=((f=(p=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:f.call(p,.9))||i.Color.RED,l=s.width||3,c=(t.positions||[]).map(w=>new i.Cartesian3(w[0],w[1],w[2]));if(c.length<2)return;if(!this.htmlLabelPool){const w=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,w),this.htmlLabelPool.registerTheme("measure-polyline-total",{createElement:(y,v)=>{var C;y.innerHTML=String(((C=v==null?void 0:v.data)==null?void 0:C.text)||""),y.style.background="rgba(0,0,0,0.6)",y.style.color="#fff",y.style.font="14px sans-serif",y.style.padding="4px 6px",y.style.borderRadius="4px",y.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-polyline-seg",{createElement:(y,v)=>{var C;y.innerHTML=String(((C=v==null?void 0:v.data)==null?void 0:C.text)||""),y.style.background="rgba(0,0,0,0.6)",y.style.color="#fff",y.style.font="14px sans-serif",y.style.padding="4px 6px",y.style.borderRadius="4px",y.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}for(const w of c){const y=o.entities.add({position:w,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(y)}this.entity=o.entities.add({polyline:{positions:c,width:l,material:n,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});let d=0;for(let w=1;w<c.length;w++){const y=i.Cartographic.fromCartesian(c[w-1]),v=i.Cartographic.fromCartesian(c[w]),C=new i.EllipsoidGeodesic(y,v);d+=C.surfaceDistance;const b=c[w-1],M=c[w],P=new i.Cartesian3((b.x+M.x)/2,(b.y+M.y)/2,(b.z+M.z)/2),L=i.Cartographic.fromCartesian(P),E=t.id+`_seg_${w-1}`;this.segmentLabelIds.push(E),this.htmlLabelPool.add({text:`${C.surfaceDistance.toFixed(2)} m`},{id:E,lon:i.Math.toDegrees(L.longitude),lat:i.Math.toDegrees(L.latitude),height:L.height||0,theme:"measure-polyline-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}const u=c[c.length-1],m=i.Cartographic.fromCartesian(u),g=t.id+"_total";this.totalLabelId=g,this.htmlLabelPool.add({text:`${d.toFixed(2)} m`},{id:g,lon:i.Math.toDegrees(m.longitude),lat:i.Math.toDegrees(m.latitude),height:m.height||0,theme:"measure-polyline-total",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}}class Je{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"labelEntity",null);h(this,"htmlLabelPool",null);h(this,"htmlLabelId",null);h(this,"topPoint",null);h(this,"zeroPoint",null);h(this,"lineEntity",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const o=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,o),this.htmlLabelPool.registerTheme("measure-terrainHeight",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var w;const s=i.scene.pickPosition(o.position);if(!s)return;const n=e.Cartographic.fromCartesian(s),r=i.scene.globe.getHeight(new e.Cartographic(n.longitude,n.latitude,0))||0,l=e.Math.toDegrees(n.longitude),c=e.Math.toDegrees(n.latitude),d=e.Cartesian3.fromDegrees(l,c,r);this.topPoint=i.entities.add({position:s,point:{pixelSize:8,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.zeroPoint=i.entities.add({position:d,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.lineEntity=i.entities.add({polyline:{positions:[d,s],width:t.width||3,material:t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:e.Color.RED,dashLength:12,dashPattern:255})}});const u=t.labelText||{height:"高差"},m=(n.height||0)-r,g=`${u.height}:${m.toFixed(2)} m`,p=this.htmlLabelId||`measure_terrain_${Date.now()}`;this.htmlLabelId=p,this.htmlLabelPool.add({text:g},{id:p,lon:l,lat:c,height:n.height||0,theme:"measure-terrainHeight",show:!0}),this.labelEntity=this.htmlLabelId;const f={label:this.labelEntity,position:s,zeroPosition:d,line:this.lineEntity,terrainHeight:r,difference:m,clear:()=>this.clear()};(w=t.onComplete)==null||w.call(t,f),this.stop()},e.ScreenSpaceEventType.LEFT_CLICK)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.lineEntity&&(this.viewer.entities.remove(this.lineEntity),this.lineEntity=null),this.topPoint&&(this.viewer.entities.remove(this.topPoint),this.topPoint=null),this.zeroPoint&&(this.viewer.entities.remove(this.zeroPoint),this.zeroPoint=null),this.htmlLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null)}rehydrate(t,e){const i=this.Cesium,o=this.viewer,s=t.options||{},n=(t.positions||[]).map(w=>new i.Cartesian3(w[0],w[1],w[2]));if(n.length<1){const y=(t.data||{}).position;y&&(Array.isArray(y)&&y.length===3?n.push(new i.Cartesian3(y[0],y[1],y[2])):typeof y=="object"&&y&&"x"in y&&"y"in y&&"z"in y&&n.push(new i.Cartesian3(y.x,y.y,y.z)))}if(n.length<1)return;if(!this.htmlLabelPool){const w=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,w),this.htmlLabelPool.registerTheme("measure-terrainHeight",{createElement:(y,v)=>{var C;y.innerHTML=String(((C=v==null?void 0:v.data)==null?void 0:C.text)||""),y.style.background="rgba(0,0,0,0.6)",y.style.color="#fff",y.style.font="14px sans-serif",y.style.padding="4px 6px",y.style.borderRadius="4px",y.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const r=n[0],l=i.Cartographic.fromCartesian(r),c=o.scene.globe.getHeight(new i.Cartographic(l.longitude,l.latitude,0))||0,d=i.Math.toDegrees(l.longitude),u=i.Math.toDegrees(l.latitude),m=i.Cartesian3.fromDegrees(d,u,c);this.topPoint=o.entities.add({position:r,point:{pixelSize:8,color:s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.zeroPoint=o.entities.add({position:m,point:{pixelSize:8,color:i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.lineEntity=o.entities.add({polyline:{positions:[m,r],width:s.width||3,material:s.color||i.Color.YELLOW,depthFailMaterial:new i.PolylineDashMaterialProperty({color:i.Color.RED,dashLength:12,dashPattern:255})}});const g=s.labelText||{height:"高差"},p=(l.height||0)-c,f=t.id+"_terrain";this.htmlLabelId=f,this.htmlLabelPool.add({text:`${g.height}:${p.toFixed(2)} m`},{id:f,lon:d,lat:u,height:l.height||0,theme:"measure-terrainHeight",show:!0})}}class Ze{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"labelEntity",null);h(this,"htmlLabelPool",null);h(this,"htmlLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const o=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,o),this.htmlLabelPool.registerTheme("measure-coordinate",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var g;const s=i.scene.pickPosition(o.position);if(!s)return;const n=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(n.longitude),l=e.Math.toDegrees(n.latitude),c=n.height||0;this.entity=i.entities.add({position:s,point:{pixelSize:10,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});const d=this.htmlLabelId||`measure_coordinate_${Date.now()}`;this.htmlLabelId=d;const u=t.labelText||{lng:"经",lat:"纬",height:"高"};this.htmlLabelPool.add({text:`${u.lng}:${r.toFixed(6)}
58
- ${u.lat}:${l.toFixed(6)}
59
- ${u.height}:${c.toFixed(2)} m`},{id:d,lon:r,lat:l,height:c,theme:"measure-coordinate",show:!0}),this.labelEntity=this.htmlLabelId;const m={entity:this.entity,label:this.labelEntity,lnglat:{lng:r,lat:l,height:c},clear:()=>this.clear()};(g=t.onComplete)==null||g.call(t,m),this.stop()},e.ScreenSpaceEventType.LEFT_CLICK)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.htmlLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null)}rehydrate(t,e){var p;const i=this.Cesium,o=this.viewer,s=t.options||{},n=(t.positions||[]).map(f=>new i.Cartesian3(f[0],f[1],f[2]));if(!n.length){const f=(p=t.data)==null?void 0:p.lnglat;if(f&&typeof f.lng=="number"&&typeof f.lat=="number"){const w=i.Cartesian3.fromDegrees(f.lng,f.lat,f.height||0);n.push(w)}}if(!n.length)return;if(!this.htmlLabelPool){const f=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,f),this.htmlLabelPool.registerTheme("measure-coordinate",{createElement:(w,y)=>{var v;w.innerHTML=String(((v=y==null?void 0:y.data)==null?void 0:v.text)||""),w.style.background="rgba(0,0,0,0.6)",w.style.color="#fff",w.style.font="14px sans-serif",w.style.padding="4px 6px",w.style.borderRadius="4px",w.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const r=n[0],l=i.Cartographic.fromCartesian(r),c=i.Math.toDegrees(l.longitude),d=i.Math.toDegrees(l.latitude),u=l.height||0;this.entity=o.entities.add({position:r,point:{pixelSize:10,color:s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});const m=t.id+"_coord";this.htmlLabelId=m;const g=s.labelText||{lng:"经",lat:"纬",height:"高"};this.htmlLabelPool.add({text:`${g.lng}:${c.toFixed(6)}
57
+ ${b.circumference}:${u.toFixed(2)} m`;this.htmlLabelPool.add({text:M},{id:C,lon:i.Math.toDegrees(v.longitude),lat:i.Math.toDegrees(v.latitude),height:v.height||0,theme:"measure-circle",show:!0})}}const Ne=class Ne{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"entity",null);l(this,"labelEntity",null);l(this,"positions",[]);l(this,"tempPoints",[]);l(this,"segmentLabels",[]);l(this,"hoverPos",null);l(this,"previewPos",null);l(this,"previewLabel",null);l(this,"previewEntity",null);l(this,"htmlLabelPool",null);l(this,"totalLabelId",null);l(this,"segmentLabelIds",[]);l(this,"previewLabelId",null);l(this,"tooltip",null);l(this,"keydownHandler",null);l(this,"contextMenuHandler",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const n=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,n),this.htmlLabelPool.registerTheme("measure-polyline-total",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-polyline-seg",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.tooltip=new ce,this.tooltip.show(Ne.TIP_TEXT),this._bindGlobalEvents(t,e,i),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var r,h;const s=i.scene.pickPosition(n.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});if(this.tempPoints.push(o),this.entity?this.entity.polyline.positions=this.positions.slice():this.entity=i.entities.add({polyline:{positions:this.positions.slice(),width:t.width||3,material:t.lineColor||t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:((h=(r=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:h.call(r,.9))||e.Color.RED,dashLength:12,dashPattern:255})}}),this.positions.length>=2){const c=this.positions[this.positions.length-2],d=this.positions[this.positions.length-1],u=e.Cartographic.fromCartesian(c),m=e.Cartographic.fromCartesian(d),p=new e.EllipsoidGeodesic(u,m).surfaceDistance,f=new e.Cartesian3((c.x+d.x)/2,(c.y+d.y)/2,(c.z+d.z)/2),w=e.Cartographic.fromCartesian(f),y=`measure_polyline_seg_${this.segmentLabelIds.length}_${Date.now()}`;this.segmentLabelIds.push(y),this.htmlLabelPool.add({text:`${p.toFixed(2)} m`},{id:y,lon:e.Math.toDegrees(w.longitude),lat:e.Math.toDegrees(w.latitude),height:w.height||0,theme:"measure-polyline-seg",show:!0})}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{this._finishMeasurement(t,e,!0)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.handler.setInputAction(()=>{this._undoLastPoint()},e.ScreenSpaceEventType.RIGHT_CLICK),this.handler.setInputAction(n=>{var p,f;if(this.positions.length===0)return;const s=i.scene.pickPosition(n.endPosition);if(!s)return;this.hoverPos=s,this.previewPos=s;const o=this.positions[this.positions.length-1],r=e.Cartographic.fromCartesian(o),h=e.Cartographic.fromCartesian(s),d=new e.EllipsoidGeodesic(r,h).surfaceDistance,u=new e.Cartesian3((o.x+s.x)/2,(o.y+s.y)/2,(o.z+s.z)/2),m=e.Cartographic.fromCartesian(u),g=this.previewLabelId||"measure_polyline_preview";this.previewLabelId=g,this.htmlLabelPool.add({text:`${d.toFixed(2)} m`},{id:g,lon:e.Math.toDegrees(m.longitude),lat:e.Math.toDegrees(m.latitude),height:m.height||0,theme:"measure-polyline-seg",show:!0}),this.previewEntity||(this.previewEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.previewPos||!this.positions.length?[]:[this.positions[this.positions.length-1],this.previewPos],!1),width:t.width||3,material:t.lineColor||t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:((f=(p=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:f.call(p,.9))||e.Color.RED,dashLength:12,dashPattern:255})}}))},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.keydownHandler&&(window.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.contextMenuHandler&&(this.viewer.canvas.removeEventListener("contextmenu",this.contextMenuHandler),this.contextMenuHandler=null),this.handler&&(this.handler.destroy(),this.handler=null),this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.totalLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.totalLabelId]),this.totalLabelId=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.hoverPos=null,this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.segmentLabelIds=[],this.tempPoints.forEach(t=>this.viewer.entities.remove(t)),this.tempPoints=[],this.positions=[]}_clearPreviewState(){this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.previewPos=null,this.hoverPos=null}_undoLastPoint(){var e;if(!this.positions.length)return;this.positions.pop();const t=this.tempPoints.pop();if(t&&this.viewer.entities.remove(t),this.segmentLabelIds.length>this.positions.length-1&&this.htmlLabelPool){const i=this.segmentLabelIds.pop();i&&this.htmlLabelPool.removeByIds([i])}(e=this.entity)!=null&&e.polyline&&(this.entity.polyline.positions=this.positions.slice()),this.positions.length?this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null):(this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this._clearPreviewState())}_finishMeasurement(t,e,i){var c;if(i){if(this.positions.length>=2&&this.tempPoints.length>=2){const d=this.tempPoints[this.tempPoints.length-1];this.viewer.entities.remove(d),this.tempPoints.pop()}if(this.segmentLabelIds.length>=1){const d=this.segmentLabelIds[this.segmentLabelIds.length-1];d&&(this.htmlLabelPool.removeByIds([d]),this.segmentLabelIds.pop())}this.positions.length>=2&&this.positions.pop()}if(this.positions.length<2){this.clear();return}this.stop(),this._clearPreviewState();let n=0;for(let d=1;d<this.positions.length;d++){const u=this.positions[d-1],m=this.positions[d],g=e.Cartographic.fromCartesian(u),p=e.Cartographic.fromCartesian(m),f=new e.EllipsoidGeodesic(g,p);n+=f.surfaceDistance}const s=this.positions[this.positions.length-1];this.entity&&this.entity.polyline&&(this.entity.polyline.positions=this.positions);const o=e.Cartographic.fromCartesian(s),r=this.totalLabelId||`measure_polyline_total_${Date.now()}`;this.totalLabelId=r,this.htmlLabelPool.add({text:`${n.toFixed(2)} m`},{id:r,lon:e.Math.toDegrees(o.longitude),lat:e.Math.toDegrees(o.latitude),height:o.height||0,theme:"measure-polyline-total",show:!0}),this.labelEntity=this.totalLabelId;const h={entity:this.entity,label:this.labelEntity,segmentLabels:this.segmentLabelIds,positions:this.positions,distance:n,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,h)}_bindGlobalEvents(t,e,i){this.keydownHandler=n=>{n.key==="Escape"&&(n.preventDefault(),this._finishMeasurement(t,e,!1))},window.addEventListener("keydown",this.keydownHandler),this.contextMenuHandler=n=>{n.preventDefault()},i.canvas.addEventListener("contextmenu",this.contextMenuHandler)}rehydrate(t,e){var p,f;const i=this.Cesium,n=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,r=((f=(p=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:f.call(p,.9))||i.Color.RED,h=s.width||3,c=(t.positions||[]).map(w=>new i.Cartesian3(w[0],w[1],w[2]));if(c.length<2)return;if(!this.htmlLabelPool){const w=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,w),this.htmlLabelPool.registerTheme("measure-polyline-total",{createElement:(y,v)=>{var C;y.innerHTML=String(((C=v==null?void 0:v.data)==null?void 0:C.text)||""),y.style.background="rgba(0,0,0,0.6)",y.style.color="#fff",y.style.font="14px sans-serif",y.style.padding="4px 6px",y.style.borderRadius="4px",y.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-polyline-seg",{createElement:(y,v)=>{var C;y.innerHTML=String(((C=v==null?void 0:v.data)==null?void 0:C.text)||""),y.style.background="rgba(0,0,0,0.6)",y.style.color="#fff",y.style.font="14px sans-serif",y.style.padding="4px 6px",y.style.borderRadius="4px",y.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}for(const w of c){const y=n.entities.add({position:w,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(y)}this.entity=n.entities.add({polyline:{positions:c,width:h,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:r,dashLength:12,dashPattern:255})}});let d=0;for(let w=1;w<c.length;w++){const y=i.Cartographic.fromCartesian(c[w-1]),v=i.Cartographic.fromCartesian(c[w]),C=new i.EllipsoidGeodesic(y,v);d+=C.surfaceDistance;const b=c[w-1],M=c[w],P=new i.Cartesian3((b.x+M.x)/2,(b.y+M.y)/2,(b.z+M.z)/2),L=i.Cartographic.fromCartesian(P),E=t.id+`_seg_${w-1}`;this.segmentLabelIds.push(E),this.htmlLabelPool.add({text:`${C.surfaceDistance.toFixed(2)} m`},{id:E,lon:i.Math.toDegrees(L.longitude),lat:i.Math.toDegrees(L.latitude),height:L.height||0,theme:"measure-polyline-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}const u=c[c.length-1],m=i.Cartographic.fromCartesian(u),g=t.id+"_total";this.totalLabelId=g,this.htmlLabelPool.add({text:`${d.toFixed(2)} m`},{id:g,lon:i.Math.toDegrees(m.longitude),lat:i.Math.toDegrees(m.latitude),height:m.height||0,theme:"measure-polyline-total",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}})}};l(Ne,"TIP_TEXT","单击左键添加点,右键撤销,双击左键或Esc结束");let De=Ne;class et{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"labelEntity",null);l(this,"htmlLabelPool",null);l(this,"htmlLabelId",null);l(this,"topPoint",null);l(this,"zeroPoint",null);l(this,"lineEntity",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const n=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,n),this.htmlLabelPool.registerTheme("measure-terrainHeight",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var w;const s=i.scene.pickPosition(n.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),r=i.scene.globe.getHeight(new e.Cartographic(o.longitude,o.latitude,0))||0,h=e.Math.toDegrees(o.longitude),c=e.Math.toDegrees(o.latitude),d=e.Cartesian3.fromDegrees(h,c,r);this.topPoint=i.entities.add({position:s,point:{pixelSize:8,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.zeroPoint=i.entities.add({position:d,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.lineEntity=i.entities.add({polyline:{positions:[d,s],width:t.width||3,material:t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:e.Color.RED,dashLength:12,dashPattern:255})}});const u=t.labelText||{height:"高差"},m=(o.height||0)-r,g=`${u.height}:${m.toFixed(2)} m`,p=this.htmlLabelId||`measure_terrain_${Date.now()}`;this.htmlLabelId=p,this.htmlLabelPool.add({text:g},{id:p,lon:h,lat:c,height:o.height||0,theme:"measure-terrainHeight",show:!0}),this.labelEntity=this.htmlLabelId;const f={label:this.labelEntity,position:s,zeroPosition:d,line:this.lineEntity,terrainHeight:r,difference:m,clear:()=>this.clear()};(w=t.onComplete)==null||w.call(t,f),this.stop()},e.ScreenSpaceEventType.LEFT_CLICK)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.lineEntity&&(this.viewer.entities.remove(this.lineEntity),this.lineEntity=null),this.topPoint&&(this.viewer.entities.remove(this.topPoint),this.topPoint=null),this.zeroPoint&&(this.viewer.entities.remove(this.zeroPoint),this.zeroPoint=null),this.htmlLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null)}rehydrate(t,e){const i=this.Cesium,n=this.viewer,s=t.options||{},o=(t.positions||[]).map(w=>new i.Cartesian3(w[0],w[1],w[2]));if(o.length<1){const y=(t.data||{}).position;y&&(Array.isArray(y)&&y.length===3?o.push(new i.Cartesian3(y[0],y[1],y[2])):typeof y=="object"&&y&&"x"in y&&"y"in y&&"z"in y&&o.push(new i.Cartesian3(y.x,y.y,y.z)))}if(o.length<1)return;if(!this.htmlLabelPool){const w=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,w),this.htmlLabelPool.registerTheme("measure-terrainHeight",{createElement:(y,v)=>{var C;y.innerHTML=String(((C=v==null?void 0:v.data)==null?void 0:C.text)||""),y.style.background="rgba(0,0,0,0.6)",y.style.color="#fff",y.style.font="14px sans-serif",y.style.padding="4px 6px",y.style.borderRadius="4px",y.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const r=o[0],h=i.Cartographic.fromCartesian(r),c=n.scene.globe.getHeight(new i.Cartographic(h.longitude,h.latitude,0))||0,d=i.Math.toDegrees(h.longitude),u=i.Math.toDegrees(h.latitude),m=i.Cartesian3.fromDegrees(d,u,c);this.topPoint=n.entities.add({position:r,point:{pixelSize:8,color:s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.zeroPoint=n.entities.add({position:m,point:{pixelSize:8,color:i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.lineEntity=n.entities.add({polyline:{positions:[m,r],width:s.width||3,material:s.color||i.Color.YELLOW,depthFailMaterial:new i.PolylineDashMaterialProperty({color:i.Color.RED,dashLength:12,dashPattern:255})}});const g=s.labelText||{height:"高差"},p=(h.height||0)-c,f=t.id+"_terrain";this.htmlLabelId=f,this.htmlLabelPool.add({text:`${g.height}:${p.toFixed(2)} m`},{id:f,lon:d,lat:u,height:h.height||0,theme:"measure-terrainHeight",show:!0})}}class tt{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"entity",null);l(this,"labelEntity",null);l(this,"htmlLabelPool",null);l(this,"htmlLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const n=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,n),this.htmlLabelPool.registerTheme("measure-coordinate",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var g;const s=i.scene.pickPosition(n.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(o.longitude),h=e.Math.toDegrees(o.latitude),c=o.height||0;this.entity=i.entities.add({position:s,point:{pixelSize:10,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});const d=this.htmlLabelId||`measure_coordinate_${Date.now()}`;this.htmlLabelId=d;const u=t.labelText||{lng:"经",lat:"纬",height:"高"};this.htmlLabelPool.add({text:`${u.lng}:${r.toFixed(6)}
58
+ ${u.lat}:${h.toFixed(6)}
59
+ ${u.height}:${c.toFixed(2)} m`},{id:d,lon:r,lat:h,height:c,theme:"measure-coordinate",show:!0}),this.labelEntity=this.htmlLabelId;const m={entity:this.entity,label:this.labelEntity,lnglat:{lng:r,lat:h,height:c},clear:()=>this.clear()};(g=t.onComplete)==null||g.call(t,m),this.stop()},e.ScreenSpaceEventType.LEFT_CLICK)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.htmlLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null)}rehydrate(t,e){var p;const i=this.Cesium,n=this.viewer,s=t.options||{},o=(t.positions||[]).map(f=>new i.Cartesian3(f[0],f[1],f[2]));if(!o.length){const f=(p=t.data)==null?void 0:p.lnglat;if(f&&typeof f.lng=="number"&&typeof f.lat=="number"){const w=i.Cartesian3.fromDegrees(f.lng,f.lat,f.height||0);o.push(w)}}if(!o.length)return;if(!this.htmlLabelPool){const f=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,f),this.htmlLabelPool.registerTheme("measure-coordinate",{createElement:(w,y)=>{var v;w.innerHTML=String(((v=y==null?void 0:y.data)==null?void 0:v.text)||""),w.style.background="rgba(0,0,0,0.6)",w.style.color="#fff",w.style.font="14px sans-serif",w.style.padding="4px 6px",w.style.borderRadius="4px",w.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const r=o[0],h=i.Cartographic.fromCartesian(r),c=i.Math.toDegrees(h.longitude),d=i.Math.toDegrees(h.latitude),u=h.height||0;this.entity=n.entities.add({position:r,point:{pixelSize:10,color:s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});const m=t.id+"_coord";this.htmlLabelId=m;const g=s.labelText||{lng:"经",lat:"纬",height:"高"};this.htmlLabelPool.add({text:`${g.lng}:${c.toFixed(6)}
60
60
  ${g.lat}:${d.toFixed(6)}
61
- ${g.height}:${u.toFixed(2)} m`},{id:m,lon:c,lat:d,height:u,theme:"measure-coordinate",show:!0})}}class Qe{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"startPoint",null);h(this,"endPoint",null);h(this,"secondPoint",null);h(this,"currentCorners",[]);h(this,"edgeEntities",[]);h(this,"pointEntities",[]);h(this,"previewEdgeEntity",null);h(this,"previewPointEntities",[]);h(this,"entity",null);h(this,"labelEntity",null);h(this,"primitive",null);h(this,"previewEntity",null);h(this,"htmlLabelPool",null);h(this,"htmlLabelId",null);h(this,"segmentLabelIds",[]);h(this,"previewLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const o=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,o),this.htmlLabelPool.registerTheme("measure-rectangle",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-rectangle-seg",{createElement:(s,n)=>{var r;s.innerHTML=String(((r=n==null?void 0:n.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(o=>{var $,D,k;const s=i.scene.pickPosition(o.position);if(!s)return;if(!this.startPoint){this.startPoint=s;return}if(!this.secondPoint){this.secondPoint=s,this.endPoint=s;return}const n=s,r=this.computeRectangle(this.startPoint,this.secondPoint,n);if(!r){this.stop();return}this.stop();const{corners:l,center:c,width:d,height:u,area:m}=r;this.previewEntity&&(i.entities.remove(this.previewEntity),this.previewEntity=null),this.primitive&&(i.scene.primitives.remove(this.primitive),this.primitive=null),this.entity&&(i.entities.remove(this.entity),this.entity=null);const g=this.htmlLabelId||`measure_rectangle_${Date.now()}`;this.htmlLabelId=g;const p=e.Cartographic.fromCartesian(c),f=t.labelText||{width:"宽",heightLabel:"高",area:"面积",side:"边长"};this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.htmlLabelPool.add({text:`${f.width}:${d.toFixed(2)} m
61
+ ${g.height}:${u.toFixed(2)} m`},{id:m,lon:c,lat:d,height:u,theme:"measure-coordinate",show:!0})}}class it{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"startPoint",null);l(this,"endPoint",null);l(this,"secondPoint",null);l(this,"currentCorners",[]);l(this,"edgeEntities",[]);l(this,"pointEntities",[]);l(this,"previewEdgeEntity",null);l(this,"previewPointEntities",[]);l(this,"entity",null);l(this,"labelEntity",null);l(this,"primitive",null);l(this,"previewEntity",null);l(this,"htmlLabelPool",null);l(this,"htmlLabelId",null);l(this,"segmentLabelIds",[]);l(this,"previewLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer;if(!this.htmlLabelPool){const n=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,n),this.htmlLabelPool.registerTheme("measure-rectangle",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-rectangle-seg",{createElement:(s,o)=>{var r;s.innerHTML=String(((r=o==null?void 0:o.data)==null?void 0:r.text)||""),s.style.background="rgba(0,0,0,0.6)",s.style.color="#fff",s.style.font="14px sans-serif",s.style.padding="4px 6px",s.style.borderRadius="4px",s.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(n=>{var $,S,O;const s=i.scene.pickPosition(n.position);if(!s)return;if(!this.startPoint){this.startPoint=s;return}if(!this.secondPoint){this.secondPoint=s,this.endPoint=s;return}const o=s,r=this.computeRectangle(this.startPoint,this.secondPoint,o);if(!r){this.stop();return}this.stop();const{corners:h,center:c,width:d,height:u,area:m}=r;this.previewEntity&&(i.entities.remove(this.previewEntity),this.previewEntity=null),this.primitive&&(i.scene.primitives.remove(this.primitive),this.primitive=null),this.entity&&(i.entities.remove(this.entity),this.entity=null);const g=this.htmlLabelId||`measure_rectangle_${Date.now()}`;this.htmlLabelId=g;const p=e.Cartographic.fromCartesian(c),f=t.labelText||{width:"宽",heightLabel:"高",area:"面积",side:"边长"};this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.htmlLabelPool.add({text:`${f.width}:${d.toFixed(2)} m
62
62
  ${f.heightLabel}:${u.toFixed(2)} m
63
- ${f.area}:${m.toFixed(2)} m²`},{id:g,lon:e.Math.toDegrees(p.longitude),lat:e.Math.toDegrees(p.latitude),height:p.height||0,theme:"measure-rectangle",show:!0});const w=[[l[0],l[1]],[l[1],l[2]],[l[2],l[3]],[l[3],l[0]]];for(let _=0;_<w.length;_++){const[O,R]=w[_],G=_===0||_===2?d:u,B=new e.Cartesian3((O.x+R.x)/2,(O.y+R.y)/2,(O.z+R.z)/2),j=e.Cartographic.fromCartesian(B),X=`measure_rectangle_seg_${Date.now()}_${_}`;this.segmentLabelIds.push(X),this.htmlLabelPool.add({text:`${f.side}:${Number(G).toFixed(2)} m`},{id:X,lon:e.Math.toDegrees(j.longitude),lat:e.Math.toDegrees(j.latitude),height:j.height||0,theme:"measure-rectangle-seg",show:!0})}const y=this.buildSurfaceRectanglePositions(l),v=new e.PolygonHierarchy(y),C=new e.PolygonGeometry({polygonHierarchy:v,vertexFormat:e.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:e.ArcType.NONE}),b=new e.GeometryInstance({geometry:C}),M=t.color||e.Color.YELLOW.withAlpha(.4),P=t.color&&t.color.withAlpha?t.color.withAlpha(.25):e.Color.RED.withAlpha(.4);this.primitive=new e.Primitive({geometryInstances:b,appearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:M}),translucent:!0,closed:!0}),depthFailAppearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:P}),translucent:!0,closed:!0})}),i.scene.primitives.add(this.primitive);const L=t.lineColor||t.color||e.Color.YELLOW,E=((D=($=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:D.call($,.9))||e.Color.RED,I=[...y,y[0]],A=i.entities.add({polyline:{positions:I,width:t.width||2,material:L,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:E,dashLength:12,dashPattern:255})}});this.edgeEntities.push(A);const x=t.pointColor||t.color||e.Color.YELLOW;for(const _ of l){const O=i.entities.add({position:_,point:{pixelSize:8,color:x,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(O)}const T={entity:this.primitive,label:this.labelEntity,positions:[this.startPoint,this.secondPoint,n],width:d,height:u,area:m,clear:()=>this.clear()};(k=t.onComplete)==null||k.call(t,T)},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(o=>{var w,y;const s=i.scene.pickPosition(o.endPosition);if(!s)return;if(this.startPoint&&!this.secondPoint){if(this.endPoint=s,!this.previewEdgeEntity){const v=t.lineColor||t.color||e.Color.YELLOW,C=((y=(w=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:y.call(w,.9))||e.Color.RED;this.previewEdgeEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.startPoint||!this.endPoint?[]:[this.startPoint,this.endPoint],!1),width:t.width||2,material:v,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:C,dashLength:12,dashPattern:255})}});const b=t.pointColor||t.color||e.Color.YELLOW,M=i.entities.add({position:this.startPoint,point:{pixelSize:8,color:b,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),P=i.entities.add({position:new e.CallbackProperty(()=>this.endPoint||this.startPoint,!1),point:{pixelSize:8,color:b,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.previewPointEntities.push(M,P)}return}if(!this.startPoint||!this.secondPoint)return;const n=this.computeRectangle(this.startPoint,this.secondPoint,s);if(!n)return;const{corners:r,center:l,width:c,height:d,area:u}=n,m=this.buildSurfaceRectanglePositions(r);this.currentCorners=m;const g=e.Cartographic.fromCartesian(l),p=this.previewLabelId||"measure_rectangle_preview";this.previewLabelId=p;const f=t.labelText||{width:"宽",heightLabel:"高",area:"面积"};if(this.htmlLabelPool.add({text:`${f.width}:${c.toFixed(2)} m
63
+ ${f.area}:${m.toFixed(2)} m²`},{id:g,lon:e.Math.toDegrees(p.longitude),lat:e.Math.toDegrees(p.latitude),height:p.height||0,theme:"measure-rectangle",show:!0});const w=[[h[0],h[1]],[h[1],h[2]],[h[2],h[3]],[h[3],h[0]]];for(let _=0;_<w.length;_++){const[k,F]=w[_],G=_===0||_===2?d:u,B=new e.Cartesian3((k.x+F.x)/2,(k.y+F.y)/2,(k.z+F.z)/2),j=e.Cartographic.fromCartesian(B),X=`measure_rectangle_seg_${Date.now()}_${_}`;this.segmentLabelIds.push(X),this.htmlLabelPool.add({text:`${f.side}:${Number(G).toFixed(2)} m`},{id:X,lon:e.Math.toDegrees(j.longitude),lat:e.Math.toDegrees(j.latitude),height:j.height||0,theme:"measure-rectangle-seg",show:!0})}const y=this.buildSurfaceRectanglePositions(h),v=new e.PolygonHierarchy(y),C=new e.PolygonGeometry({polygonHierarchy:v,vertexFormat:e.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:e.ArcType.NONE}),b=new e.GeometryInstance({geometry:C}),M=t.color||e.Color.YELLOW.withAlpha(.4),P=t.color&&t.color.withAlpha?t.color.withAlpha(.25):e.Color.RED.withAlpha(.4);this.primitive=new e.Primitive({geometryInstances:b,appearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:M}),translucent:!0,closed:!0}),depthFailAppearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:P}),translucent:!0,closed:!0})}),i.scene.primitives.add(this.primitive);const L=t.lineColor||t.color||e.Color.YELLOW,E=((S=($=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:S.call($,.9))||e.Color.RED,I=[...y,y[0]],D=i.entities.add({polyline:{positions:I,width:t.width||2,material:L,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:E,dashLength:12,dashPattern:255})}});this.edgeEntities.push(D);const x=t.pointColor||t.color||e.Color.YELLOW;for(const _ of h){const k=i.entities.add({position:_,point:{pixelSize:8,color:x,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(k)}const T={entity:this.primitive,label:this.labelEntity,positions:[this.startPoint,this.secondPoint,o],width:d,height:u,area:m,clear:()=>this.clear()};(O=t.onComplete)==null||O.call(t,T)},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(n=>{var w,y;const s=i.scene.pickPosition(n.endPosition);if(!s)return;if(this.startPoint&&!this.secondPoint){if(this.endPoint=s,!this.previewEdgeEntity){const v=t.lineColor||t.color||e.Color.YELLOW,C=((y=(w=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:y.call(w,.9))||e.Color.RED;this.previewEdgeEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.startPoint||!this.endPoint?[]:[this.startPoint,this.endPoint],!1),width:t.width||2,material:v,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:C,dashLength:12,dashPattern:255})}});const b=t.pointColor||t.color||e.Color.YELLOW,M=i.entities.add({position:this.startPoint,point:{pixelSize:8,color:b,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),P=i.entities.add({position:new e.CallbackProperty(()=>this.endPoint||this.startPoint,!1),point:{pixelSize:8,color:b,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.previewPointEntities.push(M,P)}return}if(!this.startPoint||!this.secondPoint)return;const o=this.computeRectangle(this.startPoint,this.secondPoint,s);if(!o)return;const{corners:r,center:h,width:c,height:d,area:u}=o,m=this.buildSurfaceRectanglePositions(r);this.currentCorners=m;const g=e.Cartographic.fromCartesian(h),p=this.previewLabelId||"measure_rectangle_preview";this.previewLabelId=p;const f=t.labelText||{width:"宽",heightLabel:"高",area:"面积"};if(this.htmlLabelPool.add({text:`${f.width}:${c.toFixed(2)} m
64
64
  ${f.heightLabel}:${d.toFixed(2)} m
65
- ${f.area}:${u.toFixed(2)} m²`},{id:p,lon:e.Math.toDegrees(g.longitude),lat:e.Math.toDegrees(g.latitude),height:g.height||0,theme:"measure-rectangle",show:!0}),!this.previewEntity){const v=t.color||e.Color.YELLOW.withAlpha(.4);this.previewEntity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>{if(!(!this.startPoint||!this.secondPoint||!this.currentCorners.length))return new e.PolygonHierarchy(this.currentCorners)},!1),material:v,perPositionHeight:!0,arcType:e.ArcType.NONE}})}},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){if(this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewEdgeEntity&&(this.viewer.entities.remove(this.previewEdgeEntity),this.previewEdgeEntity=null),this.previewPointEntities.length){for(const t of this.previewPointEntities)try{this.viewer.entities.remove(t)}catch{}this.previewPointEntities=[]}if(this.edgeEntities.length){for(const t of this.edgeEntities)try{this.viewer.entities.remove(t)}catch{}this.edgeEntities=[]}if(this.pointEntities.length){for(const t of this.pointEntities)try{this.viewer.entities.remove(t)}catch{}this.pointEntities=[]}this.primitive&&(this.viewer.scene.primitives.remove(this.primitive),this.primitive=null),this.htmlLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.segmentLabelIds=[],this.startPoint=null,this.endPoint=null,this.secondPoint=null,this.currentCorners=[]}buildSurfaceRectanglePositions(t){return!t||!t.length?[]:t.slice()}rehydrate(t,e){const i=this.Cesium,o=this.viewer,s=t.options||{},n=(t.positions||[]).map(x=>new i.Cartesian3(x[0],x[1],x[2]));if(n.length<3)return;if(!this.htmlLabelPool){const x=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,x),this.htmlLabelPool.registerTheme("measure-rectangle",{createElement:(T,$)=>{var D;T.innerHTML=String(((D=$==null?void 0:$.data)==null?void 0:D.text)||""),T.style.background="rgba(0,0,0,0.6)",T.style.color="#fff",T.style.font="14px sans-serif",T.style.padding="4px 6px",T.style.borderRadius="4px",T.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-rectangle-seg",{createElement:(T,$)=>{var D;T.innerHTML=String(((D=$==null?void 0:$.data)==null?void 0:D.text)||""),T.style.background="rgba(0,0,0,0.6)",T.style.color="#fff",T.style.font="14px sans-serif",T.style.padding="4px 6px",T.style.borderRadius="4px",T.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const r=this.computeRectangle(n[0],n[1],n[2]);if(!r)return;const l=r.corners,c=r.center,d=r.width,u=r.height,m=r.area,g=i.Cartographic.fromCartesian(c),p=t.id+"_rectangle",f=s.labelText||{width:"宽",heightLabel:"高",area:"面积",side:"边长"};this.htmlLabelId=p,this.htmlLabelPool.add({text:`${f.width}:${d.toFixed(2)} m
65
+ ${f.area}:${u.toFixed(2)} m²`},{id:p,lon:e.Math.toDegrees(g.longitude),lat:e.Math.toDegrees(g.latitude),height:g.height||0,theme:"measure-rectangle",show:!0}),!this.previewEntity){const v=t.color||e.Color.YELLOW.withAlpha(.4);this.previewEntity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>{if(!(!this.startPoint||!this.secondPoint||!this.currentCorners.length))return new e.PolygonHierarchy(this.currentCorners)},!1),material:v,perPositionHeight:!0,arcType:e.ArcType.NONE}})}},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){if(this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewEdgeEntity&&(this.viewer.entities.remove(this.previewEdgeEntity),this.previewEdgeEntity=null),this.previewPointEntities.length){for(const t of this.previewPointEntities)try{this.viewer.entities.remove(t)}catch{}this.previewPointEntities=[]}if(this.edgeEntities.length){for(const t of this.edgeEntities)try{this.viewer.entities.remove(t)}catch{}this.edgeEntities=[]}if(this.pointEntities.length){for(const t of this.pointEntities)try{this.viewer.entities.remove(t)}catch{}this.pointEntities=[]}this.primitive&&(this.viewer.scene.primitives.remove(this.primitive),this.primitive=null),this.htmlLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.segmentLabelIds=[],this.startPoint=null,this.endPoint=null,this.secondPoint=null,this.currentCorners=[]}buildSurfaceRectanglePositions(t){return!t||!t.length?[]:t.slice()}rehydrate(t,e){const i=this.Cesium,n=this.viewer,s=t.options||{},o=(t.positions||[]).map(x=>new i.Cartesian3(x[0],x[1],x[2]));if(o.length<3)return;if(!this.htmlLabelPool){const x=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,x),this.htmlLabelPool.registerTheme("measure-rectangle",{createElement:(T,$)=>{var S;T.innerHTML=String(((S=$==null?void 0:$.data)==null?void 0:S.text)||""),T.style.background="rgba(0,0,0,0.6)",T.style.color="#fff",T.style.font="14px sans-serif",T.style.padding="4px 6px",T.style.borderRadius="4px",T.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-rectangle-seg",{createElement:(T,$)=>{var S;T.innerHTML=String(((S=$==null?void 0:$.data)==null?void 0:S.text)||""),T.style.background="rgba(0,0,0,0.6)",T.style.color="#fff",T.style.font="14px sans-serif",T.style.padding="4px 6px",T.style.borderRadius="4px",T.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}const r=this.computeRectangle(o[0],o[1],o[2]);if(!r)return;const h=r.corners,c=r.center,d=r.width,u=r.height,m=r.area,g=i.Cartographic.fromCartesian(c),p=t.id+"_rectangle",f=s.labelText||{width:"宽",heightLabel:"高",area:"面积",side:"边长"};this.htmlLabelId=p,this.htmlLabelPool.add({text:`${f.width}:${d.toFixed(2)} m
66
66
  ${f.heightLabel}:${u.toFixed(2)} m
67
- ${f.area}:${m.toFixed(2)} m²`},{id:p,lon:i.Math.toDegrees(g.longitude),lat:i.Math.toDegrees(g.latitude),height:g.height||0,theme:"measure-rectangle",show:!0});const w=[[l[0],l[1]],[l[1],l[2]],[l[2],l[3]],[l[3],l[0]]];for(let x=0;x<w.length;x++){const[T,$]=w[x],D=x===0||x===2?d:u,k=new i.Cartesian3((T.x+$.x)/2,(T.y+$.y)/2,(T.z+$.z)/2),_=i.Cartographic.fromCartesian(k),O=t.id+`_rectangle_seg_${x}`;this.segmentLabelIds.push(O),this.htmlLabelPool.add({text:`${f.side}:${Number(D).toFixed(2)} m`},{id:O,lon:i.Math.toDegrees(_.longitude),lat:i.Math.toDegrees(_.latitude),height:_.height||0,theme:"measure-rectangle-seg",show:!0})}const y=new i.PolygonHierarchy(l),v=new i.PolygonGeometry({polygonHierarchy:y,vertexFormat:i.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:i.ArcType.NONE}),C=new i.GeometryInstance({geometry:v}),b=s.color||i.Color.YELLOW.withAlpha(.4),M=s.color&&s.color.withAlpha?s.color.withAlpha(.25):i.Color.RED.withAlpha(.4),P=new i.Primitive({geometryInstances:C,appearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:b}),translucent:!0,closed:!0}),depthFailAppearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:M}),translucent:!0,closed:!0})});this.primitive=P,o.scene.primitives.add(this.primitive);const L=s.lineColor||b,E=[...l,l[0]],I=o.entities.add({polyline:{positions:E,width:s.width||2,material:L,clampToGround:!1,arcType:i.ArcType.NONE}});this.edgeEntities.push(I);const A=s.pointColor||b;for(const x of l){const T=o.entities.add({position:x,point:{pixelSize:8,color:A,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(T)}}computeRectangle(t,e,i){const o=this.Cesium,s=new o.EllipsoidTangentPlane(t,o.Ellipsoid.WGS84),n=s.projectPointsOntoPlane([t,e,i]);if(!n||n.length<3)return null;const r=n[0],l=n[1],c=n[2],d=l.x-r.x,u=l.y-r.y,m=Math.sqrt(d*d+u*u);if(!m)return null;const g=d/m,f=-(u/m),w=g,y=c.x-l.x,v=c.y-l.y,C=y*f+v*w;if(!C)return null;const b=new o.Cartesian2(l.x+f*C,l.y+w*C),M=new o.Cartesian2(r.x+f*C,r.y+w*C),P=s.projectPointsOntoEllipsoid([r,l,b,M]);if(!P||P.length<4)return null;const L=P,E=L[0],I=L[2],A=Math.abs(m),x=Math.abs(C),T=new o.Cartesian3((E.x+I.x)/2,(E.y+I.y)/2,(E.z+I.z)/2),D=new o.EllipsoidTangentPlane(T,o.Ellipsoid.WGS84).projectPointsOntoPlane(L);let k=0;for(let O=0;O<D.length;O++){const R=(O+1)%D.length;k+=D[O].x*D[R].y-D[R].x*D[O].y}const _=Math.abs(k)/2;return{corners:L,center:T,width:A,height:x,area:_}}}class et{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"entity",null);h(this,"positions",[]);h(this,"labelEntity",null);h(this,"currentPoints",[]);h(this,"primitive",null);h(this,"previewEntity",null);h(this,"edgeEntities",[]);h(this,"pointEntities",[]);h(this,"previewEdgeEntity",null);h(this,"previewPointEntities",[]);h(this,"htmlLabelPool",null);h(this,"htmlLabelId",null);h(this,"segmentLabelIds",[]);h(this,"previewLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer,o=Math.max(t.sides||6,6);if(!this.htmlLabelPool){const s=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,s),this.htmlLabelPool.registerTheme("measure-regular",{createElement:(n,r)=>{var l;n.innerHTML=String(((l=r==null?void 0:r.data)==null?void 0:l.text)||""),n.style.background="rgba(0,0,0,0.6)",n.style.color="#fff",n.style.font="14px sans-serif",n.style.padding="4px 6px",n.style.borderRadius="4px",n.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-regular-seg",{createElement:(n,r)=>{var l;n.innerHTML=String(((l=r==null?void 0:r.data)==null?void 0:l.text)||""),n.style.background="rgba(0,0,0,0.6)",n.style.color="#fff",n.style.font="14px sans-serif",n.style.padding="4px 6px",n.style.borderRadius="4px",n.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(s=>{var r,l,c;const n=i.scene.pickPosition(s.position);if(n&&(this.positions.push(n),this.positions.length===2)){this.stop();const d=this.positions[0],u=this.positions[1],m=e.Cartesian3.distance(d,u),g=this.buildRegularPolygonPoints(d,m,o);this.previewEntity&&(i.entities.remove(this.previewEntity),this.previewEntity=null),this.primitive&&(i.scene.primitives.remove(this.primitive),this.primitive=null);const p=new e.PolygonHierarchy(g),f=new e.PolygonGeometry({polygonHierarchy:p,vertexFormat:e.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:e.ArcType.NONE}),w=new e.GeometryInstance({geometry:f}),y=t.color||e.Color.YELLOW.withAlpha(.4),v=t.color&&t.color.withAlpha?t.color.withAlpha(.25):e.Color.RED.withAlpha(.4);this.primitive=new e.Primitive({geometryInstances:w,appearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:y}),translucent:!0,closed:!0}),depthFailAppearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:v}),translucent:!0,closed:!0})}),i.scene.primitives.add(this.primitive);const C=t.lineColor||y,b=((l=(r=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(r,.9))||e.Color.RED,M=g.slice(),P=i.entities.add({polyline:{positions:M,width:t.width||2,material:C,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}});this.edgeEntities.push(P);const L=t.pointColor||y,E=g.slice(0,g.length-1);for(const k of E){const _=i.entities.add({position:k,point:{pixelSize:8,color:L,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(_)}const I=this.computeAreaByPlane(g),A=e.Cartographic.fromCartesian(d),x=this.htmlLabelId||`measure_regular_${Date.now()}`;this.htmlLabelId=x;const T=t.labelText||{sides:"边数",radius:"半径",circumference:"周长",area:"面积",side:"边长"};this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);let $=0;for(let k=1;k<g.length;k++){const _=g[k-1],O=g[k],R=e.Cartographic.fromCartesian(_),G=e.Cartographic.fromCartesian(O),j=new e.EllipsoidGeodesic(R,G).surfaceDistance;$+=j;const X=new e.Cartesian3((_.x+O.x)/2,(_.y+O.y)/2,(_.z+O.z)/2),Z=e.Cartographic.fromCartesian(X),ae=`measure_regular_seg_${Date.now()}_${k-1}`;this.segmentLabelIds.push(ae),this.htmlLabelPool.add({text:`${T.side}:${j.toFixed(2)} m`},{id:ae,lon:e.Math.toDegrees(Z.longitude),lat:e.Math.toDegrees(Z.latitude),height:Z.height||0,theme:"measure-regular-seg",show:!0})}this.htmlLabelPool.add({text:`${T.sides}:${o}
67
+ ${f.area}:${m.toFixed(2)} m²`},{id:p,lon:i.Math.toDegrees(g.longitude),lat:i.Math.toDegrees(g.latitude),height:g.height||0,theme:"measure-rectangle",show:!0});const w=[[h[0],h[1]],[h[1],h[2]],[h[2],h[3]],[h[3],h[0]]];for(let x=0;x<w.length;x++){const[T,$]=w[x],S=x===0||x===2?d:u,O=new i.Cartesian3((T.x+$.x)/2,(T.y+$.y)/2,(T.z+$.z)/2),_=i.Cartographic.fromCartesian(O),k=t.id+`_rectangle_seg_${x}`;this.segmentLabelIds.push(k),this.htmlLabelPool.add({text:`${f.side}:${Number(S).toFixed(2)} m`},{id:k,lon:i.Math.toDegrees(_.longitude),lat:i.Math.toDegrees(_.latitude),height:_.height||0,theme:"measure-rectangle-seg",show:!0})}const y=new i.PolygonHierarchy(h),v=new i.PolygonGeometry({polygonHierarchy:y,vertexFormat:i.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:i.ArcType.NONE}),C=new i.GeometryInstance({geometry:v}),b=s.color||i.Color.YELLOW.withAlpha(.4),M=s.color&&s.color.withAlpha?s.color.withAlpha(.25):i.Color.RED.withAlpha(.4),P=new i.Primitive({geometryInstances:C,appearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:b}),translucent:!0,closed:!0}),depthFailAppearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:M}),translucent:!0,closed:!0})});this.primitive=P,n.scene.primitives.add(this.primitive);const L=s.lineColor||b,E=[...h,h[0]],I=n.entities.add({polyline:{positions:E,width:s.width||2,material:L,clampToGround:!1,arcType:i.ArcType.NONE}});this.edgeEntities.push(I);const D=s.pointColor||b;for(const x of h){const T=n.entities.add({position:x,point:{pixelSize:8,color:D,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(T)}}computeRectangle(t,e,i){const n=this.Cesium,s=new n.EllipsoidTangentPlane(t,n.Ellipsoid.WGS84),o=s.projectPointsOntoPlane([t,e,i]);if(!o||o.length<3)return null;const r=o[0],h=o[1],c=o[2],d=h.x-r.x,u=h.y-r.y,m=Math.sqrt(d*d+u*u);if(!m)return null;const g=d/m,f=-(u/m),w=g,y=c.x-h.x,v=c.y-h.y,C=y*f+v*w;if(!C)return null;const b=new n.Cartesian2(h.x+f*C,h.y+w*C),M=new n.Cartesian2(r.x+f*C,r.y+w*C),P=s.projectPointsOntoEllipsoid([r,h,b,M]);if(!P||P.length<4)return null;const L=P,E=L[0],I=L[2],D=Math.abs(m),x=Math.abs(C),T=new n.Cartesian3((E.x+I.x)/2,(E.y+I.y)/2,(E.z+I.z)/2),S=new n.EllipsoidTangentPlane(T,n.Ellipsoid.WGS84).projectPointsOntoPlane(L);let O=0;for(let k=0;k<S.length;k++){const F=(k+1)%S.length;O+=S[k].x*S[F].y-S[F].x*S[k].y}const _=Math.abs(O)/2;return{corners:L,center:T,width:D,height:x,area:_}}}class st{constructor(t,e){l(this,"Cesium");l(this,"viewer");l(this,"handler",null);l(this,"entity",null);l(this,"positions",[]);l(this,"labelEntity",null);l(this,"currentPoints",[]);l(this,"primitive",null);l(this,"previewEntity",null);l(this,"edgeEntities",[]);l(this,"pointEntities",[]);l(this,"previewEdgeEntity",null);l(this,"previewPointEntities",[]);l(this,"htmlLabelPool",null);l(this,"htmlLabelId",null);l(this,"segmentLabelIds",[]);l(this,"previewLabelId",null);this.Cesium=t,this.viewer=e}start(t){this.clear();const e=this.Cesium,i=this.viewer,n=Math.max(t.sides||6,6);if(!this.htmlLabelPool){const s=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new N(e,i,s),this.htmlLabelPool.registerTheme("measure-regular",{createElement:(o,r)=>{var h;o.innerHTML=String(((h=r==null?void 0:r.data)==null?void 0:h.text)||""),o.style.background="rgba(0,0,0,0.6)",o.style.color="#fff",o.style.font="14px sans-serif",o.style.padding="4px 6px",o.style.borderRadius="4px",o.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-regular-seg",{createElement:(o,r)=>{var h;o.innerHTML=String(((h=r==null?void 0:r.data)==null?void 0:h.text)||""),o.style.background="rgba(0,0,0,0.6)",o.style.color="#fff",o.style.font="14px sans-serif",o.style.padding="4px 6px",o.style.borderRadius="4px",o.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(s=>{var r,h,c;const o=i.scene.pickPosition(s.position);if(o&&(this.positions.push(o),this.positions.length===2)){this.stop();const d=this.positions[0],u=this.positions[1],m=e.Cartesian3.distance(d,u),g=this.buildRegularPolygonPoints(d,m,n);this.previewEntity&&(i.entities.remove(this.previewEntity),this.previewEntity=null),this.primitive&&(i.scene.primitives.remove(this.primitive),this.primitive=null);const p=new e.PolygonHierarchy(g),f=new e.PolygonGeometry({polygonHierarchy:p,vertexFormat:e.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:e.ArcType.NONE}),w=new e.GeometryInstance({geometry:f}),y=t.color||e.Color.YELLOW.withAlpha(.4),v=t.color&&t.color.withAlpha?t.color.withAlpha(.25):e.Color.RED.withAlpha(.4);this.primitive=new e.Primitive({geometryInstances:w,appearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:y}),translucent:!0,closed:!0}),depthFailAppearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:v}),translucent:!0,closed:!0})}),i.scene.primitives.add(this.primitive);const C=t.lineColor||y,b=((h=(r=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:h.call(r,.9))||e.Color.RED,M=g.slice(),P=i.entities.add({polyline:{positions:M,width:t.width||2,material:C,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}});this.edgeEntities.push(P);const L=t.pointColor||y,E=g.slice(0,g.length-1);for(const O of E){const _=i.entities.add({position:O,point:{pixelSize:8,color:L,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(_)}const I=this.computeAreaByPlane(g),D=e.Cartographic.fromCartesian(d),x=this.htmlLabelId||`measure_regular_${Date.now()}`;this.htmlLabelId=x;const T=t.labelText||{sides:"边数",radius:"半径",circumference:"周长",area:"面积",side:"边长"};this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);let $=0;for(let O=1;O<g.length;O++){const _=g[O-1],k=g[O],F=e.Cartographic.fromCartesian(_),G=e.Cartographic.fromCartesian(k),j=new e.EllipsoidGeodesic(F,G).surfaceDistance;$+=j;const X=new e.Cartesian3((_.x+k.x)/2,(_.y+k.y)/2,(_.z+k.z)/2),Z=e.Cartographic.fromCartesian(X),ae=`measure_regular_seg_${Date.now()}_${O-1}`;this.segmentLabelIds.push(ae),this.htmlLabelPool.add({text:`${T.side}:${j.toFixed(2)} m`},{id:ae,lon:e.Math.toDegrees(Z.longitude),lat:e.Math.toDegrees(Z.latitude),height:Z.height||0,theme:"measure-regular-seg",show:!0})}this.htmlLabelPool.add({text:`${T.sides}:${n}
68
68
  ${T.radius}:${m.toFixed(2)} m
69
69
  ${T.circumference}:${$.toFixed(2)} m
70
- ${T.area}:${I.toFixed(2)} m²`},{id:x,lon:e.Math.toDegrees(A.longitude),lat:e.Math.toDegrees(A.latitude),height:A.height||0,theme:"measure-regular",show:!0});const D={entity:this.primitive,label:this.labelEntity,positions:g,radius:m,sides:o,perimeter:$,area:I,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,D)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(s=>{var f,w;if(this.positions.length!==1)return;const n=this.positions[0],r=i.camera.getPickRay(s.endPosition),l=i.scene.globe.pick(r,i.scene);if(!l)return;const c=e.Cartesian3.distance(n,l);if(this.currentPoints=this.buildRegularPolygonPoints(n,c,o),!this.previewEntity){const y=t.color||e.Color.YELLOW.withAlpha(.4);this.previewEntity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>{if(!(!this.currentPoints||this.currentPoints.length===0))return new e.PolygonHierarchy(this.currentPoints)},!1),material:y,perPositionHeight:!0,arcType:e.ArcType.NONE}});const v=t.lineColor||t.color||e.Color.YELLOW,C=((w=(f=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:w.call(f,.9))||e.Color.RED;this.previewEdgeEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.currentPoints||this.currentPoints.length===0?[]:this.currentPoints.slice(),!1),width:t.width||2,material:v,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:C,dashLength:12,dashPattern:255})}});const b=t.pointColor||t.color||e.Color.YELLOW,M=i.entities.add({position:n,point:{pixelSize:8,color:b,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),P=i.entities.add({position:new e.CallbackProperty(()=>l||n,!1),point:{pixelSize:8,color:b,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.previewPointEntities.push(M,P)}let d=0;for(let y=1;y<this.currentPoints.length;y++){const v=this.currentPoints[y-1],C=this.currentPoints[y],b=e.Cartographic.fromCartesian(v),M=e.Cartographic.fromCartesian(C),P=new e.EllipsoidGeodesic(b,M);d+=P.surfaceDistance}const u=this.computeAreaByPlane(this.currentPoints),m=e.Cartographic.fromCartesian(n),g=this.previewLabelId||"measure_regular_preview";this.previewLabelId=g;const p=t.labelText||{sides:"边数",radius:"半径",circumference:"周长",area:"面积"};this.htmlLabelPool.add({text:`${p.sides}:${o}
70
+ ${T.area}:${I.toFixed(2)} m²`},{id:x,lon:e.Math.toDegrees(D.longitude),lat:e.Math.toDegrees(D.latitude),height:D.height||0,theme:"measure-regular",show:!0});const S={entity:this.primitive,label:this.labelEntity,positions:g,radius:m,sides:n,perimeter:$,area:I,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,S)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(s=>{var f,w;if(this.positions.length!==1)return;const o=this.positions[0],r=i.camera.getPickRay(s.endPosition),h=i.scene.globe.pick(r,i.scene);if(!h)return;const c=e.Cartesian3.distance(o,h);if(this.currentPoints=this.buildRegularPolygonPoints(o,c,n),!this.previewEntity){const y=t.color||e.Color.YELLOW.withAlpha(.4);this.previewEntity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>{if(!(!this.currentPoints||this.currentPoints.length===0))return new e.PolygonHierarchy(this.currentPoints)},!1),material:y,perPositionHeight:!0,arcType:e.ArcType.NONE}});const v=t.lineColor||t.color||e.Color.YELLOW,C=((w=(f=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:w.call(f,.9))||e.Color.RED;this.previewEdgeEntity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>!this.currentPoints||this.currentPoints.length===0?[]:this.currentPoints.slice(),!1),width:t.width||2,material:v,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:C,dashLength:12,dashPattern:255})}});const b=t.pointColor||t.color||e.Color.YELLOW,M=i.entities.add({position:o,point:{pixelSize:8,color:b,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),P=i.entities.add({position:new e.CallbackProperty(()=>h||o,!1),point:{pixelSize:8,color:b,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.previewPointEntities.push(M,P)}let d=0;for(let y=1;y<this.currentPoints.length;y++){const v=this.currentPoints[y-1],C=this.currentPoints[y],b=e.Cartographic.fromCartesian(v),M=e.Cartographic.fromCartesian(C),P=new e.EllipsoidGeodesic(b,M);d+=P.surfaceDistance}const u=this.computeAreaByPlane(this.currentPoints),m=e.Cartographic.fromCartesian(o),g=this.previewLabelId||"measure_regular_preview";this.previewLabelId=g;const p=t.labelText||{sides:"边数",radius:"半径",circumference:"周长",area:"面积"};this.htmlLabelPool.add({text:`${p.sides}:${n}
71
71
  ${p.radius}:${c.toFixed(2)} m
72
72
  ${p.circumference}:${d.toFixed(2)} m
73
- ${p.area}:${u.toFixed(2)} m²`},{id:g,lon:e.Math.toDegrees(m.longitude),lat:e.Math.toDegrees(m.latitude),height:m.height||0,theme:"measure-regular",show:!0})},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){if(this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewEdgeEntity&&(this.viewer.entities.remove(this.previewEdgeEntity),this.previewEdgeEntity=null),this.previewPointEntities.length){for(const t of this.previewPointEntities)try{this.viewer.entities.remove(t)}catch{}this.previewPointEntities=[]}if(this.primitive&&(this.viewer.scene.primitives.remove(this.primitive),this.primitive=null),this.edgeEntities.length){for(const t of this.edgeEntities)try{this.viewer.entities.remove(t)}catch{}this.edgeEntities=[]}if(this.pointEntities.length){for(const t of this.pointEntities)try{this.viewer.entities.remove(t)}catch{}this.pointEntities=[]}this.labelEntity&&(this.viewer.entities.remove(this.labelEntity),this.labelEntity=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.segmentLabelIds=[],this.positions=[],this.currentPoints=[]}rehydrate(t,e){var P;const i=this.Cesium,o=this.viewer,s=t.options||{},n=((P=t.data)==null?void 0:P.sides)||s.sides||3,r=(t.positions||[]).map(L=>new i.Cartesian3(L[0],L[1],L[2]));if(r.length<2)return;if(!this.htmlLabelPool){const L=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,o,L),this.htmlLabelPool.registerTheme("measure-regular",{createElement:(E,I)=>{var A;E.innerHTML=String(((A=I==null?void 0:I.data)==null?void 0:A.text)||""),E.style.background="rgba(0,0,0,0.6)",E.style.color="#fff",E.style.font="14px sans-serif",E.style.padding="4px 6px",E.style.borderRadius="4px",E.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-regular-seg",{createElement:(E,I)=>{var A;E.innerHTML=String(((A=I==null?void 0:I.data)==null?void 0:A.text)||""),E.style.background="rgba(0,0,0,0.6)",E.style.color="#fff",E.style.font="14px sans-serif",E.style.padding="4px 6px",E.style.borderRadius="4px",E.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}let l=[],c=r[0],d=0;if(r.length>=3){l=r.slice(),c=new i.Cartesian3(l.reduce((E,I)=>E+I.x,0)/l.length,l.reduce((E,I)=>E+I.y,0)/l.length,l.reduce((E,I)=>E+I.z,0)/l.length);const L=l[0];l[Math.floor(l.length/2)]||l[1],d=i.Cartesian3.distance(c,L)}else{const L=r[1];d=i.Cartesian3.distance(c,L),l=this.buildRegularPolygonPoints(c,d,Math.max(n,3))}const u=new i.PolygonHierarchy(l),m=new i.PolygonGeometry({polygonHierarchy:u,vertexFormat:i.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0}),g=new i.GeometryInstance({geometry:m}),p=s.color||i.Color.YELLOW.withAlpha(.4),f=s.color&&s.color.withAlpha?s.color.withAlpha(.25):i.Color.RED.withAlpha(.4),w=new i.Primitive({geometryInstances:g,appearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:p}),translucent:!0,closed:!0}),depthFailAppearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:f}),translucent:!0,closed:!0})});o.scene.primitives.add(w),this.primitive=w;const y=this.computeAreaByPlane(l),v=i.Cartographic.fromCartesian(c),C=t.id+"_regular";this.htmlLabelId=C;const b=s.labelText||{sides:"边数",radius:"半径",circumference:"周长",area:"面积",side:"边长"};let M=0;for(let L=1;L<l.length;L++){const E=l[L-1],I=l[L],A=i.Cartographic.fromCartesian(E),x=i.Cartographic.fromCartesian(I),$=new i.EllipsoidGeodesic(A,x).surfaceDistance;M+=$;const D=new i.Cartesian3((E.x+I.x)/2,(E.y+I.y)/2,(E.z+I.z)/2),k=i.Cartographic.fromCartesian(D),_=t.id+`_regular_seg_${L-1}`;this.segmentLabelIds.push(_),this.htmlLabelPool.add({text:`${b.side}:${$.toFixed(2)} m`},{id:_,lon:i.Math.toDegrees(k.longitude),lat:i.Math.toDegrees(k.latitude),height:k.height||0,theme:"measure-regular-seg",show:!0})}this.htmlLabelPool.add({text:`${b.sides}:${Math.max(n,3)}
73
+ ${p.area}:${u.toFixed(2)} m²`},{id:g,lon:e.Math.toDegrees(m.longitude),lat:e.Math.toDegrees(m.latitude),height:m.height||0,theme:"measure-regular",show:!0})},e.ScreenSpaceEventType.MOUSE_MOVE)}stop(){this.handler&&(this.handler.destroy(),this.handler=null)}clear(){if(this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.previewEntity&&(this.viewer.entities.remove(this.previewEntity),this.previewEntity=null),this.previewEdgeEntity&&(this.viewer.entities.remove(this.previewEdgeEntity),this.previewEdgeEntity=null),this.previewPointEntities.length){for(const t of this.previewPointEntities)try{this.viewer.entities.remove(t)}catch{}this.previewPointEntities=[]}if(this.primitive&&(this.viewer.scene.primitives.remove(this.primitive),this.primitive=null),this.edgeEntities.length){for(const t of this.edgeEntities)try{this.viewer.entities.remove(t)}catch{}this.edgeEntities=[]}if(this.pointEntities.length){for(const t of this.pointEntities)try{this.viewer.entities.remove(t)}catch{}this.pointEntities=[]}this.labelEntity&&(this.viewer.entities.remove(this.labelEntity),this.labelEntity=null),this.htmlLabelPool&&this.htmlLabelId&&(this.htmlLabelPool.removeByIds([this.htmlLabelId]),this.htmlLabelId=null),this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null),this.segmentLabelIds.length&&this.htmlLabelPool&&this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()),this.segmentLabelIds=[],this.positions=[],this.currentPoints=[]}rehydrate(t,e){var P;const i=this.Cesium,n=this.viewer,s=t.options||{},o=((P=t.data)==null?void 0:P.sides)||s.sides||3,r=(t.positions||[]).map(L=>new i.Cartesian3(L[0],L[1],L[2]));if(r.length<2)return;if(!this.htmlLabelPool){const L=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new N(i,n,L),this.htmlLabelPool.registerTheme("measure-regular",{createElement:(E,I)=>{var D;E.innerHTML=String(((D=I==null?void 0:I.data)==null?void 0:D.text)||""),E.style.background="rgba(0,0,0,0.6)",E.style.color="#fff",E.style.font="14px sans-serif",E.style.padding="4px 6px",E.style.borderRadius="4px",E.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-regular-seg",{createElement:(E,I)=>{var D;E.innerHTML=String(((D=I==null?void 0:I.data)==null?void 0:D.text)||""),E.style.background="rgba(0,0,0,0.6)",E.style.color="#fff",E.style.font="14px sans-serif",E.style.padding="4px 6px",E.style.borderRadius="4px",E.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}})}let h=[],c=r[0],d=0;if(r.length>=3){h=r.slice(),c=new i.Cartesian3(h.reduce((E,I)=>E+I.x,0)/h.length,h.reduce((E,I)=>E+I.y,0)/h.length,h.reduce((E,I)=>E+I.z,0)/h.length);const L=h[0];h[Math.floor(h.length/2)]||h[1],d=i.Cartesian3.distance(c,L)}else{const L=r[1];d=i.Cartesian3.distance(c,L),h=this.buildRegularPolygonPoints(c,d,Math.max(o,3))}const u=new i.PolygonHierarchy(h),m=new i.PolygonGeometry({polygonHierarchy:u,vertexFormat:i.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0}),g=new i.GeometryInstance({geometry:m}),p=s.color||i.Color.YELLOW.withAlpha(.4),f=s.color&&s.color.withAlpha?s.color.withAlpha(.25):i.Color.RED.withAlpha(.4),w=new i.Primitive({geometryInstances:g,appearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:p}),translucent:!0,closed:!0}),depthFailAppearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:f}),translucent:!0,closed:!0})});n.scene.primitives.add(w),this.primitive=w;const y=this.computeAreaByPlane(h),v=i.Cartographic.fromCartesian(c),C=t.id+"_regular";this.htmlLabelId=C;const b=s.labelText||{sides:"边数",radius:"半径",circumference:"周长",area:"面积",side:"边长"};let M=0;for(let L=1;L<h.length;L++){const E=h[L-1],I=h[L],D=i.Cartographic.fromCartesian(E),x=i.Cartographic.fromCartesian(I),$=new i.EllipsoidGeodesic(D,x).surfaceDistance;M+=$;const S=new i.Cartesian3((E.x+I.x)/2,(E.y+I.y)/2,(E.z+I.z)/2),O=i.Cartographic.fromCartesian(S),_=t.id+`_regular_seg_${L-1}`;this.segmentLabelIds.push(_),this.htmlLabelPool.add({text:`${b.side}:${$.toFixed(2)} m`},{id:_,lon:i.Math.toDegrees(O.longitude),lat:i.Math.toDegrees(O.latitude),height:O.height||0,theme:"measure-regular-seg",show:!0})}this.htmlLabelPool.add({text:`${b.sides}:${Math.max(o,3)}
74
74
  ${b.radius}:${d.toFixed(2)} m
75
75
  ${b.circumference}:${M.toFixed(2)} m
76
- ${b.area}:${y.toFixed(2)} m²`},{id:C,lon:i.Math.toDegrees(v.longitude),lat:i.Math.toDegrees(v.latitude),height:v.height||0,theme:"measure-regular",show:!0})}buildRegularPolygonPoints(t,e,i){const o=this.Cesium,s=new o.EllipsoidTangentPlane(t,o.Ellipsoid.WGS84),n=2*Math.PI/i,r=[];for(let d=0;d<i;d++){const u=d*n,m=e*Math.cos(u),g=e*Math.sin(u);r.push(new o.Cartesian2(m,g))}const c=s.projectPointsOntoEllipsoid(r).slice();return c.push(c[0]),c}computeAreaByPlane(t){const e=this.Cesium,i=new e.Cartesian3(t.reduce((r,l)=>r+l.x,0)/t.length,t.reduce((r,l)=>r+l.y,0)/t.length,t.reduce((r,l)=>r+l.z,0)/t.length),s=new e.EllipsoidTangentPlane(i,e.Ellipsoid.WGS84).projectPointsOntoPlane(t);let n=0;for(let r=0;r<s.length;r++){const l=(r+1)%s.length;n+=s[r].x*s[l].y-s[l].x*s[r].y}return Math.abs(n)/2}}class Do{constructor({Cesium:t,viewer:e}){h(this,"Cesium");h(this,"viewer");h(this,"actives",[]);h(this,"measurements",[]);h(this,"htmlLabelPool",null);h(this,"recordHandlers",new Map);h(this,"specifiedClear",!1);h(this,"deleteLabelPool",null);h(this,"deleteLabelIds",new Map);this.Cesium=t,this.viewer=e,e.screenSpaceEventHandler.removeInputAction(t.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}measure(t,e){let i=null;switch(t){case"horizontal":i=new Ye(this.Cesium,this.viewer);break;case"vertical":i=new Ve(this.Cesium,this.viewer);break;case"triangle":i=new We(this.Cesium,this.viewer);break;case"space":i=new Ue(this.Cesium,this.viewer);break;case"area":i=new Ke(this.Cesium,this.viewer);break;case"circle":i=new qe(this.Cesium,this.viewer);break;case"polyline":i=new Xe(this.Cesium,this.viewer);break;case"terrainHeight":i=new Je(this.Cesium,this.viewer);break;case"coordinate":i=new Ze(this.Cesium,this.viewer);break;case"rectangle":i=new Qe(this.Cesium,this.viewer);break;case"regularPolygon":i=new et(this.Cesium,this.viewer);break;default:throw new Error(`Unsupported measurement type: ${t}`)}if(!i)return;this.actives.push(i);const o=i,s={...e,onComplete:n=>{var c;const r={id:`m_${Date.now()}_${this.measurements.length}`,type:t,options:(()=>{const d={...e};return"onComplete"in d&&delete d.onComplete,d})(),positions:(()=>{if(Array.isArray(n==null?void 0:n.positions))return n.positions.map(d=>[d.x,d.y,d.z]);switch(t){case"terrainHeight":{const d=n==null?void 0:n.position;return d?[[d.x,d.y,d.z]]:void 0}case"coordinate":{const d=n==null?void 0:n.lnglat;if(d&&typeof d.lng=="number"&&typeof d.lat=="number"){const u=this.Cesium.Cartesian3.fromDegrees(d.lng,d.lat,d.height||0);return[[u.x,u.y,u.z]]}return}default:return}})(),data:this._serializeMetrics(t,n)};this.measurements.push(r),o&&this.recordHandlers.set(r.id,o),this.specifiedClear&&this._showDeleteLabels("html-label-container"),(c=e.onComplete)==null||c.call(e,n);const l=this.actives.indexOf(o);l>=0&&this.actives.splice(l,1)}};i.start(s)}clear(){const t=this.actives.pop();t&&t.clear(),this._removeAllDeleteLabels(),this.specifiedClear=!1}cancel(){const t=this.actives.pop();t&&t.stop()}disableDefaultSelection({disableLeftClick:t=!1,disableDoubleClick:e=!0}={}){var o,s;const i=(s=(o=this.viewer)==null?void 0:o.cesiumWidget)==null?void 0:s.screenSpaceEventHandler;i&&(e&&i.removeInputAction(this.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),t&&i.removeInputAction(this.Cesium.ScreenSpaceEventType.LEFT_CLICK))}clearAll(){for(;this.actives.length;){const t=this.actives.pop();try{t==null||t.clear()}catch{}}for(const[,t]of this.recordHandlers)try{t.clear()}catch{}this.recordHandlers.clear(),this.measurements=[],this._removeAllDeleteLabels(),this.specifiedClear=!1}getMeasurementsConfig(){return{measurements:this.measurements.map(t=>({...t,options:t.options?{...t.options}:t.options,positions:t.positions?t.positions.map(e=>[e[0],e[1],e[2]]):t.positions,data:t.data?{...t.data}:t.data}))}}setMeasurementsConfig(t){var e,i;if((e=t==null?void 0:t.measurements)!=null&&e.length){for(const o of t.measurements){let s=null;switch(o.type){case"horizontal":s=new Ye(this.Cesium,this.viewer);break;case"vertical":s=new Ve(this.Cesium,this.viewer);break;case"triangle":s=new We(this.Cesium,this.viewer);break;case"space":s=new Ue(this.Cesium,this.viewer);break;case"area":s=new Ke(this.Cesium,this.viewer);break;case"circle":s=new qe(this.Cesium,this.viewer);break;case"polyline":s=new Xe(this.Cesium,this.viewer);break;case"terrainHeight":s=new Je(this.Cesium,this.viewer);break;case"coordinate":s=new Ze(this.Cesium,this.viewer);break;case"rectangle":s=new Qe(this.Cesium,this.viewer);break;case"regularPolygon":s=new et(this.Cesium,this.viewer);break;default:s=null}(i=s==null?void 0:s.rehydrate)==null||i.call(s,o,void 0),s&&o.id&&this.recordHandlers.set(o.id,s),this.measurements.find(r=>r.id===o.id)||this.measurements.push(o)}this.specifiedClear&&this._showDeleteLabels("html-label-container")}}_serializeMetrics(t,e){switch(t){case"space":return{distance:e==null?void 0:e.distance};case"horizontal":return{distance:e==null?void 0:e.distance};case"vertical":return{vertical:e==null?void 0:e.vertical};case"polyline":return{distance:e==null?void 0:e.distance};case"area":return{area:e==null?void 0:e.area};case"circle":return{radius:e==null?void 0:e.radius,area:e==null?void 0:e.area,perimeter:e==null?void 0:e.perimeter};case"rectangle":return{width:e==null?void 0:e.width,height:e==null?void 0:e.height,area:e==null?void 0:e.area};case"regularPolygon":return{sides:e==null?void 0:e.sides,radius:e==null?void 0:e.radius,perimeter:e==null?void 0:e.perimeter,area:e==null?void 0:e.area};case"triangle":return{lengths:e==null?void 0:e.lengths,angles:e==null?void 0:e.angles};case"terrainHeight":return{terrainHeight:e==null?void 0:e.terrainHeight,difference:e==null?void 0:e.difference,position:e==null?void 0:e.position,zeroPosition:e==null?void 0:e.zeroPosition};case"coordinate":return{lnglat:e==null?void 0:e.lnglat};default:return{}}}_toCartesian(t){const e=this.Cesium;return new e.Cartesian3(t[0],t[1],t[2])}_removeRecordVisual(t){const e=this.viewer;this.Cesium;const i=e.entities.values;for(let n=i.length-1;n>=0;n--){const r=i[n];try{e.entities.remove(r)}catch{}}const o=e.scene.primitives,s=[];o._primitives&&o._primitives.forEach(n=>s.push(n));for(const n of s)try{e.scene.primitives.remove(n)}catch{}this.htmlLabelPool&&this.htmlLabelPool.removeAll()}toggleSpecifiedClear(t){if(this.specifiedClear)this._removeAllDeleteLabels(),this.specifiedClear=!1;else{if(this.specifiedClear=!0,!this.deleteLabelPool){const e=t||"html-label-container";this.deleteLabelPool=new N(this.Cesium,this.viewer,e),this.deleteLabelPool.registerTheme("measure-delete-label",{createElement:(i,o)=>{i.innerHTML="删除",i.style.background="rgba(255,0,0,0.7)",i.style.color="#fff",i.style.font="12px sans-serif",i.style.padding="2px 6px",i.style.borderRadius="4px",i.style.whiteSpace="nowrap"},options:{offset:{x:0,y:-10}}}),this.deleteLabelPool.eventBus.addListener(V.Click,{name:"measurement_delete_label_click",fn:i=>{var s;if(!i||i.theme!=="measure-delete-label")return;const o=(s=i==null?void 0:i.data)==null?void 0:s.recordId;o&&this.deleteMeasurement(o)}},!0)}this._showDeleteLabels(t||"html-label-container")}}deleteMeasurement(t){const e=this.recordHandlers.get(t);if(e)try{e.clear()}catch{}this.recordHandlers.delete(t),this.measurements=this.measurements.filter(o=>o.id!==t);const i=this.deleteLabelIds.get(t);i&&this.deleteLabelPool&&this.deleteLabelPool.removeByIds([i]),this.deleteLabelIds.delete(t)}_showDeleteLabels(t){if(!this.deleteLabelPool)return;const e=this.Cesium;for(const i of this.measurements){const o="m_del_"+i.id;if(this.deleteLabelIds.has(i.id))continue;const s=this._computeRecordCenter(i);if(!s)continue;const n=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(n.longitude),l=e.Math.toDegrees(n.latitude),c=n.height||0;this.deleteLabelPool.add({recordId:i.id},{id:o,lon:r,lat:l,height:c,theme:"measure-delete-label",show:!0,style:{zIndex:"1000"}}),this.deleteLabelIds.set(i.id,o)}}_removeAllDeleteLabels(){if(this.deleteLabelPool){const t=Array.from(this.deleteLabelIds.values());t.length&&this.deleteLabelPool.removeByIds(t)}this.deleteLabelIds.clear()}_computeRecordCenter(t){var o,s;const e=this.Cesium,i=(t.positions||[]).map(n=>this._toCartesian(n));if(i.length>0){const n=i.reduce((c,d)=>c+d.x,0)/i.length,r=i.reduce((c,d)=>c+d.y,0)/i.length,l=i.reduce((c,d)=>c+d.z,0)/i.length;return new e.Cartesian3(n,r,l)}if(t.type==="coordinate"&&((o=t.data)!=null&&o.lnglat)){const n=t.data.lnglat.lng,r=t.data.lnglat.lat,l=t.data.lnglat.height||0;return e.Cartesian3.fromDegrees(n,r,l)}if(t.type==="terrainHeight"&&((s=t.data)!=null&&s.position)){const n=t.data.position;return new e.Cartesian3(n.x,n.y,n.z)}return null}}class So{constructor({Cesium:t,viewer:e}){h(this,"Cesium");h(this,"viewer");h(this,"options",null);h(this,"entity",null);h(this,"viewEntities",[]);h(this,"startTime",null);h(this,"stopTime",null);h(this,"isPaused",!1);h(this,"lastTime",null);h(this,"onTick",t=>{if(!this.options||!this.entity)return;const e=t.currentTime;if(this.Cesium.JulianDate.lessThan(e,this.startTime)||this.Cesium.JulianDate.greaterThan(e,this.stopTime)){!this.options.loop&&this.Cesium.JulianDate.greaterThan(e,this.stopTime)&&this.viewer.clock.shouldAnimate&&(this.viewer.clock.shouldAnimate=!1,this.options.onComplete&&this.options.onComplete());return}const i=this.entity.position.getValue(e),o=this.entity.orientation.getValue(e);if(i&&o){const s=this.Cesium.Matrix4.fromTranslationQuaternionRotationScale(i,o,new this.Cesium.Cartesian3(1,1,1),new this.Cesium.Matrix4),n=this.Cesium.Transforms.fixedFrameToHeadingPitchRoll(s,this.viewer.scene.globe.ellipsoid,this.Cesium.Transforms.eastNorthUpToFixedFrame,new this.Cesium.HeadingPitchRoll);this.viewer.camera.setView({destination:i,orientation:{heading:n.heading,pitch:n.pitch,roll:n.roll}}),this.options.onTick&&this.options.onTick(e,i,n)}});this.Cesium=t,this.viewer=e}get Viewer(){return this.viewer}get CesiumInstance(){return this.Cesium}start(t){this.clear(),this.options=t,!((t.waypoints||[]).length<2)&&(this._setupEntities(t),this.viewer.clock.startTime=this.startTime.clone(),this.viewer.clock.stopTime=this.stopTime.clone(),this.viewer.clock.currentTime=this.startTime.clone(),this.viewer.clock.clockRange=t.loop?this.Cesium.ClockRange.LOOP_STOP:this.Cesium.ClockRange.CLAMPED,this.viewer.clock.multiplier=1,this.viewer.clock.shouldAnimate=!0,this.viewer.clock.onTick.addEventListener(this.onTick))}preview(t){this.clear(),this.options=t,!((t.waypoints||[]).length<2)&&this._setupEntities(t)}_setupEntities(t){const e=t.waypoints||[],i=new this.Cesium.SampledPositionProperty,o=new this.Cesium.SampledProperty(this.Cesium.Quaternion),s=[];for(const u of e){let m;u.destination?u.destination.x!==void 0?m=new this.Cesium.Cartesian3(u.destination.x,u.destination.y,u.destination.z):m=u.destination:u.lon!==void 0&&u.lat!==void 0&&(m=this.Cesium.Cartesian3.fromDegrees(u.lon,u.lat,u.height??0));let g;u.orientation?g=new this.Cesium.HeadingPitchRoll(u.orientation.heading,u.orientation.pitch,u.orientation.roll):g=this.Cesium.HeadingPitchRoll.fromDegrees(u.heading??0,u.pitch??-30,u.roll??0);const p=this.Cesium.Transforms.headingPitchRollQuaternion(m,g);s.push({position:m,orientation:p})}const n=this.Cesium.JulianDate.now(),r=t.speed||100;let l=0;const c=[];for(let u=0;u<s.length;u++){if(u===0)c.push(n.clone());else{const g=this.Cesium.Cartesian3.distance(s[u-1].position,s[u].position)/Math.max(r,.1);l+=g,c.push(this.Cesium.JulianDate.addSeconds(n,l,new this.Cesium.JulianDate))}i.addSample(c[u],s[u].position),o.addSample(c[u],s[u].orientation)}this.startTime=c[0],this.stopTime=c[c.length-1];const d={availability:new this.Cesium.TimeIntervalCollection([new this.Cesium.TimeInterval({start:this.startTime,stop:this.stopTime})]),position:i,orientation:o};t.modelUrl?d.model={uri:t.modelUrl,scale:t.modelScale??1,minimumPixelSize:64,runAnimations:t.modelAnimate??!0}:d.point={pixelSize:1,color:this.Cesium.Color.TRANSPARENT},t.showPath&&this.viewEntities.push(this.viewer.entities.add({polyline:{positions:s.map(u=>u.position),width:3,material:this.Cesium.Color.GREEN}})),this.entity=this.viewer.entities.add(d),t.showStops&&s.forEach((u,m)=>{const g=this.Cesium.Cartographic.fromCartesian(u.position),p=this.Cesium.Cartesian3.fromRadians(g.longitude,g.latitude,0);this.viewEntities.push(this.viewer.entities.add({position:u.position,point:{pixelSize:8,color:this.Cesium.Color.YELLOW,outlineColor:this.Cesium.Color.BLACK,outlineWidth:1},label:{text:""+(m+1),font:"12px sans-serif",pixelOffset:new this.Cesium.Cartesian2(0,-15),fillColor:this.Cesium.Color.WHITE,outlineColor:this.Cesium.Color.BLACK,outlineWidth:2,style:this.Cesium.LabelStyle.FILL_AND_OUTLINE},polyline:{positions:[u.position,p],width:2,material:new this.Cesium.PolylineDashMaterialProperty({color:this.Cesium.Color.RED,dashLength:16})}}))})}stop(){this.viewer.clock.shouldAnimate=!1,this.viewer.clock.onTick.removeEventListener(this.onTick)}pause(){this.viewer.clock.shouldAnimate=!1,this.isPaused=!0}resume(){this.viewer.clock.shouldAnimate=!0,this.isPaused=!1}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null);for(const t of this.viewEntities)this.viewer.entities.remove(t);this.viewEntities=[],this.options=null}captureCurrentView(){const t=this.viewer.camera.position.clone(),e=this.viewer.camera.heading,i=this.viewer.camera.pitch,o=this.viewer.camera.roll;return{destination:{x:t.x,y:t.y,z:t.z},orientation:{heading:e,pitch:i,roll:o}}}}class Ao{constructor({Cesium:t,viewer:e}){h(this,"Cesium");h(this,"viewer");h(this,"entity",null);h(this,"positionProperty",null);h(this,"startTime",null);h(this,"stopTime",null);h(this,"options",null);h(this,"cameraOffset",null);h(this,"onTick",t=>{if(!this.options||!this.positionProperty)return;const e=t.currentTime,i=this.positionProperty.getValue(e);if(this.options.followCamera&&this.options.initialView&&i){this.cameraOffset||(this.cameraOffset=this.Cesium.Cartesian3.subtract(this.options.initialView.destination,i,new this.Cesium.Cartesian3));const o=this.Cesium.Cartesian3.add(i,this.cameraOffset,new this.Cesium.Cartesian3);this.viewer.camera.setView({destination:o,orientation:this.options.initialView.orientation})}i&&this.options.onTick&&this.options.onTick(e,i),this.Cesium.JulianDate.greaterThanOrEquals(e,this.stopTime)&&(this.options.loop||(this.options.onComplete&&this.options.onComplete(),this.stop()))});this.Cesium=t,this.viewer=e}get Viewer(){return this.viewer}get CesiumInstance(){return this.Cesium}start(t){this.clear(),this.options=t;const e=this.normalizePositions(t.positions||[]);if(!e.length)return;const i=t.speed??30,o=this.buildTimes(e,i),s=new this.Cesium.SampledPositionProperty;for(let g=0;g<e.length;g++)s.addSample(o[g],e[g]);this.positionProperty=s;const n=new this.Cesium.VelocityOrientationProperty(s),r=t.showPath??!0,l=t.pathColor??this.Cesium.Color.YELLOW,c=t.pathWidth??3,d=t.pointColor??this.Cesium.Color.RED,u=t.pointPixelSize??8,m={availability:new this.Cesium.TimeIntervalCollection([new this.Cesium.TimeInterval({start:this.startTime,stop:this.stopTime})]),position:s,orientation:n,path:r?{material:l,width:c,leadTime:0}:void 0};t.modelUrl?m.model={uri:t.modelUrl,scale:t.modelScale??1,minimumPixelSize:64,runAnimations:t.modelAnimate??!0}:m.point={color:d,pixelSize:u},this.entity=this.viewer.entities.add(m),this.viewer.clock.startTime=this.startTime.clone(),this.viewer.clock.stopTime=this.stopTime.clone(),this.viewer.clock.currentTime=this.startTime.clone(),this.viewer.clock.clockRange=t.loop?this.Cesium.ClockRange.LOOP_STOP:this.Cesium.ClockRange.CLAMPED,this.viewer.clock.multiplier=1,this.viewer.clock.shouldAnimate=!0,t.initialView?(this.viewer.camera.setView({destination:t.initialView.destination,orientation:t.initialView.orientation}),this.cameraOffset=null):t.followCamera?this.viewer.trackedEntity=this.entity:t.lookAtOffset&&this.viewer.camera.lookAt(this.entity.position,t.lookAtOffset),this.viewer.clock.onTick.addEventListener(this.onTick)}stop(){this.viewer.clock.shouldAnimate=!1,this.viewer.clock.onTick.removeEventListener(this.onTick),this.viewer.trackedEntity===this.entity&&(this.viewer.trackedEntity=void 0)}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.positionProperty=null,this.startTime=null,this.stopTime=null,this.options=null;try{this.viewer.camera.lookAtTransform(this.Cesium.Matrix4.IDENTITY)}catch{}}normalizePositions(t){const e=[];for(const i of t)if(Array.isArray(i)){const[o,s,n]=i;e.push(this.Cesium.Cartesian3.fromDegrees(o,s,n??0))}else(i==null?void 0:i.x)!==void 0&&(i==null?void 0:i.y)!==void 0&&(i==null?void 0:i.z)!==void 0&&e.push(i);return e}buildTimes(t,e){const i=[],o=this.Cesium.JulianDate.now();let s=0;for(let n=0;n<t.length;n++)if(n===0)i.push(o.clone());else{const r=this.Cesium.Cartesian3.distance(t[n-1],t[n]);s+=r/Math.max(e,.1),i.push(this.Cesium.JulianDate.addSeconds(o,s,new this.Cesium.JulianDate))}return this.startTime=i[0],this.stopTime=i[i.length-1],i}}S.AreaMeasure=Ke,S.BufferedHierarchicalAggregator=te,S.CameraRoamTool=So,S.CircleMeasure=qe,S.CoordinateMeasure=Ze,S.DOM_EVENT_MAP=it,S.DrawTool=Wt,S.EditMode=zt,S.EntityLayerManager=To,S.GLTFManage=Co,S.GLTFManageEventKey=Nt,S.HorizontalMeasure=Ye,S.HtmlOverlayLabelPool=N,S.MarkerEventBus=tt,S.MarkerEventKey=V,S.MaterialManager=Eo,S.MeasurementTool=Do,S.PathRoamTool=Ao,S.PolylineDistanceMeasure=Xe,S.PrimitiveManager=xo,S.RectangleMeasure=Qe,S.RegularPolygonMeasure=et,S.SpaceMeasure=Ue,S.TerrainHeightMeasure=Je,S.TooltipManager=_e,S.TriangleMeasure=We,S.VerticalMeasure=Ve,S.convertGeoJsonToEntityData=_o,S.getDynamicImgMaterial=bo,S.getPolylineFlowMaterialProperty=Lo,S.getWallMaterial=Po,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
76
+ ${b.area}:${y.toFixed(2)} m²`},{id:C,lon:i.Math.toDegrees(v.longitude),lat:i.Math.toDegrees(v.latitude),height:v.height||0,theme:"measure-regular",show:!0})}buildRegularPolygonPoints(t,e,i){const n=this.Cesium,s=new n.EllipsoidTangentPlane(t,n.Ellipsoid.WGS84),o=2*Math.PI/i,r=[];for(let d=0;d<i;d++){const u=d*o,m=e*Math.cos(u),g=e*Math.sin(u);r.push(new n.Cartesian2(m,g))}const c=s.projectPointsOntoEllipsoid(r).slice();return c.push(c[0]),c}computeAreaByPlane(t){const e=this.Cesium,i=new e.Cartesian3(t.reduce((r,h)=>r+h.x,0)/t.length,t.reduce((r,h)=>r+h.y,0)/t.length,t.reduce((r,h)=>r+h.z,0)/t.length),s=new e.EllipsoidTangentPlane(i,e.Ellipsoid.WGS84).projectPointsOntoPlane(t);let o=0;for(let r=0;r<s.length;r++){const h=(r+1)%s.length;o+=s[r].x*s[h].y-s[h].x*s[r].y}return Math.abs(o)/2}}class $o{constructor({Cesium:t,viewer:e}){l(this,"Cesium");l(this,"viewer");l(this,"actives",[]);l(this,"measurements",[]);l(this,"htmlLabelPool",null);l(this,"recordHandlers",new Map);l(this,"specifiedClear",!1);l(this,"deleteLabelPool",null);l(this,"deleteLabelIds",new Map);this.Cesium=t,this.viewer=e,e.screenSpaceEventHandler.removeInputAction(t.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}measure(t,e){let i=null;switch(t){case"horizontal":i=new _e(this.Cesium,this.viewer);break;case"vertical":i=new Xe(this.Cesium,this.viewer);break;case"triangle":i=new Je(this.Cesium,this.viewer);break;case"space":i=new Ze(this.Cesium,this.viewer);break;case"area":i=new xe(this.Cesium,this.viewer);break;case"circle":i=new Qe(this.Cesium,this.viewer);break;case"polyline":i=new De(this.Cesium,this.viewer);break;case"terrainHeight":i=new et(this.Cesium,this.viewer);break;case"coordinate":i=new tt(this.Cesium,this.viewer);break;case"rectangle":i=new it(this.Cesium,this.viewer);break;case"regularPolygon":i=new st(this.Cesium,this.viewer);break;default:throw new Error(`Unsupported measurement type: ${t}`)}if(!i)return;this.actives.push(i);const n=i,s={...e,onComplete:o=>{var c;const r={id:`m_${Date.now()}_${this.measurements.length}`,type:t,options:(()=>{const d={...e};return"onComplete"in d&&delete d.onComplete,d})(),positions:(()=>{if(Array.isArray(o==null?void 0:o.positions))return o.positions.map(d=>[d.x,d.y,d.z]);switch(t){case"terrainHeight":{const d=o==null?void 0:o.position;return d?[[d.x,d.y,d.z]]:void 0}case"coordinate":{const d=o==null?void 0:o.lnglat;if(d&&typeof d.lng=="number"&&typeof d.lat=="number"){const u=this.Cesium.Cartesian3.fromDegrees(d.lng,d.lat,d.height||0);return[[u.x,u.y,u.z]]}return}default:return}})(),data:this._serializeMetrics(t,o)};this.measurements.push(r),n&&this.recordHandlers.set(r.id,n),this.specifiedClear&&this._showDeleteLabels("html-label-container"),(c=e.onComplete)==null||c.call(e,o);const h=this.actives.indexOf(n);h>=0&&this.actives.splice(h,1)}};i.start(s)}clear(){const t=this.actives.pop();t&&t.clear(),this._removeAllDeleteLabels(),this.specifiedClear=!1}cancel(){const t=this.actives.pop();t&&t.stop()}disableDefaultSelection({disableLeftClick:t=!1,disableDoubleClick:e=!0}={}){var n,s;const i=(s=(n=this.viewer)==null?void 0:n.cesiumWidget)==null?void 0:s.screenSpaceEventHandler;i&&(e&&i.removeInputAction(this.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),t&&i.removeInputAction(this.Cesium.ScreenSpaceEventType.LEFT_CLICK))}clearAll(){for(;this.actives.length;){const t=this.actives.pop();try{t==null||t.clear()}catch{}}for(const[,t]of this.recordHandlers)try{t.clear()}catch{}this.recordHandlers.clear(),this.measurements=[],this._removeAllDeleteLabels(),this.specifiedClear=!1}getMeasurementsConfig(){return{measurements:this.measurements.map(t=>({...t,options:t.options?{...t.options}:t.options,positions:t.positions?t.positions.map(e=>[e[0],e[1],e[2]]):t.positions,data:t.data?{...t.data}:t.data}))}}setMeasurementsConfig(t){var e,i;if((e=t==null?void 0:t.measurements)!=null&&e.length){for(const n of t.measurements){let s=null;switch(n.type){case"horizontal":s=new _e(this.Cesium,this.viewer);break;case"vertical":s=new Xe(this.Cesium,this.viewer);break;case"triangle":s=new Je(this.Cesium,this.viewer);break;case"space":s=new Ze(this.Cesium,this.viewer);break;case"area":s=new xe(this.Cesium,this.viewer);break;case"circle":s=new Qe(this.Cesium,this.viewer);break;case"polyline":s=new De(this.Cesium,this.viewer);break;case"terrainHeight":s=new et(this.Cesium,this.viewer);break;case"coordinate":s=new tt(this.Cesium,this.viewer);break;case"rectangle":s=new it(this.Cesium,this.viewer);break;case"regularPolygon":s=new st(this.Cesium,this.viewer);break;default:s=null}(i=s==null?void 0:s.rehydrate)==null||i.call(s,n,void 0),s&&n.id&&this.recordHandlers.set(n.id,s),this.measurements.find(r=>r.id===n.id)||this.measurements.push(n)}this.specifiedClear&&this._showDeleteLabels("html-label-container")}}_serializeMetrics(t,e){switch(t){case"space":return{distance:e==null?void 0:e.distance};case"horizontal":return{distance:e==null?void 0:e.distance};case"vertical":return{vertical:e==null?void 0:e.vertical};case"polyline":return{distance:e==null?void 0:e.distance};case"area":return{area:e==null?void 0:e.area};case"circle":return{radius:e==null?void 0:e.radius,area:e==null?void 0:e.area,perimeter:e==null?void 0:e.perimeter};case"rectangle":return{width:e==null?void 0:e.width,height:e==null?void 0:e.height,area:e==null?void 0:e.area};case"regularPolygon":return{sides:e==null?void 0:e.sides,radius:e==null?void 0:e.radius,perimeter:e==null?void 0:e.perimeter,area:e==null?void 0:e.area};case"triangle":return{lengths:e==null?void 0:e.lengths,angles:e==null?void 0:e.angles};case"terrainHeight":return{terrainHeight:e==null?void 0:e.terrainHeight,difference:e==null?void 0:e.difference,position:e==null?void 0:e.position,zeroPosition:e==null?void 0:e.zeroPosition};case"coordinate":return{lnglat:e==null?void 0:e.lnglat};default:return{}}}_toCartesian(t){const e=this.Cesium;return new e.Cartesian3(t[0],t[1],t[2])}_removeRecordVisual(t){const e=this.viewer;this.Cesium;const i=e.entities.values;for(let o=i.length-1;o>=0;o--){const r=i[o];try{e.entities.remove(r)}catch{}}const n=e.scene.primitives,s=[];n._primitives&&n._primitives.forEach(o=>s.push(o));for(const o of s)try{e.scene.primitives.remove(o)}catch{}this.htmlLabelPool&&this.htmlLabelPool.removeAll()}toggleSpecifiedClear(t){if(this.specifiedClear)this._removeAllDeleteLabels(),this.specifiedClear=!1;else{if(this.specifiedClear=!0,!this.deleteLabelPool){const e=t||"html-label-container";this.deleteLabelPool=new N(this.Cesium,this.viewer,e),this.deleteLabelPool.registerTheme("measure-delete-label",{createElement:(i,n)=>{i.innerHTML="删除",i.style.background="rgba(255,0,0,0.7)",i.style.color="#fff",i.style.font="12px sans-serif",i.style.padding="2px 6px",i.style.borderRadius="4px",i.style.whiteSpace="nowrap"},options:{offset:{x:0,y:-10}}}),this.deleteLabelPool.eventBus.addListener(V.Click,{name:"measurement_delete_label_click",fn:i=>{var s;if(!i||i.theme!=="measure-delete-label")return;const n=(s=i==null?void 0:i.data)==null?void 0:s.recordId;n&&this.deleteMeasurement(n)}},!0)}this._showDeleteLabels(t||"html-label-container")}}deleteMeasurement(t){const e=this.recordHandlers.get(t);if(e)try{e.clear()}catch{}this.recordHandlers.delete(t),this.measurements=this.measurements.filter(n=>n.id!==t);const i=this.deleteLabelIds.get(t);i&&this.deleteLabelPool&&this.deleteLabelPool.removeByIds([i]),this.deleteLabelIds.delete(t)}_showDeleteLabels(t){if(!this.deleteLabelPool)return;const e=this.Cesium;for(const i of this.measurements){const n="m_del_"+i.id;if(this.deleteLabelIds.has(i.id))continue;const s=this._computeRecordCenter(i);if(!s)continue;const o=e.Cartographic.fromCartesian(s),r=e.Math.toDegrees(o.longitude),h=e.Math.toDegrees(o.latitude),c=o.height||0;this.deleteLabelPool.add({recordId:i.id},{id:n,lon:r,lat:h,height:c,theme:"measure-delete-label",show:!0,style:{zIndex:"1000"}}),this.deleteLabelIds.set(i.id,n)}}_removeAllDeleteLabels(){if(this.deleteLabelPool){const t=Array.from(this.deleteLabelIds.values());t.length&&this.deleteLabelPool.removeByIds(t)}this.deleteLabelIds.clear()}_computeRecordCenter(t){var n,s;const e=this.Cesium,i=(t.positions||[]).map(o=>this._toCartesian(o));if(i.length>0){const o=i.reduce((c,d)=>c+d.x,0)/i.length,r=i.reduce((c,d)=>c+d.y,0)/i.length,h=i.reduce((c,d)=>c+d.z,0)/i.length;return new e.Cartesian3(o,r,h)}if(t.type==="coordinate"&&((n=t.data)!=null&&n.lnglat)){const o=t.data.lnglat.lng,r=t.data.lnglat.lat,h=t.data.lnglat.height||0;return e.Cartesian3.fromDegrees(o,r,h)}if(t.type==="terrainHeight"&&((s=t.data)!=null&&s.position)){const o=t.data.position;return new e.Cartesian3(o.x,o.y,o.z)}return null}}class ko{constructor({Cesium:t,viewer:e}){l(this,"Cesium");l(this,"viewer");l(this,"options",null);l(this,"entity",null);l(this,"viewEntities",[]);l(this,"startTime",null);l(this,"stopTime",null);l(this,"isPaused",!1);l(this,"lastTime",null);l(this,"onTick",t=>{if(!this.options||!this.entity)return;const e=t.currentTime;if(this.Cesium.JulianDate.lessThan(e,this.startTime)||this.Cesium.JulianDate.greaterThan(e,this.stopTime)){!this.options.loop&&this.Cesium.JulianDate.greaterThan(e,this.stopTime)&&this.viewer.clock.shouldAnimate&&(this.viewer.clock.shouldAnimate=!1,this.options.onComplete&&this.options.onComplete());return}const i=this.entity.position.getValue(e),n=this.entity.orientation.getValue(e);if(i&&n){const s=this.Cesium.Matrix4.fromTranslationQuaternionRotationScale(i,n,new this.Cesium.Cartesian3(1,1,1),new this.Cesium.Matrix4),o=this.Cesium.Transforms.fixedFrameToHeadingPitchRoll(s,this.viewer.scene.globe.ellipsoid,this.Cesium.Transforms.eastNorthUpToFixedFrame,new this.Cesium.HeadingPitchRoll);this.viewer.camera.setView({destination:i,orientation:{heading:o.heading,pitch:o.pitch,roll:o.roll}}),this.options.onTick&&this.options.onTick(e,i,o)}});this.Cesium=t,this.viewer=e}get Viewer(){return this.viewer}get CesiumInstance(){return this.Cesium}start(t){this.clear(),this.options=t,!((t.waypoints||[]).length<2)&&(this._setupEntities(t),this.viewer.clock.startTime=this.startTime.clone(),this.viewer.clock.stopTime=this.stopTime.clone(),this.viewer.clock.currentTime=this.startTime.clone(),this.viewer.clock.clockRange=t.loop?this.Cesium.ClockRange.LOOP_STOP:this.Cesium.ClockRange.CLAMPED,this.viewer.clock.multiplier=1,this.viewer.clock.shouldAnimate=!0,this.viewer.clock.onTick.addEventListener(this.onTick))}preview(t){this.clear(),this.options=t,!((t.waypoints||[]).length<2)&&this._setupEntities(t)}_setupEntities(t){const e=t.waypoints||[],i=new this.Cesium.SampledPositionProperty,n=new this.Cesium.SampledProperty(this.Cesium.Quaternion),s=[];for(const u of e){let m;u.destination?u.destination.x!==void 0?m=new this.Cesium.Cartesian3(u.destination.x,u.destination.y,u.destination.z):m=u.destination:u.lon!==void 0&&u.lat!==void 0&&(m=this.Cesium.Cartesian3.fromDegrees(u.lon,u.lat,u.height??0));let g;u.orientation?g=new this.Cesium.HeadingPitchRoll(u.orientation.heading,u.orientation.pitch,u.orientation.roll):g=this.Cesium.HeadingPitchRoll.fromDegrees(u.heading??0,u.pitch??-30,u.roll??0);const p=this.Cesium.Transforms.headingPitchRollQuaternion(m,g);s.push({position:m,orientation:p})}const o=this.Cesium.JulianDate.now(),r=t.speed||100;let h=0;const c=[];for(let u=0;u<s.length;u++){if(u===0)c.push(o.clone());else{const g=this.Cesium.Cartesian3.distance(s[u-1].position,s[u].position)/Math.max(r,.1);h+=g,c.push(this.Cesium.JulianDate.addSeconds(o,h,new this.Cesium.JulianDate))}i.addSample(c[u],s[u].position),n.addSample(c[u],s[u].orientation)}this.startTime=c[0],this.stopTime=c[c.length-1];const d={availability:new this.Cesium.TimeIntervalCollection([new this.Cesium.TimeInterval({start:this.startTime,stop:this.stopTime})]),position:i,orientation:n};t.modelUrl?d.model={uri:t.modelUrl,scale:t.modelScale??1,minimumPixelSize:64,runAnimations:t.modelAnimate??!0}:d.point={pixelSize:1,color:this.Cesium.Color.TRANSPARENT},t.showPath&&this.viewEntities.push(this.viewer.entities.add({polyline:{positions:s.map(u=>u.position),width:3,material:this.Cesium.Color.GREEN}})),this.entity=this.viewer.entities.add(d),t.showStops&&s.forEach((u,m)=>{const g=this.Cesium.Cartographic.fromCartesian(u.position),p=this.Cesium.Cartesian3.fromRadians(g.longitude,g.latitude,0);this.viewEntities.push(this.viewer.entities.add({position:u.position,point:{pixelSize:8,color:this.Cesium.Color.YELLOW,outlineColor:this.Cesium.Color.BLACK,outlineWidth:1},label:{text:""+(m+1),font:"12px sans-serif",pixelOffset:new this.Cesium.Cartesian2(0,-15),fillColor:this.Cesium.Color.WHITE,outlineColor:this.Cesium.Color.BLACK,outlineWidth:2,style:this.Cesium.LabelStyle.FILL_AND_OUTLINE},polyline:{positions:[u.position,p],width:2,material:new this.Cesium.PolylineDashMaterialProperty({color:this.Cesium.Color.RED,dashLength:16})}}))})}stop(){this.viewer.clock.shouldAnimate=!1,this.viewer.clock.onTick.removeEventListener(this.onTick)}pause(){this.viewer.clock.shouldAnimate=!1,this.isPaused=!0}resume(){this.viewer.clock.shouldAnimate=!0,this.isPaused=!1}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null);for(const t of this.viewEntities)this.viewer.entities.remove(t);this.viewEntities=[],this.options=null}captureCurrentView(){const t=this.viewer.camera.position.clone(),e=this.viewer.camera.heading,i=this.viewer.camera.pitch,n=this.viewer.camera.roll;return{destination:{x:t.x,y:t.y,z:t.z},orientation:{heading:e,pitch:i,roll:n}}}}class Oo{constructor({Cesium:t,viewer:e}){l(this,"Cesium");l(this,"viewer");l(this,"entity",null);l(this,"positionProperty",null);l(this,"startTime",null);l(this,"stopTime",null);l(this,"options",null);l(this,"cameraOffset",null);l(this,"onTick",t=>{if(!this.options||!this.positionProperty)return;const e=t.currentTime,i=this.positionProperty.getValue(e);if(this.options.followCamera&&this.options.initialView&&i){this.cameraOffset||(this.cameraOffset=this.Cesium.Cartesian3.subtract(this.options.initialView.destination,i,new this.Cesium.Cartesian3));const n=this.Cesium.Cartesian3.add(i,this.cameraOffset,new this.Cesium.Cartesian3);this.viewer.camera.setView({destination:n,orientation:this.options.initialView.orientation})}i&&this.options.onTick&&this.options.onTick(e,i),this.Cesium.JulianDate.greaterThanOrEquals(e,this.stopTime)&&(this.options.loop||(this.options.onComplete&&this.options.onComplete(),this.stop()))});this.Cesium=t,this.viewer=e}get Viewer(){return this.viewer}get CesiumInstance(){return this.Cesium}start(t){this.clear(),this.options=t;const e=this.normalizePositions(t.positions||[]);if(!e.length)return;const i=t.speed??30,n=this.buildTimes(e,i),s=new this.Cesium.SampledPositionProperty;for(let g=0;g<e.length;g++)s.addSample(n[g],e[g]);this.positionProperty=s;const o=new this.Cesium.VelocityOrientationProperty(s),r=t.showPath??!0,h=t.pathColor??this.Cesium.Color.YELLOW,c=t.pathWidth??3,d=t.pointColor??this.Cesium.Color.RED,u=t.pointPixelSize??8,m={availability:new this.Cesium.TimeIntervalCollection([new this.Cesium.TimeInterval({start:this.startTime,stop:this.stopTime})]),position:s,orientation:o,path:r?{material:h,width:c,leadTime:0}:void 0};t.modelUrl?m.model={uri:t.modelUrl,scale:t.modelScale??1,minimumPixelSize:64,runAnimations:t.modelAnimate??!0}:m.point={color:d,pixelSize:u},this.entity=this.viewer.entities.add(m),this.viewer.clock.startTime=this.startTime.clone(),this.viewer.clock.stopTime=this.stopTime.clone(),this.viewer.clock.currentTime=this.startTime.clone(),this.viewer.clock.clockRange=t.loop?this.Cesium.ClockRange.LOOP_STOP:this.Cesium.ClockRange.CLAMPED,this.viewer.clock.multiplier=1,this.viewer.clock.shouldAnimate=!0,t.initialView?(this.viewer.camera.setView({destination:t.initialView.destination,orientation:t.initialView.orientation}),this.cameraOffset=null):t.followCamera?this.viewer.trackedEntity=this.entity:t.lookAtOffset&&this.viewer.camera.lookAt(this.entity.position,t.lookAtOffset),this.viewer.clock.onTick.addEventListener(this.onTick)}stop(){this.viewer.clock.shouldAnimate=!1,this.viewer.clock.onTick.removeEventListener(this.onTick),this.viewer.trackedEntity===this.entity&&(this.viewer.trackedEntity=void 0)}clear(){this.stop(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.positionProperty=null,this.startTime=null,this.stopTime=null,this.options=null;try{this.viewer.camera.lookAtTransform(this.Cesium.Matrix4.IDENTITY)}catch{}}normalizePositions(t){const e=[];for(const i of t)if(Array.isArray(i)){const[n,s,o]=i;e.push(this.Cesium.Cartesian3.fromDegrees(n,s,o??0))}else(i==null?void 0:i.x)!==void 0&&(i==null?void 0:i.y)!==void 0&&(i==null?void 0:i.z)!==void 0&&e.push(i);return e}buildTimes(t,e){const i=[],n=this.Cesium.JulianDate.now();let s=0;for(let o=0;o<t.length;o++)if(o===0)i.push(n.clone());else{const r=this.Cesium.Cartesian3.distance(t[o-1],t[o]);s+=r/Math.max(e,.1),i.push(this.Cesium.JulianDate.addSeconds(n,s,new this.Cesium.JulianDate))}return this.startTime=i[0],this.stopTime=i[i.length-1],i}}A.AreaMeasure=xe,A.BufferedHierarchicalAggregator=te,A.CameraRoamTool=ko,A.CircleMeasure=Qe,A.CoordinateMeasure=tt,A.DOM_EVENT_MAP=ot,A.DrawTool=qt,A.EditMode=Bt,A.EntityLayerManager=Do,A.GLTFManage=Lo,A.GLTFManageEventKey=jt,A.HorizontalMeasure=_e,A.HtmlOverlayLabelPool=N,A.MarkerEventBus=nt,A.MarkerEventKey=V,A.MaterialManager=To,A.MeasurementTool=$o,A.PathRoamTool=Oo,A.PolylineDistanceMeasure=De,A.PrimitiveManager=Ao,A.RectangleMeasure=it,A.RegularPolygonMeasure=st,A.SpaceMeasure=Ze,A.TerrainHeightMeasure=et,A.TooltipManager=ce,A.TriangleMeasure=Je,A.VerticalMeasure=Xe,A.convertGeoJsonToEntityData=So,A.getDynamicImgMaterial=Eo,A.getPolylineFlowMaterialProperty=Io,A.getWallMaterial=Mo,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
77
77
  //# sourceMappingURL=cesium-core.umd.js.map