ol-cesium
Version:
OpenLayers Cesium integration library
2 lines • 594 kB
JavaScript
/*! For license information please see commons.732f075a07b3917e2988.js.LICENSE.txt */
(self.webpackChunkol_cesium=self.webpackChunkol_cesium||[]).push([[351],{6459:(t,e,i)=>{"use strict";i.d(e,{Zw:()=>Dt,pv:()=>kt.pv,Kn:()=>Y,ZV:()=>kt.ZV,Re:()=>W,Ze:()=>z,ZP:()=>Gt,DQ:()=>V,Bq:()=>U,BN:()=>q,ss:()=>kt.ss});var s=i(1900);let n,r;function o(){if(void 0===n){const t=document.createElement("canvas");t.setAttribute("style","image-rendering: -moz-crisp-edges; image-rendering: crisp-edges; image-rendering: pixelated;");const e=t.style.imageRendering;n=!!e,n&&(r=e)}return n}function a(t){return t.get("olcs.projection")||t.getProjection()}let h=0;function l(t){return t.olcs_uid||(t.olcs_uid=++h)}function c(t){const e=t,i=e.readyPromise;return i||(void 0!==e.ready?e.ready?Promise.resolve(t):new Promise(((i,s)=>{const n=setInterval((()=>{e.ready&&(clearInterval(n),i(t))}),20)})):Promise.reject("Not a readyable object"))}if(/^(212|39|675)$/.test(i.j))var u=i(6646);var d=i(6424),g=i(6893),f=i(7811),m=i(1943),p=i(4871),_=i(2993),y=i(138),v=i(7156),x=i(3211),C=i(1505);function M(){const t=document.createElement("canvas");return t.width=1,t.height=1,t}const w=function(){const t=new C.Z({projection:"EPSG:3857",wrapX:!0}).getTileCoordForTileUrlFunction([6,-31,22]);return t&&33===t[1]&&22===t[2]}();class E{get ready(){return this.ready_}get rectangle(){return this.rectangle_}get tilingScheme(){return this.tilingScheme_}get _ready(){return this.ready_}get tileWidth(){const t=this.source_.getTileGrid();if(t){const e=t.getTileSize(0);return Array.isArray(e)?e[0]:e}return 256}get tileHeight(){const t=this.source_.getTileGrid();if(t){const e=t.getTileSize(0);return Array.isArray(e)?e[1]:e}return 256}get maximumLevel(){const t=this.source_.getTileGrid();return t?t.getMaxZoom():18}get minimumLevel(){return 0}get tileDiscardPolicy(){}get hasAlphaChannel(){return!0}pickFeatures(t,e,i,s,n){}constructor(t,e,i){this.emptyCanvas_=M(),this.emptyCanvasPromise_=Promise.resolve(this.emptyCanvas_),this.errorEvent=new Cesium.Event,this.source_=e,this.projection_=null,this.ready_=!1,this.fallbackProj_=i||null,this.tilingScheme_=new Cesium.WebMercatorTilingScheme,this.rectangle_=null,this.map_=t,this.shouldRequestNextLevel=!1;const s=this.source_.get("olcs.proxy");s&&("function"==typeof s?this.proxy={getURL:s}:"string"==typeof s&&(this.proxy=new Cesium.DefaultProxy(s))),this.source_.on("change",(t=>{this.handleSourceChanged_()})),this.handleSourceChanged_()}handleSourceChanged_(){if(!this.ready_&&"ready"==this.source_.getState()){this.projection_=a(this.source_)||this.fallbackProj_;const t={numberOfLevelZeroTilesX:1,numberOfLevelZeroTilesY:1};if(null!==this.source_.tileGrid&&this.source_.tileGrid.forEachTileCoord(this.projection_.getExtent(),0,(e=>{let[i,s,n]=e;t.numberOfLevelZeroTilesX=s+1,t.numberOfLevelZeroTilesY=n+1})),"EPSG:4326"===this.projection_.getCode())this.shouldRequestNextLevel=1===t.numberOfLevelZeroTilesX&&1===t.numberOfLevelZeroTilesY,this.tilingScheme_=new Cesium.GeographicTilingScheme(t);else{if("EPSG:3857"!==this.projection_.getCode())return;this.shouldRequestNextLevel=!1,this.tilingScheme_=new Cesium.WebMercatorTilingScheme(t)}this.rectangle_=this.tilingScheme_.rectangle,this.ready_=!0}}getTileCredits(t,e,i){const s=this.source_.getAttributions();if(!s)return[];const n=this.map_.getView().calculateExtent(this.map_.getSize()),r=this.map_.getView().getCenter();return st(s,this.shouldRequestNextLevel?i+1:i,r,n)}requestImage(t,e,i,s){const n=this.source_.getTileUrlFunction();if(n&&this.projection_){const s=this.shouldRequestNextLevel?i+1:i;let r=e;w||(r=-e-1);let o=n.call(this.source_,[s,t,r],1,this.projection_);return this.proxy&&(o=this.proxy.getURL(o)),o?Cesium.ImageryProvider.loadImage(this,o):this.emptyCanvasPromise_}return this.emptyCanvasPromise_}}var S=i(7707),b=i(8456),T=i(7774),R=i(3005),P=i(5907),I=i(6453);var L=i(594),A=i(6732),O=i(5096),F=i(629),Z=i(6890);const k=new S.Z({featureClass:Z.ZP}),N=[new b.ZP({stroke:new T.Z({color:"blue",width:2})})];class D{get minimumLevel(){return this.minimumLevel_}get ready(){return this.ready_}get rectangle(){return this.rectangle_}get tilingScheme(){return this.tilingScheme_}getTileCredits(t,e,i){return[]}get _ready(){return this.ready_}get tileDiscardPolicy(){}get hasAlphaChannel(){return!0}pickFeatures(t,e,i,s,n){}constructor(t){this.emptyCanvas_=M(),this.emptyCanvasPromise_=Promise.resolve(this.emptyCanvas_),this.tilingScheme_=new Cesium.WebMercatorTilingScheme,this.ready_=!0,this.tileWidth=256,this.tileHeight=256,this.maximumLevel=20,this.minimumLevel_=0,this.projection_=(0,f.U2)("EPSG:3857"),this.errorEvent=new Cesium.Event,this.urls=t.urls,this.rectangle_=t.rectangle||this.tilingScheme.rectangle,this.credit=t.credit,this.styleFunction_=t.styleFunction||(()=>N),this.tileRectangle_=new Cesium.Rectangle;const e=void 0!==t.cacheSize?t.cacheSize:50;this.tileCache=new A.Z(e),this.featureCache=t.featureCache||new A.Z(e),this.minimumLevel_=t.minimumLevel||0;const i=(0,O.X$)(this.projection_);this.tileFunction_=(0,F.uR)(this.urls,i)}getTileFeatures(t,e,i){const s=this.getCacheKey_(t,e,i);let n;if(this.featureCache.containsKey(s)&&(n=this.featureCache.get(s)),!n){const r=this.getUrl_(t,e,i);if(n=fetch(r).then((t=>t.ok?t:Promise.reject(t))).then((t=>t.arrayBuffer())).then((t=>this.readFeaturesFromBuffer(t))),this.featureCache.set(s,n),this.featureCache.getCount()>2*this.featureCache.highWaterMark)for(;this.featureCache.canExpireCache();)this.featureCache.pop()}return n}readFeaturesFromBuffer(t){let e;L.q4<="6.4.4"&&(e={extent:[0,0,4096,4096],dataProjection:this.projection_,featureProjection:this.projection_});const i=k.readFeatures(t,e),s=this.tileWidth/4096;return i.forEach((t=>{const e=t.getFlatCoordinates();let i=!1;for(let t=0;t<e.length;++t)e[t]*=s,i&&(e[t]=this.tileWidth-e[t]),L.q4<="6.4.4"&&(i=!i)})),i}getUrl_(t,e,i){return this.tileFunction_([t,e,i],1,this.projection_)}getCacheKey_(t,e,i){return`${t}_${e}_${i}`}requestImage(t,e,i,s){if(i<this.minimumLevel_)return this.emptyCanvasPromise_;try{const s=this.getCacheKey_(i,t,e);let n;if(this.tileCache.containsKey(s)&&(n=this.tileCache.get(s)),!n&&(n=this.getTileFeatures(i,t,e).then((s=>{this.tilingScheme.tileXYToNativeRectangle(t,e,i,this.tileRectangle_);const n=(this.tileRectangle_.east-this.tileRectangle_.west)/this.tileWidth;return this.rasterizeFeatures(s,this.styleFunction_,n)})),this.tileCache.set(s,n),this.tileCache.getCount()>2*this.tileCache.highWaterMark))for(;this.tileCache.canExpireCache();)this.tileCache.pop();return n}catch(t){this.errorEvent.raiseEvent("could not render pbf to tile",t)}}rasterizeFeatures(t,e,i){const s=document.createElement("canvas"),n=function(t,e){const i=t.canvas,s=(e=e||{}).pixelRatio||P.MP,n=e.size;n&&(i.width=n[0]*s,i.height=n[1]*s,i.style.width=n[0]+"px",i.style.height=n[1]+"px");const r=[0,0,i.width,i.height],o=(0,I.bA)((0,I.Ue)(),s,s);return new R.Z(t,s,r,o,0)}(s.getContext("2d"),{size:[this.tileWidth,this.tileHeight]});return t.forEach((t=>{const s=e(t,i);s&&(Array.isArray(s)?s.forEach((e=>{n.setStyle(e),n.drawGeometry(t)})):(n.setStyle(s),n.drawGeometry(t)))})),s}}var G=i(3522),j=i(6181);function z(t,e,i,s){void 0===e&&(e=0),void 0===i&&(i=Cesium.Cartesian3.ZERO),void 0===s&&(s=new Cesium.Cartesian3(1,1,1));const n=J(t),r=Cesium.Transforms.eastNorthUpToFixedFrame(n),o=Cesium.Quaternion.fromAxisAngle(Cesium.Cartesian3.UNIT_Z,-e),a=Cesium.Matrix4.fromTranslationQuaternionRotationScale(i,o,s);return Cesium.Matrix4.multiply(r,a,new Cesium.Matrix4)}function U(t,e,i,s,n){const r=Cesium.Math.clamp,o=Cesium.defaultValue,a=n,h=o(null==a?void 0:a.duration,500),l=o(null==a?void 0:a.easing,u.GE),c=null==a?void 0:a.callback;let d=0;const g=new Cesium.Matrix4,f=Date.now(),m=function(){const n=Date.now(),o=l(r((n-f)/h,0,1));t.transform.clone(g);const a=(o-d)*e;d=o,t.lookAtTransform(s),t.rotate(i,a),t.lookAtTransform(g),o<1?window.requestAnimationFrame(m):c&&c()};window.requestAnimationFrame(m)}function q(t,e,i,s){const n=t.camera,r=Y(t,i),o=n.right,a=Cesium.Quaternion.fromAxisAngle(o,r),h=Cesium.Matrix3.fromQuaternion(a),l=new Cesium.Cartesian3;Cesium.Cartesian3.subtract(n.position,i,l);const c=new Cesium.Cartesian3;Cesium.Matrix3.multiplyByVector(h,l,c),Cesium.Cartesian3.add(c,i,c);U(n,e,c,Cesium.Matrix4.fromTranslation(c),s)}function B(t,e){const i=t.camera.getPickRay(e);return t.globe.pick(i,t)||t.camera.pickEllipsoid(e)}function V(t){const e=t.canvas;return B(t,new Cesium.Cartesian2(e.clientWidth/2,e.clientHeight))}function W(t){const e=t.camera,i=new Cesium.Ray(e.position,e.direction);let s=t.globe.pick(i,t);if(!s){const t=Cesium.Ellipsoid.WGS84,e=Cesium.IntersectionTests.rayEllipsoid(i,t);e&&(s=Cesium.Ray.getPoint(i,e.start))}if(!s)return;const n=new Cesium.Cartesian3;Cesium.Ellipsoid.WGS84.geocentricSurfaceNormal(s,n);const r=X(e.direction,n,e.right)-Math.PI;return Cesium.Math.convertLongitudeRange(r)}function X(t,e,i){const s=new Cesium.Cartesian3,n=new Cesium.Cartesian3,r=new Cesium.Cartesian3;Cesium.Cartesian3.normalize(t,s),Cesium.Cartesian3.normalize(e,n),Cesium.Cartesian3.cross(s,n,r);const o=Cesium.Cartesian3.dot(s,n),a=Cesium.Cartesian3.magnitude(r),h=Cesium.Cartesian3.dot(i,r),l=Math.atan2(a,o);return h>=0?l:-l}function Y(t,e){const i=t.camera,s=i.frustum.fovy/2,n=function(t){const e=t.camera,i=e.frustum.fovy/2,s=e.direction,n=Cesium.Quaternion.fromAxisAngle(e.right,i),r=Cesium.Matrix3.fromQuaternion(n),o=new Cesium.Cartesian3;return Cesium.Matrix3.multiplyByVector(r,s,o),new Cesium.Ray(e.position,o)}(t),r=Cesium.Cartesian3.clone(n.direction);Cesium.Cartesian3.negate(r,r);const o=new Cesium.Cartesian3;Cesium.Ellipsoid.WGS84.geocentricSurfaceNormal(e,o);const a=new Cesium.Cartesian3;Cesium.Cartesian3.negate(i.right,a);return X(o,r,a)+s}function K(t,e){if(t&&e){const i=(0,f.$A)(t,e,"EPSG:4326");return Cesium.Rectangle.fromDegrees(i[0],i[1],i[2],i[3])}return null}function H(t,e,i){if(!(e instanceof d.Z||e instanceof g.Z||e instanceof G.Z))return null;const s=e.getSource();if(!s)return null;let n=s.get("olcs_provider");if(n||(n=function(t,e,i,s){const n=e.get("olcs_skip");if(n)return null;let r=null;if(e instanceof p.Z&&e.getUrl()&&e.getImageLoadFunction()===x.r6){const t={"olcs.proxy":e.get("olcs.proxy"),"olcs.extent":e.get("olcs.extent"),"olcs.projection":e.get("olcs.projection"),"olcs.imagesource":e};(e=new y.Z({url:e.getUrl(),attributions:e.getAttributions(),projection:e.getProjection(),params:e.getParams()})).setProperties(t)}if(e instanceof _.Z){let s=a(e);if(s||(s=i),!it(s))return null;r=new E(t,e,i)}else{if(!(e instanceof m.Z)){if(e instanceof v.Z&&s instanceof G.Z){let t=a(e);if(t||(t=i),!1===n){const i=t.getCode().split(":")[1],n=e.urls.map((t=>t.replace(i,"3857"))),o=s.getExtent(),a=K(o,t),h=e.get("olcs_minimumLevel"),l=e.getAttributions(),c=s.getStyleFunction();let u;return o&&l&&(u=st(l,0,(0,j.qg)(o),o)[0]),r=new D({credit:u,rectangle:a,minimumLevel:h,styleFunction:c,urls:n}),r}return null}return null}{let t=a(e);if(t||(t=i),!it(t))return null;{const t=Cesium.Rectangle.fromDegrees(e.getImageExtent()[0],e.getImageExtent()[1],e.getImageExtent()[2],e.getImageExtent()[3],new Cesium.Rectangle);r=new Cesium.SingleTileImageryProvider({url:e.getUrl(),rectangle:t})}}}return r}(t,s,i,e)),!n)return null;const r={},o=e.get("olcs.extent")||e.getExtent();o&&(r.rectangle=K(o,i));return new Cesium.ImageryLayer(n,r)}function $(t,e){let i=1,s=!0;[t.layer].concat(t.parents).forEach((t=>{const e=t.getOpacity();void 0!==e&&(i*=e);const n=t.getVisible();void 0!==n&&(s=s&&n)})),e.alpha=i,e.show=s}function J(t){const e=t;return e.length>2?Cesium.Cartesian3.fromDegrees(e[0],e[1],e[2]):Cesium.Cartesian3.fromDegrees(e[0],e[1])}function Q(t){const e=J,i=[];for(let s=0;s<t.length;++s)i.push(e(t[s]));return i}function tt(t,e){const i=(0,f.U2)("EPSG:4326"),s=(0,f.U2)(e);if(s.getCode()!==i.getCode()){const e=t.getProperties();(t=t.clone()).transform(s,i),t.setProperties(e)}return t}function et(t){if(t=t||"black",Array.isArray(t))return new Cesium.Color(Cesium.Color.byteToFloat(t[0]),Cesium.Color.byteToFloat(t[1]),Cesium.Color.byteToFloat(t[2]),t[3]);if("string"==typeof t)return Cesium.Color.fromCssColorString(t);if(t instanceof CanvasPattern||t instanceof CanvasGradient){const e=document.createElement("canvas"),i=e.getContext("2d");return e.width=e.height=256,i.fillStyle=t,i.fillRect(0,0,e.width,e.height),new Cesium.ImageMaterialProperty({image:e})}}function it(t){const e="EPSG:3857"===t.getCode(),i="EPSG:4326"===t.getCode();return e||i}function st(t,e,i,s){if(!t)return[];let n=t({viewState:{zoom:e,center:i,projection:void 0,resolution:void 0,rotation:void 0},extent:s});return Array.isArray(n)||(n=[n]),n.map((t=>new Cesium.Credit(t,!0)))}class nt{constructor(t){this.repaintEventNames_=["mousemove","mousedown","mouseup","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","wheel"],this.ol3d=t,this.scene_=t.getCesiumScene(),this.canvas_=this.scene_.canvas,this._boundNotifyRepaintRequired=this.notifyRepaintRequired.bind(this),this.enable()}enable(){this.scene_.requestRenderMode=!0,this.scene_.maximumRenderTimeChange=1e3;for(const t of this.repaintEventNames_)this.canvas_.addEventListener(t,this._boundNotifyRepaintRequired,!1);window.addEventListener("resize",this._boundNotifyRepaintRequired,!1),this.ol3d.getOlMap().getLayerGroup().on("change",this._boundNotifyRepaintRequired)}disable(){for(const t of this.repaintEventNames_)this.canvas_.removeEventListener(t,this._boundNotifyRepaintRequired,!1);window.removeEventListener("resize",this._boundNotifyRepaintRequired,!1),this.ol3d.getOlMap().getLayerGroup().un("change",this._boundNotifyRepaintRequired),this.scene_.requestRenderMode=!1}restartRenderLoop(){this.notifyRepaintRequired()}notifyRepaintRequired(){this.scene_.requestRender()}}var rt=i(2428),ot=i(6091);function at(t,e,i){const s=i||t.length;if(e)for(let i=0;i<s;++i)e[i]=t[i];return t}class ht{constructor(t,e){this.viewListenKey_=null,this.toLonLat_=at,this.fromLonLat_=at,this.tilt_=0,this.distance_=0,this.lastCameraViewMatrix_=null,this.viewUpdateInProgress_=!1,this.scene_=t,this.cam_=t.camera,this.map_=e,this.map_.on("change:view",(t=>{this.setView_(this.map_.getView())})),this.setView_(this.map_.getView())}destroy(){(0,rt.B)(this.viewListenKey_),this.viewListenKey_=null}setView_(t){if(this.view_&&((0,rt.B)(this.viewListenKey_),this.viewListenKey_=null),this.view_=t,t){const e=(0,f.Ck)(t.getProjection(),"EPSG:4326"),i=(0,f.Ck)("EPSG:4326",t.getProjection());this.toLonLat_=e,this.fromLonLat_=i,this.viewListenKey_=t.on("propertychange",(t=>this.handleViewChangedEvent_())),this.readFromView()}else this.toLonLat_=at,this.fromLonLat_=at}handleViewChangedEvent_(){this.viewUpdateInProgress_||this.readFromView()}setHeading(t){this.view_&&this.view_.setRotation(t)}getHeading(){if(!this.view_)return;return this.view_.getRotation()||0}setTilt(t){this.tilt_=t,this.updateCamera_()}getTilt(){return this.tilt_}setDistance(t){this.distance_=t,this.updateCamera_(),this.updateView()}getDistance(){return this.distance_}setCenter(t){this.view_&&this.view_.setCenter(t)}getCenter(){if(this.view_)return this.view_.getCenter()}setPosition(t){if(!this.toLonLat_)return;const e=this.toLonLat_(t),i=new Cesium.Cartographic((0,ot.Y)(e[0]),(0,ot.Y)(e[1]),this.getAltitude());this.cam_.setView({destination:Cesium.Ellipsoid.WGS84.cartographicToCartesian(i)}),this.updateView()}getPosition(){if(!this.fromLonLat_)return;const t=Cesium.Ellipsoid.WGS84.cartesianToCartographic(this.cam_.position);return this.fromLonLat_([(0,ot.U)(t.longitude),(0,ot.U)(t.latitude)])}setAltitude(t){const e=Cesium.Ellipsoid.WGS84.cartesianToCartographic(this.cam_.position);e.height=t,this.cam_.position=Cesium.Ellipsoid.WGS84.cartographicToCartesian(e),this.updateView()}getAltitude(){return Cesium.Ellipsoid.WGS84.cartesianToCartographic(this.cam_.position).height}updateCamera_(){if(!this.view_||!this.toLonLat_)return;const t=this.view_.getCenter();if(!t)return;const e=this.toLonLat_(t),i=new Cesium.Cartographic((0,ot.Y)(e[0]),(0,ot.Y)(e[1]));if(this.scene_.globe){const t=this.scene_.globe.getHeight(i);i.height=t||0}const s=Cesium.Ellipsoid.WGS84.cartographicToCartesian(i),n={pitch:this.tilt_-Cesium.Math.PI_OVER_TWO,heading:-this.view_.getRotation(),roll:void 0};this.cam_.setView({destination:s,orientation:n}),this.cam_.moveBackward(this.distance_),this.checkCameraChange(!0)}readFromView(){if(!this.view_||!this.toLonLat_)return;const t=this.view_.getCenter();if(null==t)return;const e=this.toLonLat_(t),i=this.view_.getResolution();this.distance_=this.calcDistanceForResolution(i||0,(0,ot.Y)(e[1])),this.updateCamera_()}updateView(){if(!this.view_||!this.fromLonLat_)return;this.viewUpdateInProgress_=!0;const t=Cesium.Ellipsoid.WGS84,e=this.scene_,i=function(t){const e=t.canvas;return B(t,new Cesium.Cartesian2(e.clientWidth/2,e.clientHeight/2))}(e);let s=i;if(!s){const t=e.globe,i=this.cam_.positionCartographic.clone(),n=t.getHeight(i);i.height=n||0,s=Cesium.Ellipsoid.WGS84.cartographicToCartesian(i)}this.distance_=Cesium.Cartesian3.distance(s,this.cam_.position);const n=t.cartesianToCartographic(s);if(this.view_.setCenter(this.fromLonLat_([(0,ot.U)(n.longitude),(0,ot.U)(n.latitude)])),this.view_.setResolution(this.calcResolutionForDistance(this.distance_,n?n.latitude:0)),i){const e=this.cam_.position,s=new Cesium.Cartesian3;t.geocentricSurfaceNormal(i,s);const n=new Cesium.Cartesian3;Cesium.Cartesian3.subtract(e,i,n),Cesium.Cartesian3.normalize(n,n);const r=this.cam_.up,o=this.cam_.right,a=new Cesium.Cartesian3(-i.y,i.x,0),h=Cesium.Cartesian3.angleBetween(o,a),l=Cesium.Cartesian3.cross(i,r,new Cesium.Cartesian3).z;this.view_.setRotation(l<0?h:-h);const c=Math.acos(Cesium.Cartesian3.dot(s,n));this.tilt_=isNaN(c)?0:c}else this.view_.setRotation(this.cam_.heading),this.tilt_=-this.cam_.pitch+Math.PI/2;this.viewUpdateInProgress_=!1}checkCameraChange(t){const e=this.lastCameraViewMatrix_,i=this.cam_.viewMatrix;e&&Cesium.Matrix4.equalsEpsilon(e,i,1e-7)||(this.lastCameraViewMatrix_=i.clone(),!0!==t&&this.updateView())}calcDistanceForResolution(t,e){return function(t,e,i,s){const n=i.canvas,r=i.camera.frustum.fovy,o=s.getMetersPerUnit();return t*n.clientHeight*o*Math.cos(Math.abs(e))/2/Math.tan(r/2)}(t,e,this.scene_,this.view_.getProjection())}calcResolutionForDistance(t,e){return function(t,e,i,s){const n=i.canvas,r=i.camera.frustum.fovy,o=s.getMetersPerUnit();return 2*t*Math.tan(r/2)/o/Math.cos(Math.abs(e))/n.clientHeight}(t,e,this.scene_,this.view_.getProjection())}}var lt=i(7291);class ct{constructor(t,e){this.layerMap={},this.olLayerListenKeys={},this.olGroupListenKeys_={},this.map=t,this.view=t.getView(),this.scene=e,this.olLayers=t.getLayerGroup().getLayers(),this.mapLayerGroup=t.getLayerGroup()}synchronize(){this.destroyAll(),this.addLayers_(this.mapLayerGroup)}orderLayers(){}addLayers_(t){const e=[{layer:t,parents:[]}];for(;e.length>0;){const t=e.splice(0,1)[0],i=t.layer,s=l(i).toString();this.olLayerListenKeys[s]=[];let n=null;if(i instanceof lt.Z)this.listenForGroupChanges_(i),i!==this.mapLayerGroup&&(n=this.createSingleLayerCounterparts(t)),n||i.getLayers().forEach((s=>{if(s){const n={layer:s,parents:i===this.mapLayerGroup?[]:[t.layer].concat(t.parents)};e.push(n)}}));else if(n=this.createSingleLayerCounterparts(t),!n){const e=s,i=t,n=()=>{const t=this.createSingleLayerCounterparts(i);t&&(i.layer.un("change",n),this.addCesiumObjects_(t,e,i.layer),this.orderLayers())};this.olLayerListenKeys[s].push(i.layer.on("change",n))}n&&this.addCesiumObjects_(n,s,i)}this.orderLayers()}addCesiumObjects_(t,e,i){this.layerMap[e]=t,this.olLayerListenKeys[e].push(i.on("change:zIndex",(()=>this.orderLayers()))),t.forEach((t=>{this.addCesiumObject(t)}))}removeAndDestroySingleLayer_(t){const e=l(t).toString(),i=this.layerMap[e];return i&&(i.forEach((t=>{this.removeSingleCesiumObject(t,!1),this.destroyCesiumObject(t)})),this.olLayerListenKeys[e].forEach(rt.B),delete this.olLayerListenKeys[e]),delete this.layerMap[e],!!i}unlistenSingleGroup_(t){if(t===this.mapLayerGroup)return;const e=l(t).toString();this.olGroupListenKeys_[e].forEach((t=>{(0,rt.B)(t)})),delete this.olGroupListenKeys_[e],delete this.layerMap[e]}removeLayer_(t){if(t){const e=[t];for(;e.length>0;){const t=e.splice(0,1)[0],i=this.removeAndDestroySingleLayer_(t);t instanceof lt.Z&&(this.unlistenSingleGroup_(t),i||t.getLayers().forEach((t=>{e.push(t)})))}}}listenForGroupChanges_(t){const e=l(t).toString(),i=[];this.olGroupListenKeys_[e]=i;let s=[];const n=function(){const e=t.getLayers();e&&(s=[e.on("add",(t=>{this.addLayers_(t.element)})),e.on("remove",(t=>{this.removeLayer_(t.element)}))],i.push(...s))}.bind(this);n(),i.push(t.on("change:layers",(t=>{s.forEach((t=>{const e=i.indexOf(t);e>=0&&i.splice(e,1),(0,rt.B)(t)})),n()})))}destroyAll(){let t;for(t in this.removeAllCesiumObjects(!0),this.olGroupListenKeys_){this.olGroupListenKeys_[t].forEach(rt.B)}for(t in this.olLayerListenKeys)this.olLayerListenKeys[t].forEach(rt.B);this.olGroupListenKeys_={},this.olLayerListenKeys={},this.layerMap={}}}var ut=i(7277);class dt extends ct{constructor(t,e){super(t,e),this.cesiumLayers_=e.imageryLayers,this.ourLayers_=new Cesium.ImageryLayerCollection}addCesiumObject(t){this.cesiumLayers_.add(t),this.ourLayers_.add(t)}destroyCesiumObject(t){t.destroy()}removeSingleCesiumObject(t,e){this.cesiumLayers_.remove(t,e),this.ourLayers_.remove(t,!1)}removeAllCesiumObjects(t){for(let e=0;e<this.ourLayers_.length;++e)this.cesiumLayers_.remove(this.ourLayers_.get(e),t);this.ourLayers_.removeAll(!1)}convertLayerToCesiumImageries(t,e){const i=H(this.map,t,e);return i?[i]:null}createSingleLayerCounterparts(t){const e=t.layer,i=l(e).toString(),s=this.view.getProjection(),n=this.convertLayerToCesiumImageries(e,s);if(n){const s=[];if([t.layer].concat(t.parents).forEach((e=>{s.push(e.on(["change:opacity","change:visible"],(()=>{for(let e=0;e<n.length;++e)$(t,n[e])})))})),e instanceof ut.Z){let t=e.getStyleFunction();s.push(e.on("change",(()=>{const i=e.getStyleFunction();if(t!==i){t=i;for(let t=0;t<n.length;++t){const e=n[t];e._imageryCache&&(e._imageryCache={});const r=e.imageryProvider;var s;if(r)null==(s=r.tileCache)||s.clear(),r.styleFunction_=i}this.scene.requestRender()}})))}for(let e=0;e<n.length;++e)$(t,n[e]);s.push(e.on("change:extent",(t=>{for(let t=0;t<n.length;++t)this.cesiumLayers_.remove(n[t],!0),this.ourLayers_.remove(n[t],!1);delete this.layerMap[l(e)],this.synchronize()}))),s.push(e.on("change",(t=>{for(let t=0;t<n.length;++t){const e=this.cesiumLayers_.indexOf(n[t]);e>=0&&(this.cesiumLayers_.remove(n[t],!1),this.cesiumLayers_.add(n[t],e))}}))),this.olLayerListenKeys[i].push(...s)}return Array.isArray(n)?n:null}orderLayers(){const t=[],e={},i=[this.mapLayerGroup];for(;i.length>0;){const s=i.splice(0,1)[0];if(t.push(s),e[l(s)]=s.getZIndex()||0,s instanceof lt.Z){const t=s.getLayers();t&&i.unshift(...t.getArray())}}t.sort(((t,i)=>e[l(t)]-e[l(i)])),t.forEach((t=>{const e=l(t).toString(),i=this.layerMap[e];i&&i.forEach((t=>{this.raiseToTop(t)}))}))}raiseToTop(t){this.cesiumLayers_.raiseToTop(t)}}var gt=i(3797),ft=(i(4115),i(2115)),mt=i(4993),pt=i(6707),_t=i(7972);class yt extends gt.Z{constructor(t){super({attributions:t.attributions,wrapX:t.wrapX}),this.resolution=void 0,this.distance=void 0!==t.distance?t.distance:20,this.minDistance=t.minDistance||0,this.interpolationRatio=0,this.features=[],this.geometryFunction=t.geometryFunction||function(t){const e=t.getGeometry();return(0,_t.h)(!e||"Point"===e.getType(),"The default `geometryFunction` can only handle `Point` or null geometries"),e},this.createCustomCluster_=t.createCluster,this.source=null,this.boundRefresh_=this.refresh.bind(this),this.updateDistance(this.distance,this.minDistance),this.setSource(t.source||null)}clear(t){this.features.length=0,super.clear(t)}getDistance(){return this.distance}getSource(){return this.source}loadFeatures(t,e,i){this.source.loadFeatures(t,e,i),e!==this.resolution&&(this.resolution=e,this.refresh())}setDistance(t){this.updateDistance(t,this.minDistance)}setMinDistance(t){this.updateDistance(this.distance,t)}getMinDistance(){return this.minDistance}setSource(t){this.source&&this.source.removeEventListener(ft.Z.CHANGE,this.boundRefresh_),this.source=t,t&&t.addEventListener(ft.Z.CHANGE,this.boundRefresh_),this.refresh()}refresh(){this.clear(),this.cluster(),this.addFeatures(this.features)}updateDistance(t,e){const i=0===t?0:Math.min(e,t)/t,s=t!==this.distance||this.interpolationRatio!==i;this.distance=t,this.minDistance=e,this.interpolationRatio=i,s&&this.refresh()}cluster(){if(void 0===this.resolution||!this.source)return;const t=(0,j.lJ)(),e=this.distance*this.resolution,i=this.source.getFeatures(),s={};for(let n=0,r=i.length;n<r;n++){const r=i[n];if(!((0,L.sq)(r)in s)){const i=this.geometryFunction(r);if(i){const n=i.getCoordinates();(0,j.HK)(n,t),(0,j.f3)(t,e,t);const r=this.source.getFeaturesInExtent(t).filter((function(t){const e=(0,L.sq)(t);return!(e in s)&&(s[e]=!0,!0)}));this.features.push(this.createCluster(r,t))}}}}createCluster(t,e){const i=[0,0];for(let e=t.length-1;e>=0;--e){const s=this.geometryFunction(t[e]);s?(0,pt.IH)(i,s.getCoordinates()):t.splice(e,1)}(0,pt.bA)(i,1/t.length);const n=(0,j.qg)(e),r=this.interpolationRatio,o=new s.Z([i[0]*(1-r)+n[0]*r,i[1]*(1-r)+n[1]*r]);return this.createCustomCluster_?this.createCustomCluster_(o,t):new mt.Z({geometry:o,features:t})}}const vt=yt;var xt=i(4949),Ct=i(2076),Mt=i(1169),wt=i(4206);class Et{constructor(t,e){this.olListenKeys=[];const i=new Cesium.BillboardCollection({scene:e}),s=new Cesium.PrimitiveCollection;this.rootCollection_=new Cesium.PrimitiveCollection,this.context={projection:t,billboards:i,featureToCesiumMap:{},primitives:s},this.rootCollection_.add(i),this.rootCollection_.add(s)}destroy(){this.olListenKeys.forEach(rt.B),this.olListenKeys.length=0}getRootPrimitive(){return this.rootCollection_}}var St=i(1815);class bt{constructor(t){this.boundOnRemoveOrClearFeatureListener_=this.onRemoveOrClearFeature_.bind(this),this.defaultBillboardEyeOffset_=new Cesium.Cartesian3(0,0,10),this.scene=t,this.scene=t}onRemoveOrClearFeature_(t){const e=t.target,i=e.olcs_cancellers;if(i){const s=t.feature;if(s){const t=l(s),e=i[t];e&&(e(),delete i[t])}else{for(const t in i)i.hasOwnProperty(t)&&i[t]();e.olcs_cancellers={}}}}setReferenceForPicking(t,e,i){i.olLayer=t,i.olFeature=e}createColoredPrimitive(t,e,i,s,n,r){const o={flat:!0,renderState:{depthTest:{enabled:!0}}};void 0!==r&&(o.renderState.lineWidth=r);const a=function(t,e){const i=new Cesium.GeometryInstance({geometry:t});return!e||e instanceof Cesium.ImageMaterialProperty||(i.attributes={color:Cesium.ColorGeometryInstanceAttribute.fromColor(e)}),i}(s,n);let h;if(this.getHeightReference(t,e,i)===Cesium.HeightReference.CLAMP_TO_GROUND){if(!("createShadowVolume"in a.geometry.constructor))return null;h=new Cesium.GroundPrimitive({geometryInstances:a})}else h=new Cesium.Primitive({geometryInstances:a});if(n instanceof Cesium.ImageMaterialProperty){const t=n.image.getValue().toDataURL();h.appearance=new Cesium.MaterialAppearance({flat:!0,renderState:{depthTest:{enabled:!0}},material:new Cesium.Material({fabric:{type:"Image",uniforms:{image:t}}})})}else h.appearance=new Cesium.MaterialAppearance({...o,material:new Cesium.Material({translucent:1!==n.alpha,fabric:{type:"Color",uniforms:{color:n}}})}),h instanceof Cesium.Primitive&&(e.get("olcs_shadows")||t.get("olcs_shadows"))&&(h.shadows=1);return this.setReferenceForPicking(t,e,h),h}extractColorFromOlStyle(t,e){const i=t.getFill()?t.getFill().getColor():null,s=t.getStroke()?t.getStroke().getColor():null;let n="black";return s&&e?n=s:i&&(n=i),et(n)}extractLineWidthFromOlStyle(t){const e=t.getStroke()?t.getStroke().getWidth():void 0;return void 0!==e?e:1}wrapFillAndOutlineGeometries(t,e,i,s,n,r){const o=this.extractColorFromOlStyle(r,!1),a=this.extractColorFromOlStyle(r,!0),h=new Cesium.PrimitiveCollection;if(r.getFill()){const n=this.createColoredPrimitive(t,e,i,s,o);h.add(n)}if(r.getStroke()&&n){const s=this.extractLineWidthFromOlStyle(r),o=this.createColoredPrimitive(t,e,i,n,a,s);o&&h.add(o)}return h}addTextStyle(t,e,i,s,n){let r;if(n instanceof Cesium.PrimitiveCollection?r=n:(r=new Cesium.PrimitiveCollection,r.add(n)),!s.getText())return r;const o=s.getText(),a=this.olGeometry4326TextPartToCesium(t,e,i,o);return a&&r.add(a),r}csAddBillboard(t,e,i,s,n,r){e.eyeOffset||(e.eyeOffset=this.defaultBillboardEyeOffset_);const o=t.add(e);return this.setReferenceForPicking(i,s,o),o}olCircleGeometryToCesium(t,e,i,s,n){const r=(i=tt(i,s)).getCenter(),o=3==r.length?r[2]:0,a=r.slice();a[0]+=i.getRadius();const h=J(r),l=J(a),u=Cesium.Cartesian3.distance(h,l),d=new Cesium.CircleGeometry({center:h,radius:u,height:o});let g,f;if(this.getHeightReference(t,e,i)===Cesium.HeightReference.CLAMP_TO_GROUND){const s=this.extractLineWidthFromOlStyle(n);if(s){const r=Q((0,Mt.iu)(i.getCenter(),u).getLinearRing(0).getCoordinates()),o=g=new Cesium.GroundPolylinePrimitive({geometryInstances:new Cesium.GeometryInstance({geometry:new Cesium.GroundPolylineGeometry({positions:r,width:s})}),appearance:new Cesium.PolylineMaterialAppearance({material:this.olStyleToCesium(e,n,!0)}),classificationType:Cesium.ClassificationType.TERRAIN});c(g).then((()=>{this.setReferenceForPicking(t,e,o._primitive)}))}}else f=new Cesium.CircleOutlineGeometry({center:h,radius:u,extrudedHeight:o,height:o});const m=this.wrapFillAndOutlineGeometries(t,e,i,d,f,n);return g&&m.add(g),this.addTextStyle(t,e,i,n,m)}olLineStringGeometryToCesium(t,e,i,s,n){const r=Q((i=tt(i,s)).getCoordinates()),o=this.extractLineWidthFromOlStyle(n);let a;const h=this.getHeightReference(t,e,i),l=new Cesium.PolylineMaterialAppearance({material:this.olStyleToCesium(e,n,!0)});if(h===Cesium.HeightReference.CLAMP_TO_GROUND){const i=new Cesium.GroundPolylineGeometry({positions:r,width:o}),s=a=new Cesium.GroundPolylinePrimitive({appearance:l,geometryInstances:new Cesium.GeometryInstance({geometry:i})});c(a).then((()=>{this.setReferenceForPicking(t,e,s._primitive)}))}else{const t=new Cesium.PolylineGeometry({positions:r,width:o,vertexFormat:l.vertexFormat});a=new Cesium.Primitive({appearance:l,geometryInstances:new Cesium.GeometryInstance({geometry:t})})}return this.setReferenceForPicking(t,e,a),this.addTextStyle(t,e,i,n,a)}olPolygonGeometryToCesium(t,e,i,s,n){i=tt(i,s);const r=this.getHeightReference(t,e,i);let o,a,h;if(5==i.getCoordinates()[0].length&&"rectangle"===e.get("olcs.polygon_kind")){const t=i.getCoordinates()[0],s=(0,j.hI)(t),n=Cesium.Rectangle.fromDegrees(s[0],s[1],s[2],s[3]);let r=0;if(3==t[0].length)for(let e=0;e<t.length;e++)r=Math.max(r,t[e][2]);const h=e.get("olcs_extruded_height");o=new Cesium.RectangleGeometry({ellipsoid:Cesium.Ellipsoid.WGS84,rectangle:n,height:r,extrudedHeight:h}),a=new Cesium.RectangleOutlineGeometry({ellipsoid:Cesium.Ellipsoid.WGS84,rectangle:n,height:r,extrudedHeight:h})}else{const s=i.getLinearRings(),l={positions:[],holes:[]},u=l;for(let t=0;t<s.length;++t){const e=Q(s[t].getCoordinates());0===t?l.positions=e:l.holes.push({positions:e,holes:[]})}const d=e.get("olcs_extruded_height");if(o=new Cesium.PolygonGeometry({polygonHierarchy:u,perPositionHeight:!0,extrudedHeight:d}),r===Cesium.HeightReference.CLAMP_TO_GROUND){const i=this.extractLineWidthFromOlStyle(n);if(i>0){const s=[l.positions];if(l.holes)for(let t=0;t<l.holes.length;++t)s.push(l.holes[t].positions);const r=new Cesium.PolylineMaterialAppearance({material:this.olStyleToCesium(e,n,!0)}),o=[];for(const t of s){const e=new Cesium.GroundPolylineGeometry({positions:t,width:i});o.push(new Cesium.GeometryInstance({geometry:e}))}h=new Cesium.GroundPolylinePrimitive({appearance:r,geometryInstances:o}),c(h).then((()=>{this.setReferenceForPicking(t,e,h._primitive)}))}}else a=new Cesium.PolygonOutlineGeometry({polygonHierarchy:l,perPositionHeight:!0,extrudedHeight:d})}const l=this.wrapFillAndOutlineGeometries(t,e,i,o,a,n);return h&&l.add(h),this.addTextStyle(t,e,i,n,l)}getHeightReference(t,e,i){let s=i.get("altitudeMode");void 0===s&&(s=e.get("altitudeMode")),void 0===s&&(s=t.get("altitudeMode"));let n=Cesium.HeightReference.NONE;return"clampToGround"===s?n=Cesium.HeightReference.CLAMP_TO_GROUND:"relativeToGround"===s&&(n=Cesium.HeightReference.RELATIVE_TO_GROUND),n}createBillboardFromImage(t,e,i,s,n,r,o,a){r instanceof Ct.Z&&r.load();const h=r.getImage(1),c=function(){if(!h)return;if(!(h instanceof HTMLCanvasElement||h instanceof Image||h instanceof HTMLImageElement))return;const s=J(i.getCoordinates());let l;const c=r.getOpacity();void 0!==c&&(l=new Cesium.Color(1,1,1,c));const u=r.getScale(),d=this.getHeightReference(t,e,i),g={image:h,color:l,scale:u,heightReference:d,position:s};if(Object.assign(g,e.get("cesiumOptions")),r instanceof Ct.Z){const t=r.getAnchor();if(t){const e=Array.isArray(u)?u[0]:u,i=Array.isArray(u)?u[1]:u;g.pixelOffset=new Cesium.Cartesian2((h.width/2-t[0])*e,(h.height/2-t[1])*i)}}const f=this.csAddBillboard(o,g,t,e,i,n);a&&a(f)}.bind(this);if(h instanceof Image&&!function(t){return""!=t.src&&0!=t.naturalHeight&&0!=t.naturalWidth&&t.complete}(h)){let i=!1;const s=t.getSource(),n=function(){i=!0};s.on(["removefeature","clear"],this.boundOnRemoveOrClearFeatureListener_);let r=s.olcs_cancellers;r||(r=s.olcs_cancellers={});const a=l(e);r[a]&&r[a](),r[a]=n;const u=function(){h.removeEventListener("load",u),o.isDestroyed()||i||c()};h.addEventListener("load",u)}else c()}olPointGeometryToCesium(t,e,i,s,n,r,o){i=tt(i,s);let a=null;const h=n.getImage();if(h){const l=i.get("olcs_model")||e.get("olcs_model");if(l){a=new Cesium.PrimitiveCollection;const t=l(),e=Object.assign({},{scene:this.scene},t.cesiumOptions);if("fromGltf"in Cesium.Model){const t=Cesium.Model.fromGltf(e);a.add(t)}else Cesium.Model.fromGltfAsync(e).then((t=>{a.add(t)}));t.debugModelMatrix&&a.add(new Cesium.DebugModelMatrixPrimitive({modelMatrix:t.debugModelMatrix}))}else this.createBillboardFromImage(t,e,i,s,n,h,r,o)}return n.getText()?this.addTextStyle(t,e,i,n,a||new Cesium.Primitive):a}olMultiGeometryToCesium(t,e,i,s,n,r,o){switch(i.getType()){case"MultiPoint":{const a=i.getPoints();if(n.getText()){const i=new Cesium.PrimitiveCollection;return a.forEach((a=>{const h=this.olPointGeometryToCesium(t,e,a,s,n,r,o);h&&i.add(h)})),i}return a.forEach((i=>{this.olPointGeometryToCesium(t,e,i,s,n,r,o)})),null}case"MultiLineString":{const r=i.getLineStrings(),o=new Cesium.PrimitiveCollection;return r.forEach((i=>{const r=this.olLineStringGeometryToCesium(t,e,i,s,n);o.add(r)})),o}case"MultiPolygon":{const r=i.getPolygons(),o=new Cesium.PrimitiveCollection;return r.forEach((i=>{const r=this.olPolygonGeometryToCesium(t,e,i,s,n);o.add(r)})),o}}}olGeometry4326TextPartToCesium(t,e,i,s){const n=s.getText();if(!n)return null;const r=new Cesium.LabelCollection({scene:this.scene}),o=(0,j.qg)(i.getExtent());if(i instanceof wt.ZP){const t=i.getFirstCoordinate();o[2]=3==t.length?t[2]:0}const a={};a.position=J(o),a.text=n,a.heightReference=this.getHeightReference(t,e,i);const h=s.getOffsetX(),l=s.getOffsetY();if(0!=h||0!=l){const t=new Cesium.Cartesian2(h,l);a.pixelOffset=t}let c,u;switch(a.font=s.getFont()||"10px sans-serif",s.getFill()&&(a.fillColor=this.extractColorFromOlStyle(s,!1),c=Cesium.LabelStyle.FILL),s.getStroke()&&(a.outlineWidth=this.extractLineWidthFromOlStyle(s),a.outlineColor=this.extractColorFromOlStyle(s,!0),c=Cesium.LabelStyle.OUTLINE),s.getFill()&&s.getStroke()&&(c=Cesium.LabelStyle.FILL_AND_OUTLINE),a.style=c,s.getTextAlign()){case"left":u=Cesium.HorizontalOrigin.LEFT;break;case"right":u=Cesium.HorizontalOrigin.RIGHT;break;default:u=Cesium.HorizontalOrigin.CENTER}if(a.horizontalOrigin=u,s.getTextBaseline()){let t;switch(s.getTextBaseline()){case"top":case"alphabetic":t=Cesium.VerticalOrigin.TOP;break;case"middle":t=Cesium.VerticalOrigin.CENTER;break;case"bottom":case"hanging":t=Cesium.VerticalOrigin.BOTTOM}a.verticalOrigin=t}const d=r.add(a);return this.setReferenceForPicking(t,e,d),r}olStyleToCesium(t,e,i){const s=e.getFill(),n=e.getStroke();if(i&&!n||!i&&!s)return null;const r=et(i?n.getColor():s.getColor());return i&&n.getLineDash()?Cesium.Material.fromType("Stripe",{horizontal:!1,repeat:500,evenColor:r,oddColor:new Cesium.Color(0,0,0,0)}):Cesium.Material.fromType("Color",{color:r})}computePlainStyle(t,e,i,s){const n=e.getStyleFunction();let r=null;return n&&(r=n(e,s)),!r&&i&&(r=i(e,s)),r?Array.isArray(r)?r:[r]:null}getGeometryFromFeature(t,e,i){if(i)return i;const s=t.get("olcs.3d_geometry");if(s&&s instanceof St.Z)return s;if(e){const i=e.getGeometryFunction()(t);if(i instanceof St.Z)return i}return t.getGeometry()}olFeatureToCesium(t,e,i,s,n){const r=this.getGeometryFromFeature(e,i,n);if(!r)return null;const o=s.projection,a=function(t){const i=s.featureToCesiumMap[l(e)];i instanceof Array?i.push(t):s.featureToCesiumMap[l(e)]=[t]};switch(r.getType()){case"GeometryCollection":const n=new Cesium.PrimitiveCollection;return r.getGeometriesArray().forEach((r=>{if(r){const o=this.olFeatureToCesium(t,e,i,s,r);o&&n.add(o)}})),n;case"Point":const h=s.billboards,l=this.olPointGeometryToCesium(t,e,r,o,i,h,a);return l||null;case"Circle":return this.olCircleGeometryToCesium(t,e,r,o,i);case"LineString":return this.olLineStringGeometryToCesium(t,e,r,o,i);case"Polygon":return this.olPolygonGeometryToCesium(t,e,r,o,i);case"MultiPoint":case"MultiLineString":case"MultiPolygon":return this.olMultiGeometryToCesium(t,e,r,o,i,s.billboards,a)||null;case"LinearRing":throw new Error("LinearRing should only be part of polygon.");default:throw new Error(`Ol geom type not handled : ${r.getType()}`)}}olVectorLayerToCesium(t,e,i){const s=e.getProjection(),n=e.getResolution();if(void 0===n||!s)throw new Error("View not ready");let r=t.getSource();r instanceof vt&&(r=r.getSource());const o=r.getFeatures(),a=new Et(s,this.scene),h=a.context;for(let e=0;e<o.length;++e){const s=o[e];if(!s)continue;const r=t.getStyleFunction(),c=this.computePlainStyle(t,s,r,n);if(!c||!c.length)continue;let u=null;for(let e=0;e<c.length;e++){const i=this.olFeatureToCesium(t,s,c[e],h);if(i)if(u){if(i){let t,e=0;for(;t=i.get(e);)u.add(t),e++}}else u=i}u&&(i[l(s)]=u,a.getRootPrimitive().add(u))}return a}convert(t,e,i,s){const n=e.getProjection(),r=e.getResolution();if(null==r||!n)return null;const o=t.getStyleFunction(),a=this.computePlainStyle(t,i,o,r);if(!a||!a.length)return null;s.projection=n;let h=null;for(let e=0;e<a.length;e++){const n=this.olFeatureToCesium(t,i,a[e],s);if(h){if(n){let t,e=0;for(;t=n.get(e);)h.add(t),e++}}else h=n}return h}}class Tt extends ct{constructor(t,e,i){super(t,e),this.converter=i||new bt(e),this.csAllPrimitives_=new Cesium.PrimitiveCollection,e.primitives.add(this.csAllPrimitives_),this.csAllPrimitives_.destroyPrimitives=!1}addCesiumObject(t){t.getRootPrimitive().counterpart=t,this.csAllPrimitives_.add(t.getRootPrimitive())}destroyCesiumObject(t){t.getRootPrimitive().destroy()}removeSingleCesiumObject(t,e){t.destroy(),this.csAllPrimitives_.destroyPrimitives=e,this.csAllPrimitives_.remove(t.getRootPrimitive()),this.csAllPrimitives_.destroyPrimitives=!1}removeAllCesiumObjects(t){if(this.csAllPrimitives_.destroyPrimitives=t,t)for(let t=0;t<this.csAllPrimitives_.length;++t)this.csAllPrimitives_.get(t).counterpart.destroy();this.csAllPrimitives_.removeAll(),this.csAllPrimitives_.destroyPrimitives=!1}updateLayerVisibility(t,e){let i=!0;[t.layer].concat(t.parents).forEach((t=>{const e=t.getVisible();i=void 0!==e&&(i&&e)})),e.show=i}createSingleLayerCounterparts(t){const e=t.layer;if(!(e instanceof xt.Z)||e instanceof G.Z)return null;let i=e.getSource();if(i instanceof vt&&(i=i.getSource()),!i)return null;const s=this.view,n={},r=this.converter.olVectorLayerToCesium(e,s,n),o=r.getRootPrimitive(),a=r.olListenKeys;[t.layer].concat(t.parents).forEach((e=>{a.push(e.on("change:visible",(()=>{this.updateLayerVisibility(t,o)})))})),this.updateLayerVisibility(t,o);const h=t=>{const i=r.context,a=this.converter.convert(e,s,t,i);a&&(n[l(t)]=a,o.add(a))},c=t=>{const e=l(t),i=r.context,s=i.featureToCesiumMap[e];s&&(delete i.featureToCesiumMap[e],s.forEach((t=>{t instanceof Cesium.Billboard&&i.billboards.remove(t)})));const a=n[e];delete n[e],a&&o.remove(a)};return a.push(i.on("addfeature",(t=>{h(t.feature)}))),a.push(i.on("removefeature",(t=>{c(t.feature)}))),a.push(i.on("changefeature",(t=>{const e=t.feature;c(e),h(e)}))),r?[r]:null}}var Rt=i(6015);function Pt(t,e){const i=t.cloneNode();if("CANVAS"===t.nodeName){i.getContext("2d").drawImage(t,0,0)}e&&e.appendChild(i),t.nodeType!==Node.TEXT_NODE&&i.addEventListener("click",(e=>{t.dispatchEvent(new MouseEvent("click",e)),e.stopPropagation()}));const s=t.childNodes;for(let t=0;t<s.length;t++)s[t]&&Pt(s[t],i);return i}class It extends Rt.Z{constructor(t){const e=t.parent;super(e.getOptions()),this.scenePostRenderListenerRemover_=null,this.attributeObserver_=[],this.scene_=t.scene,this.synchronizer_=t.synchronizer,this.parent_=e,this.positionWGS84_=void 0,this.observer_=new MutationObserver(this.handleElementChanged.bind(this)),this.attributeObserver_=[],this.listenerKeys_=[];const i=t=>this.setPropertyFromEvent_(t);this.listenerKeys_.push(this.parent_.on("change:element",i)),this.listenerKeys_.push(this.parent_.on("change:offset",i)),this.listenerKeys_.push(this.parent_.on("change:position",i)),this.listenerKeys_.push(this.parent_.on("change:positioning",i)),this.setProperties(this.parent_.getProperties()),this.handleMapChanged(),this.handleElementChanged()}observeTarget_(t){if(this.observer_){this.observer_.disconnect(),this.observer_.observe(t,{attributes:!1,childList:!0,characterData:!0,subtree:!0}),this.attributeObserver_.forEach((t=>{t.disconnect()})),this.attributeObserver_.length=0;for(let e=0;e<t.childNodes.length;e++){const i=t.childNodes[e];if(1===i.nodeType){const t=new MutationObserver(this.handleElementChanged.bind(this));t.observe(i,{attributes:!0,subtree:!0}),this.attributeObserver_.push(t)}}}}setPropertyFromEvent_(t){t.target&&t.key&&this.set(t.key,t.target.get(t.key))}getScene(){return this.scene_}handleMapChanged(){var t;this.scenePostRenderListenerRemover_&&(this.scenePostRenderListenerRemover_(),(t=this.element)&&t.parentNode&&t.parentNode.removeChild(t)),this.scenePostRenderListenerRemover_=null;const e=this.getScene();if(e){this.scenePostRenderListenerRemover_=e.postRender.addEventListener(this.updatePixelPosition.bind(this)),this.updatePixelPosition();const t=this.stopEvent?this.synchronizer_.getOverlayContainerStopEvent():this.synchronizer_.getOverlayContainer();this.insertFirst?t.insertBefore(this.element,t.childNodes[0]||null):t.appendChild(this.element)}}handlePositionChanged(){const t=this.getPosition();if(t){const e=this.parent_.getMap().getView().getProjection();this.positionWGS84_=(0,f.vs)(t,e,"EPSG:4326")}else this.positionWGS84_=void 0;this.updatePixelPosition()}handleElementChanged(){!function(t){for(;t.lastChild;)t.removeChild(t.lastChild)}(this.element);const t=this.getElement();if(t&&t.parentNode&&t.parentNode.childNodes)for(const e of Array.from(t.parentNode.childNodes)){const t=Pt(e,null);this.element.appendChild(t)}t.parentNode&&this.observeTarget_(t.parentNode)}updatePixelPosition(){const t=this.positionWGS84_;if(!this.scene_||!t)return void this.setVisible(!1);let e=0;if(2===t.length){const i=this.scene_.globe.getHeight(Cesium.Cartographic.fromDegrees(t[0],t[1]));i&&this.scene_.globe.tilesLoaded&&(t[2]=i),i&&(e=i)}else e=t[2];const i=Cesium.Cartesian3.fromDegrees(t[0],t[1],e),s=this.scene_.camera,n=new Cesium.BoundingSphere(new Cesium.Cartesian3,6356752);if(!new Cesium.Occluder(n,s.position).isPointVisible(i))return void this.setVisible(!1);if(1!==s.frustum.computeCullingVolume(s.position,s.direction,s.up).computeVisibility(new Cesium.BoundingSphere(i)))return void this.setVisible(!1);this.setVisible(!0);const r=this.scene_.cartesianToCanvasCoordinates(i),o=[r.x,r.y],a=[this.scene_.canvas.width,this.scene_.canvas.height];this.updateRenderedPosition(o,a)}destroy(){this.scenePostRenderListenerRemover_&&this.scenePostRenderListenerRemover_(),this.observer_&&this.observer_.disconnect(),(0,rt.B)(this.listenerKeys_),this.listenerKeys_.splice(0),"removeNode"in this.element?this.element.removeNode(!0):this.element.remove(),this.element=null}}class Lt{constructor(t,e){this.overlayMap_=new Map,this.overlayEvents=["click","dblclick","mousedown","touchstart","pointerdown","mousewheel","wheel"],this.map=t,this.scene=e,this.map=t,this.overlayCollection_=this.map.getOverlays(),this.scene=e,this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.overlayEvents.forEach((t=>{this.overlayContainerStopEvent_.addEventListener(t,(t=>t.stopPropagation()))})),this.scene.canvas.parentElement.appendChild(this.overlayContainerStopEvent_),this.overlayContainer_=document.createElement("div"),this.overlayContainer_.className="ol-overlaycontainer",this.scene.canvas.parentElement.appendChild(this.overlayContainer_)}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOverlayContainer(){return this.overlayContainer_}synchronize(){this.destroyAll(),this.overlayCollection_.forEach((t=>{this.addOverlay(t)})),this.overlayCollection_.on("add",(t=>this.addOverlay(t.element))),this.overlayCollection_.on("remove",(t=>this.removeOverlay(t.element)))}addOverlay(t){if(!t)return;const e=new It({scene:this.scene,synchronizer:this,parent:t});this.overlayMap_.set(l(t),e)}removeOverlay(t){const e=l(t),i=this.overlayMap_.get(e);i&&(i.destroy(),this.overlayMap_.delete(e))}destroyAll(){this.overlayMap_.forEach((t=>{t.destroy()})),this.overlayMap_.clear()}}const At=0,Ot=1,Ft=2;class Zt{constructor(t){this.autoRenderLoop_=null,this.resolutionScale_=1,this.canvasClientWidth_=0,this.canvasClientHeight_=0,this.resolutionScaleChanged_=!0,this.enabled_=!1,this.pausedInteractions_=[],this.hiddenRootGroup_=null,this.lastFrameTime_=0,this.targetFrameRate_=Number.POSITIVE_INFINITY,this.blockCesiumRendering_=!1,this.warmingUp_=!1,this.trackedFeature_=null,this.trackedEntity_=null,this.entityView_=null,this.needTrackedEntityUpdate_=!1,this.boundingSphereScratch_=new Cesium.BoundingSphere,this.map_=t.map,this.time_=t.time||function(){return Cesium.JulianDate.now()},this.to4326Transform_=(0,f.Ck)(this.map_.getView().getProjection(),"EPSG:4326");const e="position:absolute;top:0;left:0;width:100%;height:100%;touch-action:none;";this.container_=document.createElement("DIV");const i=document.createAttribute("style");i.value=`${e}visibility:hidden;`,this.container_.setAttributeNode(i);let s=t.target||this.map_.getViewport();if("string"==typeof s&&(s=document.getElementById(s)),s.appendChild(this.container_),this.isOverMap_=!t.target,this.isOverMap_&&t.stopOpenLayersEventsPropagation){const t=["click","dblclick","mousedown","touchstart","pointerdown","mousewheel","wheel"];for(let e=0,i=t.length;e<i;++e)this.container_.addEventListener(t[e],(t=>t.stopPropagation()))}this.canvas_=document.createElement("canvas");const n=document.createAttribute("style");n.value=e,this.canvas_.setAttributeNode(n),o()&&(this.canvas_.style.imageRendering=(o(),r||"")),this.canvas_.oncontextmenu=function(){return!1},this.canvas_.onselectstart=function(){return!1},this.container_.appendChild(this.canvas_);const a=void 0!==t.sceneOptions?{...t.sceneOptions,canvas:this.canvas_,scene3DOnly:!0}:{canvas:this.canvas_,scene3DOnly:!0};this.scene_=new Cesium.Scene(a);const h=this.scene_.screenSpaceCameraController;Array.isArray(h.tiltEventTypes)&&(h.tiltEventTypes.push({eventType:Cesium.CameraEventType.LEFT_DRAG,modifier:Cesium.KeyboardEventModifier.SHIFT}),h.tiltEventTypes.push({eventType:Cesium.CameraEventType.LEFT_DRAG,modifier:Cesium.KeyboardEventModifier.ALT})),h.enableLook=!1,this.scene_.camera.constrainedAxis=Cesium.Cartesian3.UNIT_Z,this.camera_=new ht(this.scene_,this.map_),this.globe_=new Cesium.Globe(Cesium.Ellipsoid.WGS84),this.globe_.baseColor=Cesium.Color.WHITE,this.scene_.globe=this.globe_,this.scene_.skyAtmosphere=new Cesium.SkyAtmosphere;const l=new Cesium.SingleTileImageryProvider({tileHeight:1,tileWidth:1,url:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",rectangle:Cesium.Rectangle.fromDegrees(0,0,1,1)});this.globe_.imageryLayers.addImageryProvider(l,0),this.dataSourceCollection_=new Cesium.DataSourceCollection,this.dataSourceDisplay_=new Cesium.DataSourceDisplay({scene:this.scene_,dataSourceCollection:this.dataSourceCollection_}),this.synchronizers_=t.createSynchronizers?t.createSynchronizers(this.map_,this.scene_,this.dataSourceCollection_):[new dt(this.map_,this.scene_),new Tt(this.map_,this.scene_),new Lt(this.map_,this.scene_)],this.handleResize_();for(let t=this.synchronizers_.length-1;t>=0;--t)this.synchronizers_[t].synchronize();(new Cesium.EventHelper).add(this.scene_.postRender,Zt.prototype.updateTrackedEntity_,this)}destroy(){cancelAnimationFrame(this.renderId_),this.renderId_=void 0,this.synchronizers_.forEach((t=>t.destroyAll())),this.camera_.destroy(),this.scene_.destroy(),this.scene_._postRender=null,this.container_.remove()}render_(){void 0!==this.renderId_&&(cancelAnimationFrame(this.renderId_),this.renderId_=void 0),!this.enabled_&&!this.warmingUp_||this.blockCesiumRendering_||(this.renderId_=requestAnimationFrame(this.onAnimationFrame_.bind(this)))}onAnimationFrame_(t){this.renderId_=void 0;const e=1e3/this.targetFrameRate_;if(t-this.lastFrameTime_<e)return void this.render_();this.lastFrameTime_=t;const i=this.time_();if(this.scene_.initializeFrame(),this.handleResize_(),this.dataSourceDisplay_.update(i),this.entityView_){const t=this.trackedEntity_;this.dataSourceDisplay_.getBoundingSphere(t,!1,this.boundingSphereScratch_)===At&&(this.boundingSphereScratch_.radius=1,this.entityView_.update(i,this.boundingSphereScratch_))}this.scene_.render(i),this.camera_.checkCameraChange(),this.render_()}updateTrackedEntity_(){if(!this.needTrackedEntityUpdate_)return;const t=this.trackedEntity_,e=this.scene_,i=this.dataSourceDisplay_.getBoundingSphere(t,!1,this.boundingSphereScratch_);if(i===O