wind-layer
Version:
a openlayers ol bmap amap maptalks extension to windjs
2 lines (1 loc) • 19.5 kB
JavaScript
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t=t||self).windLayer=i()}(this,function(){"use strict";function p(p){void 0===p&&(p={}),this.params=p;var u=this;function i(t){t.projection||(t.projection="EPSG:4326"),u.MIN_VELOCITY_INTENSITY=t.minVelocity||0,u.MAX_VELOCITY_INTENSITY=t.maxVelocity||10,u.VELOCITY_SCALE=(t.velocityScale||.005)*(Math.pow(window.devicePixelRatio,1/3)||1),u.MAX_PARTICLE_AGE=t.particleAge||90,u.PARTICLE_LINE_WIDTH=t.lineWidth||1,u.PARTICLE_MULTIPLIER=t.particleMultiplier||1/300,u.PARTICLE_REDUCTION=Math.pow(window.devicePixelRatio,1/3)||1.6,u.FRAME_RATE=t.frameRate||16,u.COLOR_SCALE=t.colorScale||e,u.DEVICEPIXELRATIO=t.devicePixelRatio||1}u.canvas=p.canvas;var e=["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 a(t,i,e,n,a,o){var r=1-t,s=1-i,h=r*s,c=t*s,l=r*i,p=t*i,d=e[0]*h+n[0]*c+a[0]*l+o[0]*p,u=e[1]*h+n[1]*c+a[1]*l+o[1]*p;return[d,u,Math.sqrt(d*d+u*u)]}function h(t){var i=null,e=null;return t.forEach(function(t){switch(t.header.parameterCategory+","+t.header.parameterNumber){case"1,2":case"2,2":i=t;break;case"1,3":case"2,3":e=t}}),function(t,i){var e=t.data,n=i.data;return{header:t.header,data:function(t){return[e[t],n[t]]},interpolate:a}}(i,e)}function o(n,a,t){function o(t,i){var e=n[Math.round(t)];return e&&e[Math.round(i)]||r}o.release=function(){n=[]},o.randomize=function(t){for(var i,e,n=0;null===o(i=Math.round(Math.floor(Math.random()*a.width)+a.x),e=Math.round(Math.floor(Math.random()*a.height)+a.y))[2]&&n++<30;);return t.x=i,t.y=e,t},t(a,o)}function c(t){return t/180*Math.PI}function l(t){return t/(Math.PI/180)}i(p),window.FRAME_TIME=1e3/u.FRAME_RATE;var y,f,d,g,v,m,w,_,M,I,r=[NaN,NaN,null],s=u.params.data,x=function(t,i){if(!f)return null;var e,n=C(t-g,360)/m,a=(v-i)/w,o=Math.floor(n),r=o+1,s=Math.floor(a),h=s+1;if(e=f[s]){var c=e[o],l=e[r];if(E(c)&&E(l)&&(e=f[h])){var p=e[o],d=e[r];if(E(p)&&E(d))return y.interpolate(n-o,a-s,c,l,p,d)}}return null},E=function(t){return null!=t},C=function(t,i){return t-i*Math.floor(t/i)},P=function(t,i,e,n,a,o){var r=2*Math.PI,s="EPSG:4326"===u.params.projection?5:Math.pow(10,-5.2),h=i<0?s:-s,c=e<0?s:-s,l=b(e,i+h,o),p=b(e+c,i,o),d=Math.cos(e/360*r);return[(l[0]-n)/h/d,(l[1]-a)/h/d,(p[0]-n)/c,(p[1]-a)/c]};function A(t){return Math.log(Math.tan(t/2+Math.PI/4))}function S(n,s){var i,e,h=(i=u.MIN_VELOCITY_INTENSITY,e=u.MAX_VELOCITY_INTENSITY,u.COLOR_SCALE.indexFor=function(t){return Math.max(0,Math.min(u.COLOR_SCALE.length-1,Math.round((t-i)/(e-i)*(u.COLOR_SCALE.length-1))))},u.COLOR_SCALE),c=h.map(function(){return[]}),t=Math.round(n.width*n.height*u.PARTICLE_MULTIPLIER);/android|blackberry|iemobile|ipad|iphone|ipod|opera mini|webos/i.test(navigator.userAgent)&&(t*=u.PARTICLE_REDUCTION);for(var a=[],o=0;o<t;o++)a.push(s.randomize({age:Math.floor(Math.random()*u.MAX_PARTICLE_AGE)+0}));var r=u.canvas.getContext("2d");r.lineWidth=u.PARTICLE_LINE_WIDTH,r.fillStyle="rgba(0, 0, 0, 0.97)",r.globalAlpha=.6;var l=Date.now();!function t(){L=requestAnimationFrame(t);var i=Date.now(),e=i-l;e>FRAME_TIME&&(l=i-e%FRAME_TIME,c.forEach(function(t){t.length=0}),a.forEach(function(t){t.age>u.MAX_PARTICLE_AGE&&(s.randomize(t).age=0);var i=t.x,e=t.y,n=s(i,e),a=n[2];if(null===a)t.age=u.MAX_PARTICLE_AGE;else{var o=i+n[0],r=e+n[1];null!==s(o,r)[2]?(t.xt=o,t.yt=r,c[h.indexFor(a)].push(t)):(t.x=o,t.y=r)}t.age+=1}),r.globalCompositeOperation="destination-in",r.fillRect(n.x,n.y,u.canvas.width,u.canvas.height),r.globalCompositeOperation="lighter",r.globalAlpha=.9,c.forEach(function(t,i){0<t.length&&(r.beginPath(),r.strokeStyle=h[i],t.forEach(function(t){r.moveTo(t.x*u.DEVICEPIXELRATIO,t.y*u.DEVICEPIXELRATIO),r.lineTo(t.xt*u.DEVICEPIXELRATIO,t.yt*u.DEVICEPIXELRATIO),t.x=t.xt,t.y=t.yt}),r.stroke())}),p.onDraw&&p.onDraw())}()}I="EPSG:4326"===u.params.projection?function(t,i,e){var n=e.east-e.west,a=e.south-e.north,o=l(e.north)+i/e.height*l(a);return[l(e.west)+t/e.width*l(n),o]}:function(t,i,e){var n=e.east-e.west,a=e.width/l(n)*360/(2*Math.PI),o=a/2*Math.log((1+Math.sin(e.south))/(1-Math.sin(e.south))),r=(e.height+o-i)/a,s=180/Math.PI*(2*Math.atan(Math.exp(r))-Math.PI/2);return[l(e.west)+t/e.width*l(n),s]};var L,b=function(t,i,e){var n=A(e.south),a=A(e.north),o=e.width/(e.east-e.west),r=e.height/(a-n),s=A(c(t));return[(c(i)-e.west)*o,s=(a-s)*r]},R=function(i,e,n,t){var a={south:c(t[0][1]),north:c(t[1][1]),east:c(t[1][0]),west:c(t[0][0]),width:e,height:n};T(),function(t,i){var e=(y=h(t)).header;g=e.lo1,v=Math.max(e.la2,e.la1),m=e.dx,w=e.dy,_=e.nx,M=e.ny,(d=new Date(e.refTime)).setHours(d.getHours()+e.forecastTime),f=[];for(var n=0,a=360<=Math.floor(_*m),o=0;o<M;o++){for(var r=[],s=0;s<_;s++,n++)r[s]=y.data(n);a&&r.push(r[0]),f[o]=r}i({date:d,interpolate:x})}(s,function(t){!function(m,w,_,e){var M={},t=(_.south-_.north)*(_.west-_.east),x=u.VELOCITY_SCALE*Math.pow(t,.4),E=[],n=w.x;function a(t){for(var i,e,n,a,o,r,s,h,c,l,p,d=[],u=w.y;u<=w.yMax;u+=2){var y=I(t,u,_);if(y){var f=y[0],g=y[1];if(isFinite(f)){var v=m.interpolate(f,g);v&&(i=M,e=f,n=g,a=t,o=u,r=x,h=_,void 0,c=(s=v)[0]*r,l=s[1]*r,p=P(i,e,n,a,o,h),s[0]=p[0]*c+p[2]*l,s[1]=p[1]*c+p[3]*l,v=s,d[u+1]=d[u]=v)}}}E[t+1]=E[t]=d}!function t(){for(var i=Date.now();n<w.width;)if(a(n),n+=2,1e3<Date.now()-i)return void setTimeout(t,25);o(E,w,e)}()}(t,function(t,i,e){var n=t[0],a=t[1],o=Math.round(n[0]),r=Math.max(Math.floor(n[1],0),0);Math.min(Math.ceil(a[0],i),i-1);return{x:o,y:r,xMax:i,yMax:Math.min(Math.ceil(a[1],e),e-1),width:i,height:e}}(i,e,n),a,function(t,i){W.field=i,S(t,i)})})},T=function(){W.field&&W.field.release(),L&&cancelAnimationFrame(L)},W={params:u.params,start:R,stop:T,update:function(t,i,e,n,a){delete u.params.data,u.params.data=t,a&&R(i,e,n,a)},shift:function(t,i){var e=u.canvas,n=e.width,a=e.height,o=e.getContext("2d");if(t<n&&i<a){var r=function(t,i){return Math.max(0,Math.min(t,i))},s=o.getImageData(r(n,-t),r(a,-i),r(n,n-t),r(a,a-i));o.clearRect(0,0,n,a),o.putImageData(s,r(n,t),r(a,i));for(var h=0,c=particles.length;h<c;h++)particles[h].x+=t,particles[h].y+=i}},createField:o,interpolatePoint:x,setData:function(t){s=t},updateParams:function(t){u.params=t,i(u.params)},getParams:function(){return u.params},buildParams:i};return W}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)});function o(t,i,e){if("undefined"==typeof document)return new e(t,i);var n=document.createElement("canvas");return n.width=t,n.height=i,n}function n(t,i,e){e.endsWith("CCW")&&(i=0<i?i=-i:Math.abs(i));var n=Math.sqrt(Math.pow(t,2)+Math.pow(i,2)),a=180*Math.atan2(t/n,i/n)/Math.PI+180;return"bearingCW"!==e&&"meteoCCW"!==e||360<=(a+=180)&&(a-=360),a}function a(t,i,e){var n=Math.sqrt(Math.pow(t,2)+Math.pow(i,2));return"k/h"===e?s(n):"kt"===e?r(n):n}var r=function(t){return t/.514},s=function(t){return 3.6*t},h=("undefined"==typeof window?{}:window).ol||{};h.layer||(h.layer={}),h.layer.Image||(h.layer.Image=function(){return function(){}}());function t(t,i){void 0===i&&(i={}),this.options=i,this.canvas=null,this.data=t,this.layer_=null,this._windy=null,i.map&&this.appendTo(i.map),this.init=this.init.bind(this),this.handleResize=this.handleResize.bind(this),this.canvasFunction=this.canvasFunction.bind(this),this._addReFreshHandle=this._addReFreshHandle.bind(this)}var i=function(e){function t(t,i){void 0===i&&(i={}),e.call(this,i),this._canvas=null,this.data=t,this.$Windy=null,this.isClear=!1,this.options=i,this.setSource(new h.source.ImageCanvas({logo:i.logo,state:i.state,attributions:i.attributions,resolutions:i.resolutions,canvasFunction:this.canvasFunction.bind(this),ratio:i.hasOwnProperty("ratio")?i.ratio:1})),this.on("precompose",this.redraw,this)}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.getData=function(){return this.data},t.prototype.setData=function(t){var i=this.getMap();if(!i)return this;if(this.data=t,this.isClear=!1,!this.$Windy&&this._canvas)this.render(this._canvas),i.renderSync();else if(this.$Windy&&this._canvas){this._cloneLayer&&(i.addLayer(this._cloneLayer),delete this._cloneLayer);var e=this._getExtent();this.$Windy.update(this.getData(),e[0],e[1],e[2],e[3])}else console.warn("please create new instance");return this},t.prototype.render=function(t){var i=this._getExtent();if(this.isClear||!this.getData()||!i)return this;if(t&&!this.$Windy){var e=this.options,n=e.minVelocity,a=e.maxVelocity,o=e.velocityScale,r=e.particleAge,s=e.lineWidth,h=e.particleMultiplier,c=e.colorScale;this.$Windy=new p({canvas:t,projection:this._getProjectionCode(),data:this.getData(),devicePixelRatio:this.options.devicePixelRatio,minVelocity:n,maxVelocity:a,velocityScale:o,particleAge:r,lineWidth:s,particleMultiplier:h,colorScale:c}),this.$Windy.start(i[0],i[1],i[2],i[3])}else if(t&&this.$Windy){var l=this._getExtent();this.$Windy.start(l[0],l[1],l[2],l[3])}return this},t.prototype.redraw=function(){if(!this.isClear){var t=this.options.extent||this._getMapExtent();this.setExtent(t)}},t.prototype.canvasFunction=function(t,i,e,n,a){return this._canvas?(this._canvas.width=n[0],this._canvas.height=n[1]):this._canvas=o(n[0],n[1]),i<=this.get("maxResolution")&&this.render(this._canvas),this._canvas},t.prototype._getExtent=function(){var t=this._getMapSize(),i=this._getMapExtent();if(t&&i){var e=this._getProjectionCode(),n=h.proj.transformExtent(i,e,"EPSG:4326");return[[[0,0],[t[0],t[1]]],t[0],t[1],[[n[0],n[1]],[n[2],n[3]]]]}return!1},t.prototype._getMapExtent=function(){if(this.getMap()){var t=this._getMapSize(),i=this.getMap().getView();return i&&i.calculateExtent(t)}},t.prototype._getMapSize=function(){if(this.getMap())return this.getMap().getSize()},t.prototype.appendTo=function(t){if(!(t&&t instanceof h.Map))throw new Error("not map object");this.set("originMap",t),this.getSource().projection_=this._getProjectionCode(),t.addLayer(this)},t.prototype.getPointData=function(t){if(!this.$Windy)return null;var i=this.$Windy.interpolatePoint(t[0],t[1]);return i&&!isNaN(i[0])&&!isNaN(i[1])&&i[2]?{direction:n(i[0],i[1],this.options.angleConvention||"bearingCCW"),speed:a(i[0],i[1],this.options.speedUnit)}:void 0},t.prototype.clearWind=function(){var t=this.getMap();t&&(this.$Windy&&this.$Windy.stop(),this.isClear=!0,this._cloneLayer=this,t.removeLayer(this),this.changed(),this.getMap().renderSync())},t.prototype.removeLayer=function(){var t=this.getMap();t&&(this.$Windy&&this.$Windy.stop(),this.un("precompose",this.redraw,this),t.removeLayer(this),delete this._canvas,delete this.$Windy,delete this._cloneLayer)},t.prototype.setMap=function(t){this.set("originMap",t)},t.prototype.getMap=function(){return this.get("originMap")},t.prototype._getProjectionCode=function(){var t=this.getMap();return t?t.getView()&&t.getView().getProjection().getCode():"EPSG:3857"},t.prototype.updateParams=function(t){if(this.options=Object.assign(this.options,t),this.$Windy){var i=this.options,e=i.minVelocity,n=i.maxVelocity,a=i.velocityScale,o=i.particleAge,r=i.lineWidth,s=i.particleMultiplier,h=i.colorScale;this.$Windy&&(this.$Windy.updateParams({minVelocity:e,maxVelocity:n,velocityScale:a,particleAge:o,lineWidth:r,particleMultiplier:s,colorScale:h,devicePixelRatio:this.options.devicePixelRatio}),this.getMap()&&this._canvas&&this.data&&this.render(this._canvas))}return this},t.prototype.getParams=function(){return this.$Windy&&this.$Windy.getParams()},t}(h.layer.Image),c=("undefined"==typeof window?{}:window).AMap||{};t.prototype.appendTo=function(t){if(!t)throw new Error("not map object");this.init(t)},t.prototype.getData=function(){return this.data},t.prototype.setData=function(t){this.data=t,this.map&&this.canvas&&this.data&&this.render(this.canvas)},t.prototype.init=function(t,i){if(!t)throw new Error("not map object");this.map=t,this.context=this.options.context||"2d",this.getCanvasLayer(),this.map.on("resize",this.handleResize,this)},t.prototype.handleResize=function(){this.canvas&&this.canvasFunction()},t.prototype.render=function(t){if(t){var i=this._getExtent();if(!this.getData()||!i)return this;if(t&&!this._windy){var e=this.options,n=e.minVelocity,a=e.maxVelocity,o=e.velocityScale,r=e.particleAge,s=e.lineWidth,h=e.particleMultiplier,c=e.colorScale;this._windy=new p({canvas:t,data:this.getData(),onDraw:function(){},minVelocity:n,maxVelocity:a,velocityScale:o,particleAge:r,lineWidth:s,particleMultiplier:h,colorScale:c}),this._windy.start(i[0],i[1],i[2],i[3])}else t&&this._windy&&this._windy.start(i[0],i[1],i[2],i[3]);return this._addReFreshHandle(),this}},t.prototype._addReFreshHandle=function(){this.map&&"3d"===this.map.getViewMode_().toLowerCase()&&(this.layer_&&this.layer_.reFresh(),c.Util.requestAnimFrame(this._addReFreshHandle))},t.prototype.getCanvasLayer=function(){if(!this.canvas&&!this.layer_){var t=this.canvasFunction(),i=this._getBounds();this.layer_=new c.CanvasLayer({canvas:t,bounds:this.options.bounds||i,zooms:this.options.zooms||[0,22],zIndex:this.options.zIndex||12,opacity:this.options.opacity||1}),this.map.on("mapmove",this.canvasFunction,this),this.map.on("zoomchange",this.canvasFunction,this),this.layer_.setMap(this.map)}},t.prototype.canvasFunction=function(){var t=[this.map.getSize().width,this.map.getSize().height],i=t[0],e=t[1];if(this.canvas){this.canvas.width=i,this.canvas.height=e;var n=this._getBounds();this.layer_&&this.layer_.setBounds(this.options.bounds||n)}else this.canvas=o(i,e,null);return this.render(this.canvas),this.canvas},t.prototype._getBounds=function(){var t=this.map.getViewMode_(),i=[],e=i[0],n=i[1],a=this.map.getBounds();if("2d"===t.toLowerCase())n=a.getNorthEast(),e=a.getSouthWest();else{var o=a.bounds.map(function(t){return[t.getLng(),t.getLat()]});e=new(Function.prototype.bind.apply(c.LngLat,[null].concat(o[3]))),n=new(Function.prototype.bind.apply(c.LngLat,[null].concat(o[1])))}return new c.Bounds(e,n)},t.prototype._getExtent=function(){var t=[this.map.getSize().width,this.map.getSize().height],i=t[0],e=t[1],n=this._getBounds(),a=n.getNorthEast(),o=n.getSouthWest(),r=o.lng,s=a.lng<0?360+a.lng:a.lng,h=Math.min(r,s),c=Math.max(r,s);return[[[0,0],[i,e]],i,e,[[h,o.lat],[c,a.lat]]]},t.prototype.removeLayer=function(){this.map&&(this.layer_.setMap(null),this.map.off("resize",this.handleResize,this),this.map.off("mapmove",this.canvasFunction,this),this.map.off("zoomchange",this.canvasFunction,this),delete this.map,delete this.layer_,delete this.canvas)},t.prototype.getContext=function(){return this.canvas.getContext(this.context)},t.prototype.getPointData=function(t){var i=this._windy.interpolatePoint(t[0],t[1]);if(i&&!isNaN(i[0])&&!isNaN(i[1])&&i[2])return{direction:n(i[0],i[1],this.options.angleConvention||"bearingCCW"),speed:a(i[0],i[1],this.options.speedUnit)}},t.prototype.clearWind=function(){this._windy&&this._windy.stop()},t.prototype.updateParams=function(t){if(this.options=Object.assign(this.options,t),this._windy){var i=this.options,e=i.minVelocity,n=i.maxVelocity,a=i.velocityScale,o=i.particleAge,r=i.lineWidth,s=i.particleMultiplier,h=i.colorScale;this._windy&&(this._windy.updateParams({minVelocity:e,maxVelocity:n,velocityScale:a,particleAge:o,lineWidth:r,particleMultiplier:s,colorScale:h}),this.map&&this.canvas&&this.data&&this.render(this.canvas))}return this},t.prototype.getParams=function(){return this._windy&&this._windy.getParams()};var l="undefined"==typeof window?{}:window;return l.BMap||(l.BMap={}),l.BMap.Overlay||(l.BMap.Overlay=function(){return function(){}}()),{AMapWind:t,BMapWind:function(e){function t(t,i){void 0===i&&(i={}),e.call(this,i),this.options=i,this.paneName=this.options.paneName||"mapPane",this.context=this.options.context||"2d",this.zIndex=this.options.zIndex||0,this.mixBlendMode=this.options.mixBlendMode||null,this.enableMassClear=this.options.enableMassClear,this._map=i.map,this._lastDrawTime=null,this.canvas=null,this.data=t,this._windy=null,this.show()}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.getData=function(){return this.data},t.prototype.setData=function(t){this.data=t,this._map&&this.data&&this._draw()},t.prototype._getExtent=function(){var t=this._map.getSize(),i=this._map.getBounds().getNorthEast(),e=this._map.getBounds().getSouthWest();return[[[0,0],[t.width,t.height]],t.width,t.height,[[e.lng,e.lat],[i.lng,i.lat]]]},t.prototype.appendTo=function(t){if(!t)throw new Error("not map object");t.addOverlay(this)},t.prototype.initialize=function(t){var i=this;this._map=t;var e=this.canvas=document.createElement("canvas");return e.style.cssText="position:absolute; left:0; top:0; z-index: "+this.zIndex+" ;user-select:none;",e.style.mixBlendMode=this.mixBlendMode,this.adjustSize(),t.getPanes()[this.paneName].appendChild(e),t.addEventListener("resize",function(){i.adjustSize(),i._draw()}),this.canvas},t.prototype.adjustSize=function(){var t=this._map.getSize(),i=this.canvas,e=this.devicePixelRatio=l.devicePixelRatio||1;i.width=t.width*e,i.height=t.height*e,"2d"===this.context&&i.getContext(this.context).scale(e,e),i.style.width=t.width+"px",i.style.height=t.height+"px"},t.prototype.draw=function(){var t=this;clearTimeout(t.timeoutID),t.timeoutID=setTimeout(function(){t._draw()},15)},t.prototype._draw=function(){var t=this._map,i=t.getSize(),e=t.getCenter();if(e){var n=t.pointToOverlayPixel(e);this.canvas.style.left=n.x-i.width/2+"px",this.canvas.style.top=n.y-i.height/2+"px",this.dispatchEvent("draw"),this.options.update&&this.options.update.call(this),this.render(this.canvas)}},t.prototype.render=function(t){var i=this._getExtent();if(!this.getData()||!i)return this;if(t&&!this._windy){var e=this.options,n=e.minVelocity,a=e.maxVelocity,o=e.velocityScale,r=e.particleAge,s=e.lineWidth,h=e.particleMultiplier,c=e.colorScale;this._windy=new p({canvas:t,data:this.getData(),onDraw:function(){},minVelocity:n,maxVelocity:a,velocityScale:o,particleAge:r,lineWidth:s,particleMultiplier:h,colorScale:c}),this._windy.start(i[0],i[1],i[2],i[3])}else t&&this._windy&&this._windy.start(i[0],i[1],i[2],i[3]);return this},t.prototype.getContainer=function(){return this.canvas},t.prototype.setZIndex=function(t){this.zIndex=t,this.canvas.style.zIndex=this.zIndex},t.prototype.getZIndex=function(){return this.zIndex},t.prototype.getPointData=function(t){var i=this._windy.interpolatePoint(t[0],t[1]);if(i&&!isNaN(i[0])&&!isNaN(i[1])&&i[2])return{direction:n(i[0],i[1],this.options.angleConvention||"bearingCCW"),speed:a(i[0],i[1],this.options.speedUnit)}},t.prototype.clearWind=function(){this._windy&&this._windy.stop()},t.prototype.updateParams=function(t){if(this.options=Object.assign(this.options,t),this._windy){var i=this.options,e=i.minVelocity,n=i.maxVelocity,a=i.velocityScale,o=i.particleAge,r=i.lineWidth,s=i.particleMultiplier,h=i.colorScale;this._windy&&(this._windy.updateParams({minVelocity:e,maxVelocity:n,velocityScale:a,particleAge:o,lineWidth:r,particleMultiplier:s,colorScale:h}),this._map&&this.canvas&&this.data&&this.render(this.canvas))}return this},t.prototype.getParams=function(){return this._windy&&this._windy.getParams()},t}(l.BMap.Overlay),OlWind:i}});