runbir-tools 1.0.20 → 1.0.21

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.
@@ -23860,11 +23860,12 @@ class Typhoon {
23860
23860
  // 台风圈中心点经度
23861
23861
  y: Number(t.latitude),
23862
23862
  // 台风圈中心点维度
23863
+ // 数据顺序:东北、东南、西南、西北(NE, SE, SW, NW)
23863
23864
  r: {
23864
- SE: lengthToDegrees(r[3]),
23865
- NE: lengthToDegrees(r[2]),
23866
- NW: lengthToDegrees(r[1]),
23867
- SW: lengthToDegrees(r[0])
23865
+ NE: lengthToDegrees(r[0]),
23866
+ SE: lengthToDegrees(r[1]),
23867
+ SW: lengthToDegrees(r[2]),
23868
+ NW: lengthToDegrees(r[3])
23868
23869
  },
23869
23870
  interval: 2,
23870
23871
  // 6° 一个间隔;间隔越小,台风圈越平滑
@@ -6,4 +6,4 @@
6
6
  `).reduce(createTextChunks,[]),{width:f,height:m,widths:p,heights:_,lineWidths:y}=getTextDimensions(l,g),A=f+d,x=[],C=(A+2)*h[0],T=(m+d)*h[1],S={width:C<0?Math.floor(C):Math.ceil(C),height:T<0?Math.floor(T):Math.ceil(T),contextInstructions:x};(h[0]!=1||h[1]!=1)&&x.push("scale",h),s&&(x.push("strokeStyle",o.strokeStyle),x.push("lineWidth",d),x.push("lineCap",o.lineCap),x.push("lineJoin",o.lineJoin),x.push("miterLimit",o.miterLimit),x.push("setLineDash",[o.lineDash]),x.push("lineDashOffset",o.lineDashOffset)),i&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const w=.5-u;let I=u*A+w*d;const L=[],D=[];let b=0,P=0,O=0,G=0,k;for(let N=0,F=g.length;N<F;N+=2){const B=g[N];if(B===`
7
7
  `){P+=b,b=0,I=u*A+w*d,++G;continue}const W=g[N+1]||l.font;W!==k&&(s&&L.push("font",W),i&&D.push("font",W),k=W),b=Math.max(b,_[O]);const X=[B,I+w*p[O]+u*(p[O]-y[G]),.5*(d+b)+P];I+=p[O],s&&L.push("strokeText",X),i&&D.push("fillText",X),++O}return Array.prototype.push.apply(x,L),Array.prototype.push.apply(x,D),this.labels_[r]=S,S}replayTextBackground_(e,t,i,s,r,o,a){e.beginPath(),e.moveTo.apply(e,t),e.lineTo.apply(e,i),e.lineTo.apply(e,s),e.lineTo.apply(e,r),e.lineTo.apply(e,t),o&&(this.alignAndScaleFill_=o[2],e.fillStyle=o[1],this.fill_(e)),a&&(this.setStrokeStyle_(e,a),e.stroke())}calculateImageOrLabelDimensions_(e,t,i,s,r,o,a,l,c,h,u,d,g,f,m,p){a*=d[0],l*=d[1];let _=i-a,y=s-l;const A=r+c>e?e-c:r,x=o+h>t?t-h:o,C=f[3]+A*d[0]+f[1],T=f[0]+x*d[1]+f[2],S=_-f[3],w=y-f[0];(m||u!==0)&&(p1[0]=S,p4[0]=S,p1[1]=w,p2[1]=w,p2[0]=S+C,p3[0]=p2[0],p3[1]=w+T,p4[1]=p3[1]);let I;return u!==0?(I=compose(create(),i,s,1,1,u,-i,-s),apply(I,p1),apply(I,p2),apply(I,p3),apply(I,p4),createOrUpdate$2(Math.min(p1[0],p2[0],p3[0],p4[0]),Math.min(p1[1],p2[1],p3[1],p4[1]),Math.max(p1[0],p2[0],p3[0],p4[0]),Math.max(p1[1],p2[1],p3[1],p4[1]),tmpExtent)):createOrUpdate$2(Math.min(S,S+C),Math.min(w,w+T),Math.max(S,S+C),Math.max(w,w+T),tmpExtent),g&&(_=Math.round(_),y=Math.round(y)),{drawImageX:_,drawImageY:y,drawImageW:A,drawImageH:x,originX:c,originY:h,declutterBox:{minX:tmpExtent[0],minY:tmpExtent[1],maxX:tmpExtent[2],maxY:tmpExtent[3],value:p},canvasTransform:I,scale:d}}replayImageOrLabel_(e,t,i,s,r,o,a){const l=!!(o||a),c=s.declutterBox,h=a?a[2]*s.scale[0]/2:0;return c.minX-h<=t[0]&&c.maxX+h>=0&&c.minY-h<=t[1]&&c.maxY+h>=0&&(l&&this.replayTextBackground_(e,p1,p2,p3,p4,o,a),drawImageOrLabel(e,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(e){const t=this.alignAndScaleFill_;if(t){const i=apply(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;e.save(),e.translate(i[0]%s,i[1]%s),t!==1&&e.scale(t,t),e.rotate(this.viewRotation_)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],t[1]&&(e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6]))}drawLabelWithPointPlacement_(e,t,i,s){const r=this.textStates[t],o=this.createLabel(e,t,s,i),a=this.strokeStates[i],l=this.pixelRatio,c=horizontalTextAlign(Array.isArray(e)?e[0]:e,r.textAlign||defaultTextAlign),h=TEXT_ALIGN[r.textBaseline||defaultTextBaseline],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],g=c*d+2*(.5-c)*u,f=h*o.height/l+2*(.5-h)*u;return{label:o,anchorX:g,anchorY:f}}execute_(e,t,i,s,r,o,a,l){const c=this.zIndexContext_;let h;this.pixelCoordinates_&&equals$2(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=transform2D(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),setFromArray(this.renderedTransform_,i));let u=0;const d=s.length;let g=0,f,m,p,_,y,A,x,C,T,S,w,I,L,D=0,b=0;const P=this.coordinateCache_,O=this.viewRotation_,G=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,k={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:O},N=this.instructions!=s||this.overlaps?0:200;let F,B,W,X;for(;u<d;){const v=s[u];switch(v[0]){case Instruction.BEGIN_GEOMETRY:F=v[1],X=v[3],F.getGeometry()?a!==void 0&&!intersects$1(a,X.getExtent())?u=v[2]+1:++u:u=v[2],c&&(c.zIndex=v[4]);break;case Instruction.BEGIN_PATH:D>N&&(this.fill_(e),D=0),b>N&&(e.stroke(),b=0),!D&&!b&&(e.beginPath(),y=NaN,A=NaN),++u;break;case Instruction.CIRCLE:g=v[1];const j=h[g],Y=h[g+1],q=h[g+2],K=h[g+3],se=q-j,ie=K-Y,Q=Math.sqrt(se*se+ie*ie);e.moveTo(j+Q,Y),e.arc(j,Y,Q,0,2*Math.PI,!0),++u;break;case Instruction.CLOSE_PATH:e.closePath(),++u;break;case Instruction.CUSTOM:g=v[1],f=v[2];const Ae=v[3],Se=v[4],_e=v[5];k.geometry=Ae,k.feature=F,u in P||(P[u]=[]);const ce=P[u];_e?_e(h,g,f,2,ce):(ce[0]=h[g],ce[1]=h[g+1],ce.length=2),c&&(c.zIndex=v[6]),Se(ce,k),++u;break;case Instruction.DRAW_IMAGE:g=v[1],f=v[2],T=v[3],m=v[4],p=v[5];let J=v[6];const re=v[7],ge=v[8],fe=v[9],ye=v[10];let ue=v[11];const pe=v[12];let me=v[13];_=v[14]||"declutter";const z=v[15];if(!T&&v.length>=20){S=v[19],w=v[20],I=v[21],L=v[22];const $=this.drawLabelWithPointPlacement_(S,w,I,L);T=$.label,v[3]=T;const de=v[23];m=($.anchorX-de)*this.pixelRatio,v[4]=m;const ee=v[24];p=($.anchorY-ee)*this.pixelRatio,v[5]=p,J=T.height,v[6]=J,me=T.width,v[13]=me}let Ie;v.length>25&&(Ie=v[25]);let ve,Te,we;v.length>17?(ve=v[16],Te=v[17],we=v[18]):(ve=defaultPadding,Te=null,we=null),ye&&G?ue+=O:!ye&&!G&&(ue-=O);let Ge=0;for(;g<f;g+=2){if(Ie&&Ie[Ge++]<me/this.pixelRatio)continue;const $=this.calculateImageOrLabelDimensions_(T.width,T.height,h[g],h[g+1],me,J,m,p,ge,fe,ue,pe,r,ve,!!Te||!!we,F),de=[e,t,T,$,re,Te,we];if(l){let ee,oe,te;if(z){const U=f-g;if(!z[U]){z[U]={args:de,declutterMode:_};continue}const H=z[U];ee=H.args,oe=H.declutterMode,delete z[U],te=getDeclutterBox(ee)}let ae,le;if(ee&&(oe!=="declutter"||!l.collides(te))&&(ae=!0),(_!=="declutter"||!l.collides($.declutterBox))&&(le=!0),oe==="declutter"&&_==="declutter"){const U=ae&&le;ae=U,le=U}ae&&(oe!=="none"&&l.insert(te),this.replayImageOrLabel_.apply(this,ee)),le&&(_!=="none"&&l.insert($.declutterBox),this.replayImageOrLabel_.apply(this,de))}else this.replayImageOrLabel_.apply(this,de)}++u;break;case Instruction.DRAW_CHARS:const Me=v[1],Oe=v[2],Re=v[3],Be=v[4];L=v[5];const We=v[6],be=v[7],De=v[8];I=v[9];const Le=v[10];S=v[11],Array.isArray(S)&&(S=S.reduce(richTextToPlainText,"")),w=v[12];const Fe=[v[13],v[13]];_=v[14]||"declutter";const Xe=v[15],Pe=this.textStates[w],Ee=Pe.font,xe=[Pe.scale[0]*be,Pe.scale[1]*be];let Ce;Ee in this.widths_?Ce=this.widths_[Ee]:(Ce={},this.widths_[Ee]=Ce);const ke=lineStringLength(h,Me,Oe,2),Ne=Math.abs(xe[0])*measureAndCacheTextWidth(Ee,S,Ce);if(Be||Ne<=ke){const $=this.textStates[w].textAlign,de=(ke-Ne)*horizontalTextAlign(S,$),ee=drawTextOnPath(h,Me,Oe,2,S,de,We,Math.abs(xe[0]),measureAndCacheTextWidth,Ee,Ce,G?0:this.viewRotation_,Xe);e:if(ee){const oe=[];let te,ae,le,U,H;if(I)for(te=0,ae=ee.length;te<ae;++te){H=ee[te],le=H[4],U=this.createLabel(le,w,"",I),m=H[2]+(xe[0]<0?-Le:Le),p=Re*U.height+(.5-Re)*2*Le*xe[1]/xe[0]-De;const he=this.calculateImageOrLabelDimensions_(U.width,U.height,H[0],H[1],U.width,U.height,m,p,0,0,H[3],Fe,!1,defaultPadding,!1,F);if(l&&_==="declutter"&&l.collides(he.declutterBox))break e;oe.push([e,t,U,he,1,null,null])}if(L)for(te=0,ae=ee.length;te<ae;++te){H=ee[te],le=H[4],U=this.createLabel(le,w,L,""),m=H[2],p=Re*U.height-De;const he=this.calculateImageOrLabelDimensions_(U.width,U.height,H[0],H[1],U.width,U.height,m,p,0,0,H[3],Fe,!1,defaultPadding,!1,F);if(l&&_==="declutter"&&l.collides(he.declutterBox))break e;oe.push([e,t,U,he,1,null,null])}l&&_!=="none"&&l.load(oe.map(getDeclutterBox));for(let he=0,Ue=oe.length;he<Ue;++he)this.replayImageOrLabel_.apply(this,oe[he])}}++u;break;case Instruction.END_GEOMETRY:if(o!==void 0){F=v[1];const $=o(F,X,_);if($)return $}++u;break;case Instruction.FILL:N?D++:this.fill_(e),++u;break;case Instruction.MOVE_TO_LINE_TO:for(g=v[1],f=v[2],B=h[g],W=h[g+1],e.moveTo(B,W),y=B+.5|0,A=W+.5|0,g+=2;g<f;g+=2)B=h[g],W=h[g+1],x=B+.5|0,C=W+.5|0,(g==f-2||x!==y||C!==A)&&(e.lineTo(B,W),y=x,A=C);++u;break;case Instruction.SET_FILL_STYLE:this.alignAndScaleFill_=v[2],D&&(this.fill_(e),D=0,b&&(e.stroke(),b=0)),e.fillStyle=v[1],++u;break;case Instruction.SET_STROKE_STYLE:b&&(e.stroke(),b=0),this.setStrokeStyle_(e,v),++u;break;case Instruction.STROKE:N?b++:e.stroke(),++u;break;default:++u;break}}D&&this.fill_(e),b&&e.stroke()}execute(e,t,i,s,r,o){this.viewRotation_=s,this.execute_(e,t,i,this.instructions,r,void 0,void 0,o)}executeHitDetection(e,t,i,s,r){return this.viewRotation_=i,this.execute_(e,[e.canvas.width,e.canvas.height],t,this.hitDetectionInstructions,!0,s,r)}}const ALL=["Polygon","Circle","LineString","Image","Text","Default"],DECLUTTER=["Image","Text"],NON_DECLUTTER=ALL.filter(n=>!DECLUTTER.includes(n));class ExecutorGroup{constructor(e,t,i,s,r,o,a){this.maxExtent_=e,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=t,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=create(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(e,t){const i=this.getClipCoords(t);e.beginPath(),e.moveTo(i[0],i[1]),e.lineTo(i[2],i[3]),e.lineTo(i[4],i[5]),e.lineTo(i[6],i[7]),e.clip()}createExecutors_(e,t){for(const i in e){let s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=e[i];for(const o in r){const a=r[o];s[o]=new Executor(this.resolution_,this.pixelRatio_,this.overlaps_,a,t)}}}hasExecutors(e){for(const t in this.executorsByZIndex_){const i=this.executorsByZIndex_[t];for(let s=0,r=e.length;s<r;++s)if(e[s]in i)return!0}return!1}forEachFeatureAtCoordinate(e,t,i,s,r,o){s=Math.round(s);const a=s*2+1,l=compose(this.hitDetectionTransform_,s+.5,s+.5,1/t,-1/t,-i,-e[0],-e[1]),c=!this.hitDetectionContext_;c&&(this.hitDetectionContext_=createCanvasContext2D(a,a));const h=this.hitDetectionContext_;h.canvas.width!==a||h.canvas.height!==a?(h.canvas.width=a,h.canvas.height=a):c||h.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=createEmpty(),extendCoordinate(u,e),buffer(u,t*(this.renderBuffer_+s),u));const d=getPixelIndexArray(s);let g;function f(C,T,S){const w=h.getImageData(0,0,a,a).data;for(let I=0,L=d.length;I<L;I++)if(w[d[I]]>0){if(!o||S==="none"||g!=="Image"&&g!=="Text"||o.includes(C)){const D=(d[I]-3)/4,b=s-D%a,P=s-(D/a|0),O=r(C,T,b*b+P*P);if(O)return O}h.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(ascending);let p,_,y,A,x;for(p=m.length-1;p>=0;--p){const C=m[p].toString();for(y=this.executorsByZIndex_[C],_=ALL.length-1;_>=0;--_)if(g=ALL[_],A=y[g],A!==void 0&&(x=A.executeHitDetection(h,l,i,f,u),x))return x}}getClipCoords(e){const t=this.maxExtent_;if(!t)return null;const i=t[0],s=t[1],r=t[2],o=t[3],a=[i,s,i,o,r,o,r,s];return transform2D(a,0,8,2,e,a),a}isEmpty(){return isEmpty$1(this.executorsByZIndex_)}execute(e,t,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?descending:ascending),o=o||ALL;const c=ALL.length;for(let h=0,u=l.length;h<u;++h){const d=l[h].toString(),g=this.executorsByZIndex_[d];for(let f=0,m=o.length;f<m;++f){const p=o[f],_=g[p];if(_!==void 0){const y=a===null?void 0:_.getZIndexContext(),A=y?y.getContext():e,x=this.maxExtent_&&p!=="Image"&&p!=="Text";if(x&&(A.save(),this.clip(A,i)),!y||p==="Text"||p==="Image"?_.execute(A,t,i,s,r,a):y.pushFunction(C=>_.execute(C,t,i,s,r,a)),x&&A.restore(),y){y.offset();const C=l[h]*c+ALL.indexOf(p);this.deferredZIndexContexts_[C]||(this.deferredZIndexContexts_[C]=[]),this.deferredZIndexContexts_[C].push(y)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(ascending);for(let i=0,s=t.length;i<s;++i)e[t[i]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),e[t[i]].length=0}}const circlePixelIndexArrayCache={};function getPixelIndexArray(n){if(circlePixelIndexArrayCache[n]!==void 0)return circlePixelIndexArrayCache[n];const e=n*2+1,t=n*n,i=new Array(t+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>t)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*e+(n+o))*4+3),r>0&&l.push(((n-r)*e+(n+o))*4+3),o>0&&(l.push(((n+r)*e+(n-o))*4+3),r>0&&l.push(((n-r)*e+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;r<o;++r)i[r]&&s.push(...i[r]);return circlePixelIndexArrayCache[n]=s,s}const HIT_DETECT_RESOLUTION=.5;function createHitDetectionImageData(n,e,t,i,s,r,o,a,l){const c=s,h=n[0]*HIT_DETECT_RESOLUTION,u=n[1]*HIT_DETECT_RESOLUTION,d=createCanvasContext2D(h,u);d.imageSmoothingEnabled=!1;const g=d.canvas,f=new CanvasImmediateRenderer(d,HIT_DETECT_RESOLUTION,s,null,o,a,null),m=t.length,p=Math.floor((256*256*256-1)/m),_={};for(let A=1;A<=m;++A){const x=t[A-1],C=x.getStyleFunction()||i;if(!C)continue;let T=C(x,r);if(!T)continue;Array.isArray(T)||(T=[T]);const w=(A*p).toString(16).padStart(7,"#00000");for(let I=0,L=T.length;I<L;++I){const D=T[I],b=D.getGeometryFunction()(x);if(!b||!intersects$1(c,b.getExtent()))continue;const P=D.clone(),O=P.getFill();O&&O.setColor(w);const G=P.getStroke();G&&(G.setColor(w),G.setLineDash(null)),P.setText(void 0);const k=D.getImage();if(k){const W=k.getImageSize();if(!W)continue;const X=createCanvasContext2D(W[0],W[1],void 0,{alpha:!1}),v=X.canvas;X.fillStyle=w,X.fillRect(0,0,v.width,v.height),P.setImage(new Icon({img:v,anchor:k.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:k.getOrigin(),opacity:1,size:k.getSize(),scale:k.getScale(),rotation:k.getRotation(),rotateWithView:k.getRotateWithView()}))}const N=P.getZIndex()||0;let F=_[N];F||(F={},_[N]=F,F.Polygon=[],F.Circle=[],F.LineString=[],F.Point=[]);const B=b.getType();if(B==="GeometryCollection"){const W=b.getGeometriesArrayRecursive();for(let X=0,v=W.length;X<v;++X){const V=W[X];F[V.getType().replace("Multi","")].push(V,P)}}else F[B.replace("Multi","")].push(b,P)}}const y=Object.keys(_).map(Number).sort(ascending);for(let A=0,x=y.length;A<x;++A){const C=_[y[A]];for(const T in C){const S=C[T];for(let w=0,I=S.length;w<I;w+=2){f.setStyle(S[w+1]);for(let L=0,D=e.length;L<D;++L)f.setTransform(e[L]),f.drawGeometry(S[w])}}}return d.getImageData(0,0,g.width,g.height)}function hitDetect(n,e,t){const i=[];if(t){const s=Math.floor(Math.round(n[0])*HIT_DETECT_RESOLUTION),r=Math.floor(Math.round(n[1])*HIT_DETECT_RESOLUTION),o=(clamp(s,0,t.width-1)+clamp(r,0,t.height-1)*t.width)*4,a=t.data[o],l=t.data[o+1],h=t.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/e.length);h&&h%u===0&&i.push(e[h/u-1])}return i}const maxStaleKeys=5;class LayerRenderer extends Observable{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.staleKeys_=new Array,this.maxStaleKeys=maxStaleKeys}getStaleKeys(){return this.staleKeys_}prependStaleKey(e){this.staleKeys_.unshift(e),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(e){return abstract()}getData(e){return null}prepareFrame(e){return abstract()}renderFrame(e,t){return abstract()}forEachFeatureAtCoordinate(e,t,i,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){const t=e.target;(t.getState()===ImageState.LOADED||t.getState()===ImageState.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=ImageState.LOADED&&t!=ImageState.ERROR&&e.addEventListener(EventType.CHANGE,this.boundHandleImageChange_),t==ImageState.IDLE&&(e.load(),t=e.getState()),t==ImageState.LOADED}renderIfReadyAndVisible(){const e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const canvasPool$1=[];let pixelContext=null;function createPixelContext(){pixelContext=createCanvasContext2D(1,1,void 0,{willReadFrequently:!0})}class CanvasLayerRenderer extends LayerRenderer{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=create(),this.pixelTransform=create(),this.inversePixelTransform=create(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,t,i){pixelContext||createPixelContext(),pixelContext.clearRect(0,0,1,1);let s;try{pixelContext.drawImage(e,t,i,1,1,0,0,1,1),s=pixelContext.getImageData(0,0,1,1).data}catch{return pixelContext=null,null}return s}getBackground(e){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(e.viewState.resolution)),i||void 0}useContainer(e,t,i){const s=this.getLayer().getClassName();let r,o;if(e&&e.className===s&&(!i||e&&e.style.backgroundColor&&equals$2(asArray(e.style.backgroundColor),asArray(i)))){const a=e.firstElementChild;a instanceof HTMLCanvasElement&&(o=a.getContext("2d"))}if(o&&equivalent(o.canvas.style.transform,t)?(this.container=e,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=document.createElement("div"),r.className=s;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=createCanvasContext2D();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(e,t,i){const s=getTopLeft(i),r=getTopRight(i),o=getBottomRight(i),a=getBottomLeft(i);apply(t.coordinateToPixelTransform,s),apply(t.coordinateToPixelTransform,r),apply(t.coordinateToPixelTransform,o),apply(t.coordinateToPixelTransform,a);const l=this.inversePixelTransform;apply(l,s),apply(l,r),apply(l,o),apply(l,a),e.save(),e.beginPath(),e.moveTo(Math.round(s[0]),Math.round(s[1])),e.lineTo(Math.round(r[0]),Math.round(r[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.lineTo(Math.round(a[0]),Math.round(a[1])),e.clip()}prepareContainer(e,t){const i=e.extent,s=e.viewState.resolution,r=e.viewState.rotation,o=e.pixelRatio,a=Math.round(getWidth(i)/s*o),l=Math.round(getHeight(i)/s*o);compose(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/o,1/o,r,-a/2,-l/2),makeInverse(this.inversePixelTransform,this.pixelTransform);const c=toString$1(this.pixelTransform);if(this.useContainer(t,c,this.getBackground(e)),!this.containerReused){const h=this.context.canvas;h.width!=a||h.height!=l?(h.width=a,h.height=l):this.context.clearRect(0,0,a,l),c!==h.style.transform&&(h.style.transform=c)}}dispatchRenderEvent_(e,t,i){const s=this.getLayer();if(s.hasListener(e)){const r=new RenderEvent(e,this.inversePixelTransform,i,t);s.dispatchEvent(r)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(RenderEventType.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(RenderEventType.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new ZIndexContext),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(RenderEventType.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(RenderEventType.POSTRENDER,this.context,e))}getRenderTransform(e,t,i,s,r,o,a){const l=r/2,c=o/2,h=s/t,u=-h,d=-e[0]+a,g=-e[1];return compose(this.tempTransform,l,c,h,u,-i,d,g)}disposeInternal(){delete this.frameState,super.disposeInternal()}}class CanvasVectorLayerRenderer extends CanvasLayerRenderer{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=createEmpty(),this.wrappedRenderedExtent_=createEmpty(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(e,t,i){const s=t.extent,r=t.viewState,o=r.center,a=r.resolution,l=r.projection,c=r.rotation,h=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),g=t.pixelRatio,f=t.viewHints,m=!(f[ViewHint.ANIMATING]||f[ViewHint.INTERACTING]),p=this.context,_=Math.round(getWidth(s)/a*g),y=Math.round(getHeight(s)/a*g),A=u.getWrapX()&&l.canWrapX(),x=A?getWidth(h):null,C=A?Math.ceil((s[2]-h[2])/x)+1:1;let T=A?Math.floor((s[0]-h[0])/x):0;do{let S=this.getRenderTransform(o,a,0,g,_,y,T*x);t.declutter&&(S=S.slice(0)),e.execute(p,[p.canvas.width,p.canvas.height],S,c,m,i===void 0?ALL:i?DECLUTTER:NON_DECLUTTER,i?d&&t.declutter[d]:void 0)}while(++T<C)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=createCanvasContext2D(this.context.canvas.width,this.context.canvas.height,canvasPool$1))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){const e=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=e,releaseCanvas(this.context),canvasPool$1.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(e){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,e,!0)}renderDeferredInternal(e){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(e,t){const i=e.layerStatesArray[e.layerIndex];this.opacity_=i.opacity;const s=e.viewState;this.prepareContainer(e,t);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(RenderEventType.PRERENDER)||this.getLayer().hasListener(RenderEventType.POSTRENDER)))return this.container;if(this.setDrawContext_(),this.preRender(r,e),s.projection,this.clipped_=!1,a&&i.extent&&this.clipping){const l=fromUserExtent(i.extent);a=intersects$1(l,e.extent),this.clipped_=a&&!containsExtent(l,e.extent),this.clipped_&&this.clipUnrotated(r,e,l)}return a&&this.renderWorlds(o,e,this.getLayer().getDeclutter()?!1:void 0),!e.declutter&&this.clipped_&&r.restore(),this.postRender(r,e),this.renderedRotation_!==s.rotation&&(this.renderedRotation_=s.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(t=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,c=this.getLayer(),h=[],u=i[0]*HIT_DETECT_RESOLUTION,d=i[1]*HIT_DETECT_RESOLUTION;h.push(this.getRenderTransform(s,r,o,HIT_DETECT_RESOLUTION,u,d,0).slice());const g=c.getSource(),f=a.getExtent();if(g.getWrapX()&&a.canWrapX()&&!containsExtent(f,l)){let m=l[0];const p=getWidth(f);let _=0,y;for(;m<f[0];)--_,y=p*_,h.push(this.getRenderTransform(s,r,o,HIT_DETECT_RESOLUTION,u,d,y).slice()),m+=p;for(_=0,m=l[2];m>f[2];)++_,y=p*_,h.push(this.getRenderTransform(s,r,o,HIT_DETECT_RESOLUTION,u,d,y).slice()),m-=p}this.hitDetectionImageData_=createHitDetectionImageData(i,h,this.renderedFeatures_,c.getStyleFunction(),l,r,o,getSquaredTolerance(r,this.renderedPixelRatio_))}t(hitDetect(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,i,s,r){var d,g;if(!this.replayGroup_)return;const o=t.viewState.resolution,a=t.viewState.rotation,l=this.getLayer(),c={},h=function(f,m,p){const _=getUid(f),y=c[_];if(y){if(y!==!0&&p<y.distanceSq){if(p===0)return c[_]=!0,r.splice(r.lastIndexOf(y),1),s(f,l,m);y.geometry=m,y.distanceSq=p}}else{if(p===0)return c[_]=!0,s(f,l,m);r.push(c[_]={feature:f,layer:l,geometry:m,distanceSq:p,callback:s})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(e,o,a,i,h,u?(g=(d=t.declutter)==null?void 0:d[u])==null?void 0:g.all().map(f=>f.value):null)}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){const t=this.getLayer(),i=t.getSource();if(!i)return!1;const s=e.viewHints[ViewHint.ANIMATING],r=e.viewHints[ViewHint.INTERACTING],o=t.getUpdateWhileAnimating(),a=t.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=e.extent,c=e.viewState,h=c.projection,u=c.resolution,d=e.pixelRatio,g=t.getRevision(),f=t.getRenderBuffer();let m=t.getRenderOrder();m===void 0&&(m=defaultOrder);const p=c.center.slice(),_=buffer(l,f*u),y=_.slice(),A=[_.slice()],x=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!containsExtent(x,e.extent)){const O=getWidth(x),G=Math.max(getWidth(_)/2,O);_[0]=x[0]-G,_[2]=x[2]+G,wrapX$1(p,h);const k=wrapX$2(A[0],h);k[0]<x[0]&&k[2]<x[2]?A.push([k[0]+O,k[1],k[2]+O,k[3]]):k[0]>x[0]&&k[2]>x[2]&&A.push([k[0]-O,k[1],k[2]-O,k[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==g&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!e.declutter&&containsExtent(this.wrappedRenderedExtent_,_))return equals$2(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=p,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const C=new BuilderGroup(getTolerance(u,d),_,u,d);let T;for(let O=0,G=A.length;O<G;++O)i.loadFeatures(A[O],u,h);const S=getSquaredTolerance(u,d);let w=!0;const I=(O,G)=>{let k;const N=O.getStyleFunction()||t.getStyleFunction();if(N&&(k=N(O,u)),k){const F=this.renderFeature(O,S,k,C,T,this.getLayer().getDeclutter(),G);w=w&&!F}},L=toUserExtent(_),D=i.getFeaturesInExtent(L);m&&D.sort(m);for(let O=0,G=D.length;O<G;++O)I(D[O],O);this.renderedFeatures_=D,this.ready=w;const b=C.finish(),P=new ExecutorGroup(_,u,d,i.getOverlaps(),b,t.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=u,this.renderedRevision_=g,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=y,this.wrappedRenderedExtent_=_,this.renderedCenter_=p,this.renderedProjection_=h,this.renderedPixelRatio_=d,this.replayGroup_=P,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,t,i,s,r,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let c=0,h=i.length;c<h;++c)l=renderFeature(s,e,i[c],t,this.boundHandleStyleImageChange_,r,o,a)||l;else l=renderFeature(s,e,i,t,this.boundHandleStyleImageChange_,r,o,a);return l}}class VectorLayer extends BaseVectorLayer{constructor(e){super(e)}createRenderer(){return new CanvasVectorLayerRenderer(this)}}class Tile extends Target{constructor(e,t,i){super(),i=i||{},this.tileCoord=e,this.state=t,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(EventType.CHANGE)}release(){this.setState(TileState.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==TileState.EMPTY){if(this.state!==TileState.ERROR&&this.state>e)throw new Error("Tile load sequence violation");this.state=e,this.changed()}}load(){abstract()}getAlpha(e,t){if(!this.transition_)return 1;let i=this.transitionStarts_[e];if(!i)i=t,this.transitionStarts_[e]=i;else if(i===-1)return 1;const s=t-i+1e3/60;return s>=this.transition_?1:easeIn(s/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}function asImageLike(n){return n instanceof Image||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageBitmap?n:null}const disposedError=new Error("disposed"),defaultSize=[256,256];class DataTile extends Tile{constructor(e){const t=TileState.IDLE;super(e.tileCoord,t,{transition:e.transition,interpolate:e.interpolate}),this.loader_=e.loader,this.data_=null,this.error_=null,this.size_=e.size||null,this.controller_=e.controller||null}getSize(){if(this.size_)return this.size_;const e=asImageLike(this.data_);return e?[e.width,e.height]:defaultSize}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==TileState.IDLE&&this.state!==TileState.ERROR)return;this.state=TileState.LOADING,this.changed();const e=this;this.loader_().then(function(t){e.data_=t,e.state=TileState.LOADED,e.changed()}).catch(function(t){e.error_=t,e.state=TileState.ERROR,e.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(disposedError),this.controller_=null),super.disposeInternal()}}class ImageTile extends Tile{constructor(e,t,i,s,r,o){super(e,t,o),this.crossOrigin_=s,this.src_=i,this.key=i,this.image_=new Image,s!==null&&(this.image_.crossOrigin=s),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(e){this.image_=e,this.state=TileState.LOADED,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=TileState.ERROR,this.unlistenImage_(),this.image_=getBlankImage(),this.changed()}handleImageLoad_(){const e=this.image_;e.naturalWidth&&e.naturalHeight?this.state=TileState.LOADED:this.state=TileState.EMPTY,this.unlistenImage_(),this.changed()}load(){this.state==TileState.ERROR&&(this.state=TileState.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==TileState.IDLE&&(this.state=TileState.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=listenImage(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}}function getBlankImage(){const n=createCanvasContext2D(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}let brokenDiagonalRendering_;const canvasPool=[];function drawTestTriangle(n,e,t,i,s){n.beginPath(),n.moveTo(0,0),n.lineTo(e,t),n.lineTo(i,s),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(e,i)+1,Math.max(t,s)),n.restore()}function verifyBrokenDiagonalRendering(n,e){return Math.abs(n[e*4]-210)>2||Math.abs(n[e*4+3]-.75*255)>2}function isBrokenDiagonalRendering(){if(brokenDiagonalRendering_===void 0){const n=createCanvasContext2D(6,6,canvasPool);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",drawTestTriangle(n,4,5,4,0),drawTestTriangle(n,4,5,0,5);const e=n.getImageData(0,0,3,3).data;brokenDiagonalRendering_=verifyBrokenDiagonalRendering(e,0)||verifyBrokenDiagonalRendering(e,4)||verifyBrokenDiagonalRendering(e,8),releaseCanvas(n),canvasPool.push(n.canvas)}return brokenDiagonalRendering_}function calculateSourceResolution(n,e,t,i){const s=transform(t,e,n);let r=getPointResolution(e,i,t);const o=e.getMetersPerUnit();o!==void 0&&(r*=o);const a=n.getMetersPerUnit();a!==void 0&&(r/=a);const l=n.getExtent();if(!l||containsCoordinate(l,s)){const c=getPointResolution(n,r,s)/r;isFinite(c)&&c>0&&(r/=c)}return r}function calculateSourceExtentResolution(n,e,t,i){const s=getCenter(t);let r=calculateSourceResolution(n,e,s,i);return(!isFinite(r)||r<=0)&&forEachCorner(t,function(o){return r=calculateSourceResolution(n,e,o,i),isFinite(r)&&r>0}),r}function render(n,e,t,i,s,r,o,a,l,c,h,u,d,g){const f=createCanvasContext2D(Math.round(t*n),Math.round(t*e),canvasPool);if(u||(f.imageSmoothingEnabled=!1),l.length===0)return f.canvas;f.scale(t,t);function m(C){return Math.round(C*t)/t}f.globalCompositeOperation="lighter";const p=createEmpty();l.forEach(function(C,T,S){extend$1(p,C.extent)});let _;const y=t/i,A=(u?1:1+Math.pow(2,-24))/y;(!d||l.length!==1||c!==0)&&(_=createCanvasContext2D(Math.round(getWidth(p)*y),Math.round(getHeight(p)*y),canvasPool),u||(_.imageSmoothingEnabled=!1),l.forEach(function(C,T,S){if(C.image.width>0&&C.image.height>0){if(C.clipExtent){_.save();const b=(C.clipExtent[0]-p[0])*y,P=-(C.clipExtent[3]-p[3])*y,O=getWidth(C.clipExtent)*y,G=getHeight(C.clipExtent)*y;_.rect(u?b:Math.round(b),u?P:Math.round(P),u?O:Math.round(b+O)-Math.round(b),u?G:Math.round(P+G)-Math.round(P)),_.clip()}const w=(C.extent[0]-p[0])*y,I=-(C.extent[3]-p[3])*y,L=getWidth(C.extent)*y,D=getHeight(C.extent)*y;_.drawImage(C.image,c,c,C.image.width-2*c,C.image.height-2*c,u?w:Math.round(w),u?I:Math.round(I),u?L:Math.round(w+L)-Math.round(w),u?D:Math.round(I+D)-Math.round(I)),C.clipExtent&&_.restore()}}));const x=getTopLeft(o);return a.getTriangles().forEach(function(C,T,S){const w=C.source,I=C.target;let L=w[0][0],D=w[0][1],b=w[1][0],P=w[1][1],O=w[2][0],G=w[2][1];const k=m((I[0][0]-x[0])/r),N=m(-(I[0][1]-x[1])/r),F=m((I[1][0]-x[0])/r),B=m(-(I[1][1]-x[1])/r),W=m((I[2][0]-x[0])/r),X=m(-(I[2][1]-x[1])/r),v=L,V=D;L=0,D=0,b-=v,P-=V,O-=v,G-=V;const j=[[b,P,0,0,F-k],[O,G,0,0,W-k],[0,0,b,P,B-N],[0,0,O,G,X-N]],Y=solveLinearSystem(j);if(!Y)return;if(f.save(),f.beginPath(),isBrokenDiagonalRendering()||!u){f.moveTo(F,B);const K=4,se=k-F,ie=N-B;for(let Q=0;Q<K;Q++)f.lineTo(F+m((Q+1)*se/K),B+m(Q*ie/(K-1))),Q!=K-1&&f.lineTo(F+m((Q+1)*se/K),B+m((Q+1)*ie/(K-1)));f.lineTo(W,X)}else f.moveTo(F,B),f.lineTo(k,N),f.lineTo(W,X);f.clip(),f.transform(Y[0],Y[2],Y[1],Y[3],k,N),f.translate(p[0]-v,p[3]-V);let q;if(_)q=_.canvas,f.scale(A,-A);else{const K=l[0],se=K.extent;q=K.image,f.scale(getWidth(se)/q.width,-getHeight(se)/q.height)}f.drawImage(q,0,0),f.restore()}),_&&(releaseCanvas(_),canvasPool.push(_.canvas)),h&&(f.save(),f.globalCompositeOperation="source-over",f.strokeStyle="black",f.lineWidth=1,a.getTriangles().forEach(function(C,T,S){const w=C.target,I=(w[0][0]-x[0])/r,L=-(w[0][1]-x[1])/r,D=(w[1][0]-x[0])/r,b=-(w[1][1]-x[1])/r,P=(w[2][0]-x[0])/r,O=-(w[2][1]-x[1])/r;f.beginPath(),f.moveTo(D,b),f.lineTo(I,L),f.lineTo(P,O),f.closePath(),f.stroke()}),f.restore()),f.canvas}const MAX_SUBDIVISION=10,MAX_TRIANGLE_WIDTH=.25;class Triangulation{constructor(e,t,i,s,r,o,a){this.sourceProj_=e,this.targetProj_=t;let l={};const c=a?createTransformFromCoordinateTransform(A=>apply(a,transform(A,this.targetProj_,this.sourceProj_))):getTransform(this.targetProj_,this.sourceProj_);this.transformInv_=function(A){const x=A[0]+"/"+A[1];return l[x]||(l[x]=c(A)),l[x]},this.maxSourceExtent_=s,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!s&&!!this.sourceProj_.getExtent()&&getWidth(s)>=getWidth(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?getWidth(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?getWidth(this.targetProj_.getExtent()):null;const h=getTopLeft(i),u=getTopRight(i),d=getBottomRight(i),g=getBottomLeft(i),f=this.transformInv_(h),m=this.transformInv_(u),p=this.transformInv_(d),_=this.transformInv_(g),y=MAX_SUBDIVISION+(o?Math.max(0,Math.ceil(Math.log2(getArea(i)/(o*o*256*256)))):0);if(this.addQuad_(h,u,d,g,f,m,p,_,y),this.wrapsXInSource_){let A=1/0;this.triangles_.forEach(function(x,C,T){A=Math.min(A,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-A>this.sourceWorldWidth_/2){const C=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];C[0][0]-A>this.sourceWorldWidth_/2&&(C[0][0]-=this.sourceWorldWidth_),C[1][0]-A>this.sourceWorldWidth_/2&&(C[1][0]-=this.sourceWorldWidth_),C[2][0]-A>this.sourceWorldWidth_/2&&(C[2][0]-=this.sourceWorldWidth_);const T=Math.min(C[0][0],C[1][0],C[2][0]);Math.max(C[0][0],C[1][0],C[2][0])-T<this.sourceWorldWidth_/2&&(x.source=C)}})}l={}}addTriangle_(e,t,i,s,r,o){this.triangles_.push({source:[s,r,o],target:[e,t,i]})}addQuad_(e,t,i,s,r,o,a,l,c){const h=boundingExtent([r,o,a,l]),u=this.sourceWorldWidth_?getWidth(h)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,g=this.sourceProj_.canWrapX()&&u>.5&&u<1;let f=!1;if(c>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const p=boundingExtent([e,t,i,s]);f=getWidth(p)/this.targetWorldWidth_>MAX_TRIANGLE_WIDTH||f}!g&&this.sourceProj_.isGlobal()&&u&&(f=u>MAX_TRIANGLE_WIDTH||f)}if(!f&&this.maxSourceExtent_&&isFinite(h[0])&&isFinite(h[1])&&isFinite(h[2])&&isFinite(h[3])&&!intersects$1(h,this.maxSourceExtent_))return;let m=0;if(!f&&(!isFinite(r[0])||!isFinite(r[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(c>0)f=!0;else if(m=(!isFinite(r[0])||!isFinite(r[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),m!=1&&m!=2&&m!=4&&m!=8)return}if(c>0){if(!f){const p=[(e[0]+i[0])/2,(e[1]+i[1])/2],_=this.transformInv_(p);let y;g?y=(modulo(r[0],d)+modulo(a[0],d))/2-modulo(_[0],d):y=(r[0]+a[0])/2-_[0];const A=(r[1]+a[1])/2-_[1];f=y*y+A*A>this.errorThresholdSquared_}if(f){if(Math.abs(e[0]-i[0])<=Math.abs(e[1]-i[1])){const p=[(t[0]+i[0])/2,(t[1]+i[1])/2],_=this.transformInv_(p),y=[(s[0]+e[0])/2,(s[1]+e[1])/2],A=this.transformInv_(y);this.addQuad_(e,t,p,y,r,o,_,A,c-1),this.addQuad_(y,p,i,s,A,_,a,l,c-1)}else{const p=[(e[0]+t[0])/2,(e[1]+t[1])/2],_=this.transformInv_(p),y=[(i[0]+s[0])/2,(i[1]+s[1])/2],A=this.transformInv_(y);this.addQuad_(e,p,y,s,r,_,A,l,c-1),this.addQuad_(p,t,i,y,_,o,a,A,c-1)}return}}if(g){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(m&11)==0&&this.addTriangle_(e,i,s,r,a,l),(m&14)==0&&this.addTriangle_(e,i,t,r,a,o),m&&((m&13)==0&&this.addTriangle_(t,s,e,o,l,r),(m&7)==0&&this.addTriangle_(t,s,i,o,l,a))}calculateSourceExtent(){const e=createEmpty();return this.triangles_.forEach(function(t,i,s){const r=t.source;extendCoordinate(e,r[0]),extendCoordinate(e,r[1]),extendCoordinate(e,r[2])}),e}getTriangles(){return this.triangles_}}const ERROR_THRESHOLD=.5;class ReprojTile extends Tile{constructor(e,t,i,s,r,o,a,l,c,h,u,d){super(r,TileState.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=t,this.targetTileGrid_=s,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=e.canWrapX()?e.getExtent():void 0;const g=s.getTileCoordExtent(this.wrappedTileCoord_),f=this.targetTileGrid_.getExtent();let m=this.sourceTileGrid_.getExtent();const p=f?getIntersection(g,f):g;if(getArea(p)===0){this.state=TileState.EMPTY;return}const _=e.getExtent();_&&(m?m=getIntersection(m,_):m=_);const y=s.getResolution(this.wrappedTileCoord_[0]),A=calculateSourceExtentResolution(e,i,p,y);if(!isFinite(A)||A<=0){this.state=TileState.EMPTY;return}const x=h!==void 0?h:ERROR_THRESHOLD;if(this.triangulation_=new Triangulation(e,i,p,m,A*x,y),this.triangulation_.getTriangles().length===0){this.state=TileState.EMPTY;return}this.sourceZ_=t.getZForResolution(A);let C=this.triangulation_.calculateSourceExtent();if(m&&(e.canWrapX()?(C[1]=clamp(C[1],m[1],m[3]),C[3]=clamp(C[3],m[1],m[3])):C=getIntersection(C,m)),!getArea(C))this.state=TileState.EMPTY;else{let T=0,S=0;e.canWrapX()&&(T=getWidth(_),S=Math.floor((C[0]-_[0])/T)),wrapAndSliceX(C.slice(),e,!0).forEach(I=>{const L=t.getTileRangeForExtentAndZ(I,this.sourceZ_);for(let D=L.minX;D<=L.maxX;D++)for(let b=L.minY;b<=L.maxY;b++){const P=c(this.sourceZ_,D,b,a);if(P){const O=S*T;this.sourceTiles_.push({tile:P,offset:O})}}++S}),this.sourceTiles_.length===0&&(this.state=TileState.EMPTY)}}getImage(){return this.canvas_}reproject_(){const e=[];if(this.sourceTiles_.forEach(t=>{var s;const i=t.tile;if(i&&i.getState()==TileState.LOADED){const r=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);r[0]+=t.offset,r[2]+=t.offset;const o=(s=this.clipExtent_)==null?void 0:s.slice();o&&(o[0]+=t.offset,o[2]+=t.offset),e.push({extent:r,clipExtent:o,image:i.getImage()})}}),this.sourceTiles_.length=0,e.length===0)this.state=TileState.ERROR;else{const t=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(t),s=typeof i=="number"?i:i[0],r=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(t),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=render(s,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=TileState.LOADED}this.changed()}load(){if(this.state==TileState.IDLE){this.state=TileState.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:t})=>{const i=t.getState();if(i==TileState.IDLE||i==TileState.LOADING){e++;const s=listen(t,EventType.CHANGE,r=>{const o=t.getState();(o==TileState.LOADED||o==TileState.ERROR||o==TileState.EMPTY)&&(unlistenByKey(s),e--,e===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(s)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t},i,s){t.getState()==TileState.IDLE&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(unlistenByKey),this.sourcesListenerKeys_=null}release(){this.canvas_&&(releaseCanvas(this.canvas_.getContext("2d")),canvasPool.push(this.canvas_),this.canvas_=null),super.release()}}class TileRange{constructor(e,t,i,s){this.minX=e,this.maxX=t,this.minY=i,this.maxY=s}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minX<this.minX&&(this.minX=e.minX),e.maxX>this.maxX&&(this.maxX=e.maxX),e.minY<this.minY&&(this.minY=e.minY),e.maxY>this.maxY&&(this.maxY=e.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}}function createOrUpdate$1(n,e,t,i,s){return s!==void 0?(s.minX=n,s.maxX=e,s.minY=t,s.maxY=i,s):new TileRange(n,e,t,i)}class LRUCache{constructor(e){this.highWaterMark=e!==void 0?e:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const e=this.pop();e instanceof Disposable&&e.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){const i=this.entries_[e];return assert(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(e){const t=this.entries_[e];return assert(t!==void 0,"Tried to get a value for a key that does not exist in the cache"),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){const e=new Array(this.count_);let t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.key_;return e}getValues(){const e=new Array(this.count_);let t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){var t;return(t=this.entries_[e])==null?void 0:t.value_}pop(){const e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){assert(!(e in this.entries_),"Tried to set a value for a key that is used already");const i={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[e]=i,++this.count_}setSize(e){this.highWaterMark=e}}function createOrUpdate(n,e,t,i){return i!==void 0?(i[0]=n,i[1]=e,i[2]=t,i):[n,e,t]}function getKeyZXY(n,e,t){return n+"/"+e+"/"+t}function hash(n){return hashZXY(n[0],n[1],n[2])}function hashZXY(n,e,t){return(e<<n)+t}function withinExtentAndZ(n,e){const t=n[0],i=n[1],s=n[2];if(e.getMinZoom()>t||t>e.getMaxZoom())return!1;const r=e.getFullTileRange(t);return r?r.containsXY(i,s):!0}class CanvasImageLayerRenderer extends CanvasLayerRenderer{constructor(e){super(e),this.image=null}getImage(){return this.image?this.image.getImage():null}prepareFrame(e){const t=e.layerStatesArray[e.layerIndex],i=e.pixelRatio,s=e.viewState,r=s.resolution,o=this.getLayer().getSource(),a=e.viewHints;let l=e.extent;if(t.extent!==void 0&&(l=getIntersection(l,fromUserExtent(t.extent,s.projection))),!a[ViewHint.ANIMATING]&&!a[ViewHint.INTERACTING]&&!isEmpty(l))if(o){const c=s.projection,h=o.getImage(l,r,i,c);h&&(this.loadImage(h)?this.image=h:h.getState()===ImageState.EMPTY&&(this.image=null))}else this.image=null;return!!this.image}getData(e){const t=this.frameState;if(!t)return null;const i=this.getLayer(),s=apply(t.pixelToCoordinateTransform,e.slice()),r=i.getExtent();if(r&&!containsCoordinate(r,s))return null;const o=this.image.getExtent(),a=this.image.getImage(),l=getWidth(o),c=Math.floor(a.width*((s[0]-o[0])/l));if(c<0||c>=a.width)return null;const h=getHeight(o),u=Math.floor(a.height*((o[3]-s[1])/h));return u<0||u>=a.height?null:this.getImageData(a,c,u)}renderFrame(e,t){const i=this.image,s=i.getExtent(),r=i.getResolution(),[o,a]=Array.isArray(r)?r:[r,r],l=i.getPixelRatio(),c=e.layerStatesArray[e.layerIndex],h=e.pixelRatio,u=e.viewState,d=u.center,g=u.resolution,f=h*o/(g*l),m=h*a/(g*l);this.prepareContainer(e,t);const p=this.context.canvas.width,_=this.context.canvas.height,y=this.getRenderContext(e);let A=!1,x=!0;if(c.extent){const I=fromUserExtent(c.extent,u.projection);x=intersects$1(I,e.extent),A=x&&!containsExtent(I,e.extent),A&&this.clipUnrotated(y,e,I)}const C=i.getImage(),T=compose(this.tempTransform,p/2,_/2,f,m,0,l*(s[0]-d[0])/o,l*(d[1]-s[3])/a);this.renderedResolution=a*h/l;const S=C.width*T[0],w=C.height*T[3];if(this.getLayer().getSource().getInterpolate()||(y.imageSmoothingEnabled=!1),this.preRender(y,e),x&&S>=.5&&w>=.5){const I=T[4],L=T[5],D=c.opacity;D!==1&&(y.save(),y.globalAlpha=D),y.drawImage(C,0,0,+C.width,+C.height,I,L,S,w),D!==1&&y.restore()}return this.postRender(this.context,e),A&&y.restore(),y.imageSmoothingEnabled=!0,this.container}}class BaseImageLayer extends Layer{constructor(e){e=e||{},super(e)}}class ImageLayer extends BaseImageLayer{constructor(e){super(e)}createRenderer(){return new CanvasImageLayerRenderer(this)}getData(e){return super.getData(e)}}function getCacheKey(n,e,t,i,s){return`${getUid(n)},${e},${getKeyZXY(t,i,s)}`}function addTileToLookup(n,e,t){if(!(t in n))return n[t]=new Set([e]),!0;const i=n[t],s=i.has(e);return s||i.add(e),!s}function removeTileFromLookup(n,e,t){const i=n[t];return i?i.delete(e):!1}function getRenderExtent(n,e){const t=n.layerStatesArray[n.layerIndex];t.extent&&(e=getIntersection(e,fromUserExtent(t.extent,n.viewState.projection)));const i=t.layer.getRenderSource();if(!i.getWrapX()){const s=i.getTileGridForProjection(n.viewState.projection).getExtent();s&&(e=getIntersection(e,s))}return e}class CanvasTileLayerRenderer extends CanvasLayerRenderer{constructor(e,t){super(e),t=t||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=createEmpty(),this.tempTileRange_=new TileRange(0,0,0,0),this.tempTileCoord_=createOrUpdate(0,0,0);const i=t.cacheSize!==void 0?t.cacheSize:512;this.tileCache_=new LRUCache(i),this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getOrCreateTile(e,t,i,s){const r=this.tileCache_,a=this.getLayer().getSource(),l=getCacheKey(a,a.getKey(),e,t,i);let c;if(r.containsKey(l))c=r.get(l);else{if(c=a.getTile(e,t,i,s.pixelRatio,s.viewState.projection),!c)return null;r.set(l,c)}return c}getTile(e,t,i,s){const r=this.getOrCreateTile(e,t,i,s);return r||null}getData(e){const t=this.frameState;if(!t)return null;const i=this.getLayer(),s=apply(t.pixelToCoordinateTransform,e.slice()),r=i.getExtent();if(r&&!containsCoordinate(r,s))return null;const o=t.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(o.projection),c=a.getTilePixelRatio(t.pixelRatio);for(let h=l.getZForResolution(o.resolution);h>=l.getMinZoom();--h){const u=l.getTileCoordForCoordAndZ(s,h),d=this.getTile(h,u[1],u[2],t);if(!d||d.getState()!==TileState.LOADED)continue;const g=l.getOrigin(h),f=toSize(l.getTileSize(h)),m=l.getResolution(h);let p;if(d instanceof ImageTile||d instanceof ReprojTile)p=d.getImage();else if(d instanceof DataTile){if(p=asImageLike(d.getData()),!p)continue}else continue;const _=Math.floor(c*((s[0]-g[0])/m-u[1]*f[0])),y=Math.floor(c*((g[1]-s[1])/m-u[2]*f[1])),A=Math.round(c*a.getGutterForProjection(o.projection));return this.getImageData(p,_+A,y+A)}return null}prepareFrame(e){this.renderedProjection?e.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=e.viewState.projection):this.renderedProjection=e.viewState.projection;const t=this.getLayer().getSource();if(!t)return!1;const i=t.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===t.getKey()&&this.tileCache_.clear()):this.renderedSourceRevision_=i,!0}enqueueTiles(e,t,i,s,r){const o=e.viewState,a=this.getLayer(),l=a.getRenderSource(),c=l.getTileGridForProjection(o.projection),h=getUid(l);h in e.wantedTiles||(e.wantedTiles[h]={});const u=e.wantedTiles[h],d=a.getMapInternal(),g=Math.max(i-r,c.getMinZoom(),c.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):c.getResolution(0)),l.zDirection)),f=o.rotation,m=f?getRotatedViewport(o.center,o.resolution,f,e.size):void 0;for(let p=i;p>=g;--p){const _=c.getTileRangeForExtentAndZ(t,p,this.tempTileRange_),y=c.getResolution(p);for(let A=_.minX;A<=_.maxX;++A)for(let x=_.minY;x<=_.maxY;++x){if(f&&!c.tileCoordIntersectsViewport([p,A,x],m))continue;const C=this.getTile(p,A,x,e);if(!C||!addTileToLookup(s,C,p))continue;const S=C.getKey();if(u[S]=!0,C.getState()===TileState.IDLE&&!e.tileQueue.isKeyQueued(S)){const w=createOrUpdate(p,A,x,this.tempTileCoord_);e.tileQueue.enqueue([C,h,c.getTileCoordCenter(w),y])}}}}findStaleTile_(e,t){const i=this.tileCache_,s=e[0],r=e[1],o=e[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){const c=getCacheKey(this.getLayer().getSource(),a[l],s,r,o);if(i.containsKey(c)){const h=i.peek(c);if(h.getState()===TileState.LOADED)return h.endTransition(getUid(this)),addTileToLookup(t,h,s),!0}}return!1}findAltTiles_(e,t,i,s){const r=e.getTileRangeForTileCoordAndZ(t,i,this.tempTileRange_);if(!r)return!1;let o=!0;const a=this.tileCache_,l=this.getLayer().getRenderSource(),c=l.getKey();for(let h=r.minX;h<=r.maxX;++h)for(let u=r.minY;u<=r.maxY;++u){const d=getCacheKey(l,c,i,h,u);let g=!1;if(a.containsKey(d)){const f=a.peek(d);f.getState()===TileState.LOADED&&(addTileToLookup(s,f,i),g=!0)}g||(o=!1)}return o}renderFrame(e,t){this.renderComplete=!0;const i=e.layerStatesArray[e.layerIndex],s=e.viewState,r=s.projection,o=s.resolution,a=s.center,l=e.pixelRatio,c=this.getLayer(),h=c.getSource(),u=h.getTileGridForProjection(r),d=u.getZForResolution(o,h.zDirection),g=u.getResolution(d),f=h.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==f&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=f):this.renderedSourceKey_=f;let m=e.extent;const p=h.getTilePixelRatio(l);this.prepareContainer(e,t);const _=this.context.canvas.width,y=this.context.canvas.height,A=i.extent&&fromUserExtent(i.extent);A&&(m=getIntersection(m,fromUserExtent(i.extent)));const x=g*_/2/p,C=g*y/2/p,T=[a[0]-x,a[1]-C,a[0]+x,a[1]+C],S={};this.renderedTiles.length=0;const w=c.getPreload();if(e.nextExtent){const F=u.getZForResolution(s.nextResolution,h.zDirection),B=getRenderExtent(e,e.nextExtent);this.enqueueTiles(e,B,F,S,w)}const I=getRenderExtent(e,m);if(this.enqueueTiles(e,I,d,S,0),w>0&&setTimeout(()=>{this.enqueueTiles(e,I,d-1,S,w-1)},0),!(d in S))return this.container;const L=getUid(this),D=e.time;for(const F of S[d]){const B=F.getState();if(B===TileState.EMPTY)continue;const W=F.tileCoord;if(B===TileState.LOADED&&F.getAlpha(L,D)===1){F.endTransition(L);continue}if(B!==TileState.ERROR&&(this.renderComplete=!1),this.findStaleTile_(W,S)){removeTileFromLookup(S,F,d),e.animate=!0;continue}if(this.findAltTiles_(u,W,d+1,S))continue;const V=u.getMinZoom();for(let j=d-1;j>=V&&!this.findAltTiles_(u,W,j,S);--j);}const b=g/o*l/p,P=this.getRenderContext(e);compose(this.tempTransform,_/2,y/2,b,b,0,-_/2,-y/2),i.extent&&this.clipUnrotated(P,e,A),h.getInterpolate()||(P.imageSmoothingEnabled=!1),this.preRender(P,e);const O=Object.keys(S).map(Number);O.sort(ascending);let G;const k=[],N=[];for(let F=O.length-1;F>=0;--F){const B=O[F],W=h.getTilePixelSize(B,l,r),v=u.getResolution(B)/g,V=W[0]*v*b,j=W[1]*v*b,Y=u.getTileCoordForCoordAndZ(getTopLeft(T),B),q=u.getTileCoordExtent(Y),K=apply(this.tempTransform,[p*(q[0]-T[0])/g,p*(T[3]-q[3])/g]),se=p*h.getGutterForProjection(r);for(const ie of S[B]){if(ie.getState()!==TileState.LOADED)continue;const Q=ie.tileCoord,Ae=Y[1]-Q[1],Se=Math.round(K[0]-(Ae-1)*V),_e=Y[2]-Q[2],ce=Math.round(K[1]-(_e-1)*j),J=Math.round(K[0]-Ae*V),re=Math.round(K[1]-_e*j),ge=Se-J,fe=ce-re,ye=O.length===1;let ue=!1;G=[J,re,J+ge,re,J+ge,re+fe,J,re+fe];for(let pe=0,me=k.length;pe<me;++pe)if(!ye&&B<N[pe]){const z=k[pe];intersects$1([J,re,J+ge,re+fe],[z[0],z[3],z[4],z[7]])&&(ue||(P.save(),ue=!0),P.beginPath(),P.moveTo(G[0],G[1]),P.lineTo(G[2],G[3]),P.lineTo(G[4],G[5]),P.lineTo(G[6],G[7]),P.moveTo(z[6],z[7]),P.lineTo(z[4],z[5]),P.lineTo(z[2],z[3]),P.lineTo(z[0],z[1]),P.clip())}k.push(G),N.push(B),this.drawTile(ie,e,J,re,ge,fe,se,ye),ue&&P.restore(),this.renderedTiles.unshift(ie),this.updateUsedTiles(e.usedTiles,h,ie)}}if(this.renderedResolution=g,this.extentChanged=!this.renderedExtent_||!equals$1(this.renderedExtent_,T),this.renderedExtent_=T,this.renderedPixelRatio=l,this.postRender(this.context,e),i.extent&&P.restore(),P.imageSmoothingEnabled=!0,this.renderComplete){const F=(B,W)=>{const X=getUid(h),v=W.wantedTiles[X],V=v?Object.keys(v).length:0;this.updateCacheSize(V),this.tileCache_.expireCache()};e.postRenderFunctions.push(F)}return this.container}updateCacheSize(e){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,e*2)}drawTile(e,t,i,s,r,o,a,l){let c;if(e instanceof DataTile){if(c=asImageLike(e.getData()),!c)throw new Error("Rendering array data is not yet supported")}else c=this.getTileImage(e);if(!c)return;const h=this.getRenderContext(t),u=getUid(this),d=t.layerStatesArray[t.layerIndex],g=d.opacity*(l?e.getAlpha(u,t.time):1),f=g!==h.globalAlpha;f&&(h.save(),h.globalAlpha=g),h.drawImage(c,a,a,c.width-2*a,c.height-2*a,i,s,r,o),f&&h.restore(),g!==d.opacity?t.animate=!0:l&&e.endTransition(u)}getImage(){const e=this.context;return e?e.canvas:null}getTileImage(e){return e.getImage()}updateUsedTiles(e,t,i){const s=getUid(t);s in e||(e[s]={}),e[s][i.getKey()]=!0}}const TileProperty={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class BaseTileLayer extends Layer{constructor(e){e=e||{};const t=Object.assign({},e),i=e.cacheSize;delete e.cacheSize,delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(e.preload!==void 0?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(TileProperty.PRELOAD)}setPreload(e){this.set(TileProperty.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(TileProperty.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(TileProperty.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}}class TileLayer extends BaseTileLayer{constructor(e){super(e)}createRenderer(){return new CanvasTileLayerRenderer(this,{cacheSize:this.getCacheSize()})}}function fromResolutionLike(n){return Array.isArray(n)?Math.min(...n):n}const tmpTileCoord=[0,0,0],DECIMALS$1=5;class TileGrid{constructor(e){this.minZoom=e.minZoom!==void 0?e.minZoom:0,this.resolutions_=e.resolutions,assert(isSorted(this.resolutions_,(s,r)=>r-s),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let s=0,r=this.resolutions_.length-1;s<r;++s)if(!t)t=this.resolutions_[s]/this.resolutions_[s+1];else if(this.resolutions_[s]/this.resolutions_[s+1]!==t){t=void 0;break}}this.zoomFactor_=t,this.maxZoom=this.resolutions_.length-1,this.origin_=e.origin!==void 0?e.origin:null,this.origins_=null,e.origins!==void 0&&(this.origins_=e.origins,assert(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));const i=e.extent;i!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=getTopLeft(i)),assert(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,e.tileSizes!==void 0&&(this.tileSizes_=e.tileSizes,assert(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=e.tileSize!==void 0?e.tileSize:this.tileSizes_?null:DEFAULT_TILE_SIZE,assert(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=i!==void 0?i:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],e.sizes!==void 0?this.fullTileRanges_=e.sizes.map((s,r)=>{const o=new TileRange(Math.min(0,s[0]),Math.max(s[0]-1,-1),Math.min(0,s[1]),Math.max(s[1]-1,-1));if(i){const a=this.getTileRangeForExtentAndZ(i,r);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):i&&this.calculateTileRanges_(i)}forEachTileCoord(e,t,i){const s=this.getTileRangeForExtentAndZ(e,t);for(let r=s.minX,o=s.maxX;r<=o;++r)for(let a=s.minY,l=s.maxY;a<=l;++a)i([t,r,a])}forEachTileCoordParentTileRange(e,t,i,s){let r,o,a,l=null,c=e[0]-1;for(this.zoomFactor_===2?(o=e[1],a=e[2]):l=this.getTileCoordExtent(e,s);c>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=createOrUpdate$1(o,o,a,a,i)):r=this.getTileRangeForExtentAndZ(l,c,i),t(c,r))return!0;--c}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,i){if(e[0]<this.maxZoom){if(this.zoomFactor_===2){const r=e[1]*2,o=e[2]*2;return createOrUpdate$1(r,r+1,o,o+1,t)}const s=this.getTileCoordExtent(e,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(s,e[0]+1,t)}return null}getTileRangeForTileCoordAndZ(e,t,i){if(t>this.maxZoom||t<this.minZoom)return null;const s=e[0],r=e[1],o=e[2];if(t===s)return createOrUpdate$1(r,o,r,o,i);if(this.zoomFactor_){const l=Math.pow(this.zoomFactor_,t-s),c=Math.floor(r*l),h=Math.floor(o*l);if(t<s)return createOrUpdate$1(c,c,h,h,i);const u=Math.floor(l*(r+1))-1,d=Math.floor(l*(o+1))-1;return createOrUpdate$1(c,u,h,d,i)}const a=this.getTileCoordExtent(e,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,t,i)}getTileRangeForExtentAndZ(e,t,i){this.getTileCoordForXYAndZ_(e[0],e[3],t,!1,tmpTileCoord);const s=tmpTileCoord[1],r=tmpTileCoord[2];this.getTileCoordForXYAndZ_(e[2],e[1],t,!0,tmpTileCoord);const o=tmpTileCoord[1],a=tmpTileCoord[2];return createOrUpdate$1(s,o,r,a,i)}getTileCoordCenter(e){const t=this.getOrigin(e[0]),i=this.getResolution(e[0]),s=toSize(this.getTileSize(e[0]),this.tmpSize_);return[t[0]+(e[1]+.5)*s[0]*i,t[1]-(e[2]+.5)*s[1]*i]}getTileCoordExtent(e,t){const i=this.getOrigin(e[0]),s=this.getResolution(e[0]),r=toSize(this.getTileSize(e[0]),this.tmpSize_),o=i[0]+e[1]*r[0]*s,a=i[1]-(e[2]+1)*r[1]*s,l=o+r[0]*s,c=a+r[1]*s;return createOrUpdate$2(o,a,l,c,t)}getTileCoordForCoordAndResolution(e,t,i){return this.getTileCoordForXYAndResolution_(e[0],e[1],t,!1,i)}getTileCoordForXYAndResolution_(e,t,i,s,r){const o=this.getZForResolution(i),a=i/this.getResolution(o),l=this.getOrigin(o),c=toSize(this.getTileSize(o),this.tmpSize_);let h=a*(e-l[0])/i/c[0],u=a*(l[1]-t)/i/c[1];return s?(h=ceil(h,DECIMALS$1)-1,u=ceil(u,DECIMALS$1)-1):(h=floor(h,DECIMALS$1),u=floor(u,DECIMALS$1)),createOrUpdate(o,h,u,r)}getTileCoordForXYAndZ_(e,t,i,s,r){const o=this.getOrigin(i),a=this.getResolution(i),l=toSize(this.getTileSize(i),this.tmpSize_);let c=(e-o[0])/a/l[0],h=(o[1]-t)/a/l[1];return s?(c=ceil(c,DECIMALS$1)-1,h=ceil(h,DECIMALS$1)-1):(c=floor(c,DECIMALS$1),h=floor(h,DECIMALS$1)),createOrUpdate(i,c,h,r)}getTileCoordForCoordAndZ(e,t,i){return this.getTileCoordForXYAndZ_(e[0],e[1],t,!1,i)}getTileCoordResolution(e){return this.resolutions_[e[0]]}getTileSize(e){return this.tileSize_?this.tileSize_:this.tileSizes_[e]}getFullTileRange(e){return this.fullTileRanges_?this.fullTileRanges_[e]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,e):null}getZForResolution(e,t){const i=linearFindNearest(this.resolutions_,e,t||0);return clamp(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(e,t){return intersectsLinearRing(t,0,t.length,2,this.getTileCoordExtent(e))}calculateTileRanges_(e){const t=this.resolutions_.length,i=new Array(t);for(let s=this.minZoom;s<t;++s)i[s]=this.getTileRangeForExtentAndZ(e,s);this.fullTileRanges_=i}}function getForProjection(n){let e=n.getDefaultTileGrid();return e||(e=createForProjection(n),n.setDefaultTileGrid(e)),e}function wrapX(n,e,t){const i=e[0],s=n.getTileCoordCenter(e),r=extentFromProjection(t);if(!containsCoordinate(r,s)){const o=getWidth(r),a=Math.ceil((r[0]-s[0])/o);return s[0]+=o*a,n.getTileCoordForCoordAndZ(s,i)}return e}function createForExtent(n,e,t,i){i=i!==void 0?i:"top-left";const s=resolutionsFromExtent(n,e,t);return new TileGrid({extent:n,origin:getCorner(n,i),resolutions:s,tileSize:t})}function createXYZ(n){const e=n||{},t=e.extent||get$1("EPSG:3857").getExtent(),i={extent:t,minZoom:e.minZoom,tileSize:e.tileSize,resolutions:resolutionsFromExtent(t,e.maxZoom,e.tileSize,e.maxResolution)};return new TileGrid(i)}function resolutionsFromExtent(n,e,t,i){e=e!==void 0?e:DEFAULT_MAX_ZOOM,t=toSize(t!==void 0?t:DEFAULT_TILE_SIZE);const s=getHeight(n),r=getWidth(n);i=i>0?i:Math.max(r/t[0],s/t[1]);const o=e+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=i/Math.pow(2,l);return a}function createForProjection(n,e,t,i){const s=extentFromProjection(n);return createForExtent(s,e,t,i)}function extentFromProjection(n){n=get$1(n);let e=n.getExtent();if(!e){const t=180*METERS_PER_UNIT$1.degrees/n.getMetersPerUnit();e=createOrUpdate$2(-t,-t,t,t)}return e}const zRegEx=/\{z\}/g,xRegEx=/\{x\}/g,yRegEx=/\{y\}/g,dashYRegEx=/\{-y\}/g;function renderXYZTemplate(n,e,t,i,s){return n.replace(zRegEx,e.toString()).replace(xRegEx,t.toString()).replace(yRegEx,i.toString()).replace(dashYRegEx,function(){if(s===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(s-i).toString()})}function expandUrl(n){const e=[];let t=/\{([a-z])-([a-z])\}/.exec(n);if(t){const i=t[1].charCodeAt(0),s=t[2].charCodeAt(0);let r;for(r=i;r<=s;++r)e.push(n.replace(t[0],String.fromCharCode(r)));return e}if(t=/\{(\d+)-(\d+)\}/.exec(n),t){const i=parseInt(t[2],10);for(let s=parseInt(t[1],10);s<=i;s++)e.push(n.replace(t[0],s.toString()));return e}return e.push(n),e}function createFromTemplate(n,e){return(function(t,i,s){if(!t)return;let r;const o=t[0];if(e){const a=e.getFullTileRange(o);a&&(r=a.getHeight()-1)}return renderXYZTemplate(n,o,t[1],t[2],r)})}function createFromTemplates(n,e){const t=n.length,i=new Array(t);for(let s=0;s<t;++s)i[s]=createFromTemplate(n[s],e);return createFromTileUrlFunctions(i)}function createFromTileUrlFunctions(n){return n.length===1?n[0]:(function(e,t,i){if(!e)return;const s=hash(e),r=modulo(s,n.length);return n[r](e,t,i)})}class TileSource extends Source{constructor(e){super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,projection:e.projection,state:e.state,wrapX:e.wrapX,interpolate:e.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=e.tilePixelRatio!==void 0?e.tilePixelRatio:1,this.tileGrid=e.tileGrid!==void 0?e.tileGrid:null;const t=[256,256];this.tileGrid&&toSize(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),t),this.tmpSize=[0,0],this.key_=e.key||getUid(this),this.tileOptions={transition:e.transition,interpolate:e.interpolate},this.zDirection=e.zDirection?e.zDirection:0}getGutterForProjection(e){return 0}getKey(){return this.key_}setKey(e){this.key_!==e&&(this.key_=e,this.changed())}getResolutions(e){const t=e?this.getTileGridForProjection(e):this.tileGrid;return t?t.getResolutions():null}getTile(e,t,i,s,r){return abstract()}getTileGrid(){return this.tileGrid}getTileGridForProjection(e){return this.tileGrid?this.tileGrid:getForProjection(e)}getTilePixelRatio(e){return this.tilePixelRatio_}getTilePixelSize(e,t,i){const s=this.getTileGridForProjection(i),r=this.getTilePixelRatio(t),o=toSize(s.getTileSize(e),this.tmpSize);return r==1?o:scale(o,r,this.tmpSize)}getTileCoordForTileUrlFunction(e,t){const i=t!==void 0?t:this.getProjection(),s=t!==void 0?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(e=wrapX(s,e,i)),withinExtentAndZ(e,s)?e:null}clear(){}refresh(){this.clear(),super.refresh()}}class TileSourceEvent extends BaseEvent{constructor(e,t){super(e),this.tile=t}}const TileEventType={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class UrlTile extends TileSource{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tilePixelRatio:e.tilePixelRatio,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===UrlTile.prototype.tileUrlFunction,this.tileLoadFunction=e.tileLoadFunction,e.tileUrlFunction&&(this.tileUrlFunction=e.tileUrlFunction),this.urls=null,e.urls?this.setUrls(e.urls):e.url&&this.setUrl(e.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(e){const t=e.target,i=getUid(t),s=t.getState();let r;s==TileState.LOADING?(this.tileLoadingKeys_[i]=!0,r=TileEventType.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=s==TileState.ERROR?TileEventType.TILELOADERROR:s==TileState.LOADED?TileEventType.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new TileSourceEvent(r,t))}setTileLoadFunction(e){this.tileLoadFunction=e,this.changed()}setTileUrlFunction(e,t){this.tileUrlFunction=e,typeof t<"u"?this.setKey(t):this.changed()}setUrl(e){const t=expandUrl(e);this.urls=t,this.setUrls(t)}setUrls(e){this.urls=e;const t=e.join(`
8
8
  `);this.generateTileUrlFunction_?this.setTileUrlFunction(createFromTemplates(e,this.tileGrid),t):this.setKey(t)}tileUrlFunction(e,t,i){}}class TileImage extends UrlTile{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction?e.tileLoadFunction:defaultTileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate!==void 0?e.interpolate:!0,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.crossOrigin=e.crossOrigin!==void 0?e.crossOrigin:null,this.tileClass=e.tileClass!==void 0?e.tileClass:ImageTile,this.tileGridForProjection={},this.reprojectionErrorThreshold_=e.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(e){return this.getProjection()&&e&&!equivalent$1(this.getProjection(),e)?0:this.getGutter()}getGutter(){return 0}getKey(){let e=super.getKey();return this.getInterpolate()||(e+=":disable-interpolation"),e}getTileGridForProjection(e){const t=this.getProjection();if(this.tileGrid&&(!t||equivalent$1(t,e)))return this.tileGrid;const i=getUid(e);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=getForProjection(e)),this.tileGridForProjection[i]}createTile_(e,t,i,s,r,o){const a=[e,t,i],l=this.getTileCoordForTileUrlFunction(a,r),c=l?this.tileUrlFunction(l,s,r):void 0,h=new this.tileClass(a,c!==void 0?TileState.IDLE:TileState.EMPTY,c!==void 0?c:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return h.key=o,h.addEventListener(EventType.CHANGE,this.handleTileChange.bind(this)),h}getTile(e,t,i,s,r){const o=this.getProjection();if(!o||!r||equivalent$1(o,r))return this.getTileInternal(e,t,i,s,o||r);const a=[e,t,i],l=this.getKey(),c=this.getTileGridForProjection(o),h=this.getTileGridForProjection(r),u=this.getTileCoordForTileUrlFunction(a,r),d=new ReprojTile(o,c,r,h,a,u,this.getTilePixelRatio(s),this.getGutter(),(g,f,m,p)=>this.getTileInternal(g,f,m,p,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return d.key=l,d}getTileInternal(e,t,i,s,r){const o=this.getKey();return this.createTile_(e,t,i,s,r,o)}setRenderReprojectionEdges(e){this.renderReprojectionEdges_!=e&&(this.renderReprojectionEdges_=e,this.changed())}setTileGridForProjection(e,t){const i=get$1(e);if(i){const s=getUid(i);s in this.tileGridForProjection||(this.tileGridForProjection[s]=t)}}}function defaultTileLoadFunction(n,e){n.getImage().src=e}class XYZ extends TileImage{constructor(e){e=e||{};const t=e.projection!==void 0?e.projection:"EPSG:3857",i=e.tileGrid!==void 0?e.tileGrid:createXYZ({extent:extentFromProjection(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize});super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0}getGutter(){return this.gutter_}}class ReprojImage extends ImageWrapper{constructor(e,t,i,s,r,o,a){let l=e.getExtent();l&&e.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);let c=t.getExtent();c&&t.canWrapX()&&(c=c.slice(),c[0]=-1/0,c[2]=1/0);const h=c?getIntersection(i,c):i,u=getCenter(h),d=calculateSourceResolution(e,t,u,s),g=ERROR_THRESHOLD,f=new Triangulation(e,t,h,l,d*g,s),m=f.calculateSourceExtent(),p=isEmpty(m)?null:o(m,d,r),_=p?ImageState.IDLE:ImageState.EMPTY,y=p?p.getPixelRatio():1;super(i,s,y,_),this.targetProj_=t,this.maxSourceExtent_=l,this.triangulation_=f,this.targetResolution_=s,this.targetExtent_=i,this.sourceImage_=p,this.sourcePixelRatio_=y,this.interpolate_=a,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){this.state==ImageState.LOADING&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const e=this.sourceImage_.getState();if(e==ImageState.LOADED){const t=getWidth(this.targetExtent_)/this.targetResolution_,i=getHeight(this.targetExtent_)/this.targetResolution_;this.canvas_=render(t,i,this.sourcePixelRatio_,fromResolutionLike(this.sourceImage_.getResolution()),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_,!0)}this.state=e,this.changed()}load(){if(this.state==ImageState.IDLE){this.state=ImageState.LOADING,this.changed();const e=this.sourceImage_.getState();e==ImageState.LOADED||e==ImageState.ERROR?this.reproject_():(this.sourceListenerKey_=listen(this.sourceImage_,EventType.CHANGE,t=>{const i=this.sourceImage_.getState();(i==ImageState.LOADED||i==ImageState.ERROR)&&(this.unlistenSource_(),this.reproject_())}),this.sourceImage_.load())}}unlistenSource_(){unlistenByKey(this.sourceListenerKey_),this.sourceListenerKey_=null}}const DECIMALS=4,ImageSourceEventType={IMAGELOADSTART:"imageloadstart",IMAGELOADEND:"imageloadend",IMAGELOADERROR:"imageloaderror"};class ImageSourceEvent extends BaseEvent{constructor(e,t){super(e),this.image=t}}class ImageSource extends Source{constructor(e){super({attributions:e.attributions,projection:e.projection,state:e.state,interpolate:e.interpolate!==void 0?e.interpolate:!0}),this.on,this.once,this.un,this.loader=e.loader||null,this.resolutions_=e.resolutions!==void 0?e.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=e.loader?e.loader.length===0:!1,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(e){this.resolutions_=e}findNearestResolution(e){const t=this.getResolutions();if(t){const i=linearFindNearest(t,e,0);e=t[i]}return e}getImage(e,t,i,s){const r=this.getProjection();if(!r||!s||equivalent$1(r,s))return r&&(s=r),this.getImageInternal(e,t,i,s);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&equivalent$1(this.reprojectedImage_.getProjection(),s)&&this.reprojectedImage_.getResolution()==t&&equals$1(this.reprojectedImage_.getExtent(),e))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new ReprojImage(r,s,e,t,i,(o,a,l)=>this.getImageInternal(o,a,l,r),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(e,t,i,s){if(this.loader){const r=getRequestExtent(e,t,i,1),o=this.findNearestResolution(t);if(this.image&&(this.static_||this.wantedProjection_===s&&(this.wantedExtent_&&containsExtent(this.wantedExtent_,r)||containsExtent(this.image.getExtent(),r))&&(this.wantedResolution_&&fromResolutionLike(this.wantedResolution_)===o||fromResolutionLike(this.image.getResolution())===o)))return this.image;this.wantedProjection_=s,this.wantedExtent_=r,this.wantedResolution_=o,this.image=new ImageWrapper(r,o,i,this.loader),this.image.addEventListener(EventType.CHANGE,this.handleImageChange.bind(this))}return this.image}handleImageChange(e){const t=e.target;let i;switch(t.getState()){case ImageState.LOADING:this.loading=!0,i=ImageSourceEventType.IMAGELOADSTART;break;case ImageState.LOADED:this.loading=!1,i=ImageSourceEventType.IMAGELOADEND;break;case ImageState.ERROR:this.loading=!1,i=ImageSourceEventType.IMAGELOADERROR;break;default:return}this.hasListener(i)&&this.dispatchEvent(new ImageSourceEvent(i,t))}}function defaultImageLoadFunction(n,e){n.getImage().src=e}function getRequestExtent(n,e,t,i){const s=e/t,r=getCenter(n),o=ceil(getWidth(n)/s,DECIMALS),a=ceil(getHeight(n)/s,DECIMALS),l=ceil((i-1)*o/2,DECIMALS),c=o+2*l,h=ceil((i-1)*a/2,DECIMALS),u=a+2*h;return getForViewAndSize(r,s,0,[c,u])}function createLoader(n){const e=n.load||decode,t=n.imageExtent,i=n.crossOrigin??null;return()=>{const s=new Image;return s.crossOrigin=i,e(s,n.url).then(r=>{const o=getWidth(t)/r.width,a=getHeight(t)/r.height;return{image:r,extent:t,resolution:o!==a?[o,a]:a,pixelRatio:1}})}}class Static extends ImageSource{constructor(e){const t=e.crossOrigin!==void 0?e.crossOrigin:null,i=e.imageLoadFunction!==void 0?e.imageLoadFunction:defaultImageLoadFunction;super({attributions:e.attributions,interpolate:e.interpolate,projection:get$1(e.projection)}),this.url_=e.url,this.imageExtent_=e.imageExtent,this.image=null,this.image=new ImageWrapper(this.imageExtent_,void 0,1,createLoader({url:e.url,imageExtent:e.imageExtent,crossOrigin:t,load:(s,r)=>(this.image.setImage(s),i(this.image,r),decode(s))})),this.image.addEventListener(EventType.CHANGE,this.handleImageChange.bind(this))}getImageExtent(){return this.imageExtent_}getImageInternal(e,t,i,s){return intersects$1(e,this.image.getExtent())?this.image:null}getUrl(){return this.url_}}class WindBarb{constructor(e){ne(this,"maxWinds",72);ne(this,"windbarbWidth");ne(this,"windbarbHeight");ne(this,"interval");ne(this,"lineWidth",1);ne(this,"icons",[]);this.windbarbWidth=e,this.windbarbHeight=e*2,this.interval=this.windbarbHeight/7.8}getIconOfCanvas(e,t=!1){let i=e%2===0?e-e%2:e-e%2+2;if(e>0&&e<=1&&(i=1),this.icons[i])return this.icons[i];const s=document.createElement("canvas");s.width=this.windbarbWidth,s.height=this.windbarbHeight,t&&(s.width*=2,s.height*=2);const r=s.getContext("2d");return r&&(r.lineWidth=this.lineWidth,r.strokeStyle="#ffffff",r.fillStyle="#ffffff",this.createWindBarb(r,i,t),this.icons[i]=s),s}createWindBarb(e,t,i){let s=this.lineWidth/2+1,r=this.windbarbWidth-1;i&&(s=this.lineWidth/2+this.windbarbWidth,r=this.windbarbWidth+this.windbarbWidth);let o=this.lineWidth/2;t>=4&&t<20?(e.beginPath(),e.moveTo(s,this.interval),e.lineTo(s,this.windbarbHeight)):t===0?(e.moveTo(s,this.windbarbHeight-1),e.lineTo(s,this.windbarbHeight)):(e.beginPath(),e.moveTo(s,0),e.lineTo(s,this.windbarbHeight));const a=parseInt(`${t/20}`);if(a>0)for(let h=0;h<a;h++){const u=this.interval*h+this.lineWidth/2*(h+1);o=this.interval*(h+1)+this.lineWidth/2*(h+1),e.moveTo(s,o),e.lineTo(r,u),e.moveTo(s,u),e.lineTo(r,u)}const l=parseInt(`${t%20/4}`);if(l>0)for(let h=0;h<l;h++)o=o+this.interval,e.moveTo(s,o),e.lineTo(r,o-this.interval);parseInt(`${t%20%4/2}`)>0&&(o=o+this.interval,e.moveTo(s,o),e.lineTo(r-this.windbarbWidth/2+2,o-this.interval/2)),e.stroke(),e.beginPath(),e.arc(s,this.windbarbHeight-2,2,0,2*Math.PI),e.fill()}}class FeatureFormat{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=Feature,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let i=t.dataProjection?get$1(t.dataProjection):this.readProjection(e);t.extent&&i&&i.getUnits()==="tile-pixels"&&(i=get$1(i),i.setWorldExtent(t.extent)),t={dataProjection:i,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return abstract()}readFeature(e,t){return abstract()}readFeatures(e,t){return abstract()}readGeometry(e,t){return abstract()}readProjection(e){return abstract()}writeFeature(e,t){return abstract()}writeFeatures(e,t){return abstract()}writeGeometry(e,t){return abstract()}}function transformGeometryWithOptions(n,e,t){const i=t?get$1(t.featureProjection):null,s=t?get$1(t.dataProjection):null;let r=n;if(i&&s&&!equivalent$1(i,s)){e&&(r=n.clone());const o=e?i:s,a=e?s:i;o.getUnits()==="tile-pixels"?r.transform(o,a):r.applyTransform(getTransform(o,a))}if(e&&t&&t.decimals!==void 0){const o=Math.pow(10,t.decimals),a=function(l){for(let c=0,h=l.length;c<h;++c)l[c]=Math.round(l[c]*o)/o;return l};r===n&&(r=n.clone()),r.applyTransform(a)}return r}class TextFeature extends FeatureFormat{constructor(){super()}getType(){return"text"}readFeature(e,t){return this.readFeatureFromText(getText(e),this.adaptOptions(t))}readFeatureFromText(e,t){return abstract()}readFeatures(e,t){return this.readFeaturesFromText(getText(e),this.adaptOptions(t))}readFeaturesFromText(e,t){return abstract()}readGeometry(e,t){return this.readGeometryFromText(getText(e),this.adaptOptions(t))}readGeometryFromText(e,t){return abstract()}readProjection(e){return this.readProjectionFromText(getText(e))}readProjectionFromText(e){return this.dataProjection}writeFeature(e,t){return this.writeFeatureText(e,this.adaptOptions(t))}writeFeatureText(e,t){return abstract()}writeFeatures(e,t){return this.writeFeaturesText(e,this.adaptOptions(t))}writeFeaturesText(e,t){return abstract()}writeGeometry(e,t){return this.writeGeometryText(e,this.adaptOptions(t))}writeGeometryText(e,t){return abstract()}}function getText(n){return typeof n=="string"?n:""}const GeometryConstructor={POINT:Point,LINESTRING:LineString,POLYGON:Polygon,MULTIPOINT:MultiPoint,MULTILINESTRING:MultiLineString,MULTIPOLYGON:MultiPolygon},EMPTY="EMPTY",Z="Z",M="M",ZM="ZM",TokenType={START:0,TEXT:1,LEFT_PAREN:2,RIGHT_PAREN:3,NUMBER:4,COMMA:5,EOF:6},wktTypeLookup={Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION",Circle:"CIRCLE"};class Lexer{constructor(e){this.wkt=e,this.index_=-1}isAlpha_(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}isNumeric_(e,t){return t=t!==void 0?t:!1,e>="0"&&e<="9"||e=="."&&!t}isWhiteSpace_(e){return e==" "||e==" "||e=="\r"||e==`
9
- `}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const e=this.nextChar_(),t=this.index_;let i=e,s;if(e=="(")s=TokenType.LEFT_PAREN;else if(e==",")s=TokenType.COMMA;else if(e==")")s=TokenType.RIGHT_PAREN;else if(this.isNumeric_(e)||e=="-")s=TokenType.NUMBER,i=this.readNumber_();else if(this.isAlpha_(e))s=TokenType.TEXT,i=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(e==="")s=TokenType.EOF;else throw new Error("Unexpected character: "+e)}return{position:t,value:i,type:s}}readNumber_(){let e;const t=this.index_;let i=!1,s=!1;do e=="."?i=!0:(e=="e"||e=="E")&&(s=!0),e=this.nextChar_();while(this.isNumeric_(e,i)||!s&&(e=="e"||e=="E")||s&&(e=="-"||e=="+"));return parseFloat(this.wkt.substring(t,this.index_--))}readText_(){let e;const t=this.index_;do e=this.nextChar_();while(this.isAlpha_(e));return this.wkt.substring(t,this.index_--).toUpperCase()}}class Parser{constructor(e){this.lexer_=e,this.token_={position:0,type:TokenType.START},this.layout_="XY"}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(e){return this.token_.type==e}match(e){const t=this.isTokenType(e);return t&&this.consume_(),t}parse(){return this.consume_(),this.parseGeometry_()}parseGeometryLayout_(){let e="XY";const t=this.token_;if(this.isTokenType(TokenType.TEXT)){const i=t.value;i===Z?e="XYZ":i===M?e="XYM":i===ZM&&(e="XYZM"),e!=="XY"&&this.consume_()}return e}parseGeometryCollectionText_(){if(this.match(TokenType.LEFT_PAREN)){const e=[];do e.push(this.parseGeometry_());while(this.match(TokenType.COMMA));if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(TokenType.LEFT_PAREN)){const e=this.parsePoint_();if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(TokenType.LEFT_PAREN)){const e=this.parsePointList_();if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(TokenType.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(TokenType.LEFT_PAREN)){let e;if(this.token_.type==TokenType.LEFT_PAREN?e=this.parsePointTextList_():e=this.parsePointList_(),this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(TokenType.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(TokenType.LEFT_PAREN)){const e=this.parsePolygonTextList_();if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePoint_(){const e=[],t=this.layout_.length;for(let i=0;i<t;++i){const s=this.token_;if(this.match(TokenType.NUMBER))e.push(s.value);else break}if(e.length==t)return e;throw new Error(this.formatErrorMessage_())}parsePointList_(){const e=[this.parsePoint_()];for(;this.match(TokenType.COMMA);)e.push(this.parsePoint_());return e}parsePointTextList_(){const e=[this.parsePointText_()];for(;this.match(TokenType.COMMA);)e.push(this.parsePointText_());return e}parseLineStringTextList_(){const e=[this.parseLineStringText_()];for(;this.match(TokenType.COMMA);)e.push(this.parseLineStringText_());return e}parsePolygonTextList_(){const e=[this.parsePolygonText_()];for(;this.match(TokenType.COMMA);)e.push(this.parsePolygonText_());return e}isEmptyGeometry_(){const e=this.isTokenType(TokenType.TEXT)&&this.token_.value==EMPTY;return e&&this.consume_(),e}formatErrorMessage_(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}parseGeometry_(){const e=this.token_;if(this.match(TokenType.TEXT)){const t=e.value;this.layout_=this.parseGeometryLayout_();const i=this.isEmptyGeometry_();if(t=="GEOMETRYCOLLECTION"){if(i)return new GeometryCollection([]);const o=this.parseGeometryCollectionText_();return new GeometryCollection(o)}const s=GeometryConstructor[t];if(!s)throw new Error("Invalid geometry type: "+t);let r;if(i)t=="POINT"?r=[NaN,NaN]:r=[];else switch(t){case"POINT":{r=this.parsePointText_();break}case"LINESTRING":{r=this.parseLineStringText_();break}case"POLYGON":{r=this.parsePolygonText_();break}case"MULTIPOINT":{r=this.parseMultiPointText_();break}case"MULTILINESTRING":{r=this.parseMultiLineStringText_();break}case"MULTIPOLYGON":{r=this.parseMultiPolygonText_();break}}return new s(r,this.layout_)}throw new Error(this.formatErrorMessage_())}}class WKT extends TextFeature{constructor(e){super(),e=e||{},this.splitCollection_=e.splitCollection!==void 0?e.splitCollection:!1}parse_(e){const t=new Lexer(e);return new Parser(t).parse()}readFeatureFromText(e,t){const i=this.readGeometryFromText(e,t),s=new Feature;return s.setGeometry(i),s}readFeaturesFromText(e,t){let i=[];const s=this.readGeometryFromText(e,t);this.splitCollection_&&s.getType()=="GeometryCollection"?i=s.getGeometriesArray():i=[s];const r=[];for(let o=0,a=i.length;o<a;++o){const l=new Feature;l.setGeometry(i[o]),r.push(l)}return r}readGeometryFromText(e,t){const i=this.parse_(e);return transformGeometryWithOptions(i,!1,t)}writeFeatureText(e,t){const i=e.getGeometry();return i?this.writeGeometryText(i,t):""}writeFeaturesText(e,t){if(e.length==1)return this.writeFeatureText(e[0],t);const i=[];for(let r=0,o=e.length;r<o;++r)i.push(e[r].getGeometry());const s=new GeometryCollection(i);return this.writeGeometryText(s,t)}writeGeometryText(e,t){return encode(transformGeometryWithOptions(e,!0,t))}}function encodePointGeometry(n){const e=n.getCoordinates();return e.length===0?"":e.join(" ")}function encodeMultiPointGeometry(n){const e=[],t=n.getPoints();for(let i=0,s=t.length;i<s;++i)e.push("("+encodePointGeometry(t[i])+")");return e.join(",")}function encodeGeometryCollectionGeometry(n){const e=[],t=n.getGeometries();for(let i=0,s=t.length;i<s;++i)e.push(encode(t[i]));return e.join(",")}function encodeLineStringGeometry(n){const e=n.getCoordinates(),t=[];for(let i=0,s=e.length;i<s;++i)t.push(e[i].join(" "));return t.join(",")}function encodeMultiLineStringGeometry(n){const e=[],t=n.getLineStrings();for(let i=0,s=t.length;i<s;++i)e.push("("+encodeLineStringGeometry(t[i])+")");return e.join(",")}function encodePolygonGeometry(n){const e=[],t=n.getLinearRings();for(let i=0,s=t.length;i<s;++i)e.push("("+encodeLineStringGeometry(t[i])+")");return e.join(",")}function encodeMultiPolygonGeometry(n){const e=[],t=n.getPolygons();for(let i=0,s=t.length;i<s;++i)e.push("("+encodePolygonGeometry(t[i])+")");return e.join(",")}function encodeGeometryLayout(n){const e=n.getLayout();let t="";return(e==="XYZ"||e==="XYZM")&&(t+=Z),(e==="XYM"||e==="XYZM")&&(t+=M),t}const GeometryEncoder={Point:encodePointGeometry,LineString:encodeLineStringGeometry,Polygon:encodePolygonGeometry,MultiPoint:encodeMultiPointGeometry,MultiLineString:encodeMultiLineStringGeometry,MultiPolygon:encodeMultiPolygonGeometry,GeometryCollection:encodeGeometryCollectionGeometry};function encode(n){const e=n.getType(),t=GeometryEncoder[e],i=t(n);let s=wktTypeLookup[e];if(typeof n.getFlatCoordinates=="function"){const r=encodeGeometryLayout(n);r.length>0&&(s+=" "+r)}return i.length===0?s+" "+EMPTY:s+"("+i+")"}var earthRadius=63710088e-1,factors={centimeters:earthRadius*100,centimetres:earthRadius*100,degrees:360/(2*Math.PI),feet:earthRadius*3.28084,inches:earthRadius*39.37,kilometers:earthRadius/1e3,kilometres:earthRadius/1e3,meters:earthRadius,metres:earthRadius,miles:earthRadius/1609.344,millimeters:earthRadius*1e3,millimetres:earthRadius*1e3,nauticalmiles:earthRadius/1852,radians:1,yards:earthRadius*1.0936};function lengthToRadians(n,e="kilometers"){const t=factors[e];if(!t)throw new Error(e+" units is invalid");return n/t}function lengthToDegrees(n,e){return radiansToDegrees(lengthToRadians(n,e))}function radiansToDegrees(n){return n%(2*Math.PI)*180/Math.PI}class Typhoon{constructor(){ne(this,"typhoonLevel",{CZ:"#000000",TD:"#00ff00",TS:"#0000ff",STS:"#ffff00",TY:"#ffa000",STY:"#ff0000",SUPERTY:"#a200a2"});ne(this,"vectorSource");ne(this,"lastPointLive")}createTrack(e){this.vectorSource||(this.vectorSource=new VectorSource);let t={coordinate:[],color:""};for(let i=0;i<e.live.length;i++){const s=e.live[i],r=[s.longitude,s.latitude];this.drawPoint(this.vectorSource,s,e.baseInfo,e.unit);const o=this.typhoonLevel[s.tcRank]?this.typhoonLevel[s.tcRank]:"#ffffff";if(i>0){const a=[];a.push(t.coordinate),a.push(r);const l=new Feature({geometry:new LineString(a)});let c;s.type==="forecast"&&(c=[5]),l.setStyle(new Style({stroke:new Stroke({color:t.color,width:1,lineDash:c})})),this.vectorSource.addFeature(l)}t={color:o,coordinate:r},this.lastPointLive=s}for(const i in e.forecast){const s=e.forecast[i].fore,r=e.forecast[i].obs,o=[];if(s.length>0){if(r&&r.length>0){const l=this.getLastPoint(e,r[0]);o.push([Number(l.longitude),Number(l.latitude)])}s.forEach(l=>{this.drawPoint(this.vectorSource,l,e.baseInfo,e.unit),o.push([Number(l.longitude),Number(l.latitude)])});const a=new Feature({geometry:new LineString(o)});a.setStyle(new Style({stroke:new Stroke({color:e.forecast[i].color,width:2,lineDash:[5]})})),this.vectorSource.addFeature(a)}}return this.drawWindCircle(),this.vectorSource}drawPoint(e,t,i,s){const r=[t.longitude,t.latitude],o=new Feature({geometry:new Point(r)});t.baseInfo=i,t.unit=s,o.set("mark","typhoon"),o.set("data",t);const a=this.typhoonLevel[t.tcRank]?this.typhoonLevel[t.tcRank]:"#ffffff";o.setStyle(new Style({image:new CircleStyle({radius:4,stroke:new Stroke({width:1,color:"#5e5e5e"}),fill:new Fill({color:a})}),zIndex:2})),e.addFeature(o)}drawWindCircle(e){const t=e||this.lastPointLive;this.vectorSource.forEachFeature(s=>{s.getId()!==void 0&&s.getId().includes("typhoon")&&this.vectorSource.removeFeature(s)});const i={rd06:"#00FF00",rd07:"#0000FF",rd08:"#FFFF00",rd10:"#F59A23",rd12:"#FF0000"};for(const s in i)if(t[s]){let r=t[s].split(",").map(Number);const o={x:Number(t.longitude),y:Number(t.latitude),r:{SE:lengthToDegrees(r[3]),NE:lengthToDegrees(r[2]),NW:lengthToDegrees(r[1]),SW:lengthToDegrees(r[0])},interval:2,color:i[s]},a=new WKT;let l="POLYGON((",c="";for(let u=0;u<360/o.interval;u++){let d=0;const g=u*o.interval;g>0&&g<=90?d=o.r.NE:g>90&&g<=180?d=o.r.NW:g>180&&g<=270?d=o.r.SW:d=o.r.SE;const f=o.x+d*Math.cos(g*Math.PI/180),m=o.y+d*Math.sin(g*Math.PI/180);l=l+`${f} ${m},`,u===0&&(c=`${f} ${m}`)}l=l+c+"))";const h=a.readFeature(l);h.setId(`typhoon_${s}`),h.setStyle(new Style({stroke:new Stroke({color:o.color})})),this.vectorSource.addFeature(h)}}getLastPoint(e,t){let i=e.live[0];return e.live.forEach(s=>{if(new Date(t.ddateTime).getTime()>=new Date(s.ddateTime).getTime())i=s;else return}),i}}const Property={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class Overlay extends BaseObject{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=e.insertFirst!==void 0?e.insertFirst:!0,this.stopEvent=e.stopEvent!==void 0?e.stopEvent:!0,this.element=document.createElement("div"),this.element.className=e.className!==void 0?e.className:"ol-overlay-container "+CLASS_SELECTABLE,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=e.autoPan===!0?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(Property.ELEMENT,this.handleElementChanged),this.addChangeListener(Property.MAP,this.handleMapChanged),this.addChangeListener(Property.OFFSET,this.handleOffsetChanged),this.addChangeListener(Property.POSITION,this.handlePositionChanged),this.addChangeListener(Property.POSITIONING,this.handlePositioningChanged),e.element!==void 0&&this.setElement(e.element),this.setOffset(e.offset!==void 0?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),e.position!==void 0&&this.setPosition(e.position)}getElement(){return this.get(Property.ELEMENT)}getId(){return this.id}getMap(){return this.get(Property.MAP)||null}getOffset(){return this.get(Property.OFFSET)}getPosition(){return this.get(Property.POSITION)}getPositioning(){return this.get(Property.POSITIONING)}handleElementChanged(){removeChildren(this.element);const e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){var t;this.mapPostrenderListenerKey&&((t=this.element)==null||t.remove(),unlistenByKey(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const e=this.getMap();if(e){this.mapPostrenderListenerKey=listen(e,MapEventType.POSTRENDER,this.render,this),this.updatePixelPosition();const i=this.stopEvent?e.getOverlayContainerStopEvent():e.getOverlayContainer();this.insertFirst?i.insertBefore(this.element,i.childNodes[0]||null):i.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(Property.ELEMENT,e)}setMap(e){this.set(Property.MAP,e)}setOffset(e){this.set(Property.OFFSET,e)}setPosition(e){this.set(Property.POSITION,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(Property.POSITION))return;const i=this.getRect(t.getTargetElement(),t.getSize()),s=this.getElement(),r=this.getRect(s,[outerWidth(s),outerHeight(s)]);e=e||{};const o=e.margin===void 0?20:e.margin;if(!containsExtent(i,r)){const a=r[0]-i[0],l=i[2]-r[2],c=r[1]-i[1],h=i[3]-r[3],u=[0,0];if(a<0?u[0]=a-o:l<0&&(u[0]=Math.abs(l)+o),c<0?u[1]=c-o:h<0&&(u[1]=Math.abs(h)+o),u[0]!==0||u[1]!==0){const d=t.getView().getCenterInternal(),g=t.getPixelFromCoordinateInternal(d);if(!g)return;const f=[g[0]+u[0],g[1]+u[1]],m=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(f),duration:m.duration,easing:m.easing})}}}getRect(e,t){const i=e.getBoundingClientRect(),s=i.left+window.pageXOffset,r=i.top+window.pageYOffset;return[s,r,s+t[0],r+t[1]]}setPositioning(e){this.set(Property.POSITIONING,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){const e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t){this.setVisible(!1);return}const i=e.getPixelFromCoordinate(t),s=e.getSize();this.updateRenderedPosition(i,s)}updateRenderedPosition(e,t){const i=this.element.style,s=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=`${e[0]+s[0]}px`,a=`${e[1]+s[1]}px`;let l="0%",c="0%";r=="bottom-right"||r=="center-right"||r=="top-right"?l="-100%":(r=="bottom-center"||r=="center-center"||r=="top-center")&&(l="-50%"),r=="bottom-left"||r=="bottom-center"||r=="bottom-right"?c="-100%":(r=="center-left"||r=="center-center"||r=="center-right")&&(c="-50%");const h=`translate(${l}, ${c}) translate(${o}, ${a})`;this.rendered.transform_!=h&&(this.rendered.transform_=h,i.transform=h)}getOptions(){return this.options}}const _hoisted_1={id:"map",class:"map"},transparentTile="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",_sfc_main=vue.defineComponent({__name:"VueOl",props:{options:{}},emits:["olMap"],setup(__props,{emit:__emit}){const emits=__emit,props=__props,layers=[],options={target:"map",layers,view:new View(props.options.view),controls:defaults$1({rotate:!1,zoom:!1,...props.options.controls})};let map;const typhoonList={},typhoonMarks={},pendingImageStaticUrls=new WeakMap,addLayer=n=>{let e=getLayer(n);return e&&e.set("id",n.id),e},updateLayer=(n,e,t)=>{const s=map.getLayers().getArray().find(r=>r.get("id")===n);switch(e){case"xyz":updateXYZLayer(s,t,n);break;case"imageStatic":updateImageStaticLayer(s,t,n);break;case"point":updatePointLayer(s,t);break;case"typhoon":updateTyphoonLayer(s,t,n);break;default:console.error(`未定义类型(${e}),请使用原生ol实现!`);break}},updateXYZLayer=(n,e,t)=>{updated(n,e,t,["extent","map","maxResolution","maxZoom","minResolution","minZoom","opacity","preload","properties","source","useInterimTilesOnError","visible","zIndex"],["attributions","properties","renderReprojectionEdges","tileGridForProjection","tileUrlFunction","url"])},updateImageStaticUrl=(n,e,t)=>{var a;const i=!!(e!=null&&e.useInterimTilesWhenMissing),s=n.getSource(),r=!!(s&&typeof s.setUrl=="function");if(pendingImageStaticUrls.delete(n),!t){i&&n.setSource(null);return}if(!e)return;pendingImageStaticUrls.set(n,t);const o=document.createElement("img");((a=e.source)==null?void 0:a.crossOrigin)!==void 0&&(o.crossOrigin=e.source.crossOrigin),o.onload=()=>{pendingImageStaticUrls.get(n)===t&&(r&&n.getSource()===s?s.setUrl(t):n.setSource(getSource(e)),pendingImageStaticUrls.delete(n))},o.onerror=()=>{pendingImageStaticUrls.get(n)===t&&(i&&n.setSource(null),pendingImageStaticUrls.delete(n))},o.src=t},updateImageStaticLayer=(n,e,t)=>{let i=e;if(Object.prototype.hasOwnProperty.call(e.source??{},"url")){const o=props.options.layers.find(l=>l.id===t);updateImageStaticUrl(n,o,e.source.url);const a={...e.source};delete a.url,i={...e,source:a},Object.keys(i.source).length===0&&delete i.source}updated(n,i,t,["extent","map","maxResolution","maxZoom","minResolution","minZoom","opacity","properties","source","visible","zIndex"],["attributions","properties","url"])},updatePointLayer=(layer,info)=>{const layerEffectiveFields=["declutter","extent","map","maxResolution","maxZoom","minResolution","minZoom","opacity","properties","source","style","visible","zIndex"],source=layer.getSource();for(const key in info)if(key==="add"){const n=[];info[key].length>0&&(info[key].forEach(e=>{const t=new Feature;t.setGeometry(new Point([e.lng,e.lat]));const i={...e};delete i.style,t.set("data",i),t.setId(e.id),e.style&&t.setStyle(getStyle(e.style,e)),n.push(t)}),source.addFeatures(n))}else if(key==="update"){if(info[key].length>0){const n=[],e=[];info[key].forEach(t=>{const i=new Feature;i.setGeometry(new Point([t.lng,t.lat])),i.set("data",t),i.setId(t.id),t.style&&i.setStyle(getStyle(t.style,t)),n.push(source.getFeatureById(t.id)),e.push(i)}),source.removeFeatures(n),source.addFeatures(e)}}else if(key==="delete"){const n=[];info[key].length>0&&info[key].forEach(e=>{n.push(source.getFeatureById(e.id))}),source.removeFeatures(n)}else if(key==="style"){const n=typeof info[key]=="function"?info[key]:getStyle(info[key]);layer.setStyle(n)}else layerEffectiveFields.includes(key)&&eval(`layer.set${capitalize(key)}(info[key])`)},updateTyphoonLayer=(n,e,t)=>{const i=["extent","layers","maxResolution","maxZoom","minResolution","minZoom","opacity","properties","visible","zIndex"];if(e.visible!==void 0){const s=props.options.layers.findIndex(o=>o.id===t),r=props.options.layers[s].data.baseInfo.tsId;for(const o in typhoonMarks)if(o.includes(r))if(e.visible){const a=typhoonMarks[o].nameOverlay.get("lnglat"),l=typhoonMarks[o].lastPointOverlay.get("lnglat");typhoonMarks[o].nameOverlay.setPosition(a),typhoonMarks[o].lastPointOverlay.setPosition(l)}else typhoonMarks[o].nameOverlay.setPosition(void 0),typhoonMarks[o].lastPointOverlay.setPosition(void 0)}updated(n,e,t,i,[])},updated=(layer,info,id,layerEffectiveFields,sourceEffectiveFields)=>{for(const key in info)if(key==="source")if(Object.keys(info.source).every(t=>sourceEffectiveFields.includes(t))){const t=layer.getSource();if(t)for(const i in info.source){const s=t[`set${capitalize(i)}`];typeof s=="function"&&s.call(t,info.source[i])}}else{const t=props.options.layers.findIndex(i=>i.id===id);layer.setSource(null),setTimeout(()=>{const i=getSource(props.options.layers[t]);layer.setSource(i)})}else layerEffectiveFields.includes(key)&&eval(`layer.set${capitalize(key)}(info[key])`)},getLayer=n=>{switch(n.type){case"xyz":return getXYZLayer(n);case"imageStatic":return getImageStaticLayer(n);case"point":return getPointLayer(n);case"typhoon":return getTypeoonLayer(n);default:console.error(`layer config error;id:${n.id}`);break}},getXYZLayer=n=>{const e=getSource(n);return new TileLayer({...n,source:e})},getImageStaticLayer=n=>{const e=getSource(n),t={...n,source:e};return new ImageLayer(t)},getPointLayer=n=>{const e={...n};delete e.data,delete e.style;const t=new VectorLayer({...e,source:getPointSource(n)});if(n.style){const i=typeof n.style=="function"?n.style:getStyle(n.style);t.setStyle(i)}return t},getTypeoonLayer=n=>{const e=[],t=[];if(n.data.mainPath){const r=n.data.data[n.data.mainPath],o={};o.live=[...r.obs].reverse(),o.forecast=n.data.data,o.baseInfo=n.data.baseInfo,o.unit=n.data.mainPath,e.push(o)}else for(const r in n.data.data){const o={};o.live=[...n.data.data[r].obs].reverse(),o.baseInfo=n.data.baseInfo,o.forecast={},o.forecast[r]=n.data.data[r],o.unit=r,e.push(o)}e.forEach(r=>{if(r.live.length===0)return;const o=new Typhoon,a=n.data.baseInfo.tsId+"_"+r.unit;typhoonList[a]=o;const l=new VectorLayer({source:o.createTrack(r)});if(t.push(l),typhoonMarks[a]||(typhoonMarks[a]={}),n.data.baseInfo.tseName){const h=r.live[0],u=document.createElement("div");u.innerHTML=`<span style="font-weight:bold;font-size:14px">${n.data.baseInfo.tscName}${n.data.baseInfo.tseName}</span>`;let d;(n.visible===void 0||n.visible)&&(d=[h.longitude,h.latitude]);const g=new Overlay({position:d,element:u,positioning:"bottom-center",offset:[0,-10],stopEvent:!1});g.set("lnglat",[h.longitude,h.latitude]),map.addOverlay(g),typhoonMarks[a].nameOverlay=g}const c=r.live[r.live.length-1];if(c.tcRank!==""){const h=new URL(Object.assign({"../assets/images/typhoon-STS.png":__vite_glob_0_0,"../assets/images/typhoon-STY.png":__vite_glob_0_1,"../assets/images/typhoon-SUPERTY.png":__vite_glob_0_2,"../assets/images/typhoon-TD.png":__vite_glob_0_3,"../assets/images/typhoon-TS.png":__vite_glob_0_4,"../assets/images/typhoon-TY.png":__vite_glob_0_5})[`../assets/images/typhoon-${c.tcRank}.png`],typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("runbir-tools.umd.js",document.baseURI).href).href,u=document.createElement("div");u.innerHTML=`<img src="${h}" style="width:30px;height: 30px;animation: rotate 2s infinite;"/>`;let d;(n.visible===void 0||n.visible)&&(d=[c.longitude,c.latitude]);const g=new Overlay({position:d,element:u,positioning:"center-center",stopEvent:!1});g.set("lnglat",[c.longitude,c.latitude]),map.addOverlay(g),typhoonMarks[a].lastPointOverlay=g}});const i={...n};return delete i.data,new LayerGroup({...i,layers:t})},getSource=n=>{switch(n.type){case"xyz":{const e={...n.source};return n.useInterimTilesWhenMissing&&(e.transition=0,e.tileLoadFunction=(t,i)=>{const s=t.getImage(),r=document.createElement("img");e.crossOrigin!==void 0&&(r.crossOrigin=e.crossOrigin),r.onload=()=>{s.src=i},r.onerror=()=>{s.src=transparentTile},r.src=i}),new XYZ(e)}case"imageStatic":{const e={...n.source};return n.useInterimTilesWhenMissing&&(e.imageLoadFunction=(t,i)=>{const s=t.getImage();if(!i){s.src=transparentTile;return}const r=document.createElement("img");e.crossOrigin!==void 0&&(r.crossOrigin=e.crossOrigin),r.onload=()=>{s.src=i},r.onerror=()=>{s.src=transparentTile},r.src=i}),new Static(e)}case"point":return getPointSource(n);default:console.error(`layer config error;id:${n.id}`);break}},getPointSource=n=>{const e=[];return n.data.forEach(t=>{const i=new Feature;i.setGeometry(new Point([t.lng,t.lat])),i.set("data",t),i.setId(t.id),t.style&&i.setStyle(getStyle(t.style,t)),e.push(i)}),new VectorSource({...n.source,features:e})},getStyle=(n,e)=>{const t={...n};if(n.image){let i;switch(n.image.type){case"circle":{i=new CircleStyle({...n.image,fill:new Fill({...n.image.fill}),stroke:new Stroke({...n.image.stroke})});break}case"icon":i=new Icon({...n.image});break;case"regularShape":{i=new RegularShape({...n.image,fill:new Fill({...n.image.fill}),stroke:new Stroke({...n.image.stroke})});break}case"windBarb":{const s=n.image.size||[12,24],o=new WindBarb(s[0]).getIconOfCanvas(e.winds),a=parseFloat(e.windd)*Math.PI/180;i=new Icon({img:o,size:s,anchor:[2,1],anchorXUnits:"pixels",rotation:a,color:getColor(e.winds),...n.image});break}default:console.error("暂不支持此图标类型,请自行原生处理。");break}t.image=i}if(n.text){const i=new Text({...n.text,text:e.text});t.text=i}return new Style(t)};props.options.layers.forEach(n=>{const e=addLayer(n);e&&layers.push(e)});function capitalize(n){return n.charAt(0).toUpperCase()+n.slice(1)}const cloneDeepKeepFunction=n=>{if(Array.isArray(n))return n.map(e=>cloneDeepKeepFunction(e));if(n&&typeof n=="object"){const e={};return Object.keys(n).forEach(t=>{e[t]=cloneDeepKeepFunction(n[t])}),e}return n},isEqualWithFunction=(n,e)=>{if(typeof n=="function"||typeof e=="function")return typeof n!="function"||typeof e!="function"?!1:n===e||n.toString()===e.toString();if(n===e)return!0;if(Array.isArray(n)&&Array.isArray(e))return n.length!==e.length?!1:n.every((t,i)=>isEqualWithFunction(t,e[i]));if(n&&e&&typeof n=="object"&&typeof e=="object"){const t=Object.keys(n),i=Object.keys(e);return t.length!==i.length?!1:t.every(s=>isEqualWithFunction(n[s],e[s]))}return!1};function getColor(n){return n<10.8?"#404040":n<13.9?"#008000":n<17.2?"#0000ff":n<24.5?"#ff7d00":"#ff0000"}let typhoonPoint;const handlePointermove=n=>{let e=!1;if(map.forEachFeatureAtPixel(n.pixel,t=>{t.get("mark")&&(typhoonPoint=t.get("data"),e=!0)}),e){const t=typhoonPoint.baseInfo.tsId+"_"+typhoonPoint.unit;typhoonList[t].drawWindCircle(typhoonPoint)}else if(typhoonPoint){const t=typhoonPoint.baseInfo.tsId+"_"+typhoonPoint.unit;typhoonList[t].drawWindCircle(),typhoonPoint=void 0}};vue.onMounted(()=>{map=new Map(options);const n=new Set;props.options.event&&props.options.event.register.forEach(e=>{n.add(e)}),n.add("pointermove"),map.on([...n],e=>{switch(props.options.event&&props.options.event.register.includes(e.type)&&props.options.event.callback(e),e.type){case"pointermove":handlePointermove(e);break}}),emits("olMap",map)}),vue.watch(()=>props.options.view.center,n=>{map.getView().setCenter(n)}),vue.watch(()=>props.options.view.constrainResolution,n=>{n&&map.getView().setConstrainResolution(n)}),vue.watch(()=>props.options.view.maxZoom,n=>{n&&map.getView().setMaxZoom(n)}),vue.watch(()=>props.options.view.minZoom,n=>{n&&map.getView().setMinZoom(n)}),vue.watch(()=>props.options.view.resolution,n=>{n&&map.getView().setResolution(n)}),vue.watch(()=>props.options.view.rotation,n=>{n&&map.getView().setRotation(n)}),vue.watch(()=>props.options.view.zoom,n=>{n&&map.getView().setZoom(n)}),vue.watch(()=>props.options.view,n=>{map.setView(new View(n))});let previousLayersSnapshot=cloneDeepKeepFunction(props.options.layers);return vue.watch(()=>props.options.layers,n=>{if(!map){previousLayersSnapshot=cloneDeepKeepFunction(n);return}const e=previousLayersSnapshot;n.forEach(t=>{const i=e.findIndex(s=>s.id===t.id);if(i>-1){const s={};for(const r in t)if(!isEqualWithFunction(t[r],e[i][r]))if(r==="source"){const o={};for(const a in t[r])isEqualWithFunction(t[r][a],e[i][r][a])||(o[a]=t[r][a]);s[r]=o}else t.type==="point"&&r==="data"?(s.add=[],s.update=[],s.delete=[],t[r].forEach(o=>{const a=e[i][r].findIndex(l=>l.id===o.id);a<0?s.add.push(o):isEqualWithFunction(o,e[i][r][a])||s.update.push(o)}),e[i][r].forEach(o=>{t[r].find(l=>l.id===o.id)||s.delete.push(o)})):s[r]=t[r];Object.keys(s).length>0&&updateLayer(t.id,t.type,s)}else{const s=addLayer(t);map.addLayer(s)}}),e.forEach(t=>{if(n.findIndex(s=>s.id===t.id)<0){const s=map.getLayers(),r=s.getArray().find(o=>o.get("id")===t.id);if(r&&s.remove(r),t.type==="typhoon"){const o=t.data.baseInfo.tsId;for(const a in typhoonMarks)a.includes(o)&&(map.removeOverlay(typhoonMarks[a].nameOverlay),map.removeOverlay(typhoonMarks[a].lastPointOverlay),delete typhoonMarks[a])}}}),previousLayersSnapshot=cloneDeepKeepFunction(n)},{deep:!0}),(n,e)=>(vue.openBlock(),vue.createElementBlock("div",_hoisted_1))}}),_export_sfc=(n,e)=>{const t=n.__vccOpts||n;for(const[i,s]of e)t[i]=s;return t},VueOl=_export_sfc(_sfc_main,[["__scopeId","data-v-df8b758d"]]),plugin={install(n){n.component("VueOl",VueOl)}};exports.VueOl=VueOl,exports.default=plugin,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
9
+ `}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const e=this.nextChar_(),t=this.index_;let i=e,s;if(e=="(")s=TokenType.LEFT_PAREN;else if(e==",")s=TokenType.COMMA;else if(e==")")s=TokenType.RIGHT_PAREN;else if(this.isNumeric_(e)||e=="-")s=TokenType.NUMBER,i=this.readNumber_();else if(this.isAlpha_(e))s=TokenType.TEXT,i=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(e==="")s=TokenType.EOF;else throw new Error("Unexpected character: "+e)}return{position:t,value:i,type:s}}readNumber_(){let e;const t=this.index_;let i=!1,s=!1;do e=="."?i=!0:(e=="e"||e=="E")&&(s=!0),e=this.nextChar_();while(this.isNumeric_(e,i)||!s&&(e=="e"||e=="E")||s&&(e=="-"||e=="+"));return parseFloat(this.wkt.substring(t,this.index_--))}readText_(){let e;const t=this.index_;do e=this.nextChar_();while(this.isAlpha_(e));return this.wkt.substring(t,this.index_--).toUpperCase()}}class Parser{constructor(e){this.lexer_=e,this.token_={position:0,type:TokenType.START},this.layout_="XY"}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(e){return this.token_.type==e}match(e){const t=this.isTokenType(e);return t&&this.consume_(),t}parse(){return this.consume_(),this.parseGeometry_()}parseGeometryLayout_(){let e="XY";const t=this.token_;if(this.isTokenType(TokenType.TEXT)){const i=t.value;i===Z?e="XYZ":i===M?e="XYM":i===ZM&&(e="XYZM"),e!=="XY"&&this.consume_()}return e}parseGeometryCollectionText_(){if(this.match(TokenType.LEFT_PAREN)){const e=[];do e.push(this.parseGeometry_());while(this.match(TokenType.COMMA));if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(TokenType.LEFT_PAREN)){const e=this.parsePoint_();if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(TokenType.LEFT_PAREN)){const e=this.parsePointList_();if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(TokenType.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(TokenType.LEFT_PAREN)){let e;if(this.token_.type==TokenType.LEFT_PAREN?e=this.parsePointTextList_():e=this.parsePointList_(),this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(TokenType.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(TokenType.LEFT_PAREN)){const e=this.parsePolygonTextList_();if(this.match(TokenType.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePoint_(){const e=[],t=this.layout_.length;for(let i=0;i<t;++i){const s=this.token_;if(this.match(TokenType.NUMBER))e.push(s.value);else break}if(e.length==t)return e;throw new Error(this.formatErrorMessage_())}parsePointList_(){const e=[this.parsePoint_()];for(;this.match(TokenType.COMMA);)e.push(this.parsePoint_());return e}parsePointTextList_(){const e=[this.parsePointText_()];for(;this.match(TokenType.COMMA);)e.push(this.parsePointText_());return e}parseLineStringTextList_(){const e=[this.parseLineStringText_()];for(;this.match(TokenType.COMMA);)e.push(this.parseLineStringText_());return e}parsePolygonTextList_(){const e=[this.parsePolygonText_()];for(;this.match(TokenType.COMMA);)e.push(this.parsePolygonText_());return e}isEmptyGeometry_(){const e=this.isTokenType(TokenType.TEXT)&&this.token_.value==EMPTY;return e&&this.consume_(),e}formatErrorMessage_(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}parseGeometry_(){const e=this.token_;if(this.match(TokenType.TEXT)){const t=e.value;this.layout_=this.parseGeometryLayout_();const i=this.isEmptyGeometry_();if(t=="GEOMETRYCOLLECTION"){if(i)return new GeometryCollection([]);const o=this.parseGeometryCollectionText_();return new GeometryCollection(o)}const s=GeometryConstructor[t];if(!s)throw new Error("Invalid geometry type: "+t);let r;if(i)t=="POINT"?r=[NaN,NaN]:r=[];else switch(t){case"POINT":{r=this.parsePointText_();break}case"LINESTRING":{r=this.parseLineStringText_();break}case"POLYGON":{r=this.parsePolygonText_();break}case"MULTIPOINT":{r=this.parseMultiPointText_();break}case"MULTILINESTRING":{r=this.parseMultiLineStringText_();break}case"MULTIPOLYGON":{r=this.parseMultiPolygonText_();break}}return new s(r,this.layout_)}throw new Error(this.formatErrorMessage_())}}class WKT extends TextFeature{constructor(e){super(),e=e||{},this.splitCollection_=e.splitCollection!==void 0?e.splitCollection:!1}parse_(e){const t=new Lexer(e);return new Parser(t).parse()}readFeatureFromText(e,t){const i=this.readGeometryFromText(e,t),s=new Feature;return s.setGeometry(i),s}readFeaturesFromText(e,t){let i=[];const s=this.readGeometryFromText(e,t);this.splitCollection_&&s.getType()=="GeometryCollection"?i=s.getGeometriesArray():i=[s];const r=[];for(let o=0,a=i.length;o<a;++o){const l=new Feature;l.setGeometry(i[o]),r.push(l)}return r}readGeometryFromText(e,t){const i=this.parse_(e);return transformGeometryWithOptions(i,!1,t)}writeFeatureText(e,t){const i=e.getGeometry();return i?this.writeGeometryText(i,t):""}writeFeaturesText(e,t){if(e.length==1)return this.writeFeatureText(e[0],t);const i=[];for(let r=0,o=e.length;r<o;++r)i.push(e[r].getGeometry());const s=new GeometryCollection(i);return this.writeGeometryText(s,t)}writeGeometryText(e,t){return encode(transformGeometryWithOptions(e,!0,t))}}function encodePointGeometry(n){const e=n.getCoordinates();return e.length===0?"":e.join(" ")}function encodeMultiPointGeometry(n){const e=[],t=n.getPoints();for(let i=0,s=t.length;i<s;++i)e.push("("+encodePointGeometry(t[i])+")");return e.join(",")}function encodeGeometryCollectionGeometry(n){const e=[],t=n.getGeometries();for(let i=0,s=t.length;i<s;++i)e.push(encode(t[i]));return e.join(",")}function encodeLineStringGeometry(n){const e=n.getCoordinates(),t=[];for(let i=0,s=e.length;i<s;++i)t.push(e[i].join(" "));return t.join(",")}function encodeMultiLineStringGeometry(n){const e=[],t=n.getLineStrings();for(let i=0,s=t.length;i<s;++i)e.push("("+encodeLineStringGeometry(t[i])+")");return e.join(",")}function encodePolygonGeometry(n){const e=[],t=n.getLinearRings();for(let i=0,s=t.length;i<s;++i)e.push("("+encodeLineStringGeometry(t[i])+")");return e.join(",")}function encodeMultiPolygonGeometry(n){const e=[],t=n.getPolygons();for(let i=0,s=t.length;i<s;++i)e.push("("+encodePolygonGeometry(t[i])+")");return e.join(",")}function encodeGeometryLayout(n){const e=n.getLayout();let t="";return(e==="XYZ"||e==="XYZM")&&(t+=Z),(e==="XYM"||e==="XYZM")&&(t+=M),t}const GeometryEncoder={Point:encodePointGeometry,LineString:encodeLineStringGeometry,Polygon:encodePolygonGeometry,MultiPoint:encodeMultiPointGeometry,MultiLineString:encodeMultiLineStringGeometry,MultiPolygon:encodeMultiPolygonGeometry,GeometryCollection:encodeGeometryCollectionGeometry};function encode(n){const e=n.getType(),t=GeometryEncoder[e],i=t(n);let s=wktTypeLookup[e];if(typeof n.getFlatCoordinates=="function"){const r=encodeGeometryLayout(n);r.length>0&&(s+=" "+r)}return i.length===0?s+" "+EMPTY:s+"("+i+")"}var earthRadius=63710088e-1,factors={centimeters:earthRadius*100,centimetres:earthRadius*100,degrees:360/(2*Math.PI),feet:earthRadius*3.28084,inches:earthRadius*39.37,kilometers:earthRadius/1e3,kilometres:earthRadius/1e3,meters:earthRadius,metres:earthRadius,miles:earthRadius/1609.344,millimeters:earthRadius*1e3,millimetres:earthRadius*1e3,nauticalmiles:earthRadius/1852,radians:1,yards:earthRadius*1.0936};function lengthToRadians(n,e="kilometers"){const t=factors[e];if(!t)throw new Error(e+" units is invalid");return n/t}function lengthToDegrees(n,e){return radiansToDegrees(lengthToRadians(n,e))}function radiansToDegrees(n){return n%(2*Math.PI)*180/Math.PI}class Typhoon{constructor(){ne(this,"typhoonLevel",{CZ:"#000000",TD:"#00ff00",TS:"#0000ff",STS:"#ffff00",TY:"#ffa000",STY:"#ff0000",SUPERTY:"#a200a2"});ne(this,"vectorSource");ne(this,"lastPointLive")}createTrack(e){this.vectorSource||(this.vectorSource=new VectorSource);let t={coordinate:[],color:""};for(let i=0;i<e.live.length;i++){const s=e.live[i],r=[s.longitude,s.latitude];this.drawPoint(this.vectorSource,s,e.baseInfo,e.unit);const o=this.typhoonLevel[s.tcRank]?this.typhoonLevel[s.tcRank]:"#ffffff";if(i>0){const a=[];a.push(t.coordinate),a.push(r);const l=new Feature({geometry:new LineString(a)});let c;s.type==="forecast"&&(c=[5]),l.setStyle(new Style({stroke:new Stroke({color:t.color,width:1,lineDash:c})})),this.vectorSource.addFeature(l)}t={color:o,coordinate:r},this.lastPointLive=s}for(const i in e.forecast){const s=e.forecast[i].fore,r=e.forecast[i].obs,o=[];if(s.length>0){if(r&&r.length>0){const l=this.getLastPoint(e,r[0]);o.push([Number(l.longitude),Number(l.latitude)])}s.forEach(l=>{this.drawPoint(this.vectorSource,l,e.baseInfo,e.unit),o.push([Number(l.longitude),Number(l.latitude)])});const a=new Feature({geometry:new LineString(o)});a.setStyle(new Style({stroke:new Stroke({color:e.forecast[i].color,width:2,lineDash:[5]})})),this.vectorSource.addFeature(a)}}return this.drawWindCircle(),this.vectorSource}drawPoint(e,t,i,s){const r=[t.longitude,t.latitude],o=new Feature({geometry:new Point(r)});t.baseInfo=i,t.unit=s,o.set("mark","typhoon"),o.set("data",t);const a=this.typhoonLevel[t.tcRank]?this.typhoonLevel[t.tcRank]:"#ffffff";o.setStyle(new Style({image:new CircleStyle({radius:4,stroke:new Stroke({width:1,color:"#5e5e5e"}),fill:new Fill({color:a})}),zIndex:2})),e.addFeature(o)}drawWindCircle(e){const t=e||this.lastPointLive;this.vectorSource.forEachFeature(s=>{s.getId()!==void 0&&s.getId().includes("typhoon")&&this.vectorSource.removeFeature(s)});const i={rd06:"#00FF00",rd07:"#0000FF",rd08:"#FFFF00",rd10:"#F59A23",rd12:"#FF0000"};for(const s in i)if(t[s]){let r=t[s].split(",").map(Number);const o={x:Number(t.longitude),y:Number(t.latitude),r:{NE:lengthToDegrees(r[0]),SE:lengthToDegrees(r[1]),SW:lengthToDegrees(r[2]),NW:lengthToDegrees(r[3])},interval:2,color:i[s]},a=new WKT;let l="POLYGON((",c="";for(let u=0;u<360/o.interval;u++){let d=0;const g=u*o.interval;g>0&&g<=90?d=o.r.NE:g>90&&g<=180?d=o.r.NW:g>180&&g<=270?d=o.r.SW:d=o.r.SE;const f=o.x+d*Math.cos(g*Math.PI/180),m=o.y+d*Math.sin(g*Math.PI/180);l=l+`${f} ${m},`,u===0&&(c=`${f} ${m}`)}l=l+c+"))";const h=a.readFeature(l);h.setId(`typhoon_${s}`),h.setStyle(new Style({stroke:new Stroke({color:o.color})})),this.vectorSource.addFeature(h)}}getLastPoint(e,t){let i=e.live[0];return e.live.forEach(s=>{if(new Date(t.ddateTime).getTime()>=new Date(s.ddateTime).getTime())i=s;else return}),i}}const Property={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class Overlay extends BaseObject{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=e.insertFirst!==void 0?e.insertFirst:!0,this.stopEvent=e.stopEvent!==void 0?e.stopEvent:!0,this.element=document.createElement("div"),this.element.className=e.className!==void 0?e.className:"ol-overlay-container "+CLASS_SELECTABLE,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=e.autoPan===!0?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(Property.ELEMENT,this.handleElementChanged),this.addChangeListener(Property.MAP,this.handleMapChanged),this.addChangeListener(Property.OFFSET,this.handleOffsetChanged),this.addChangeListener(Property.POSITION,this.handlePositionChanged),this.addChangeListener(Property.POSITIONING,this.handlePositioningChanged),e.element!==void 0&&this.setElement(e.element),this.setOffset(e.offset!==void 0?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),e.position!==void 0&&this.setPosition(e.position)}getElement(){return this.get(Property.ELEMENT)}getId(){return this.id}getMap(){return this.get(Property.MAP)||null}getOffset(){return this.get(Property.OFFSET)}getPosition(){return this.get(Property.POSITION)}getPositioning(){return this.get(Property.POSITIONING)}handleElementChanged(){removeChildren(this.element);const e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){var t;this.mapPostrenderListenerKey&&((t=this.element)==null||t.remove(),unlistenByKey(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const e=this.getMap();if(e){this.mapPostrenderListenerKey=listen(e,MapEventType.POSTRENDER,this.render,this),this.updatePixelPosition();const i=this.stopEvent?e.getOverlayContainerStopEvent():e.getOverlayContainer();this.insertFirst?i.insertBefore(this.element,i.childNodes[0]||null):i.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(Property.ELEMENT,e)}setMap(e){this.set(Property.MAP,e)}setOffset(e){this.set(Property.OFFSET,e)}setPosition(e){this.set(Property.POSITION,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(Property.POSITION))return;const i=this.getRect(t.getTargetElement(),t.getSize()),s=this.getElement(),r=this.getRect(s,[outerWidth(s),outerHeight(s)]);e=e||{};const o=e.margin===void 0?20:e.margin;if(!containsExtent(i,r)){const a=r[0]-i[0],l=i[2]-r[2],c=r[1]-i[1],h=i[3]-r[3],u=[0,0];if(a<0?u[0]=a-o:l<0&&(u[0]=Math.abs(l)+o),c<0?u[1]=c-o:h<0&&(u[1]=Math.abs(h)+o),u[0]!==0||u[1]!==0){const d=t.getView().getCenterInternal(),g=t.getPixelFromCoordinateInternal(d);if(!g)return;const f=[g[0]+u[0],g[1]+u[1]],m=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(f),duration:m.duration,easing:m.easing})}}}getRect(e,t){const i=e.getBoundingClientRect(),s=i.left+window.pageXOffset,r=i.top+window.pageYOffset;return[s,r,s+t[0],r+t[1]]}setPositioning(e){this.set(Property.POSITIONING,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){const e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t){this.setVisible(!1);return}const i=e.getPixelFromCoordinate(t),s=e.getSize();this.updateRenderedPosition(i,s)}updateRenderedPosition(e,t){const i=this.element.style,s=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=`${e[0]+s[0]}px`,a=`${e[1]+s[1]}px`;let l="0%",c="0%";r=="bottom-right"||r=="center-right"||r=="top-right"?l="-100%":(r=="bottom-center"||r=="center-center"||r=="top-center")&&(l="-50%"),r=="bottom-left"||r=="bottom-center"||r=="bottom-right"?c="-100%":(r=="center-left"||r=="center-center"||r=="center-right")&&(c="-50%");const h=`translate(${l}, ${c}) translate(${o}, ${a})`;this.rendered.transform_!=h&&(this.rendered.transform_=h,i.transform=h)}getOptions(){return this.options}}const _hoisted_1={id:"map",class:"map"},transparentTile="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",_sfc_main=vue.defineComponent({__name:"VueOl",props:{options:{}},emits:["olMap"],setup(__props,{emit:__emit}){const emits=__emit,props=__props,layers=[],options={target:"map",layers,view:new View(props.options.view),controls:defaults$1({rotate:!1,zoom:!1,...props.options.controls})};let map;const typhoonList={},typhoonMarks={},pendingImageStaticUrls=new WeakMap,addLayer=n=>{let e=getLayer(n);return e&&e.set("id",n.id),e},updateLayer=(n,e,t)=>{const s=map.getLayers().getArray().find(r=>r.get("id")===n);switch(e){case"xyz":updateXYZLayer(s,t,n);break;case"imageStatic":updateImageStaticLayer(s,t,n);break;case"point":updatePointLayer(s,t);break;case"typhoon":updateTyphoonLayer(s,t,n);break;default:console.error(`未定义类型(${e}),请使用原生ol实现!`);break}},updateXYZLayer=(n,e,t)=>{updated(n,e,t,["extent","map","maxResolution","maxZoom","minResolution","minZoom","opacity","preload","properties","source","useInterimTilesOnError","visible","zIndex"],["attributions","properties","renderReprojectionEdges","tileGridForProjection","tileUrlFunction","url"])},updateImageStaticUrl=(n,e,t)=>{var a;const i=!!(e!=null&&e.useInterimTilesWhenMissing),s=n.getSource(),r=!!(s&&typeof s.setUrl=="function");if(pendingImageStaticUrls.delete(n),!t){i&&n.setSource(null);return}if(!e)return;pendingImageStaticUrls.set(n,t);const o=document.createElement("img");((a=e.source)==null?void 0:a.crossOrigin)!==void 0&&(o.crossOrigin=e.source.crossOrigin),o.onload=()=>{pendingImageStaticUrls.get(n)===t&&(r&&n.getSource()===s?s.setUrl(t):n.setSource(getSource(e)),pendingImageStaticUrls.delete(n))},o.onerror=()=>{pendingImageStaticUrls.get(n)===t&&(i&&n.setSource(null),pendingImageStaticUrls.delete(n))},o.src=t},updateImageStaticLayer=(n,e,t)=>{let i=e;if(Object.prototype.hasOwnProperty.call(e.source??{},"url")){const o=props.options.layers.find(l=>l.id===t);updateImageStaticUrl(n,o,e.source.url);const a={...e.source};delete a.url,i={...e,source:a},Object.keys(i.source).length===0&&delete i.source}updated(n,i,t,["extent","map","maxResolution","maxZoom","minResolution","minZoom","opacity","properties","source","visible","zIndex"],["attributions","properties","url"])},updatePointLayer=(layer,info)=>{const layerEffectiveFields=["declutter","extent","map","maxResolution","maxZoom","minResolution","minZoom","opacity","properties","source","style","visible","zIndex"],source=layer.getSource();for(const key in info)if(key==="add"){const n=[];info[key].length>0&&(info[key].forEach(e=>{const t=new Feature;t.setGeometry(new Point([e.lng,e.lat]));const i={...e};delete i.style,t.set("data",i),t.setId(e.id),e.style&&t.setStyle(getStyle(e.style,e)),n.push(t)}),source.addFeatures(n))}else if(key==="update"){if(info[key].length>0){const n=[],e=[];info[key].forEach(t=>{const i=new Feature;i.setGeometry(new Point([t.lng,t.lat])),i.set("data",t),i.setId(t.id),t.style&&i.setStyle(getStyle(t.style,t)),n.push(source.getFeatureById(t.id)),e.push(i)}),source.removeFeatures(n),source.addFeatures(e)}}else if(key==="delete"){const n=[];info[key].length>0&&info[key].forEach(e=>{n.push(source.getFeatureById(e.id))}),source.removeFeatures(n)}else if(key==="style"){const n=typeof info[key]=="function"?info[key]:getStyle(info[key]);layer.setStyle(n)}else layerEffectiveFields.includes(key)&&eval(`layer.set${capitalize(key)}(info[key])`)},updateTyphoonLayer=(n,e,t)=>{const i=["extent","layers","maxResolution","maxZoom","minResolution","minZoom","opacity","properties","visible","zIndex"];if(e.visible!==void 0){const s=props.options.layers.findIndex(o=>o.id===t),r=props.options.layers[s].data.baseInfo.tsId;for(const o in typhoonMarks)if(o.includes(r))if(e.visible){const a=typhoonMarks[o].nameOverlay.get("lnglat"),l=typhoonMarks[o].lastPointOverlay.get("lnglat");typhoonMarks[o].nameOverlay.setPosition(a),typhoonMarks[o].lastPointOverlay.setPosition(l)}else typhoonMarks[o].nameOverlay.setPosition(void 0),typhoonMarks[o].lastPointOverlay.setPosition(void 0)}updated(n,e,t,i,[])},updated=(layer,info,id,layerEffectiveFields,sourceEffectiveFields)=>{for(const key in info)if(key==="source")if(Object.keys(info.source).every(t=>sourceEffectiveFields.includes(t))){const t=layer.getSource();if(t)for(const i in info.source){const s=t[`set${capitalize(i)}`];typeof s=="function"&&s.call(t,info.source[i])}}else{const t=props.options.layers.findIndex(i=>i.id===id);layer.setSource(null),setTimeout(()=>{const i=getSource(props.options.layers[t]);layer.setSource(i)})}else layerEffectiveFields.includes(key)&&eval(`layer.set${capitalize(key)}(info[key])`)},getLayer=n=>{switch(n.type){case"xyz":return getXYZLayer(n);case"imageStatic":return getImageStaticLayer(n);case"point":return getPointLayer(n);case"typhoon":return getTypeoonLayer(n);default:console.error(`layer config error;id:${n.id}`);break}},getXYZLayer=n=>{const e=getSource(n);return new TileLayer({...n,source:e})},getImageStaticLayer=n=>{const e=getSource(n),t={...n,source:e};return new ImageLayer(t)},getPointLayer=n=>{const e={...n};delete e.data,delete e.style;const t=new VectorLayer({...e,source:getPointSource(n)});if(n.style){const i=typeof n.style=="function"?n.style:getStyle(n.style);t.setStyle(i)}return t},getTypeoonLayer=n=>{const e=[],t=[];if(n.data.mainPath){const r=n.data.data[n.data.mainPath],o={};o.live=[...r.obs].reverse(),o.forecast=n.data.data,o.baseInfo=n.data.baseInfo,o.unit=n.data.mainPath,e.push(o)}else for(const r in n.data.data){const o={};o.live=[...n.data.data[r].obs].reverse(),o.baseInfo=n.data.baseInfo,o.forecast={},o.forecast[r]=n.data.data[r],o.unit=r,e.push(o)}e.forEach(r=>{if(r.live.length===0)return;const o=new Typhoon,a=n.data.baseInfo.tsId+"_"+r.unit;typhoonList[a]=o;const l=new VectorLayer({source:o.createTrack(r)});if(t.push(l),typhoonMarks[a]||(typhoonMarks[a]={}),n.data.baseInfo.tseName){const h=r.live[0],u=document.createElement("div");u.innerHTML=`<span style="font-weight:bold;font-size:14px">${n.data.baseInfo.tscName}${n.data.baseInfo.tseName}</span>`;let d;(n.visible===void 0||n.visible)&&(d=[h.longitude,h.latitude]);const g=new Overlay({position:d,element:u,positioning:"bottom-center",offset:[0,-10],stopEvent:!1});g.set("lnglat",[h.longitude,h.latitude]),map.addOverlay(g),typhoonMarks[a].nameOverlay=g}const c=r.live[r.live.length-1];if(c.tcRank!==""){const h=new URL(Object.assign({"../assets/images/typhoon-STS.png":__vite_glob_0_0,"../assets/images/typhoon-STY.png":__vite_glob_0_1,"../assets/images/typhoon-SUPERTY.png":__vite_glob_0_2,"../assets/images/typhoon-TD.png":__vite_glob_0_3,"../assets/images/typhoon-TS.png":__vite_glob_0_4,"../assets/images/typhoon-TY.png":__vite_glob_0_5})[`../assets/images/typhoon-${c.tcRank}.png`],typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:_documentCurrentScript&&_documentCurrentScript.tagName.toUpperCase()==="SCRIPT"&&_documentCurrentScript.src||new URL("runbir-tools.umd.js",document.baseURI).href).href,u=document.createElement("div");u.innerHTML=`<img src="${h}" style="width:30px;height: 30px;animation: rotate 2s infinite;"/>`;let d;(n.visible===void 0||n.visible)&&(d=[c.longitude,c.latitude]);const g=new Overlay({position:d,element:u,positioning:"center-center",stopEvent:!1});g.set("lnglat",[c.longitude,c.latitude]),map.addOverlay(g),typhoonMarks[a].lastPointOverlay=g}});const i={...n};return delete i.data,new LayerGroup({...i,layers:t})},getSource=n=>{switch(n.type){case"xyz":{const e={...n.source};return n.useInterimTilesWhenMissing&&(e.transition=0,e.tileLoadFunction=(t,i)=>{const s=t.getImage(),r=document.createElement("img");e.crossOrigin!==void 0&&(r.crossOrigin=e.crossOrigin),r.onload=()=>{s.src=i},r.onerror=()=>{s.src=transparentTile},r.src=i}),new XYZ(e)}case"imageStatic":{const e={...n.source};return n.useInterimTilesWhenMissing&&(e.imageLoadFunction=(t,i)=>{const s=t.getImage();if(!i){s.src=transparentTile;return}const r=document.createElement("img");e.crossOrigin!==void 0&&(r.crossOrigin=e.crossOrigin),r.onload=()=>{s.src=i},r.onerror=()=>{s.src=transparentTile},r.src=i}),new Static(e)}case"point":return getPointSource(n);default:console.error(`layer config error;id:${n.id}`);break}},getPointSource=n=>{const e=[];return n.data.forEach(t=>{const i=new Feature;i.setGeometry(new Point([t.lng,t.lat])),i.set("data",t),i.setId(t.id),t.style&&i.setStyle(getStyle(t.style,t)),e.push(i)}),new VectorSource({...n.source,features:e})},getStyle=(n,e)=>{const t={...n};if(n.image){let i;switch(n.image.type){case"circle":{i=new CircleStyle({...n.image,fill:new Fill({...n.image.fill}),stroke:new Stroke({...n.image.stroke})});break}case"icon":i=new Icon({...n.image});break;case"regularShape":{i=new RegularShape({...n.image,fill:new Fill({...n.image.fill}),stroke:new Stroke({...n.image.stroke})});break}case"windBarb":{const s=n.image.size||[12,24],o=new WindBarb(s[0]).getIconOfCanvas(e.winds),a=parseFloat(e.windd)*Math.PI/180;i=new Icon({img:o,size:s,anchor:[2,1],anchorXUnits:"pixels",rotation:a,color:getColor(e.winds),...n.image});break}default:console.error("暂不支持此图标类型,请自行原生处理。");break}t.image=i}if(n.text){const i=new Text({...n.text,text:e.text});t.text=i}return new Style(t)};props.options.layers.forEach(n=>{const e=addLayer(n);e&&layers.push(e)});function capitalize(n){return n.charAt(0).toUpperCase()+n.slice(1)}const cloneDeepKeepFunction=n=>{if(Array.isArray(n))return n.map(e=>cloneDeepKeepFunction(e));if(n&&typeof n=="object"){const e={};return Object.keys(n).forEach(t=>{e[t]=cloneDeepKeepFunction(n[t])}),e}return n},isEqualWithFunction=(n,e)=>{if(typeof n=="function"||typeof e=="function")return typeof n!="function"||typeof e!="function"?!1:n===e||n.toString()===e.toString();if(n===e)return!0;if(Array.isArray(n)&&Array.isArray(e))return n.length!==e.length?!1:n.every((t,i)=>isEqualWithFunction(t,e[i]));if(n&&e&&typeof n=="object"&&typeof e=="object"){const t=Object.keys(n),i=Object.keys(e);return t.length!==i.length?!1:t.every(s=>isEqualWithFunction(n[s],e[s]))}return!1};function getColor(n){return n<10.8?"#404040":n<13.9?"#008000":n<17.2?"#0000ff":n<24.5?"#ff7d00":"#ff0000"}let typhoonPoint;const handlePointermove=n=>{let e=!1;if(map.forEachFeatureAtPixel(n.pixel,t=>{t.get("mark")&&(typhoonPoint=t.get("data"),e=!0)}),e){const t=typhoonPoint.baseInfo.tsId+"_"+typhoonPoint.unit;typhoonList[t].drawWindCircle(typhoonPoint)}else if(typhoonPoint){const t=typhoonPoint.baseInfo.tsId+"_"+typhoonPoint.unit;typhoonList[t].drawWindCircle(),typhoonPoint=void 0}};vue.onMounted(()=>{map=new Map(options);const n=new Set;props.options.event&&props.options.event.register.forEach(e=>{n.add(e)}),n.add("pointermove"),map.on([...n],e=>{switch(props.options.event&&props.options.event.register.includes(e.type)&&props.options.event.callback(e),e.type){case"pointermove":handlePointermove(e);break}}),emits("olMap",map)}),vue.watch(()=>props.options.view.center,n=>{map.getView().setCenter(n)}),vue.watch(()=>props.options.view.constrainResolution,n=>{n&&map.getView().setConstrainResolution(n)}),vue.watch(()=>props.options.view.maxZoom,n=>{n&&map.getView().setMaxZoom(n)}),vue.watch(()=>props.options.view.minZoom,n=>{n&&map.getView().setMinZoom(n)}),vue.watch(()=>props.options.view.resolution,n=>{n&&map.getView().setResolution(n)}),vue.watch(()=>props.options.view.rotation,n=>{n&&map.getView().setRotation(n)}),vue.watch(()=>props.options.view.zoom,n=>{n&&map.getView().setZoom(n)}),vue.watch(()=>props.options.view,n=>{map.setView(new View(n))});let previousLayersSnapshot=cloneDeepKeepFunction(props.options.layers);return vue.watch(()=>props.options.layers,n=>{if(!map){previousLayersSnapshot=cloneDeepKeepFunction(n);return}const e=previousLayersSnapshot;n.forEach(t=>{const i=e.findIndex(s=>s.id===t.id);if(i>-1){const s={};for(const r in t)if(!isEqualWithFunction(t[r],e[i][r]))if(r==="source"){const o={};for(const a in t[r])isEqualWithFunction(t[r][a],e[i][r][a])||(o[a]=t[r][a]);s[r]=o}else t.type==="point"&&r==="data"?(s.add=[],s.update=[],s.delete=[],t[r].forEach(o=>{const a=e[i][r].findIndex(l=>l.id===o.id);a<0?s.add.push(o):isEqualWithFunction(o,e[i][r][a])||s.update.push(o)}),e[i][r].forEach(o=>{t[r].find(l=>l.id===o.id)||s.delete.push(o)})):s[r]=t[r];Object.keys(s).length>0&&updateLayer(t.id,t.type,s)}else{const s=addLayer(t);map.addLayer(s)}}),e.forEach(t=>{if(n.findIndex(s=>s.id===t.id)<0){const s=map.getLayers(),r=s.getArray().find(o=>o.get("id")===t.id);if(r&&s.remove(r),t.type==="typhoon"){const o=t.data.baseInfo.tsId;for(const a in typhoonMarks)a.includes(o)&&(map.removeOverlay(typhoonMarks[a].nameOverlay),map.removeOverlay(typhoonMarks[a].lastPointOverlay),delete typhoonMarks[a])}}}),previousLayersSnapshot=cloneDeepKeepFunction(n)},{deep:!0}),(n,e)=>(vue.openBlock(),vue.createElementBlock("div",_hoisted_1))}}),_export_sfc=(n,e)=>{const t=n.__vccOpts||n;for(const[i,s]of e)t[i]=s;return t},VueOl=_export_sfc(_sfc_main,[["__scopeId","data-v-df8b758d"]]),plugin={install(n){n.component("VueOl",VueOl)}};exports.VueOl=VueOl,exports.default=plugin,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "runbir-tools",
3
3
  "private": false,
4
- "version": "1.0.20",
4
+ "version": "1.0.21",
5
5
  "type": "module",
6
6
  "main": "./dist/runbir-tools.umd.js",
7
7
  "module": "./dist/runbir-tools.es.js",