UNPKG

wind-layer

Version:

a openlayers ol bmap amap maptalks extension to windjs

2 lines (1 loc) 28 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("ol/layer"),require("ol")):"function"==typeof define&&define.amd?define(["ol/layer","ol"],e):(t=t||self).windLayer=e(t.ol.layer,t.ol)}(this,function(t,e){"use strict";function r(){return function(){throw new Error("Unimplemented abstract method.")}()}var n=0;var o,i,a=(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),c=(i=Error,a(s,i),s);function s(t){var e=this,n="Assertion failed. See https://openlayers.org/en/"+("v"+"6.2.1".split("-")[0])+"/doc/errors/#"+t+" for details.";return(e=i.call(this,n)||this).code=t,e.name="AssertionError",e.message=n,e}function u(t,e,n,r,o){return o?(o[0]=t,o[1]=e,o[2]=n,o[3]=r,o):[t,e,n,r]}function l(t){return[t[0],t[1]]}function h(t){return[t[2],t[1]]}function _(t,e,n){var r=n||[1/0,1/0,-1/0,-1/0];return y(t,e)?(t[0]>e[0]?r[0]=t[0]:r[0]=e[0],t[1]>e[1]?r[1]=t[1]:r[1]=e[1],t[2]<e[2]?r[2]=t[2]:r[2]=e[2],t[3]<e[3]?r[3]=t[3]:r[3]=e[3]):function(t){u(1/0,1/0,-1/0,-1/0,t)}(r),r}function f(t){return[t[0],t[3]]}function d(t){return[t[2],t[3]]}function y(t,e){return t[0]<=e[2]&&t[2]>=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function p(t,e,n){var r=[t[0],t[1],t[0],t[3],t[2],t[1],t[2],t[3]];return e(r,r,2),function(t,e,n){return u(Math.min.apply(null,t),Math.min.apply(null,e),Math.max.apply(null,t),Math.max.apply(null,e),n)}([r[0],r[2],r[4],r[6]],[r[1],r[3],r[5],r[7]],n)}function v(t,e,n){var r=n&&n.length?n.shift():document.createElement("canvas");return t&&(r.width=t),e&&(r.height=e),r.getContext("2d")}var g=(m.prototype.preventDefault=function(){this.propagationStopped=!0},m.prototype.stopPropagation=function(){this.propagationStopped=!0},m);function m(t){this.propagationStopped,this.type=t,this.target=null}var w,E,x=((w=function(t,e){return(w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}w(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)})(M,E=g),M);function M(t,e,n,r){var o=E.call(this,t)||this;return o.inversePixelTransform=e,o.frameState=n,o.context=r,o}var P="prerender",T="postrender",R="function"==typeof Object.assign?Object.assign:function(t,e){var n=arguments;if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(t),o=1,i=arguments.length;o<i;++o){var a=n[o];if(null!=a)for(var s in a)a.hasOwnProperty(s)&&(r[s]=a[s])}return r};var b="propertychange";function A(t,e,n,r,o){if(r&&r!==t&&(n=n.bind(r)),o){var i=n;n=function(){t.removeEventListener(e,n),i.apply(this,arguments)}}var a={target:t,type:e,listener:n};return t.addEventListener(e,n),a}function I(t,e,n,r){return A(t,e,n,r,!0)}var O=(C.prototype.dispose=function(){this.disposed_||(this.disposed_=!0,this.disposeInternal())},C.prototype.disposeInternal=function(){},C);function C(){this.disposed_=!1}function L(){}var S,j,F=((S=function(t,e){return(S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}S(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)})(D,j=O),D.prototype.addEventListener=function(t,e){if(t&&e){var n=this.listeners_[t];n||(n=[],this.listeners_[t]=n),-1===n.indexOf(e)&&n.push(e)}},D.prototype.dispatchEvent=function(t){var e="string"==typeof t?new g(t):t,n=e.type;e.target||(e.target=this.eventTarget_||this);var r,o=this.listeners_[n];if(o){n in this.dispatching_||(this.dispatching_[n]=0,this.pendingRemovals_[n]=0),++this.dispatching_[n];for(var i=0,a=o.length;i<a;++i)if(!1===o[i].call(this,e)||e.propagationStopped){r=!1;break}if(--this.dispatching_[n],0===this.dispatching_[n]){var s=this.pendingRemovals_[n];for(delete this.pendingRemovals_[n];s--;)this.removeEventListener(n,L);delete this.dispatching_[n]}return r}},D.prototype.disposeInternal=function(){!function(t){for(var e in t)delete t[e]}(this.listeners_)},D.prototype.getListeners=function(t){return this.listeners_[t]},D.prototype.hasListener=function(t){return t?t in this.listeners_:0<Object.keys(this.listeners_).length},D.prototype.removeEventListener=function(t,e){var n=this.listeners_[t];if(n){var r=n.indexOf(e);-1!==r&&(t in this.pendingRemovals_?(n[r]=L,++this.pendingRemovals_[t]):(n.splice(r,1),0===n.length&&delete this.listeners_[t]))}},D);function D(t){var e=j.call(this)||this;return e.eventTarget_=t,e.pendingRemovals_={},e.dispatching_={},e.listeners_={},e}var G,N,V="change",W=((G=function(t,e){return(G=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}G(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)})(X,N=F),X.prototype.changed=function(){++this.revision_,this.dispatchEvent(V)},X.prototype.getRevision=function(){return this.revision_},X.prototype.on=function(t,e){if(Array.isArray(t)){for(var n=t.length,r=new Array(n),o=0;o<n;++o)r[o]=A(this,t[o],e);return r}return A(this,t,e)},X.prototype.once=function(t,e){if(Array.isArray(t)){for(var n=t.length,r=new Array(n),o=0;o<n;++o)r[o]=I(this,t[o],e);return r}return I(this,t,e)},X.prototype.un=function(t,e){if(Array.isArray(t))for(var n=0,r=t.length;n<r;++n)this.removeEventListener(t[n],e);else this.removeEventListener(t,e)},X);function X(){var t=N.call(this)||this;return t.revision_=0,t}var U,k,q=(U=function(t,e){return(U=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}U(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),z=(q(Y,k=g),Y);function Y(t,e,n){var r=k.call(this,t)||this;return r.key=e,r.oldValue=n,r}var H,K=(q($,H=W),$.prototype.get=function(t){var e;return this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e},$.prototype.getKeys=function(){return Object.keys(this.values_)},$.prototype.getProperties=function(){return R({},this.values_)},$.prototype.notify=function(t,e){var n;n=function(t){return B.hasOwnProperty(t)?B[t]:B[t]="change:"+t}(t),this.dispatchEvent(new z(n,t,e)),n=b,this.dispatchEvent(new z(n,t,e))},$.prototype.set=function(t,e,n){if(n)this.values_[t]=e;else{var r=this.values_[t];r!==(this.values_[t]=e)&&this.notify(t,r)}},$.prototype.setProperties=function(t,e){for(var n in t)this.set(n,t[n],e)},$.prototype.unset=function(t,e){if(t in this.values_){var n=this.values_[t];delete this.values_[t],e||this.notify(t,n)}},$);function $(t){var e=H.call(this)||this;return function(t){t.ol_uid||(t.ol_uid=String(++n))}(e),e.values_={},void 0!==t&&e.setProperties(t),e}var B={};new K;function J(t,e,n,r){0!==e&&(t.translate(n,r),t.rotate(e),t.translate(-n,-r))}(new F).setSize=function(){console.warn("labelCache is deprecated.")};var Q,Z,tt=0,et=2,nt=3,rt="ready",ot=((Q=function(t,e){return(Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}Q(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)})(it,Z=W),it.prototype.getFeatures=function(t){return r()},it.prototype.prepareFrame=function(t){return r()},it.prototype.renderFrame=function(t,e){return r()},it.prototype.loadedTileCallback=function(t,e,n){t[e]||(t[e]={}),t[e][n.tileCoord.toString()]=n},it.prototype.createLoadedTileFinder=function(r,o,i){return function(t,e){var n=this.loadedTileCallback.bind(this,i,t);return r.forEachLoadedTile(o,t,e,n)}.bind(this)},it.prototype.forEachFeatureAtCoordinate=function(t,e,n,r,o){},it.prototype.getDataAtPixel=function(t,e,n){return r()},it.prototype.getLayer=function(){return this.layer_},it.prototype.handleFontsChanged=function(){},it.prototype.handleImageChange_=function(t){t.target.getState()===et&&this.renderIfReadyAndVisible()},it.prototype.loadImage=function(t){var e=t.getState();return e!=et&&e!=nt&&t.addEventListener(V,this.boundHandleImageChange_),e==tt&&(t.load(),e=t.getState()),e==et},it.prototype.renderIfReadyAndVisible=function(){var t=this.getLayer();t.getVisible()&&t.getSourceState()==rt&&t.changed()},it);function it(t){var e=Z.call(this)||this;return e.boundHandleImageChange_=e.handleImageChange_.bind(e),e.layer_=t,e}function at(t,e){var n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function st(t,e,n,r,o,i,a,s){var u=Math.sin(i),c=Math.cos(i);return t[0]=r*c,t[1]=o*u,t[2]=-r*u,t[3]=o*c,t[4]=a*r*c-s*r*u+e,t[5]=a*o*u+s*o*c+n,t}function ut(t,e){var n=function(t){return t[0]*t[3]-t[1]*t[2]}(e);!function(t,e){if(!t)throw new c(e)}(0!==n,32);var r=e[0],o=e[1],i=e[2],a=e[3],s=e[4],u=e[5];return t[0]=a/n,t[1]=-o/n,t[2]=-i/n,t[3]=r/n,t[4]=(i*u-a*s)/n,t[5]=-(r*u-o*s)/n,t}var ct,pt,lt=((ct=function(t,e){return(ct=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}ct(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)})(ht,pt=ot),ht.prototype.useContainer=function(t,e,n){var r,o,i=this.getLayer().getClassName();if(t&&""===t.style.opacity&&t.className===i&&(s=t.firstElementChild)instanceof HTMLCanvasElement&&(o=s.getContext("2d")),o&&o.canvas.style.transform===e?(this.container=t,this.context=o,this.containerReused=!0):this.containerReused&&(this.container=null,this.context=null,this.containerReused=!1),!this.container){(r=document.createElement("div")).className=i;var a=r.style;a.position="absolute",a.width="100%",a.height="100%";var s=(o=v()).canvas;r.appendChild(s),(a=s.style).position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}},ht.prototype.clip=function(t,e,n){var r=e.pixelRatio,o=e.size[0]*r/2,i=e.size[1]*r/2,a=e.viewState.rotation,s=f(n),u=d(n),c=h(n),p=l(n);at(e.coordinateToPixelTransform,s),at(e.coordinateToPixelTransform,u),at(e.coordinateToPixelTransform,c),at(e.coordinateToPixelTransform,p),t.save(),J(t,-a,o,i),t.beginPath(),t.moveTo(s[0]*r,s[1]*r),t.lineTo(u[0]*r,u[1]*r),t.lineTo(c[0]*r,c[1]*r),t.lineTo(p[0]*r,p[1]*r),t.clip(),J(t,a,o,i)},ht.prototype.clipUnrotated=function(t,e,n){var r=f(n),o=d(n),i=h(n),a=l(n);at(e.coordinateToPixelTransform,r),at(e.coordinateToPixelTransform,o),at(e.coordinateToPixelTransform,i),at(e.coordinateToPixelTransform,a);var s=this.inversePixelTransform;at(s,r),at(s,o),at(s,i),at(s,a),t.save(),t.beginPath(),t.moveTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.lineTo(Math.round(i[0]),Math.round(i[1])),t.lineTo(Math.round(a[0]),Math.round(a[1])),t.clip()},ht.prototype.dispatchRenderEvent_=function(t,e,n){var r=this.getLayer();if(r.hasListener(t)){var o=new x(t,this.inversePixelTransform,n,e);r.dispatchEvent(o)}},ht.prototype.preRender=function(t,e){this.dispatchRenderEvent_(P,t,e)},ht.prototype.postRender=function(t,e){this.dispatchRenderEvent_(T,t,e)},ht.prototype.getRenderTransform=function(t,e,n,r,o,i,a){var s=o/2,u=i/2,c=r/e,p=-c,l=-t[0]+a,h=-t[1];return st(this.tempTransform_,s,u,c,p,-n,l,h)},ht.prototype.getDataAtPixel=function(t,e,n){var r,o=at(this.inversePixelTransform,t.slice()),i=this.context;try{r=i.getImageData(Math.round(o[0]),Math.round(o[1]),1,1).data}catch(t){return"SecurityError"===t.name?new Uint8Array:r}return 0===r[3]?null:r},ht.prototype.createTransformString=function(t){return this.createTransformStringCanvas_.style.transform=function(t){return"matrix("+t.join(", ")+")"}(t),this.createTransformStringCanvas_.style.transform},ht);function ht(t){var e=pt.call(this,t)||this;return e.container=null,e.renderedResolution,e.tempTransform_=[1,0,0,1,0,0],e.pixelTransform=[1,0,0,1,0,0],e.inversePixelTransform=[1,0,0,1,0,0],e.context=null,e.containerReused=!1,e.createTransformStringCanvas_=v(1,1).canvas,e}var ft="cosh"in Math?Math.cosh:function(t){var e=Math.exp(t);return(e+1/e)/2},dt="degrees",vt="ft",yt="m",gt="us-ft",_t={};_t[dt]=2*Math.PI*6370997/360,_t[vt]=.3048,_t[yt]=1,_t[gt]=1200/3937;var mt=(wt.prototype.canWrapX=function(){return this.canWrapX_},wt.prototype.getCode=function(){return this.code_},wt.prototype.getExtent=function(){return this.extent_},wt.prototype.getUnits=function(){return this.units_},wt.prototype.getMetersPerUnit=function(){return this.metersPerUnit_||_t[this.units_]},wt.prototype.getWorldExtent=function(){return this.worldExtent_},wt.prototype.getAxisOrientation=function(){return this.axisOrientation_},wt.prototype.isGlobal=function(){return this.global_},wt.prototype.setGlobal=function(t){this.global_=t,this.canWrapX_=!(!t||!this.extent_)},wt.prototype.getDefaultTileGrid=function(){return this.defaultTileGrid_},wt.prototype.setDefaultTileGrid=function(t){this.defaultTileGrid_=t},wt.prototype.setExtent=function(t){this.extent_=t,this.canWrapX_=!(!this.global_||!t)},wt.prototype.setWorldExtent=function(t){this.worldExtent_=t},wt.prototype.setGetPointResolution=function(t){this.getPointResolutionFunc_=t},wt.prototype.getPointResolutionFunc=function(){return this.getPointResolutionFunc_},wt);function wt(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}var Et,xt,Mt=(Et=function(t,e){return(Et=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}Et(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),Pt=6378137,Tt=Math.PI*Pt,Rt=[-Tt,-Tt,Tt,Tt],bt=[-180,-85,180,85],At=(Mt(It,xt=mt),It);function It(t){return xt.call(this,{code:t,units:yt,extent:Rt,global:!0,worldExtent:bt,getPointResolution:function(t,e){return t/ft(e[1]/Pt)}})||this}var Ot=[new At("EPSG:3857"),new At("EPSG:102100"),new At("EPSG:102113"),new At("EPSG:900913"),new At("urn:ogc:def:crs:EPSG:6.18:3:3857"),new At("urn:ogc:def:crs:EPSG::3857"),new At("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Ct(t,e,n){var r=t.length,o=1<n?n:2,i=e;void 0===i&&(i=2<o?t.slice():new Array(r));for(var a=Tt,s=0;s<r;s+=o){i[s]=a*t[s]/180;var u=Pt*Math.log(Math.tan(Math.PI*(+t[s+1]+90)/360));a<u?u=a:u<-a&&(u=-a),i[s+1]=u}return i}function Lt(t,e,n){var r=t.length,o=1<n?n:2,i=e;void 0===i&&(i=2<o?t.slice():new Array(r));for(var a=0;a<r;a+=o)i[a]=180*t[a]/Tt,i[a+1]=360*Math.atan(Math.exp(t[a+1]/Pt))/Math.PI-90;return i}var St,jt,Ft=(St=function(t,e){return(St=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}St(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),Dt=[-180,-90,180,90],Gt=6378137*Math.PI/180,Nt=(Ft(Vt,jt=mt),Vt);function Vt(t,e){return jt.call(this,{code:t,units:dt,extent:Dt,axisOrientation:e,global:!0,metersPerUnit:Gt,worldExtent:Dt})||this}var Wt=[new Nt("CRS:84"),new Nt("EPSG:4326","neu"),new Nt("urn:ogc:def:crs:EPSG::4326","neu"),new Nt("urn:ogc:def:crs:EPSG:6.6:4326","neu"),new Nt("urn:ogc:def:crs:OGC:1.3:CRS84"),new Nt("urn:ogc:def:crs:OGC:2:84"),new Nt("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Nt("urn:x-ogc:def:crs:EPSG:4326","neu")],Xt={};function Ut(t,e,n){var r=t.getCode(),o=e.getCode();r in Xt||(Xt[r]={}),Xt[r][o]=n}var kt={};function qt(t,e,n){var r;if(void 0!==e){for(var o=0,i=t.length;o<i;++o)e[o]=t[o];r=e}else r=t.slice();return r}function zt(t,e,n){if(void 0!==e&&t!==e){for(var r=0,o=t.length;r<o;++r)e[r]=t[r];t=e}return t}function Yt(t){!function(t,e){kt[t]=e}(t.getCode(),t),Ut(t,t,qt)}function Ht(t){return"string"==typeof t?function(t){return kt[t]||null}(t):t||null}function Kt(t){!function(t){t.forEach(Yt)}(t),t.forEach(function(e){t.forEach(function(t){e!==t&&Ut(e,t,qt)})})}function $t(t,e){var n=function(t,e){var n;return t in Xt&&e in Xt[t]&&(n=Xt[t][e]),n}(t.getCode(),e.getCode());return n||(n=zt),n}function Bt(t,e,n){return p(t,function(t,e){return $t(Ht(t),Ht(e))}(e,n))}var Jt,Qt,Zt;function te(t){return t}Kt(Ot),Kt(Wt),Jt=Ot,Qt=Ct,Zt=Lt,Wt.forEach(function(e){Jt.forEach(function(t){Ut(e,t,Qt),Ut(t,e,Zt)})});function ee(l){void 0===l&&(l={}),this.params=l;var f=this;function e(t){t.projection||(t.projection="EPSG:4326"),f.MIN_VELOCITY_INTENSITY=t.minVelocity||0,f.MAX_VELOCITY_INTENSITY=t.maxVelocity||10,f.VELOCITY_SCALE=(t.velocityScale||.005)*(Math.pow(window.devicePixelRatio,1/3)||1),f.MAX_PARTICLE_AGE=t.particleAge||90,f.PARTICLE_LINE_WIDTH=t.lineWidth||1,f.PARTICLE_MULTIPLIER=t.particleMultiplier||1/300,f.PARTICLE_REDUCTION=Math.pow(window.devicePixelRatio,1/3)||1.6,f.FRAME_RATE=t.frameRate||16,f.COLOR_SCALE=t.colorScale||n,f.DEVICEPIXELRATIO=t.devicePixelRatio||1}f.canvas=l.canvas;var n=["rgb(36,104, 180)","rgb(60,157, 194)","rgb(128,205,193 )","rgb(151,218,168 )","rgb(198,231,181)","rgb(238,247,217)","rgb(255,238,159)","rgb(252,217,125)","rgb(255,182,100)","rgb(252,150,75)","rgb(250,112,52)","rgb(245,64,32)","rgb(237,45,28)","rgb(220,24,32)","rgb(180,0,35)"];function o(t,e,n,r,o,i){var a=1-t,s=1-e,u=a*s,c=t*s,p=a*e,l=t*e,h=n[0]*u+r[0]*c+o[0]*p+i[0]*l,f=n[1]*u+r[1]*c+o[1]*p+i[1]*l;return[h,f,Math.sqrt(h*h+f*f)]}function u(t){var e=null,n=null;return t.forEach(function(t){switch(t.header.parameterCategory+","+t.header.parameterNumber){case"1,2":case"2,2":e=t;break;case"1,3":case"2,3":n=t}}),function(t,e){var n=t.data,r=e.data;return{header:t.header,data:function(t){return[n[t],r[t]]},interpolate:o}}(e,n)}function i(r,o,t){function i(t,e){var n=r[Math.round(t)];return n&&n[Math.round(e)]||a}i.release=function(){r=[]},i.randomize=function(t){for(var e,n,r=0;null===i(e=Math.round(Math.floor(Math.random()*o.width)+o.x),n=Math.round(Math.floor(Math.random()*o.height)+o.y))[2]&&r++<30;);return t.x=e,t.y=n,t},t(o,i)}function c(t){return t/180*Math.PI}function p(t){return t/(Math.PI/180)}e(l),window.FRAME_TIME=1e3/f.FRAME_RATE;var d,v,h,y,g,_,m,w,E,P,a=[NaN,NaN,null],s=f.params.data,x=function(t,e){if(!v)return null;var n,r=T(t-y,360)/_,o=(g-e)/m,i=Math.floor(r),a=i+1,s=Math.floor(o),u=s+1;if(n=v[s]){var c=n[i],p=n[a];if(M(c)&&M(p)&&(n=v[u])){var l=n[i],h=n[a];if(M(l)&&M(h))return d.interpolate(r-i,o-s,c,p,l,h)}}return null},M=function(t){return null!=t},T=function(t,e){return t-e*Math.floor(t/e)},R=function(t,e,n,r,o,i){var a=2*Math.PI,s="EPSG:4326"===f.params.projection?5:Math.pow(10,-5.2),u=e<0?s:-s,c=n<0?s:-s,p=O(n,e+u,i),l=O(n+c,e,i),h=Math.cos(n/360*a);return[(p[0]-r)/u/h,(p[1]-o)/u/h,(l[0]-r)/c,(l[1]-o)/c]};function b(t){return Math.log(Math.tan(t/2+Math.PI/4))}function A(r,s){var e,n,u=(e=f.MIN_VELOCITY_INTENSITY,n=f.MAX_VELOCITY_INTENSITY,f.COLOR_SCALE.indexFor=function(t){return Math.max(0,Math.min(f.COLOR_SCALE.length-1,Math.round((t-e)/(n-e)*(f.COLOR_SCALE.length-1))))},f.COLOR_SCALE),c=u.map(function(){return[]}),t=Math.round(r.width*r.height*f.PARTICLE_MULTIPLIER);/android|blackberry|iemobile|ipad|iphone|ipod|opera mini|webos/i.test(navigator.userAgent)&&(t*=f.PARTICLE_REDUCTION);for(var o=[],i=0;i<t;i++)o.push(s.randomize({age:Math.floor(Math.random()*f.MAX_PARTICLE_AGE)+0}));var a=f.canvas.getContext("2d");a.lineWidth=f.PARTICLE_LINE_WIDTH,a.fillStyle="rgba(0, 0, 0, 0.97)",a.globalAlpha=.6;var p=Date.now();!function t(){I=requestAnimationFrame(t);var e=Date.now(),n=e-p;n>FRAME_TIME&&(p=e-n%FRAME_TIME,c.forEach(function(t){t.length=0}),o.forEach(function(t){t.age>f.MAX_PARTICLE_AGE&&(s.randomize(t).age=0);var e=t.x,n=t.y,r=s(e,n),o=r[2];if(null===o)t.age=f.MAX_PARTICLE_AGE;else{var i=e+r[0],a=n+r[1];null!==s(i,a)[2]?(t.xt=i,t.yt=a,c[u.indexFor(o)].push(t)):(t.x=i,t.y=a)}t.age+=1}),a.globalCompositeOperation="destination-in",a.fillRect(r.x,r.y,f.canvas.width,f.canvas.height),a.globalCompositeOperation="lighter",a.globalAlpha=.9,c.forEach(function(t,e){0<t.length&&(a.beginPath(),a.strokeStyle=u[e],t.forEach(function(t){a.moveTo(t.x*f.DEVICEPIXELRATIO,t.y*f.DEVICEPIXELRATIO),a.lineTo(t.xt*f.DEVICEPIXELRATIO,t.yt*f.DEVICEPIXELRATIO),t.x=t.xt,t.y=t.yt}),a.stroke())}),l.onDraw&&l.onDraw())}()}P="EPSG:4326"===f.params.projection?function(t,e,n){var r=n.east-n.west,o=n.south-n.north,i=p(n.north)+e/n.height*p(o);return[p(n.west)+t/n.width*p(r),i]}:function(t,e,n){var r=n.east-n.west,o=n.width/p(r)*360/(2*Math.PI),i=o/2*Math.log((1+Math.sin(n.south))/(1-Math.sin(n.south))),a=(n.height+i-e)/o,s=180/Math.PI*(2*Math.atan(Math.exp(a))-Math.PI/2);return[p(n.west)+t/n.width*p(r),s]};var I,O=function(t,e,n){var r=b(n.south),o=b(n.north),i=n.width/(n.east-n.west),a=n.height/(o-r),s=b(c(t));return[(c(e)-n.west)*i,s=(o-s)*a]},C=function(e,n,r,t){var o={south:c(t[0][1]),north:c(t[1][1]),east:c(t[1][0]),west:c(t[0][0]),width:n,height:r};L(),function(t,e){var n=(d=u(t)).header;y=n.lo1,g=Math.max(n.la2,n.la1),_=n.dx,m=n.dy,w=n.nx,E=n.ny,(h=new Date(n.refTime)).setHours(h.getHours()+n.forecastTime),v=[];for(var r=0,o=360<=Math.floor(w*_),i=0;i<E;i++){for(var a=[],s=0;s<w;s++,r++)a[s]=d.data(r);o&&a.push(a[0]),v[i]=a}e({date:h,interpolate:x})}(s,function(t){!function(_,m,w,n){var E={},t=(w.south-w.north)*(w.west-w.east),x=f.VELOCITY_SCALE*Math.pow(t,.4),M=[],r=m.x;function o(t){for(var e,n,r,o,i,a,s,u,c,p,l,h=[],f=m.y;f<=m.yMax;f+=2){var d=P(t,f,w);if(d){var v=d[0],y=d[1];if(isFinite(v)){var g=_.interpolate(v,y);g&&(e=E,n=v,r=y,o=t,i=f,a=x,u=w,void 0,c=(s=g)[0]*a,p=s[1]*a,l=R(e,n,r,o,i,u),s[0]=l[0]*c+l[2]*p,s[1]=l[1]*c+l[3]*p,g=s,h[f+1]=h[f]=g)}}}M[t+1]=M[t]=h}!function t(){for(var e=Date.now();r<m.width;)if(o(r),r+=2,1e3<Date.now()-e)return void setTimeout(t,25);i(M,m,n)}()}(t,function(t,e,n){var r=t[0],o=t[1],i=Math.round(r[0]),a=Math.max(Math.floor(r[1],0),0);Math.min(Math.ceil(o[0],e),e-1);return{x:i,y:a,xMax:e,yMax:Math.min(Math.ceil(o[1],n),n-1),width:e,height:n}}(e,n,r),o,function(t,e){S.field=e,A(t,e)})})},L=function(){S.field&&S.field.release(),I&&cancelAnimationFrame(I)},S={params:f.params,start:C,stop:L,update:function(t,e,n,r,o){delete f.params.data,f.params.data=t,o&&C(e,n,r,o)},shift:function(t,e){var n=f.canvas,r=n.width,o=n.height,i=n.getContext("2d");if(t<r&&e<o){var a=function(t,e){return Math.max(0,Math.min(t,e))},s=i.getImageData(a(r,-t),a(o,-e),a(r,r-t),a(o,o-e));i.clearRect(0,0,r,o),i.putImageData(s,a(r,t),a(o,e));for(var u=0,c=particles.length;u<c;u++)particles[u].x+=t,particles[u].y+=e}},createField:i,interpolatePoint:x,setData:function(t){s=t},updateParams:function(t){f.params=t,e(f.params)},getParams:function(){return f.params},buildParams:e};return S}window.requestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/window.FRAME_RATE)},window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)});var ne=0,re=1,oe=function(e){function t(t){e.call(this,t),this.wind=void 0}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.prepareFrame=function(t){var e=t.layerStatesArray[t.layerIndex],n=t.viewState,r=t.viewHints,o=t.extent;if(void 0!==e.extent&&(o=_(o,te(e.extent,n.projection))),r[ne]||r[re]||function(t){return t[2]<t[0]||t[3]<t[1]}(o))return!1;if(this.wind||!this.context)return!0;var i=this.getLayer(),a=this._getExtent(t),s=i.options,u=s.projection,c=s.minVelocity,p=s.maxVelocity,l=s.velocityScale,h=s.particleAge,f=s.lineWidth,d=s.particleMultiplier,v=s.colorScale,y=s.devicePixelRatio,g=this.context.canvas;return this.wind=new ee({canvas:g,data:i.getData(),projection:u,minVelocity:c,maxVelocity:p,velocityScale:l,particleAge:h,lineWidth:f,particleMultiplier:d,colorScale:v,devicePixelRatio:y}),this.wind.start(a[0],a[1],a[2],a[3]),!!this.wind},t.prototype.renderFrame=function(t,e){var n=t.layerStatesArray[t.layerIndex],r=t.pixelRatio,o=t.viewState,i=t.size,a=Math.round(i[0]*r),s=Math.round(i[1]*r),u=o.rotation;if(u){var c=Math.round(Math.sqrt(a*a+s*s));s=a=c}st(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/r,1/r,u,-a/2,-s/2),ut(this.inversePixelTransform,this.pixelTransform);var p=this.createTransformString(this.pixelTransform);this.useContainer(e,p,n.opacity);var l=this.context,h=l.canvas;h.width!==a||h.height!==s?(h.width=a,h.height=s):this.containerReused||l.clearRect(0,0,a,s);var f=!1;if(n.extent){var d=te(n.extent,o.projection);(f=!function(t,e){return t[0]<=e[0]&&e[2]<=t[2]&&t[1]<=e[1]&&e[3]<=t[3]}(d,t.extent)&&y(d,t.extent))&&this.clipUnrotated(l,t,d)}this.preRender(l,t);var v=this._getExtent(t);return this.wind&&v&&this.wind.start(v[0],v[1],v[2],v[3]),this.postRender(l,t),f&&l.restore(),p!==h.style.transform&&(h.style.transform=p),this.container},t.prototype._getExtent=function(t){var e=t.size,n=t.extent,r=t.viewState;if(!n||!r||!e)return!1;var o=Bt(n,r.projection,"EPSG:4326");return[[[0,0],[e[0],e[1]]],e[0],e[1],[[o[0],o[1]],[o[2],o[3]]]]},t.prototype.getLayer=function(){return e.prototype.getLayer.call(this)},t}(lt),ie=function(t){return t/.514},ae=function(t){return 3.6*t};return function(n){function t(t,e){void 0===e&&(e={}),n.call(this,e),this.options=e,t&&this.setData(t)}return n&&(t.__proto__=n),((t.prototype=Object.create(n&&n.prototype)).constructor=t).prototype.render=function(t,e){var n=this.getRenderer();if(n.prepareFrame(t))return n.renderFrame(t,e)},t.prototype.getRenderer=function(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_},t.prototype.hasRenderer=function(){return!!this.renderer_},t.prototype.createRenderer=function(){return new oe(this)},t.prototype.getData=function(){return this.data},t.prototype.setData=function(t){return t?this.data=t:console.error("Illegal data"),this},t.prototype.appendTo=function(t){if(!(t&&t instanceof e.Map))throw new Error("not map object");t.addLayer(this)},t.prototype.getPointData=function(t){var e=this.getRenderer();if(!e||!e.wind)return null;var n=e.wind.interpolatePoint(t[0],t[1]);return n&&!isNaN(n[0])&&!isNaN(n[1])&&n[2]?{direction:function(t,e,n){n.endsWith("CCW")&&(e=0<e?e=-e:Math.abs(e));var r=Math.sqrt(Math.pow(t,2)+Math.pow(e,2)),o=180*Math.atan2(t/r,e/r)/Math.PI+180;return"bearingCW"!==n&&"meteoCCW"!==n||360<=(o+=180)&&(o-=360),o}(n[0],n[1],this.options.angleConvention||"bearingCCW"),speed:function(t,e,n){var r=Math.sqrt(Math.pow(t,2)+Math.pow(e,2));return"k/h"===n?ae(r):"kt"===n?ie(r):r}(n[0],n[1],this.options.speedUnit)}:void 0},t.prototype.clearWind=function(){var t=this.getRenderer();if(!t||!t.wind)return null;t.wind.stop(),this.changed()},t.prototype.removeLayer=function(){var t=this.getRenderer();if(!t||!t.wind)return null;t.wind.stop(),console.warn("You should use `map.removeLayer()` to remove this layer!")},t.prototype.updateParams=function(t){void 0===t&&(t={});var e=this.getRenderer();if(this.options=Object.assign(this.options,t),this.layerRenderer&&e.wind){var n=this.options,r=n.minVelocity,o=n.maxVelocity,i=n.velocityScale,a=n.particleAge,s=n.lineWidth,u=n.particleMultiplier,c=n.colorScale;this.$Windy.updateParams({minVelocity:r,maxVelocity:o,velocityScale:i,particleAge:a,lineWidth:s,particleMultiplier:u,colorScale:c,devicePixelRatio:this.options.devicePixelRatio})}return this},t.prototype.getParams=function(){var t=this.getRenderer();if(t&&t.wind)return t.wind.getParams()},t}(t.Layer)});