leiting-bim 2.1.62 → 2.1.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/leiting-bim.es.js +1 -1
- package/leiting-bim.umd.js +42 -48
- package/leitingbim.css +1 -1
- package/package.json +1 -1
- package/plugins/cesium-core/dist/cesium-core.mjs +301 -295
- package/plugins/cesium-core/dist/cesium-core.mjs.map +1 -1
- package/plugins/cesium-core/dist/cesium-core.umd.js +13 -13
- package/plugins/cesium-core/dist/cesium-core.umd.js.map +1 -1
- package/plugins/cesium-core/dist/components/BufferedHierarchicalAggregator.d.ts +2 -0
- package/plugins/cesium-core/package.json +1 -1
- package/plugins/cesium-vue/dist/cesium-vue/src/components/basic-audio/index.d.ts +13 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/basic-video/index.d.ts +98 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/card-carousel/index.d.ts +147 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/card-content/index.d.ts +16 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/card-page/index.d.ts +64 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/carousel-img/index.d.ts +34 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/echarts-pro/index.d.ts +63 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-bubble/index.d.ts +73 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-default/index.d.ts +43 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-html/index.d.ts +43 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-manage/index.d.ts +159 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/marker-text/index.d.ts +25 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/measurement/index.d.ts +73 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/components/position-picker/index.d.ts +58 -0
- package/plugins/cesium-vue/dist/cesium-vue/src/index.d.ts +46 -0
- package/plugins/cesium-vue/dist/components/basic-audio.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/basic-audio.js.map +1 -1
- package/plugins/cesium-vue/dist/components/basic-video.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/basic-video.js.map +1 -1
- package/plugins/cesium-vue/dist/components/card-carousel.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/card-carousel.js.map +1 -1
- package/plugins/cesium-vue/dist/components/card-content.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/card-content.js.map +1 -1
- package/plugins/cesium-vue/dist/components/card-page.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/card-page.js.map +1 -1
- package/plugins/cesium-vue/dist/components/carousel-img.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/carousel-img.js.map +1 -1
- package/plugins/cesium-vue/dist/components/echarts-pro.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/marker-bubble.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/marker-bubble.js.map +1 -1
- package/plugins/cesium-vue/dist/components/marker-default.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/marker-default.js.map +1 -1
- package/plugins/cesium-vue/dist/components/marker-html.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/marker-html.js.map +1 -1
- package/plugins/cesium-vue/dist/components/marker-manage.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/marker-manage.js +511 -488
- package/plugins/cesium-vue/dist/components/marker-manage.js.map +1 -1
- package/plugins/cesium-vue/dist/components/marker-text.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/marker-text.js.map +1 -1
- package/plugins/cesium-vue/dist/components/measurement.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/measurement.js.map +1 -1
- package/plugins/cesium-vue/dist/components/position-picker.d.ts +3 -3
- package/plugins/cesium-vue/dist/components/position-picker.js.map +1 -1
- package/plugins/cesium-vue/dist/index-CUs_hd1V.js.map +1 -1
- package/plugins/cesium-vue/dist/index-Kdqw0FJN.js.map +1 -1
- package/plugins/cesium-vue/dist/index.d.ts +6 -46
- package/plugins/cesium-vue/dist/index.js.map +1 -1
- package/plugins/cesium-vue/package.json +4 -4
- package/plugins/theme-chalk/package.json +1 -1
- package/plugins/utils/package.json +1 -1
- package/snapdom-D8jRyUPk.js +0 -2896
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(_,ie){typeof exports=="object"&&typeof module<"u"?ie(exports):typeof define=="function"&&define.amd?define(["exports"],ie):(_=typeof globalThis<"u"?globalThis:_||self,ie(_.CesiumCore={}))})(this,(function(_){"use strict";var Or=Object.defineProperty;var Fr=(_,ie,U)=>ie in _?Or(_,ie,{enumerable:!0,configurable:!0,writable:!0,value:U}):_[ie]=U;var h=(_,ie,U)=>Fr(_,typeof ie!="symbol"?ie+"":ie,U);class ie{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,"levelIndexByTileLevel",new Map);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);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;const r=this.viewer.scene&&this.viewer.scene.globe,s=r&&r._surface,o=s&&s._tileProvider;this.tilingScheme=(o==null?void 0:o.tilingScheme)||new this.Cesium.GeographicTilingScheme,this.levels=this._createLevels(),this._buildLevels(),this._updateFn=this._update.bind(this),r&&(this._tileLoadListener=n=>{n===0&&this._cameraDirty&&(this._cameraDirty=!1,this._scheduleUpdate())},r.tileLoadProgressEvent.addEventListener(this._tileLoadListener)),this._cameraChangedHandler=()=>{const n=this.viewer.scene,l=n&&n.globe;if(!l){this._scheduleUpdate();return}this._cameraDirty=!0,l.tilesLoaded&&(this._cameraDirty=!1,this._scheduleUpdate())},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._clearDebugGrids(),e&&this._update()}_createLevels(){const t=[];this.levelIndexByTileLevel=new Map;const e=0,i=this.maxLevel;let r=0;for(let s=e;s<=i;s++,r++){const o=360/Math.pow(2,s);t.push({level:s,size:o,minViewWidth:o*4}),this.levelIndexByTileLevel.set(s,r)}return t}addPoints(t){this.points=t,this._buildLevels()}appendPoints(t,e=!0){for(const i of t)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._updateTimer=null},this._updateDelay)}updatePoint(t){var s,o;const e=this.points.findIndex(n=>n.id===t.id);if(e===-1)return;const i=this.points[e];for(const n of this.levels){const l=n.level,c=this.gridLayers.get(l);if(!c)continue;const d=this.Cesium.Cartographic.fromDegrees(i.lon,i.lat),u=this.tilingScheme.positionToTileXY(d,l,new this.Cesium.Cartesian2);if(!u)continue;const m=`${u.x}_${u.y}`,g=c.get(m);if(g){const p=g.allPoints.findIndex(f=>f.id===t.id);if(p!==-1&&g.allPoints.splice(p,1),(s=i.data)!=null&&s.skipAggregation){const f=g.skipPoints.findIndex(w=>w.id===t.id);f!==-1&&g.skipPoints.splice(f,1)}else{const f=this.groupByTheme?(o=i.data)==null?void 0:o.theme:this.clusterTheme,w=g.groups.get(f);if(w){const y=w.findIndex(C=>C.id===t.id);y!==-1&&w.splice(y,1),w.length===0&&g.groups.delete(f)}}}}const r={...i,...t};this.points[e]=r,this._addPointToGrid(r),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 r=this.gridLayers.get(i.level);if(r)for(const[s,o]of r.entries()){o.allPoints=o.allPoints.filter(n=>!e.has(n.id)),o.skipPoints=o.skipPoints.filter(n=>!e.has(n.id));for(const[n,l]of o.groups.entries()){const c=l.filter(d=>!e.has(d.id));c.length===0?o.groups.delete(n):o.groups.set(n,c)}o.allPoints.length===0&&r.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,r,s,o,n;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),(r=(i=(e=t.data)==null?void 0:e.billboard)==null?void 0:i[0])!=null&&r.skipAggregation)p.skipPoints.push(t);else{const f=this.groupByTheme?(n=(o=(s=t.data)==null?void 0:s.billboard)==null?void 0:o[0])==null?void 0:n.theme:this.clusterTheme;p.groups.has(f)||p.groups.set(f,[]),p.groups.get(f).push(t)}}}_update(){var r,s,o,n;if(!this.labelPool)return;this.labelPool.reset(),this.debugCurrentGrids&&this._clearDebugGrids();const t=this.points.length<this.minGlobalPointCount?1/0:this.threshold;let e=0;const i=(l,c,d)=>{var E,I,D,A,T,S,x,$,F,O,R,Y,V,j,W;if(e>=this.displayLimit||l<0)return;l>=this.levels.length&&(l=this.levels.length-1);const u=this.levels[l],m=l===this.levels.length-1,g=u.level,p=this.gridLayers.get(g);if(!p)return;const f=`${c}_${d}`,w=p.get(f);if(!w)return;const y=this.tilingScheme.tileXYToRectangle(c,d,g),C=this.Cesium.Math.toDegrees(y.west),b=this.Cesium.Math.toDegrees(y.south),v=this.Cesium.Math.toDegrees(y.east),M=this.Cesium.Math.toDegrees(y.north),P=(C+v)/2,L=(b+M)/2;for(const H of w.skipPoints)if(((E=H.data)==null?void 0:E.show)!==!1){if(e>=this.displayLimit)break;this.labelPool.add(H.data,{id:`point-${H.id}`,lon:H.lon,lat:H.lat,height:H.height,theme:((A=(D=(I=H.data)==null?void 0:I.billboard)==null?void 0:D[0])==null?void 0:A.theme)||this.pointTheme,style:H.style}),e++}if(e>=this.displayLimit){this.debugCurrentGrids&&this._drawDebugGrid(C,b,v,M,f);return}for(const[H,ne]of w.groups){const K=ne.filter(z=>{var oe;return((oe=z.data)==null?void 0:oe.show)!==!1});if(K.length===0)continue;let ce=P,ue=L;if(this.centralPointMode=="firstPoint"&&(ce=((T=K[0])==null?void 0:T.lon)||0,ue=((S=K[0])==null?void 0:S.lat)||0),m||K.length<t)for(const z of K){if(e>=this.displayLimit)break;this.labelPool.add(z.data,{id:`point-${z.id}`,lon:z.lon,lat:z.lat,height:z.height,theme:((F=($=(x=z.data)==null?void 0:x.billboard)==null?void 0:$[0])==null?void 0:F.theme)||this.pointTheme,style:z.style}),e++}else{if(e>=this.displayLimit)break;const oe=((V=(Y=(R=(O=K[0])==null?void 0:O.data)==null?void 0:R.billboard)==null?void 0:Y[0])==null?void 0:V.theme)||this.clusterTheme,se=this.groupByTheme?`cluster-${l}-${c}-${d}-${H}`:`cluster-${l}-${c}-${d}`;this.labelPool.add({id:se,billboard:((W=(j=K[0])==null?void 0:j.data)==null?void 0:W.billboard)||[],count:K.length,gridKey:f,points:K,aggregationGroup:H},{id:se,lon:ce,lat:ue,theme:oe}),e++}}if(this.debugCurrentGrids){const H=this.levels[l].level;this._drawDebugGrid(C,b,v,M,`L:${H} X:${c} Y:${d}`)}};try{const l=this.viewer.scene&&this.viewer.scene.globe,c=l&&l._surface;let d;if(c&&(d=c._tilesToRender||c._tilesToRenderByTextureCount),!d||d.length===0){for(const m of this.points){if(e>=this.displayLimit)break;((r=m.data)==null?void 0:r.show)!==!1&&(this.labelPool.add(m.data,{id:`point-${m.id}`,lon:m.lon,lat:m.lat,height:m.height,theme:((n=(o=(s=m.data)==null?void 0:s.billboard)==null?void 0:o[0])==null?void 0:n.theme)||this.pointTheme,style:m.style}),e++)}this.labelPool.cleanup(),this.points.length>0&&this._tilesRetryCount<this._tilesRetryMax&&(this._tilesRetryCount++,this._scheduleUpdate());return}this._tilesRetryCount=0;const u=new Set;for(const m of d){const g=m.rectangle,p=m._level??m.level;if(!g||typeof p!="number")continue;let f=this.levelIndexByTileLevel.get(p);if(f===void 0){if(this.levels.length===0)continue;const S=this.levels[0].level,x=this.levels[this.levels.length-1].level;if(p>x)f=this.levels.length-1;else if(p<S)f=0;else{let $=0,F=1/0;for(let O=0;O<this.levels.length;O++){const R=Math.abs(this.levels[O].level-p);R<F&&(F=R,$=O)}f=$}}if(f===void 0)continue;const w=this.levels[f].level,y=m._x??m.x,C=m._y??m.y;if(typeof y=="number"&&typeof C=="number"){let S=y,x=C;const $=p-w;if($>0){const O=1<<$;S=Math.floor(y/O),x=Math.floor(C/O)}else if($<0){const O=1<<-$;S=y*O,x=C*O}const F=`${w}_${S}_${x}`;if(u.has(F))continue;u.add(F),i(f,S,x);continue}const v=this.levels[f].size,M=this.Cesium.Math.toDegrees(g.west),P=this.Cesium.Math.toDegrees(g.east),L=this.Cesium.Math.toDegrees(g.south),E=this.Cesium.Math.toDegrees(g.north),I=Math.floor((M- -180)/v),D=Math.floor((P- -180)/v),A=Math.floor((L- -90)/v),T=Math.floor((E- -90)/v);for(let S=I;S<=D;S++)for(let x=A;x<=T;x++){const $=`${w}_${S}_${x}`;u.has($)||(u.add($),i(f,S,x))}}}catch{this.labelPool.cleanup();return}this.labelPool.cleanup()}refresh(){this._update()}_drawDebugGrid(t,e,i,r,s){const o=this.Cesium.Rectangle.fromDegrees(t,e,i,r),n=this.viewer.entities.add({rectangle:{coordinates:o,material:this.Cesium.Color.YELLOW.withAlpha(.2),outline:!0,outlineColor:this.Cesium.Color.RED,height: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(n)}_clearDebugGrids(){for(const t of this.debugGrids)this.viewer.entities.remove(t);this.debugGrids=[]}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()}}var U=(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))(U||{});class tt{constructor(){h(this,"listenerMap",new Map)}addListener(t,e,i=!1){let r=this.listenerMap.get(t);return r||(r=new Map,this.listenerMap.set(t,r)),r.has(e.name)?i?(console.warn(`[MarkerEventBus] Overwriting listener "${e.name}" for event "${t}".`),r.set(e.name,e),!0):(console.warn(`[MarkerEventBus] Listener "${e.name}" for event "${t}" already exists. Use overwrite=true to replace it.`),!1):(r.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 r=this.listenerMap.get(t);if(r)for(const[s,o]of r.entries()){try{o.fn(e,i)}catch(n){console.error(`Error in listener "${s}" for event "${t}":`,n)}o.once&&r.delete(s)}}}const it={[U.Click]:"click",[U.DoubleClick]:"dblclick",[U.RightClick]:"contextmenu",[U.MouseEnter]:"mouseenter",[U.MouseLeave]:"mouseleave",[U.MouseDown]:"mousedown",[U.MouseUp]:"mouseup"};class B{constructor(t,e,i="html-label-container",r,s=!0){h(this,"viewer");h(this,"Cesium");h(this,"container");h(this,"labels",new Map);h(this,"activeIds",new Set);h(this,"_updateFn");h(this,"themes",{});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.eventBus=r||new tt,this.openWheel=s}_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:r,lat:s,height:o=0,theme:n,show:l=!0,notCreateElement:c=!1,style:d}=e,u=this.themes[n];if(!u){console.warn(`Theme "${n}" not registered`);return}let m=this.labels.get(i);if(m){m.theme=n,m.data=t,m.notCreateElement=c;try{m.unload=u.createElement(m.el,{id:i,theme:n,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,C=>{C.stopPropagation();const b=this.labels.get(i);this.eventBus.runListener(f,b,C)});let y=0;g.addEventListener("wheel",C=>{if(!this.openWheel)return;const b=C.currentTarget;y=Date.now();const v=y;b.style.pointerEvents="none",setTimeout(()=>{y===v&&(b.style.pointerEvents="auto")},2e3)})}let p=null;if(!c||l){try{p=u.createElement(g,{id:i,theme:n,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:n,data:t,notCreateElement:c,unload:p},this.labels.set(i,m)}m.el.dataset.lon=String(r),m.el.dataset.lat=String(s),m.el.dataset.height=String(o),m.el.style.zIndex=(d==null?void 0:d.zIndex)||"1",m.el.style.display=l?"block":"none",l&&this.activeIds.add(i)}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))}}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()}update(t,e){const i=this.labels.get(t);if(!i){console.warn(`Label with id "${t}" not found for update.`);return}const r=this.themes[i.theme];if(!r){console.warn(`Theme "${i.theme}" not registered.`);return}try{r.createElement(i.el,{id:t,theme:i.theme,data:e},r)}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))}}hideAll(){for(const t of this.labels.values())t.notCreateElement&&this.unloadByLabel(t),t.el.style.display="none",this.activeIds.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))}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 r=this.themes[i.theme];if(!r){console.warn(`Theme "${i.theme}" not registered`);return}i.unload=r.createElement(i.el,{id:e,theme:i.theme,data:i.data},r)||{}}catch(r){console.error(`Error creating label element for theme "${i.theme}":`,r);return}i.el.style.display="block",this.activeIds.add(e)}}}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")}async toWindowPositionByLonLat(t,e){const i=this.Cesium,r=this.viewer.scene,s=[i.Cartographic.fromDegrees(t,e)];let o;try{o=await r.clampToHeightMostDetailed(s)}catch{console.warn("clampToHeightMostDetailed failed, fallback to ellipsoid height.")}let n=0;o&&o[0]&&o[0].height!=null?n=o[0].height:n=0;const l=i.Cartesian3.fromDegrees(t,e,n);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.")}async _update(){var t;this.viewer.scene;for(const e of this.activeIds){const i=this.labels.get(e);if(!i)continue;const r=parseFloat(i.el.dataset.lon),s=parseFloat(i.el.dataset.lat),o=parseFloat(i.el.dataset.height||"0"),n=this.Cesium.Cartesian3.fromDegrees(r,s,o),l=this.toWindowCoordinates(n);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;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="block"}else i.el.style.display="none"}}destroy(){this.viewer.scene.postRender.removeEventListener(this._updateFn),this.labels.clear(),this.activeIds.clear()}}class xe{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 xe,this.tooltip.show("左键添加点"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(r=>{var m,g;const s=i.scene.pickPosition(r.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),n=e.Math.toDegrees(o.longitude),l=e.Math.toDegrees(o.latitude),c=o.height,d=i.entities.add({position:s,point:{pixelSize:10,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.entity=d;const u={entity:d,position:s,lnglat:{lng:n,lat:l,height:c},clear:()=>{this.clear()}};(m=t.onComplete)==null||m.call(t,u),this.stopDrawing(),(g=this.tooltip)==null||g.hide(),this.tooltip=null},e.ScreenSpaceEventType.LEFT_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.stopDrawing()}}class Bt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.tooltip=new xe,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(r=>{var n,l;const s=i.scene.pickPosition(r.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(o),this.entity||(this.entity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>this.positions,!1),width:3,material:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY,depthFailMaterial:((l=(n=t.color)==null?void 0:n.withAlpha)==null?void 0:l.call(n,.5))||e.Color.YELLOW.withAlpha(.5)}}))},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var o,n;if(this.stopDrawing(),(o=this.tooltip)==null||o.hide(),this.tooltip=null,this.positions.length<2)return;this.positions.length=this.positions.length-1;const r=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:r,clear:()=>{this.clear()}};(n=t.onComplete)==null||n.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class jt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"startPoint",null);h(this,"endPoint",null);h(this,"entity",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(r=>{var o;const s=i.scene.pickPosition(r.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 n=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c=Math.min(n.longitude,l.longitude),d=Math.max(n.longitude,l.longitude),u=Math.min(n.latitude,l.latitude),m=Math.max(n.latitude,l.latitude);return new e.Rectangle(c,u,d,m)}catch(n){console.warn("Rectangle calculation error:",n);return}},!1),material:t.color||e.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:e.Color.BLACK,disableDepthTestDistance:Number.POSITIVE_INFINITY}});else{this.stopDrawing();const n=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c={lng:e.Math.toDegrees(Math.min(n.longitude,l.longitude)),lat:e.Math.toDegrees(Math.min(n.latitude,l.latitude)),height:0},d={lng:e.Math.toDegrees(Math.max(n.longitude,l.longitude)),lat:e.Math.toDegrees(Math.max(n.latitude,l.latitude)),height:0},u={entity:this.entity,position:this.startPoint,lnglat:{lng:e.Math.toDegrees(n.longitude),lat:e.Math.toDegrees(n.latitude),height:n.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(r=>{if(!this.startPoint)return;const s=i.scene.pickPosition(r.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],r=this.viewer.camera.getPickRay(e.endPosition),s=this.viewer.scene.globe.pick(r,this.viewer.scene);s&&this.drawPreviewCircle(i,s,t)},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}drawPreviewCircle(t,e,i){const r=this.Cesium.Cartesian3.distance(t,e);if(this.entity)Math.abs(this.currentRadius-r)>.5&&(this.currentRadius=r);else{this.currentRadius=r;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,r=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},n=(t==null?void 0:t.step)||1,l=[],c=[];for(let m=0;m<360;m+=n){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(r),w=this.Cesium.Ellipsoid.WGS84.cartographicToCartesian(f);l.push(w);const y=this.Cesium.Cartographic.fromCartesian(w);c.push({lng:this.Cesium.Math.toDegrees(y.longitude),lat:this.Cesium.Math.toDegrees(y.latitude),height:y.height})}c.push(c[0]);const d=this.positions.map(m=>{const g=this.Cesium.Cartographic.fromCartesian(m);return{lng:this.Cesium.Math.toDegrees(g.longitude),lat:this.Cesium.Math.toDegrees(g.latitude),height:g.height}});(u=t.onComplete)==null||u.call(t,{entity:this.entity,positions:this.positions,lnglats:d,circlePoints:l,circleLnglats:c,center:o,radius:r,clear:()=>{this.clear()}})}stopDrawing(){this.handler&&(this.handler.destroy(),this.handler=null),this._isDrawing=!1}clear(){this.stopDrawing(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.positions=[],this.currentRadius=0}}class Vt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.tooltip=new xe,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(r=>{const s=i.scene.pickPosition(r.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,heightReference:e.HeightReference.CLAMP_TO_GROUND}});this.tempPoints.push(o),this.entity||(this.entity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>({positions:this.positions}),!1),material:t.color||e.Color.YELLOW.withAlpha(.5)}}))},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var o,n;if(this.stopDrawing(),(o=this.tooltip)==null||o.hide(),this.tooltip=null,this.positions.length<3)return;this.positions.length=this.positions.length-1;const r=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:r,clear:()=>{this.clear()}};(n=t.onComplete)==null||n.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class Wt{constructor(t,e){h(this,"viewer");h(this,"Cesium");h(this,"activeDrawer",null);this.viewer=e,this.Cesium=t}draw(t,e){var i;switch(this.clear(),t){case"point":this.activeDrawer=new Gt(this.Cesium,this.viewer);break;case"line":this.activeDrawer=new Bt(this.Cesium,this.viewer);break;case"rectangle":this.activeDrawer=new jt(this.Cesium,this.viewer);break;case"circle":this.activeDrawer=new Yt(this.Cesium,this.viewer);break;case"polygon":this.activeDrawer=new Vt(this.Cesium,this.viewer);break;default:throw new Error(`Unsupported draw type: ${t}`)}(i=this.activeDrawer)==null||i.startDrawing(e)}clear(){this.activeDrawer&&(this.activeDrawer.stopDrawing(),this.activeDrawer.clear(),this.activeDrawer=null)}cancel(){this.clear()}}var st=typeof global=="object"&&global&&global.Object===Object&&global,Ut=typeof self=="object"&&self&&self.Object===Object&&self,ae=st||Ut||Function("return this")(),ye=ae.Symbol,ot=Object.prototype,Kt=ot.hasOwnProperty,qt=ot.toString,Pe=ye?ye.toStringTag:void 0;function Xt(a){var t=Kt.call(a,Pe),e=a[Pe];try{a[Pe]=void 0;var i=!0}catch{}var r=qt.call(a);return i&&(t?a[Pe]=e:delete a[Pe]),r}var Jt=Object.prototype,Qt=Jt.toString;function Zt(a){return Qt.call(a)}var ei="[object Null]",ti="[object Undefined]",rt=ye?ye.toStringTag:void 0;function Le(a){return a==null?a===void 0?ti:ei:rt&&rt in Object(a)?Xt(a):Zt(a)}function Ee(a){return a!=null&&typeof a=="object"}var De=Array.isArray;function _e(a){var t=typeof a;return a!=null&&(t=="object"||t=="function")}var ii="[object AsyncFunction]",si="[object Function]",oi="[object GeneratorFunction]",ri="[object Proxy]";function nt(a){if(!_e(a))return!1;var t=Le(a);return t==si||t==oi||t==ii||t==ri}var ke=ae["__core-js_shared__"],at=(function(){var a=/[^.]+$/.exec(ke&&ke.keys&&ke.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""})();function ni(a){return!!at&&at in a}var ai=Function.prototype,li=ai.toString;function me(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(!_e(a)||ni(a))return!1;var t=nt(a)?gi:ci;return t.test(me(a))}function yi(a,t){return a==null?void 0:a[t]}function ge(a,t){var e=yi(a,t);return fi(e)?e:void 0}var Re=ge(ae,"WeakMap"),lt=Object.create,wi=(function(){function a(){}return function(t){if(!_e(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=ge(Object,"defineProperty");return a({},"",{}),a}catch{}})();function Ci(a,t){for(var e=-1,i=a==null?0:a.length;++e<i&&t(a[e],e,a)!==!1;);return a}var vi=9007199254740991,bi=/^(?:0|[1-9]\d*)$/;function Pi(a,t){var e=typeof a;return t=t??vi,!!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 xi(a){return a!=null&&dt(a.length)&&!nt(a)}var Di=Object.prototype;function pt(a){var t=a&&a.constructor,e=typeof t=="function"&&t.prototype||Di;return a===e}function _i(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 Ee(a)&&Le(a)==Si}var mt=Object.prototype,Ai=mt.hasOwnProperty,$i=mt.propertyIsEnumerable,Oi=ut((function(){return arguments})())?ut:function(a){return Ee(a)&&Ai.call(a,"callee")&&!$i.call(a,"callee")};function Fi(){return!1}var gt=typeof _=="object"&&_&&!_.nodeType&&_,ft=gt&&typeof module=="object"&&module&&!module.nodeType&&module,ki=ft&&ft.exports===gt,yt=ki?ae.Buffer:void 0,Ri=yt?yt.isBuffer:void 0,wt=Ri||Fi,Hi="[object Arguments]",zi="[object Array]",Ni="[object Boolean]",Gi="[object Date]",Bi="[object Error]",ji="[object Function]",Yi="[object Map]",Vi="[object Number]",Wi="[object Object]",Ui="[object RegExp]",Ki="[object Set]",qi="[object String]",Xi="[object WeakMap]",Ji="[object ArrayBuffer]",Qi="[object DataView]",Zi="[object Float32Array]",es="[object Float64Array]",ts="[object Int8Array]",is="[object Int16Array]",ss="[object Int32Array]",os="[object Uint8Array]",rs="[object Uint8ClampedArray]",ns="[object Uint16Array]",as="[object Uint32Array]",G={};G[Zi]=G[es]=G[ts]=G[is]=G[ss]=G[os]=G[rs]=G[ns]=G[as]=!0,G[Hi]=G[zi]=G[Ji]=G[Ni]=G[Qi]=G[Gi]=G[Bi]=G[ji]=G[Yi]=G[Vi]=G[Wi]=G[Ui]=G[Ki]=G[qi]=G[Xi]=!1;function ls(a){return Ee(a)&&dt(a.length)&&!!G[Le(a)]}function He(a){return function(t){return a(t)}}var Ct=typeof _=="object"&&_&&!_.nodeType&&_,Me=Ct&&typeof module=="object"&&module&&!module.nodeType&&module,hs=Me&&Me.exports===Ct,ze=hs&&st.process,we=(function(){try{var a=Me&&Me.require&&Me.require("util").types;return a||ze&&ze.binding&&ze.binding("util")}catch{}})(),vt=we&&we.isTypedArray,cs=vt?He(vt):ls,ds=Object.prototype,ps=ds.hasOwnProperty;function us(a,t){var e=De(a),i=!e&&Oi(a),r=!e&&!i&&wt(a),s=!e&&!i&&!r&&cs(a),o=e||i||r||s,n=o?_i(a.length,String):[],l=n.length;for(var c in a)ps.call(a,c)&&!(o&&(c=="length"||r&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Pi(c,l)))&&n.push(c);return n}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 xi(a)?us(a):ys(a)}var Ie=ge(Object,"create");function Cs(){this.__data__=Ie?Ie(null):{},this.size=0}function vs(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(Ie){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 Ie?t[a]!==void 0:Is.call(t,a)}var xs="__lodash_hash_undefined__";function Ds(a,t){var e=this.__data__;return this.size+=this.has(a)?0:1,e[a]=Ie&&t===void 0?xs:t,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=Cs,fe.prototype.delete=vs,fe.prototype.get=Es,fe.prototype.has=Ts,fe.prototype.set=Ds;function _s(){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 Fs(a){return Se(this.__data__,a)>-1}function ks(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 le(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])}}le.prototype.clear=_s,le.prototype.delete=$s,le.prototype.get=Os,le.prototype.has=Fs,le.prototype.set=ks;var Te=ge(ae,"Map");function Rs(){this.size=0,this.__data__={hash:new fe,map:new(Te||le),string:new fe}}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 Ce(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])}}Ce.prototype.clear=Rs,Ce.prototype.delete=zs,Ce.prototype.get=Ns,Ce.prototype.has=Gs,Ce.prototype.set=Bs;function js(a,t){for(var e=-1,i=t.length,r=a.length;++e<i;)a[r+e]=t[e];return a}var Ys=bt(Object.getPrototypeOf,Object);function Vs(){this.__data__=new le,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 le){var i=e.__data__;if(!Te||i.length<qs-1)return i.push([a,t]),this.size=++e.size,this;e=this.__data__=new Ce(i)}return e.set(a,t),this.size=e.size,this}function ve(a){var t=this.__data__=new le(a);this.size=t.size}ve.prototype.clear=Vs,ve.prototype.delete=Ws,ve.prototype.get=Us,ve.prototype.has=Ks,ve.prototype.set=Xs;var Pt=typeof _=="object"&&_&&!_.nodeType&&_,Lt=Pt&&typeof module=="object"&&module&&!module.nodeType&&module,Js=Lt&&Lt.exports===Pt,Et=Js?ae.Buffer:void 0;Et&&Et.allocUnsafe;function Qs(a,t){return a.slice()}function Zs(a,t){for(var e=-1,i=a==null?0:a.length,r=0,s=[];++e<i;){var o=a[e];t(o,e,a)&&(s[r++]=o)}return s}function eo(){return[]}var to=Object.prototype,io=to.propertyIsEnumerable,Mt=Object.getOwnPropertySymbols,so=Mt?function(a){return a==null?[]:(a=Object(a),Zs(Mt(a),function(t){return io.call(a,t)}))}:eo;function oo(a,t,e){var i=t(a);return De(a)?i:js(i,e(a))}function ro(a){return oo(a,ws,so)}var Ne=ge(ae,"DataView"),Ge=ge(ae,"Promise"),Be=ge(ae,"Set"),It="[object Map]",no="[object Object]",Tt="[object Promise]",xt="[object Set]",Dt="[object WeakMap]",_t="[object DataView]",ao=me(Ne),lo=me(Te),ho=me(Ge),co=me(Be),po=me(Re),he=Le;(Ne&&he(new Ne(new ArrayBuffer(1)))!=_t||Te&&he(new Te)!=It||Ge&&he(Ge.resolve())!=Tt||Be&&he(new Be)!=xt||Re&&he(new Re)!=Dt)&&(he=function(a){var t=Le(a),e=t==no?a.constructor:void 0,i=e?me(e):"";if(i)switch(i){case ao:return _t;case lo:return It;case ho:return Tt;case co:return xt;case po:return Dt}return t});var uo=Object.prototype,mo=uo.hasOwnProperty;function go(a){var t=a.length,e=new a.constructor(t);return t&&typeof a[0]=="string"&&mo.call(a,"index")&&(e.index=a.index,e.input=a.input),e}var St=ae.Uint8Array;function je(a){var t=new a.constructor(a.byteLength);return new St(t).set(new St(a)),t}function fo(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.byteLength)}var yo=/\w*$/;function wo(a){var t=new a.constructor(a.source,yo.exec(a));return t.lastIndex=a.lastIndex,t}var At=ye?ye.prototype:void 0,$t=At?At.valueOf:void 0;function Co(a){return $t?Object($t.call(a)):{}}function vo(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.length)}var bo="[object Boolean]",Po="[object Date]",Lo="[object Map]",Eo="[object Number]",Mo="[object RegExp]",Io="[object Set]",To="[object String]",xo="[object Symbol]",Do="[object ArrayBuffer]",_o="[object DataView]",So="[object Float32Array]",Ao="[object Float64Array]",$o="[object Int8Array]",Oo="[object Int16Array]",Fo="[object Int32Array]",ko="[object Uint8Array]",Ro="[object Uint8ClampedArray]",Ho="[object Uint16Array]",zo="[object Uint32Array]";function No(a,t,e){var i=a.constructor;switch(t){case Do:return je(a);case bo:case Po:return new i(+a);case _o:return fo(a);case So:case Ao:case $o:case Oo:case Fo:case ko:case Ro:case Ho:case zo:return vo(a);case Lo:return new i;case Eo:case To:return new i(a);case Mo:return wo(a);case Io:return new i;case xo:return Co(a)}}function Go(a){return typeof a.constructor=="function"&&!pt(a)?wi(Ys(a)):{}}var Bo="[object Map]";function jo(a){return Ee(a)&&he(a)==Bo}var Ot=we&&we.isMap,Yo=Ot?He(Ot):jo,Vo="[object Set]";function Wo(a){return Ee(a)&&he(a)==Vo}var Ft=we&&we.isSet,Uo=Ft?He(Ft):Wo,kt="[object Arguments]",Ko="[object Array]",qo="[object Boolean]",Xo="[object Date]",Jo="[object Error]",Rt="[object Function]",Qo="[object GeneratorFunction]",Zo="[object Map]",er="[object Number]",Ht="[object Object]",tr="[object RegExp]",ir="[object Set]",sr="[object String]",or="[object Symbol]",rr="[object WeakMap]",nr="[object ArrayBuffer]",ar="[object DataView]",lr="[object Float32Array]",hr="[object Float64Array]",cr="[object Int8Array]",dr="[object Int16Array]",pr="[object Int32Array]",ur="[object Uint8Array]",mr="[object Uint8ClampedArray]",gr="[object Uint16Array]",fr="[object Uint32Array]",N={};N[kt]=N[Ko]=N[nr]=N[ar]=N[qo]=N[Xo]=N[lr]=N[hr]=N[cr]=N[dr]=N[pr]=N[Zo]=N[er]=N[Ht]=N[tr]=N[ir]=N[sr]=N[or]=N[ur]=N[mr]=N[gr]=N[fr]=!0,N[Jo]=N[Rt]=N[rr]=!1;function $e(a,t,e,i,r,s){var o;if(o!==void 0)return o;if(!_e(a))return a;var n=De(a);if(n)o=go(a);else{var l=he(a),c=l==Rt||l==Qo;if(wt(a))return Qs(a);if(l==Ht||l==kt||c&&!r)o=c?{}:Go(a);else{if(!N[l])return r?a:{};o=No(a,l)}}s||(s=new ve);var d=s.get(a);if(d)return d;s.set(a,o),Uo(a)?a.forEach(function(g){o.add($e(g,t,e,g,a,s))}):Yo(a)&&a.forEach(function(g,p){o.set(p,$e(g,t,e,p,a,s))});var u=ro,m=n?void 0:u(a);return Ci(m||a,function(g,p){m&&(p=g,g=a[p]),Ii(o,p,$e(g,t,e,p,a,s))}),o}var yr=1,wr=4;function Oe(a){return $e(a,yr|wr)}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 Cr{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(r=>{i.scene.primitives.remove(r)}),t.forEach(r=>{this.primitives.has(r.id)||this.add(r,e)})}get(t){return this.primitives.get(t)}add(t,e=!0){var u,m,g;const i=this.viewer,r=this.Cesium,s=r.Math.toRadians(((u=t.headingPitchRoll)==null?void 0:u.heading)||0),o=r.Math.toRadians(((m=t.headingPitchRoll)==null?void 0:m.pitch)||0),n=r.Math.toRadians(((g=t.headingPitchRoll)==null?void 0:g.roll)||0),l=new r.HeadingPitchRoll(s,o,n),c=r.Transforms.headingPitchRollToFixedFrame(t.position,l,i.scene.globe.ellipsoid,r.Transforms.eastNorthUpToFixedFrame,new r.Matrix4);let d=i.scene.primitives.add(r.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 r=this.primitives.get(t);const s=r.boundingSphere,o=i.Matrix4.multiplyByPoint(r.modelMatrix,s.center,new i.Cartesian3),n=new i.BoundingSphere(o,s.radius);e.camera.flyToBoundingSphere(n,{duration:1.5,offset:new i.HeadingPitchRange(0,-.5,s.radius*2)})}removeById(t){var r;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),(!((r=this.rotationRing)!=null&&r._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,r=e.latitude-t.latitude;return Math.atan2(r,i)}getModelHeadingPitchRoll(t){const e=this.Cesium,i=this.viewer,r=e.Transforms.eastNorthUpToFixedFrame(e.Matrix4.getTranslation(t,new e.Cartesian3),i.scene.globe.ellipsoid,new e.Matrix4),s=e.Matrix4.multiply(e.Matrix4.inverse(r,new e.Matrix4),t,new e.Matrix4),o=e.Matrix4.getRotation(s,new e.Matrix3),n=e.Quaternion.fromRotationMatrix(o);return e.HeadingPitchRoll.fromQuaternion(n)}addEventListener(t,e,i){let r={f:e,options:i};return this.eventListener.get(t)?(this.eventListener.get(t)||[]).push(r):this.eventListener.set(t,[r]),r}removeEventListener(t,e){let i=this.eventListener.get(t);if(!i)return console.error("key不存在");let r=i.findIndex(s=>s==e);r>=0?i.splice(r,1):console.error("instantiation不存在")}runEventListener(t,e){let i=this.eventListener.get(t);return i?(i.forEach(r=>{typeof r.f=="function"&&r.f(e)}),!0):!1}initEditBox(t){const e=this.Cesium,i=this.viewer,r=i.scene;let s=null,o=null,n=null,l=null,c=null;const d=()=>{s=null,o=null,n=null,c=null,l=null,this.setEditMode(""),this.unlockCamera()},u=(m,g)=>{if(s=this.primitives.get(m),s){o=e.Matrix4.clone(s.modelMatrix);const p=e.Matrix4.getTranslation(o,new e.Cartesian3);n=this.toCartographic(p),c=g.position;const f=r.globe.pick(i.camera.getPickRay(g.position),r);l=this.toCartographic(f),this.lockCamera()}};this.handler.setInputAction(m=>{var f,w,y,C,b,v,M,P,L,E;if(!t())return;const p=r.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&&((C=p.id)!=null&&C.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||!((v=(b=this.rotationRing)==null?void 0:b._instanceIds)!=null&&v.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=r.globe.pick(i.camera.getPickRay(m.endPosition),r),f=this.toCartographic(p);let w=0;if(this.editMode==="rotate"){let y=this.calculateHeading(n,f);w=this.calculateHeading(n,l)-y,this.rotateModel(s,o,w)}else this.editMode==="move"?this.moveModel(s,o,m):this.editMode==="moveHeight"&&this.moveModelHeight(s,o,m,c)}},e.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(()=>{if(!t())return;let g=this.dragEndCallbackMap.get(s==null?void 0:s.id);if(g&&(this.editMode==="move"||this.editMode==="moveHeight")){let p=g.get("translation");p&&(this.runEventListener("translation",p),g.delete("translation"))}else if(g&&this.editMode==="rotate"){let p=g.get("rotate");p&&(this.runEventListener("rotate",p),g.delete("rotate"))}d()},e.ScreenSpaceEventType.LEFT_UP),this.handler.setInputAction(()=>{this.removeTool()},e.ScreenSpaceEventType.RIGHT_UP)}createRotationRing(t){const e=this.Cesium,i=this.viewer;this.rotationRing&&i.scene.primitives.remove(this.rotationRing);const r=[];for(let n=0;n<=360;n+=3){const l=Math.sin(e.Math.toRadians(n)),c=Math.cos(e.Math.toRadians(n)),d=t.boundingSphere.radius*c,u=t.boundingSphere.radius*l;r.push(new e.Cartesian3(d,u,0))}const s=new e.PolylineGeometry({positions:r,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)}),n=new e.GeometryInstance({id:`translationSquare_${t.id}`,geometry:o,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.BLUE)}});this.translationSquare=new e.Primitive({geometryInstances:n,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 r=e.Color.GREEN,s=Math.max(t.boundingSphere.radius*.025,1),o=2*s,n=t.boundingSphere.radius+50,l=n*.1;const c=Math.max(t.boundingSphere.radius*.2,1),d=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:n,topRadius:s,bottomRadius:s})),u=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:l,topRadius:0,bottomRadius:o}));let m=n+c,g=(n+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:r}),translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:r.withAlpha(.3)}),translucent:!0}),cull:!1}),i.scene.primitives.add(this.heightArrow)}translate(t,e){let i=this.Cesium;const r=new i.Cartesian3;De(e)?(r.x=e[0],r.y=e[1],r.z=e[2]):i.Cartesian3.clone(e,r);for(let s=0;s<t.attributes.position.values.length;s+=3)t.attributes.position.values[s]+=r.x,t.attributes.position.values[s+1]+=r.y,t.attributes.position.values[s+2]+=r.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 r=this.Cesium,s=this.viewer,o=s.scene,n=o.globe.pick(s.camera.getPickRay(i.endPosition),o);if(n){const l=r.Matrix4.getTranslation(e,new r.Cartesian3),c=r.Cartographic.fromCartesian(l),d=r.Cartographic.fromCartesian(n),u=new r.Cartographic(d.longitude,d.latitude,c.height),m=r.Cartographic.toCartesian(u),g=r.Matrix4.getRotation(e,new r.Matrix3),p=r.Matrix4.fromRotationTranslation(g,m);t.modelMatrix=p,this.updatedTool(p);let f=new r.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,r){const s=this.Cesium,o=this.viewer,n=o.scene,l=r.y-i.endPosition.y;if(n.globe.pick(o.camera.getPickRay(i.endPosition),n)){const d=s.Matrix4.getTranslation(e,new s.Cartesian3),u=s.Cartographic.fromCartesian(d),m=new s.Cartographic(u.longitude,u.latitude,u.height+l*.001*Math.max(o.camera.positionCartographic.height,1)),g=s.Cartographic.toCartesian(m),p=s.Matrix4.getRotation(e,new s.Matrix3),f=s.Matrix4.fromRotationTranslation(p,g);t.modelMatrix=f,this.updatedTool(f);let w=new s.Cartesian3(f[12],f[13],f[14]),y=this.dragEndCallbackMap.get(t.id);y||(y=new Map,this.dragEndCallbackMap.set(t.id,y)),y.set("translation",{id:t.id,position:w})}}rotateModel(t,e,i){const r=this.Cesium,s=this.viewer,o=this.getModelHeadingPitchRoll(e),n=o.heading+i,l=new r.HeadingPitchRoll(n,o.pitch,o.roll),c=r.Transforms.headingPitchRollToFixedFrame(r.Matrix4.getTranslation(t.modelMatrix,new r.Cartesian3),l,s.scene.globe.ellipsoid,r.Transforms.eastNorthUpToFixedFrame,new r.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:r.Math.toDegrees(n),pitch:r.Math.toDegrees(o.pitch),roll:r.Math.toDegrees(o.roll)}})}cleanup(){this.handler&&(this.handler.destroy(),this.handler=null)}}function vr(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 r=function(s){return`
|
|
1
|
+
(function(D,se){typeof exports=="object"&&typeof module<"u"?se(exports):typeof define=="function"&&define.amd?define(["exports"],se):(D=typeof globalThis<"u"?globalThis:D||self,se(D.CesiumCore={}))})(this,(function(D){"use strict";var Or=Object.defineProperty;var Fr=(D,se,J)=>se in D?Or(D,se,{enumerable:!0,configurable:!0,writable:!0,value:J}):D[se]=J;var h=(D,se,J)=>Fr(D,typeof se!="symbol"?se+"":se,J);class se{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,"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);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;const r=this.viewer.scene&&this.viewer.scene.globe,s=r&&r._surface,o=s&&s._tileProvider,n=(o==null?void 0:o.tilingScheme)||new this.Cesium.GeographicTilingScheme;this._lastTileProvider=o,this.tilingScheme=n,this.levels=this._createLevels(),this._buildLevels(),this._updateFn=this._update.bind(this),r&&(this._tileLoadListener=l=>{l===0&&this._cameraDirty&&(this._cameraDirty=!1,this._scheduleUpdate())},r.tileLoadProgressEvent.addEventListener(this._tileLoadListener)),this._cameraChangedHandler=()=>{const l=this.viewer.scene,c=l&&l.globe;if(!c){this._scheduleUpdate();return}this._cameraDirty=!0,c.tilesLoaded&&(this._cameraDirty=!1,this._scheduleUpdate())},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._clearDebugGrids(),e&&this._update()}_syncTilingSchemeAndLevels(){const t=this.viewer.scene&&this.viewer.scene.globe,e=t&&t._surface,i=e&&e._tileProvider,r=(i==null?void 0:i.tilingScheme)||new this.Cesium.GeographicTilingScheme,s=i!==this._lastTileProvider,o=this.tilingScheme!==r;!s&&!o&&this.levels&&this.levels.length>0||(this._lastTileProvider=i,this.tilingScheme=r,this.levels=this._createLevels(),this._buildLevels())}_createLevels(){const t=[];this.levelIndexByTileLevel=new Map;const e=0,i=this.maxLevel;let r=0;for(let s=e;s<=i;s++,r++){const o=360/Math.pow(2,s);t.push({level:s,size:o,minViewWidth:o*4}),this.levelIndexByTileLevel.set(s,r)}return t}addPoints(t){this.points=t,this._buildLevels()}appendPoints(t,e=!0){for(const i of t)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._updateTimer=null},this._updateDelay)}updatePoint(t){var s,o;const e=this.points.findIndex(n=>n.id===t.id);if(e===-1)return;const i=this.points[e];for(const n of this.levels){const l=n.level,c=this.gridLayers.get(l);if(!c)continue;const d=this.Cesium.Cartographic.fromDegrees(i.lon,i.lat),u=this.tilingScheme.positionToTileXY(d,l,new this.Cesium.Cartesian2);if(!u)continue;const m=`${u.x}_${u.y}`,g=c.get(m);if(g){const p=g.allPoints.findIndex(f=>f.id===t.id);if(p!==-1&&g.allPoints.splice(p,1),(s=i.data)!=null&&s.skipAggregation){const f=g.skipPoints.findIndex(w=>w.id===t.id);f!==-1&&g.skipPoints.splice(f,1)}else{const f=this.groupByTheme?(o=i.data)==null?void 0:o.theme:this.clusterTheme,w=g.groups.get(f);if(w){const y=w.findIndex(C=>C.id===t.id);y!==-1&&w.splice(y,1),w.length===0&&g.groups.delete(f)}}}}const r={...i,...t};this.points[e]=r,this._addPointToGrid(r),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 r=this.gridLayers.get(i.level);if(r)for(const[s,o]of r.entries()){o.allPoints=o.allPoints.filter(n=>!e.has(n.id)),o.skipPoints=o.skipPoints.filter(n=>!e.has(n.id));for(const[n,l]of o.groups.entries()){const c=l.filter(d=>!e.has(d.id));c.length===0?o.groups.delete(n):o.groups.set(n,c)}o.allPoints.length===0&&r.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,r,s,o,n;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),(r=(i=(e=t.data)==null?void 0:e.billboard)==null?void 0:i[0])!=null&&r.skipAggregation)p.skipPoints.push(t);else{const f=this.groupByTheme?(n=(o=(s=t.data)==null?void 0:s.billboard)==null?void 0:o[0])==null?void 0:n.theme:this.clusterTheme;p.groups.has(f)||p.groups.set(f,[]),p.groups.get(f).push(t)}}}_update(){var r,s,o,n;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=(l,c,d)=>{var E,I,_,A,T,S,x,$,F,O,R,V,W,B,K,q,re;if(e>=this.displayLimit||l<0)return;l>=this.levels.length&&(l=this.levels.length-1);const u=this.levels[l],m=l===this.levels.length-1,g=u.level,p=this.gridLayers.get(g);if(!p)return;const f=`${c}_${d}`,w=p.get(f);if(!w)return;const y=this.tilingScheme.tileXYToRectangle(c,d,g),C=this.Cesium.Math.toDegrees(y.west),b=this.Cesium.Math.toDegrees(y.south),v=this.Cesium.Math.toDegrees(y.east),M=this.Cesium.Math.toDegrees(y.north),P=(C+v)/2,L=(b+M)/2;for(const j of w.skipPoints)if(((E=j.data)==null?void 0:E.show)!==!1){if(e>=this.displayLimit)break;this.labelPool.add(j.data,{id:`point-${j.id}`,lon:j.lon,lat:j.lat,height:j.height,theme:((A=(_=(I=j.data)==null?void 0:I.billboard)==null?void 0:_[0])==null?void 0:A.theme)||this.pointTheme,style:j.style}),e++}if(e>=this.displayLimit){this.debugCurrentGrids&&this._drawDebugGrid(C,b,v,M,f);return}for(const[j,ue]of w.groups){const X=ue.filter(H=>{var U;return((U=H.data)==null?void 0:U.show)!==!1});if(X.length===0)continue;let Y=P,he=L,oe=((T=X[0])==null?void 0:T.height)||0;if(this.centralPointMode=="firstPoint"&&(Y=((S=X[0])==null?void 0:S.lon)||0,he=((x=X[0])==null?void 0:x.lat)||0,oe=(($=X[0])==null?void 0:$.height)||0),m||X.length<t)for(const H of X){if(e>=this.displayLimit)break;this.labelPool.add(H.data,{id:`point-${H.id}`,lon:H.lon,lat:H.lat,height:H.height,theme:((R=(O=(F=H.data)==null?void 0:F.billboard)==null?void 0:O[0])==null?void 0:R.theme)||this.pointTheme,style:H.style}),e++}else{if(e>=this.displayLimit)break;const U=((K=(B=(W=(V=X[0])==null?void 0:V.data)==null?void 0:W.billboard)==null?void 0:B[0])==null?void 0:K.theme)||this.clusterTheme,ne=this.groupByTheme?`cluster-${l}-${c}-${d}-${j}`:`cluster-${l}-${c}-${d}`;this.labelPool.add({id:ne,billboard:((re=(q=X[0])==null?void 0:q.data)==null?void 0:re.billboard)||[],count:X.length,gridKey:f,points:X,aggregationGroup:j},{id:ne,lon:Y,lat:he,height:oe,theme:U}),e++}}if(this.debugCurrentGrids){const j=this.levels[l].level;this._drawDebugGrid(C,b,v,M,`L:${j} X:${c} Y:${d}`)}};try{const l=this.viewer.scene&&this.viewer.scene.globe,c=l&&l._surface;let d;if(c&&(d=c._tilesToRender||c._tilesToRenderByTextureCount),!d||d.length===0){for(const m of this.points){if(e>=this.displayLimit)break;((r=m.data)==null?void 0:r.show)!==!1&&(this.labelPool.add(m.data,{id:`point-${m.id}`,lon:m.lon,lat:m.lat,height:m.height,theme:((n=(o=(s=m.data)==null?void 0:s.billboard)==null?void 0:o[0])==null?void 0:n.theme)||this.pointTheme,style:m.style}),e++)}this.labelPool.cleanup(),this.points.length>0&&this._tilesRetryCount<this._tilesRetryMax&&(this._tilesRetryCount++,this._scheduleUpdate());return}this._tilesRetryCount=0;const u=new Set;for(const m of d){const g=m.rectangle,p=m._level??m.level;if(!g||typeof p!="number")continue;let f=this.levelIndexByTileLevel.get(p);if(f===void 0){if(this.levels.length===0)continue;const S=this.levels[0].level,x=this.levels[this.levels.length-1].level;if(p>x)f=this.levels.length-1;else if(p<S)f=0;else{let $=0,F=1/0;for(let O=0;O<this.levels.length;O++){const R=Math.abs(this.levels[O].level-p);R<F&&(F=R,$=O)}f=$}}if(f===void 0)continue;const w=this.levels[f].level,y=m._x??m.x,C=m._y??m.y;if(typeof y=="number"&&typeof C=="number"){let S=y,x=C;const $=p-w;if($>0){const O=1<<$;S=Math.floor(y/O),x=Math.floor(C/O)}else if($<0){const O=1<<-$;S=y*O,x=C*O}const F=`${w}_${S}_${x}`;if(u.has(F))continue;u.add(F),i(f,S,x);continue}const v=this.levels[f].size,M=this.Cesium.Math.toDegrees(g.west),P=this.Cesium.Math.toDegrees(g.east),L=this.Cesium.Math.toDegrees(g.south),E=this.Cesium.Math.toDegrees(g.north),I=Math.floor((M- -180)/v),_=Math.floor((P- -180)/v),A=Math.floor((L- -90)/v),T=Math.floor((E- -90)/v);for(let S=I;S<=_;S++)for(let x=A;x<=T;x++){const $=`${w}_${S}_${x}`;u.has($)||(u.add($),i(f,S,x))}}}catch{this.labelPool.cleanup();return}this.labelPool.cleanup()}refresh(){this._update()}_drawDebugGrid(t,e,i,r,s){const o=this.Cesium.Rectangle.fromDegrees(t,e,i,r),n=this.viewer.entities.add({rectangle:{coordinates:o,material:this.Cesium.Color.YELLOW.withAlpha(.2),outline:!0,outlineColor:this.Cesium.Color.RED,height: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(n)}_clearDebugGrids(){for(const t of this.debugGrids)this.viewer.entities.remove(t);this.debugGrids=[]}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()}}var J=(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))(J||{});class tt{constructor(){h(this,"listenerMap",new Map)}addListener(t,e,i=!1){let r=this.listenerMap.get(t);return r||(r=new Map,this.listenerMap.set(t,r)),r.has(e.name)?i?(console.warn(`[MarkerEventBus] Overwriting listener "${e.name}" for event "${t}".`),r.set(e.name,e),!0):(console.warn(`[MarkerEventBus] Listener "${e.name}" for event "${t}" already exists. Use overwrite=true to replace it.`),!1):(r.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 r=this.listenerMap.get(t);if(r)for(const[s,o]of r.entries()){try{o.fn(e,i)}catch(n){console.error(`Error in listener "${s}" for event "${t}":`,n)}o.once&&r.delete(s)}}}const it={[J.Click]:"click",[J.DoubleClick]:"dblclick",[J.RightClick]:"contextmenu",[J.MouseEnter]:"mouseenter",[J.MouseLeave]:"mouseleave",[J.MouseDown]:"mousedown",[J.MouseUp]:"mouseup"};class G{constructor(t,e,i="html-label-container",r,s=!0){h(this,"viewer");h(this,"Cesium");h(this,"container");h(this,"labels",new Map);h(this,"activeIds",new Set);h(this,"_updateFn");h(this,"themes",{});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.eventBus=r||new tt,this.openWheel=s}_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:r,lat:s,height:o=0,theme:n,show:l=!0,notCreateElement:c=!1,style:d}=e,u=this.themes[n];if(!u){console.warn(`Theme "${n}" not registered`);return}let m=this.labels.get(i);if(m){m.theme=n,m.data=t,m.notCreateElement=c;try{m.unload=u.createElement(m.el,{id:i,theme:n,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,C=>{C.stopPropagation();const b=this.labels.get(i);this.eventBus.runListener(f,b,C)});let y=0;g.addEventListener("wheel",C=>{if(!this.openWheel)return;const b=C.currentTarget;y=Date.now();const v=y;b.style.pointerEvents="none",setTimeout(()=>{y===v&&(b.style.pointerEvents="auto")},2e3)})}let p=null;if(!c||l){try{p=u.createElement(g,{id:i,theme:n,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:n,data:t,notCreateElement:c,unload:p},this.labels.set(i,m)}m.el.dataset.lon=String(r),m.el.dataset.lat=String(s),m.el.dataset.height=String(o),m.el.style.zIndex=(d==null?void 0:d.zIndex)||"1",m.el.style.display=l?"block":"none",l&&this.activeIds.add(i)}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))}}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()}update(t,e){const i=this.labels.get(t);if(!i){console.warn(`Label with id "${t}" not found for update.`);return}const r=this.themes[i.theme];if(!r){console.warn(`Theme "${i.theme}" not registered.`);return}try{r.createElement(i.el,{id:t,theme:i.theme,data:e},r)}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))}}hideAll(){for(const t of this.labels.values())t.notCreateElement&&this.unloadByLabel(t),t.el.style.display="none",this.activeIds.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))}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 r=this.themes[i.theme];if(!r){console.warn(`Theme "${i.theme}" not registered`);return}i.unload=r.createElement(i.el,{id:e,theme:i.theme,data:i.data},r)||{}}catch(r){console.error(`Error creating label element for theme "${i.theme}":`,r);return}i.el.style.display="block",this.activeIds.add(e)}}}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")}async toWindowPositionByLonLat(t,e){const i=this.Cesium,r=this.viewer.scene,s=[i.Cartographic.fromDegrees(t,e)];let o;try{o=await r.clampToHeightMostDetailed(s)}catch{console.warn("clampToHeightMostDetailed failed, fallback to ellipsoid height.")}let n=0;o&&o[0]&&o[0].height!=null?n=o[0].height:n=0;const l=i.Cartesian3.fromDegrees(t,e,n);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.")}async _update(){var t;this.viewer.scene;for(const e of this.activeIds){const i=this.labels.get(e);if(!i)continue;const r=parseFloat(i.el.dataset.lon),s=parseFloat(i.el.dataset.lat),o=parseFloat(i.el.dataset.height||"0"),n=this.Cesium.Cartesian3.fromDegrees(r,s,o),l=this.toWindowCoordinates(n);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;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="block"}else i.el.style.display="none"}}destroy(){this.viewer.scene.postRender.removeEventListener(this._updateFn),this.labels.clear(),this.activeIds.clear()}}class xe{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 xe,this.tooltip.show("左键添加点"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(r=>{var m,g;const s=i.scene.pickPosition(r.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),n=e.Math.toDegrees(o.longitude),l=e.Math.toDegrees(o.latitude),c=o.height,d=i.entities.add({position:s,point:{pixelSize:10,color:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.entity=d;const u={entity:d,position:s,lnglat:{lng:n,lat:l,height:c},clear:()=>{this.clear()}};(m=t.onComplete)==null||m.call(t,u),this.stopDrawing(),(g=this.tooltip)==null||g.hide(),this.tooltip=null},e.ScreenSpaceEventType.LEFT_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.stopDrawing()}}class Bt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.tooltip=new xe,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(r=>{var n,l;const s=i.scene.pickPosition(r.position);if(!s)return;this.positions.push(s);const o=i.entities.add({position:s,point:{pixelSize:8,color:e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(o),this.entity||(this.entity=i.entities.add({polyline:{positions:new e.CallbackProperty(()=>this.positions,!1),width:3,material:t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY,depthFailMaterial:((l=(n=t.color)==null?void 0:n.withAlpha)==null?void 0:l.call(n,.5))||e.Color.YELLOW.withAlpha(.5)}}))},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var o,n;if(this.stopDrawing(),(o=this.tooltip)==null||o.hide(),this.tooltip=null,this.positions.length<2)return;this.positions.length=this.positions.length-1;const r=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:r,clear:()=>{this.clear()}};(n=t.onComplete)==null||n.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class jt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"startPoint",null);h(this,"endPoint",null);h(this,"entity",null);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(r=>{var o;const s=i.scene.pickPosition(r.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 n=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c=Math.min(n.longitude,l.longitude),d=Math.max(n.longitude,l.longitude),u=Math.min(n.latitude,l.latitude),m=Math.max(n.latitude,l.latitude);return new e.Rectangle(c,u,d,m)}catch(n){console.warn("Rectangle calculation error:",n);return}},!1),material:t.color||e.Color.YELLOW.withAlpha(.5),outline:!0,outlineColor:e.Color.BLACK,disableDepthTestDistance:Number.POSITIVE_INFINITY}});else{this.stopDrawing();const n=e.Cartographic.fromCartesian(this.startPoint),l=e.Cartographic.fromCartesian(this.endPoint),c={lng:e.Math.toDegrees(Math.min(n.longitude,l.longitude)),lat:e.Math.toDegrees(Math.min(n.latitude,l.latitude)),height:0},d={lng:e.Math.toDegrees(Math.max(n.longitude,l.longitude)),lat:e.Math.toDegrees(Math.max(n.latitude,l.latitude)),height:0},u={entity:this.entity,position:this.startPoint,lnglat:{lng:e.Math.toDegrees(n.longitude),lat:e.Math.toDegrees(n.latitude),height:n.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(r=>{if(!this.startPoint)return;const s=i.scene.pickPosition(r.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],r=this.viewer.camera.getPickRay(e.endPosition),s=this.viewer.scene.globe.pick(r,this.viewer.scene);s&&this.drawPreviewCircle(i,s,t)},this.Cesium.ScreenSpaceEventType.MOUSE_MOVE)}drawPreviewCircle(t,e,i){const r=this.Cesium.Cartesian3.distance(t,e);if(this.entity)Math.abs(this.currentRadius-r)>.5&&(this.currentRadius=r);else{this.currentRadius=r;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,r=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},n=(t==null?void 0:t.step)||1,l=[],c=[];for(let m=0;m<360;m+=n){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(r),w=this.Cesium.Ellipsoid.WGS84.cartographicToCartesian(f);l.push(w);const y=this.Cesium.Cartographic.fromCartesian(w);c.push({lng:this.Cesium.Math.toDegrees(y.longitude),lat:this.Cesium.Math.toDegrees(y.latitude),height:y.height})}c.push(c[0]);const d=this.positions.map(m=>{const g=this.Cesium.Cartographic.fromCartesian(m);return{lng:this.Cesium.Math.toDegrees(g.longitude),lat:this.Cesium.Math.toDegrees(g.latitude),height:g.height}});(u=t.onComplete)==null||u.call(t,{entity:this.entity,positions:this.positions,lnglats:d,circlePoints:l,circleLnglats:c,center:o,radius:r,clear:()=>{this.clear()}})}stopDrawing(){this.handler&&(this.handler.destroy(),this.handler=null),this._isDrawing=!1}clear(){this.stopDrawing(),this.entity&&(this.viewer.entities.remove(this.entity),this.entity=null),this.positions=[],this.currentRadius=0}}class Vt{constructor(t,e){h(this,"Cesium");h(this,"viewer");h(this,"handler",null);h(this,"positions",[]);h(this,"entity",null);h(this,"tooltip",null);h(this,"tempPoints",[]);this.Cesium=t,this.viewer=e}startDrawing(t){const{Cesium:e,viewer:i}=this;this.positions=[],this.tempPoints=[],this.tooltip=new xe,this.tooltip.show("单击左键添加点,双击左键结束"),this.handler=new e.ScreenSpaceEventHandler(i.canvas),this.handler.setInputAction(r=>{const s=i.scene.pickPosition(r.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,heightReference:e.HeightReference.CLAMP_TO_GROUND}});this.tempPoints.push(o),this.entity||(this.entity=i.entities.add({polygon:{hierarchy:new e.CallbackProperty(()=>({positions:this.positions}),!1),material:t.color||e.Color.YELLOW.withAlpha(.5)}}))},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(()=>{var o,n;if(this.stopDrawing(),(o=this.tooltip)==null||o.hide(),this.tooltip=null,this.positions.length<3)return;this.positions.length=this.positions.length-1;const r=this.positions.map(l=>{const c=e.Cartographic.fromCartesian(l);return{lng:e.Math.toDegrees(c.longitude),lat:e.Math.toDegrees(c.latitude),height:c.height}}),s={entity:this.entity,positions:this.positions,lnglats:r,clear:()=>{this.clear()}};(n=t.onComplete)==null||n.call(t,s)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}stopDrawing(){var t;(t=this.handler)==null||t.destroy(),this.handler=null}clear(){var e;const{viewer:t}=this;this.entity&&(t.entities.remove(this.entity),this.entity=null),this.tempPoints.forEach(i=>t.entities.remove(i)),this.tempPoints=[],(e=this.tooltip)==null||e.hide(),this.tooltip=null,this.positions=[],this.stopDrawing()}}class Wt{constructor(t,e){h(this,"viewer");h(this,"Cesium");h(this,"activeDrawer",null);this.viewer=e,this.Cesium=t}draw(t,e){var i;switch(this.clear(),t){case"point":this.activeDrawer=new Gt(this.Cesium,this.viewer);break;case"line":this.activeDrawer=new Bt(this.Cesium,this.viewer);break;case"rectangle":this.activeDrawer=new jt(this.Cesium,this.viewer);break;case"circle":this.activeDrawer=new Yt(this.Cesium,this.viewer);break;case"polygon":this.activeDrawer=new Vt(this.Cesium,this.viewer);break;default:throw new Error(`Unsupported draw type: ${t}`)}(i=this.activeDrawer)==null||i.startDrawing(e)}clear(){this.activeDrawer&&(this.activeDrawer.stopDrawing(),this.activeDrawer.clear(),this.activeDrawer=null)}cancel(){this.clear()}}var st=typeof global=="object"&&global&&global.Object===Object&&global,Ut=typeof self=="object"&&self&&self.Object===Object&&self,le=st||Ut||Function("return this")(),ye=le.Symbol,ot=Object.prototype,Kt=ot.hasOwnProperty,qt=ot.toString,Pe=ye?ye.toStringTag:void 0;function Xt(a){var t=Kt.call(a,Pe),e=a[Pe];try{a[Pe]=void 0;var i=!0}catch{}var r=qt.call(a);return i&&(t?a[Pe]=e:delete a[Pe]),r}var Jt=Object.prototype,Qt=Jt.toString;function Zt(a){return Qt.call(a)}var ei="[object Null]",ti="[object Undefined]",rt=ye?ye.toStringTag:void 0;function Le(a){return a==null?a===void 0?ti:ei:rt&&rt in Object(a)?Xt(a):Zt(a)}function Ee(a){return a!=null&&typeof a=="object"}var _e=Array.isArray;function De(a){var t=typeof a;return a!=null&&(t=="object"||t=="function")}var ii="[object AsyncFunction]",si="[object Function]",oi="[object GeneratorFunction]",ri="[object Proxy]";function nt(a){if(!De(a))return!1;var t=Le(a);return t==si||t==oi||t==ii||t==ri}var ke=le["__core-js_shared__"],at=(function(){var a=/[^.]+$/.exec(ke&&ke.keys&&ke.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""})();function ni(a){return!!at&&at in a}var ai=Function.prototype,li=ai.toString;function me(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)||ni(a))return!1;var t=nt(a)?gi:ci;return t.test(me(a))}function yi(a,t){return a==null?void 0:a[t]}function ge(a,t){var e=yi(a,t);return fi(e)?e:void 0}var Re=ge(le,"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=ge(Object,"defineProperty");return a({},"",{}),a}catch{}})();function Ci(a,t){for(var e=-1,i=a==null?0:a.length;++e<i&&t(a[e],e,a)!==!1;);return a}var vi=9007199254740991,bi=/^(?:0|[1-9]\d*)$/;function Pi(a,t){var e=typeof a;return t=t??vi,!!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 xi(a){return a!=null&&dt(a.length)&&!nt(a)}var _i=Object.prototype;function pt(a){var t=a&&a.constructor,e=typeof t=="function"&&t.prototype||_i;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 Ee(a)&&Le(a)==Si}var mt=Object.prototype,Ai=mt.hasOwnProperty,$i=mt.propertyIsEnumerable,Oi=ut((function(){return arguments})())?ut:function(a){return Ee(a)&&Ai.call(a,"callee")&&!$i.call(a,"callee")};function Fi(){return!1}var gt=typeof D=="object"&&D&&!D.nodeType&&D,ft=gt&&typeof module=="object"&&module&&!module.nodeType&&module,ki=ft&&ft.exports===gt,yt=ki?le.Buffer:void 0,Ri=yt?yt.isBuffer:void 0,wt=Ri||Fi,Hi="[object Arguments]",zi="[object Array]",Ni="[object Boolean]",Gi="[object Date]",Bi="[object Error]",ji="[object Function]",Yi="[object Map]",Vi="[object Number]",Wi="[object Object]",Ui="[object RegExp]",Ki="[object Set]",qi="[object String]",Xi="[object WeakMap]",Ji="[object ArrayBuffer]",Qi="[object DataView]",Zi="[object Float32Array]",es="[object Float64Array]",ts="[object Int8Array]",is="[object Int16Array]",ss="[object Int32Array]",os="[object Uint8Array]",rs="[object Uint8ClampedArray]",ns="[object Uint16Array]",as="[object Uint32Array]",N={};N[Zi]=N[es]=N[ts]=N[is]=N[ss]=N[os]=N[rs]=N[ns]=N[as]=!0,N[Hi]=N[zi]=N[Ji]=N[Ni]=N[Qi]=N[Gi]=N[Bi]=N[ji]=N[Yi]=N[Vi]=N[Wi]=N[Ui]=N[Ki]=N[qi]=N[Xi]=!1;function ls(a){return Ee(a)&&dt(a.length)&&!!N[Le(a)]}function He(a){return function(t){return a(t)}}var Ct=typeof D=="object"&&D&&!D.nodeType&&D,Me=Ct&&typeof module=="object"&&module&&!module.nodeType&&module,hs=Me&&Me.exports===Ct,ze=hs&&st.process,we=(function(){try{var a=Me&&Me.require&&Me.require("util").types;return a||ze&&ze.binding&&ze.binding("util")}catch{}})(),vt=we&&we.isTypedArray,cs=vt?He(vt):ls,ds=Object.prototype,ps=ds.hasOwnProperty;function us(a,t){var e=_e(a),i=!e&&Oi(a),r=!e&&!i&&wt(a),s=!e&&!i&&!r&&cs(a),o=e||i||r||s,n=o?Di(a.length,String):[],l=n.length;for(var c in a)ps.call(a,c)&&!(o&&(c=="length"||r&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Pi(c,l)))&&n.push(c);return n}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 xi(a)?us(a):ys(a)}var Ie=ge(Object,"create");function Cs(){this.__data__=Ie?Ie(null):{},this.size=0}function vs(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(Ie){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 Ie?t[a]!==void 0:Is.call(t,a)}var xs="__lodash_hash_undefined__";function _s(a,t){var e=this.__data__;return this.size+=this.has(a)?0:1,e[a]=Ie&&t===void 0?xs:t,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=Cs,fe.prototype.delete=vs,fe.prototype.get=Es,fe.prototype.has=Ts,fe.prototype.set=_s;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 Fs(a){return Se(this.__data__,a)>-1}function ks(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 ce(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])}}ce.prototype.clear=Ds,ce.prototype.delete=$s,ce.prototype.get=Os,ce.prototype.has=Fs,ce.prototype.set=ks;var Te=ge(le,"Map");function Rs(){this.size=0,this.__data__={hash:new fe,map:new(Te||ce),string:new fe}}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 Ce(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])}}Ce.prototype.clear=Rs,Ce.prototype.delete=zs,Ce.prototype.get=Ns,Ce.prototype.has=Gs,Ce.prototype.set=Bs;function js(a,t){for(var e=-1,i=t.length,r=a.length;++e<i;)a[r+e]=t[e];return a}var Ys=bt(Object.getPrototypeOf,Object);function Vs(){this.__data__=new ce,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 ce){var i=e.__data__;if(!Te||i.length<qs-1)return i.push([a,t]),this.size=++e.size,this;e=this.__data__=new Ce(i)}return e.set(a,t),this.size=e.size,this}function ve(a){var t=this.__data__=new ce(a);this.size=t.size}ve.prototype.clear=Vs,ve.prototype.delete=Ws,ve.prototype.get=Us,ve.prototype.has=Ks,ve.prototype.set=Xs;var Pt=typeof D=="object"&&D&&!D.nodeType&&D,Lt=Pt&&typeof module=="object"&&module&&!module.nodeType&&module,Js=Lt&&Lt.exports===Pt,Et=Js?le.Buffer:void 0;Et&&Et.allocUnsafe;function Qs(a,t){return a.slice()}function Zs(a,t){for(var e=-1,i=a==null?0:a.length,r=0,s=[];++e<i;){var o=a[e];t(o,e,a)&&(s[r++]=o)}return s}function eo(){return[]}var to=Object.prototype,io=to.propertyIsEnumerable,Mt=Object.getOwnPropertySymbols,so=Mt?function(a){return a==null?[]:(a=Object(a),Zs(Mt(a),function(t){return io.call(a,t)}))}:eo;function oo(a,t,e){var i=t(a);return _e(a)?i:js(i,e(a))}function ro(a){return oo(a,ws,so)}var Ne=ge(le,"DataView"),Ge=ge(le,"Promise"),Be=ge(le,"Set"),It="[object Map]",no="[object Object]",Tt="[object Promise]",xt="[object Set]",_t="[object WeakMap]",Dt="[object DataView]",ao=me(Ne),lo=me(Te),ho=me(Ge),co=me(Be),po=me(Re),de=Le;(Ne&&de(new Ne(new ArrayBuffer(1)))!=Dt||Te&&de(new Te)!=It||Ge&&de(Ge.resolve())!=Tt||Be&&de(new Be)!=xt||Re&&de(new Re)!=_t)&&(de=function(a){var t=Le(a),e=t==no?a.constructor:void 0,i=e?me(e):"";if(i)switch(i){case ao:return Dt;case lo:return It;case ho:return Tt;case co:return xt;case po:return _t}return t});var uo=Object.prototype,mo=uo.hasOwnProperty;function go(a){var t=a.length,e=new a.constructor(t);return t&&typeof a[0]=="string"&&mo.call(a,"index")&&(e.index=a.index,e.input=a.input),e}var St=le.Uint8Array;function je(a){var t=new a.constructor(a.byteLength);return new St(t).set(new St(a)),t}function fo(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.byteLength)}var yo=/\w*$/;function wo(a){var t=new a.constructor(a.source,yo.exec(a));return t.lastIndex=a.lastIndex,t}var At=ye?ye.prototype:void 0,$t=At?At.valueOf:void 0;function Co(a){return $t?Object($t.call(a)):{}}function vo(a,t){var e=je(a.buffer);return new a.constructor(e,a.byteOffset,a.length)}var bo="[object Boolean]",Po="[object Date]",Lo="[object Map]",Eo="[object Number]",Mo="[object RegExp]",Io="[object Set]",To="[object String]",xo="[object Symbol]",_o="[object ArrayBuffer]",Do="[object DataView]",So="[object Float32Array]",Ao="[object Float64Array]",$o="[object Int8Array]",Oo="[object Int16Array]",Fo="[object Int32Array]",ko="[object Uint8Array]",Ro="[object Uint8ClampedArray]",Ho="[object Uint16Array]",zo="[object Uint32Array]";function No(a,t,e){var i=a.constructor;switch(t){case _o:return je(a);case bo:case Po:return new i(+a);case Do:return fo(a);case So:case Ao:case $o:case Oo:case Fo:case ko:case Ro:case Ho:case zo:return vo(a);case Lo:return new i;case Eo:case To:return new i(a);case Mo:return wo(a);case Io:return new i;case xo:return Co(a)}}function Go(a){return typeof a.constructor=="function"&&!pt(a)?wi(Ys(a)):{}}var Bo="[object Map]";function jo(a){return Ee(a)&&de(a)==Bo}var Ot=we&&we.isMap,Yo=Ot?He(Ot):jo,Vo="[object Set]";function Wo(a){return Ee(a)&&de(a)==Vo}var Ft=we&&we.isSet,Uo=Ft?He(Ft):Wo,kt="[object Arguments]",Ko="[object Array]",qo="[object Boolean]",Xo="[object Date]",Jo="[object Error]",Rt="[object Function]",Qo="[object GeneratorFunction]",Zo="[object Map]",er="[object Number]",Ht="[object Object]",tr="[object RegExp]",ir="[object Set]",sr="[object String]",or="[object Symbol]",rr="[object WeakMap]",nr="[object ArrayBuffer]",ar="[object DataView]",lr="[object Float32Array]",hr="[object Float64Array]",cr="[object Int8Array]",dr="[object Int16Array]",pr="[object Int32Array]",ur="[object Uint8Array]",mr="[object Uint8ClampedArray]",gr="[object Uint16Array]",fr="[object Uint32Array]",z={};z[kt]=z[Ko]=z[nr]=z[ar]=z[qo]=z[Xo]=z[lr]=z[hr]=z[cr]=z[dr]=z[pr]=z[Zo]=z[er]=z[Ht]=z[tr]=z[ir]=z[sr]=z[or]=z[ur]=z[mr]=z[gr]=z[fr]=!0,z[Jo]=z[Rt]=z[rr]=!1;function $e(a,t,e,i,r,s){var o;if(o!==void 0)return o;if(!De(a))return a;var n=_e(a);if(n)o=go(a);else{var l=de(a),c=l==Rt||l==Qo;if(wt(a))return Qs(a);if(l==Ht||l==kt||c&&!r)o=c?{}:Go(a);else{if(!z[l])return r?a:{};o=No(a,l)}}s||(s=new ve);var d=s.get(a);if(d)return d;s.set(a,o),Uo(a)?a.forEach(function(g){o.add($e(g,t,e,g,a,s))}):Yo(a)&&a.forEach(function(g,p){o.set(p,$e(g,t,e,p,a,s))});var u=ro,m=n?void 0:u(a);return Ci(m||a,function(g,p){m&&(p=g,g=a[p]),Ii(o,p,$e(g,t,e,p,a,s))}),o}var yr=1,wr=4;function Oe(a){return $e(a,yr|wr)}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 Cr{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(r=>{i.scene.primitives.remove(r)}),t.forEach(r=>{this.primitives.has(r.id)||this.add(r,e)})}get(t){return this.primitives.get(t)}add(t,e=!0){var u,m,g;const i=this.viewer,r=this.Cesium,s=r.Math.toRadians(((u=t.headingPitchRoll)==null?void 0:u.heading)||0),o=r.Math.toRadians(((m=t.headingPitchRoll)==null?void 0:m.pitch)||0),n=r.Math.toRadians(((g=t.headingPitchRoll)==null?void 0:g.roll)||0),l=new r.HeadingPitchRoll(s,o,n),c=r.Transforms.headingPitchRollToFixedFrame(t.position,l,i.scene.globe.ellipsoid,r.Transforms.eastNorthUpToFixedFrame,new r.Matrix4);let d=i.scene.primitives.add(r.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 r=this.primitives.get(t);const s=r.boundingSphere,o=i.Matrix4.multiplyByPoint(r.modelMatrix,s.center,new i.Cartesian3),n=new i.BoundingSphere(o,s.radius);e.camera.flyToBoundingSphere(n,{duration:1.5,offset:new i.HeadingPitchRange(0,-.5,s.radius*2)})}removeById(t){var r;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),(!((r=this.rotationRing)!=null&&r._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,r=e.latitude-t.latitude;return Math.atan2(r,i)}getModelHeadingPitchRoll(t){const e=this.Cesium,i=this.viewer,r=e.Transforms.eastNorthUpToFixedFrame(e.Matrix4.getTranslation(t,new e.Cartesian3),i.scene.globe.ellipsoid,new e.Matrix4),s=e.Matrix4.multiply(e.Matrix4.inverse(r,new e.Matrix4),t,new e.Matrix4),o=e.Matrix4.getRotation(s,new e.Matrix3),n=e.Quaternion.fromRotationMatrix(o);return e.HeadingPitchRoll.fromQuaternion(n)}addEventListener(t,e,i){let r={f:e,options:i};return this.eventListener.get(t)?(this.eventListener.get(t)||[]).push(r):this.eventListener.set(t,[r]),r}removeEventListener(t,e){let i=this.eventListener.get(t);if(!i)return console.error("key不存在");let r=i.findIndex(s=>s==e);r>=0?i.splice(r,1):console.error("instantiation不存在")}runEventListener(t,e){let i=this.eventListener.get(t);return i?(i.forEach(r=>{typeof r.f=="function"&&r.f(e)}),!0):!1}initEditBox(t){const e=this.Cesium,i=this.viewer,r=i.scene;let s=null,o=null,n=null,l=null,c=null;const d=()=>{s=null,o=null,n=null,c=null,l=null,this.setEditMode(""),this.unlockCamera()},u=(m,g)=>{if(s=this.primitives.get(m),s){o=e.Matrix4.clone(s.modelMatrix);const p=e.Matrix4.getTranslation(o,new e.Cartesian3);n=this.toCartographic(p),c=g.position;const f=r.globe.pick(i.camera.getPickRay(g.position),r);l=this.toCartographic(f),this.lockCamera()}};this.handler.setInputAction(m=>{var f,w,y,C,b,v,M,P,L,E;if(!t())return;const p=r.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&&((C=p.id)!=null&&C.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||!((v=(b=this.rotationRing)==null?void 0:b._instanceIds)!=null&&v.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=r.globe.pick(i.camera.getPickRay(m.endPosition),r),f=this.toCartographic(p);let w=0;if(this.editMode==="rotate"){let y=this.calculateHeading(n,f);w=this.calculateHeading(n,l)-y,this.rotateModel(s,o,w)}else this.editMode==="move"?this.moveModel(s,o,m):this.editMode==="moveHeight"&&this.moveModelHeight(s,o,m,c)}},e.ScreenSpaceEventType.MOUSE_MOVE),this.handler.setInputAction(()=>{if(!t())return;let g=this.dragEndCallbackMap.get(s==null?void 0:s.id);if(g&&(this.editMode==="move"||this.editMode==="moveHeight")){let p=g.get("translation");p&&(this.runEventListener("translation",p),g.delete("translation"))}else if(g&&this.editMode==="rotate"){let p=g.get("rotate");p&&(this.runEventListener("rotate",p),g.delete("rotate"))}d()},e.ScreenSpaceEventType.LEFT_UP),this.handler.setInputAction(()=>{this.removeTool()},e.ScreenSpaceEventType.RIGHT_UP)}createRotationRing(t){const e=this.Cesium,i=this.viewer;this.rotationRing&&i.scene.primitives.remove(this.rotationRing);const r=[];for(let n=0;n<=360;n+=3){const l=Math.sin(e.Math.toRadians(n)),c=Math.cos(e.Math.toRadians(n)),d=t.boundingSphere.radius*c,u=t.boundingSphere.radius*l;r.push(new e.Cartesian3(d,u,0))}const s=new e.PolylineGeometry({positions:r,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)}),n=new e.GeometryInstance({id:`translationSquare_${t.id}`,geometry:o,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.BLUE)}});this.translationSquare=new e.Primitive({geometryInstances:n,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 r=e.Color.GREEN,s=Math.max(t.boundingSphere.radius*.025,1),o=2*s,n=t.boundingSphere.radius+50,l=n*.1;const c=Math.max(t.boundingSphere.radius*.2,1),d=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:n,topRadius:s,bottomRadius:s})),u=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:l,topRadius:0,bottomRadius:o}));let m=n+c,g=(n+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:r}),translucent:!0}),depthFailAppearance:new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:r.withAlpha(.3)}),translucent:!0}),cull:!1}),i.scene.primitives.add(this.heightArrow)}translate(t,e){let i=this.Cesium;const r=new i.Cartesian3;_e(e)?(r.x=e[0],r.y=e[1],r.z=e[2]):i.Cartesian3.clone(e,r);for(let s=0;s<t.attributes.position.values.length;s+=3)t.attributes.position.values[s]+=r.x,t.attributes.position.values[s+1]+=r.y,t.attributes.position.values[s+2]+=r.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 r=this.Cesium,s=this.viewer,o=s.scene,n=o.globe.pick(s.camera.getPickRay(i.endPosition),o);if(n){const l=r.Matrix4.getTranslation(e,new r.Cartesian3),c=r.Cartographic.fromCartesian(l),d=r.Cartographic.fromCartesian(n),u=new r.Cartographic(d.longitude,d.latitude,c.height),m=r.Cartographic.toCartesian(u),g=r.Matrix4.getRotation(e,new r.Matrix3),p=r.Matrix4.fromRotationTranslation(g,m);t.modelMatrix=p,this.updatedTool(p);let f=new r.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,r){const s=this.Cesium,o=this.viewer,n=o.scene,l=r.y-i.endPosition.y;if(n.globe.pick(o.camera.getPickRay(i.endPosition),n)){const d=s.Matrix4.getTranslation(e,new s.Cartesian3),u=s.Cartographic.fromCartesian(d),m=new s.Cartographic(u.longitude,u.latitude,u.height+l*.001*Math.max(o.camera.positionCartographic.height,1)),g=s.Cartographic.toCartesian(m),p=s.Matrix4.getRotation(e,new s.Matrix3),f=s.Matrix4.fromRotationTranslation(p,g);t.modelMatrix=f,this.updatedTool(f);let w=new s.Cartesian3(f[12],f[13],f[14]),y=this.dragEndCallbackMap.get(t.id);y||(y=new Map,this.dragEndCallbackMap.set(t.id,y)),y.set("translation",{id:t.id,position:w})}}rotateModel(t,e,i){const r=this.Cesium,s=this.viewer,o=this.getModelHeadingPitchRoll(e),n=o.heading+i,l=new r.HeadingPitchRoll(n,o.pitch,o.roll),c=r.Transforms.headingPitchRollToFixedFrame(r.Matrix4.getTranslation(t.modelMatrix,new r.Cartesian3),l,s.scene.globe.ellipsoid,r.Transforms.eastNorthUpToFixedFrame,new r.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:r.Math.toDegrees(n),pitch:r.Math.toDegrees(o.pitch),roll:r.Math.toDegrees(o.roll)}})}cleanup(){this.handler&&(this.handler.destroy(),this.handler=null)}}function vr(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 r=function(s){return`
|
|
2
2
|
czm_material czm_getMaterial(czm_materialInput materialInput)
|
|
3
3
|
{
|
|
4
4
|
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
return material;
|
|
26
26
|
}
|
|
27
|
-
`,o};return a.Material._materialCache.addMaterial(e,{fabric:{type:e,uniforms:{color:new a.Color(1,0,0,.5),image:t.image,time:0},source:r({count:t.count,freely:t.freely,direction:t.direction})},translucent:function(){return!0}}),new i(t)}function Pr(a,t){const e=a.Color,i=
|
|
27
|
+
`,o};return a.Material._materialCache.addMaterial(e,{fabric:{type:e,uniforms:{color:new a.Color(1,0,0,.5),image:t.image,time:0},source:r({count:t.count,freely:t.freely,direction:t.direction})},translucent:function(){return!0}}),new i(t)}function Pr(a,t){const e=a.Color,i=Object.defineProperties,r=a.Event,s=a.createPropertyDescriptor,o=a.Property,n=(u,m)=>u===void 0?m:u,l={};let c=t.materialType||"PolylineFlow"+Date.now()+Math.floor(Math.random()*1e3);function d(u){u=n(u,l),this._definitionChanged=new r,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=n(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,7 +40,7 @@
|
|
|
40
40
|
material.alpha = alpha;
|
|
41
41
|
material.emission = fragColor.rgb;
|
|
42
42
|
return material;
|
|
43
|
-
}`})()},translucent(){return!0}}),new c(t)}class Lr{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:r=!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(r)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 r;return e=e||"default",this.CategoryGet[e]?this.CategoryGet[e]({themeKey:t,materialMap:this.categoryMap,options:i||{}}):(r=this.categoryMap.get(e))==null?void 0:r.get(t)}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 r=i.get(t);r!=null&&r.destroy&&r.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 r of e.values())(i=r==null?void 0:r.destroy)==null||i.call(r);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 Er{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:r=[],dataItem:s={},aggregator:o,cardPool:n}=t;this.id=e,this.entities=i,this.primitives=r,this.dataItem=s,this.aggregator=o,this.cardPool=n}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,r)=>{var o;return{id:this.dataItem.id,data:{...this.dataItem,show:t&&(((o=i.data)==null?void 0:o.show)??!0)}}}).forEach(i=>{var r;(r=this.aggregator)==null||r.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 Mr{constructor(t,e,i,r,s,o){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=r,this.aggregator=s,this.cardPool=o,this.aggregator.labelPool.eventBus.addListener(U.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}),r=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(r)},show:(t.show??!0)&&e})}createWall(t,e){var l,c;if(!t.positions||t.positions.length<1)return null;const i=this.materialManager.get({themeKey:t.theme,category:"wall",options:t}),r=t.positions.length===((l=t.minimumHeights)==null?void 0:l.length)?t.minimumHeights.map(d=>d-Number(t.minHeight||0)):t.positions.map(d=>(d[2]||0)-Number(t.minHeight||0)),s=t.positions.length===((c=t.maximumHeights)==null?void 0:c.length)?t.maximumHeights.map(d=>d+Number(t.maxHeight||0)):t.positions.map(d=>(d[2]||0)+Number(t.maxHeight||0)),o=t.positions.map(d=>this.Cesium.Cartesian3.fromDegrees(d[0],d[1],d[2]||0));let n={...t};return i&&(n.material=i),this.viewer.entities.add({wall:{...n,positions:o,minimumHeights:r,maximumHeights:s},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}),r=Array.isArray(t.hierarchy[0])?t.hierarchy.flat():t.hierarchy,s=this.Cesium.Cartesian3.fromDegreesArrayHeights(r),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())}))||[],n=new this.Cesium.PolygonHierarchy(s,o);let l={...t};return i&&(l.material=i),this.viewer.entities.add({polygon:{...l,hierarchy:n},show:(t.show??!0)&&e})}createBillboardPoints(t){var e;return!((e=t.billboard)!=null&&e.length)||!this.aggregator?[]:t.billboard.map(i=>{var n;const[r,s,o=0]=i.position||[0,0,0];return{id:t.id,lon:r,lat:s,height:o,name:((n=i.options)==null?void 0:n.text)||"",data:t,style:{zIndex:t.zIndex||"1"}}})}createCard(t){var e,i,r;(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:((r=t==null?void 0:t.card)==null?void 0:r.zIndex)||"110"}})}addGroup(t,e=!0){const i=t.id||`${Date.now()}`;this.removeGroup(i);const r=[],s=t.show!==!1;(t.polyline||[]).forEach(l=>{const c=this.createPolyline(l,s);c&&r.push(c)}),(t.wall||[]).forEach(l=>{const c=this.createWall(l,s);c&&r.push(c)}),(t.polygon||[]).forEach(l=>{const c=this.createPolygon(l,s);c&&r.push(c)});const o=this.createBillboardPoints(t);o.length&&e&&this.aggregator.appendPoints(o,!1),this.createCard(t);const n=new Er({id:i,entities:r,primitives:[],dataItem:t,aggregator:this.aggregator,cardPool:this.cardPool});return this.groupMap.set(i,n),o}async addGroups(t){const i=t.map(r=>this.addGroup(r,!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 r=this.groupMap.get(i);if(r){let s=r.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(r=>r.id)),this.cardPool.removeByIds(t.map(r=>r.id));const i=t.map(r=>{const s=this.groupMap.get(r.id);return s&&(s.removeAll(this.viewer,!1),this.groupMap.delete(r.id)),this.addGroup(r,!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 Ir{constructor(t,e,i,r,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=r,this.cardPool=s}addLayer(t){this.layerMap.has(t)||this.layerMap.set(t,new Mr(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 r;(r=this.layerMap.get(t))==null||r.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 Tr(a){const t=[];return a.features.forEach((e,i)=>{if(e.geometry&&e.properties){const r=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(r.type){case"Point":o.billboard.push({position:r.coordinates,options:s,name:`${s.layer}_${i}`});break;case"LineString":o.polyline.push({positions:r.coordinates,theme:s.theme||"default"});break;case"Polygon":o.polygon.push({hierarchy:r.coordinates[0],theme:s.theme||"default"});break;case"MultiLineString":r.coordinates.forEach(n=>{o.polyline.push({positions:n})});break;case"MultiPolygon":r.coordinates.forEach(n=>{o.polygon.push({hierarchy:n[0]})});break;case"GeometryCollection":r.geometries.forEach(n=>{n.type==="Point"?o.billboard.push({position:n.coordinates}):n.type==="LineString"?o.polyline.push({positions:n.coordinates}):n.type==="Polygon"&&o.polygon.push({hierarchy:n.coordinates[0]})});break;default:console.warn(`Unsupported geometry type: ${r.type}`);break}t.push(o)}}),t}class xr{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:r,entityLayerManager:s}=t;this.Cesium=e,this.viewer=i,this.layerMap=new Map,this.PrimitiveThemeMap=new Map,this.hideLayerMap=new Map,this.materialManager=r,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 r=this.createAppearance(e);i={Primitive:null,ids:new Map,appearance:r,geometryInstances:new Map},this.PrimitiveThemeMap.set(e.theme,i)}return i}initTheme(t){var r,s,o,n,l,c,d,u,m,g,p,f;let e=this.materialManager,i=this.Cesium;if(t.category=="polyline"){const w=((s=(r=t.properties)==null?void 0:r.lineType)==null?void 0:s.pattern)&&((n=(o=t.properties)==null?void 0:o.lineType)==null?void 0:n.patternLength);let y="";if(w){const C=((c=(l=t.properties)==null?void 0:l.lineType)==null?void 0:c.pattern)||[.25,-.125],b=((u=(d=t.properties)==null?void 0:d.lineType)==null?void 0:u.patternLength)||.375;let v=this.convertCadPatternToCesiumDash(C,b);y=`DashedLineMaterial_pattern_${v.dashPattern}_dashLength_${v.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:v.dashLength,dashPattern:v.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 r=e/16;let s=[],o=0;for(let l of t){const c=Math.floor(Math.abs(l)/r),d=l>=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 n=0;for(let l=0;l<16;l++)n=n<<1|s[l];return{dashPattern:n,dashLength:e}}async processBatch(t){const e=new Map;t.forEach(i=>{let{layerId:r,dataList:s}=i;Oe(s).forEach(n=>{let l=this.createGeometryInstance(n);if(l){let c=this.carateThemePrimitive(n);c.ids.set(n.id,n),c.geometryInstances.set(n.id,l);const d=this.layerMap.get(r);if(d)d.set(n.id,n);else{let u=new Map;this.layerMap.set(r,u),u.set(n.id,n)}e.set(n.theme,n)}})}),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),r=((o=t.holes)==null?void 0:o.map(n=>{let l=Array.isArray(n[0])?n.flat():n,c=this.Cesium.Cartesian3.fromDegreesArrayHeights(l.flat());return new this.Cesium.PolygonHierarchy(c)}))||[],s=new this.Cesium.PolygonHierarchy(i,r);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 r=i.get(e.id);if(i.set(e.id,e),!r){console.warn(`没有找到图元 ${e.id} 在图层 ${e.layerId} 中`);return}if(r.theme!==e.theme){let o=this.PrimitiveThemeMap.get(r.theme);o==null||o.geometryInstances.delete(e.id),o==null||o.ids.delete(e.id),this.updatePrimitive(r)}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:r,ids:s}=i;const o=this.layerMap.get(r);if(!o){console.warn(`没有找到图层 ${r}`);return}s.forEach(n=>{let l=o.get(n);if(!l){console.warn(`没有找到图元 ${n} 在图层 ${r} 中`);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 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 r=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);r.length<=0||(t.category==="polyline"?(e.Primitive=new this.Cesium.GroundPolylinePrimitive({geometryInstances:r,appearance:e.appearance}),this.viewer.scene.primitives.add(e.Primitive)):(e.Primitive=new this.Cesium.GroundPrimitive({geometryInstances:r,appearance:e.appearance}),this.viewer.scene.primitives.add(e.Primitive)))}hideByLayerAndId(t){let e=new Map;t.forEach(i=>{let{layerId:r,ids:s}=i,o=this.hideLayerMap.get(r);o||(o=new Set,this.hideLayerMap.set(r,o)),s.forEach(n=>{o.add(n);let l=this.getGeometryInstanceInfo(r,n);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:r,ids:s}=i,o=this.hideLayerMap.get(r);o||(o=new Set,this.hideLayerMap.set(r,o)),s.forEach(n=>{o.delete(n);let l=this.getGeometryInstanceInfo(r,n);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 r=i.get(e);if(!r)return!1;let s=this.PrimitiveThemeMap.get(r.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 r=i.get(e);if(!r){console.warn(`没有找到图元 ${e} 在图层 ${t} 中`);return}let s=this.PrimitiveThemeMap.get(r.theme);if(!s){console.warn(`没有找到 ${e} 图元相关的Primitive`);return}const o=s.geometryInstances.get(e);if(!o){console.warn(`没有找到图元的几何体 ${e}`);return}const n=o.geometry,l=n._positions||n._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(b=>{c=Math.min(c,b.x),d=Math.min(d,b.y),u=Math.min(u,b.z),m=Math.max(m,b.x),g=Math.max(g,b.y),p=Math.max(p,b.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,C=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,C)})}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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new B(e,i,r),this.htmlLabelPool.registerTheme("measure-horizontal-total",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var f,w,y,C;const s=i.scene.pickPosition(r.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),n=e.Math.toDegrees(o.longitude),l=e.Math.toDegrees(o.latitude);this.positions.length===0&&(this.firstHeight=o.height||0);const c=e.Cartesian3.fromDegrees(n,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(o.longitude,o.latitude,0))||0,m=e.Cartesian3.fromDegrees(n,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 b=this.positions[this.positions.length-2],v=this.positions[this.positions.length-1],M=e.Cartographic.fromCartesian(b),P=e.Cartographic.fromCartesian(v),L=i.entities.add({polyline:{positions:[b,v],width:t.width||3,material:t.lineColor||t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:((C=(y=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:C.call(y,.9))||e.Color.RED,dashLength:12,dashPattern:255})}});this.segmentEntities.push(L);const I=new e.EllipsoidGeodesic(M,P).surfaceDistance,D=new e.Cartesian3((b.x+v.x)/2,(b.y+v.y)/2,(b.z+v.z)/2),A=e.Cartographic.fromCartesian(D),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(A.longitude),lat:e.Math.toDegrees(A.latitude),height:A.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 r=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);r+=f.surfaceDistance}const s=this.positions[this.positions.length-1],o=e.Cartographic.fromCartesian(s),n=this.totalLabelId||`measure_horizontal_total_${Date.now()}`;this.totalLabelId=n,this.htmlLabelPool.add({text:`${r.toFixed(2)} m`},{id:n,lon:e.Math.toDegrees(o.longitude),lat:e.Math.toDegrees(o.latitude),height:o.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:r,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,l)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.handler.setInputAction(r=>{var M,P,L,E;if(this.positions.length===0)return;const s=i.scene.pickPosition(r.endPosition);if(!s)return;this.hoverPos=s;const o=e.Cartographic.fromCartesian(s),n=e.Math.toDegrees(o.longitude),l=e.Math.toDegrees(o.latitude),c=e.Cartesian3.fromDegrees(n,l,this.firstHeight||0);this.previewPos=c;const d=i.scene.globe.getHeight(new e.Cartographic(o.longitude,o.latitude,0))||0,u=e.Cartesian3.fromDegrees(n,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),C=e.Cartographic.fromCartesian(y),b=this.previewLabelId||"measure_horizontal_preview";this.previewLabelId=b,this.htmlLabelPool.add({text:`${w.toFixed(2)} m`},{id:b,lon:e.Math.toDegrees(C.longitude),lat:e.Math.toDegrees(C.latitude),height:C.height||this.firstHeight||0,theme:"measure-horizontal-seg",show:!0});const v=((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:v,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,r=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,n=((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 B(i,r,w),this.htmlLabelPool.registerTheme("measure-horizontal-total",{createElement:(y,C)=>{var b;y.innerHTML=String(((b=C==null?void 0:C.data)==null?void 0:b.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,C)=>{var b;y.innerHTML=String(((b=C==null?void 0:C.data)==null?void 0:b.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=r.entities.add({position:w,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(y);const C=i.Cartographic.fromCartesian(w),b=i.Math.toDegrees(C.longitude),v=i.Math.toDegrees(C.latitude),M=r.scene.globe.getHeight(new i.Cartographic(C.longitude,C.latitude,0))||0,P=i.Cartesian3.fromDegrees(b,v,M),L=r.entities.add({polyline:{positions:[P,w],width:l,material:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}});this.groundLineEntities.push(L)}for(let w=1;w<c.length;w++){const y=c[w-1],C=c[w],b=r.entities.add({polyline:{positions:[y,C],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}});this.segmentEntities.push(b);const v=i.Cartographic.fromCartesian(y),M=i.Cartographic.fromCartesian(C),L=new i.EllipsoidGeodesic(v,M).surfaceDistance,E=new i.Cartesian3((y.x+C.x)/2,(y.y+C.y)/2,(y.z+C.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]),C=i.Cartographic.fromCartesian(c[w]),b=new i.EllipsoidGeodesic(y,C);d+=b.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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new B(e,i,r),this.htmlLabelPool.registerTheme("measure-vertical",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var n,l,c,d,u;const s=i.camera.getPickRay(r.position);let o=s?i.scene.globe.pick(s,i.scene):null;if(o||(o=i.camera.pickEllipsoid(r.position,e.Ellipsoid.WGS84)),o||(o=i.scene.pickPosition(r.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=((l=(n=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(n,.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(r.position);if(!g)return;const p=g.origin,f=e.Cartesian3.normalize(g.direction,new e.Cartesian3),w=m,y=this.baseUp,C=e.Cartesian3.subtract(p,w,new e.Cartesian3),b=e.Cartesian3.dot(f,f),v=-e.Cartesian3.dot(f,y),M=e.Cartesian3.dot(y,y),P=-e.Cartesian3.dot(f,C),L=e.Cartesian3.dot(y,C),E=b*M-v*v;if(Math.abs(E)<1e-6)return;const I=(b*L-v*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 A=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:A,depthFailMaterial:new e.PolylineDashMaterialProperty({color:T,dashLength:12,dashPattern:255})}});const S=i.entities.add({position:D,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(S);const x=this.baseCarto,$=e.Cartographic.fromCartesian(D),F=Math.abs(($.height||0)-(x.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 Y=this.htmlLabelId||`measure_vertical_${Date.now()}`;this.htmlLabelId=Y,this.htmlLabelPool.add({text:`${F.toFixed(2)} m`},{id:Y,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 V={entity:this.entity,label:this.labelEntity,positions:this.positions,vertical:F,clear:()=>this.clear()};(u=t.onComplete)==null||u.call(t,V)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(r=>{var D,A;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(r.endPosition);if(!o)return;const n=o.origin,l=e.Cartesian3.normalize(o.direction,new e.Cartesian3),c=s,d=this.baseUp,u=e.Cartesian3.subtract(n,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 C=(m*w-g*f)/y,b=e.Cartesian3.add(c,e.Cartesian3.multiplyByScalar(d,C,new e.Cartesian3),new e.Cartesian3);if(this.positions[1]=b,!this.previewEntity){const T=t.lineColor||t.color||e.Color.CYAN,S=((A=(D=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:A.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:S,dashLength:12,dashPattern:255})}})}this.previewPointEntity?this.previewPointEntity.position=b:this.previewPointEntity=i.entities.add({position:b,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});const v=this.baseCarto,M=e.Cartographic.fromCartesian(b),P=Math.abs((M.height||0)-(v.height||0)),L=new e.Cartesian3((this.positions[0].x+b.x)/2,(this.positions[0].y+b.y)/2,(this.positions[0].z+b.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 v,M;const i=this.Cesium,r=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.CYAN,n=((M=(v=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:M.call(v,.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 B(i,r,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=r.entities.add({position:d,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),g=r.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=r.entities.add({polyline:{positions:[d,u],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,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),C=i.Cartographic.fromCartesian(y),b=t.id+"_label";this.htmlLabelId=b,this.htmlLabelPool.add({text:`${w.toFixed(2)} m`},{id:b,lon:i.Math.toDegrees(C.longitude),lat:i.Math.toDegrees(C.latitude),height:C.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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new B(e,i,r),this.htmlLabelPool.registerTheme("measure-triangle",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var n,l,c;const s=i.scene.pickPosition(r.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(Z=>i.entities.remove(Z)),this.previewSegmentEntities=[],this.previewAngleMarkerEntities.forEach(Z=>i.entities.remove(Z)),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),C=e.Cartesian3.fromDegrees(e.Math.toDegrees(w.longitude),e.Math.toDegrees(w.latitude),y),b=t.lineColor||t.color||e.Color.YELLOW,v=((l=(n=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(n,.9))||e.Color.RED,M=i.entities.add({polyline:{positions:[p,C],width:t.width||3,material:b,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}}),P=i.entities.add({polyline:{positions:[C,f],width:t.width||3,material:b,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}}),L=i.entities.add({polyline:{positions:[p,f],width:t.width||3,material:b,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}});this.segmentEntities.push(M,P,L);const E=e.Cartesian3.distance(p,C),I=e.Cartesian3.distance(C,f),D=e.Cartesian3.distance(p,f),A=new e.Cartesian3((p.x+C.x)/2,(p.y+C.y)/2,(p.z+C.z)/2),T=new e.Cartesian3((C.x+f.x)/2,(C.y+f.y)/2,(C.z+f.z)/2),S=new e.Cartesian3((p.x+f.x)/2,(p.y+f.y)/2,(p.z+f.z)/2),x=e.Cartographic.fromCartesian(A),$=e.Cartographic.fromCartesian(T),F=e.Cartographic.fromCartesian(S),O="measure_triangle_seg_v",R="measure_triangle_seg_h",Y="measure_triangle_seg_hyp";this.segmentLabelIds=[O,R,Y],this.htmlLabelPool.add({text:`${E.toFixed(2)} m`},{id:O,lon:e.Math.toDegrees(x.longitude),lat:e.Math.toDegrees(x.latitude),height:x.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($.longitude),lat:e.Math.toDegrees($.latitude),height:$.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${D.toFixed(2)} m`},{id:Y,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"}});const V=e.Cartesian3.subtract(f,p,new e.Cartesian3),j=e.Cartesian3.subtract(C,p,new e.Cartesian3),W=e.Cartesian3.subtract(C,f,new e.Cartesian3),H=e.Cartesian3.subtract(p,f,new e.Cartesian3),ne=e.Cartesian3.dot(V,j),K=Math.sqrt(e.Cartesian3.dot(V,V))*Math.sqrt(e.Cartesian3.dot(j,j)),ce=e.Cartesian3.dot(W,H),ue=Math.sqrt(e.Cartesian3.dot(W,W))*Math.sqrt(e.Cartesian3.dot(H,H)),z=Math.acos(Math.min(Math.max(ne/(K||1),-1),1)),oe=Math.acos(Math.min(Math.max(ce/(ue||1),-1),1)),se=e.Cartographic.fromCartesian(p),q=e.Cartographic.fromCartesian(f),ee="measure_triangle_angle_a",de="measure_triangle_angle_b";this.angleLabelIds=[ee,de],this.htmlLabelPool.add({text:`${(z*180/Math.PI).toFixed(2)}°`},{id:ee,lon:e.Math.toDegrees(se.longitude),lat:e.Math.toDegrees(se.latitude),height:se.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${(oe*180/Math.PI).toFixed(2)}°`},{id:de,lon:e.Math.toDegrees(q.longitude),lat:e.Math.toDegrees(q.latitude),height:q.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)),X=Math.min(E,I)*be;if(E>.001&&I>.001){const Z=e.Cartesian3.normalize(e.Cartesian3.subtract(p,C,new e.Cartesian3),new e.Cartesian3),pe=e.Cartesian3.normalize(e.Cartesian3.subtract(f,C,new e.Cartesian3),new e.Cartesian3),te=new e.Cartesian3(C.x+Z.x*X,C.y+Z.y*X,C.z+Z.z*X),k=new e.Cartesian3(C.x+pe.x*X,C.y+pe.y*X,C.z+pe.z*X),Q=new e.Cartesian3(C.x+Z.x*X+pe.x*X,C.y+Z.y*X+pe.y*X,C.z+Z.z*X+pe.z*X),re=i.entities.add({polyline:{positions:[te,Q],width:t.width||3,material:b,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}}),Fe=i.entities.add({polyline:{positions:[k,Q],width:t.width||3,material:b,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}});this.angleMarkerEntities.push(re,Fe)}this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);const J={entity:this.segmentEntities,positions:[p,f,C],lengths:{vertical:E,horizontal:I,hypotenuse:D},angles:{acuteA:z,acuteB:oe},clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,J)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(r=>{var oe,se;if(this.positions.length!==1)return;const s=i.scene.pickPosition(r.endPosition);if(!s)return;const o=e.Cartographic.fromCartesian(this.positions[0]),n=e.Cartographic.fromCartesian(s),l=o.height||0,c=n.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=((se=(oe=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:se.call(oe,.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 q=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})}}),ee=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})}}),de=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(q,ee,de)}const y=e.Cartesian3.distance(d,p),C=e.Cartesian3.distance(p,u),b=e.Cartesian3.distance(d,u),v=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(v,M),I=Math.sqrt(e.Cartesian3.dot(v,v))*Math.sqrt(e.Cartesian3.dot(M,M)),D=e.Cartesian3.dot(P,L),A=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)),S=Math.acos(Math.min(Math.max(D/(A||1),-1),1)),x=new e.Cartesian3((d.x+p.x)/2,(d.y+p.y)/2,(d.z+p.z)/2),$=new e.Cartesian3((p.x+u.x)/2,(p.y+u.y)/2,(p.z+u.z)/2),F=new e.Cartesian3((d.x+u.x)/2,(d.y+u.y)/2,(d.z+u.z)/2),O=e.Cartographic.fromCartesian(x),R=e.Cartographic.fromCartesian($),Y=e.Cartographic.fromCartesian(F),V=e.Cartographic.fromCartesian(d),j=e.Cartographic.fromCartesian(u),W="measure_triangle_seg_v",H="measure_triangle_seg_h",ne="measure_triangle_seg_hyp",K="measure_triangle_angle_a",ce="measure_triangle_angle_b";this.segmentLabelIds.length===0&&(this.segmentLabelIds=[W,H,ne]),this.angleLabelIds.length===0&&(this.angleLabelIds=[K,ce]),this.htmlLabelPool.add({text:`${y.toFixed(2)} m`},{id:W,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:`${C.toFixed(2)} m`},{id:H,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:`${b.toFixed(2)} m`},{id:ne,lon:e.Math.toDegrees(Y.longitude),lat:e.Math.toDegrees(Y.latitude),height:Y.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:K,lon:e.Math.toDegrees(V.longitude),lat:e.Math.toDegrees(V.latitude),height:V.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${(S*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 ue=Math.max(.01,Math.min(.5,t.angleMarkerRatio??.2)),z=Math.min(y,C)*ue;if(y>.001&&C>.001){const q=e.Cartesian3.normalize(e.Cartesian3.subtract(d,p,new e.Cartesian3),new e.Cartesian3),ee=e.Cartesian3.normalize(e.Cartesian3.subtract(u,p,new e.Cartesian3),new e.Cartesian3),de=new e.Cartesian3(p.x+q.x*z,p.y+q.y*z,p.z+q.z*z),be=new e.Cartesian3(p.x+ee.x*z,p.y+ee.y*z,p.z+ee.z*z),X=new e.Cartesian3(p.x+q.x*z+ee.x*z,p.y+q.y*z+ee.y*z,p.z+q.z*z+ee.z*z);if(this.previewMarkerP1=de,this.previewMarkerP2=be,this.previewMarkerCorner=X,!this.previewAngleMarkerEntities.length){const J=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})}}),Z=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(J,Z)}}},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 Z,pe;const i=this.Cesium,r=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,n=((pe=(Z=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:pe.call(Z,.9))||i.Color.RED,l=s.width||3,c=(t.positions||[]).map(te=>new i.Cartesian3(te[0],te[1],te[2]));if(c.length<2)return;if(!this.htmlLabelPool){const te=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new B(i,r,te),this.htmlLabelPool.registerTheme("measure-triangle",{createElement:(k,Q)=>{var re;k.innerHTML=String(((re=Q==null?void 0:Q.data)==null?void 0:re.text)||""),k.style.background="rgba(0,0,0,0.6)",k.style.color="#fff",k.style.font="14px sans-serif",k.style.padding="4px 6px",k.style.borderRadius="4px",k.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-seg",{createElement:(k,Q)=>{var re;k.innerHTML=String(((re=Q==null?void 0:Q.data)==null?void 0:re.text)||""),k.style.background="rgba(0,0,0,0.6)",k.style.color="#fff",k.style.font="14px sans-serif",k.style.padding="4px 6px",k.style.borderRadius="4px",k.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-angle",{createElement:(k,Q)=>{var re;k.innerHTML=String(((re=Q==null?void 0:Q.data)==null?void 0:re.text)||""),k.style.background="rgba(0,0,0,0.6)",k.style.color="#fff",k.style.font="14px sans-serif",k.style.padding="4px 6px",k.style.borderRadius="4px",k.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=r.entities.add({position:p,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),y=r.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 C=i.Cartographic.fromCartesian(p),b=Math.max(m,g),v=i.Cartesian3.fromDegrees(i.Math.toDegrees(C.longitude),i.Math.toDegrees(C.latitude),b),M=r.entities.add({polyline:{positions:[p,v],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}}),P=r.entities.add({polyline:{positions:[v,f],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}}),L=r.entities.add({polyline:{positions:[p,f],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}});this.segmentEntities.push(M,P,L);const E=i.Cartesian3.distance(p,v),I=i.Cartesian3.distance(v,f),D=i.Cartesian3.distance(p,f),A=new i.Cartesian3((p.x+v.x)/2,(p.y+v.y)/2,(p.z+v.z)/2),T=new i.Cartesian3((v.x+f.x)/2,(v.y+f.y)/2,(v.z+f.z)/2),S=new i.Cartesian3((p.x+f.x)/2,(p.y+f.y)/2,(p.z+f.z)/2),x=i.Cartographic.fromCartesian(A),$=i.Cartographic.fromCartesian(T),F=i.Cartographic.fromCartesian(S),O=t.id+"_tri_v",R=t.id+"_tri_h",Y=t.id+"_tri_hyp";this.segmentLabelIds=[O,R,Y],this.htmlLabelPool.add({text:`${E.toFixed(2)} m`},{id:O,lon:i.Math.toDegrees(x.longitude),lat:i.Math.toDegrees(x.latitude),height:x.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($.longitude),lat:i.Math.toDegrees($.latitude),height:$.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${D.toFixed(2)} m`},{id:Y,lon:i.Math.toDegrees(F.longitude),lat:i.Math.toDegrees(F.latitude),height:F.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const V=i.Cartesian3.subtract(f,p,new i.Cartesian3),j=i.Cartesian3.subtract(v,p,new i.Cartesian3),W=i.Cartesian3.subtract(v,f,new i.Cartesian3),H=i.Cartesian3.subtract(p,f,new i.Cartesian3),ne=i.Cartesian3.dot(V,j),K=Math.sqrt(i.Cartesian3.dot(V,V))*Math.sqrt(i.Cartesian3.dot(j,j)),ce=i.Cartesian3.dot(W,H),ue=Math.sqrt(i.Cartesian3.dot(W,W))*Math.sqrt(i.Cartesian3.dot(H,H)),z=Math.acos(Math.min(Math.max(ne/(K||1),-1),1)),oe=Math.acos(Math.min(Math.max(ce/(ue||1),-1),1)),se=i.Cartographic.fromCartesian(p),q=i.Cartographic.fromCartesian(f),ee=s.labelText||{angle:"角度"},de=t.id+"_tri_angA",be=t.id+"_tri_angB";this.angleLabelIds=[de,be],this.htmlLabelPool.add({text:`${ee.angle}:${(z*180/Math.PI).toFixed(2)}°`},{id:de,lon:i.Math.toDegrees(se.longitude),lat:i.Math.toDegrees(se.latitude),height:se.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${ee.angle}:${(oe*180/Math.PI).toFixed(2)}°`},{id:be,lon:i.Math.toDegrees(q.longitude),lat:i.Math.toDegrees(q.latitude),height:q.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const X=Math.max(.01,Math.min(.5,s.angleMarkerRatio??.2)),J=Math.min(E,I)*X;if(E>.001&&I>.001){const te=i.Cartesian3.normalize(i.Cartesian3.subtract(p,v,new i.Cartesian3),new i.Cartesian3),k=i.Cartesian3.normalize(i.Cartesian3.subtract(f,v,new i.Cartesian3),new i.Cartesian3),Q=new i.Cartesian3(v.x+te.x*J,v.y+te.y*J,v.z+te.z*J),re=new i.Cartesian3(v.x+k.x*J,v.y+k.y*J,v.z+k.z*J),Fe=new i.Cartesian3(v.x+te.x*J+k.x*J,v.y+te.y*J+k.y*J,v.z+te.z*J+k.z*J),Ar=r.entities.add({polyline:{positions:[Q,Fe],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}}),$r=r.entities.add({polyline:{positions:[re,Fe],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}});this.angleMarkerEntities.push(Ar,$r)}}}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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new B(e,i,r),this.htmlLabelPool.registerTheme("measure-space",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var n,l,c;const s=i.scene.pickPosition(r.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=((l=(n=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(n,.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 C={entity:this.entity,label:this.labelEntity,positions:this.positions,distance:p,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,C)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(r=>{var g,p;if(this.positions.length!==1)return;const s=i.scene.pickPosition(r.endPosition);if(!s)return;this.previewPos=s;const o=this.positions[0],n=e.Cartesian3.distance(o,s),l=new e.Cartesian3((o.x+s.x)/2,(o.y+s.y)/2,(o.z+s.z)/2),c=e.Cartographic.fromCartesian(l),d=this.previewLabelId||"measure_space_preview";this.previewLabelId=d,this.htmlLabelPool.add({text:`${n.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,r=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,n=((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 B(i,r,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=r.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=r.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=r.entities.add({polyline:{positions:[c[0],c[1]],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new B(e,i,r),this.htmlLabelPool.registerTheme("measure-area",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var m,g;const s=i.scene.pickPosition(r.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 n=new e.PolygonHierarchy(this.positions.slice()),l=new e.PolygonGeometry({polygonHierarchy:n,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 C of this.edgeEntities)try{i.entities.remove(C)}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(r=>{var p,f;if(this.positions.length===0)return;const s=i.scene.pickPosition(r.endPosition);if(!s)return;this.previewPos=s;const o=this.positions.concat([s]),n=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(n,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(n),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,C=((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:C,dashLength:12,dashPattern:255})}});const b=t.pointColor||t.color||e.Color.YELLOW,v=i.entities.add({position:new e.CallbackProperty(()=>this.previewPos||this.positions[this.positions.length-1],!1),point:{pixelSize:8,color:b,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.previewPointEntities.push(v)}},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 r=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(r,e.Ellipsoid.WGS84).projectPointsOntoPlane(this.positions);let n=0;for(let p=0;p<o.length;p++){const f=(p+1)%o.length;n+=o[p].x*o[f].y-o[f].x*o[p].y}n=Math.abs(n)/2;const l=e.Cartographic.fromCartesian(r),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}:${n.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],C=e.Cartographic.fromCartesian(w),b=e.Cartographic.fromCartesian(y),M=new e.EllipsoidGeodesic(C,b).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],C=f.x-w.x,b=f.y-w.y,v=y.x-w.x,M=y.y-w.y,P=Math.sqrt(C*C+b*b),L=Math.sqrt(v*v+M*M);if(!P||!L)continue;const E=C/P*(v/L)+b/P*(M/L),I=Math.acos(Math.min(1,Math.max(-1,E)))*(180/Math.PI),D=e.Cartographic.fromCartesian(this.positions[p]),A=`measure_area_angle_${Date.now()}_${p}`;this.angleLabelIds.push(A),this.htmlLabelPool.add({text:`${d.angle}:${I.toFixed(2)} °`},{id:A,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:n,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,r=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 B(i,r,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=r.entities.add({position:M,point:{pixelSize:8,color:s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(P)}const n=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(n,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(n),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),C=s.color&&s.color.withAlpha?s.color.withAlpha(.25):i.Color.RED.withAlpha(.4),b=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:C}),translucent:!0,closed:!0})});r.scene.primitives.add(b),this.primitive=b;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,S=new i.Cartesian3((L.x+E.x)/2,(L.y+E.y)/2,(L.z+E.z)/2),x=i.Cartographic.fromCartesian(S),$=t.id+`_area_seg_${M}`;this.segmentLabelIds.push($),this.htmlLabelPool.add({text:`${g.side}:${T.toFixed(2)} m`},{id:$,lon:i.Math.toDegrees(x.longitude),lat:i.Math.toDegrees(x.latitude),height:x.height||0,theme:"measure-area-seg",show:!0})}const v=c;for(let M=0;M<v.length;M++){const P=v[(M-1+v.length)%v.length],L=v[M],E=v[(M+1)%v.length],I=P.x-L.x,D=P.y-L.y,A=E.x-L.x,T=E.y-L.y,S=Math.sqrt(I*I+D*D),x=Math.sqrt(A*A+T*T);if(!S||!x)continue;const $=I/S*(A/x)+D/S*(T/x),F=Math.acos(Math.min(1,Math.max(-1,$)))*(180/Math.PI),O=i.Cartographic.fromCartesian(o[M]),R=t.id+`_area_angle_${M}`;this.angleLabelIds.push(R),this.htmlLabelPool.add({text:`${g.angle}:${F.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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new B(e,i,r),this.htmlLabelPool.registerTheme("measure-circle",{createElement:(s,o)=>{var l;const n=((l=o==null?void 0:o.data)==null?void 0:l.text)||"";s.innerHTML=String(n),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(r=>{var o;const s=i.scene.pickPosition(r.position);if(s&&(this.positions.push(s),this.positions.length===2)){this.stop();const n=this.positions[0],l=this.positions[1],c=e.Cartesian3.distance(n,l),d=Math.PI*c*c,u=2*Math.PI*c,m=t.labelText||{radius:"半径",area:"面积",circumference:"周长"},g=n;this.labelEntity?(this.labelEntity.position=g,this.labelEntity.label.text=`${m.radius}:${c.toFixed(2)} m
|
|
43
|
+
}`})()},translucent(){return!0}}),new d(t)}class Lr{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:r=!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(r)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 r;return e=e||"default",this.CategoryGet[e]?this.CategoryGet[e]({themeKey:t,materialMap:this.categoryMap,options:i||{}}):(r=this.categoryMap.get(e))==null?void 0:r.get(t)}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 r=i.get(t);r!=null&&r.destroy&&r.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 r of e.values())(i=r==null?void 0:r.destroy)==null||i.call(r);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 Er{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:r=[],dataItem:s={},aggregator:o,cardPool:n}=t;this.id=e,this.entities=i,this.primitives=r,this.dataItem=s,this.aggregator=o,this.cardPool=n}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,r)=>{var o;return{id:this.dataItem.id,data:{...this.dataItem,show:t&&(((o=i.data)==null?void 0:o.show)??!0)}}}).forEach(i=>{var r;(r=this.aggregator)==null||r.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 Mr{constructor(t,e,i,r,s,o){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=r,this.aggregator=s,this.cardPool=o,this.aggregator.labelPool.eventBus.addListener(J.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}),r=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(r)},show:(t.show??!0)&&e})}createWall(t,e){var l,c;if(!t.positions||t.positions.length<1)return null;const i=this.materialManager.get({themeKey:t.theme,category:"wall",options:t}),r=t.positions.length===((l=t.minimumHeights)==null?void 0:l.length)?t.minimumHeights.map(d=>d-Number(t.minHeight||0)):t.positions.map(d=>(d[2]||0)-Number(t.minHeight||0)),s=t.positions.length===((c=t.maximumHeights)==null?void 0:c.length)?t.maximumHeights.map(d=>d+Number(t.maxHeight||0)):t.positions.map(d=>(d[2]||0)+Number(t.maxHeight||0)),o=t.positions.map(d=>this.Cesium.Cartesian3.fromDegrees(d[0],d[1],d[2]||0));let n={...t};return i&&(n.material=i),this.viewer.entities.add({wall:{...n,positions:o,minimumHeights:r,maximumHeights:s},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}),r=Array.isArray(t.hierarchy[0])?t.hierarchy.flat():t.hierarchy,s=this.Cesium.Cartesian3.fromDegreesArrayHeights(r),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())}))||[],n=new this.Cesium.PolygonHierarchy(s,o);let l={...t};return i&&(l.material=i),this.viewer.entities.add({polygon:{...l,hierarchy:n},show:(t.show??!0)&&e})}createBillboardPoints(t){var e;return!((e=t.billboard)!=null&&e.length)||!this.aggregator?[]:t.billboard.map(i=>{var n;const[r,s,o=0]=i.position||[0,0,0];return{id:t.id,lon:r,lat:s,height:o,name:((n=i.options)==null?void 0:n.text)||"",data:t,style:{zIndex:t.zIndex||"1"}}})}createCard(t){var e,i,r;(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:((r=t==null?void 0:t.card)==null?void 0:r.zIndex)||"110"}})}addGroup(t,e=!0){const i=t.id||`${Date.now()}`;this.removeGroup(i);const r=[],s=t.show!==!1;(t.polyline||[]).forEach(l=>{const c=this.createPolyline(l,s);c&&r.push(c)}),(t.wall||[]).forEach(l=>{const c=this.createWall(l,s);c&&r.push(c)}),(t.polygon||[]).forEach(l=>{const c=this.createPolygon(l,s);c&&r.push(c)});const o=this.createBillboardPoints(t);o.length&&e&&this.aggregator.appendPoints(o,!1),this.createCard(t);const n=new Er({id:i,entities:r,primitives:[],dataItem:t,aggregator:this.aggregator,cardPool:this.cardPool});return this.groupMap.set(i,n),o}async addGroups(t){const i=t.map(r=>this.addGroup(r,!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 r=this.groupMap.get(i);if(r){let s=r.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(r=>r.id)),this.cardPool.removeByIds(t.map(r=>r.id));const i=t.map(r=>{const s=this.groupMap.get(r.id);return s&&(s.removeAll(this.viewer,!1),this.groupMap.delete(r.id)),this.addGroup(r,!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 Ir{constructor(t,e,i,r,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=r,this.cardPool=s}addLayer(t){this.layerMap.has(t)||this.layerMap.set(t,new Mr(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 r;(r=this.layerMap.get(t))==null||r.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 Tr(a){const t=[];return a.features.forEach((e,i)=>{if(e.geometry&&e.properties){const r=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(r.type){case"Point":o.billboard.push({position:r.coordinates,options:s,name:`${s.layer}_${i}`});break;case"LineString":o.polyline.push({positions:r.coordinates,theme:s.theme||"default"});break;case"Polygon":o.polygon.push({hierarchy:r.coordinates[0],theme:s.theme||"default"});break;case"MultiLineString":r.coordinates.forEach(n=>{o.polyline.push({positions:n})});break;case"MultiPolygon":r.coordinates.forEach(n=>{o.polygon.push({hierarchy:n[0]})});break;case"GeometryCollection":r.geometries.forEach(n=>{n.type==="Point"?o.billboard.push({position:n.coordinates}):n.type==="LineString"?o.polyline.push({positions:n.coordinates}):n.type==="Polygon"&&o.polygon.push({hierarchy:n.coordinates[0]})});break;default:console.warn(`Unsupported geometry type: ${r.type}`);break}t.push(o)}}),t}class xr{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:r,entityLayerManager:s}=t;this.Cesium=e,this.viewer=i,this.layerMap=new Map,this.PrimitiveThemeMap=new Map,this.hideLayerMap=new Map,this.materialManager=r,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 r=this.createAppearance(e);i={Primitive:null,ids:new Map,appearance:r,geometryInstances:new Map},this.PrimitiveThemeMap.set(e.theme,i)}return i}initTheme(t){var r,s,o,n,l,c,d,u,m,g,p,f;let e=this.materialManager,i=this.Cesium;if(t.category=="polyline"){const w=((s=(r=t.properties)==null?void 0:r.lineType)==null?void 0:s.pattern)&&((n=(o=t.properties)==null?void 0:o.lineType)==null?void 0:n.patternLength);let y="";if(w){const C=((c=(l=t.properties)==null?void 0:l.lineType)==null?void 0:c.pattern)||[.25,-.125],b=((u=(d=t.properties)==null?void 0:d.lineType)==null?void 0:u.patternLength)||.375;let v=this.convertCadPatternToCesiumDash(C,b);y=`DashedLineMaterial_pattern_${v.dashPattern}_dashLength_${v.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:v.dashLength,dashPattern:v.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 r=e/16;let s=[],o=0;for(let l of t){const c=Math.floor(Math.abs(l)/r),d=l>=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 n=0;for(let l=0;l<16;l++)n=n<<1|s[l];return{dashPattern:n,dashLength:e}}async processBatch(t){const e=new Map;t.forEach(i=>{let{layerId:r,dataList:s}=i;Oe(s).forEach(n=>{let l=this.createGeometryInstance(n);if(l){let c=this.carateThemePrimitive(n);c.ids.set(n.id,n),c.geometryInstances.set(n.id,l);const d=this.layerMap.get(r);if(d)d.set(n.id,n);else{let u=new Map;this.layerMap.set(r,u),u.set(n.id,n)}e.set(n.theme,n)}})}),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),r=((o=t.holes)==null?void 0:o.map(n=>{let l=Array.isArray(n[0])?n.flat():n,c=this.Cesium.Cartesian3.fromDegreesArrayHeights(l.flat());return new this.Cesium.PolygonHierarchy(c)}))||[],s=new this.Cesium.PolygonHierarchy(i,r);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 r=i.get(e.id);if(i.set(e.id,e),!r){console.warn(`没有找到图元 ${e.id} 在图层 ${e.layerId} 中`);return}if(r.theme!==e.theme){let o=this.PrimitiveThemeMap.get(r.theme);o==null||o.geometryInstances.delete(e.id),o==null||o.ids.delete(e.id),this.updatePrimitive(r)}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:r,ids:s}=i;const o=this.layerMap.get(r);if(!o){console.warn(`没有找到图层 ${r}`);return}s.forEach(n=>{let l=o.get(n);if(!l){console.warn(`没有找到图元 ${n} 在图层 ${r} 中`);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 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 r=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);r.length<=0||(t.category==="polyline"?(e.Primitive=new this.Cesium.GroundPolylinePrimitive({geometryInstances:r,appearance:e.appearance}),this.viewer.scene.primitives.add(e.Primitive)):(e.Primitive=new this.Cesium.GroundPrimitive({geometryInstances:r,appearance:e.appearance}),this.viewer.scene.primitives.add(e.Primitive)))}hideByLayerAndId(t){let e=new Map;t.forEach(i=>{let{layerId:r,ids:s}=i,o=this.hideLayerMap.get(r);o||(o=new Set,this.hideLayerMap.set(r,o)),s.forEach(n=>{o.add(n);let l=this.getGeometryInstanceInfo(r,n);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:r,ids:s}=i,o=this.hideLayerMap.get(r);o||(o=new Set,this.hideLayerMap.set(r,o)),s.forEach(n=>{o.delete(n);let l=this.getGeometryInstanceInfo(r,n);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 r=i.get(e);if(!r)return!1;let s=this.PrimitiveThemeMap.get(r.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 r=i.get(e);if(!r){console.warn(`没有找到图元 ${e} 在图层 ${t} 中`);return}let s=this.PrimitiveThemeMap.get(r.theme);if(!s){console.warn(`没有找到 ${e} 图元相关的Primitive`);return}const o=s.geometryInstances.get(e);if(!o){console.warn(`没有找到图元的几何体 ${e}`);return}const n=o.geometry,l=n._positions||n._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(b=>{c=Math.min(c,b.x),d=Math.min(d,b.y),u=Math.min(u,b.z),m=Math.max(m,b.x),g=Math.max(g,b.y),p=Math.max(p,b.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,C=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,C)})}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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,r),this.htmlLabelPool.registerTheme("measure-horizontal-total",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var f,w,y,C;const s=i.scene.pickPosition(r.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),n=e.Math.toDegrees(o.longitude),l=e.Math.toDegrees(o.latitude);this.positions.length===0&&(this.firstHeight=o.height||0);const c=e.Cartesian3.fromDegrees(n,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(o.longitude,o.latitude,0))||0,m=e.Cartesian3.fromDegrees(n,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 b=this.positions[this.positions.length-2],v=this.positions[this.positions.length-1],M=e.Cartographic.fromCartesian(b),P=e.Cartographic.fromCartesian(v),L=i.entities.add({polyline:{positions:[b,v],width:t.width||3,material:t.lineColor||t.color||e.Color.YELLOW,depthFailMaterial:new e.PolylineDashMaterialProperty({color:((C=(y=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:C.call(y,.9))||e.Color.RED,dashLength:12,dashPattern:255})}});this.segmentEntities.push(L);const I=new e.EllipsoidGeodesic(M,P).surfaceDistance,_=new e.Cartesian3((b.x+v.x)/2,(b.y+v.y)/2,(b.z+v.z)/2),A=e.Cartographic.fromCartesian(_),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(A.longitude),lat:e.Math.toDegrees(A.latitude),height:A.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 r=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);r+=f.surfaceDistance}const s=this.positions[this.positions.length-1],o=e.Cartographic.fromCartesian(s),n=this.totalLabelId||`measure_horizontal_total_${Date.now()}`;this.totalLabelId=n,this.htmlLabelPool.add({text:`${r.toFixed(2)} m`},{id:n,lon:e.Math.toDegrees(o.longitude),lat:e.Math.toDegrees(o.latitude),height:o.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:r,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,l)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.handler.setInputAction(r=>{var M,P,L,E;if(this.positions.length===0)return;const s=i.scene.pickPosition(r.endPosition);if(!s)return;this.hoverPos=s;const o=e.Cartographic.fromCartesian(s),n=e.Math.toDegrees(o.longitude),l=e.Math.toDegrees(o.latitude),c=e.Cartesian3.fromDegrees(n,l,this.firstHeight||0);this.previewPos=c;const d=i.scene.globe.getHeight(new e.Cartographic(o.longitude,o.latitude,0))||0,u=e.Cartesian3.fromDegrees(n,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),C=e.Cartographic.fromCartesian(y),b=this.previewLabelId||"measure_horizontal_preview";this.previewLabelId=b,this.htmlLabelPool.add({text:`${w.toFixed(2)} m`},{id:b,lon:e.Math.toDegrees(C.longitude),lat:e.Math.toDegrees(C.latitude),height:C.height||this.firstHeight||0,theme:"measure-horizontal-seg",show:!0});const v=((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:v,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,r=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,n=((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 G(i,r,w),this.htmlLabelPool.registerTheme("measure-horizontal-total",{createElement:(y,C)=>{var b;y.innerHTML=String(((b=C==null?void 0:C.data)==null?void 0:b.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,C)=>{var b;y.innerHTML=String(((b=C==null?void 0:C.data)==null?void 0:b.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=r.entities.add({position:w,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(y);const C=i.Cartographic.fromCartesian(w),b=i.Math.toDegrees(C.longitude),v=i.Math.toDegrees(C.latitude),M=r.scene.globe.getHeight(new i.Cartographic(C.longitude,C.latitude,0))||0,P=i.Cartesian3.fromDegrees(b,v,M),L=r.entities.add({polyline:{positions:[P,w],width:l,material:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}});this.groundLineEntities.push(L)}for(let w=1;w<c.length;w++){const y=c[w-1],C=c[w],b=r.entities.add({polyline:{positions:[y,C],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}});this.segmentEntities.push(b);const v=i.Cartographic.fromCartesian(y),M=i.Cartographic.fromCartesian(C),L=new i.EllipsoidGeodesic(v,M).surfaceDistance,E=new i.Cartesian3((y.x+C.x)/2,(y.y+C.y)/2,(y.z+C.z)/2),I=i.Cartographic.fromCartesian(E),_=t.id+`_seg_${w-1}`;this.segmentLabelIds.push(_),this.htmlLabelPool.add({text:`${L.toFixed(2)} m`},{id:_,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]),C=i.Cartographic.fromCartesian(c[w]),b=new i.EllipsoidGeodesic(y,C);d+=b.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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,r),this.htmlLabelPool.registerTheme("measure-vertical",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var n,l,c,d,u;const s=i.camera.getPickRay(r.position);let o=s?i.scene.globe.pick(s,i.scene):null;if(o||(o=i.camera.pickEllipsoid(r.position,e.Ellipsoid.WGS84)),o||(o=i.scene.pickPosition(r.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=((l=(n=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(n,.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(r.position);if(!g)return;const p=g.origin,f=e.Cartesian3.normalize(g.direction,new e.Cartesian3),w=m,y=this.baseUp,C=e.Cartesian3.subtract(p,w,new e.Cartesian3),b=e.Cartesian3.dot(f,f),v=-e.Cartesian3.dot(f,y),M=e.Cartesian3.dot(y,y),P=-e.Cartesian3.dot(f,C),L=e.Cartesian3.dot(y,C),E=b*M-v*v;if(Math.abs(E)<1e-6)return;const I=(b*L-v*P)/E,_=e.Cartesian3.add(w,e.Cartesian3.multiplyByScalar(y,I,new e.Cartesian3),new e.Cartesian3);this.positions[1]=_,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 A=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,_],width:t.width||3,material:A,depthFailMaterial:new e.PolylineDashMaterialProperty({color:T,dashLength:12,dashPattern:255})}});const S=i.entities.add({position:_,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(S);const x=this.baseCarto,$=e.Cartographic.fromCartesian(_),F=Math.abs(($.height||0)-(x.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 V=this.htmlLabelId||`measure_vertical_${Date.now()}`;this.htmlLabelId=V,this.htmlLabelPool.add({text:`${F.toFixed(2)} m`},{id:V,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 W={entity:this.entity,label:this.labelEntity,positions:this.positions,vertical:F,clear:()=>this.clear()};(u=t.onComplete)==null||u.call(t,W)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(r=>{var _,A;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(r.endPosition);if(!o)return;const n=o.origin,l=e.Cartesian3.normalize(o.direction,new e.Cartesian3),c=s,d=this.baseUp,u=e.Cartesian3.subtract(n,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 C=(m*w-g*f)/y,b=e.Cartesian3.add(c,e.Cartesian3.multiplyByScalar(d,C,new e.Cartesian3),new e.Cartesian3);if(this.positions[1]=b,!this.previewEntity){const T=t.lineColor||t.color||e.Color.CYAN,S=((A=(_=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:A.call(_,.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:S,dashLength:12,dashPattern:255})}})}this.previewPointEntity?this.previewPointEntity.position=b:this.previewPointEntity=i.entities.add({position:b,point:{pixelSize:8,color:t.pointColor||t.color||e.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});const v=this.baseCarto,M=e.Cartographic.fromCartesian(b),P=Math.abs((M.height||0)-(v.height||0)),L=new e.Cartesian3((this.positions[0].x+b.x)/2,(this.positions[0].y+b.y)/2,(this.positions[0].z+b.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 v,M;const i=this.Cesium,r=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.CYAN,n=((M=(v=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:M.call(v,.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 G(i,r,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=r.entities.add({position:d,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),g=r.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=r.entities.add({polyline:{positions:[d,u],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,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),C=i.Cartographic.fromCartesian(y),b=t.id+"_label";this.htmlLabelId=b,this.htmlLabelPool.add({text:`${w.toFixed(2)} m`},{id:b,lon:i.Math.toDegrees(C.longitude),lat:i.Math.toDegrees(C.latitude),height:C.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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,r),this.htmlLabelPool.registerTheme("measure-triangle",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var n,l,c;const s=i.scene.pickPosition(r.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(te=>i.entities.remove(te)),this.previewSegmentEntities=[],this.previewAngleMarkerEntities.forEach(te=>i.entities.remove(te)),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),C=e.Cartesian3.fromDegrees(e.Math.toDegrees(w.longitude),e.Math.toDegrees(w.latitude),y),b=t.lineColor||t.color||e.Color.YELLOW,v=((l=(n=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(n,.9))||e.Color.RED,M=i.entities.add({polyline:{positions:[p,C],width:t.width||3,material:b,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}}),P=i.entities.add({polyline:{positions:[C,f],width:t.width||3,material:b,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}}),L=i.entities.add({polyline:{positions:[p,f],width:t.width||3,material:b,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}});this.segmentEntities.push(M,P,L);const E=e.Cartesian3.distance(p,C),I=e.Cartesian3.distance(C,f),_=e.Cartesian3.distance(p,f),A=new e.Cartesian3((p.x+C.x)/2,(p.y+C.y)/2,(p.z+C.z)/2),T=new e.Cartesian3((C.x+f.x)/2,(C.y+f.y)/2,(C.z+f.z)/2),S=new e.Cartesian3((p.x+f.x)/2,(p.y+f.y)/2,(p.z+f.z)/2),x=e.Cartographic.fromCartesian(A),$=e.Cartographic.fromCartesian(T),F=e.Cartographic.fromCartesian(S),O="measure_triangle_seg_v",R="measure_triangle_seg_h",V="measure_triangle_seg_hyp";this.segmentLabelIds=[O,R,V],this.htmlLabelPool.add({text:`${E.toFixed(2)} m`},{id:O,lon:e.Math.toDegrees(x.longitude),lat:e.Math.toDegrees(x.latitude),height:x.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($.longitude),lat:e.Math.toDegrees($.latitude),height:$.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${_.toFixed(2)} m`},{id:V,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"}});const W=e.Cartesian3.subtract(f,p,new e.Cartesian3),B=e.Cartesian3.subtract(C,p,new e.Cartesian3),K=e.Cartesian3.subtract(C,f,new e.Cartesian3),q=e.Cartesian3.subtract(p,f,new e.Cartesian3),re=e.Cartesian3.dot(W,B),j=Math.sqrt(e.Cartesian3.dot(W,W))*Math.sqrt(e.Cartesian3.dot(B,B)),ue=e.Cartesian3.dot(K,q),X=Math.sqrt(e.Cartesian3.dot(K,K))*Math.sqrt(e.Cartesian3.dot(q,q)),Y=Math.acos(Math.min(Math.max(re/(j||1),-1),1)),he=Math.acos(Math.min(Math.max(ue/(X||1),-1),1)),oe=e.Cartographic.fromCartesian(p),H=e.Cartographic.fromCartesian(f),U="measure_triangle_angle_a",ne="measure_triangle_angle_b";this.angleLabelIds=[U,ne],this.htmlLabelPool.add({text:`${(Y*180/Math.PI).toFixed(2)}°`},{id:U,lon:e.Math.toDegrees(oe.longitude),lat:e.Math.toDegrees(oe.latitude),height:oe.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${(he*180/Math.PI).toFixed(2)}°`},{id:ne,lon:e.Math.toDegrees(H.longitude),lat:e.Math.toDegrees(H.latitude),height:H.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)),Q=Math.min(E,I)*be;if(E>.001&&I>.001){const te=e.Cartesian3.normalize(e.Cartesian3.subtract(p,C,new e.Cartesian3),new e.Cartesian3),pe=e.Cartesian3.normalize(e.Cartesian3.subtract(f,C,new e.Cartesian3),new e.Cartesian3),ie=new e.Cartesian3(C.x+te.x*Q,C.y+te.y*Q,C.z+te.z*Q),k=new e.Cartesian3(C.x+pe.x*Q,C.y+pe.y*Q,C.z+pe.z*Q),ee=new e.Cartesian3(C.x+te.x*Q+pe.x*Q,C.y+te.y*Q+pe.y*Q,C.z+te.z*Q+pe.z*Q),ae=i.entities.add({polyline:{positions:[ie,ee],width:t.width||3,material:b,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}}),Fe=i.entities.add({polyline:{positions:[k,ee],width:t.width||3,material:b,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}});this.angleMarkerEntities.push(ae,Fe)}this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);const Z={entity:this.segmentEntities,positions:[p,f,C],lengths:{vertical:E,horizontal:I,hypotenuse:_},angles:{acuteA:Y,acuteB:he},clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,Z)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(r=>{var he,oe;if(this.positions.length!==1)return;const s=i.scene.pickPosition(r.endPosition);if(!s)return;const o=e.Cartographic.fromCartesian(this.positions[0]),n=e.Cartographic.fromCartesian(s),l=o.height||0,c=n.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=((oe=(he=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:oe.call(he,.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 H=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})}}),U=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})}}),ne=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(H,U,ne)}const y=e.Cartesian3.distance(d,p),C=e.Cartesian3.distance(p,u),b=e.Cartesian3.distance(d,u),v=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(v,M),I=Math.sqrt(e.Cartesian3.dot(v,v))*Math.sqrt(e.Cartesian3.dot(M,M)),_=e.Cartesian3.dot(P,L),A=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)),S=Math.acos(Math.min(Math.max(_/(A||1),-1),1)),x=new e.Cartesian3((d.x+p.x)/2,(d.y+p.y)/2,(d.z+p.z)/2),$=new e.Cartesian3((p.x+u.x)/2,(p.y+u.y)/2,(p.z+u.z)/2),F=new e.Cartesian3((d.x+u.x)/2,(d.y+u.y)/2,(d.z+u.z)/2),O=e.Cartographic.fromCartesian(x),R=e.Cartographic.fromCartesian($),V=e.Cartographic.fromCartesian(F),W=e.Cartographic.fromCartesian(d),B=e.Cartographic.fromCartesian(u),K="measure_triangle_seg_v",q="measure_triangle_seg_h",re="measure_triangle_seg_hyp",j="measure_triangle_angle_a",ue="measure_triangle_angle_b";this.segmentLabelIds.length===0&&(this.segmentLabelIds=[K,q,re]),this.angleLabelIds.length===0&&(this.angleLabelIds=[j,ue]),this.htmlLabelPool.add({text:`${y.toFixed(2)} m`},{id:K,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:`${C.toFixed(2)} m`},{id:q,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:`${b.toFixed(2)} m`},{id:re,lon:e.Math.toDegrees(V.longitude),lat:e.Math.toDegrees(V.latitude),height:V.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:j,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"}}),this.htmlLabelPool.add({text:`${(S*180/Math.PI).toFixed(2)}°`},{id:ue,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"}});const X=Math.max(.01,Math.min(.5,t.angleMarkerRatio??.2)),Y=Math.min(y,C)*X;if(y>.001&&C>.001){const H=e.Cartesian3.normalize(e.Cartesian3.subtract(d,p,new e.Cartesian3),new e.Cartesian3),U=e.Cartesian3.normalize(e.Cartesian3.subtract(u,p,new e.Cartesian3),new e.Cartesian3),ne=new e.Cartesian3(p.x+H.x*Y,p.y+H.y*Y,p.z+H.z*Y),be=new e.Cartesian3(p.x+U.x*Y,p.y+U.y*Y,p.z+U.z*Y),Q=new e.Cartesian3(p.x+H.x*Y+U.x*Y,p.y+H.y*Y+U.y*Y,p.z+H.z*Y+U.z*Y);if(this.previewMarkerP1=ne,this.previewMarkerP2=be,this.previewMarkerCorner=Q,!this.previewAngleMarkerEntities.length){const Z=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})}}),te=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(Z,te)}}},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 te,pe;const i=this.Cesium,r=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,n=((pe=(te=s.dashLineColor||s.lineColor||s.color||i.Color.RED).withAlpha)==null?void 0:pe.call(te,.9))||i.Color.RED,l=s.width||3,c=(t.positions||[]).map(ie=>new i.Cartesian3(ie[0],ie[1],ie[2]));if(c.length<2)return;if(!this.htmlLabelPool){const ie=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new G(i,r,ie),this.htmlLabelPool.registerTheme("measure-triangle",{createElement:(k,ee)=>{var ae;k.innerHTML=String(((ae=ee==null?void 0:ee.data)==null?void 0:ae.text)||""),k.style.background="rgba(0,0,0,0.6)",k.style.color="#fff",k.style.font="14px sans-serif",k.style.padding="4px 6px",k.style.borderRadius="4px",k.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-seg",{createElement:(k,ee)=>{var ae;k.innerHTML=String(((ae=ee==null?void 0:ee.data)==null?void 0:ae.text)||""),k.style.background="rgba(0,0,0,0.6)",k.style.color="#fff",k.style.font="14px sans-serif",k.style.padding="4px 6px",k.style.borderRadius="4px",k.style.whiteSpace="pre"},options:{offset:{x:0,y:-10}}}),this.htmlLabelPool.registerTheme("measure-triangle-angle",{createElement:(k,ee)=>{var ae;k.innerHTML=String(((ae=ee==null?void 0:ee.data)==null?void 0:ae.text)||""),k.style.background="rgba(0,0,0,0.6)",k.style.color="#fff",k.style.font="14px sans-serif",k.style.padding="4px 6px",k.style.borderRadius="4px",k.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=r.entities.add({position:p,point:{pixelSize:8,color:s.pointColor||s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),y=r.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 C=i.Cartographic.fromCartesian(p),b=Math.max(m,g),v=i.Cartesian3.fromDegrees(i.Math.toDegrees(C.longitude),i.Math.toDegrees(C.latitude),b),M=r.entities.add({polyline:{positions:[p,v],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}}),P=r.entities.add({polyline:{positions:[v,f],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}}),L=r.entities.add({polyline:{positions:[p,f],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}});this.segmentEntities.push(M,P,L);const E=i.Cartesian3.distance(p,v),I=i.Cartesian3.distance(v,f),_=i.Cartesian3.distance(p,f),A=new i.Cartesian3((p.x+v.x)/2,(p.y+v.y)/2,(p.z+v.z)/2),T=new i.Cartesian3((v.x+f.x)/2,(v.y+f.y)/2,(v.z+f.z)/2),S=new i.Cartesian3((p.x+f.x)/2,(p.y+f.y)/2,(p.z+f.z)/2),x=i.Cartographic.fromCartesian(A),$=i.Cartographic.fromCartesian(T),F=i.Cartographic.fromCartesian(S),O=t.id+"_tri_v",R=t.id+"_tri_h",V=t.id+"_tri_hyp";this.segmentLabelIds=[O,R,V],this.htmlLabelPool.add({text:`${E.toFixed(2)} m`},{id:O,lon:i.Math.toDegrees(x.longitude),lat:i.Math.toDegrees(x.latitude),height:x.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($.longitude),lat:i.Math.toDegrees($.latitude),height:$.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${_.toFixed(2)} m`},{id:V,lon:i.Math.toDegrees(F.longitude),lat:i.Math.toDegrees(F.latitude),height:F.height||0,theme:"measure-triangle-seg",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const W=i.Cartesian3.subtract(f,p,new i.Cartesian3),B=i.Cartesian3.subtract(v,p,new i.Cartesian3),K=i.Cartesian3.subtract(v,f,new i.Cartesian3),q=i.Cartesian3.subtract(p,f,new i.Cartesian3),re=i.Cartesian3.dot(W,B),j=Math.sqrt(i.Cartesian3.dot(W,W))*Math.sqrt(i.Cartesian3.dot(B,B)),ue=i.Cartesian3.dot(K,q),X=Math.sqrt(i.Cartesian3.dot(K,K))*Math.sqrt(i.Cartesian3.dot(q,q)),Y=Math.acos(Math.min(Math.max(re/(j||1),-1),1)),he=Math.acos(Math.min(Math.max(ue/(X||1),-1),1)),oe=i.Cartographic.fromCartesian(p),H=i.Cartographic.fromCartesian(f),U=s.labelText||{angle:"角度"},ne=t.id+"_tri_angA",be=t.id+"_tri_angB";this.angleLabelIds=[ne,be],this.htmlLabelPool.add({text:`${U.angle}:${(Y*180/Math.PI).toFixed(2)}°`},{id:ne,lon:i.Math.toDegrees(oe.longitude),lat:i.Math.toDegrees(oe.latitude),height:oe.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}}),this.htmlLabelPool.add({text:`${U.angle}:${(he*180/Math.PI).toFixed(2)}°`},{id:be,lon:i.Math.toDegrees(H.longitude),lat:i.Math.toDegrees(H.latitude),height:H.height||0,theme:"measure-triangle-angle",show:!0,style:{pointerEvents:"none",userSelect:"none",cursor:"default"}});const Q=Math.max(.01,Math.min(.5,s.angleMarkerRatio??.2)),Z=Math.min(E,I)*Q;if(E>.001&&I>.001){const ie=i.Cartesian3.normalize(i.Cartesian3.subtract(p,v,new i.Cartesian3),new i.Cartesian3),k=i.Cartesian3.normalize(i.Cartesian3.subtract(f,v,new i.Cartesian3),new i.Cartesian3),ee=new i.Cartesian3(v.x+ie.x*Z,v.y+ie.y*Z,v.z+ie.z*Z),ae=new i.Cartesian3(v.x+k.x*Z,v.y+k.y*Z,v.z+k.z*Z),Fe=new i.Cartesian3(v.x+ie.x*Z+k.x*Z,v.y+ie.y*Z+k.y*Z,v.z+ie.z*Z+k.z*Z),Ar=r.entities.add({polyline:{positions:[ee,Fe],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}}),$r=r.entities.add({polyline:{positions:[ae,Fe],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}});this.angleMarkerEntities.push(Ar,$r)}}}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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,r),this.htmlLabelPool.registerTheme("measure-space",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var n,l,c;const s=i.scene.pickPosition(r.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=((l=(n=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(n,.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 C={entity:this.entity,label:this.labelEntity,positions:this.positions,distance:p,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,C)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(r=>{var g,p;if(this.positions.length!==1)return;const s=i.scene.pickPosition(r.endPosition);if(!s)return;this.previewPos=s;const o=this.positions[0],n=e.Cartesian3.distance(o,s),l=new e.Cartesian3((o.x+s.x)/2,(o.y+s.y)/2,(o.z+s.z)/2),c=e.Cartographic.fromCartesian(l),d=this.previewLabelId||"measure_space_preview";this.previewLabelId=d,this.htmlLabelPool.add({text:`${n.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,r=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,n=((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 G(i,r,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=r.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=r.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=r.entities.add({polyline:{positions:[c[0],c[1]],width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,r),this.htmlLabelPool.registerTheme("measure-area",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var m,g;const s=i.scene.pickPosition(r.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 n=new e.PolygonHierarchy(this.positions.slice()),l=new e.PolygonGeometry({polygonHierarchy:n,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 C of this.edgeEntities)try{i.entities.remove(C)}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(r=>{var p,f;if(this.positions.length===0)return;const s=i.scene.pickPosition(r.endPosition);if(!s)return;this.previewPos=s;const o=this.positions.concat([s]),n=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(n,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(n),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,C=((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:C,dashLength:12,dashPattern:255})}});const b=t.pointColor||t.color||e.Color.YELLOW,v=i.entities.add({position:new e.CallbackProperty(()=>this.previewPos||this.positions[this.positions.length-1],!1),point:{pixelSize:8,color:b,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.previewPointEntities.push(v)}},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 r=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(r,e.Ellipsoid.WGS84).projectPointsOntoPlane(this.positions);let n=0;for(let p=0;p<o.length;p++){const f=(p+1)%o.length;n+=o[p].x*o[f].y-o[f].x*o[p].y}n=Math.abs(n)/2;const l=e.Cartographic.fromCartesian(r),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}:${n.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],C=e.Cartographic.fromCartesian(w),b=e.Cartographic.fromCartesian(y),M=new e.EllipsoidGeodesic(C,b).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],C=f.x-w.x,b=f.y-w.y,v=y.x-w.x,M=y.y-w.y,P=Math.sqrt(C*C+b*b),L=Math.sqrt(v*v+M*M);if(!P||!L)continue;const E=C/P*(v/L)+b/P*(M/L),I=Math.acos(Math.min(1,Math.max(-1,E)))*(180/Math.PI),_=e.Cartographic.fromCartesian(this.positions[p]),A=`measure_area_angle_${Date.now()}_${p}`;this.angleLabelIds.push(A),this.htmlLabelPool.add({text:`${d.angle}:${I.toFixed(2)} °`},{id:A,lon:e.Math.toDegrees(_.longitude),lat:e.Math.toDegrees(_.latitude),height:_.height||0,theme:"measure-area-angle",show:!0})}const m={entity:this.primitive,label:this.labelEntity,positions:this.positions,area:n,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,r=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 G(i,r,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=r.entities.add({position:M,point:{pixelSize:8,color:s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.tempPoints.push(P)}const n=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(n,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(n),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),C=s.color&&s.color.withAlpha?s.color.withAlpha(.25):i.Color.RED.withAlpha(.4),b=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:C}),translucent:!0,closed:!0})});r.scene.primitives.add(b),this.primitive=b;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),_=i.Cartographic.fromCartesian(E),T=new i.EllipsoidGeodesic(I,_).surfaceDistance,S=new i.Cartesian3((L.x+E.x)/2,(L.y+E.y)/2,(L.z+E.z)/2),x=i.Cartographic.fromCartesian(S),$=t.id+`_area_seg_${M}`;this.segmentLabelIds.push($),this.htmlLabelPool.add({text:`${g.side}:${T.toFixed(2)} m`},{id:$,lon:i.Math.toDegrees(x.longitude),lat:i.Math.toDegrees(x.latitude),height:x.height||0,theme:"measure-area-seg",show:!0})}const v=c;for(let M=0;M<v.length;M++){const P=v[(M-1+v.length)%v.length],L=v[M],E=v[(M+1)%v.length],I=P.x-L.x,_=P.y-L.y,A=E.x-L.x,T=E.y-L.y,S=Math.sqrt(I*I+_*_),x=Math.sqrt(A*A+T*T);if(!S||!x)continue;const $=I/S*(A/x)+_/S*(T/x),F=Math.acos(Math.min(1,Math.max(-1,$)))*(180/Math.PI),O=i.Cartographic.fromCartesian(o[M]),R=t.id+`_area_angle_${M}`;this.angleLabelIds.push(R),this.htmlLabelPool.add({text:`${g.angle}:${F.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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,r),this.htmlLabelPool.registerTheme("measure-circle",{createElement:(s,o)=>{var l;const n=((l=o==null?void 0:o.data)==null?void 0:l.text)||"";s.innerHTML=String(n),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(r=>{var o;const s=i.scene.pickPosition(r.position);if(s&&(this.positions.push(s),this.positions.length===2)){this.stop();const n=this.positions[0],l=this.positions[1],c=e.Cartesian3.distance(n,l),d=Math.PI*c*c,u=2*Math.PI*c,m=t.labelText||{radius:"半径",area:"面积",circumference:"周长"},g=n;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²
|
|
@@ -52,26 +52,26 @@ ${m.circumference}:${u.toFixed(2)} m`):this.labelEntity=i.entities.add({position
|
|
|
52
52
|
${m.area}:${d.toFixed(2)} m²
|
|
53
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,C=this.htmlLabelId||`measure_circle_${Date.now()}`;this.htmlLabelId=C;const b=`${m.radius}:${l.toFixed(2)} m
|
|
54
54
|
${m.area}:${d.toFixed(2)} m²
|
|
55
|
-
${m.circumference}:${u.toFixed(2)} m`;if(this.htmlLabelPool.add({text:b},{id:C,lon:f,lat:w,height:y,theme:"measure-circle",show:!0}),!this.previewEntity){const v=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:v}})}},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,r=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
|
|
55
|
+
${m.circumference}:${u.toFixed(2)} m`;if(this.htmlLabelPool.add({text:b},{id:C,lon:f,lat:w,height:y,theme:"measure-circle",show:!0}),!this.previewEntity){const v=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:v}})}},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,r=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 G(i,r,P),this.htmlLabelPool.registerTheme("measure-circle",{createElement:(L,E)=>{var _;const I=((_=E==null?void 0:E.data)==null?void 0:_.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 n=o[0],l=o[1],c=i.Cartesian3.distance(n,l),d=Math.PI*c*c,u=2*Math.PI*c,m=i.Cartographic.fromCartesian(n),g=new i.EllipseGeometry({center:n,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})});r.scene.primitives.add(y),this.ellipsePrimitive=y,this.entity=y,this.isPrimitive=!0;const C=i.Cartographic.fromCartesian(n),b=t.id+"_circle";this.htmlLabelId=b;const v=s.labelText||{radius:"半径",area:"面积",circumference:"周长"},M=`${v.radius}:${c.toFixed(2)} m
|
|
56
56
|
${v.area}:${d.toFixed(2)} m²
|
|
57
|
-
${v.circumference}:${u.toFixed(2)} m`;this.htmlLabelPool.add({text:M},{id:b,lon:i.Math.toDegrees(C.longitude),lat:i.Math.toDegrees(C.latitude),height:C.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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new B(e,i,r),this.htmlLabelPool.registerTheme("measure-polyline-total",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var n,l;const s=i.scene.pickPosition(r.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:((l=(n=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(n,.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 r=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;r+=w}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),n=this.totalLabelId||`measure_polyline_total_${Date.now()}`;this.totalLabelId=n,this.htmlLabelPool.add({text:`${r.toFixed(2)} m`},{id:n,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 l={entity:this.entity,label:this.labelEntity,segmentLabels:this.segmentLabelIds,positions:this.positions,distance:r,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,l)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.handler.setInputAction(r=>{var p,f;if(this.positions.length===0)return;const s=i.scene.pickPosition(r.endPosition);if(!s)return;this.hoverPos=s,this.previewPos=s;const o=this.positions[this.positions.length-1],n=e.Cartographic.fromCartesian(o),l=e.Cartographic.fromCartesian(s),d=new e.EllipsoidGeodesic(n,l).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.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,r=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,n=((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 B(i,r,w),this.htmlLabelPool.registerTheme("measure-polyline-total",{createElement:(y,C)=>{var b;y.innerHTML=String(((b=C==null?void 0:C.data)==null?void 0:b.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,C)=>{var b;y.innerHTML=String(((b=C==null?void 0:C.data)==null?void 0:b.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=r.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=r.entities.add({polyline:{positions:c,width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}});let d=0;for(let w=1;w<c.length;w++){const y=i.Cartographic.fromCartesian(c[w-1]),C=i.Cartographic.fromCartesian(c[w]),b=new i.EllipsoidGeodesic(y,C);d+=b.surfaceDistance;const v=c[w-1],M=c[w],P=new i.Cartesian3((v.x+M.x)/2,(v.y+M.y)/2,(v.z+M.z)/2),L=i.Cartographic.fromCartesian(P),E=t.id+`_seg_${w-1}`;this.segmentLabelIds.push(E),this.htmlLabelPool.add({text:`${b.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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new B(e,i,r),this.htmlLabelPool.registerTheme("measure-terrainHeight",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var w;const s=i.scene.pickPosition(r.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),n=i.scene.globe.getHeight(new e.Cartographic(o.longitude,o.latitude,0))||0,l=e.Math.toDegrees(o.longitude),c=e.Math.toDegrees(o.latitude),d=e.Cartesian3.fromDegrees(l,c,n);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)-n,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: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:n,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,r=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 B(i,r,w),this.htmlLabelPool.registerTheme("measure-terrainHeight",{createElement:(y,C)=>{var b;y.innerHTML=String(((b=C==null?void 0:C.data)==null?void 0:b.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 n=o[0],l=i.Cartographic.fromCartesian(n),c=r.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=r.entities.add({position:n,point:{pixelSize:8,color:s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.zeroPoint=r.entities.add({position:m,point:{pixelSize:8,color:i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.lineEntity=r.entities.add({polyline:{positions:[m,n],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 Qe{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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new B(e,i,r),this.htmlLabelPool.registerTheme("measure-coordinate",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var g;const s=i.scene.pickPosition(r.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),n=e.Math.toDegrees(o.longitude),l=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}:${n.toFixed(6)}
|
|
57
|
+
${v.circumference}:${u.toFixed(2)} m`;this.htmlLabelPool.add({text:M},{id:b,lon:i.Math.toDegrees(C.longitude),lat:i.Math.toDegrees(C.latitude),height:C.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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,r),this.htmlLabelPool.registerTheme("measure-polyline-total",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var n,l;const s=i.scene.pickPosition(r.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:((l=(n=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(n,.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 r=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;r+=w}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),n=this.totalLabelId||`measure_polyline_total_${Date.now()}`;this.totalLabelId=n,this.htmlLabelPool.add({text:`${r.toFixed(2)} m`},{id:n,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 l={entity:this.entity,label:this.labelEntity,segmentLabels:this.segmentLabelIds,positions:this.positions,distance:r,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,l)},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.handler.setInputAction(r=>{var p,f;if(this.positions.length===0)return;const s=i.scene.pickPosition(r.endPosition);if(!s)return;this.hoverPos=s,this.previewPos=s;const o=this.positions[this.positions.length-1],n=e.Cartographic.fromCartesian(o),l=e.Cartographic.fromCartesian(s),d=new e.EllipsoidGeodesic(n,l).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.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,r=this.viewer,s=t.options||{},o=s.lineColor||s.color||i.Color.YELLOW,n=((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 G(i,r,w),this.htmlLabelPool.registerTheme("measure-polyline-total",{createElement:(y,C)=>{var b;y.innerHTML=String(((b=C==null?void 0:C.data)==null?void 0:b.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,C)=>{var b;y.innerHTML=String(((b=C==null?void 0:C.data)==null?void 0:b.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=r.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=r.entities.add({polyline:{positions:c,width:l,material:o,depthFailMaterial:new i.PolylineDashMaterialProperty({color:n,dashLength:12,dashPattern:255})}});let d=0;for(let w=1;w<c.length;w++){const y=i.Cartographic.fromCartesian(c[w-1]),C=i.Cartographic.fromCartesian(c[w]),b=new i.EllipsoidGeodesic(y,C);d+=b.surfaceDistance;const v=c[w-1],M=c[w],P=new i.Cartesian3((v.x+M.x)/2,(v.y+M.y)/2,(v.z+M.z)/2),L=i.Cartographic.fromCartesian(P),E=t.id+`_seg_${w-1}`;this.segmentLabelIds.push(E),this.htmlLabelPool.add({text:`${b.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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,r),this.htmlLabelPool.registerTheme("measure-terrainHeight",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var w;const s=i.scene.pickPosition(r.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),n=i.scene.globe.getHeight(new e.Cartographic(o.longitude,o.latitude,0))||0,l=e.Math.toDegrees(o.longitude),c=e.Math.toDegrees(o.latitude),d=e.Cartesian3.fromDegrees(l,c,n);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)-n,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: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:n,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,r=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 G(i,r,w),this.htmlLabelPool.registerTheme("measure-terrainHeight",{createElement:(y,C)=>{var b;y.innerHTML=String(((b=C==null?void 0:C.data)==null?void 0:b.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 n=o[0],l=i.Cartographic.fromCartesian(n),c=r.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=r.entities.add({position:n,point:{pixelSize:8,color:s.color||i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.zeroPoint=r.entities.add({position:m,point:{pixelSize:8,color:i.Color.YELLOW,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),this.lineEntity=r.entities.add({polyline:{positions:[m,n],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 Qe{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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,r),this.htmlLabelPool.registerTheme("measure-coordinate",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var g;const s=i.scene.pickPosition(r.position);if(!s)return;const o=e.Cartographic.fromCartesian(s),n=e.Math.toDegrees(o.longitude),l=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}:${n.toFixed(6)}
|
|
58
58
|
${u.lat}:${l.toFixed(6)}
|
|
59
|
-
${u.height}:${c.toFixed(2)} m`},{id:d,lon:n,lat:l,height:c,theme:"measure-coordinate",show:!0}),this.labelEntity=this.htmlLabelId;const m={entity:this.entity,label:this.labelEntity,lnglat:{lng:n,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,r=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
|
|
59
|
+
${u.height}:${c.toFixed(2)} m`},{id:d,lon:n,lat:l,height:c,theme:"measure-coordinate",show:!0}),this.labelEntity=this.htmlLabelId;const m={entity:this.entity,label:this.labelEntity,lnglat:{lng:n,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,r=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 G(i,r,f),this.htmlLabelPool.registerTheme("measure-coordinate",{createElement:(w,y)=>{var C;w.innerHTML=String(((C=y==null?void 0:y.data)==null?void 0:C.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 n=o[0],l=i.Cartographic.fromCartesian(n),c=i.Math.toDegrees(l.longitude),d=i.Math.toDegrees(l.latitude),u=l.height||0;this.entity=r.entities.add({position:n,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 Ze{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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new
|
|
61
|
+
${g.height}:${u.toFixed(2)} m`},{id:m,lon:c,lat:d,height:u,theme:"measure-coordinate",show:!0})}}class Ze{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 r=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,r),this.htmlLabelPool.registerTheme("measure-rectangle",{createElement:(s,o)=>{var n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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 n;s.innerHTML=String(((n=o==null?void 0:o.data)==null?void 0:n.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(r=>{var S,x,$;const s=i.scene.pickPosition(r.position);if(!s)return;if(!this.startPoint){this.startPoint=s;return}if(!this.secondPoint){this.secondPoint=s,this.endPoint=s;return}const o=s,n=this.computeRectangle(this.startPoint,this.secondPoint,o);if(!n){this.stop();return}this.stop();const{corners:l,center:c,width:d,height:u,area:m}=n;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 F=0;F<w.length;F++){const[O,R]=w[F],
|
|
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 F=0;F<w.length;F++){const[O,R]=w[F],V=F===0||F===2?d:u,W=new e.Cartesian3((O.x+R.x)/2,(O.y+R.y)/2,(O.z+R.z)/2),B=e.Cartographic.fromCartesian(W),K=`measure_rectangle_seg_${Date.now()}_${F}`;this.segmentLabelIds.push(K),this.htmlLabelPool.add({text:`${f.side}:${Number(V).toFixed(2)} m`},{id:K,lon:e.Math.toDegrees(B.longitude),lat:e.Math.toDegrees(B.latitude),height:B.height||0,theme:"measure-rectangle-seg",show:!0})}const y=this.buildSurfaceRectanglePositions(l),C=new e.PolygonHierarchy(y),b=new e.PolygonGeometry({polygonHierarchy:C,vertexFormat:e.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:e.ArcType.NONE}),v=new e.GeometryInstance({geometry:b}),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:v,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=((x=(S=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:x.call(S,.9))||e.Color.RED,I=[...y,y[0]],_=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(_);const A=t.pointColor||t.color||e.Color.YELLOW;for(const F of l){const O=i.entities.add({position:F,point:{pixelSize:8,color:A,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(O)}const T={entity:this.primitive,label:this.labelEntity,positions:[this.startPoint,this.secondPoint,o],width:d,height:u,area:m,clear:()=>this.clear()};($=t.onComplete)==null||$.call(t,T)},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(r=>{var w,y;const s=i.scene.pickPosition(r.endPosition);if(!s)return;if(this.startPoint&&!this.secondPoint){if(this.endPoint=s,!this.previewEdgeEntity){const C=t.lineColor||t.color||e.Color.YELLOW,b=((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:C,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}});const v=t.pointColor||t.color||e.Color.YELLOW,M=i.entities.add({position:this.startPoint,point:{pixelSize:8,color:v,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),P=i.entities.add({position:new e.CallbackProperty(()=>this.endPoint||this.startPoint,!1),point:{pixelSize:8,color:v,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:n,center:l,width:c,height:d,area:u}=o,m=this.buildSurfaceRectanglePositions(n);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
|
|
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 C=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:C,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,r=this.viewer,s=t.options||{},o=(t.positions||[]).map(A=>new i.Cartesian3(A[0],A[1],A[2]));if(o.length<3)return;if(!this.htmlLabelPool){const A=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new
|
|
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 C=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:C,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,r=this.viewer,s=t.options||{},o=(t.positions||[]).map(A=>new i.Cartesian3(A[0],A[1],A[2]));if(o.length<3)return;if(!this.htmlLabelPool){const A=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new G(i,r,A),this.htmlLabelPool.registerTheme("measure-rectangle",{createElement:(T,S)=>{var x;T.innerHTML=String(((x=S==null?void 0:S.data)==null?void 0:x.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,S)=>{var x;T.innerHTML=String(((x=S==null?void 0:S.data)==null?void 0:x.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 n=this.computeRectangle(o[0],o[1],o[2]);if(!n)return;const l=n.corners,c=n.center,d=n.width,u=n.height,m=n.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 A=0;A<w.length;A++){const[T,S]=w[A],x=A===0||A===2?d:u,$=new i.Cartesian3((T.x+S.x)/2,(T.y+S.y)/2,(T.z+S.z)/2),F=i.Cartographic.fromCartesian($),O=t.id+`_rectangle_seg_${A}`;this.segmentLabelIds.push(O),this.htmlLabelPool.add({text:`${f.side}:${Number(x).toFixed(2)} m`},{id:O,lon:i.Math.toDegrees(F.longitude),lat:i.Math.toDegrees(F.latitude),height:F.height||0,theme:"measure-rectangle-seg",show:!0})}const y=new i.PolygonHierarchy(l),C=new i.PolygonGeometry({polygonHierarchy:y,vertexFormat:i.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:i.ArcType.NONE}),b=new i.GeometryInstance({geometry:C}),v=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:b,appearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:v}),translucent:!0,closed:!0}),depthFailAppearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:M}),translucent:!0,closed:!0})});this.primitive=P,r.scene.primitives.add(this.primitive);const L=s.lineColor||v,E=[...l,l[0]],I=r.entities.add({polyline:{positions:E,width:s.width||2,material:L,clampToGround:!1,arcType:i.ArcType.NONE}});this.edgeEntities.push(I);const
|
|
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 A=0;A<w.length;A++){const[T,S]=w[A],x=A===0||A===2?d:u,$=new i.Cartesian3((T.x+S.x)/2,(T.y+S.y)/2,(T.z+S.z)/2),F=i.Cartographic.fromCartesian($),O=t.id+`_rectangle_seg_${A}`;this.segmentLabelIds.push(O),this.htmlLabelPool.add({text:`${f.side}:${Number(x).toFixed(2)} m`},{id:O,lon:i.Math.toDegrees(F.longitude),lat:i.Math.toDegrees(F.latitude),height:F.height||0,theme:"measure-rectangle-seg",show:!0})}const y=new i.PolygonHierarchy(l),C=new i.PolygonGeometry({polygonHierarchy:y,vertexFormat:i.MaterialAppearance.VERTEX_FORMAT,perPositionHeight:!0,arcType:i.ArcType.NONE}),b=new i.GeometryInstance({geometry:C}),v=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:b,appearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:v}),translucent:!0,closed:!0}),depthFailAppearance:new i.MaterialAppearance({material:i.Material.fromType("Color",{color:M}),translucent:!0,closed:!0})});this.primitive=P,r.scene.primitives.add(this.primitive);const L=s.lineColor||v,E=[...l,l[0]],I=r.entities.add({polyline:{positions:E,width:s.width||2,material:L,clampToGround:!1,arcType:i.ArcType.NONE}});this.edgeEntities.push(I);const _=s.pointColor||v;for(const A of l){const T=r.entities.add({position:A,point:{pixelSize:8,color:_,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(T)}}computeRectangle(t,e,i){const r=this.Cesium,s=new r.EllipsoidTangentPlane(t,r.Ellipsoid.WGS84),o=s.projectPointsOntoPlane([t,e,i]);if(!o||o.length<3)return null;const n=o[0],l=o[1],c=o[2],d=l.x-n.x,u=l.y-n.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,C=c.y-l.y,b=y*f+C*w;if(!b)return null;const v=new r.Cartesian2(l.x+f*b,l.y+w*b),M=new r.Cartesian2(n.x+f*b,n.y+w*b),P=s.projectPointsOntoEllipsoid([n,l,v,M]);if(!P||P.length<4)return null;const L=P,E=L[0],I=L[2],_=Math.abs(m),A=Math.abs(b),T=new r.Cartesian3((E.x+I.x)/2,(E.y+I.y)/2,(E.z+I.z)/2),x=new r.EllipsoidTangentPlane(T,r.Ellipsoid.WGS84).projectPointsOntoPlane(L);let $=0;for(let O=0;O<x.length;O++){const R=(O+1)%x.length;$+=x[O].x*x[R].y-x[R].x*x[O].y}const F=Math.abs($)/2;return{corners:L,center:T,width:_,height:A,area:F}}}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,r=Math.max(t.sides||6,6);if(!this.htmlLabelPool){const s=t.overlayContainerId||"html-label-container";this.htmlLabelPool=new G(e,i,s),this.htmlLabelPool.registerTheme("measure-regular",{createElement:(o,n)=>{var l;o.innerHTML=String(((l=n==null?void 0:n.data)==null?void 0:l.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,n)=>{var l;o.innerHTML=String(((l=n==null?void 0:n.data)==null?void 0:l.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 n,l,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,r);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),C=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:C}),translucent:!0,closed:!0})}),i.scene.primitives.add(this.primitive);const b=t.lineColor||y,v=((l=(n=t.dashLineColor||t.lineColor||t.color||e.Color.RED).withAlpha)==null?void 0:l.call(n,.9))||e.Color.RED,M=g.slice(),P=i.entities.add({polyline:{positions:M,width:t.width||2,material:b,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:v,dashLength:12,dashPattern:255})}});this.edgeEntities.push(P);const L=t.pointColor||y,E=g.slice(0,g.length-1);for(const $ of E){const F=i.entities.add({position:$,point:{pixelSize:8,color:L,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.pointEntities.push(F)}const I=this.computeAreaByPlane(g),_=e.Cartographic.fromCartesian(d),A=this.htmlLabelId||`measure_regular_${Date.now()}`;this.htmlLabelId=A;const T=t.labelText||{sides:"边数",radius:"半径",circumference:"周长",area:"面积",side:"边长"};this.previewLabelId&&this.htmlLabelPool&&(this.htmlLabelPool.removeByIds([this.previewLabelId]),this.previewLabelId=null);let S=0;for(let $=1;$<g.length;$++){const F=g[$-1],O=g[$],R=e.Cartographic.fromCartesian(F),V=e.Cartographic.fromCartesian(O),B=new e.EllipsoidGeodesic(R,V).surfaceDistance;S+=B;const K=new e.Cartesian3((F.x+O.x)/2,(F.y+O.y)/2,(F.z+O.z)/2),q=e.Cartographic.fromCartesian(K),re=`measure_regular_seg_${Date.now()}_${$-1}`;this.segmentLabelIds.push(re),this.htmlLabelPool.add({text:`${T.side}:${B.toFixed(2)} m`},{id:re,lon:e.Math.toDegrees(q.longitude),lat:e.Math.toDegrees(q.latitude),height:q.height||0,theme:"measure-regular-seg",show:!0})}this.htmlLabelPool.add({text:`${T.sides}:${r}
|
|
68
68
|
${T.radius}:${m.toFixed(2)} m
|
|
69
69
|
${T.circumference}:${S.toFixed(2)} m
|
|
70
|
-
${T.area}:${I.toFixed(2)} m²`},{id:A,lon:e.Math.toDegrees(
|
|
70
|
+
${T.area}:${I.toFixed(2)} m²`},{id:A,lon:e.Math.toDegrees(_.longitude),lat:e.Math.toDegrees(_.latitude),height:_.height||0,theme:"measure-regular",show:!0});const x={entity:this.primitive,label:this.labelEntity,positions:g,radius:m,sides:r,perimeter:S,area:I,clear:()=>this.clear()};(c=t.onComplete)==null||c.call(t,x)}},e.ScreenSpaceEventType.LEFT_CLICK),this.handler.setInputAction(s=>{var f,w;if(this.positions.length!==1)return;const o=this.positions[0],n=i.camera.getPickRay(s.endPosition),l=i.scene.globe.pick(n,i.scene);if(!l)return;const c=e.Cartesian3.distance(o,l);if(this.currentPoints=this.buildRegularPolygonPoints(o,c,r),!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 C=t.lineColor||t.color||e.Color.YELLOW,b=((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:C,clampToGround:!1,arcType:e.ArcType.NONE,depthFailMaterial:new e.PolylineDashMaterialProperty({color:b,dashLength:12,dashPattern:255})}});const v=t.pointColor||t.color||e.Color.YELLOW,M=i.entities.add({position:o,point:{pixelSize:8,color:v,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),P=i.entities.add({position:new e.CallbackProperty(()=>l||o,!1),point:{pixelSize:8,color:v,disableDepthTestDistance:Number.POSITIVE_INFINITY}});this.previewPointEntities.push(M,P)}let d=0;for(let y=1;y<this.currentPoints.length;y++){const C=this.currentPoints[y-1],b=this.currentPoints[y],v=e.Cartographic.fromCartesian(C),M=e.Cartographic.fromCartesian(b),P=new e.EllipsoidGeodesic(v,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}:${r}
|
|
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,r=this.viewer,s=t.options||{},o=((P=t.data)==null?void 0:P.sides)||s.sides||3,n=(t.positions||[]).map(L=>new i.Cartesian3(L[0],L[1],L[2]));if(n.length<2)return;if(!this.htmlLabelPool){const L=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new
|
|
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,r=this.viewer,s=t.options||{},o=((P=t.data)==null?void 0:P.sides)||s.sides||3,n=(t.positions||[]).map(L=>new i.Cartesian3(L[0],L[1],L[2]));if(n.length<2)return;if(!this.htmlLabelPool){const L=s.overlayContainerId||"html-label-container";this.htmlLabelPool=e||new G(i,r,L),this.htmlLabelPool.registerTheme("measure-regular",{createElement:(E,I)=>{var _;E.innerHTML=String(((_=I==null?void 0:I.data)==null?void 0:_.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 _;E.innerHTML=String(((_=I==null?void 0:I.data)==null?void 0:_.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=n[0],d=0;if(n.length>=3){l=n.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=n[1];d=i.Cartesian3.distance(c,L),l=this.buildRegularPolygonPoints(c,d,Math.max(o,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})});r.scene.primitives.add(w),this.primitive=w;const y=this.computeAreaByPlane(l),C=i.Cartographic.fromCartesian(c),b=t.id+"_regular";this.htmlLabelId=b;const v=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],_=i.Cartographic.fromCartesian(E),A=i.Cartographic.fromCartesian(I),S=new i.EllipsoidGeodesic(_,A).surfaceDistance;M+=S;const x=new i.Cartesian3((E.x+I.x)/2,(E.y+I.y)/2,(E.z+I.z)/2),$=i.Cartographic.fromCartesian(x),F=t.id+`_regular_seg_${L-1}`;this.segmentLabelIds.push(F),this.htmlLabelPool.add({text:`${v.side}:${S.toFixed(2)} m`},{id:F,lon:i.Math.toDegrees($.longitude),lat:i.Math.toDegrees($.latitude),height:$.height||0,theme:"measure-regular-seg",show:!0})}this.htmlLabelPool.add({text:`${v.sides}:${Math.max(o,3)}
|
|
74
74
|
${v.radius}:${d.toFixed(2)} m
|
|
75
75
|
${v.circumference}:${M.toFixed(2)} m
|
|
76
|
-
${v.area}:${y.toFixed(2)} m²`},{id:b,lon:i.Math.toDegrees(C.longitude),lat:i.Math.toDegrees(C.latitude),height:C.height||0,theme:"measure-regular",show:!0})}buildRegularPolygonPoints(t,e,i){const r=this.Cesium,s=new r.EllipsoidTangentPlane(t,r.Ellipsoid.WGS84),o=2*Math.PI/i,n=[];for(let d=0;d<i;d++){const u=d*o,m=e*Math.cos(u),g=e*Math.sin(u);n.push(new r.Cartesian2(m,g))}const c=s.projectPointsOntoEllipsoid(n).slice();return c.push(c[0]),c}computeAreaByPlane(t){const e=this.Cesium,i=new e.Cartesian3(t.reduce((n,l)=>n+l.x,0)/t.length,t.reduce((n,l)=>n+l.y,0)/t.length,t.reduce((n,l)=>n+l.z,0)/t.length),s=new e.EllipsoidTangentPlane(i,e.Ellipsoid.WGS84).projectPointsOntoPlane(t);let o=0;for(let n=0;n<s.length;n++){const l=(n+1)%s.length;o+=s[n].x*s[l].y-s[l].x*s[n].y}return Math.abs(o)/2}}class Dr{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 Qe(this.Cesium,this.viewer);break;case"rectangle":i=new Ze(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 r=i,s={...e,onComplete:o=>{var c;const n={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(n),r&&this.recordHandlers.set(n.id,r),this.specifiedClear&&this._showDeleteLabels("html-label-container"),(c=e.onComplete)==null||c.call(e,o);const l=this.actives.indexOf(r);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 r,s;const i=(s=(r=this.viewer)==null?void 0:r.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 r of t.measurements){let s=null;switch(r.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 Qe(this.Cesium,this.viewer);break;case"rectangle":s=new Ze(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,r,void 0),s&&r.id&&this.recordHandlers.set(r.id,s),this.measurements.find(n=>n.id===r.id)||this.measurements.push(r)}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 n=i[o];try{e.entities.remove(n)}catch{}}const r=e.scene.primitives,s=[];r._primitives&&r._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 B(this.Cesium,this.viewer,e),this.deleteLabelPool.registerTheme("measure-delete-label",{createElement:(i,r)=>{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(U.Click,{name:"measurement_delete_label_click",fn:i=>{var s;if(!i||i.theme!=="measure-delete-label")return;const r=(s=i==null?void 0:i.data)==null?void 0:s.recordId;r&&this.deleteMeasurement(r)}},!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(r=>r.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 r="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),n=e.Math.toDegrees(o.longitude),l=e.Math.toDegrees(o.latitude),c=o.height||0;this.deleteLabelPool.add({recordId:i.id},{id:r,lon:n,lat:l,height:c,theme:"measure-delete-label",show:!0,style:{zIndex:"1000"}}),this.deleteLabelIds.set(i.id,r)}}_removeAllDeleteLabels(){if(this.deleteLabelPool){const t=Array.from(this.deleteLabelIds.values());t.length&&this.deleteLabelPool.removeByIds(t)}this.deleteLabelIds.clear()}_computeRecordCenter(t){var r,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,n=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(o,n,l)}if(t.type==="coordinate"&&((r=t.data)!=null&&r.lnglat)){const o=t.data.lnglat.lng,n=t.data.lnglat.lat,l=t.data.lnglat.height||0;return e.Cartesian3.fromDegrees(o,n,l)}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 _r{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),r=this.entity.orientation.getValue(e);if(i&&r){const s=this.Cesium.Matrix4.fromTranslationQuaternionRotationScale(i,r,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,r=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(),n=t.speed||100;let l=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(n,.1);l+=g,c.push(this.Cesium.JulianDate.addSeconds(o,l,new this.Cesium.JulianDate))}i.addSample(c[u],s[u].position),r.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:r};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,r=this.viewer.camera.roll;return{destination:{x:t.x,y:t.y,z:t.z},orientation:{heading:e,pitch:i,roll:r}}}}class Sr{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 r=this.Cesium.Cartesian3.add(i,this.cameraOffset,new this.Cesium.Cartesian3);this.viewer.camera.setView({destination:r,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,r=this.buildTimes(e,i),s=new this.Cesium.SampledPositionProperty;for(let g=0;g<e.length;g++)s.addSample(r[g],e[g]);this.positionProperty=s;const o=new this.Cesium.VelocityOrientationProperty(s),n=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:o,path:n?{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[r,s,o]=i;e.push(this.Cesium.Cartesian3.fromDegrees(r,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=[],r=this.Cesium.JulianDate.now();let s=0;for(let o=0;o<t.length;o++)if(o===0)i.push(r.clone());else{const n=this.Cesium.Cartesian3.distance(t[o-1],t[o]);s+=n/Math.max(e,.1),i.push(this.Cesium.JulianDate.addSeconds(r,s,new this.Cesium.JulianDate))}return this.startTime=i[0],this.stopTime=i[i.length-1],i}}_.AreaMeasure=Ke,_.BufferedHierarchicalAggregator=ie,_.CameraRoamTool=_r,_.CircleMeasure=qe,_.CoordinateMeasure=Qe,_.DOM_EVENT_MAP=it,_.DrawTool=Wt,_.EditMode=zt,_.EntityLayerManager=Ir,_.GLTFManage=Cr,_.GLTFManageEventKey=Nt,_.HorizontalMeasure=Ye,_.HtmlOverlayLabelPool=B,_.MarkerEventBus=tt,_.MarkerEventKey=U,_.MaterialManager=Lr,_.MeasurementTool=Dr,_.PathRoamTool=Sr,_.PolylineDistanceMeasure=Xe,_.PrimitiveManager=xr,_.RectangleMeasure=Ze,_.RegularPolygonMeasure=et,_.SpaceMeasure=Ue,_.TerrainHeightMeasure=Je,_.TooltipManager=xe,_.TriangleMeasure=We,_.VerticalMeasure=Ve,_.convertGeoJsonToEntityData=Tr,_.getDynamicImgMaterial=vr,_.getPolylineFlowMaterialProperty=Pr,_.getWallMaterial=br,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
|
|
76
|
+
${v.area}:${y.toFixed(2)} m²`},{id:b,lon:i.Math.toDegrees(C.longitude),lat:i.Math.toDegrees(C.latitude),height:C.height||0,theme:"measure-regular",show:!0})}buildRegularPolygonPoints(t,e,i){const r=this.Cesium,s=new r.EllipsoidTangentPlane(t,r.Ellipsoid.WGS84),o=2*Math.PI/i,n=[];for(let d=0;d<i;d++){const u=d*o,m=e*Math.cos(u),g=e*Math.sin(u);n.push(new r.Cartesian2(m,g))}const c=s.projectPointsOntoEllipsoid(n).slice();return c.push(c[0]),c}computeAreaByPlane(t){const e=this.Cesium,i=new e.Cartesian3(t.reduce((n,l)=>n+l.x,0)/t.length,t.reduce((n,l)=>n+l.y,0)/t.length,t.reduce((n,l)=>n+l.z,0)/t.length),s=new e.EllipsoidTangentPlane(i,e.Ellipsoid.WGS84).projectPointsOntoPlane(t);let o=0;for(let n=0;n<s.length;n++){const l=(n+1)%s.length;o+=s[n].x*s[l].y-s[l].x*s[n].y}return Math.abs(o)/2}}class _r{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 Qe(this.Cesium,this.viewer);break;case"rectangle":i=new Ze(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 r=i,s={...e,onComplete:o=>{var c;const n={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(n),r&&this.recordHandlers.set(n.id,r),this.specifiedClear&&this._showDeleteLabels("html-label-container"),(c=e.onComplete)==null||c.call(e,o);const l=this.actives.indexOf(r);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 r,s;const i=(s=(r=this.viewer)==null?void 0:r.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 r of t.measurements){let s=null;switch(r.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 Qe(this.Cesium,this.viewer);break;case"rectangle":s=new Ze(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,r,void 0),s&&r.id&&this.recordHandlers.set(r.id,s),this.measurements.find(n=>n.id===r.id)||this.measurements.push(r)}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 n=i[o];try{e.entities.remove(n)}catch{}}const r=e.scene.primitives,s=[];r._primitives&&r._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 G(this.Cesium,this.viewer,e),this.deleteLabelPool.registerTheme("measure-delete-label",{createElement:(i,r)=>{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(J.Click,{name:"measurement_delete_label_click",fn:i=>{var s;if(!i||i.theme!=="measure-delete-label")return;const r=(s=i==null?void 0:i.data)==null?void 0:s.recordId;r&&this.deleteMeasurement(r)}},!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(r=>r.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 r="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),n=e.Math.toDegrees(o.longitude),l=e.Math.toDegrees(o.latitude),c=o.height||0;this.deleteLabelPool.add({recordId:i.id},{id:r,lon:n,lat:l,height:c,theme:"measure-delete-label",show:!0,style:{zIndex:"1000"}}),this.deleteLabelIds.set(i.id,r)}}_removeAllDeleteLabels(){if(this.deleteLabelPool){const t=Array.from(this.deleteLabelIds.values());t.length&&this.deleteLabelPool.removeByIds(t)}this.deleteLabelIds.clear()}_computeRecordCenter(t){var r,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,n=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(o,n,l)}if(t.type==="coordinate"&&((r=t.data)!=null&&r.lnglat)){const o=t.data.lnglat.lng,n=t.data.lnglat.lat,l=t.data.lnglat.height||0;return e.Cartesian3.fromDegrees(o,n,l)}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 Dr{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),r=this.entity.orientation.getValue(e);if(i&&r){const s=this.Cesium.Matrix4.fromTranslationQuaternionRotationScale(i,r,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,r=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(),n=t.speed||100;let l=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(n,.1);l+=g,c.push(this.Cesium.JulianDate.addSeconds(o,l,new this.Cesium.JulianDate))}i.addSample(c[u],s[u].position),r.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:r};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,r=this.viewer.camera.roll;return{destination:{x:t.x,y:t.y,z:t.z},orientation:{heading:e,pitch:i,roll:r}}}}class Sr{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 r=this.Cesium.Cartesian3.add(i,this.cameraOffset,new this.Cesium.Cartesian3);this.viewer.camera.setView({destination:r,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,r=this.buildTimes(e,i),s=new this.Cesium.SampledPositionProperty;for(let g=0;g<e.length;g++)s.addSample(r[g],e[g]);this.positionProperty=s;const o=new this.Cesium.VelocityOrientationProperty(s),n=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:o,path:n?{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[r,s,o]=i;e.push(this.Cesium.Cartesian3.fromDegrees(r,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=[],r=this.Cesium.JulianDate.now();let s=0;for(let o=0;o<t.length;o++)if(o===0)i.push(r.clone());else{const n=this.Cesium.Cartesian3.distance(t[o-1],t[o]);s+=n/Math.max(e,.1),i.push(this.Cesium.JulianDate.addSeconds(r,s,new this.Cesium.JulianDate))}return this.startTime=i[0],this.stopTime=i[i.length-1],i}}D.AreaMeasure=Ke,D.BufferedHierarchicalAggregator=se,D.CameraRoamTool=Dr,D.CircleMeasure=qe,D.CoordinateMeasure=Qe,D.DOM_EVENT_MAP=it,D.DrawTool=Wt,D.EditMode=zt,D.EntityLayerManager=Ir,D.GLTFManage=Cr,D.GLTFManageEventKey=Nt,D.HorizontalMeasure=Ye,D.HtmlOverlayLabelPool=G,D.MarkerEventBus=tt,D.MarkerEventKey=J,D.MaterialManager=Lr,D.MeasurementTool=_r,D.PathRoamTool=Sr,D.PolylineDistanceMeasure=Xe,D.PrimitiveManager=xr,D.RectangleMeasure=Ze,D.RegularPolygonMeasure=et,D.SpaceMeasure=Ue,D.TerrainHeightMeasure=Je,D.TooltipManager=xe,D.TriangleMeasure=We,D.VerticalMeasure=Ve,D.convertGeoJsonToEntityData=Tr,D.getDynamicImgMaterial=vr,D.getPolylineFlowMaterialProperty=Pr,D.getWallMaterial=br,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));
|
|
77
77
|
//# sourceMappingURL=cesium-core.umd.js.map
|