ino-cesium 0.0.1-5.beta.1

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.
@@ -0,0 +1 @@
1
+ import*as e from"cesium";export{e as Cesium};var t=Object.freeze({__proto__:null});let i=1;const n=(t,i)=>{i||(i={token:""}),i.token&&(e.Ion.defaultAccessToken=i.token);const n={...s,...i},o=new e.Viewer(t,n);return o.scene.postProcessStages.fxaa.enabled=!0,o.scene.msaaSamples=8,console.log("%c%s","color: GREEN; font-size: 20px",`Cesium ${e.VERSION}`),o},o=(e,t)=>{t.scene.globe.translucency.enabled=!0,t.scene.globe.translucency.frontFaceAlpha=e,t.scene.globe.translucency.backFaceAlpha=e},r=e=>{i=e},a=()=>i,s={animation:!1,baseLayerPicker:!1,fullscreenButton:!1,geocoder:!1,homeButton:!1,infoBox:!0,sceneModePicker:!1,selectionIndicator:!1,timeline:!1,navigationHelpButton:!1,scene3DOnly:!0,navigation:!1,navigationInstructionsInitiallyVisible:!1,showRenderLoopErrors:!0,orderIndependentTranslucency:!1,contextOptions:{webgl:{alpha:!0}}},l=t=>{const{lng:i,lat:n,height:o,viewer:r}=t;r.scene.camera.setView({destination:e.Cartesian3.fromDegrees(i,n,o||1e4)})},c=t=>{const{lng:i,lat:n,height:o,viewer:r}=t;r.scene.camera.flyTo({destination:e.Cartesian3.fromDegrees(i,n,o||1e4)})},d=e=>{const{position:t,viewer:i}=e;i.scene.camera.flyTo({destination:t})};function u(t){const i=t.camera.heading,n=t.camera.pitch,o=t.camera.roll;return{destination:new e.Cartesian3(t.camera.position.x,t.camera.position.y,t.camera.position.z),orientation:{heading:i,pitch:n,roll:o}}}function p(e,t){e&&t.scene.camera.flyTo({...e})}function h(e,t){const i=t.dataSources.getByName(e);i.length>0&&t.flyTo(i[0])}function m(e,t){e&&t.flyTo(e)}function f(e,t){t.flyTo(e)}function g(t,i){const n=new e.Cartesian3(t[0],t[1],t[2]),o=new e.BoundingSphere(n,t[3]);i.camera.flyToBoundingSphere(o,{offset:new e.HeadingPitchRange(3.5,-.5,200),duration:2})}function v(e){e.show=!1,setTimeout(()=>{e.show=!0,setTimeout(()=>{e.show=!1,setTimeout(()=>{e.show=!0},300)},300)},300)}const y=(t,i)=>{const n=t.scene,o=new e.ScreenSpaceEventHandler(n.canvas);o.setInputAction(e=>{if(i.LEFT_POSITION){const o=n.pickPosition(e.position);w(e.position,o,i.LEFT_POSITION,t)}i.PICK_FEATURE&&C(t,e.position,i.PICK_FEATURE),t._element.style.cursor="default"},e.ScreenSpaceEventType.LEFT_CLICK),o.setInputAction(e=>{if(i.MOVE_POSITION){const o=n.pickPosition(e.endPosition);w(e.endPosition,o,i.MOVE_POSITION,t)}i.MOVE_PICK_FEATURE&&C(t,e.endPosition,i.MOVE_PICK_FEATURE)},e.ScreenSpaceEventType.MOUSE_MOVE)},C=(t,i,n)=>{const o=t.scene.pick(i),r={};if(o){if(t._element.style.cursor="pointer",o instanceof e.Cesium3DTileFeature){o.getPropertyIds().forEach(e=>{r[e]=o.getProperty(e)})}else o.id instanceof e.Entity?t._element.style.cursor="pointer":o.primitive&&Object.assign(r,o.primitive.properties);n(o,r)}else n(void 0,r)},w=(t,i,n,o)=>{i||(i=e.Cartesian3.fromDegrees(0,0,0));const r=e.Cartographic.fromCartesian(i);n({windowPosition:t,position:i,lnglat:{lng:e.Math.toDegrees(r.longitude),lat:e.Math.toDegrees(r.latitude),height:r.height},cameraView:u(o)})},b=()=>`${Date.now()}${Math.round(9999999999*Math.random()+1)}`;let _="/ino-cesium";const x=e=>{_=e},P=()=>_;class M{static tooltip;_title;_div;_message;constructor(e){const t=document.createElement("DIV");t.id="tooltip",t.className="twipsy right";const i=document.createElement("DIV");i.className="twipsy-inner",t.appendChild(i),this._div=t,this._title=i,this._message="";const n=e._element.getElementsByClassName("cesium-widget")[0];if(!n)throw new Error("The cesium-widget element has not finished loading yet, so the popup cannot be created!");n.appendChild(t),t.onmousemove=e=>{this.showAt({x:e.clientX,y:e.clientY},this._message)}}showAt(e,t){e&&t&&(this.setVisible(!0),this._title.innerHTML=t,this._div.style.left=`${e.x+10}px`,this._div.style.top=e.y-this._div.clientHeight/2+"px",this._message=t)}setVisible(e){this._div.style.display=e?"block":"none"}static createToolTip(e){return M.tooltip||(M.tooltip=new M(e)),M.tooltip}destroy(){M.tooltip&&(this._div&&this._div.parentNode.removeChild(this._div),M.tooltip=null)}}class D{static popup;_div;viewer;offset=new e.Cartesian2(140,150);position=e.Cartesian3.ZERO;constructor(e,t,i){this.viewer=e,i&&(this.offset=i),this._div=t,this._div.style.position="absolute",this._div.style.left="0",this._div.style.top="0",this._div.style.display="none";const n=e._element.getElementsByClassName("cesium-widget")[0];if(!n)throw new Error("The cesium-widget element has not finished loading yet, so the popup cannot be created!");n.appendChild(t),this.renderPosition()}showAt(e){this.position=e,e&&this.setVisible(!0)}setVisible(e){this._div.style.display=e?"block":"none"}renderPosition(){this.viewer.scene.postRender.addEventListener(()=>{if(!this.position.equals(e.Cartesian3.ZERO)){const e=this.viewer.scene.cartesianToCanvasCoordinates(this.position);this._div.style.left=e.x-this.offset.x+"px",this._div.style.top=e.y-this.offset.y+"px"}})}static createPupup(e,t,i){return D.popup||(D.popup=new D(e,t,i)),D.popup}destroy(){D.popup&&(this._div&&this._div.parentNode.removeChild(this._div),D.popup=null)}}const E=(e,t=[-180,180],i=[-90,90])=>{const n=[];for(let o=0;o<e;o++){const e=A(t),o=A(i);n.push({type:"Feature",geometry:{type:"Point",coordinates:[e,o]},properties:{}})}return{type:"FeatureCollection",features:n}};function A(e){const[t,i]=e;return Math.random()*(i-t)+t}function S(){return`rgba(${Math.round(255*Math.random())},${Math.round(255*Math.random())},${Math.round(255*Math.random())},${Math.random()})`}const I=(e,t=[-180,180],i=[-90,90])=>{const n=[];for(let o=0;o<e;o++){const e=Math.floor(A([3,10])),o=[];for(let n=0;n<e;n++){const e=A(t),n=A(i);o.push([e,n])}n.push({type:"Feature",geometry:{type:"LineString",coordinates:o},properties:{}})}return{type:"FeatureCollection",features:n}},T=(e,t=[-180,180],i=[-90,90])=>{const n=[];for(let o=0;o<e;o++){const e=z(t,i);n.push({type:"Feature",geometry:{type:"Polygon",coordinates:[e]}})}return{type:"FeatureCollection",features:n}};function z(e,t){const i=Math.floor(A([3,10])),n=A(e),o=A(t),r=A([1,5]),a=[];for(let e=0;e<i;e++){const t=e/i*2*Math.PI,s=A([.8*r,r]),l=n+s*Math.cos(t),c=o+s*Math.sin(t);a.push([l,c])}return a.push(a[0]),a}const R=(t,i)=>{let n=!1;const o=new e.Viewer(t,{...s,scene3DOnly:!1});o.scene.mode=2;const r=o.scene.screenSpaceCameraController;r.enableRotate=!1,r.enableTranslate=!1,r.enableZoom=!1,r.enableTilt=!1,r.enableLook=!1,i.entities.add({position:e.Cartesian3.fromDegrees(0,0),label:{text:new e.CallbackProperty(()=>(a(),""),!0)}});const a=function(){n||o.camera.flyTo({destination:i.camera.position,orientation:{heading:i.camera.heading,pitch:i.camera.pitch,roll:i.camera.roll},duration:0})};return{viewer:o,open:()=>{n=!1},close:()=>{n=!0}}};var O=6371008.8,F={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*O,kilometers:6371.0088,kilometres:6371.0088,meters:O,metres:O,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:O/1852,radians:1,yards:6967335.223679999};function L(e,t,i={}){const n={type:"Feature"};return(0===i.id||i.id)&&(n.id=i.id),i.bbox&&(n.bbox=i.bbox),n.properties=t||{},n.geometry=e,n}function B(e,t,i={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!U(e[0])||!U(e[1]))throw new Error("coordinates must contain numbers");return L({type:"Point",coordinates:e},t,i)}function k(e,t,i={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return L({type:"Polygon",coordinates:e},t,i)}function N(e,t={}){const i={type:"FeatureCollection"};return t.id&&(i.id=t.id),t.bbox&&(i.bbox=t.bbox),i.features=e,i}function G(e){return e%360*Math.PI/180}function U(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function V(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function $(e){return"Feature"===e.type?e.geometry:e}function W(e,t,i={}){var n=V(e),o=V(t),r=G(o[1]-n[1]),a=G(o[0]-n[0]),s=G(n[1]),l=G(o[1]),c=Math.pow(Math.sin(r/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(l);return function(e,t="kilometers"){const i=F[t];if(!i)throw new Error(t+" units is invalid");return e*i}(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),i.units)}function H(e,t,i){if(null!==e)for(var n,o,r,a,s,l,c,d,u=0,p=0,h=e.type,m="FeatureCollection"===h,f="Feature"===h,g=m?e.features.length:1,v=0;v<g;v++){s=(d=!!(c=m?e.features[v].geometry:f?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var y=0;y<s;y++){var C=0,w=0;if(null!==(a=d?c.geometries[y]:c)){l=a.coordinates;var b=a.type;switch(u=!i||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===t(l,p,v,C,w))return!1;p++,C++;break;case"LineString":case"MultiPoint":for(n=0;n<l.length;n++){if(!1===t(l[n],p,v,C,w))return!1;p++,"MultiPoint"===b&&C++}"LineString"===b&&C++;break;case"Polygon":case"MultiLineString":for(n=0;n<l.length;n++){for(o=0;o<l[n].length-u;o++){if(!1===t(l[n][o],p,v,C,w))return!1;p++}"MultiLineString"===b&&C++,"Polygon"===b&&w++}"Polygon"===b&&C++;break;case"MultiPolygon":for(n=0;n<l.length;n++){for(w=0,o=0;o<l[n].length;o++){for(r=0;r<l[n][o].length-u;r++){if(!1===t(l[n][o][r],p,v,C,w))return!1;p++}w++}C++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===H(a.geometries[n],t,i))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function q(e,t){var i,n,o,r,a,s,l,c,d,u,p=0,h="FeatureCollection"===e.type,m="Feature"===e.type,f=h?e.features.length:1;for(i=0;i<f;i++){for(s=h?e.features[i].geometry:m?e.geometry:e,c=h?e.features[i].properties:m?e.properties:{},d=h?e.features[i].bbox:m?e.bbox:void 0,u=h?e.features[i].id:m?e.id:void 0,a=(l=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(r=l?s.geometries[o]:s))switch(r.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(r,p,c,d,u))return!1;break;case"GeometryCollection":for(n=0;n<r.geometries.length;n++)if(!1===t(r.geometries[n],p,c,d,u))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,d,u))return!1;p++}}function j(e){return function(e,t,i){var n=i;return q(e,function(e,o,r,a,s){n=0===o&&void 0===i?e:t(n,e,o,r,a,s)}),n}(e,(e,t)=>e+function(e){let t,i=0;switch(e.type){case"Polygon":return Z(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)i+=Z(e.coordinates[t]);return i;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(t),0)}function Z(e){let t=0;if(e&&e.length>0){t+=Math.abs(X(e[0]));for(let i=1;i<e.length;i++)t-=Math.abs(X(e[i]))}return t}var Y=20294876564838.72,K=Math.PI/180;function X(e){const t=e.length-1;if(t<=2)return 0;let i=0,n=0;for(;n<t;){const o=e[n],r=e[n+1===t?0:n+1],a=e[n+2>=t?(n+2)%t:n+2],s=o[0]*K,l=r[1]*K;i+=(a[0]*K-s)*Math.sin(l),n++}return i*Y}function J(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const i=[1/0,1/0,-1/0,-1/0];return H(e,e=>{i[0]>e[0]&&(i[0]=e[0]),i[1]>e[1]&&(i[1]=e[1]),i[2]<e[0]&&(i[2]=e[0]),i[3]<e[1]&&(i[3]=e[1])}),i}const Q=11102230246251565e-32,ee=134217729,te=(3+8*Q)*Q;function ie(e,t,i,n,o){let r,a,s,l,c=t[0],d=n[0],u=0,p=0;d>c==d>-c?(r=c,c=t[++u]):(r=d,d=n[++p]);let h=0;if(u<e&&p<i)for(d>c==d>-c?(a=c+r,s=r-(a-c),c=t[++u]):(a=d+r,s=r-(a-d),d=n[++p]),r=a,0!==s&&(o[h++]=s);u<e&&p<i;)d>c==d>-c?(a=r+c,l=a-r,s=r-(a-l)+(c-l),c=t[++u]):(a=r+d,l=a-r,s=r-(a-l)+(d-l),d=n[++p]),r=a,0!==s&&(o[h++]=s);for(;u<e;)a=r+c,l=a-r,s=r-(a-l)+(c-l),c=t[++u],r=a,0!==s&&(o[h++]=s);for(;p<i;)a=r+d,l=a-r,s=r-(a-l)+(d-l),d=n[++p],r=a,0!==s&&(o[h++]=s);return 0===r&&0!==h||(o[h++]=r),h}function ne(e){return new Float64Array(e)}const oe=ne(4),re=ne(8),ae=ne(12),se=ne(16),le=ne(4);function ce(e,t,i,n,o,r){const a=(t-r)*(i-o),s=(e-o)*(n-r),l=a-s,c=Math.abs(a+s);return Math.abs(l)>=33306690738754716e-32*c?l:-function(e,t,i,n,o,r,a){let s,l,c,d,u,p,h,m,f,g,v,y,C,w,b,_,x,P;const M=e-o,D=i-o,E=t-r,A=n-r;w=M*A,p=ee*M,h=p-(p-M),m=M-h,p=ee*A,f=p-(p-A),g=A-f,b=m*g-(w-h*f-m*f-h*g),_=E*D,p=ee*E,h=p-(p-E),m=E-h,p=ee*D,f=p-(p-D),g=D-f,x=m*g-(_-h*f-m*f-h*g),v=b-x,u=b-v,oe[0]=b-(v+u)+(u-x),y=w+v,u=y-w,C=w-(y-u)+(v-u),v=C-_,u=C-v,oe[1]=C-(v+u)+(u-_),P=y+v,u=P-y,oe[2]=y-(P-u)+(v-u),oe[3]=P;let S=function(e,t){let i=t[0];for(let n=1;n<e;n++)i+=t[n];return i}(4,oe),I=22204460492503146e-32*a;if(S>=I||-S>=I)return S;if(u=e-M,s=e-(M+u)+(u-o),u=i-D,c=i-(D+u)+(u-o),u=t-E,l=t-(E+u)+(u-r),u=n-A,d=n-(A+u)+(u-r),0===s&&0===l&&0===c&&0===d)return S;if(I=11093356479670487e-47*a+te*Math.abs(S),S+=M*d+A*s-(E*c+D*l),S>=I||-S>=I)return S;w=s*A,p=ee*s,h=p-(p-s),m=s-h,p=ee*A,f=p-(p-A),g=A-f,b=m*g-(w-h*f-m*f-h*g),_=l*D,p=ee*l,h=p-(p-l),m=l-h,p=ee*D,f=p-(p-D),g=D-f,x=m*g-(_-h*f-m*f-h*g),v=b-x,u=b-v,le[0]=b-(v+u)+(u-x),y=w+v,u=y-w,C=w-(y-u)+(v-u),v=C-_,u=C-v,le[1]=C-(v+u)+(u-_),P=y+v,u=P-y,le[2]=y-(P-u)+(v-u),le[3]=P;const T=ie(4,oe,4,le,re);w=M*d,p=ee*M,h=p-(p-M),m=M-h,p=ee*d,f=p-(p-d),g=d-f,b=m*g-(w-h*f-m*f-h*g),_=E*c,p=ee*E,h=p-(p-E),m=E-h,p=ee*c,f=p-(p-c),g=c-f,x=m*g-(_-h*f-m*f-h*g),v=b-x,u=b-v,le[0]=b-(v+u)+(u-x),y=w+v,u=y-w,C=w-(y-u)+(v-u),v=C-_,u=C-v,le[1]=C-(v+u)+(u-_),P=y+v,u=P-y,le[2]=y-(P-u)+(v-u),le[3]=P;const z=ie(T,re,4,le,ae);w=s*d,p=ee*s,h=p-(p-s),m=s-h,p=ee*d,f=p-(p-d),g=d-f,b=m*g-(w-h*f-m*f-h*g),_=l*c,p=ee*l,h=p-(p-l),m=l-h,p=ee*c,f=p-(p-c),g=c-f,x=m*g-(_-h*f-m*f-h*g),v=b-x,u=b-v,le[0]=b-(v+u)+(u-x),y=w+v,u=y-w,C=w-(y-u)+(v-u),v=C-_,u=C-v,le[1]=C-(v+u)+(u-_),P=y+v,u=P-y,le[2]=y-(P-u)+(v-u),le[3]=P;const R=ie(z,ae,4,le,se);return se[R-1]}(e,t,i,n,o,r,c)}function de(e,t){var i,n,o,r,a,s,l,c,d,u=0,p=e[0],h=e[1],m=t.length;for(i=0;i<m;i++){n=0;var f=t[i],g=f.length-1;if((c=f[0])[0]!==f[g][0]&&c[1]!==f[g][1])throw new Error("First and last coordinates in a ring must be the same");for(r=c[0]-p,a=c[1]-h;n<g;n++){if(s=(d=f[n+1])[0]-p,l=d[1]-h,0===a&&0===l){if(s<=0&&r>=0||r<=0&&s>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(0===(o=ce(r,s,a,l,0,0)))return 0;(o>0&&l>0&&a<=0||o<0&&l<=0&&a>0)&&u++}c=d,a=l,r=s}}return u%2!=0}function ue(e,t,i={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=V(e),o=$(t),r=o.type,a=t.bbox;let s=o.coordinates;if(a&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(n,a))return!1;"Polygon"===r&&(s=[s]);let l=!1;for(var c=0;c<s.length;++c){const e=de(n,s[c]);if(0===e)return!i.ignoreBoundary;e&&(l=!0)}return l}function pe(e,t,i={}){const n=V(e),o=function(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}(t);for(let e=0;e<o.length-1;e++){let t=!1;if(i.ignoreEndVertices&&(0===e&&(t="start"),e===o.length-2&&(t="end"),0===e&&e+1===o.length-1&&(t="both")),he(o[e],o[e+1],n,t,void 0===i.epsilon?null:i.epsilon))return!0}return!1}function he(e,t,i,n,o){const r=i[0],a=i[1],s=e[0],l=e[1],c=t[0],d=t[1],u=c-s,p=d-l,h=(i[0]-s)*p-(i[1]-l)*u;if(null!==o){if(Math.abs(h)>o)return!1}else if(0!==h)return!1;return Math.abs(u)===Math.abs(p)&&0===Math.abs(u)?!n&&(i[0]===e[0]&&i[1]===e[1]):n?"start"===n?Math.abs(u)>=Math.abs(p)?u>0?s<r&&r<=c:c<=r&&r<s:p>0?l<a&&a<=d:d<=a&&a<l:"end"===n?Math.abs(u)>=Math.abs(p)?u>0?s<=r&&r<c:c<r&&r<=s:p>0?l<=a&&a<d:d<a&&a<=l:"both"===n&&(Math.abs(u)>=Math.abs(p)?u>0?s<r&&r<c:c<r&&r<s:p>0?l<a&&a<d:d<a&&a<l):Math.abs(u)>=Math.abs(p)?u>0?s<=r&&r<=c:c<=r&&r<=s:p>0?l<=a&&a<=d:d<=a&&a<=l}function me(e,t){var i=$(e),n=$(t),o=i.type,r=n.type;switch(o){case"Point":switch(r){case"MultiPoint":return function(e,t){var i,n=!1;for(i=0;i<t.coordinates.length;i++)if(ge(t.coordinates[i],e.coordinates)){n=!0;break}return n}(i,n);case"LineString":return pe(i,n,{ignoreEndVertices:!0});case"Polygon":case"MultiPolygon":return ue(i,n,{ignoreBoundary:!0});default:throw new Error("feature2 "+r+" geometry not supported")}case"MultiPoint":switch(r){case"MultiPoint":return function(e,t){for(var i=0;i<e.coordinates.length;i++){for(var n=!1,o=0;o<t.coordinates.length;o++)ge(e.coordinates[i],t.coordinates[o])&&(n=!0);if(!n)return!1}return!0}(i,n);case"LineString":return function(e,t){for(var i=!1,n=0;n<e.coordinates.length;n++){if(!pe(e.coordinates[n],t))return!1;i||(i=pe(e.coordinates[n],t,{ignoreEndVertices:!0}))}return i}(i,n);case"Polygon":case"MultiPolygon":return function(e,t){for(var i=!0,n=!1,o=0;o<e.coordinates.length;o++){if(!(n=ue(e.coordinates[o],t))){i=!1;break}n=ue(e.coordinates[o],t,{ignoreBoundary:!0})}return i&&n}(i,n);default:throw new Error("feature2 "+r+" geometry not supported")}case"LineString":switch(r){case"LineString":return function(e,t){for(var i=0;i<e.coordinates.length;i++)if(!pe(e.coordinates[i],t))return!1;return!0}(i,n);case"Polygon":case"MultiPolygon":return function(e,t){var i=J(t),n=J(e);if(!fe(i,n))return!1;for(var o=!1,r=0;r<e.coordinates.length;r++){if(!ue(e.coordinates[r],t))return!1;if(o||(o=ue(e.coordinates[r],t,{ignoreBoundary:!0})),!o&&r<e.coordinates.length-1)o=ue(ve(e.coordinates[r],e.coordinates[r+1]),t,{ignoreBoundary:!0})}return o}(i,n);default:throw new Error("feature2 "+r+" geometry not supported")}case"Polygon":switch(r){case"Polygon":case"MultiPolygon":return function(e,t){var i=J(e);if(!fe(J(t),i))return!1;for(var n=0;n<e.coordinates[0].length;n++)if(!ue(e.coordinates[0][n],t))return!1;return!0}(i,n);default:throw new Error("feature2 "+r+" geometry not supported")}default:throw new Error("feature1 "+o+" geometry not supported")}}function fe(e,t){return!(e[0]>t[0])&&(!(e[2]<t[2])&&(!(e[1]>t[1])&&!(e[3]<t[3])))}function ge(e,t){return e[0]===t[0]&&e[1]===t[1]}function ve(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function ye(e,t={}){let i=0,n=0,o=0;return H(e,function(e){i+=e[0],n+=e[1],o++},!0),B([i/o,n/o],t.properties)}function Ce(e){return function(e,t={}){const i=Number(e[0]),n=Number(e[1]),o=Number(e[2]),r=Number(e[3]);if(6===e.length)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");const a=[i,n];return k([[a,[o,n],[o,r],[i,r],a]],t.properties,{bbox:e,id:t.id})}(J(e))}function we(e,t){const i=[];return function(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var i=0;i<e.features.length&&!1!==t(e.features[i],i);i++);}(e,function(e){let n=!1;if("Point"===e.geometry.type)q(t,function(t){ue(e,t)&&(n=!0)}),n&&i.push(e);else{if("MultiPoint"!==e.geometry.type)throw new Error("Input geometry must be a Point or MultiPoint");var o=[];q(t,function(t){H(e,function(e){ue(e,t)&&(n=!0,o.push(e))})}),n&&i.push(function(e,t,i={}){return L({type:"MultiPoint",coordinates:e},t,i)}(o,e.properties))}}),N(i)}const be=(t,i)=>{const n=e.Cartographic.fromCartesian(t),o=e.Cartographic.fromCartesian(i),r=new e.EllipsoidGeodesic;r.setEndPoints(n,o);let a=r.surfaceDistance;return a=Math.sqrt(a**2+(o.height-n.height)**2),a};function _e(e){let t=0;return e.forEach((i,n)=>{if(n===e.length-1)return;const o=be(i,e[n+1]);t+=o}),t}function xe(t,i,n){const{EllipsoidGeodesic:o,Ellipsoid:r}=e;return new o((n=n||r.WGS84).cartesianToCartographic(t),n.cartesianToCartographic(i)).surfaceDistance}function Pe(e){let t=0;return e.forEach((i,n)=>{if(n===e.length-1)return;const o=xe(i,e[n+1]);t+=o}),t}const Me=t=>{if(t.length<4)return e.BoundingSphere.fromPoints(t).center;const i=k([t.map(e=>[e.x,e.y])]),n=e.BoundingSphere.fromPoints(t).center,o=ye(i);return new e.Cartesian3(o.geometry.coordinates[0],o.geometry.coordinates[1],n.z)};function De(t){let i=0;const{CoplanarPolygonGeometry:n,VertexFormat:o,defined:r,Cartesian3:a}=e,s=n.createGeometry(n.fromPositions({positions:t,vertexFormat:o.POSITION_ONLY}));if(r(s)){const e=s.indices,t=s.attributes.position.values;for(let n=0;n<e.length;n+=3){const o=e[n],r=e[n+1],s=e[n+2];i+=Ee(a.unpack(t,3*o,{}),a.unpack(t,3*r,{}),a.unpack(t,3*s,{}))}}return i}const Ee=(t,i,n)=>{const{Cartesian3:o}=e,r=o.subtract(t,i,{}),a=o.subtract(n,i,{}),s=o.cross(r,a,r);return.5*o.magnitude(s)},Ae=async(t,i)=>{const n=i.map(t=>e.Cartographic.fromCartesian(t));return await e.sampleTerrainMostDetailed(t,n)},Se=async(e,t)=>await e.scene.clampToHeightMostDetailed(t),Ie=(t,i,n,o)=>{const r=[],a=e.Cartographic.fromCartesian(t),s=e.Cartographic.fromCartesian(i),l=180*a.longitude/Math.PI,c=180*a.latitude/Math.PI,d=180*s.longitude/Math.PI,u=180*s.latitude/Math.PI,p=Math.sqrt((l-d)*(l-d)+(c-u)*(c-u))*n,h=e.Cartesian3.clone(t),m=e.Cartesian3.clone(i),f=e.Cartesian3.distance(h,e.Cartesian3.ZERO),g=e.Cartesian3.distance(m,e.Cartesian3.ZERO);if(e.Cartesian3.normalize(h,h),e.Cartesian3.normalize(m,m),!e.Cartesian3.distance(h,m))return r;const v=e.Cartesian3.angleBetween(h,m);r.push(t);for(let t=1;t<o-1;t++){const i=1*t/(o-1),n=1-i,a=Math.sin(n*v)/Math.sin(v),s=Math.sin(i*v)/Math.sin(v),l=e.Cartesian3.multiplyByScalar(h,a,new e.Cartesian3),c=e.Cartesian3.multiplyByScalar(m,s,new e.Cartesian3);let d=e.Cartesian3.add(l,c,new e.Cartesian3);const u=i*Math.PI,y=f*n+g*i+Math.sin(u)*p;d=e.Cartesian3.multiplyByScalar(d,y,d),r.push(d)}return r.push(i),r},Te=e=>{const t=e.positionCartographic.height,i=-40467.74;return Math.round(i+80955.31/(1+(t/91610.74)**7096758e-11))},ze=e=>e,Re=(t,i)=>{const n=[];let o=0,r=0,a=0;const s=[];for(let i=0;i<t.length-1;++i)o+=e.Cartesian3.distance(t[i],t[i+1]);for(let i=0;i<t.length;i++)0===i?r=0:(a+=e.Cartesian3.distance(t[i-1],t[i]),r=a/o),n.push(r);const l=new e.LinearSpline({times:n,points:t});for(let e=0;e<=i;e++){const t=l.evaluate(e/i);s.push(t)}return s};class Oe{_primitive;_promise;appearance;geometryInstance;drawCommand;needUpdate=!1;constructor(){this._primitive=void 0,this.appearance=void 0,this.geometryInstance=void 0,this._promise=null,this.drawCommand=null,this.needUpdate=!1}update(e){const t=this.getPrimitive();if(t){this._primitive=t;this._primitive.update(e)}}then(e=null){return this._promise?.then(e)}catch(e=null){return this._promise?.catch(e)}isDestroyed(){return!!this._primitive}destroy(){this._primitive=void 0}}class Fe{_definitionChanged=new e.Event;get definitionChanged(){return this._definitionChanged}get isConstant(){return!1}}const Le=t=>{let i=0;for(let n=0;n<t.length;n++){const o=t[n],r=t[(n+1)%t.length];i+=e.Cartesian3.cross(o,r,new e.Cartesian3).z}return i>0?t.reverse():t},Be=t=>{let i=0;for(let n=0;n<t.length;n++){const o=t[n],r=t[(n+1)%t.length];i+=e.Cartesian3.cross(o,r,new e.Cartesian3).z}return i<0?t.reverse():t},ke=e=>e.map(e=>Ne(e)),Ne=t=>{const i=e.Cartographic.fromCartesian(t);return{longitude:e.Math.toDegrees(i.longitude),latitude:e.Math.toDegrees(i.latitude),height:i.height}},Ge=t=>t.map(t=>e.Cartesian3.fromDegrees(t.longitude,t.latitude,t.height)),Ue=t=>e.Cartesian3.fromDegrees(t.longitude,t.latitude,t.height),Ve=e=>{const t=e[0],i=e[e.length-1];return t.x===i.x&&t.y===i.y&&t.z===i.z?e:[...e,e[0]]},$e=e=>{const t=[];return e.forEach(e=>{t.push({type:"Feature",geometry:{type:"Point",coordinates:[e.longitude,e.latitude]},properties:{height:e.height}})}),{type:"FeatureCollection",features:t}},We=e=>{const t=[];return e.forEach((i,n)=>{0!==n&&t.push({type:"Feature",geometry:{type:"LineString",coordinates:[[e[n-1].longitude,e[n-1].latitude],[i.longitude,i.latitude]]},properties:{height:i.height}})}),{type:"FeatureCollection",features:t}},He=e=>{const t=[];return t.push({type:"Feature",geometry:{type:"Polygon",coordinates:[e.map(e=>[e.longitude,e.latitude])]},properties:{heights:e.map(e=>e.height)}}),{type:"FeatureCollection",features:t}},qe=t=>({heading:e.Math.toRadians(t.yaw+(t.offsetYaw||0)),pitch:e.Math.toRadians(t.pitch),roll:e.Math.toRadians(t.roll)}),je=e.BoxGeometry,Ze=e.Cartesian3,Ye=e.defaultValue,Ke=e.defined,Xe=e.destroyObject,Je=e.DeveloperError,Qe=e.GeometryPipeline,et=e.Matrix3,tt=e.Matrix4,it=e.Transforms,nt=e.VertexFormat,ot=e.BufferUsage,rt=e.CubeMap,at=e.DrawCommand,st=e.loadCubeMap,lt=e.RenderState,ct=e.VertexArray,dt=e.BlendingState,ut=e.SceneMode,pt=e.ShaderProgram,ht=e.ShaderSource,mt=new et;class ft{constructor(t){e.defined(e.Matrix4.getRotation)||(e.Matrix4.getRotation=e.Matrix4.getMatrix3),this.sources=t.sources,this._sources=void 0,this.show=Ye(t.show,!0),this._command=new at({modelMatrix:tt.clone(tt.IDENTITY),owner:this}),this._cubeMap=void 0,this._attributeLocations=void 0,this._useHdr=void 0}update(e,t){const i=this;if(!this.show)return;if(e.mode!==ut.SCENE3D&&e.mode!==ut.MORPHING)return;if(!e.passes.render)return;const n=e.context;if(this._sources!==this.sources){this._sources=this.sources;const e=this.sources;if(!(Ke(e.positiveX)&&Ke(e.negativeX)&&Ke(e.positiveY)&&Ke(e.negativeY)&&Ke(e.positiveZ)&&Ke(e.negativeZ)))throw new Je("this.sources is required and must have positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ properties.");if(typeof e.positiveX!=typeof e.negativeX||typeof e.positiveX!=typeof e.positiveY||typeof e.positiveX!=typeof e.negativeY||typeof e.positiveX!=typeof e.positiveZ||typeof e.positiveX!=typeof e.negativeZ)throw new Je("this.sources properties must all be the same type.");"string"==typeof e.positiveX?st(n,this._sources).then(e=>{i._cubeMap=i._cubeMap&&i._cubeMap.destroy(),i._cubeMap=e}):(this._cubeMap=this._cubeMap&&this._cubeMap.destroy(),this._cubeMap=new rt({context:n,source:e}))}const o=this._command;if(o.modelMatrix=it.eastNorthUpToFixedFrame(e.camera._positionWC),!Ke(o.vertexArray)){o.uniformMap={u_cubeMap:()=>i._cubeMap,u_rotateMatrix:()=>tt.getRotation(o.modelMatrix,mt)};const e=je.createGeometry(je.fromDimensions({dimensions:new Ze(2,2,2),vertexFormat:nt.POSITION_ONLY})),t=this._attributeLocations=Qe.createAttributeLocations(e);o.vertexArray=ct.fromGeometry({context:n,geometry:e,attributeLocations:t,bufferUsage:ot._DRAW}),o.renderState=lt.fromCache({blending:dt.ALPHA_BLEND})}if(!Ke(o.shaderProgram)||this._useHdr!==t){const e=new ht({defines:[t?"HDR":""],sources:["precision highp float;\n\nuniform samplerCube u_cubeMap;\nin vec3 v_texCoord;\nout vec4 fragColor;\n\nvoid main() {\n vec4 color = texture(u_cubeMap, normalize(v_texCoord));\n fragColor = vec4(czm_gammaCorrect(color).rgb, czm_morphTime);\n}"]});o.shaderProgram=pt.fromCache({context:n,vertexShaderSource:"#version 300 es\n\nprecision highp float;\n\nin vec3 position;\nout vec3 v_texCoord;\n\nuniform mat3 u_rotateMatrix;\n\nvoid main() {\n vec3 p = czm_viewRotation * u_rotateMatrix * (czm_temeToPseudoFixed * (czm_entireFrustum.y * position));\n gl_Position = czm_projection * vec4(p, 1.0);\n v_texCoord = position;\n}\n",fragmentShaderSource:e,attributeLocations:this._attributeLocations}),this._useHdr=t}return Ke(this._cubeMap)?o:void 0}isDestroyed(){return!1}destroy(){const e=this._command;return e.vertexArray=e.vertexArray&&e.vertexArray.destroy(),e.shaderProgram=e.shaderProgram&&e.shaderProgram.destroy(),this._cubeMap=this._cubeMap&&this._cubeMap.destroy(),Xe(this)}}const gt=t=>{const{viewer:i,sources:n}=t;return i.scene.skyBox=new e.SkyBox({sources:n}),i.scene.skyBox},vt=t=>{let{viewer:i,sources:n}=t;const o=t.height?t.height:225705,r=i.scene.skyBox;n||(n={positiveX:`${P()}/assets/ground-skybox/px.jpg`,negativeX:`${P()}/assets/ground-skybox/nx.jpg`,positiveY:`${P()}/assets/ground-skybox/py.jpg`,negativeY:`${P()}/assets/ground-skybox/ny.jpg`,positiveZ:`${P()}/assets/ground-skybox/pz.jpg`,negativeZ:`${P()}/assets/ground-skybox/nz.jpg`});const a=new ft({sources:n});i.scene.postRender.addEventListener(()=>{const t=i.camera.position;e.Cartographic.fromCartesian(t).height<o?(i.scene.skyBox=a,i.scene.skyAtmosphere.show=!1):(i.scene.skyBox=r,i.scene.skyAtmosphere.show=!0)})},yt=t=>{const i=[];let n,o;t.clock.shouldAnimate=!0;const r={},a=(e,i)=>{if(s(),e.entity.cylinder){const i=e.entity.cylinder;i.roamId=e.id,e.entity.cylinder=void 0,o=t.entities.add({position:e.property,cylinder:i})}t.trackedEntity=e.entity,i&&(n=e)},s=()=>{if(o){t.entities.remove(o);const e=i.find(e=>e.id===o.cylinder.roamId);e&&(e.entity.cylinder=o.cylinder),o=void 0}},l=()=>{t.trackedEntity=void 0,n=void 0,s()},c=e=>{t.trackedEntity?.id===e.entity.id&&l(),t.entities.remove(e.entity);const n=i.findIndex(t=>t.id===e.id);n>-1&&i.splice(n,1)},d=(e,t)=>{const i=e.property.getValue(t);if(i&&(e.status="ROAMING",m.roaming&&m.roaming(e,{time:t,position:i})),e.stopTime.secondsOfDay<t.secondsOfDay&&"END"!==e.status&&(e.status="END",m.end&&m.end(e),e.loop?u(e):l()),e.flyParams.hpr){const n=r[e.id].find(e=>e.time>t.secondsOfDay);n&&h(e,n,i)}},u=i=>{const{property:n,startTime:o,stopTime:r}=p(i);i.stopTime=r,i.startTime=o,i.property=n,i.flyParams.hpr||(i.entity.orientation=new e.VelocityOrientationProperty(n)),i.entity.position=n,i.status="START",t.clock.currentTime=o,t.clock.multiplier=1,m.reStart&&m.reStart(i)},p=t=>{const i=[],{positions:n,flyParams:o}=t,a=new e.SampledPositionProperty;let s=0;const l=e.JulianDate.now();let c=l.clone();return n.forEach((t,r)=>{let d=e.JulianDate.now();if(r){let i=0;if(o.speed){i=e.Cartesian3.distance(t,n[r-1])/(1e3*o.speed/3600)}o.times&&(i=(o.times[r]-o.times[r-1])/1e3),s+=i,d=e.JulianDate.addSeconds(l,s,new e.JulianDate)}else d=l;c=d,a.addSample(d,t),o.hpr&&i.push({time:d.secondsOfDay,heading:o.hpr[r].heading,pitch:o.hpr[r].pitch,roll:o.hpr[r].roll})}),r[t.id]=i,{property:a,startTime:l,stopTime:c}},h=(t,i,n)=>{if(!n)return;const{heading:o,pitch:r,roll:a}=i,s=new e.HeadingPitchRoll(o,r,a);t.entity.orientation=Transforms.headingPitchRollQuaternion(n,s)};t.scene.preRender.addEventListener((o,r)=>{if(i.forEach(e=>{d(e,r)}),!n)return;const a=n.entity.computeModelMatrix(t.clock.currentTime);a&&t.camera.lookAtTransform(a,new e.Cartesian3(...[-20,0,5]))});const m={};return{set:n=>{const{entity:o}=n;n.id=b(),t.entities.add(o);const{property:r,startTime:a,stopTime:s}=p(n);n.flyParams.hpr||(o.orientation=new e.VelocityOrientationProperty(r)),o.position=r;const l={...n,startTime:a,stopTime:s,property:r,status:"START"};return t.clock.currentTime=a,t.clock.multiplier=1,i.push(l),l.status="START",m.start&&m.start(l),l},tracked:a,stopTracked:l,remove:c,frameRoam:d,trackedByEntityId:(e,t)=>{const n=i.find(t=>t.entity.id===e);n&&a(n,t)},removeAll:()=>{i.forEach(e=>{c(e)}),i.length=0},Event:m,lockCameraView:e=>{n=e},updateRoamAttitude:(t,i)=>{"UP"!==i&&"DOWN"!==i||(t.entity.orientation=void 0),"front"!==i&&"back"!==i||(t.entity.orientation=new e.VelocityOrientationProperty(t.property))}}};var Ct=(e=>(e.UP="UP",e.DOWN="DOWN",e.LEFT="left",e.RIGHT="right",e.FRONT="front",e.BACK="back",e))(Ct||{}),wt=(e=>(e.END="END",e.START="START",e.ROAMING="ROAMING",e))(wt||{});let bt=100,_t="",xt="0";const Pt=t=>{const{viewer:i}=t,n=document.createElement("div");n.className="bottom-status-bar";const o=document.createElement("div");o.className="scale-bar",o.innerHTML="";const r=document.createElement("div");r.className="scale-label",r.innerHTML="",o.appendChild(r),n.appendChild(o);const a=document.createElement("div");a.id="bottom-status-bar-camera",t.clickCopy&&(a.style.pointerEvents="auto",a.style.cursor="pointer"),n.appendChild(a),a.style.display="flex";const s=document.createElement("div"),l=document.createElement("div"),c=i._element.getElementsByClassName("cesium-widget")[0];if(!c)throw new Error("The cesium-widget element has not finished loading yet, so the popup cannot be created!");c.appendChild(n),y(i,{MOVE_POSITION(e){a.innerHTML=`\n 经度:${e.lnglat.lng.toFixed(6)}&nbsp;&nbsp;\n 纬度:${e.lnglat.lat.toFixed(6)}&nbsp;&nbsp;\n 高程:${e.lnglat.height.toFixed(2)}&nbsp;&nbsp;\n `,t.clickCopy&&u(i),a.appendChild(l),a.appendChild(s)}}),t.clickCopy&&document.addEventListener("click",e=>{e.target.id});let d=Date.now(),p=0;const h=()=>{requestAnimationFrame(()=>{if(p+=1,p>=30){const e=Date.now(),t=e-d,i=Math.round(1e3/(t/p));d=e,p=0,s.innerHTML=`${i} FPS`}t.hpr?l.innerHTML=`\n 方位角:${e.Math.toDegrees(i.camera.heading).toFixed(1)}°&nbsp;&nbsp;\n 俯仰角:${e.Math.toDegrees(i.camera.pitch).toFixed(1)}°&nbsp;&nbsp;\n 翻滚角:${e.Math.toDegrees(i.camera.roll).toFixed(1)}°&nbsp;&nbsp;\n `:l.innerHTML="",l.innerHTML+=`\n 视高:${i.camera.positionCartographic.height.toFixed(0)}m&nbsp;&nbsp;\n `;const n=Mt(i);r.innerHTML=`${n.distanceLabel}`,h()})};h()},Mt=t=>{const i=t.camera.positionCartographic.height.toFixed(0);if(i===xt)return{barWidth:bt,distanceLabel:_t};xt=i;const n=new e.EllipsoidGeodesic,o=[1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,3e3,5e3,1e4,2e4,3e4,5e4,1e5,2e5,3e5,5e5,1e6,2e6,3e6,5e6,1e7,2e7,3e7,5e7],r=t.scene,a=r.canvas.clientWidth,s=r.canvas.clientHeight,l=r.camera.getPickRay(new e.Cartesian2(a/2|0,s-1)),c=r.camera.getPickRay(new e.Cartesian2(1+a/2|0,s-1)),d=r.globe,u=d.pick(l,r),p=d.pick(c,r);if(!e.defined(u)||!e.defined(p))return{barWidth:bt,distanceLabel:_t};const h=d.ellipsoid.cartesianToCartographic(u),m=d.ellipsoid.cartesianToCartographic(p);n.setEndPoints(h,m);const f=n.surfaceDistance;let g;for(let t=o.length-1;!e.defined(g)&&t>=0;--t)o[t]/f<100&&(g=o[t]);if(e.defined(g)){const e=g>=1e3?`${(g/1e3).toString()} km`:`${g.toString()} m`;bt=g/f|0,_t=e}else bt=0,_t="";return{barWidth:bt,distanceLabel:_t}},Dt=t=>new Promise(i=>{const{viewer:n,center:o}=t;let r=o.lng,a=1,s=null;const l=t=>{null===s&&(s=t);r-=(t-s)/2e4*2,r<-180&&(r=180,a+=1),2===a&&r>o.lng?n.camera.flyTo({destination:e.Cartesian3.fromDegrees(o.lng,o.lat,3e7),duration:2,orientation:{heading:e.Math.toRadians(360),pitch:e.Math.toRadians(-90),roll:0},easingFunction:e.EasingFunction.LINEAR_NONE,complete:()=>{n.camera.flyTo({destination:e.Cartesian3.fromDegrees(o.lng,o.lat,o.height),duration:3,orientation:{heading:e.Math.toRadians(2.8),pitch:e.Math.toRadians(-90),roll:6.282253919167732},complete:()=>{i(!0)}})}}):(n.camera.setView({destination:e.Cartesian3.fromDegrees(r,o.lat,3e7),orientation:{heading:e.Math.toRadians(360),pitch:e.Math.toRadians(-90),roll:0}}),requestAnimationFrame(l))};requestAnimationFrame(l)}),Et=(t,i,n)=>{const o=new Float64Array(24);for(let e=0;e<8;e++)o[3*e]=t[e].x,o[3*e+1]=t[e].y,o[3*e+2]=t[e].z;const r=new Uint16Array([0,1,2,0,2,3,4,6,5,4,7,6,0,4,1,1,4,5,1,5,2,2,5,6,2,6,3,3,6,7,3,7,0,0,7,4]),a={position:new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:o})},s=new e.Geometry({indices:r,attributes:a,primitiveType:e.PrimitiveType.TRIANGLES,boundingSphere:e.BoundingSphere.fromVertices(o)});return new e.GeometryInstance({geometry:s,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(i)},id:`${n}`})},At=(t,i,n)=>{const[o,r,a,s,l,c,d,u]=t,p=[o,r,r,a,a,s,s,o,l,c,c,d,d,u,u,l,o,l,l,c,c,r,r,o,s,u,u,d,d,a,a,s,o,s,s,u,u,l,l,o,r,c,c,d,d,a,a,r];return new e.GeometryInstance({geometry:new e.PolylineGeometry({positions:p,width:2,vertexFormat:e.PolylineColorAppearance.VERTEX_FORMAT}),attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(i)},id:`${n}`})},St=(t,i)=>[e.Cartesian3.fromDegrees(t.longitude,t.latitude,i.height),e.Cartesian3.fromDegrees(t.longitude,i.latitude,i.height),e.Cartesian3.fromDegrees(i.longitude,i.latitude,i.height),e.Cartesian3.fromDegrees(i.longitude,t.latitude,i.height),e.Cartesian3.fromDegrees(t.longitude,t.latitude,t.height),e.Cartesian3.fromDegrees(t.longitude,i.latitude,t.height),e.Cartesian3.fromDegrees(i.longitude,i.latitude,t.height),e.Cartesian3.fromDegrees(i.longitude,t.latitude,t.height)],It=(t,i,n,o,r,a)=>[e.Cartesian3.fromDegrees(t,t,r),e.Cartesian3.fromDegrees(i,i,r),e.Cartesian3.fromDegrees(n,n,r),e.Cartesian3.fromDegrees(o,o,r),e.Cartesian3.fromDegrees(t,t,a),e.Cartesian3.fromDegrees(i,i,a),e.Cartesian3.fromDegrees(n,n,a),e.Cartesian3.fromDegrees(o,o,a)],Tt=3e3*Math.PI/180,zt=Math.PI,Rt=6378245,Ot=.006693421622965943,Ft=(e,t)=>!(e>72.004&&e<137.8347&&t>.8293&&t<55.8271),Lt=(e,t)=>{let i=2*e-100+3*t+.2*t*t+.1*e*t+.2*Math.sqrt(Math.abs(e));return i+=2*(20*Math.sin(6*e*zt)+20*Math.sin(2*e*zt))/3,i+=2*(20*Math.sin(t*zt)+40*Math.sin(t/3*zt))/3,i+=2*(160*Math.sin(t/12*zt)+320*Math.sin(t*zt/30))/3,i},Bt=(e,t)=>{let i=300+e+2*t+.1*e*e+.1*e*t+.1*Math.sqrt(Math.abs(e));return i+=2*(20*Math.sin(6*e*zt)+20*Math.sin(2*e*zt))/3,i+=2*(20*Math.sin(e*zt)+40*Math.sin(e/3*zt))/3,i+=2*(150*Math.sin(e/12*zt)+300*Math.sin(e/30*zt))/3,i},kt=(e,t)=>{if(Ft(e,t))return[e,t];let i=Lt(e-105,t-35),n=Bt(e-105,t-35);const o=t/180*zt;let r=Math.sin(o);r=1-Ot*r*r;const a=Math.sqrt(r);i=180*i/(Rt*(1-Ot)/(r*a)*zt),n=180*n/(Rt/a*Math.cos(o)*zt);return[e+n,t+i]},Nt=(e,t)=>{if(Ft(e,t))return[e,t];let i=Lt(e-105,t-35),n=Bt(e-105,t-35);const o=t/180*zt;let r=Math.sin(o);r=1-Ot*r*r;const a=Math.sqrt(r);i=180*i/(Rt*(1-Ot)/(r*a)*zt),n=180*n/(Rt/a*Math.cos(o)*zt);return[2*e-(e+n),2*t-(t+i)]},Gt=(e,t)=>{const i=e,n=t,o=Math.sqrt(i*i+n*n)+2e-5*Math.sin(n*Tt),r=Math.atan2(n,i)+3e-6*Math.cos(i*Tt);return[o*Math.cos(r)+.0065,o*Math.sin(r)+.006]},Ut=(e,t)=>{const i=e-.0065,n=t-.006,o=Math.sqrt(i*i+n*n)-2e-5*Math.sin(n*Tt),r=Math.atan2(n,i)-3e-6*Math.cos(i*Tt);return[o*Math.cos(r),o*Math.sin(r)]};class Vt{static wgs84ToGcj02(e){const[t,i]=kt(e.lng,e.lat);return{lng:t,lat:i}}static gcj02ToWgs84(e){const[t,i]=Nt(e.lng,e.lat);return{lng:t,lat:i}}static gcj02ToBd09(e){const[t,i]=Gt(e.lng,e.lat);return{lng:t,lat:i}}static bd09ToGcj02(e){const[t,i]=Ut(e.lng,e.lat);return{lng:t,lat:i}}static bd09ToWgs84(e){const[t,i]=((e,t)=>{const[i,n]=Ut(e,t);return Nt(i,n)})(e.lng,e.lat);return{lng:t,lat:i}}static wgs84ToBd09(e){const[t,i]=((e,t)=>{const[i,n]=kt(e,t);return Gt(i,n)})(e.lng,e.lat);return{lng:t,lat:i}}}const $t=t=>{const{viewer:i,token:n}=t,o=i.imageryLayers.addImageryProvider(new e.WebMapTileServiceImageryProvider({url:`//t{s}.tianditu.gov.cn/img_w/wmts?tk=${n}`,layer:"img",style:"default",tileMatrixSetID:"w",format:"tiles",maximumLevel:18,subdomains:["0","1","2","3","4","5","6","7"]})),r=i.imageryLayers.addImageryProvider(new e.WebMapTileServiceImageryProvider({url:`//t{s}.tianditu.gov.cn/cia_w/wmts?tk=${n}`,layer:"cia",style:"default",tileMatrixSetID:"w",format:"tiles",maximumLevel:18,subdomains:["0","1","2","3","4","5","6","7"]}));return{layers:[o,r],remove:()=>{i.imageryLayers.remove(o),i.imageryLayers.remove(r)}}},Wt={cacheBytes:4294967296,maximumCacheOverflowBytes:5368709120},Ht=async t=>{const{viewer:i,url:n,options:o}=t,r=await e.Cesium3DTileset.fromUrl(n,{...Wt,...o});i.scene.primitives.add(r);return{tileset:r,setHeightOffset:e=>{qt(r,e)},remove:()=>{i.scene.primitives.remove(r)},flyTo:()=>{i.flyTo(r)}}},qt=(t,i)=>{Yt(t,e.Cartesian3.fromElements(0,0,i,new e.Cartesian3))},jt=async e=>{const t=[];function i(e){if(console.log(e),!e.content||!e.content.featuresLength)return;const n=e.content;for(let e=0;e<n.featuresLength;e++)t.push(n.getFeature(e));e.children?.forEach(i)}return new Promise(n=>{e.allTilesLoaded.addEventListener(()=>{i(e.root),n(t)})})},Zt=e=>{const t=[];function i(e){t.push(e),e.children?.forEach(i)}return new Promise(n=>{e.allTilesLoaded.addEventListener(()=>{i(e.root),n(t)})})},Yt=(t,i)=>{if(i.equals(e.Cartesian3.ZERO))return;const n=t.boundingSphere.center,o=e.Transforms.eastNorthUpToFixedFrame(n),r=e.Matrix4.multiplyByPoint(o,i,new e.Cartesian3),a=e.Cartesian3.subtract(r,n,new e.Cartesian3),s=e.Matrix4.fromTranslation(a);t.modelMatrix=e.Matrix4.multiply(s,t.modelMatrix,new e.Matrix4)},Kt={translate:Yt,scale:(t,i)=>{if(i.equals(e.Cartesian3.ZERO)||i.equals(e.Cartesian3.ONE))return;const n=t.boundingSphere.center,o=e.Transforms.eastNorthUpToFixedFrame(n),r=e.Matrix4.inverse(o,new e.Matrix4),a=e.Matrix4.fromScale(i),s=e.Matrix4.multiply(a,r,new e.Matrix4),l=e.Matrix4.multiply(o,s,new e.Matrix4);t.modelMatrix=e.Matrix4.multiply(l,t.modelMatrix,new e.Matrix4)},rotate:(t,i)=>{const{x:n,y:o,z:r}=i,a=t.boundingSphere.center,s=e.Transforms.eastNorthUpToFixedFrame(a),l=e.Matrix4.inverse(s,new e.Matrix4),c=e.Matrix4.clone(e.Matrix4.IDENTITY);if(0!==n){const t=e.Matrix4.fromRotation(e.Matrix3.fromRotationX(e.Math.toRadians(n)));e.Matrix4.multiply(t,c,c)}if(0!==o){const t=e.Matrix4.fromRotation(e.Matrix3.fromRotationY(e.Math.toRadians(o)));e.Matrix4.multiply(t,c,c)}if(0!==r){const t=e.Matrix4.fromRotation(e.Matrix3.fromRotationZ(e.Math.toRadians(r)));e.Matrix4.multiply(t,c,c)}const d=e.Matrix4.multiply(c,l,new e.Matrix4),u=e.Matrix4.multiply(s,d,new e.Matrix4);t.modelMatrix=e.Matrix4.multiply(u,t.modelMatrix,new e.Matrix4)}},Xt=async t=>{const{viewer:i,url:n}=t,o=await e.CesiumTerrainProvider.fromUrl(n,{requestWaterMask:!0,requestVertexNormals:!0});i.scene.terrainProvider=o;return{terrainProvider:o,remove:()=>{i.scene.terrainProvider=new e.EllipsoidTerrainProvider}}},Jt=t=>{t.scene.terrainProvider=new e.EllipsoidTerrainProvider},Qt=async()=>await e.CesiumTerrainProvider.fromIonAssetId(1,{requestWaterMask:!0,requestVertexNormals:!0}),ei=()=>{},ti=()=>{},ii=async t=>{const{viewer:i,url:n,options:o}=t,r=await e.I3SDataProvider.fromUrl(n,o);i.scene.primitives.add(r);return{i3sData:r,setHeightOffset:e=>{r.layers.forEach(t=>{const i=t.tileset;i&&qt(i,e)})},remove:()=>{i.scene.primitives.remove(r)},flyTo:()=>{i.camera.flyTo({destination:r.extent,orientation:{heading:0,pitch:e.Math.toRadians(-90),roll:0}})}}},ni=(t,i=e.Color.YELLOW)=>{const n=t.scene.postProcessStages.add(new e.PostProcessStage({fragmentShader:"\n uniform sampler2D colorTexture;\n in vec2 v_textureCoordinates;\n uniform vec4 highlight;\n void main() {\n vec4 color = texture(colorTexture, v_textureCoordinates);\n if (czm_selected()) {\n vec3 highlighted = highlight.a * highlight.rgb + (1.0 - highlight.a) * color.rgb;\n out_FragColor = mix(color, vec4(highlighted,0.5), 0.3);\n } else {\n out_FragColor = color;\n }\n }\n ",uniforms:{highlight:()=>i}}));n.selected=[];return{stage:n,remove:()=>{t.scene.postProcessStages.remove(n)}}},oi=t=>{const i=e.PostProcessStageLibrary.createEdgeDetectionStage(),n=new e.PostProcessStage({name:"skyline",fragmentShader:"\n uniform sampler2D colorTexture;\n uniform sampler2D depthTexture;\n in vec2 v_textureCoordinates;\n void main() { float depth = czm_readDepth(depthTexture, v_textureCoordinates);\n vec4 color = texture(colorTexture, v_textureCoordinates);\n if (depth < 1.0 - 0.000001) {\n out_FragColor = color;\n } else {\n out_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n }\n }"}),o=new e.PostProcessStage({name:"mix",fragmentShader:"\n uniform sampler2D colorTexture;\n uniform sampler2D redTexture;\n uniform sampler2D silhouetteTexture;\n in vec2 v_textureCoordinates;\n\n void main() {\n vec4 redColor = texture(redTexture, v_textureCoordinates);\n vec4 silhouetteColor = texture(silhouetteTexture, v_textureCoordinates);\n vec4 color = texture(colorTexture, v_textureCoordinates);\n if (redColor.r == 1.0) {\n out_FragColor = mix(color, vec4(5.0, 0.0, 0.0, 1.0), silhouetteColor.a);\n } else {\n out_FragColor = color;\n }\n }",uniforms:{redTexture:n.name,silhouetteTexture:i.name}}),r=new e.PostProcessStageComposite({stages:[i,n,o],inputPreviousStageTexture:!1,uniforms:i.uniforms});t.scene.postProcessStages.add(r);return{stage:r,remove:()=>{t.scene.postProcessStages.remove(r)}}},ri=(t,i=e.Color.YELLOW)=>{const n=t.scene.postProcessStages,o=e.PostProcessStageLibrary.createEdgeDetectionStage();o.uniforms.color=i,o.uniforms.length=1,o.selected=[];const r=e.PostProcessStageLibrary.createEdgeDetectionStage();r.uniforms.color=i,r.selected=[];const a=n.add(e.PostProcessStageLibrary.createSilhouetteStage([o,r]));a.selected=[];return{stage:a,remove:()=>{t.scene.postProcessStages.remove(a)}}},ai=t=>{const i=t.viewer,n=new e.PostProcessStage({name:"SnowEffectCover",fragmentShader:"\n vec3 getEyeCoordinate3FromWindowCoordinate(vec2 fragCoord, float logDepthOrDepth)\n {\n vec4 eyeCoordinate = czm_windowToEyeCoordinates(fragCoord, logDepthOrDepth);\n return eyeCoordinate.xyz / eyeCoordinate.w;\n }\n vec3 vectorFromOffset(vec4 eyeCoordinate, vec2 positiveOffset, sampler2D depthMap) {\n vec2 glFragCoordXY = gl_FragCoord.xy;\n float upOrRightLogDepth = czm_unpackDepth(texture(depthMap, (glFragCoordXY + positiveOffset) / czm_viewport.zw));\n float downOrLeftLogDepth = czm_unpackDepth(texture(depthMap, (glFragCoordXY - positiveOffset) / czm_viewport.zw));\n bvec2 upOrRightInBounds = lessThan(glFragCoordXY + positiveOffset, czm_viewport.zw);\n\n float useUpOrRight = float(upOrRightLogDepth > 0.0 && upOrRightInBounds.x && upOrRightInBounds.y);\n float useDownOrLeft = float(useUpOrRight == 0.0);\n vec3 upOrRightEC = getEyeCoordinate3FromWindowCoordinate(glFragCoordXY + positiveOffset, upOrRightLogDepth);\n vec3 downOrLeftEC = getEyeCoordinate3FromWindowCoordinate(glFragCoordXY - positiveOffset, downOrLeftLogDepth);\n return (upOrRightEC - (eyeCoordinate.xyz / eyeCoordinate.w)) * useUpOrRight + ((eyeCoordinate.xyz / eyeCoordinate.w) - downOrLeftEC) * useDownOrLeft;\n }\n uniform sampler2D colorTexture;\n uniform sampler2D depthTexture;\n uniform float intensity;\n in vec2 v_textureCoordinates;\n void main(void)\n {\n vec4 sceneColor = texture(colorTexture, v_textureCoordinates);\n\n float logDepthOrDepth = czm_unpackDepth(texture(depthTexture, v_textureCoordinates));\n vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);\n vec4 worldCoordinate4 = czm_inverseView * eyeCoordinate;\n vec3 worldCoordinate = worldCoordinate4.xyz / worldCoordinate4.w;\n vec3 downUp = vectorFromOffset(eyeCoordinate, vec2(0.0, 1.0), depthTexture);\n vec3 leftRight = vectorFromOffset(eyeCoordinate, vec2(1.0, 0.0), depthTexture);\n vec3 normalEC = normalize(cross(leftRight, downUp));\n vec3 normalMC = normalize((czm_inverseView * vec4(normalEC, 0.0)).xyz);\n vec3 ellipsoidNormal = normalize(worldCoordinate);\n float dotProd = dot(ellipsoidNormal, normalMC);\n if(dotProd < 0.3){\n out_FragColor = sceneColor;\n } else {\n out_FragColor = mix(sceneColor, vec4(1.0), dotProd * intensity);\n }\n if (czm_selected()) {\n out_FragColor = sceneColor;\n }\n }\n ",forcePowerOfTwo:!1,textureScale:1,uniforms:{intensity:()=>t.intensity||.8}});i.scene.postProcessStages.add(n);return n.selected=[],{stage:n,remove:()=>{i.scene.postProcessStages.remove(n)}}},si=t=>{const i=t.viewer,n=i.scene.postProcessStages.add(new e.PostProcessStage({fragmentShader:"\n uniform sampler2D colorTexture; //输入的场景渲染照片\n in vec2 v_textureCoordinates;\n uniform float speed;\n uniform float scale;\n\n float snow(vec2 uv, float thisScale) {\n float time = czm_frameNumber * speed / 1000.0;\n float wMars3D = smoothstep(1.0, 0.0, -uv.y * (thisScale / 10.0));\n if(wMars3D < 0.1)\n return 0.0;\n uv += time / thisScale;\n uv.y += time * 2.0 / thisScale;\n uv.x += sin(uv.y + time * 0.5) / thisScale;\n uv *= thisScale;\n\n vec2 s = floor(uv), f = fract(uv), p;\n float k = 3.0, d;\n p = 0.5 + 0.35 * sin(11.0 * fract(sin((s + p + thisScale) * mat2(7, 3, 6, 5)) * 5.0)) - f;\n d = length(p);\n k = min(d, k);\n k = smoothstep(0.0, k, sin(f.x + f.y) * 0.01);\n return k * wMars3D;\n }\n void main(void) {\n vec2 resolution = czm_viewport.zw;\n vec2 uv = (gl_FragCoord.xy * 2. - resolution.xy) / min(resolution.x, resolution.y);\n\n float c = 0.0;\n float step = 1.0/(scale*0.1);\n for(float i = 1.0; i < 12.0; i += 1.0) {\n c += snow(uv, i*step);\n }\n vec3 finalColor = vec3(c); //屏幕上雪的颜色\n out_FragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(finalColor, 1.0), 0.5); //将雪和三维场景融合\n }",uniforms:{scale:()=>t.scale||5,speed:()=>t.speed||16}}));n.selected=[];return{stage:n,remove:()=>{i.scene.postProcessStages.remove(n)}}},li=t=>{const i=t.viewer.scene.postProcessStages.add(new e.PostProcessStage({fragmentShader:"\n uniform sampler2D colorTexture;\n uniform sampler2D depthTexture;\n uniform float alpha;\n uniform float height;\n uniform vec3 oneOverRadii;\n uniform vec3 oneOverRadiiSquared;\n uniform float centerToleranceSquared;\n uniform float EPSILON12;\n uniform float earthRadius;\n\n in vec2 v_textureCoordinates;\n out vec4 glColor;\n\n vec4 toEye(in vec2 uv, in float depth){\n vec2 xy = vec2((uv.x * 2.0 - 1.0),(uv.y * 2.0 - 1.0));\n vec4 posInCamera =czm_inverseProjection * vec4(xy, depth, 1.0);\n posInCamera =posInCamera / posInCamera.w;\n return posInCamera;\n }\n float getDepth(in vec4 depth){\n float z_window = czm_unpackDepth(depth);\n z_window = czm_reverseLogDepth(z_window);\n float n_range = czm_depthRange.near;\n float f_range = czm_depthRange.far;\n return (2.0 * z_window - n_range - f_range) / (f_range - n_range);\n }\n\n\n vec3 getWorldCoordinateFromDepth(in vec4 currD){\n float depth = czm_unpackDepth(currD);\n vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);\n vec4 worldCoordinate4 = czm_inverseView * eyeCoordinate;\n vec3 worldCoordinate = worldCoordinate4.xyz / worldCoordinate4.w;\n return worldCoordinate;\n }\n\n float magnitude(in vec3 v){\n return sqrt(v.x * v.x + v.y * v.y + v.z * v.z);\n }\n\n // 沿大地表面法线缩放提供的笛卡尔位置,使其位于该椭球体的表面上\n vec3 scaleToGeodeticSurface(in vec3 cartesian){\n float positionX = cartesian.x;\n float positionY = cartesian.y;\n float positionZ = cartesian.z;\n float x2 = cartesian.x * cartesian.x * oneOverRadii.x * oneOverRadii.x;\n float y2 = cartesian.y * cartesian.y * oneOverRadii.y * oneOverRadii.y;\n float z2 = cartesian.z * cartesian.z * oneOverRadii.z * oneOverRadii.z;\n\n float squaredNorm = x2 + y2 + z2;\n float ratio = sqrt(1.0 / squaredNorm);\n vec3 intersection = cartesian * ratio;\n\n float oneOverRadiiSquaredX = oneOverRadiiSquared.x;\n float oneOverRadiiSquaredY = oneOverRadiiSquared.y;\n float oneOverRadiiSquaredZ = oneOverRadiiSquared.z;\n\n vec3 gradient = vec3(intersection.x * oneOverRadiiSquaredX * 2.0,intersection.y * oneOverRadiiSquaredY * 2.0,intersection.z * oneOverRadiiSquaredZ * 2.0);\n\n float lambda = ((1.0 - ratio) * magnitude(cartesian) ) / (0.5 * magnitude(gradient));\n float correction = 0.0;\n float func = 0.0;\n float denominator = 0.0;\n float xMultiplier = 0.0;\n float yMultiplier = 0.0;\n float zMultiplier = 0.0;\n float xMultiplier2 = 0.0;\n float yMultiplier2 = 0.0;\n float zMultiplier2 = 0.0;\n float xMultiplier3 = 0.0;\n float yMultiplier3 = 0.0;\n float zMultiplier3 = 0.0;\n do {\n lambda -= correction;\n\n xMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredX);\n yMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredY);\n zMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredZ);\n\n xMultiplier2 = xMultiplier * xMultiplier;\n yMultiplier2 = yMultiplier * yMultiplier;\n zMultiplier2 = zMultiplier * zMultiplier;\n\n xMultiplier3 = xMultiplier2 * xMultiplier;\n yMultiplier3 = yMultiplier2 * yMultiplier;\n zMultiplier3 = zMultiplier2 * zMultiplier;\n\n float func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0;\n\n float denominator =\n x2 * xMultiplier3 * oneOverRadiiSquaredX +\n y2 * yMultiplier3 * oneOverRadiiSquaredY +\n z2 * zMultiplier3 * oneOverRadiiSquaredZ;\n\n float derivative = -2.0 * denominator;\n\n correction = func / derivative;\n } while (abs(func) > EPSILON12);\n return vec3(positionX * xMultiplier, positionY * yMultiplier, positionZ * zMultiplier);\n }\n\n vec3 multiplyComponents(in vec3 left,in vec3 right){\n return vec3(left.x * right.x, left.y * right.y, left.z * right.z);\n }\n\n\n // 将世界坐标转为经纬度高度\n vec3 getCartographicFromCartesian3(in vec3 cartesian){\n vec3 p = scaleToGeodeticSurface(cartesian);\n vec3 n = multiplyComponents(p,oneOverRadiiSquared);\n n = normalize(n);\n vec3 h = cartesian - p;\n\n float longitude = atan(n.y, n.x);\n float latitude = asin(n.z);\n float height = sign(dot(h, cartesian)) * magnitude(h);\n\n return vec3(longitude,latitude,height);\n }\n\n // 计算每个像素点的高度 通过计算相机所在位置的地球半径作为每个点的地球半径,然后用每个点的length减去半径得到近似的高度\n float getHeight(in vec4 currD){\n // 传入每个点的世界坐标\n float altitude = 0.0;\n float depth = czm_unpackDepth(currD);\n if (depth == 0.0) {\n altitude = czm_infinity;\n }\n vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);\n float distance = -eyeCoordinate.z / eyeCoordinate.w;\n vec4 worldCoordinate4 = czm_inverseView * eyeCoordinate;\n vec3 worldCoordinate = worldCoordinate4.xyz / worldCoordinate4.w;\n altitude = length(worldCoordinate.xyz) - earthRadius;\n return altitude;\n }\n\n void main(){\n vec4 color = texture(colorTexture, v_textureCoordinates);\n vec4 currD = texture(depthTexture, v_textureCoordinates);\n if(currD.r>=1.0){\n glColor = color;\n return;\n }\n // 此方法有问题 会闪烁\n float depth = getDepth(currD);\n vec4 positionEC = toEye(v_textureCoordinates, depth);\n vec4 positionWC = czm_inverseView * positionEC;\n // 获取当前点的高度\n // vec3 positionWC = getWorldCoordinateFromDepth(currD);\n vec3 cartographic = getCartographicFromCartesian3(vec3(positionWC.x,positionWC.y,positionWC.z));\n // 高度加了10之后 就不闪烁了\n float pointHeight = cartographic.z + 10.;\n // 当前点高度越高,雾浓度越小,高度达到设定高度,雾浓度为0,同时乘以深度,距离越远,浓度越大\n float fog = (height/pointHeight - 1.);\n fog = clamp(fog, 0.0, 1.0);\n glColor = mix(color,vec4(1.0,1.,1.,1),fog*alpha);\n }",uniforms:{EPSILON12:()=>t.EPSILON12||1e-12,alpha:()=>t.alpha||.88,centerToleranceSquared:()=>t.centerToleranceSquared||.1,height:()=>t.height||100,oneOverRadii:()=>t.oneOverRadii||{x:1.567855942887398e-7,y:1.567855942887398e-7,z:1.573130351105623e-7},oneOverRadiiSquared:()=>t.oneOverRadiiSquared||{x:2458172257647332e-29,y:2458172257647332e-29,z:24747391015697002e-30}}}));i.selected=[];return{stage:i,remove:()=>{t.viewer.scene.postProcessStages.remove(i)}}},ci=t=>{const i=t.viewer.scene.postProcessStages.add(new e.PostProcessStage({fragmentShader:"\nfloat getDistance(sampler2D depthTexture, vec2 texCoords) {\n float depth = czm_unpackDepth(texture(depthTexture, texCoords));\n if(depth == 0.0) {\n return czm_infinity;\n }\n vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);\n return -eyeCoordinate.z / eyeCoordinate.w;\n}\nfloat interpolateByDistanceMars3D(vec4 nearFarScalar, float distance) {\n float startDistance = nearFarScalar.x;\n float startValue = nearFarScalar.y;\n float endDistance = nearFarScalar.z;\n float endValue = nearFarScalar.w;\n float t = clamp((distance - startDistance) / (endDistance - startDistance), 0.0, 1.0);\n return mix(startValue, endValue, t);\n}\nvec4 alphaBlend(vec4 sourceColor, vec4 destinationColor) {\n return sourceColor * vec4(sourceColor.aaa, 1.0) + destinationColor * (1.0 - sourceColor.a);\n}\nuniform sampler2D colorTexture;\nuniform sampler2D depthTexture;\nuniform vec4 fogByDistance;\nuniform vec4 fogColor;\nin vec2 v_textureCoordinates;\nvoid main(void) {\n float distance = getDistance(depthTexture, v_textureCoordinates);\n vec4 sceneColor = texture(colorTexture, v_textureCoordinates);\n float blendAmount = interpolateByDistanceMars3D(fogByDistance, distance);\n vec4 finalFogColor = vec4(fogColor.rgb, fogColor.a * blendAmount);\n out_FragColor = alphaBlend(finalFogColor, sceneColor);\n}\n ",uniforms:{fogColor:()=>t.fogColor||e.Color.WHITE,fogByDistance:()=>t.fogByDistance||new e.Cartesian4(100,0,9e3,.9)}}));i.selected=[];return{stage:i,remove:()=>{t.viewer.scene.postProcessStages.remove(i)}}},di=t=>{const i=new e.PostProcessStageComposite({name:"undefinedcontrast_bias_blur",stages:[new e.PostProcessStage({name:"undefinedcontrast_bias",fragmentShader:"\n uniform sampler2D colorTexture;\n in vec2 v_textureCoordinates;\n uniform float contrast;\n uniform float brightness;\n void main(void)\n {\n vec4 texture1 = texture(colorTexture, v_textureCoordinates);\n vec3 sceneColor = texture1.rgb;\n\n sceneColor = czm_RGBToHSB(sceneColor);\n sceneColor.z += brightness;\n sceneColor = czm_HSBToRGB(sceneColor);\n float factor = (259.0 * (contrast + 255.0)) / (255.0 * (259.0 - contrast));\n sceneColor = factor * (sceneColor - vec3(0.5)) + vec3(0.5);\n out_FragColor = vec4(sceneColor, texture1.a);\n }\n ",uniforms:{contrast:()=>128,brightness:()=>-.3}}),new e.PostProcessStageComposite({name:"undefined_blur_comp",stages:[new e.PostProcessStage({name:"undefinedhigh",fragmentShader:"\n uniform sampler2D colorTexture;\n uniform float threshold;\n uniform float smoothWidth;\n\n in vec2 v_textureCoordinates;\n void main() {\n vec4 marstexel = texture( colorTexture, v_textureCoordinates );\n\n #ifdef CZM_SELECTED_FEATURE\n if (!czm_selected()) {\n marstexel = vec4(0.);\n }\n #endif\n\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float marsv = dot( marstexel.xyz, luma );\n float alpha = smoothstep(threshold, threshold + smoothWidth, marsv);\n\n vec4 outputColor = vec4(0.0,0.0,0.0,0.0);\n out_FragColor = mix( outputColor, marstexel, alpha );\n }\n ",uniforms:{threshold:()=>0,smoothWidth:()=>.01}})]})]}),n=t.scene.postProcessStages.add(new e.PostProcessStageComposite({name:"bloom_target",inputPreviousStageTexture:!1,stages:[i,new e.PostProcessStage({name:"undefinedgenerate_composite",fragmentShader:"\n uniform sampler2D colorTexture;\n uniform sampler2D bloomTexture;\n uniform float ratio;\n uniform vec4 color;\n in vec2 v_textureCoordinates;\n void main(void)\n {\n vec4 color1 = texture(colorTexture, v_textureCoordinates);\n vec4 bloom = texture(bloomTexture, v_textureCoordinates);\n bloom *= color;\n if (czm_selected()) {\n bloom *= ratio;\n out_FragColor = bloom + color1;\n } else {\n out_FragColor = color1;\n }\n }\n ",uniforms:{bloomTexture:()=>"undefinedcontrast_bias_blur",color:()=>e.Color.GREEN,ratio:()=>2}})]}));n.enabled=!1;return n.selected=[],{stage:n,remove:()=>{t.scene.postProcessStages.remove(n)}}},ui=t=>{const i=t.viewer.scene.postProcessStages.add(new e.PostProcessStage({fragmentShader:"\n uniform sampler2D colorTexture;\n in vec2 v_textureCoordinates;\n uniform float speed;\n uniform float size;\n uniform float direction;\n\n float hash(float x) {\n return fract(sin(x * 133.3) * 13.13);\n }\n\n void main(void) {\n\n float time = czm_frameNumber * speed / 1000.0;\n vec2 resolution = czm_viewport.zw;\n\n vec2 uv = (gl_FragCoord.xy * 2. - resolution.xy) / min(resolution.x, resolution.y);\n vec3 finalColor = vec3(.6, .7, .8);//粒子的颜色\n\n float siMars3D = sin(direction), co = cos(direction);\n uv *= mat2(co, -siMars3D, siMars3D, co);\n uv *= length(uv + vec2(0, 4.9))*(20.0/size) + 1.0;\n\n float v = 1. - sin(hash(floor(uv.x * 100.0)) * 2.0);\n float b = clamp(abs(sin(20.0 * time * v + uv.y * (5. / (2.0 + v)))) - .95, 0.0, 1.0) * 20.0;\n finalColor *= v * b; //屏幕上雨的颜色\n\n out_FragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(finalColor, 1.0), 0.5); //将雨和三维场景融合\n }\n ",uniforms:{speed:()=>t.speed||16,size:()=>t.size||20,direction:()=>360+(t.direction||30)}}));i.selected=[];return{stage:i,remove:()=>{t.viewer.scene.postProcessStages.remove(i)}}},pi=t=>{const i=t.viewer,n=new e.PostProcessStage({fragmentShader:"\n#extension GL_OES_standard_derivatives:enable\nuniform sampler2D colorTexture;\nuniform sampler2D depthTexture;\nin vec2 v_textureCoordinates;\nvec4 toEye(in vec2 uv, in float depth){\n vec2 xy = vec2((uv.x * 2.0 - 1.0),(uv.y * 2.0 - 1.0));\n vec4 posInCamera =czm_inverseProjection * vec4(xy, depth, 1.0);\n posInCamera =posInCamera / posInCamera.w;\n return posInCamera;\n}\nfloat getDepth(in vec4 depth){\n float z_window = czm_unpackDepth(depth);\n z_window = czm_reverseLogDepth(z_window);\n float n_range = czm_depthRange.near;\n float f_range = czm_depthRange.far;\n return (2.0 * z_window - n_range - f_range) / (f_range - n_range);\n}\nvec3 guussColor(vec2 uv){\n vec2 pixelSize = 1.0 / czm_viewport.zw;\n float dx0 = -pixelSize.x;\n float dy0 = -pixelSize.y;\n float dx1 = pixelSize.x;\n float dy1 = pixelSize.y;\n vec4 gc = (\n texture(colorTexture, uv)+\n texture(colorTexture, uv + vec2(dx0, dy0)) +\n texture(colorTexture, uv + vec2(0.0, dy0)) +\n texture(colorTexture, uv + vec2(dx1, dy0)) +\n texture(colorTexture, uv + vec2(dx0, 0.0)) +\n texture(colorTexture, uv + vec2(dx1, 0.0)) +\n texture(colorTexture, uv + vec2(dx0, dy1)) +\n texture(colorTexture, uv + vec2(0.0, dy1)) +\n texture(colorTexture, uv + vec2(dx1, dy1))\n ) * (1.0 / 9.0);\n return gc.rgb;\n}\nvoid main(){\n float offset = 0.0;\n vec4 color = texture(colorTexture, v_textureCoordinates);\n vec4 currD = texture(depthTexture, v_textureCoordinates);\n if(currD.r>=1.0){\n out_FragColor = color;\n return;\n }\n float depth = getDepth(currD);\n\n vec4 positionEC = toEye(v_textureCoordinates, depth);\n vec3 dx = dFdx(positionEC.xyz);\n vec3 dy = dFdy(positionEC.xyz);\n vec3 normal = normalize(cross(dx,dy));\n\n vec4 positionWC = normalize(czm_inverseView * positionEC);\n vec3 normalWC = normalize(czm_inverseViewRotation * normal);\n float fotNumWC = dot(positionWC.xyz,normalWC);\n if(fotNumWC<=0.5){\n out_FragColor = color;\n return;\n }\n\n vec3 viewDir = normalize(positionEC.xyz);\n vec3 reflectDir = reflect(viewDir, normal);\n vec3 viewReflectDir = reflectDir;\n\n float step = 0.05;\n int stepNum = int(20.0 / step);\n vec3 pos;\n vec3 albedo;\n bool jd = false;\n for(int i = 1;i <= 400;i++)\n {\n float delta = step * float(i) + offset;\n pos = positionEC.xyz + viewReflectDir * delta;\n float d = -pos.z;\n\n vec4 tmp = czm_projection * vec4(pos,1.0);\n vec3 screenPos = tmp.xyz / tmp.w;\n vec2 uv = vec2(screenPos.x, screenPos.y) * 0.5 + vec2(0.5, 0.5);\n\n if(uv.x > 0.0 && uv.x < 1.0 && uv.y > 0.0 && uv.y < 1.0){\n float dd = getDepth(texture(depthTexture, uv));\n vec4 jzc = toEye(uv, dd);\n dd = -jzc.z;\n if(d>dd){\n if(abs(abs(d) - abs(dd)) <=step){\n jd = true;\n // albedo = texture(colorTexture, uv).rgb;\n albedo = guussColor(uv);\n }\n break;\n }\n }\n }\n if(jd){\n out_FragColor = vec4(mix(color.xyz,albedo,0.5),1.0);\n }else{\n out_FragColor = color;\n }\n}\n",uniforms:{}});i.scene.postProcessStages.add(n);return{stage:n,remove:()=>{i.scene.postProcessStages.remove(n)}}},hi=t=>{const i=t.viewer.scene.postProcessStages.add(new e.PostProcessStage({fragmentShader:"\n float hash(float x)\n {\n return fract(21654.6512 * sin(385.51 * x));\n }\n float hash(vec2 p)\n {\n return fract(1654.65157 * sin(15.5134763 * p.x + 45.5173247 * p.y + 5.21789));\n }\n vec2 hash2(vec2 p)\n {\n return vec2(hash(p * .754), hash(1.5743 * p + 4.5476351));\n }\n vec2 add = vec2(1.0, 0.0);\n vec2 noise2(vec2 x)\n {\n vec2 p = floor(x);\n vec2 f = fract(x);\n f = f * f * (3.0 - 2.0 * f);\n vec2 res = mix(mix(hash2(p),\n hash2(p + add.xy), f.x),\n mix(hash2(p + add.yx), hash2(p + add.xx), f.x), f.y);\n return res;\n }\n vec2 fbm2(vec2 x)\n {\n vec2 r = vec2(0.0);\n float a = 1.0;\n for (int i = 0; i < 8; i++)\n {\n r += noise2(x) * a;\n x *= 2.;\n a *= .5;\n }\n return r;\n }\n float dseg(vec2 ba, vec2 pa)\n {\n float h = clamp(dot(pa, ba) / dot(ba, ba), -0.2, 1.);\n return length(pa - ba * h);\n }\n uniform sampler2D colorTexture;\n uniform float fallInterval;\n uniform float mixFactor;\n in vec2 v_textureCoordinates;\n void main(void){\n vec2 uv = gl_FragCoord.xy;\n float iTime = czm_frameNumber * fallInterval * clamp(fallInterval * 0.1, 0.01, 0.1);\n vec2 p = uv / czm_viewport.zw;\n vec2 d;\n vec2 tgt = vec2(1., -1.);\n float c = 0.;\n if (p.y >= 0.)\n c = (1. - (fbm2((p + .2) * p.y + .1 * iTime)).x) * p.y;\n else\n c = (1. - (fbm2(p + .2 + .1 * iTime)).x) * p.y * p.y;\n vec3 col = vec3(0.);\n vec3 col1 = c * vec3(.3, .5, 1.);\n float mdist = 100000.;\n float t = hash(floor(5. * iTime));\n tgt += 4. * hash2(tgt + t) - 1.5;\n if (hash(t + 2.3) > .6)\n for (int i = 0; i < 100; i++) {\n vec2 dtgt = tgt - p;\n d = .05 * (vec2(-.5, -1.) + hash2(vec2(float(i), t)));\n float dist = dseg(d, dtgt);\n mdist = min(mdist, dist);\n tgt -= d;\n c = exp(-1.2 * dist) + exp(-55. * mdist);\n col = c * vec3(.7, .8, 1.);\n }\n col += col1;\n out_FragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(col, 0.0), mixFactor);\n}\n ",uniforms:{mixFactor:()=>t.mixFactor||.1,fallInterval:()=>t.fallInterval||.8}}));i.selected=[];return{stage:i,remove:()=>{t.viewer.scene.postProcessStages.remove(i)}}},mi=t=>new e.CustomShader({vertexShaderText:fi,fragmentShaderText:gi,uniforms:{maxValue:{type:e.UniformType.FLOAT,value:t.maxValue||0},minValue:{type:e.UniformType.FLOAT,value:t.minValue||1},uColor:{type:e.UniformType.VEC4,value:t.color||e.Color.PURPLE},speed:{type:e.UniformType.FLOAT,value:t.speed||2},lineWidth:{type:e.UniformType.FLOAT,value:t.lineWidth||1}}}),fi="\n void vertexMain(VertexInput vsInput, inout czm_modelVertexOutput vsOutput) {\n vsOutput.positionMC += 0.1 * vsInput.attributes.normalMC;\n }\n",gi="\n void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material){\n float _baseHeight = minValue; // 物体的基础高度,需要修改成一个合适的建筑基础高度\n float _heightRange = maxValue / 3.0; // 高亮的范围(_baseHeight ~ _baseHeight + _heightRange) 默认是 0-60米\n float _glowRange = maxValue; // 光环的移动范围(高度)\n\n // 建筑基础色\n float vtxf_height = fsInput.attributes.positionMC.z - _baseHeight;\n float vtxf_a11 = fract(czm_frameNumber / 120.0) * 3.14159265 * 2.0;\n float vtxf_a12 = vtxf_height / _heightRange + sin(vtxf_a11) * 0.1;\n material.diffuse *= vec3(vtxf_a12, vtxf_a12, vtxf_a12);\n material.diffuse *= vec3(uColor.r,uColor.g,uColor.b);\n\n // 动态光环\n float vtxf_a13 = fract(czm_frameNumber / (360.0 * speed));\n float vtxf_h = clamp(vtxf_height / _glowRange, 0.0, 1.0);\n vtxf_a13 = abs(vtxf_a13 - 0.5) * 2.0;\n float vtxf_diff = step(lineWidth / 200.0, abs(vtxf_h - vtxf_a13));\n material.diffuse += material.diffuse * (1.0 - vtxf_diff);\n material.alpha = uColor.a;\n }\n",vi=t=>new e.CustomShader({fragmentShaderText:yi,uniforms:{color:{type:e.UniformType.VEC4,value:t.color||e.Color.PURPLE}}}),yi="\n void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {\n vec4 originColor = vec4(material.diffuse,1.0);\n material.diffuse = vec3(mix(originColor,color,0.3));\n material.alpha = 0.8;\n }\n",Ci=t=>{const i=t.scene.postProcessStages.add(e.PostProcessStageLibrary.createSilhouetteStage());i.uniforms.color=e.Color.YELLOW,i.selected=[];return{stage:i,remove:()=>{}}};var wi=(e=>(e.DRAW_ADD="drawAdd",e.DRAW_MOVE="drawMove",e.DRAW_PICK="drawPick",e.DRAW_DB_CLICK="drawDbClick",e.DRAW_RIGHT_CLICK="drawRightClick",e))(wi||{}),bi=Object.freeze({__proto__:null,DrawEventType:wi});const _i="cm",xi="厘米",Pi="m",Mi="米",Di="km",Ei="千米",Ai="公里",Si="㎡",Ii="平方厘米",Ti="㎡",zi="平方米",Ri="km²",Oi="平方千米",Fi="平方公里",Li="亩",Bi="公顷",ki={cm:"cm²",m:"㎡",km:"km²","米":"平方米","千米":"平方千米","公里":"平方公里"},Ni=(e,t,i)=>t===i?e:e*Vi(i),Gi=(e,t,i)=>t===i?e:e*function(e){switch(e){case Si:return 1e4;case Ti:return 1;case Ri:return 1e-6;case Ii:return 1e4;case zi:return 1;case Oi:case Fi:return 1e-6;case Li:return.0015;case Bi:return 1e-4;default:return 1}}(i),Ui=e=>ki[e],Vi=e=>{switch(e){case Pi:return 1;case _i:case xi:return 100;case Di:return.001;case Mi:return 1;case Ei:case Ai:return.001;default:return 1}};const $i=(e,t,i,n,o)=>{i.push(...e.map((i,o)=>{const r=e[o+1];if(r){let e=t?xe(i,r):be(i,r);return e=Ni(e,"m",n),{value:Number(e.toFixed(2)),unit:n,position:Me([i,r]),positions:[i,r]}}return null}).filter(e=>e&&e.value>0))},Wi=e=>{if(2===e.length)return e;let[t,i]=e;return i||(i=Ui(t)),[t,i]},Hi={drawStart:{circle:"单击左键绘制圆的中心点,单机右键取消绘制。",rectangle:"单击左键绘制矩形左上角。",point:"单击左键结束绘制,单机右键取消绘制。","vertical-surface-line":"单击左键结束绘制,单机右键取消绘制。",default:"单击左键绘制第一个节点,单机右键取消绘制。"},drawMove:{circle:"单击左键确定圆的半径并结束绘制,单机右键取消绘制。",rectangle:"单击左键结束绘制,单机右键取消绘制。","vertical-line":"单击左键结束绘制,单机右键取消绘制。","vertical-surface-line":"单击左键结束绘制,单机右键取消绘制。",default:"单机左键绘制下一个节点,双击左键结束绘制,单机右键撤销上次绘制。"},pointEnter:"双击左键编辑节点。",drawEditMove:{default:"移动鼠标修改节点,单击左键确定修改,单机右键取消修改。"}},qi={point:{color:"rgba(255,255,0,0.8)",pixelSize:8,outlineColor:"rgba(255,255,255,0.8)",outlineWidth:2,disableDepthTestDistance:Number.POSITIVE_INFINITY},polyline:{width:2,color:"rgba(81,255,0,0.8)",depthFailColor:"rgba(255,0,0,0.5)"},polygon:{color:"rgba(255,255,54,0.3)",depthFailColor:"rgba(255,0,0,0.3)"}};class ji extends Oe{positions;drawData;appearanceTran;depthFailAppearance;linePrimitiveCollection;constructor(t){super(),this.drawData=t,this.positions=t.positions,this.linePrimitiveCollection=new e.PrimitiveCollection,this.setAppearance()}getGeometry(){const t=((t,i)=>{let n=t;if("vertical-surface-line"===i&&t.length>=1){const i=t[0],o=e.Cartographic.fromCartesian(i),r=e.Math.toDegrees(o.longitude),a=e.Math.toDegrees(o.latitude),s=0;n=[e.Cartesian3.fromDegrees(r,a,o.height),e.Cartesian3.fromDegrees(r,a,s)]}if("polygon"===i&&t.length>=2&&(n=[...t,t[0]]),"vertical-line"===i&&t.length>=2){const i=t[0],o=t[1],r=e.Cartographic.fromCartesian(i),a=e.Cartographic.fromCartesian(o).height,s=e.Math.toDegrees(r.longitude),l=e.Math.toDegrees(r.latitude);n=[e.Cartesian3.fromDegrees(s,l,r.height),e.Cartesian3.fromDegrees(s,l,a)]}if("circle"===i&&t.length>=2){const i=be(t[0],t[1]),o=e.Cartographic.fromCartesian(t[0]).height,r=new e.CircleOutlineGeometry({center:t[0],height:o,radius:i}),a=e.CircleOutlineGeometry.createGeometry(r);let s=[];if(a){const t=[].slice.call(a.attributes.position.values);s=e.Cartesian3.unpackArray(t),s.push(s[0]),n=s}}if("rectangle"===i&&t.length>=2){const i=e.Cartographic.fromCartesian(t[0]).height,o=e.Rectangle.fromCartesianArray(t),r=new e.RectangleOutlineGeometry({rectangle:o,height:i}),a=e.RectangleOutlineGeometry.createGeometry(r);let s=[];if(a){const t=[].slice.call(a.attributes.position.values);s=e.Cartesian3.unpackArray(t),s.push(s[0]),n=s}}return n})(this.positions,this.drawData.shape);if(this.drawData.shapePositions=t,"vertical-line"===this.drawData.shape||"vertical-surface-line"===this.drawData.shape){const e=this.drawData.pointPrimitives.get(1);e&&(e.position=this.drawData.shapePositions[1])}if(!(t.length<2))return this.drawData.clampToGround?new e.GroundPolylineGeometry({positions:t,width:qi.polyline.width}):new e.PolylineGeometry({positions:t,width:qi.polyline.width})}getPrimitive(){if(!this.drawData.isEditing)return this._primitive;const t=this.getGeometry();if(!t)return;const i=new e.GeometryInstance({geometry:t,id:this.drawData.id});return t?this.drawData.clampToGround?new e.GroundPolylinePrimitive({geometryInstances:i,appearance:this.appearance,asynchronous:!1}):(this.linePrimitiveCollection.removeAll(),this.linePrimitiveCollection.add(new e.Primitive({geometryInstances:i,appearance:this.appearance,asynchronous:!1})),this.linePrimitiveCollection.add(new e.Primitive({geometryInstances:i,appearance:this.appearanceTran,depthFailAppearance:this.drawData.disDepthFail?void 0:this.depthFailAppearance,asynchronous:!1})),this.linePrimitiveCollection):void 0}setAppearance(t){t?this.appearance=t:(this.appearance=new e.PolylineMaterialAppearance({material:new e.Material({fabric:{type:"Color",uniforms:{color:e.Color.fromCssColorString(qi.polyline.color)}}})}),this.appearanceTran=new e.MaterialAppearance({material:new e.Material({fabric:{type:"Color",uniforms:{color:new e.Color(0,0,0,0)}}})}),this.depthFailAppearance=new e.PolylineMaterialAppearance({material:e.Material.fromType(e.Material.PolylineDashType,{color:e.Color.fromCssColorString(qi.polyline.depthFailColor)})}))}}class Zi extends Oe{positions;drawData;depthFailAppearance;constructor(e){super(),this.drawData=e,this.positions=e.positions,this.setAppearance()}getPrimitive(){if(!this.drawData.isEditing)return this._primitive;if(this.positions.length<3)return;const t=JSON.parse(JSON.stringify(this.positions)),i=[new e.GeometryInstance({geometry:new e.PolygonGeometry({polygonHierarchy:new e.PolygonHierarchy(t),perPositionHeight:!0}),id:`${this.drawData.id}-polygon`})];return this.drawData.clampToGround?new e.GroundPrimitive({geometryInstances:i,appearance:this.appearance,asynchronous:!1}):new e.Primitive({geometryInstances:i,appearance:this.appearance,depthFailAppearance:this.drawData.disDepthFail?void 0:this.depthFailAppearance,asynchronous:!1})}setAppearance(){this.appearance=new e.MaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.fromCssColorString(qi.polygon.color)})}),this.depthFailAppearance=new e.MaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.fromCssColorString(qi.polygon.depthFailColor)})})}}class Yi extends Oe{positions;drawData;depthFailAppearance;primitiveCollection;constructor(t){super(),this.drawData=t,this.positions=t.positions,this.primitiveCollection=new e.PrimitiveCollection,this.setAppearance()}getPrimitive(){if(!this.drawData.isEditing)return this._primitive;if(this.positions.length<2)return;this.primitiveCollection.removeAll();const t=JSON.parse(JSON.stringify(this.positions)),i=this.drawData.clampToGround?xe(t[0],t[1]):be(t[0],t[1]);if(!i)return;const n=e.Cartographic.fromCartesian(t[0]).height,o=[new e.GeometryInstance({geometry:new e.CircleGeometry({center:t[0],height:n,radius:i}),id:`${this.drawData.id}`})];return this.drawData.clampToGround?this.primitiveCollection.add(new e.GroundPrimitive({geometryInstances:o,appearance:this.appearance,asynchronous:!1})):this.primitiveCollection.add(new e.Primitive({geometryInstances:o,appearance:this.appearance,depthFailAppearance:this.drawData.disDepthFail?void 0:this.depthFailAppearance,asynchronous:!1})),this.primitiveCollection}setAppearance(){this.appearance=new e.MaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.fromCssColorString(qi.polygon.color)})}),this.depthFailAppearance=new e.MaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.fromCssColorString(qi.polygon.depthFailColor)})})}}class Ki extends Oe{positions;drawData;depthFailAppearance;primitiveCollection;constructor(t){super(),this.drawData=t,this.positions=t.positions,this.primitiveCollection=new e.PrimitiveCollection,this.setAppearance()}getPrimitive(){if(!this.drawData.isEditing)return this._primitive;if(this.positions.length<2)return this.primitiveCollection;this.primitiveCollection.removeAll();const t=JSON.parse(JSON.stringify(this.positions));t.length=2;const i=e.Cartographic.fromCartesian(t[0]).height,n=e.Rectangle.fromCartesianArray(t),o=[new e.GeometryInstance({geometry:new e.RectangleGeometry({rectangle:n,height:i}),id:`${this.drawData.id}`})];return this.drawData.clampToGround?this.primitiveCollection.add(new e.GroundPrimitive({geometryInstances:o,appearance:this.appearance,asynchronous:!1})):this.primitiveCollection.add(new e.Primitive({geometryInstances:o,appearance:this.appearance,depthFailAppearance:this.drawData.disDepthFail?void 0:this.depthFailAppearance,asynchronous:!1})),this.primitiveCollection}setAppearance(){this.appearance=new e.MaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.fromCssColorString(qi.polygon.color)})}),this.depthFailAppearance=new e.MaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.fromCssColorString(qi.polygon.depthFailColor)})})}}class Xi extends Oe{drawData;labelCollection;measureDivs;cesiumWidget;viewer;constructor(t,i){super(),this.viewer=i,this.cesiumWidget=i._element.getElementsByClassName("cesium-widget")[0],this.drawData=t,this.labelCollection=new e.LabelCollection({scene:i.scene}),this.drawData.measureLabel&&this.setAppearance(),this.measureDivs=[],this.renderDivPosition()}getPrimitive(){return this.drawData.isEditing&&this.drawData.measureLabel?"point"===this.drawData.shape?(this.updatePointDivLabel(),this.labelCollection):this.drawData.shapePositions.length>=2?(this.updateUnit(this.drawData.measureUnit),this.labelCollection):void 0:this.labelCollection}updateUnit(e){if("point"===this.drawData.shape)return;this.drawData.measureUnit=e,this.clearAllDiv();const t=(e=>{let{shapePositions:t,positions:i,shape:n,clampToGround:o,measureUnit:r}=e;t||(t=i),o||(o=!1);const[a,s]=Wi(r),l=Ui(a);e.measureUnit=[a,s];const c=[];if("polyline"===n&&($i(i,o,c,a),c.push({value:0,unit:a,position:i[0],positions:i,prefixText:"起点"}),c.push({value:Number(c.reduce((e,t)=>e+t.value,0).toFixed(2)),unit:a,position:i[i.length-1],positions:i})),"vertical-line"!==n&&"vertical-surface-line"!==n||($i(t,o,c,a),c.length&&(c[0].position=t[0])),"polygon"===n){$i(t,o,c,a);const e=Gi(De(t),l,s);c.push({value:Number(e.toFixed(2)),unit:s,position:Me(t),positions:t})}if("rectangle"===n){$i(t,o,c,a);const e=Gi(De(t),l,s);c.push({value:Number(e.toFixed(2)),unit:s,position:Me(t),positions:t})}if("circle"===n){const e=o?xe(i[0],i[1]):be(i[0],i[1]);c.push({value:Number(Ni(e,"m",a).toFixed(2)),unit:a,position:i[1],positions:i,prefixText:"半径"});const t=Gi(e*e*Math.PI,a,s);e>0&&c.push({value:Number(t.toFixed(2)),unit:s,position:i[0],positions:i})}return c})(this.drawData);this.drawData.measureResult=t,t.forEach((e,t)=>{let i="";e.prefixText?(i=`${e.prefixText}`,e.value&&(i+=`:${e.value}${e.unit}`)):i+=`${e.value}${e.unit}`;const n=this.createDiv(`measure-label-${this.drawData.id}-${t}`,i);this.measureDivs.push({position:e.position,divEle:n})})}updatePointDivLabel(){this.clearAllDiv(),this.drawData.positions.forEach(e=>{const t=Ne(e),i=this.createDiv(`measure-label-${this.drawData.id}-0`,`经度:${t.longitude.toFixed(6)}\n纬度:${t.latitude.toFixed(6)}\n高度:${t.height.toFixed(6)}`);this.measureDivs.push({position:e,divEle:i})})}renderDivPosition(){this.viewer.scene.postRender.addEventListener(()=>{this.measureDivs.forEach(e=>{const t=this.viewer.scene.cartesianToCanvasCoordinates(e.position);if(t){e.divEle.style.display="block";const i=e.divEle.getBoundingClientRect();e.divEle.style.left=t.x-i.width/2+"px",e.divEle.style.top=t.y-i.height+"px"}else e.divEle.style.display="none"})})}destroy(){super.destroy(),this.clearAllDiv()}setAppearance(){}clearAllDiv(){this.measureDivs.forEach(e=>{e.divEle.remove()}),this.measureDivs=[]}createDiv(e,t,i=48){const n=`\n <div style="\n background: rgba(0, 0, 0, 0.6);\n color: white;\n border-radius: 5px;\n padding: 0 10px 0 10px;\n font-size: 14px;\n white-space: nowrap;\n pointer-events: none;\n ">\n ${t.split("\n").map(e=>`\n <div style="height: 24px; line-height: 24px">\n ${e}\n </div>\n `).join(" ")}\n </div>\n <div style="\n height: ${i}px;\n width: 2px;\n background: rgba(0, 0, 0, 0.6);\n margin: auto;\n ">\n </div>\n `,o=document.createElement("div");return o.id=e,o.innerHTML=n,o.style.position="absolute",o.style.pointerEvents="none",o.className=`measure-label measure-label-${this.drawData.id}`,this.cesiumWidget.appendChild(o),o}}const Ji="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAQBJREFUWEft2MsNgkAQBuAZtABCBctBErvATryiRRibkKudGKvgwMFtQGIBumOAYAxCArsTs4fZ8w758032wSJ4PtDzfCABXTvEKhjmhXpka+0a6rueNWB0KgmAdLVLYq6QbAHDvEwDgksdzOAz5pKUgK6tFkERnCogq3iq1Ng8ERRBS4HBjTrKywMAqjnfJCKFAGlTg3ieU9vOJV1lq2O/bjhgcyv59yBt8LXpXzLYBFsE2toKojHX+z75kWc8iwsV0PLm8XVLArotivp/RFrsYiiCLnp1rQiKoKWAHHWWcJ8yZsFF8zbj5eNRt9VwPRp1hGyCrq0cq5eArrLeC74BlkT4KR3TrCoAAAAASUVORK5CYII=",Qi="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAY9JREFUWEftmNFRwzAMhiVYAMoC5Y50jjAJ9LFliMIQNI/NJtA1CA9hAHIsgMWZYC5xHVtNajcHzqtl+ctvSZaNMPIPR84HEXDoDv1tBc/XxRMCpFaVEPNqcTXvq6RTwbOsSE8FTfUFBOKNE05NQsxRiK3u4/MEy49F8myDdwJOstcNEN32VWCouhHQu4JetnYPp84tVr4uHl8OGofvd7Ocw8kGnKwL4jjk2lTLhLU2y0guGgE7pI8KdsVkuBhEzDtPGstYEEAkmstyMcmKFRDcN9WyjUk774AKQEE1IW1jyt47IACV1XJ22VRNQqKgN70Im9qyAIASbRdST4qunjEQoB3S1tAGBATQY05iy7ObEDdHLzMmOFPi6KBBFLTBuSC9A5rg6pijqSm79TrpHRC021o7IdrZfbwy8wNpztYacgRlhtuitu38b3E/rt9Z/w+Q9czBVtV9RCpX7I7adTKw2QBAIFy7njz2Bvy+OGXFighS9pvMDjWVdXlKHrg/xFaQ6/DQdhFwqKJRwaEKfgEJRgs46ima/wAAAABJRU5ErkJggg==",en="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAMdJREFUWEdjZBjkgHGQu49h1IGUxtBoCI6GIKUhQKn+0TQ4GoKUhgCl+kfT4GgIUhoClOofTYM0DUGh6bfrGRgYFSi1BJ9+xn//Dr7NVluASw3eKBaadvs/LR0HM/sfI4Pjh0zVA9jswulAgenXFZj+s9ynjwP/KH7I1HxAkgNBioWn3kr4z8RkT1tH/n/wLlO1kawopq3DiDN9tJghLpxwqxoNwdEQpDQEKNU/mgZHQ5DSEKBU/2gaHA1BSkOAUv2jaXDYhyAAbjwcKU1UyjYAAAAASUVORK5CYII=",tn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAkJJREFUWEftl19SwkAMxpPCARAvgDPijKewnER4BA8hHEJ5FE8CnsIZccZ6AJEDMF1Ny5Zu/6bNMvQBXmk3vyZfvmQRGv7DhvPBGVBaIasZ7M4/XwhoM74eScH0+9YAAzilhuHByttMbq5sQFoBNOE0lh1IMeDF83qJAG52tuSQIsBiODuZrA14+fQxVIhBUwSqA1hFmURcHPQIAIiLuo1TG5CguvP14z/Z1EcYtHzVi4ARpj7sXh3V/iLw30l/ULdhRIAUtDN/723Ht56RUYTpZtyf6f/qwtF7YkAdPAtQAmbdB08KSMF/Hm4WRRmpCkjeyWmc0hJHVlLSiaQ3gHYv/IidR7rM+6CDPZX7ZCFg0ueoW7fj/kqiLfoQ6u7DGcWQuYDHgNNQVSAzAZNwgQkjpDJHXldUSm1DDrTv01nHnmHmOQtGCpA3vsJwnJJ35mvXUbBkySJD5ylAPR04B54EMD7C4kJGBbMkdJn16BK3/FZq21GOc8eZ17lNYmZSeeHA76cgOZlOPpMse9G8zgUMOo3ErWC631c8H3Fk22bKlolCHzQgLRq1rk4ZHGtZIEjSUJneqo46zvhkAXI1VhWQe27pLOYe1FhAXapGLqzhddN3yYLQV9/myg9vwQQR3EdEGkz6pAL09KXJuECFUYIrAFcu8edqazDtk9nhOVZSBF4b0NhUIjM3Q0nhRCU2djtj4uznjvC6qc8XZTCer7gmbWTOOqDegpQCV3JRT+rRWgbrdCjnnTMgJ0tHsxlpcM77f6iGZThXF5iUAAAAAElFTkSuQmCC";class nn{static editUI;_editUi;viewer;_editUiPosition=null;_editPointPrimitive=null;_drawEditEvent;elementId="draw-edit-ui";constructor(e,t){this._editUi=null,this.viewer=e,this.create(),this.setVisible(!1),this.renderPosition(),this._drawEditEvent=t}create(){if(this._editUi=document.getElementById(this.elementId),this._editUi)return this._editUi;const e=document.createElement("DIV");e.id=this.elementId,e.className="draw-edit-ui";const t=document.createElement("DIV");t.title="点击移动节点";const i=document.createElement("img");i.src=tn,i.className="draw-edit-icon",t.appendChild(i),t.addEventListener("click",()=>{this._drawEditEvent.drawEditMove&&this._drawEditEvent.drawEditMove(this._editPointPrimitive)});const n=document.createElement("DIV");n.id="addPoint";const o=document.createElement("img");o.src=Ji,o.title="点击添加节点",o.className="draw-edit-icon",n.appendChild(o),n.addEventListener("click",()=>{this._drawEditEvent.drawEditAdd&&this._drawEditEvent.drawEditAdd(this._editPointPrimitive)});const r=document.createElement("DIV"),a=document.createElement("img");r.id="removePoint",a.src=en,a.title="点击删除节点",a.className="draw-edit-icon",r.appendChild(a),r.addEventListener("click",()=>{this._drawEditEvent.drawEditRemove&&this._drawEditEvent.drawEditRemove(this._editPointPrimitive)});const s=document.createElement("DIV"),l=document.createElement("img");l.src=Qi,l.title="点击删除绘制",l.className="draw-edit-icon",s.appendChild(l),s.addEventListener("click",()=>{this._drawEditEvent.drawDelete&&this._drawEditEvent.drawDelete(this._editPointPrimitive)}),e.appendChild(t),e.appendChild(n),e.appendChild(r),e.appendChild(s),document.body.appendChild(e),this._editUi=e}setAddElementStatus(e){const t=document.getElementById("addPoint"),i=document.getElementById("removePoint");t&&(t.style.display=e?"block":"none"),i&&(i.style.display=e?"block":"none")}static createEditUi(e,t){return nn.editUI||(nn.editUI=new nn(e,t)),nn.editUI}showAt(e,t,i){this.setVisible(!0),this._editUiPosition=e,this._editPointPrimitive=t,this.setAddElementStatus(!["point","circle","rectangle","vertical-line"].includes(i))}setVisible(e){this._editUi&&(this._editUi.style.display=e?"flex":"none")}renderPosition(){this.viewer.scene.postRender.addEventListener(()=>{if(this._editUiPosition&&this._editUi&&"flex"===this._editUi.style.display){const e=this.viewer.scene.cartesianToCanvasCoordinates(this._editUiPosition);this._editUi.style.position="fixed",this._editUi.style.top=e.y-28+"px",this._editUi.style.left=`${e.x+15}px`}})}destroy(){nn.editUI&&(this._editUi&&this._editUi.parentNode.removeChild(this._editUi),this._editUi=null)}}const on=t=>{let i;const n=[];let o=new e.Cartesian3(0,0,0);const r=[];let a,s,l,c;const d=qi.point;let u=!1;((t,i)=>{const n=t.scene,o=new e.ScreenSpaceEventHandler(n.canvas);let r;t.cesiumWidget.screenSpaceEventHandler.removeInputAction(e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),o.setInputAction(e=>{const o=n.pickPosition(e.position),a=(new Date).getTime();if(r&&a-r<270){const n=t.scene.pick(e.position);return void i(wi.DRAW_DB_CLICK,{position:o,pickPrimitive:n?.primitive,windowPosition:e.position})}i(wi.DRAW_ADD,{position:o}),r=(new Date).getTime()},e.ScreenSpaceEventType.LEFT_CLICK),o.setInputAction(e=>{const o=t.scene.pick(e.endPosition),r=n.pickPosition(e.endPosition);i(wi.DRAW_MOVE,{position:r,pickPrimitive:o?.primitive,windowPosition:e.endPosition}),o&&i(wi.DRAW_PICK,{position:r,pickPrimitive:o?.primitive,windowPosition:e.endPosition})},e.ScreenSpaceEventType.MOUSE_MOVE),o.setInputAction(()=>{i(wi.DRAW_RIGHT_CLICK,{})},e.ScreenSpaceEventType.RIGHT_CLICK)})(t,(e,t)=>{a&&(["drawDbClick","drawPick","drawMove","drawRightClick"].includes(e)||a.isEditing)&&w[e]?.(t)});const p=new e.PrimitiveCollection;p.destroyPrimitives=!1,t.scene.primitives.add(p);const h=e=>{const t=r.findIndex(t=>t.id===e),i=r[t];i.positions.length=0,r.splice(t,1),z.drawRemove&&z.drawRemove(i),setTimeout(()=>{i.measurePrimitive?.clearAllDiv(),p.remove(i?.primitives)},300)},m=()=>{t._element.style.cursor="default",o=new e.Cartesian3(0,0,0),a.positions.pop(),a.isDisAdd=!0,setTimeout(()=>{a.isEditing=!1,a.isDisAdd=!1,z.drawEnd&&z.drawEnd(a),a={}},300),s=void 0,l&&(a.pointPrimitives.remove(l),l=void 0),P()},f=e=>{const t=new ji(e);e.primitives.add(t)},g=e=>{const t=new Zi(e);e.primitives.add(t)},v=e=>{const t=new Yi(e);e.primitives.add(t)},y=e=>{const t=new Ki(e);e.primitives.add(t)},C=e=>{const i=new Xi(e,t);e.primitives.add(i),e.measurePrimitive=i,e.primitives.raiseToTop(i)},w={drawAdd:({position:e})=>{if(a.positions.push(e),u=!1,E.id)return z.drawEditEnd&&z.drawEditEnd(a),E.id="",void m();const t=T(e,a);z.drawAdd&&z.drawAdd(e,a),"point"!==a.shape&&"vertical-surface-line"!==a.shape||m(),"vertical-line"===a.shape&&a.positions.length<=2&&n.push(t.id),["circle","rectangle","vertical-line"].includes(a.shape)&&a.positions.length>2&&("vertical-line"===a.shape&&(t.position=l.position),m())},drawMove:({position:e,windowPosition:t})=>{if(u=!0,D(),e&&!a.isDisAdd&&a.isEditing){if(P(t),E.id)a.positions.splice(E.index,1,e),E.pointPrimitive.position=e;else{const t=a.positions.findIndex(e=>e.x===o.x&&e.y===o.y&&e.z===o.z);a.positions.push(e),-1!==t&&a.positions.splice(t,1),l&&a.pointPrimitives.remove(l),l=T(e,a)}o=e,z.drawMove&&z.drawMove(e,a)}},drawPick:({pickPrimitive:t,windowPosition:i})=>{a.isEditing||t instanceof e.PointPrimitive&&_(t,i)},drawDbClick:({position:e,windowPosition:t,pickPrimitive:i})=>{a.isEditing?m():!a.isEditing&&i&&x(e,t,i)},drawRightClick:()=>{a.isEditing?(()=>{if(E.id)return E.id="",a.isDisAdd=!0,a.isEditing=!0,E.originPosition?(a.positions.splice(E.index,1,E.originPosition),E.pointPrimitive.position=E.originPosition):a?.positions.splice(E.index,1),z.drawEditEnd&&z.drawEditEnd(a),setTimeout(()=>{a.isEditing=!1,a.isDisAdd=!1},300),o=new e.Cartesian3(0,0,0),s=void 0,void P();if(["polyline","polygon"].includes(a.shape)&&a.positions.length>2){const e=u?2:1,t=a.pointPrimitives.get(a.positions.length-e);return a.pointPrimitives.remove(t),void a?.positions.splice(a.positions.length-e,1)}o=new e.Cartesian3(0,0,0),s=void 0,h(a.id),a={},P()})():i.setVisible(!1)}},_=(e,i)=>{const o=e.id.split("-")[0],a=r.find(e=>e.id===o);n.includes(e.id)||a&&a.edit&&(t._element.style.cursor="pointer",e.pixelSize=1.5*d.pixelSize,e.outlineWidth=1.5*d.outlineWidth,s=e,c.showAt(i,Hi.pointEnter),c.setVisible(!0))},x=(t,o,a)=>{if(a instanceof e.PointPrimitive){if(n.includes(a.id))return;const e=a.id.split("-")[0],o=r.find(t=>t.id===e);if(!o)return;if(!o.edit)return;i.showAt(t,a,o.shape),z.drawEditStart&&z.drawEditStart(o)}},P=e=>{if(c)return e&&a.positions?void(E.id?c.showAt(e,Hi.drawEditMove[a.shape]||Hi.drawEditMove.default):a.positions.length>1?c.showAt(e,Hi.drawMove[a.shape]||Hi.drawMove.default):c.showAt(e,Hi.drawStart[a.shape]||Hi.drawStart.default)):(t._element.style.cursor="default",void c.setVisible(!1));t._element.style.cursor="default"},D=()=>{s&&(s.pixelSize=d.pixelSize,s.outlineWidth=d.outlineWidth,P())},E={},A={drawEditAdd:n=>{i.setVisible(!1);const{id:o,index:r,drawData:s}=S(n),l=new e.Cartesian3(n.position.x,n.position.y,n.position.z);s?.positions.splice(r,0,l),a=s;const c=T(l,a);t._element.style.cursor="move",Object.assign(E,{id:o,index:r+1,pointPrimitive:c,originPosition:l}),a.isEditing=!0},drawEditMove:n=>{i.setVisible(!1),t._element.style.cursor="move";const{id:o,index:r,drawData:s}=S(n);a=s,Object.assign(E,{id:o,index:r,pointPrimitive:n,originPosition:new e.Cartesian3(n.position.x,n.position.y,n.position.z)}),a.isEditing=!0},drawEditRemove:e=>{i.setVisible(!1);const{index:t,drawData:n}=S(e);n.isEditing=!0,n.isDisAdd=!0,n?.positions.splice(t,1),n?.pointPrimitives.remove(e),z.drawEditEnd&&z.drawEditEnd(n),setTimeout(()=>{n.isEditing=!1,n.isDisAdd=!1},300)},drawDelete:e=>{i.setVisible(!1);const{id:t}=S(e);h(t)}};i=nn.createEditUi(t,A);const S=e=>{const t=e.id.split("-")[0],i=r.find(e=>e.id===t),n=i.positions.findIndex(t=>t.x===e.position.x&&t.y===e.position.y&&t.z===e.position.z);return{id:t,drawData:i,index:n}},I=t=>{const i=new e.PrimitiveCollection,n=new e.PointPrimitiveCollection;i.add(n);const o={id:b(),edit:t.edit||!1,measure:t.measure||!1,measureLabel:t.measureLabel||!1,disDepthFail:t.disDepthFail||!1,measureUnit:t.measureUnit||["m"],isEditing:!0,shape:t.shape,positions:[],clampToGround:t.clampToGround,pointPrimitives:n,primitives:i};return p.add(i),o},T=(t,i)=>i.pointPrimitives.add({id:`${i.id}-${b()}`,position:t,...d,color:e.Color.fromCssColorString(d.color),outlineColor:e.Color.fromCssColorString(d.outlineColor)}),z={};return{draw:e=>{t._element.style.cursor="crosshair",c=M.createToolTip(t),s=void 0;const i=I(e);a=i,z.drawStart&&z.drawStart(i),r.push(i),e.shape,"polyline"===e.shape&&f(i),"vertical-line"===e.shape&&(i.clampToGround=!1,f(i)),"vertical-surface-line"===e.shape&&(i.clampToGround=!1,f(i)),"polygon"===e.shape&&(g(i),f(i)),"circle"===e.shape&&(f(i),v(i)),"rectangle"===e.shape&&(f(i),y(i)),e.measure&&C(i),i.primitives.raiseToTop(i.pointPrimitives)},remove:e=>{h(e.id)},removeAll:()=>{r.forEach(e=>{e.measurePrimitive?.clearAllDiv()}),p.removeAll(),r.length=0},setDrawStyle:e=>{Object.assign(qi.point,e.point),Object.assign(qi.polyline,e.polyline),Object.assign(qi.polygon,e.polygon)},Event:z,updateMeasureUnit:(e,t)=>{if(-1===r.findIndex(t=>t.id===e.id))throw new Error("绘制对象不存在");const i=e.primitives._primitives.find(e=>e instanceof Xi);i&&i.updateUnit(t)}}};var rn=Object.freeze({__proto__:null});const an={PolylineFlow:"PolylineFlow",PolylineTrail:"PolylineTrail",CircleWave:"CircleWave",CircleRaderWave:"CircleRaderWave",CircleRaderFan:"CircleRaderFan",LightWall:"LightWall",CircleAperture:"CircleAperture",RadarScanCircle:"RadarScanCircle",EllipsoidElectric:"EllipsoidElectric",EllipsoidScan:"EllipsoidScan",Corridor:"Corridor",Zaps:"Zaps"};(()=>{for(const t in an)e.Material[t]=an[t]})();const sn={color:"rgba(255,255,255,1)",speed:6*Math.random()};class ln extends Fe{speed;color;name="";image="";constructor(t){super(),this.createPropertyDescriptors();const i={...sn,...t};this.image=i.image,this.name=`${an.PolylineTrail}-${b()}`,this.color=e.Color.fromCssColorString(i.color),this.speed=i.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,i){return e.defined(i)||(i={}),i.color=e.Property.getValueOrClonedDefault(this.color,t,e.Color.WHITE,i.color),i.speed=this.speed,i.image=this.image,i}equals(t){return this===t||t instanceof ln&&this.speed===t.speed&&e.Property.equals(this.color,t.color)&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{image:this.image,color:e.Color.fromCssColorString("#ff0000"),speed:this.speed},source:dn},translucent:()=>!0})}createPropertyDescriptors(){Object.defineProperties(this,{color:e.createPropertyDescriptor("color")})}}const cn=t=>{const i={...sn,...t};return new e.Material({fabric:{type:`${an.PolylineTrail}-${b()}`,uniforms:{color:e.Color.fromCssColorString(i.color),image:i.image,speed:i.speed},source:dn},translucent:!0})},dn="\n uniform sampler2D image;\n uniform vec4 color;\n uniform float speed;\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float time = fract(czm_frameNumber * speed / 1000.0);\n vec4 colorImage = texture(image,st);\n vec3 fragColor = color.rgb;\n if(st.t > 0.45 && st.t < 0.55 ) {\n fragColor = vec3(1.0);\n }\n if(color.a == 0.0){\n material.alpha = colorImage.a * 1.5 * fract(st.s - time);\n material.diffuse = colorImage.rgb;\n }else{\n material.alpha = colorImage.a * color.a * 1.5 * smoothstep(.0,1., fract(st.s - time));\n material.diffuse = max(fragColor.rgb * material.alpha , fragColor.rgb);\n }\n return material;\n }\n\n",un={color:"rgba(255,255,255,1)",speed:6,repeatCount:4,blendColor:!0};class pn extends Fe{repeatCount;image;speed;color;blend;name="";constructor(t){super(),this.createPropertyDescriptors();const i={...un,...t};this.name=`${an.PolylineFlow}-${b()}`,this.color=e.Color.fromCssColorString(i.color),this.speed=i.speed,this.image=i.image,this.repeatCount=i.repeatCount,this.blend=i.blendColor?1:0,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,i){return e.defined(i)||(i={}),i.color=e.Property.getValueOrClonedDefault(this.color,t,e.Color.WHITE,i.color),i.image=this.image,i.blend=this.blend,i.speed=this.speed,i.repeatCount=this.repeatCount,i}equals(e){return this===e||e instanceof pn&&this.speed===e.speed&&this.repeatCount===e.repeatCount&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:e.Color.fromCssColorString("#ffffff"),image:"",speed:this.speed,count:this.repeatCount,blend:this.blend},source:mn},translucent:()=>!0})}createPropertyDescriptors(){Object.defineProperties(this,{color:e.createPropertyDescriptor("color")})}}const hn=t=>{const i={...un,...t};return new e.Material({fabric:{type:an.PolylineFlow+b(),uniforms:{color:e.Color.fromCssColorString(i.color),image:i.image,speed:i.speed,count:i.repeatCount,blend:i.blendColor?1:0},source:mn},translucent:!0})},mn="\n uniform vec4 color;\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n float time = fract(czm_frameNumber * speed / 1000.0);\n vec2 st = materialInput.st;\n vec4 colorImage = texture(image, vec2(fract( count * st.s - time),fract(st.t)));\n material.alpha = colorImage.a * color.a;\n if(blend > 0.5) {\n material.diffuse = (colorImage.rgb + color.rgb) * 2.0;\n } else {\n material.diffuse = color.rgb * 2.0 ;\n }\n return material;\n }\n",fn={color:"rgba(255,255,0,0.3)",speed:8,count:5,gradient:.3};class gn extends Fe{count;speed;gradient;color;name="";constructor(t){super(),t||(t={});const i={...fn,...t};this.name=`${an.CircleWave}-${b()}`,this.color=e.Color.fromCssColorString(i.color),this.speed=i.speed,this.count=i.count,this.gradient=i.gradient,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,i){return e.defined(i)||(i={}),i.color=this.color,i.speed=this.speed,i.repeatCount=this.count||fn.count,i}equals(t){return this===t||t instanceof gn&&e.Property.equals(this.color,t.color)&&this.speed===t.speed&&this.count===t.count&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:new e.Color(1,0,0,.5),speed:this.speed,count:this.count,gradient:this.gradient},source:yn},translucent:()=>!0})}}const vn=t=>{const i={...fn,...t};return{material:new e.Material({fabric:{type:`${an.CircleWave}-${b()}`,uniforms:{color:e.Color.fromCssColorString(i.color),speed:i.speed,count:i.count,gradient:i.gradient},source:yn},translucent:!0})}},yn="\n uniform vec4 color;\n uniform float speed;\n uniform float count;\n uniform float gradient;\n\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n material.diffuse = 1.5 * color.rgb;\n vec2 st = materialInput.st;\n float dis = distance(st, vec2(0.5, 0.5));\n float per = fract(czm_frameNumber * speed / 1000.0);\n if(count == 1.0){\n if(dis > per * 0.5){\n discard;\n }else {\n material.alpha = color.a * dis / per / 2.0;\n }\n } else {\n vec3 str = materialInput.str;\n if(abs(str.z) > 0.001){\n discard;\n }\n if(dis > 0.5){\n discard;\n } else {\n float perDis = 0.5 / count;\n float disNum;\n float bl = 0.0;\n for(int i = 0; i <= 999; i++){\n if(float(i) <= count){\n disNum = perDis * float(i) - dis + per / count;\n if(disNum > 0.0){\n if(disNum < perDis){\n bl = 1.0 - disNum / perDis;\n }\n else if(disNum - perDis < perDis){\n bl = 1.0 - abs(1.0 - disNum / perDis);\n }\n material.alpha = pow(bl,(1.0 + 10.0 * (1.0 - gradient)));\n }\n }\n }\n }\n }\n return material;\n }\n",Cn={color:"rgba(255,255,255,1)",speed:8};class wn extends Fe{speed;color;name="";constructor(t){super();const i={...Cn,...t};this.name=`${an.CircleRaderWave}-${b()}`,this.color=e.Color.fromCssColorString(i.color),this.speed=i.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,i){return e.defined(i)||(i={}),i.speed=this.speed,i}equals(e){return this===e||e instanceof wn&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:_n},translucent:()=>!0})}}const bn=t=>{const i={...Cn,...t};return{material:new e.Material({fabric:{type:`${an.CircleRaderWave}-${b()}`,uniforms:{color:e.Color.fromCssColorString(i.color),speed:i.speed},source:_n},translucent:!0})}},_n="\n uniform vec4 color;\n uniform float speed;\n #define PI 3.14159265359\n float rand(vec2 co){\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n }\n\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n vec2 pos = st - vec2(0.5);\n float time = czm_frameNumber * speed / 1000.0 ;\n float r = length(pos);\n float t = atan(pos.y, pos.x) - time * 2.5;\n float a = (atan(sin(t), cos(t)) + PI)/(2.0*PI);\n float ta = 0.5;\n float v = smoothstep(ta-0.05,ta+0.05,a) * smoothstep(ta+0.05,ta-0.05,a);\n vec3 flagColor = color.rgb * v;\n float blink = pow(sin(time*1.5)*0.5+0.5, 0.8);\n flagColor = color.rgb * pow(a, 4.0*(.2+blink))*(sin(r*500.0)*.5+.5) ;\n flagColor = flagColor * pow(r, 0.4);\n material.alpha = length(flagColor) * 1.3;\n material.diffuse = flagColor * 3.0;\n return material;\n }\n",xn={name:"circle-fan",color:"rgba(255,255,255,1)",speed:8};class Pn extends Fe{speed;color;name="";constructor(t){super();const i={...xn,...t};this.name=`${an.CircleRaderFan}-${b()}`,this.color=e.Color.fromCssColorString(i.color),this.speed=i.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,i){return e.defined(i)||(i={}),i.speed=this.speed,i}equals(e){return this===e||e instanceof Pn&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:Dn},translucent:()=>!0})}}const Mn=t=>{const i={...xn,...t};return{material:new e.Material({fabric:{type:`${an.CircleRaderFan}-${b()}`,uniforms:{color:e.Color.fromCssColorString(i.color),speed:i.speed},source:Dn},translucent:!0})}},Dn="\n uniform vec4 color;\n uniform float speed;\n #define PI 3.14159265359\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n // 绘制边线\n float dis = distance(materialInput.st, vec2(0.5));\n float alpha = step((0.5- 0.01), dis);\n\n material.alpha = alpha;\n material.diffuse = color.rgb;\n\n // 绘制扇区\n vec2 xy = materialInput.st;\n float rx = xy.x - 0.5;\n float ry = xy.y - 0.5;\n float at = atan(ry, rx);\n float per = czm_frameNumber * speed / PI * 3.0 / 200.0;\n // 半径\n float radius = sqrt(rx * rx + ry * ry);\n // 扇区叠加旋转角度\n float current_radians = at + per;\n xy = vec2(cos(current_radians) * radius, sin(current_radians) * radius);\n xy = vec2(xy.x + 0.5, xy.y + 0.5);\n // 扇区渐变色渲染\n if (xy.y - xy.x < 0.0 && xy.x > 0.5 && xy.y > 0.5){\n material.alpha = (alpha + color.a) * dis;\n material.diffuse = color.rgb;\n }\n return material;\n }\n",En={color:"rgba(255,255,0,0.3)",speed:8};class An extends Fe{speed;color;name="";constructor(t){super(),t||(t={});const i={...En,...t};this.name=`${an.CircleAperture}-${b()}`,this.color=e.Color.fromCssColorString(i.color),this.speed=i.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,i){return e.defined(i)||(i={}),i.color=this.color,i.speed=this.speed,i}equals(t){return this===t||t instanceof An&&e.Property.equals(this.color,t.color)&&this.speed===t.speed&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:new e.Color(1,0,0,.5),speed:this.speed},source:In},translucent:()=>!0})}}const Sn=t=>{const i={...En,...t};return new e.Material({fabric:{type:`${an.CircleAperture}-${b()}`,uniforms:{color:e.Color.fromCssColorString(i.color),speed:i.speed},source:In},translucent:!0})},In="\n uniform vec4 color;\n uniform float speed;\n\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float d = distance(st, vec2(0.5, 0.5));\n float alpha = step(.15, d) * step(d, .17) + step(.49, d) * step(d, 0.5) + d * d * step(d, 0.5);\n float movingCircleD = fract(czm_frameNumber * speed / 1000.0);\n alpha += step(movingCircleD, d) * step(d, movingCircleD + .015);\n material.diffuse = color.rgb;\n material.alpha = alpha;\n return material;\n }\n",Tn=t=>{t||(t={});return new e.Material({fabric:{type:`${an.RadarScanCircle}-${b()}`,uniforms:{radians:3*Math.PI/8,bgColor:e.Color.fromCssColorString(t.bgColor||"rgba(0,255,0,0.2)"),sectorColor:e.Color.fromCssColorString(t.sectorColor||"rgba(152,18,8,.1)"),width:t.width||.003,offset:t.offset||0,count:t.count||3},source:zn},translucent:!0})},zn="\n uniform vec4 bgColor;\n uniform vec4 sectorColor;\n uniform float count;\n uniform float radians;\n uniform float width;\n uniform float offset;\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float dis = distance(st, vec2(0.5));\n\n float alpha;\n vec3 diffuse;\n // 绘制圆圈\n float sp = 1.0 / count / 2.0;\n float m = mod(dis, sp);\n alpha = step(sp * (1.0 - width * 10.0), m);\n // alpha = clamp(alpha, 0.2, 1.0);\n if (alpha < bgColor.a){\n alpha = bgColor.a;\n diffuse = bgColor.rgb;\n } else {\n diffuse = bgColor.rgb;\n }\n material.alpha = alpha;\n material.diffuse = diffuse;\n // 绘制十字线\n if ((st.s > 0.5 - width / 2.0 && st.s < 0.5 + width / 2.0) || (st.t > 0.5 - width / 2.0 && st.t < 0.5 + width / 2.0)) {\n material.alpha = 0.8;\n material.diffuse = bgColor.rgb;\n return material;\n }\n // 绘制光晕\n float ma = mod(dis + offset, 0.5);\n if (ma < 0.25){\n alpha = ma * 3.0 + alpha;\n } else{\n alpha = 3.0 * (0.5 - ma) + alpha;\n }\n material.alpha = alpha;\n material.diffuse = bgColor.rgb;\n // 绘制扇区\n vec2 xy = materialInput.st;\n float rx = xy.x - 0.5;\n float ry = xy.y - 0.5;\n float at = atan(ry, rx);\n // 半径\n float radius = sqrt(rx * rx + ry * ry);\n // 扇区叠加旋转角度\n float current_radians = at + radians;\n xy = vec2(cos(current_radians) * radius, sin(current_radians) * radius);\n xy = vec2(xy.x + 0.5, xy.y + 0.5);\n // 扇区渐变色渲染\n if (xy.y - xy.x < 0.0 && xy.x > 0.5 && xy.y > 0.5){\n material.alpha = alpha + sectorColor.a;\n material.diffuse = sectorColor.rgb;\n }\n return material;\n }\n",Rn={color:"rgba(255,255,255,1)",count:3,duration:1500};class On extends Fe{duration;count;vertical;direction;color;_time;image;name="";constructor(t){super();const i={...Rn,...t};Object.prototype.hasOwnProperty.call(i,"vertical")||(i.vertical=1),this.name=`LightWall-${b()}`,this._time=(new Date).getTime(),this.color=e.Color.fromCssColorString(i.color),this.duration=i.duration,this.count=i.count,this.vertical=i.vertical,this.image=i.image,this.direction=i.direction,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,i){return e.defined(i)||(i={}),i.color=this.color,i.image=this.image,i.vertical=this.vertical,i.direction=this.direction,i.count=this.count,i.duration=this.duration,this.duration&&(i.time=((new Date).getTime()-this._time)%this.duration/this.duration),i}equals(t){return this===t||t instanceof On&&e.Property.equals(this.color,t.color)&&this.name===t.name&&this.image===t.image&&this.vertical===t.vertical&&this.direction===t.direction&&this.count===t.count&&this.duration===t.duration}init(){const t=Ln({count:this.count,vertical:this.vertical,direction:this.direction});e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,duration:this.duration,vertical:this.vertical,image:this.image,count:this.count,time:-20},source:t},translucent:()=>!0})}}const Fn=t=>{const i={...Rn,...t};return{material:new e.Material({fabric:{type:`LightWall${b()}`,uniforms:{color:e.Color.fromCssColorString(i.color),duration:i.duration,vertical:i.vertical,image:i.image,count:i.count,time:-20},source:Ln({count:i.count,vertical:i.vertical,direction:i.direction})}})}},Ln=e=>{const t=e.vertical?"vertical":"standard",i=e.direction?"+":"-";let n="czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;";return n+="vertical"===t?`vec4 colorImage = texture(image, vec2(fract(float(${e.count})*st.t ${i} time)),fract(st.s));\n `:`vec4 colorImage = texture(image, vec2(fract(float(${e.count})*st.s ${i} time), fract(st.t)));\n `,n+="vec4 fragColor;\n fragColor.rgb = (colorImage.rgb+color.rgb) / 1.0;\n fragColor = czm_gammaCorrect(fragColor);\n material.diffuse = colorImage.rgb;\n material.alpha = colorImage.a * color.a;\n material.emission = fragColor.rgb;\n return material;\n }",n},Bn={name:"circle-fan",color:"rgba(255,255,255,1)",speed:8};class kn extends Fe{speed;color;name="";constructor(t){super();const i={...Bn,...t};this.name=`${an.EllipsoidElectric}-${b()}`,this.color=e.Color.fromCssColorString(i.color),this.speed=i.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,i){return e.defined(i)||(i={}),i.speed=this.speed,i}equals(e){return this===e||e instanceof kn&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:Gn},translucent:()=>!0})}}const Nn=t=>{const i={...Bn,...t};return{material:new e.Material({fabric:{type:`${an.EllipsoidElectric}-${b()}`,uniforms:{color:e.Color.fromCssColorString(i.color),speed:i.speed},source:Gn},translucent:!0})}},Gn="\n uniform vec4 color;\n uniform float speed;\n #define pi 3.1415926535\n #define PI2RAD 0.01745329252\n #define TWO_PI (2. * PI)\n\n float rands(float p){\n return fract(sin(p) * 10000.0);\n }\n\n float noise(vec2 p){\n float time = fract( czm_frameNumber * speed / 1000.0);\n float t = time / 20000.0;\n\n if(t > 1.0) t -= floor(t);\n return rands(p.x * 14. + p.y * sin(t) * 0.5);\n }\n\n vec2 sw(vec2 p){\n return vec2(floor(p.x), floor(p.y));\n }\n\n vec2 se(vec2 p){\n return vec2(ceil(p.x), floor(p.y));\n }\n\n vec2 nw(vec2 p){\n return vec2(floor(p.x), ceil(p.y));\n }\n\n vec2 ne(vec2 p){\n return vec2(ceil(p.x), ceil(p.y));\n }\n\n float smoothNoise(vec2 p){\n vec2 inter = smoothstep(0.0, 1.0, fract(p));\n float s = mix(noise(sw(p)), noise(se(p)), inter.x);\n float n = mix(noise(nw(p)), noise(ne(p)), inter.x);\n return mix(s, n, inter.y);\n }\n\n float fbm(vec2 p){\n float z = 2.0;\n float rz = 0.0;\n vec2 bp = p;\n for(float i = 1.0; i < 6.0; i++){\n rz += abs((smoothNoise(p) - 0.5)* 2.0) / z;\n z *= 2.0;\n p *= 2.0;\n }\n return rz;\n }\n\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n vec2 st2 = materialInput.st;\n float time = fract( czm_frameNumber * speed / 1000.0);\n if (st.t < 0.5) {\n discard;\n }\n st *= 4.;\n float rz = fbm(st);\n st /= exp(mod( time * 2.0, pi));\n rz *= pow(15., 0.9);\n vec4 temp = vec4(0);\n temp = mix( color / rz, vec4(color.rgb, 0.1), 0.2);\n if (st2.s < 0.05) {\n temp = mix(vec4(color.rgb, 0.1), temp, st2.s / 0.05);\n }\n if (st2.s > 0.95){\n temp = mix(temp, vec4(color.rgb, 0.1), (st2.s - 0.95) / 0.05);\n }\n material.diffuse = temp.rgb;\n material.alpha = temp.a * 2.0;\n return material;\n }\n",Un={name:"circle-fan",color:"rgba(255,255,255,1)",speed:8};class Vn extends Fe{speed;color;name="";constructor(t){super();const i={...Un,...t};this.name=`${an.EllipsoidScan}-${b()}`,this.color=e.Color.fromCssColorString(i.color),this.speed=i.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,i){return e.defined(i)||(i={}),i.speed=this.speed,i}equals(e){return this===e||e instanceof Vn&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:Wn},translucent:()=>!0})}}const $n=t=>{const i={...Un,...t};return{material:new e.Material({fabric:{type:`${an.EllipsoidScan}-${b()}`,uniforms:{color:e.Color.fromCssColorString(i.color),speed:i.speed},source:Wn},translucent:!0})}},Wn="\n uniform vec4 color;\n uniform float speed;\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float time = fract(czm_frameNumber * speed / 1000.0);\n float alpha = abs(smoothstep(0.5,1.,fract( -st.t - time)));\n alpha += .1;\n material.alpha = alpha;\n material.diffuse = color.rgb;\n return material;\n }\n",Hn={color:"rgba(255,255,255,1)",speed:1};class qn extends Fe{color;speed;name="";constructor(t){super();const i={...Hn,...t};this.name=an.Zaps,this.color=e.Color.fromCssColorString(i.color),this.speed=i.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,i){return e.defined(i)||(i={}),i.color=this.color,i}equals(t){return this===t||t instanceof qn&&e.Property.equals(this.color,t.color)&&this.speed===t.speed&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(an.Zaps,{fabric:{type:an.Zaps,uniforms:{uColor:this.color,speed:this.speed,uResolution:new e.Cartesian2(1024,1024)},source:Zn},translucent:()=>!0})}}const jn=t=>{const i={...Hn,...t};return{material:new e.Material({fabric:{type:an.Zaps,uniforms:{uColor:e.Color.fromCssColorString(i.color),uSpeed:i.speed,uResolution:new e.Cartesian2(1024,1024)},source:Zn}})}},Zn="\n uniform float uSpeed;\n uniform vec4 uColor;\n uniform vec2 uResolution;\n\n void mainImage(out vec4 o, vec2 u, float time)\n {\n vec2 v = uResolution.xy;\n u = .2*(u+u-v)/v.y;\n\n vec4 z = o = vec4(1,2,3,0);\n for (float a = .5, t = time, i;\n ++i < 19.;\n o += (1. + cos(z+t))\n / length((1.+i*dot(v,v))\n * sin(1.5*u/(.5-dot(u,u)) - 9.*u.yx + t))\n )\n v = cos(++t - 7.*u*pow(a += .03, i)) - 5.*u,\n // use stanh here if shader has black artifacts\n // vvvv\n u += tanh(40. * dot(u *= mat2(cos(i + .02*t - vec4(0,11,33,0)))\n ,u)\n * cos(1e2*u.yx + t)) / 2e2\n + .2 * a * u\n + cos(4./exp(dot(o,o)/1e2) + t) / 3e2;\n\n o = 25.6 / (min(o, 13.) + 164. / o)\n - dot(u, u) / 250.;\n }\n\n czm_material czm_getMaterial(czm_materialInput materialInput) {\n float time = fract(czm_frameNumber * speed / 1000.0);\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec4 color = vec4(0.0,0.0,0.0,1.0);\n mainImage(color,materialInput.st * uResolution,time);\n\n material.diffuse = color.rgb * uColor.rgb;\n material.alpha = 0.33 + (sin(time * 0.3) + 1.0) / 3.0;\n return material;\n }\n ";class Yn extends Oe{position;options;constructor(e){super(),this.options=e,this.position=e.position,this.setAppearance()}getGeometry(){return new e.CircleGeometry({center:this.position,radius:this.options.radius})}getPrimitive(){if(!this.needUpdate&&this._primitive)return this._primitive;const t=this.getGeometry();if(!t)return;const i={geometryInstances:new e.GeometryInstance({geometry:t}),appearance:this.appearance,asynchronous:!1};return this.options.ground?new e.GroundPrimitive(i):new e.Primitive(i)}setAppearance(t){t?this.appearance=t:(this.appearance=new e.MaterialAppearance({material:Tn(this.options.materialOptions||{}),flat:!1,faceForward:!1,translucent:!0,closed:!1,...this.options.appearanceOptions||{}}),this.options.viewer.scene.preRender.addEventListener(()=>{this.appearance.material.uniforms.radians+=3*Math.PI/300}))}}const Kn=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];let Xn=class e{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,n]=new Uint8Array(t,0,2);if(219!==i)throw new Error("Data does not appear to be in a KDBush format.");const o=n>>4;if(1!==o)throw new Error(`Got v${o} data when expected v1.`);const r=Kn[15&n];if(!r)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,a,r,t)}constructor(e,t=64,i=Float64Array,n){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const o=Kn.indexOf(this.ArrayType),r=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-a%8)%8;if(o<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+r+a+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+o]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Jn(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:r,nodeSize:a}=this,s=[0,o.length-1,0],l=[];for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u<=a){for(let a=u;a<=d;a++){const s=r[2*a],c=r[2*a+1];s>=e&&s<=i&&c>=t&&c<=n&&l.push(o[a])}continue}const p=u+d>>1,h=r[2*p],m=r[2*p+1];h>=e&&h<=i&&m>=t&&m<=n&&l.push(o[p]),(0===c?e<=h:t<=m)&&(s.push(u),s.push(p-1),s.push(1-c)),(0===c?i>=h:n>=m)&&(s.push(p+1),s.push(d),s.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:r}=this,a=[0,n.length-1,0],s=[],l=i*i;for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u<=r){for(let i=u;i<=d;i++)io(o[2*i],o[2*i+1],e,t)<=l&&s.push(n[i]);continue}const p=u+d>>1,h=o[2*p],m=o[2*p+1];io(h,m,e,t)<=l&&s.push(n[p]),(0===c?e-i<=h:t-i<=m)&&(a.push(u),a.push(p-1),a.push(1-c)),(0===c?e+i>=h:t+i>=m)&&(a.push(p+1),a.push(d),a.push(1-c))}return s}};function Jn(e,t,i,n,o,r){if(o-n<=i)return;const a=n+o>>1;Qn(e,t,a,n,o,r),Jn(e,t,i,n,a-1,1-r),Jn(e,t,i,a+1,o,1-r)}function Qn(e,t,i,n,o,r){for(;o>n;){if(o-n>600){const a=o-n+1,s=i-n+1,l=Math.log(a),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(a-c)/a)*(s-a/2<0?-1:1);Qn(e,t,i,Math.max(n,Math.floor(i-s*c/a+d)),Math.min(o,Math.floor(i+(a-s)*c/a+d)),r)}const a=t[2*i+r];let s=n,l=o;for(eo(e,t,n,i),t[2*o+r]>a&&eo(e,t,n,o);s<l;){for(eo(e,t,s,l),s++,l--;t[2*s+r]<a;)s++;for(;t[2*l+r]>a;)l--}t[2*n+r]===a?eo(e,t,n,l):(l++,eo(e,t,l,o)),l<=i&&(n=l+1),i<=l&&(o=l-1)}}function eo(e,t,i,n){to(e,i,n),to(t,2*i,2*n),to(t,2*i+1,2*n+1)}function to(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function io(e,t,i,n){const o=e-i,r=t-n;return o*o+r*r}const no={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},oo=Math.fround||(ro=new Float32Array(1),e=>(ro[0]=+e,ro[0]));var ro;class ao{constructor(e){this.options=Object.assign(Object.create(no),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:n}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;const r=[];for(let t=0;t<e.length;t++){const i=e[t];if(!i.geometry)continue;const[n,o]=i.geometry.coordinates,a=oo(co(n)),s=oo(uo(o));r.push(a,s,1/0,t,-1,1),this.options.reduce&&r.push(0)}let a=this.trees[n+1]=this._createTree(r);t&&console.timeEnd(o);for(let e=n;e>=i;e--){const i=+Date.now();a=this.trees[e]=this._createTree(this._cluster(a,e)),t&&console.log("z%d: %d clusters in %dms",e,a.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let o=180===e[2]?180:((e[2]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,o=180;else if(i>o){const e=this.getClusters([i,n,180,r],t),a=this.getClusters([-180,n,o,r],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],s=a.range(co(i),uo(r),co(o),uo(n)),l=a.data,c=[];for(const e of s){const t=this.stride*e;c.push(l[t+5]>1?so(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",o=this.trees[i];if(!o)throw new Error(n);const r=o.data;if(t*this.stride>=r.length)throw new Error(n);const a=this.options.radius/(this.options.extent*Math.pow(2,i-1)),s=r[t*this.stride],l=r[t*this.stride+1],c=o.within(s,l,a),d=[];for(const t of c){const i=t*this.stride;r[i+4]===e&&d.push(r[i+5]>1?so(r,i,this.clusterProps):this.points[r[i+3]])}if(0===d.length)throw new Error(n);return d}getLeaves(e,t,i){t=t||10,i=i||0;const n=[];return this._appendLeaves(n,e,t,i,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],o=Math.pow(2,e),{extent:r,radius:a}=this.options,s=a/r,l=(i-s)/o,c=(i+1+s)/o,d={features:[]};return this._addTileFeatures(n.range((t-s)/o,l,(t+1+s)/o,c),n.data,t,i,o,d),0===t&&this._addTileFeatures(n.range(1-s/o,l,1,c),n.data,o,i,o,d),t===o-1&&this._addTileFeatures(n.range(0,l,s/o,c),n.data,-1,i,o,d),d.features.length?d:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,o){const r=this.getChildren(t);for(const t of r){const r=t.properties;if(r&&r.cluster?o+r.point_count<=n?o+=r.point_count:o=this._appendLeaves(e,r.cluster_id,i,n,o):o<n?o++:e.push(t),e.length===i)break}return o}_createTree(e){const t=new Xn(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let i=0;i<e.length;i+=this.stride)t.add(e[i],e[i+1]);return t.finish(),t.data=e,t}_addTileFeatures(e,t,i,n,o,r){for(const a of e){const e=a*this.stride,s=t[e+5]>1;let l,c,d;if(s)l=lo(t,e,this.clusterProps),c=t[e],d=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[n,o]=i.geometry.coordinates;c=co(n),d=uo(o)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*o-i)),Math.round(this.options.extent*(d*o-n))]],tags:l};let p;p=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==p&&(u.id=p),r.features.push(u)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:n,reduce:o,minPoints:r}=this.options,a=i/(n*Math.pow(2,t)),s=e.data,l=[],c=this.stride;for(let i=0;i<s.length;i+=c){if(s[i+2]<=t)continue;s[i+2]=t;const n=s[i],d=s[i+1],u=e.within(s[i],s[i+1],a),p=s[i+5];let h=p;for(const e of u){const i=e*c;s[i+2]>t&&(h+=s[i+5])}if(h>p&&h>=r){let e,r=n*p,a=d*p,m=-1;const f=(i/c<<5)+(t+1)+this.points.length;for(const n of u){const l=n*c;if(s[l+2]<=t)continue;s[l+2]=t;const d=s[l+5];r+=s[l]*d,a+=s[l+1]*d,s[l+4]=f,o&&(e||(e=this._map(s,i,!0),m=this.clusterProps.length,this.clusterProps.push(e)),o(e,this._map(s,l)))}s[i+4]=f,l.push(r/h,a/h,1/0,f,-1,h),o&&l.push(m)}else{for(let e=0;e<c;e++)l.push(s[i+e]);if(h>1)for(const e of u){const i=e*c;if(!(s[i+2]<=t)){s[i+2]=t;for(let e=0;e<c;e++)l.push(s[i+e])}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const n=this.clusterProps[e[t+6]];return i?Object.assign({},n):n}const n=this.points[e[t+3]].properties,o=this.options.map(n);return i&&o===n?Object.assign({},o):o}}function so(e,t,i){return{type:"Feature",id:e[t+3],properties:lo(e,t,i),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),po(e[t+1])]}};var n}function lo(e,t,i){const n=e[t+5],o=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,r=e[t+6],a=-1===r?{}:Object.assign({},i[r]);return Object.assign(a,{cluster:!0,cluster_id:e[t+3],point_count:n,point_count_abbreviated:o})}function co(e){return e/360+.5}function uo(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function po(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}class ho extends Oe{options;pointPrimitives=new e.PrimitiveCollection;boundingSphere=new e.BoundingSphere(e.Cartesian3.ZERO,0);pointCollection;labelCollection;billboardCollection;clusterImageCache={};supercluster;constructor(t){super(),this.options=t,this.clacBoundingSphere(this.options.geoJson),this.options.point&&(this.pointCollection=new e.PointPrimitiveCollection,this.pointPrimitives.add(this.pointCollection)),this.options.billboard&&(this.billboardCollection=new e.BillboardCollection({scene:t.viewer.scene}),this.pointPrimitives.add(this.billboardCollection)),this.options.label&&(this.labelCollection=new e.LabelCollection({scene:t.viewer.scene}),this.pointPrimitives.add(this.labelCollection)),t.cluster?(this.supercluster=new ao({radius:this.options.cluster?.radius||vo.radius,maxZoom:this.options.cluster?.maxZoom||vo.maxZoom}),this.initCluster(this.options.viewer,this.options.geoJson)):this.initCollection(this.options.geoJson)}initCollection=async t=>{await this.calcPointHeight(this.options.viewer,t);const i=[];t.features.forEach(t=>{if(i.push(e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],0)),this.options.point){this.pointCollection.add(this.createPoint(t)).properties=t.properties||{}}if(this.options.billboard){this.billboardCollection.add(this.createBillboard(t)).properties=t.properties||{}}if(this.options.label){this.labelCollection.add(this.createLabel(t)).properties=t.properties||{}}})};clacBoundingSphere(t){const i=t.features.map(t=>e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],0));e.BoundingSphere.fromPoints(i,this.boundingSphere)}createPoint(t){const i={...mo,...this.options.point,...t.properties?.style?.point};return{id:b(),position:e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],t.geometry.coordinates[2]),color:e.Color.fromCssColorString(i.color),pixelSize:i.pixelSize,outlineColor:e.Color.fromCssColorString(i.outlineColor),outlineWidth:i.outlineWidth,scaleByDistance:i.scaleByDistance,translucencyByDistance:i.translucencyByDistance,disableDepthTestDistance:i.disableDepthTestDistance,distanceDisplayCondition:i.distanceDisplayCondition}}createBillboard(t){const i={...go,...this.options.billboard,...t.properties?.style?.billboard};return{id:b(),position:e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],t.geometry.coordinates[2]||0),image:i.image,scale:i.scale,width:t.properties?.cluster?void 0:i.width,height:t.properties?.cluster?void 0:i.height,color:t.properties?.cluster?void 0:e.Color.fromCssColorString(i.color),pixelOffset:e.Cartesian2.fromArray(i?.pixelOffset),horizontalOrigin:i.horizontalOrigin,verticalOrigin:i.verticalOrigin,heightReference:i.heightReference,scaleByDistance:i.scaleByDistance,translucencyByDistance:i.translucencyByDistance,disableDepthTestDistance:i.disableDepthTestDistance,distanceDisplayCondition:i.distanceDisplayCondition}}createLabel(t){const i={...fo,...this.options.label,...t.properties?.style?.label};return{id:b(),position:e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],t.geometry.coordinates[2]||0),text:t.properties?.[i?.field]||i?.field,font:i?.font,fillColor:e.Color.fromCssColorString(i?.fillColor),outlineColor:e.Color.fromCssColorString(i?.outlineColor),outlineWidth:i?.outlineWidth,style:i?.style,scale:i?.scale,showBackground:i?.showBackground,backgroundColor:e.Color.fromCssColorString(i?.backgroundColor),backgroundPadding:e.Cartesian2.fromArray(i?.backgroundPadding),pixelOffset:e.Cartesian2.fromArray(i?.pixelOffset),horizontalOrigin:i.horizontalOrigin,verticalOrigin:i.verticalOrigin,heightReference:i?.heightReference,scaleByDistance:i?.scaleByDistance,translucencyByDistance:i.translucencyByDistance,disableDepthTestDistance:i?.disableDepthTestDistance,distanceDisplayCondition:i.distanceDisplayCondition}}initCluster=async(t,i)=>{this.supercluster.load(i.features);let n=e.getTimestamp();this.loadCluster(t),t.camera.changed.addEventListener(()=>{e.getTimestamp()-n<=500||(n=e.getTimestamp(),this.loadCluster(t))})};flyToChildByClusterId(t){const i=this.supercluster?.getChildren(t),n=i?.map(t=>e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],0)),o=e.BoundingSphere.fromPoints(n);return this.options.viewer.camera.flyToBoundingSphere(o),i}loadCluster=t=>{const i=Te(t.camera),n=t.camera.computeViewRectangle(),o=this.supercluster.getClusters([e.Math.toDegrees(n.west),e.Math.toDegrees(n.south),e.Math.toDegrees(n.east),e.Math.toDegrees(n.north)],i);this.clearCollection();const r=this.options.cluster.colorsByRate||vo.colorsByRate,a={type:"FeatureCollection",features:o.map(e=>{const t=e.properties.point_count/this.options.geoJson.features.length,n=Object.keys(r).find(e=>t>Number(e))||"#ff0000";if(e.properties.cluster){const t=this.getClusterImageByCount(r[n],e.properties.point_count,i),o=16*(String(e.properties.point_count).length+1);e.properties.style={...e.properties.style,billboard:{...e.properties.style?.billboard,image:t,pixelOffset:[0,-o/12]}}}return e})};this.initCollection(a)};getClusterImageByCount(t,i,n){if(!this.clusterImageCache[i+t]){const o=16*(String(i).length+1);let r=-Math.PI/12;const a=Math.PI/2,s=Math.PI/6,l=document.createElement("canvas");l.width=o,l.height=o;const c=l.getContext("2d");c.save(),c.scale(o/24,o/24),c.beginPath(),c.arc(12,12,6,0,2*Math.PI),c.fillStyle=t,c.fill(),c.closePath(),c.lineWidth=2,c.fillStyle="rgba(255,255,255,1)",c.font=`${this.calcfontSize(n)}px Microsoft YaHei`,c.textAlign="center",c.textBaseline="middle",c.fillText(`${i}`,11.5,12.5);for(let i=0;i<3;i++)c.beginPath(),c.arc(12,12,8,r,r+a,!1),c.strokeStyle=e.Color.fromCssColorString(t).withAlpha(.4).toCssColorString(),c.stroke(),c.arc(12,12,11,r,r+a,!1),c.strokeStyle=e.Color.fromCssColorString(t).withAlpha(.2).toCssColorString(),c.stroke(),c.closePath(),r=r+a+s;c.restore(),this.clusterImageCache[i+t]=l.toDataURL()}return this.clusterImageCache[i+t]}calcfontSize(e){return e<4?4:e-1}async calcPointHeight(t,i){if(this.options.calcHeight)if(t.scene.terrainProvider instanceof e.EllipsoidTerrainProvider)i.features.forEach(e=>{3===e.geometry.coordinates.length?e.geometry.coordinates[2]=0:e.geometry.coordinates.push(0)});else{const n=t.scene.terrainProvider,o=i.features.map(t=>e.Cartographic.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1])),r=await e.sampleTerrainMostDetailed(n,o);i.features.forEach((e,t)=>{3===e.geometry.coordinates.length?e.geometry.coordinates[2]=r[t].height:e.geometry.coordinates.push(r[t].height)})}}clearCollection(){this.pointCollection?.removeAll(),this.billboardCollection?.removeAll(),this.labelCollection?.removeAll()}remove(){}removeAll(){this.clearCollection(),this.pointPrimitives.removeAll()}getPrimitive(){return this.pointPrimitives}}const mo={color:"rgba(81,255,0,0.8)",pixelSize:10,outlineColor:"rgba(255,0,0,0.8)",outlineWidth:1},fo={font:"20px sans-serif",fillColor:"rgba(255,255,255,0.8)",outlineColor:"rgba(0,0,0,0.8)",backgroundColor:"rgba(0,0,0,1)",outlineWidth:2,pixelOffset:[0,0],backgroundPadding:[0,0],scale:1,disableDepthTestDistance:0,horizontalOrigin:0,verticalOrigin:0,heightReference:e.HeightReference.CLAMP_TO_GROUND},go={image:"/icons/cesium-marker.png",scale:1,color:"rgba(255,0,0,1)",rotation:0,width:32,height:32,horizontalOrigin:0,verticalOrigin:0,pixelOffset:[0,-16],heightReference:e.HeightReference.CLAMP_TO_GROUND},vo={radius:60,maxZoom:25,colorsByRate:{.1:"#ff0000",.01:"#ff00ff",.001:"blue",1e-4:"#00ff00"}},yo={width:2,color:"rgba(0,255,0,0.8)"};class Co extends Oe{options;polylinePrimitives;constructor(e){super(),this.options=e,this.polylinePrimitives=void 0,this.options.material&&this.setMaterialAppearance(),this.initCollection()}initCollection(){const t=[],i=[];let n;this.options.geoJson.features.forEach(e=>{"MultiLineString"===e.geometry.type?e.geometry.coordinates.forEach(t=>{i.push({coordinates:t,properties:e.properties})}):i.push({coordinates:e.geometry.coordinates,properties:e.properties})}),i.forEach(i=>{const n=i.coordinates.map(t=>e.Cartesian3.fromDegrees(t[0],t[1],t[2])),o={...yo,...this.options?.line,...i.properties?.style?.line};t.push(new e.GeometryInstance({id:b(),geometry:new e.GroundPolylineGeometry({positions:n,width:o?.width}),attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.fromCssColorString(o.color))}}))}),n=this.appearance?this.appearance:new e.PolylineColorAppearance,this.polylinePrimitives=new e.GroundPolylinePrimitive({geometryInstances:t,appearance:n})}getPrimitive(){return this.polylinePrimitives}setMaterialAppearance(){this.appearance=new e.MaterialAppearance({material:this.options.material})}}const wo={width:2,color:"rgba(0,255,0,0.8)"};class bo extends Oe{options;primitives;constructor(e){super(),this.options=e,this.primitives=void 0,this.initCollection()}initCollection(){const t=[];this.options.geoJson.features.forEach(i=>{let n;n="Polygon"===i.geometry.type?new e.PolygonHierarchy(e.Cartesian3.fromDegreesArray(i.geometry.coordinates[0].flat())):_o(i.geometry);const o={...wo,...this.options?.line,...i.properties?.style?.line},r=b();i.properties&&(i.properties.id=r);const a=new e.GeometryInstance({id:r,geometry:new e.PolygonGeometry({polygonHierarchy:n}),attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.fromCssColorString(o.color))}});t.push(a),a.properties=i.properties}),this.primitives=new e.GroundPrimitive({geometryInstances:t,appearance:new e.PerInstanceColorAppearance({})})}getPrimitive(){return this.primitives}getAppearance(t){this.appearance=t||new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.fromCssColorString("rgba(81,255,0,0.8)")})})}}const _o=t=>new e.PolygonHierarchy(e.Cartesian3.fromDegreesArray(t.coordinates[0][0].flat()));function xo(e,t,i,n,o,r){if(o-n<=i)return;const a=n+o>>1;Po(e,t,a,n,o,r%2),xo(e,t,i,n,a-1,r+1),xo(e,t,i,a+1,o,r+1)}function Po(e,t,i,n,o,r){for(;o>n;){if(o-n>600){const a=o-n+1,s=i-n+1,l=Math.log(a),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(a-c)/a)*(s-a/2<0?-1:1);Po(e,t,i,Math.max(n,Math.floor(i-s*c/a+d)),Math.min(o,Math.floor(i+(a-s)*c/a+d)),r)}const a=t[2*i+r];let s=n,l=o;for(Mo(e,t,n,i),t[2*o+r]>a&&Mo(e,t,n,o);s<l;){for(Mo(e,t,s,l),s++,l--;t[2*s+r]<a;)s++;for(;t[2*l+r]>a;)l--}t[2*n+r]===a?Mo(e,t,n,l):(l++,Mo(e,t,l,o)),l<=i&&(n=l+1),i<=l&&(o=l-1)}}function Mo(e,t,i,n){Do(e,i,n),Do(t,2*i,2*n),Do(t,2*i+1,2*n+1)}function Do(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Eo(e,t,i,n){const o=e-i,r=t-n;return o*o+r*r}const Ao=e=>e[0],So=e=>e[1];class Io{constructor(e,t=Ao,i=So,n=64,o=Float64Array){this.nodeSize=n,this.points=e;const r=e.length<65536?Uint16Array:Uint32Array,a=this.ids=new r(e.length),s=this.coords=new o(2*e.length);for(let n=0;n<e.length;n++)a[n]=n,s[2*n]=t(e[n]),s[2*n+1]=i(e[n]);xo(a,s,n,0,a.length-1,0)}range(e,t,i,n){return function(e,t,i,n,o,r,a){const s=[0,e.length-1,0],l=[];let c,d;for(;s.length;){const u=s.pop(),p=s.pop(),h=s.pop();if(p-h<=a){for(let a=h;a<=p;a++)c=t[2*a],d=t[2*a+1],c>=i&&c<=o&&d>=n&&d<=r&&l.push(e[a]);continue}const m=Math.floor((h+p)/2);c=t[2*m],d=t[2*m+1],c>=i&&c<=o&&d>=n&&d<=r&&l.push(e[m]);const f=(u+1)%2;(0===u?i<=c:n<=d)&&(s.push(h),s.push(m-1),s.push(f)),(0===u?o>=c:r>=d)&&(s.push(m+1),s.push(p),s.push(f))}return l}(this.ids,this.coords,e,t,i,n,this.nodeSize)}within(e,t,i){return function(e,t,i,n,o,r){const a=[0,e.length-1,0],s=[],l=o*o;for(;a.length;){const c=a.pop(),d=a.pop(),u=a.pop();if(d-u<=r){for(let o=u;o<=d;o++)Eo(t[2*o],t[2*o+1],i,n)<=l&&s.push(e[o]);continue}const p=Math.floor((u+d)/2),h=t[2*p],m=t[2*p+1];Eo(h,m,i,n)<=l&&s.push(e[p]);const f=(c+1)%2;(0===c?i-o<=h:n-o<=m)&&(a.push(u),a.push(p-1),a.push(f)),(0===c?i+o>=h:n+o>=m)&&(a.push(p+1),a.push(d),a.push(f))}return s}(this.ids,this.coords,e,t,i,this.nodeSize)}}function To(t){t=e.defaultValue(t,e.defaultValue.EMPTY_OBJECT),this._enabled=e.defaultValue(t.enabled,!1),this._pixelRange=e.defaultValue(t.pixelRange,80),this._minimumClusterSize=e.defaultValue(t.minimumClusterSize,2),this._clusterBillboards=e.defaultValue(t.clusterBillboards,!0),this._clusterLabels=e.defaultValue(t.clusterLabels,!0),this._clusterPoints=e.defaultValue(t.clusterPoints,!0),this._labelCollection=void 0,this._billboardCollection=void 0,this._pointCollection=void 0,this._clusterBillboardCollection=void 0,this._clusterLabelCollection=void 0,this._clusterPointCollection=void 0,this._collectionIndicesByEntity={},this._unusedLabelIndices=[],this._unusedBillboardIndices=[],this._unusedPointIndices=[],this._previousClusters=[],this._previousHeight=void 0,this._enabledDirty=!1,this._clusterDirty=!1,this._cluster=void 0,this._removeEventListener=void 0,this._clusterEvent=new Event,this.show=e.defaultValue(t.show,!0)}function zo(e){return e.coord.x}function Ro(e){return e.coord.y}function Oo(e,t){e.x-=t,e.y-=t,e.width+=2*t,e.height+=2*t}const Fo=new e.BoundingRectangle;function Lo(t,i,n,o,r){if(e.defined(t._labelCollection)&&o._clusterLabels?r=e.Label.getScreenSpaceBoundingBox(t,i,r):e.defined(t._billboardCollection)&&o._clusterBillboards?r=e.Billboard.getScreenSpaceBoundingBox(t,i,r):e.defined(t._pointPrimitiveCollection)&&o._clusterPoints&&(r=e.PointPrimitive.getScreenSpaceBoundingBox(t,i,r)),Oo(r,n),o._clusterLabels&&!e.defined(t._labelCollection)&&e.defined(t.id)&&No(o,t.id.id)&&e.defined(t.id._label)){const a=o._collectionIndicesByEntity[t.id.id].labelIndex,s=o._labelCollection.get(a),l=e.Label.getScreenSpaceBoundingBox(s,i,Fo);Oo(l,n),r=e.BoundingRectangle.union(r,l,r)}return r}function Bo(t,i){if(t.clusterShow=!0,!e.defined(t._labelCollection)&&e.defined(t.id)&&No(i,t.id.id)&&e.defined(t.id._label)){const e=i._collectionIndicesByEntity[t.id.id].labelIndex;i._labelCollection.get(e).clusterShow=!0}}function ko(e,t,i,n){const o={billboard:n._clusterBillboardCollection.add(),label:n._clusterLabelCollection.add(),point:n._clusterPointCollection.add()};o.billboard.show=!1,o.point.show=!1,o.label.show=!0,o.label.text=t.toLocaleString(),o.label.id=i,o.billboard.position=o.label.position=o.point.position=e,n._clusterEvent.raiseEvent(i,o)}function No(t,i){return e.defined(t)&&e.defined(t._collectionIndicesByEntity[i])&&e.defined(t._collectionIndicesByEntity[i].labelIndex)}function Go(t,i,n,o,r){if(!e.defined(t))return;const a=t.length;for(let s=0;s<a;++s){const a=t.get(s);if(a.clusterShow=!1,!a.show||r._scene.mode===e.SceneMode.SCENE3D&&!o.isPointVisible(a.position))continue;const l=a.computeScreenSpacePosition(n);e.defined(l)&&i.push({index:s,collection:t,clustered:!1,coord:l})}}const Uo=new e.BoundingRectangle,Vo=new e.BoundingRectangle,$o=new e.BoundingRectangle;function Wo(t,i,n,o){return function(r){let a=this[t];e.defined(this._collectionIndicesByEntity)||(this._collectionIndicesByEntity={});let s,l,c=this._collectionIndicesByEntity[r.id];if(e.defined(c)||(c=this._collectionIndicesByEntity[r.id]={billboardIndex:void 0,labelIndex:void 0,pointIndex:void 0}),e.defined(a)&&e.defined(c[o]))return a.get(c[o]);e.defined(a)||(a=this[t]=new i({scene:this._scene}));const d=this[n];return d.length>0?(s=d.pop(),l=a.get(s)):(l=a.add(),s=a.length-1),c[o]=s,Promise.resolve().then(()=>{this._clusterDirty=!0}),l}}function Ho(t,i){const n=t._collectionIndicesByEntity[i];e.defined(n.billboardIndex)||e.defined(n.labelIndex)||e.defined(n.pointIndex)||delete t._collectionIndicesByEntity[i]}function qo(t){if(!e.defined(t))return;const i=t.length;for(let e=0;e<i;++e)t.get(e).clusterShow=!0}To.prototype._initialize=function(t){this._scene=t;const i=(n=this,function(t){if(e.defined(t)&&t<.05||!n.enabled)return;const i=n._scene,o=n._labelCollection,r=n._billboardCollection,a=n._pointCollection;if(!e.defined(o)&&!e.defined(r)&&!e.defined(a)||!n._clusterBillboards&&!n._clusterLabels&&!n._clusterPoints)return;let s=n._clusterLabelCollection,l=n._clusterBillboardCollection,c=n._clusterPointCollection;e.defined(s)?s.removeAll():s=n._clusterLabelCollection=new e.LabelCollection({scene:i}),e.defined(l)?l.removeAll():l=n._clusterBillboardCollection=new e.BillboardCollection({scene:i}),e.defined(c)?c.removeAll():c=n._clusterPointCollection=new e.PointPrimitiveCollection;const d=n._pixelRange,u=n._minimumClusterSize,p=n._previousClusters,h=[],m=n._previousHeight,f=i.camera.positionCartographic.height,g=i.mapProjection.ellipsoid,v=i.camera.positionWC,y=new e.EllipsoidalOccluder(g,v),C=[];let w,b,_,x,P,M,D,E,A,S,I,T;n._clusterLabels&&Go(o,C,i,y,n),n._clusterBillboards&&Go(r,C,i,y,n),n._clusterPoints&&Go(a,C,i,y,n);const z=new Io(C,zo,Ro,64,Int32Array);if(f<m)for(_=p.length,w=0;w<_;++w){const t=p[w];if(!y.isPointVisible(t.position))continue;const o=e.Billboard._computeScreenSpacePosition(e.Matrix4.IDENTITY,t.position,e.Cartesian3.ZERO,e.Cartesian2.ZERO,i);if(!e.defined(o))continue;const r=1-f/m;let a=t.width=t.width*r,s=t.height=t.height*r;a=Math.max(a,t.minimumWidth),s=Math.max(s,t.minimumHeight);const l=o.x-.5*a,c=o.y-.5*s,d=o.x+a,g=o.y+s;for(P=z.range(l,c,d,g),M=P.length,S=0,A=[],b=0;b<M;++b)D=P[b],E=C[D],E.clustered||(++S,I=E.collection,T=E.index,A.push(I.get(T).id));if(S>=u)for(ko(t.position,S,A,n),h.push(t),b=0;b<M;++b)C[P[b]].clustered=!0}for(_=C.length,w=0;w<_;++w){const t=C[w];if(t.clustered)continue;t.clustered=!0,I=t.collection,T=t.index;const i=I.get(T);x=Lo(i,t.coord,d,n,Uo);const o=e.BoundingRectangle.clone(x,Vo);P=z.range(x.x,x.y,x.x+x.width,x.y+x.height),M=P.length;const r=e.Cartesian3.clone(i.position);for(S=1,A=[i.id],b=0;b<M;++b)if(D=P[b],E=C[D],!E.clustered){const t=E.collection.get(E.index),i=Lo(t,E.coord,d,n,$o);e.Cartesian3.add(t.position,r,r),e.BoundingRectangle.union(o,i,o),++S,A.push(t.id)}if(S>=u){const t=e.Cartesian3.multiplyByScalar(r,1/S,r);for(ko(t,S,A,n),h.push({position:t,width:o.width,height:o.height,minimumWidth:x.width,minimumHeight:x.height}),b=0;b<M;++b)C[P[b]].clustered=!0}else Bo(i,n)}0===s.length&&(s.destroy(),n._clusterLabelCollection=void 0),0===l.length&&(l.destroy(),n._clusterBillboardCollection=void 0),0===c.length&&(c.destroy(),n._clusterPointCollection=void 0),n._previousClusters=h,n._previousHeight=f});var n;this._cluster=i,this._removeEventListener=t.camera.changed.addEventListener(i)},Object.defineProperties(To.prototype,{enabled:{get(){return this._enabled},set(e){this._enabledDirty=e!==this._enabled,this._enabled=e}},pixelRange:{get(){return this._pixelRange},set(e){this._clusterDirty=this._clusterDirty||e!==this._pixelRange,this._pixelRange=e}},minimumClusterSize:{get(){return this._minimumClusterSize},set(e){this._clusterDirty=this._clusterDirty||e!==this._minimumClusterSize,this._minimumClusterSize=e}},clusterEvent:{get(){return this._clusterEvent}},clusterBillboards:{get(){return this._clusterBillboards},set(e){this._clusterDirty=this._clusterDirty||e!==this._clusterBillboards,this._clusterBillboards=e}},clusterLabels:{get(){return this._clusterLabels},set(e){this._clusterDirty=this._clusterDirty||e!==this._clusterLabels,this._clusterLabels=e}},clusterPoints:{get(){return this._clusterPoints},set(e){this._clusterDirty=this._clusterDirty||e!==this._clusterPoints,this._clusterPoints=e}}}),To.prototype.getLabel=Wo("_labelCollection",e.LabelCollection,"_unusedLabelIndices","labelIndex"),To.prototype.removeLabel=function(t){const i=this._collectionIndicesByEntity&&this._collectionIndicesByEntity[t.id];if(!e.defined(this._labelCollection)||!e.defined(i)||!e.defined(i.labelIndex))return;const n=i.labelIndex;i.labelIndex=void 0,Ho(this,t.id);const o=this._labelCollection.get(n);o.show=!1,o.text="",o.id=void 0,this._unusedLabelIndices.push(n),this._clusterDirty=!0},To.prototype.getBillboard=Wo("_billboardCollection",e.BillboardCollection,"_unusedBillboardIndices","billboardIndex"),To.prototype.removeBillboard=function(t){const i=this._collectionIndicesByEntity&&this._collectionIndicesByEntity[t.id];if(!e.defined(this._billboardCollection)||!e.defined(i)||!e.defined(i.billboardIndex))return;const n=i.billboardIndex;i.billboardIndex=void 0,Ho(this,t.id);const o=this._billboardCollection.get(n);o.id=void 0,o.show=!1,o.image=void 0,this._unusedBillboardIndices.push(n),this._clusterDirty=!0},To.prototype.getPoint=Wo("_pointCollection",e.PointPrimitiveCollection,"_unusedPointIndices","pointIndex"),To.prototype.removePoint=function(t){const i=this._collectionIndicesByEntity&&this._collectionIndicesByEntity[t.id];if(!e.defined(this._pointCollection)||!e.defined(i)||!e.defined(i.pointIndex))return;const n=i.pointIndex;i.pointIndex=void 0,Ho(this,t.id);const o=this._pointCollection.get(n);o.show=!1,o.id=void 0,this._unusedPointIndices.push(n),this._clusterDirty=!0},To.prototype.update=function(t){if(!this.show)return;let i;var n;e.defined(this._labelCollection)&&this._labelCollection.length>0&&0===this._labelCollection.get(0)._glyphs.length&&(i=t.commandList,t.commandList=[],this._labelCollection.update(t),t.commandList=i),e.defined(this._billboardCollection)&&this._billboardCollection.length>0&&!e.defined(this._billboardCollection.get(0).width)&&(i=t.commandList,t.commandList=[],this._billboardCollection.update(t),t.commandList=i),this._enabledDirty&&(this._enabledDirty=!1,(n=this).enabled||(e.defined(n._clusterLabelCollection)&&n._clusterLabelCollection.destroy(),e.defined(n._clusterBillboardCollection)&&n._clusterBillboardCollection.destroy(),e.defined(n._clusterPointCollection)&&n._clusterPointCollection.destroy(),n._clusterLabelCollection=void 0,n._clusterBillboardCollection=void 0,n._clusterPointCollection=void 0,qo(n._labelCollection),qo(n._billboardCollection),qo(n._pointCollection)),this._clusterDirty=!0),this._clusterDirty&&(this._clusterDirty=!1,this._cluster()),e.defined(this._clusterLabelCollection)&&this._clusterLabelCollection.update(t),e.defined(this._clusterBillboardCollection)&&this._clusterBillboardCollection.update(t),e.defined(this._clusterPointCollection)&&this._clusterPointCollection.update(t),e.defined(this._labelCollection)&&this._labelCollection.update(t),e.defined(this._billboardCollection)&&this._billboardCollection.update(t),e.defined(this._pointCollection)&&this._pointCollection.update(t)},To.prototype.destroy=function(){this._labelCollection=this._labelCollection&&this._labelCollection.destroy(),this._billboardCollection=this._billboardCollection&&this._billboardCollection.destroy(),this._pointCollection=this._pointCollection&&this._pointCollection.destroy(),this._clusterLabelCollection=this._clusterLabelCollection&&this._clusterLabelCollection.destroy(),this._clusterBillboardCollection=this._clusterBillboardCollection&&this._clusterBillboardCollection.destroy(),this._clusterPointCollection=this._clusterPointCollection&&this._clusterPointCollection.destroy(),e.defined(this._removeEventListener)&&(this._removeEventListener(),this._removeEventListener=void 0),this._labelCollection=void 0,this._billboardCollection=void 0,this._pointCollection=void 0,this._clusterBillboardCollection=void 0,this._clusterLabelCollection=void 0,this._clusterPointCollection=void 0,this._collectionIndicesByEntity=void 0,this._unusedLabelIndices=[],this._unusedBillboardIndices=[],this._unusedPointIndices=[],this._previousClusters=[],this._previousHeight=void 0,this._enabledDirty=!1,this._pixelRangeDirty=!1,this._minimumClusterSizeDirty=!1};class jo extends Oe{position;options;constructor(e){super(),this.options=e,this.position=e.position,this.setAppearance()}getGeometry(){return new e.CircleGeometry({center:this.position,radius:this.options.radius})}getPrimitive(){if(!this.needUpdate&&this._primitive)return this._primitive;this.needUpdate=!1;const t=this.getGeometry();if(!t)return;const i={geometryInstances:new e.GeometryInstance({geometry:t}),appearance:this.appearance,asynchronous:!1};return this.options.ground?new e.GroundPrimitive(i):new e.Primitive(i)}setAppearance(t){this.appearance=t||new e.MaterialAppearance({material:Sn(this.options.materialOptions),flat:!1,faceForward:!1,translucent:!0,closed:!1})}}class Zo extends Oe{gridPrimitiveCollection=new e.PrimitiveCollection;polygonPrimitive;outlinePrimitive;options;constructor(t){super(),this.options=t,this.gridPrimitiveCollection=new e.PrimitiveCollection,this.polygonPrimitive=this.createGridPolygonPrimitive(),this.outlinePrimitive=this.createGridOutlinePrimitive()}createGridPolygonPrimitive(){if(!this.options.fill)return;const t=[];this.options.vertices.forEach(i=>{const n=e.Color.fromCssColorString(this.options.fillColor),o=Et(i.positions,n,`grid-${i.id}`);t.push(o)});const i=new e.Primitive({geometryInstances:t,appearance:new e.PerInstanceColorAppearance({flat:!0,translucent:!0}),asynchronous:!1});return this.gridPrimitiveCollection.add(i),i}createGridOutlinePrimitive(){if(!this.options.outline)return;const t=[];this.options.vertices.forEach(i=>{const n=e.Color.fromCssColorString(this.options.outlineColor),o=At(i.positions,n,`grid-${i.id}`);t.push(o)});const i=new e.Primitive({geometryInstances:t,appearance:new e.PolylineColorAppearance({translucent:!0}),asynchronous:!1});return this.gridPrimitiveCollection.add(i),i}getPrimitive(){return this.gridPrimitiveCollection}selectGrids(t){const i=e.Color.fromCssColorString(this.options.fillSelectColor),n=e.Color.fromCssColorString(this.options.outlineSelectColor);t.forEach(t=>{if(this.polygonPrimitive){this.polygonPrimitive.getGeometryInstanceAttributes(t).color=e.ColorGeometryInstanceAttribute.toValue(i)}if(this.outlinePrimitive){this.outlinePrimitive.getGeometryInstanceAttributes(t).color=e.ColorGeometryInstanceAttribute.toValue(n)}})}unSelectGrids(t){const i=e.Color.fromCssColorString(this.options.fillColor),n=e.Color.fromCssColorString(this.options.outlineColor);t.forEach(t=>{if(this.polygonPrimitive){this.polygonPrimitive.getGeometryInstanceAttributes(t).color=e.ColorGeometryInstanceAttribute.toValue(i)}if(this.outlinePrimitive){this.outlinePrimitive.getGeometryInstanceAttributes(t).color=e.ColorGeometryInstanceAttribute.toValue(n)}})}}const Yo=t=>{const i=new e.ClippingPlaneCollection({edgeColor:e.Color.YELLOW,enabled:!0,modelMatrix:e.Matrix4.IDENTITY,edgeWidth:2});t.scene.globe.clippingPlanes=i,t.scene.globe.backFaceCulling=!1,t.scene.globe.showSkirts=!1;return{set:t=>{Object.assign(t,{unionClippingRegions:!1,...t}),i.unionClippingRegions=t.unionClippingRegions||!1,i.removeAll();let n=t?.positions;n=t.unionClippingRegions?Le(n):Be(n),n.forEach((t,o)=>{const r=(o+1)%n.length,a=n[r];let s=e.Cartesian3.add(t,a,new e.Cartesian3);s=e.Cartesian3.multiplyByScalar(s,.5,s);const l=e.Cartesian3.normalize(s,new e.Cartesian3);let c=e.Cartesian3.subtract(a,s,new e.Cartesian3);c=e.Cartesian3.normalize(c,c);let d=e.Cartesian3.cross(c,l,new e.Cartesian3);d=e.Cartesian3.normalize(d,d);const u=new e.Plane(d,0),p=e.Plane.getPointDistance(u,s);i.add(new e.ClippingPlane(d,p))})},remove:()=>{i.removeAll()},removeAll:()=>{i.removeAll()},destroy:()=>{}}},Ko=t=>{const i=new e.ClippingPolygonCollection;t.scene.globe.clippingPolygons=i;const n=new e.CustomDataSource("clipPolygon");t.dataSources.add(n),t.scene.globe.backFaceCulling=!1,t.scene.globe.showSkirts=!1;return{set:t=>{t={inverse:!1,...t};const o=t?.positions,r=new e.ClippingPolygon({positions:o});i.add(r);const a=Ge(ke(o).map(e=>(e.height=-t.depth,e))),s=n.entities.add({polygon:{hierarchy:a,perPositionHeight:!0,material:new e.ImageMaterialProperty({image:"/icons/terrain/poly-soil.jpg"})}});n.entities.add({polygon:{hierarchy:a,perPositionHeight:!0,extrudedHeight:t.depth,material:new e.ImageMaterialProperty({image:"/icons/terrain/poly-soil.jpg"})}});return{id:b(),polygon:r,bottomEntity:s}},remove:()=>{i.isDestroyed()||i.removeAll(),t.scene.globe.clippingPolygons=new e.ClippingPolygonCollection,n.entities.removeAll()},removeAll:()=>{i.isDestroyed()||i.removeAll(),t.scene.globe.clippingPolygons=new e.ClippingPolygonCollection,n.entities.removeAll()},destroy:()=>{}}},Xo=t=>{const i=new e.CustomDataSource("flood-analysis");t.dataSources.add(i);return{set:e=>{const{positions:t,type:i,speed:n}=e;return console.log(t,e,i,n),{id:b()}},remove:()=>{},removeAll:()=>{i.entities.removeAll()},destroy:()=>{t.dataSources.remove(i)}}},Jo=t=>{const i=new e.PrimitiveCollection({destroyPrimitives:!1}),n=new e.PrimitiveCollection({destroyPrimitives:!1}),o=new e.PointPrimitiveCollection,r=new e.LabelCollection;n.add(o),i.add(r),i.add(n),t.scene.primitives.add(i);const a=(t,i)=>{t.forEach(t=>{i.add({position:t,color:e.Color.TRANSPARENT})})},s=(t,i)=>{const n=new e.GroundPolylineGeometry({positions:t,width:3}),o=new e.GeometryInstance({geometry:n});i.add(new e.GroundPolylinePrimitive({geometryInstances:o,asynchronous:!1,appearance:new e.MaterialAppearance({translucent:!0,faceForward:!0,material:e.Material.fromType("Color",{color:e.Color.fromCssColorString("#ff00ff").withAlpha(.5)})})}))},l=(t,i)=>{const n=new e.WallGeometry({positions:t}),o=e.WallGeometry.createGeometry(n),r=new e.GeometryInstance({geometry:o});i.add(new e.Primitive({geometryInstances:[r],asynchronous:!1,appearance:new e.MaterialAppearance({translucent:!0,faceForward:!0,material:e.Material.fromType("Color",{color:e.Color.fromCssColorString("#00ff00").withAlpha(.5)})})}))},c=(t,i,n)=>{const o=new e.PolygonGeometry({polygonHierarchy:new e.PolygonHierarchy(t),height:i}),r=new e.GeometryInstance({geometry:o});n.add(new e.Primitive({geometryInstances:[r],asynchronous:!1,appearance:new e.MaterialAppearance({translucent:!0,faceForward:!0,material:e.Material.fromType("Color",{color:e.Color.fromCssColorString("#0088ff").withAlpha(.5)})})}))},d=(t,i,n,o,r)=>{const a=t.map(t=>e.Cartographic.fromCartesian(t).height),s=Math.min(...a),l=Math.max(...a);let c=0;for(let e=0;e<a.length;e++)c+=(a[e]-s)*i*i;const d=e.Cartesian3.fromDegrees(n.geometry.coordinates[0],n.geometry.coordinates[1],l),u={},h=r*l;c?u["挖方体积"]=`${p(c)}方\n`:c=0,h&&(u["填方体积"]=`${p(h-c)}方\n`),r&&(u["横切面积"]=`${p(r)}平方米\n`),s&&(u["最小高程"]=`${p(s)}米\n`),l&&(u["最大高程"]=`${p(l)}米\n`),s&&(u["基准面高程"]=`${p(s)}米`);let m="";Object.keys(u).forEach(e=>{m+=`${e}:${u[e]}`}),o.add({position:d,text:m,font:"16px sans-serif",fillColor:e.Color.WHITE,showBackground:!0,style:e.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:Number.POSITIVE_INFINITY})},u=(t,i,n)=>{t.forEach((t,o)=>{n.add({position:t,text:`高程:${p(i[o].height)}米`,font:"14px sans-serif",fillColor:e.Color.WHITE,showBackground:!0,style:e.LabelStyle.FILL_AND_OUTLINE,disableDepthTestDistance:Number.POSITIVE_INFINITY})})},p=e=>{const t=["","万","百万","千万","亿"];let i=0;for(;e>=1e4&&i<t.length-1;)e/=1e4,i++;return`${e.toFixed(2).replace(/\.?0+$/,"")}${t[i]}`};return{set:p=>{const h=Ve(p.positions),m=h.map(t=>{const i=e.Cartographic.fromCartesian(t);return{lng:e.Math.toDegrees(i.longitude),lat:e.Math.toDegrees(i.latitude),height:i.height}}),f=Math.min(...m.map(e=>e.height)),g=k([m.map(e=>[e.lng,e.lat])]),v=j(g),y=Math.sqrt(j(g)/200),C=Ce(g),w=ye(g),_=function(e,t,i={}){i.mask&&!i.units&&(i.units="kilometers");for(var n=[],o=e[0],r=e[1],a=e[2],s=e[3],l=t/W([o,r],[a,r],i)*(a-o),c=t/W([o,r],[o,s],i)*(s-r),d=a-o,u=s-r,p=Math.floor(d/l),h=(u-Math.floor(u/c)*c)/2,m=o+(d-p*l)/2;m<=a;){for(var f=r+h;f<=s;){var g=B([m,f],i.properties);i.mask?me(g,i.mask)&&n.push(g):n.push(g),f+=c}m+=l}return N(n)}(J(C),y,{units:"meters"}),x=we(_,g).features.map(t=>e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1]));return t.scene.clampToHeightMostDetailed(x).then(e=>{a(e,o),c(h,f,i),s(h,n),l(h,i),d(e,y,w,r,v),u(h,m,r)}),{id:b()}},remove:()=>{},removeAll:()=>{r.removeAll(),o.removeAll(),n.removeAll(),i.removeAll(),n.add(o),i.add(n),i.add(r)},destroy:()=>{}}},Qo=t=>{const i=new e.PrimitiveCollection({destroyPrimitives:!1});let n,o="/icons/markers/mark-icon.png";const r=[];t.scene.primitives.add(i);const a=i=>{if(!i)return n&&t.entities.remove(n),void(n=void 0);n||(n=t.entities.add({position:Ue(new e.Cartographic(i.longitude,i.latitude,i.height)),billboard:{image:o,scale:.5,verticalOrigin:e.VerticalOrigin.BOTTOM,heightReference:e.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}})),n.position=Ue(new e.Cartographic(i.longitude,i.latitude,i.height))};return{set:async e=>{e.tipMarkerUrl&&(o=e.tipMarkerUrl);const{positions:i}=e;let n=Pe(i);const a=Math.floor(n/e.pointDistance);let s=Re(i,a);s=await t.scene.clampToHeightMostDetailed(s),n=0;const l=s.map((e,t)=>{let i=0;t>0&&(i=xe(s[t-1],e),n+=i);return{...Ne(e),distance:i,allDistance:n}}),c={id:b(),datas:l};return r.push(c),c},remove:e=>{const t=r.findIndex(t=>t.id===e.id);-1!==t&&r.splice(t,1),a()},removeAll:()=>{i.removeAll(),a()},destroy:()=>{t.scene.primitives.remove(i)},changeTipPoint:a}},er=e=>{const t=new PrimitiveCollection({destroyPrimitives:!1});let i=null,n="";const o=[];e.scene.primitives.add(t);const r=async(t,i,n)=>{const o=JSON.parse(JSON.stringify(t));await e.scene.clampToHeightMostDetailed(o)},a=t=>{if(!t)return i&&e.entities.remove(i),void(i=void 0);i||(i=e.entities.add({position:Ue(new Cartographic(t.longitude,t.latitude,t.height)),billboard:{image:n,scale:.5,verticalOrigin:VerticalOrigin.BOTTOM,disableDepthTestDistance:Number.POSITIVE_INFINITY}})),i.position=Ue(new Cartographic(t.longitude,t.latitude,t.height))};return{set:async t=>{t.tipMarkerUrl&&(n=t.tipMarkerUrl);const i=t.layers;return e.terrainProvider instanceof EllipsoidTerrainProvider||(e.terrainProvider,e.terrainProvider=new EllipsoidTerrainProvider),i.forEach(e=>{e.visible=!1}),new Promise(e=>{setTimeout(()=>{const{positions:i}=t,n=Pe(i),o=Math.floor(n/t.pointDistance),a=Re(i,o).filter(e=>e&&e.x&&e.y&&e.z),s={id:b(),datas:[]};r(a),e(s)},500)})},remove:e=>{const t=o.findIndex(t=>t.id===e.id);-1!==t&&o.splice(t,1),a(void 0)},removeAll:()=>{t.removeAll(),a(void 0)},destroy:()=>{e.scene.primitives.remove(t)},changeTipPoint:a}};export{Fe as BaseMaterialProperty,Oe as BasePrimitive,An as CircleApertureMaterialProperty,jo as CircleAperturePrimitive,Pn as CircleRaderFanMaterialProperty,wn as CircleRaderWaveMaterialProperty,gn as CircleWaveMaterialProperty,t as Common,Vt as CoordinateTransformer,s as DefaultViewerOptions,bi as Draw,wi as DrawEventType,kn as EllipsoidElectricMaterialProperty,Vn as EllipsoidScanMaterialProperty,Ct as FlyAttitude,Zo as GridPrimitives,bo as GroundPolygonPrimitives,Co as GroundPolylinePrimitives,On as LightWallMaterialProperty,rn as Material,To as PointClusterPrimitives,ho as PointPrimitives,pn as PolylineFlowMaterialProperty,ln as PolylineTrailMaterialProperty,D as Popup,Yn as RadereScanPrimitive,wt as RoamStatus,M as Tooltip,Kt as TransformsFor3dtiles,qn as ZapsMaterialProperty,De as calcArea,ze as calcCameraHeightFromZoom,xe as calcGeodesicDistance,Pe as calcGeodesicDistances,Re as calcLerpPosition,Me as calcPoistionCenter,Se as calcSceneHeightFromPositions,be as calcSpaceDistance,_e as calcSpaceDistances,Ae as calcTerrainHeightFromPositions,Ee as calcTriangleArea,Te as calcZoomFromCameraHeight,Ie as clacPositionsForParabola,di as createBloomTargetStage,Pt as createBottomStatusBar,Sn as createCircleApertureMaterial,Mn as createCircleRaderFanMaterial,vn as createCircleWaveMaterial,Yo as createClipPlaneAnalysis,Ko as createClipPolygonAnalysis,on as createDrawHandler,vi as createDroneAnimCustomShader,R as createEagleEye,Nn as createEllipsoidElectricMaterial,$n as createEllipsoidScanMaterial,Jo as createFillAndDigAnalysis,Xo as createFloodAnalysis,ci as createFogStage,li as createHeightFogStage,ni as createHighLightStage,mi as createLightBandCustomShader,Fn as createLightWallMaterial,hi as createLightningStage,er as createModelProfileAnalysis,Dt as createOpenAnim,Ci as createOutLineEffect,ri as createOutlineStage,hn as createPoylineFlowMaterial,Qo as createProfileAnalysis,bn as createRaderWaveMaterial,pi as createRainCoverStage,ui as createRainStage,yt as createRoamHandler,Tn as createScanRadarMaterial,gt as createSkyBox,vt as createSkyBoxOnGround,oi as createSkylineStage,ai as createSnowCoverStage,si as createSnowStage,cn as createTrailMaterial,jn as createZapsMaterial,p as flyToCameraView,f as flyToCesium3DTile,h as flyToDataSource,g as flyToFromSphere,m as flyToImagery,c as flyToLnglat,d as flyToPosition,jt as getAllFeaturesFrom3dTiles,Zt as getAllTilesFrom3dTiles,u as getCameraView,a as getCesiumForAutoFitScale,P as getInoCesiumBaseUrl,n as initCesium,y as initCesiumEvent,Ht as load3dTiles,ii as loadI3s,ei as loadModel,Xt as loadTerrain,Qt as loadTerrainFromCesium,$t as loadTianDiTu,ti as loads3m,St as makeGridFromElevationExtrema,Et as makeGridToInstanceForBox,At as makeGridToInstanceForLine,Ue as makeLnglatToPosition,We as makeLnglatsToLineGeojson,$e as makeLnglatsToPointGeojson,He as makeLnglatsToPolygonGeojson,Ge as makeLnglatsToPositions,Ve as makePositionsClose,Be as makePositionsForAntiClockwise,Le as makePositionsForClockwise,ke as makePositionsToLnglats,Ne as makePositiontoLnglat,qe as makeYawPitchRollToHeadingPitchRoll,It as mekeGridPolygonAndHeight,b as numberId,S as randomColor,E as randomPointToGeoJson,T as randomPolygonToGeoJson,I as randomPolylineToGeoJson,Jt as removeTerrain,r as setCesiumForAutoFitScale,o as setGlobeOpatity,qt as setHeightOffsetFor3dTiles,x as setInoCesiumBaseUrl,l as setViewToLnglat,v as twinkleModel};
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "ino-cesium",
3
+ "type": "module",
4
+ "version": "0.0.15.beta.1",
5
+ "author": "koino",
6
+ "keywords": [
7
+ "cesium",
8
+ "ino-cesium"
9
+ ],
10
+ "exports": {
11
+ ".": "./dist/index.js",
12
+ "./ino-css": "./dist/ino-cesium.css"
13
+ },
14
+ "typesVersions": {
15
+ "*": {
16
+ "*": [
17
+ "./src/*",
18
+ "./dist/*"
19
+ ]
20
+ }
21
+ },
22
+ "files": [
23
+ "dist/*.css",
24
+ "dist/*.d.ts",
25
+ "dist/*.js",
26
+ "assets/*",
27
+ "README.MD"
28
+ ],
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "dependencies": {
33
+ "@ino-cesium/analysis": "0.0.15.beta.1",
34
+ "@ino-cesium/common": "0.0.15.beta.1",
35
+ "@ino-cesium/draw": "0.0.15.beta.1",
36
+ "@ino-cesium/effects": "0.0.15.beta.1",
37
+ "@ino-cesium/layers": "0.0.15.beta.1",
38
+ "@ino-cesium/material": "0.0.15.beta.1",
39
+ "@ino-cesium/primitive": "0.0.15.beta.1"
40
+ },
41
+ "peerDependencies": {
42
+ "cesium": "*"
43
+ },
44
+ "types": "./dist/index.d.ts",
45
+ "scripts": {
46
+ "build": "rimraf dist && rollup -c",
47
+ "clean": "rimraf dist",
48
+ "release": "pnpm publish --no-git-checks --access public ",
49
+ "unpublish": "pnpm unpublish ino-cesium --force "
50
+ }
51
+ }