@idmwx/idmui-gl2-h5
Version:
idm webgl
191 lines (155 loc) • 211 kB
JavaScript
(function($,Z){typeof exports=="object"&&typeof module<"u"?Z(exports,require("@idm-plugin/tag"),require("vue"),require("@turf/turf"),require("@mapbox/sphericalmercator"),require("moment"),require("mapbox-gl"),require("@idm-plugin/geo"),require("axios"),require("@idm-plugin/meteo")):typeof define=="function"&&define.amd?define(["exports","@idm-plugin/tag","vue","@turf/turf","@mapbox/sphericalmercator","moment","mapbox-gl","@idm-plugin/geo","axios","@idm-plugin/meteo"],Z):($=typeof globalThis<"u"?globalThis:$||self,Z($["idm-gl"]={},$["@idm-plugin/tag"],$.Vue,$.turf,$["@mapbox/sphericalmercator"],$.moment,$["mapbox-gl"],$["@idm-plugin/geo"],$.axios,$["@idm-plugin/meteo"]))})(this,function($,Z,r,Me,Ne,ne,ke,A,_e,Re){"use strict";var Di=Object.defineProperty;var Mi=($,Z,r)=>Z in $?Di($,Z,{enumerable:!0,configurable:!0,writable:!0,value:r}):$[Z]=r;var X=($,Z,r)=>(Mi($,typeof Z!="symbol"?Z+"":Z,r),r);function Ae(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const E=Ae(Me),Ni="",Ai="",V=(a,e)=>{const t=a.__vccOpts||a;for(const[s,i]of e)t[s]=i;return t},Ve={name:"IdmGlLayer",props:{map:{type:Object},top:{type:String,default:"30px"},bottom:{type:String,default:"340px"},right:{type:String,default:"0px"},importReportLayers:{type:Boolean,default:!1}},emits:["weather","other","coordinate","measure","point","3d","particle"],data(){return{showLayers:!1,showPinLayers:!1,source:"",weatherLayers:[],activeWeatherLayers:[],autoActive:!0,otherLayers:[],layers:{weather:[...Z.LayerHelper.WEATHER_LAYERS],other:[...Z.LayerHelper.OTHER_LAYERS]},weatherLayersCache:"weatherLayersCache",autoActiveCache:"autoActiveCache",otherLayersCache:"otherLayersCache",sourceCache:"defaultSourceCache",showCoord:!1,showMeasure:!1,showPoint:!1,show3d:!1,version:{v:"0.0.4",k:"glCacheVersion"},weatherLayerImgUrl:"https://osshz.idmwx.com/layers/weather/icon/",isParticleActive:!1,maxLayerLength:4}},computed:{computeLayerClass(){return function(a,e){return a.enabled?e.some(t=>t.key===a.key)?"layer-option active":"layer-option":"layer-option disabled"}},computeLayerPngClass(){return function(a,e){return e.some(t=>t.key===a.key)?"layer-png-option active":"layer-png-option"}},computeLayerSwitch(){return function(a,e){return e.some(t=>t.key===a.key)?"layer-switch-option active":"layer-switch-option"}},computeIsWindActive(){return this.activeWeatherLayers.some(a=>a.key==="wind"||a.key==="current")}},watch:{},mounted(){const a=localStorage.getItem(this.version.k);this.version.v!==a&&(localStorage.removeItem(this.weatherLayersCache),localStorage.setItem(this.version.k,this.version.v));let e=localStorage.getItem(this.autoActiveCache);this.autoActive=e!=="false",e=localStorage.getItem(this.weatherLayersCache);let t="";this.importReportLayers?t=JSON.parse('[{"weight":1,"name":"Wind","key":"wind","enabled":true,"type":"json","particle":true}, { "weight": 32, "name": "Current Direction", "key": "current-direction", "vendor": "cmems", "partly": true, "enabled": true, "type": "json" },{"weight": 16, "name": "Sig Waves", "key": "sig-wave-height", "h5": true, "enabled": true, "type": "json"}]'):t=JSON.parse(e||'[{"weight":256,"name":"Tropicals","key":"tropicals","enabled":true,"type":"json"}]'),this.weatherLayers=t,this.autoActive&&(this.activeWeatherLayers=[...t]),e=localStorage.getItem(this.otherLayersCache),this.importReportLayers?t=[]:t=JSON.parse(e||"[]"),this.otherLayers=t,e=localStorage.getItem(this.sourceCache),this.source=e||"GFS",this.handleConfirm()},methods:{handleConfirm(){this.$emit("weather",this.weatherLayers,this.activeWeatherLayers,this.source),this.$emit("other",this.otherLayers),localStorage.setItem(this.autoActiveCache,this.autoActive),localStorage.setItem(this.sourceCache,this.source)},handleWeatherLayerPick(a){this.weatherLayers.some(e=>e.key===a.key)?(this.weatherLayers=this.weatherLayers.filter(e=>e.key!==a.key),this.activeWeatherLayers=this.activeWeatherLayers.filter(e=>e.key!==a.key)):this.weatherLayers.length<=this.maxLayerLength&&a.enabled&&(["png","jpg"].includes(a.type)&&(this.weatherLayers=this.weatherLayers.filter(e=>e.type==="json"&&!["wind","current"].includes(e.key)),this.activeWeatherLayers=this.activeWeatherLayers.filter(e=>e.type==="json"&&!["wind","current"].includes(e.key))),["wind","current"].includes(a.key)&&(this.weatherLayers=this.weatherLayers.filter(e=>e.type==="json"&&!["wind","current"].includes(e.key)),this.activeWeatherLayers=this.activeWeatherLayers.filter(e=>e.type==="json"&&!["wind","current"].includes(e.key))),this.weatherLayers.push(a),this.activeWeatherLayers.push(a)),localStorage.setItem(this.weatherLayersCache,JSON.stringify(this.weatherLayers)),this.handleConfirm()},handleActiveWeatherLayerPick(a){if(this.activeWeatherLayers.some(e=>e.key===a.key))this.activeWeatherLayers=this.activeWeatherLayers.filter(e=>e.key!==a.key);else if(a.enabled){this.activeWeatherLayers.push(a);for(const e of this.weatherLayers)a.weight>e.weight&&a.weight&e.weight&&this.activeWeatherLayers.push(e)}this.$emit("weather",this.weatherLayers,this.activeWeatherLayers,this.source)},handleOtherLayerPick(a){this.otherLayers.some(e=>e.key===a.key)?this.otherLayers=this.otherLayers.filter(e=>e.key!==a.key):a.enabled&&this.otherLayers.push(a),localStorage.setItem(this.otherLayersCache,JSON.stringify(this.otherLayers)),this.handleConfirm()},handleCoordToggle(){this.showCoord=!this.showCoord,this.$emit("coordinate",this.showCoord)},handlePointToggle(){this.showPoint=!this.showPoint,this.$emit("point",this.showPoint)},handleMeasureToggle(){this.showMeasure=!this.showMeasure,this.$emit("measure",this.showMeasure)},handle3DToggle(){this.show3d=!this.show3d,this.$emit("3d",this.show3d)},handleParticlePick(){this.isParticleActive=!this.isParticleActive,this.activeWeatherLayers.some(a=>a.key==="wind")?this.$emit("particle",{particle:this.isParticleActive,key:"wind",weight:1}):this.activeWeatherLayers.some(a=>a.key==="current")&&this.$emit("particle",{particle:this.isParticleActive,key:"current",weight:96})},handleSourceToggle(a){this.source=a,this.handleConfirm()}}},We={key:0,class:"idm-gl-layer"},Oe={class:"bar-item layer-bars"},Fe={class:"bar-item tool-bars"},je={class:"main"},$e={class:"content"},Ue={class:"weather-layers"},Ge={class:"body"},He=["onClick"],qe=["src"],Xe={class:"text"},Ze={class:"other-layers"},Je={class:"body"},Ye={class:"text"},Ke=["onClick"],Qe=["onClick"],et={class:"layer-switch-option"},tt={class:"model-box"};function at(a,e,t,s,i,o){var l;return t.importReportLayers?r.createCommentVNode("",!0):(r.openBlock(),r.createElementBlock("div",We,[r.createElementVNode("div",{class:"menu-bar-box",style:r.normalizeStyle({top:t.top,right:t.right})},[r.createElementVNode("div",Oe,[r.createElementVNode("div",{class:r.normalizeClass(i.showLayers?"menu-icon active":"menu-icon"),onClick:e[0]||(e[0]=n=>i.showLayers=!i.showLayers)},e[7]||(e[7]=[r.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),r.createElementVNode("div",Fe,[r.createElementVNode("div",{class:r.normalizeClass(i.showMeasure?"menu-icon active":"menu-icon"),onClick:e[1]||(e[1]=(...n)=>o.handleMeasureToggle&&o.handleMeasureToggle(...n))},e[8]||(e[8]=[r.createElementVNode("span",{class:"iconfont"},"",-1)]),2),r.createElementVNode("div",{class:r.normalizeClass(i.showPoint?"menu-icon active":"menu-icon"),onClick:e[2]||(e[2]=(...n)=>o.handlePointToggle&&o.handlePointToggle(...n))},e[9]||(e[9]=[r.createElementVNode("span",{class:"iconfont"},"",-1)]),2),r.createElementVNode("div",{class:r.normalizeClass(i.showCoord?"menu-icon active":"menu-icon"),onClick:e[3]||(e[3]=(...n)=>o.handleCoordToggle&&o.handleCoordToggle(...n))},e[10]||(e[10]=[r.createElementVNode("span",{class:"iconfont"},"",-1)]),2)])],4),r.createElementVNode("div",{class:"all-layers-box",style:r.normalizeStyle({bottom:i.showLayers?0:"-105vh"})},[r.createElementVNode("div",{class:"mask",onClick:e[4]||(e[4]=n=>i.showLayers=!1)}),r.createElementVNode("div",je,[r.createElementVNode("div",$e,[r.createElementVNode("div",Ue,[e[12]||(e[12]=r.createElementVNode("div",{class:"title",style:{}},[r.createElementVNode("div",null,"Weather Layers")],-1)),r.createElementVNode("div",Ge,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(i.layers.weather.filter(n=>n.h5&&n.enabled),n=>(r.openBlock(),r.createElementBlock("div",{key:n.key,class:r.normalizeClass(o.computeLayerPngClass(n,i.weatherLayers)),onClick:c=>o.handleWeatherLayerPick(n)},[e[11]||(e[11]=r.createElementVNode("span",{class:"iconfont pin-icon"},"",-1)),r.createElementVNode("img",{class:"layer-png",src:`${i.weatherLayerImgUrl}${n.key}.jpeg`},null,8,qe),r.createElementVNode("div",Xe,r.toDisplayString(n.name),1)],10,He))),128))])]),r.createElementVNode("div",Ze,[e[14]||(e[14]=r.createElementVNode("div",{class:"title"},"Display on Map",-1)),r.createElementVNode("div",Je,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList((l=i.layers.other)==null?void 0:l.filter(n=>n.h5&&n.enabled&&n.key!=="enc"),n=>(r.openBlock(),r.createElementBlock("div",{key:n.key,class:r.normalizeClass(o.computeLayerSwitch(n,i.otherLayers))},[r.createElementVNode("span",Ye,r.toDisplayString(n.name),1),r.createElementVNode("span",{class:"iconfont switch-on",onClick:c=>o.handleOtherLayerPick(n)},"",8,Ke),r.createElementVNode("span",{class:"iconfont switch-off",onClick:c=>o.handleOtherLayerPick(n)},"",8,Qe)],2))),128)),r.createElementVNode("div",et,[e[13]||(e[13]=r.createElementVNode("span",{class:"text"},"Forecast Model",-1)),r.createElementVNode("div",tt,[r.createElementVNode("span",{class:r.normalizeClass(i.source==="GFS"?"text active":"text"),onClick:e[5]||(e[5]=n=>o.handleSourceToggle("GFS"))},"GFS",2),r.createElementVNode("span",{class:r.normalizeClass(i.source==="CMEMS"?"text active":"text"),onClick:e[6]||(e[6]=n=>o.handleSourceToggle("CMEMS"))},"ECMWF",2)])])])])])])],4)]))}const it=V(Ve,[["render",at],["__scopeId","data-v-e63e3e9a"]]),j="#fff",Be={"000kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M512 245.76c-146.80064 0-266.24 119.43936-266.24 266.24s119.43936 266.24 266.24 266.24 266.24-119.43936 266.24-266.24-119.43936-266.24-266.24-266.24z m0 40.96c124.64128 0 225.28 100.63872 225.28 225.28s-100.63872 225.28-225.28 225.28-225.28-100.63872-225.28-225.28 100.63872-225.28 225.28-225.28z m0 81.92c-78.9504 0-143.36 64.4096-143.36 143.36s64.4096 143.36 143.36 143.36 143.36-64.4096 143.36-143.36-64.4096-143.36-143.36-143.36z m0 40.96c56.79104 0 102.4 45.60896 102.4 102.4s-45.60896 102.4-102.4 102.4-102.4-45.60896-102.4-102.4 45.60896-102.4 102.4-102.4z" fill="${j}"></path></svg>`,"002kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M638 835.99999999c0-63.288-47.10599999-115.524-108-124.30799999L530.00000001 62l-36.00000002 0 1e-8 649.692c-60.894 8.784-108 61.02-108 124.30799999 0 69.39 56.61 126 126 126s126-56.61 126-126z m-36 1e-8c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"005kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M702.116 166.634l-20.232-29.25000001L530 243.674 530.00000001 62l-36.00000002 0 1e-8 649.692c-60.894 8.784-108 61.02-108 124.30799999 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.288-47.10599999-115.524-108-124.30799999L530 287zM602 836c0 49.91400001-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"010kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M702.116 94.634L681.88400001 65.384l-180.00000001 126-7.884 5.04 0 515.268c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L530 215zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}" ></path></svg>`,"015kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M702.116 94.634L681.88400001 65.384l-180.00000001 126-7.884 5.04 0 515.268c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L530 322.99999999l82.134-57.38399999-20.25-29.232L530 279.692 530 215zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"020kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M702.116 94.634L681.88400001 65.384l-180.00000001 126-7.884 5.04 0 515.268c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L530 322.99999999l172.134-120.38399999-20.268-29.24999999L530 279.71 530 215zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"025kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M702.116 94.634L681.88400001 65.384l-180.00000001 126-7.884 5.04 0 515.268c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L529.99999999 431l82.13400001-57.384-20.25-29.25L530 387.71 530 322.99999999l172.134-120.38399999-20.268-29.24999999L530 279.71 530 215zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"030kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M702.116 94.634L681.88400001 65.384l-180.00000001 126-7.884 5.04 0 515.268c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L529.99999999 431l172.13400001-120.384-20.26800001-29.232L530 387.674 530 322.99999999l172.134-120.38399999-20.268-29.24999999L530 279.71 530 215zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"035kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M702.116 94.634L681.88400001 65.384l-180.00000001 126-7.884 5.04 0 515.268c-60.894 8.80199999-108 61.056-108 124.308 0 69.372 56.628 126 126 126s126-56.628 126-126c0-63.252-47.106-115.506-108-124.308L530 539l82.134-57.38400001-20.25-29.24999999L529.99999999 495.71 529.99999999 431l172.13400001-120.384-20.26800001-29.232L530 387.674 530 322.99999999l172.134-120.38399999-20.268-29.24999999L530 279.71 530 215l172.134-120.384zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"040kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M702.116 94.634L681.88400001 65.384l-180.00000001 126-7.884 5.04 0 515.268c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L530 539l172.134-120.384-20.268-29.25L529.99999999 495.71 529.99999999 431l172.13400001-120.384-20.26800001-29.232L530 387.674 530 322.99999999l172.134-120.38399999-20.268-29.24999999L530 279.71 530 215zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"045kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M702.116 94.634L681.88400001 65.384l-180.00000001 126-7.884 5.04 0 515.268c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L530 647l82.13400001-57.384-20.25000001-29.25L530 603.71 530 539l172.134-120.384-20.268-29.25L529.99999999 495.71 529.99999999 431l172.13400001-120.384-20.26800001-29.232L530 387.674 530 322.99999999l172.134-120.38399999-20.268-29.24999999L530 279.71 530 215zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"050kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.366 62L494 62l0 649.692c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L530 215l172.134-120.384zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}" ></path></svg>`,"055kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.366 62L494 62l0 649.692c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L530 322.99999999l82.134-57.38399999-20.25-29.232L530 279.692 530 215l172.134-120.384zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}" ></path></svg>`,"060kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.366 62L494 62l0 649.692c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L530 322.99999999l135.558-94.49999999-20.25000001-29.808-115.30799999 81L530 215l172.134-120.384zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}" ></path></svg>`,"065kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.096 62L494 62l1e-8 649.44c-60.894 8.82-108 61.308-108.00000001 124.56 0 69.372 56.628 126 126 126s126-56.628 126-126c0-63.252-47.106-115.74-108.00000001-124.56L530 431.36l82.332-57.636-20.664-29.448L530 387.44l0-64.08 135.774-95.004-20.646-29.484L530 279.44 529.99999999 215.378 749.096 62zM602 836c0 49.932-40.068 90-90 90s-90-40.068-90-90 40.068-90 90-90 90 40.068 90 90z" fill="${j}" ></path></svg>`,"070kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.096 62L494 62l1e-8 649.44c-60.87599999 8.82-108 61.308-108.00000001 124.56 0 69.372 56.628 126 126 126s126-56.628 126-126c0-63.252-47.124-115.74-108.00000001-124.56L530 431.36l135.774-95.004-20.646-29.48399999L530 387.44l0-64.08 135.774-95.004-20.646-29.484L530 279.44 529.99999999 215.378 749.096 62zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"075kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.096 62L494 62l1e-8 649.44c-60.87599999 8.82-108 61.308-108.00000001 124.56 0 69.372 56.628 126 126 126s126-56.628 126-126c0-63.252-47.124-115.74-108.00000001-124.56l0-172.08 82.33200001-57.636-20.664-29.448L530 495.44l0-64.08 135.774-95.004-20.646-29.48399999L530 387.44l0-64.08 135.774-95.004-20.646-29.484L530 279.44 529.99999999 215.378 749.096 62zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"080kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.096 62L494 62l1e-8 649.44c-60.87599999 8.82-108 61.308-108.00000001 124.56 0 69.372 56.628 126 126 126s126-56.628 126-126c0-63.252-47.124-115.74-108.00000001-124.56l0-172.08 135.774-95.004-20.64599999-29.484L530 495.44l0-64.08 135.774-95.004-20.646-29.48399999L530 387.44l0-64.08 135.774-95.004-20.646-29.484L530 279.44 529.99999999 215.378 749.096 62zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"085kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.096 62L494 62l1e-8 649.44c-60.87599999 8.82-108 61.308-108.00000001 124.56 0 69.372 56.628 126 126 126s126-56.628 126-126c0-63.252-47.124-115.74-108.00000001-124.56l1e-8-64.08 82.332-57.636-20.664-29.44800001L529.99999999 603.44l0-64.08 135.774-95.004-20.64599999-29.484L530 495.44l0-64.08 135.774-95.004-20.646-29.48399999L530 387.44l0-64.08 135.774-95.004-20.646-29.484L530 279.44 529.99999999 215.378 749.096 62zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"090kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.096 62L494 62l1e-8 649.44c-60.87599999 8.82-108 61.308-108.00000001 124.56 0 69.372 56.628 126 126 126s126-56.628 126-126c0-63.252-47.124-115.74-108.00000001-124.56l1e-8-64.08 135.774-95.004-20.646-29.484L529.99999999 603.44l0-64.08 135.774-95.004-20.64599999-29.484L530 495.44l0-64.08 135.774-95.004-20.646-29.48399999L530 387.44l0-64.08 135.774-95.004-20.646-29.484L530 279.44 529.99999999 215.378 749.096 62zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}"></path></svg>`,"095kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.096 62L494 62l1e-8 649.44c-60.87599999 8.82-108 61.308-108.00000001 124.56 0 69.372 56.628 126 126 126s126-56.628 126-126c0-63.252-47.124-115.74-108.00000001-124.56l1e-8-46.08 82.332-57.636-20.664-29.448L530 621.44l0-46.08 135.774-95.004-20.64600001-29.484L530 531.44l0-46.08 135.774-95.004-20.646-29.484L529.99999999 441.44l0-46.08 135.774-95.004-20.64599999-29.484L530 351.44l0-46.08 135.774-95.004-20.646-29.48400001L530 261.44 529.99999999 215.378 749.096 62zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}" ></path></svg>`,"100kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.366 62L494 62l0 649.692c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L530 360.116 746 206l-203.058 0 159.174-111.384zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}" ></path></svg>`,"105kts":`<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M749.366 62L494 62l0 649.692c-60.894 8.784-108 61.02-108 124.308 0 69.39 56.61 126 126 126s126-56.61 126-126c0-63.28800001-47.106-115.524-108-124.308L530 467l135.558-94.5-20.25000001-29.808-115.30799999 81 0-63.576L746 206l-203.058 0 159.174-111.384zM602 836c0 49.91399999-40.086 90-90 90s-90-40.086-90-90 40.086-90 90-90 90 40.086 90 90z" fill="${j}" ></path></svg>`},Vi="",rt={name:"IdmWindBarb",props:{map:{type:Object},wind:{type:Object},beforeLayer:{type:String},left:{type:String,default:"10px"},bottom:{type:String,default:"280px"},right:{type:String,default:"10px"},showParticle:{type:Boolean,default:!1},importReportLayers:{type:Boolean,default:!1}},emits:["particle"],data(){return{source:"wind-barb-source",windSvg:Be,barbs:[0,2,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105],empty:E.featureCollection([]),showFeather:!1}},watch:{"wind.version":{handler(){var a;(a=this.wind)!=null&&a.active&&this.showFeather?this.handleRender():this.handleClear()},deep:!0},showParticle:{handler(){this.showFeather=!this.showParticle}},showFeather:{handler(){var a,e;this.handleParticle(),this.handleToggle(),this.showFeather&&((e=(a=this.map)==null?void 0:a.getLayer("grayland"))==null||e.setPaintProperty("raster-color","#bbbfc2"))}},importReportLayers:{handler(){this.importReportLayers&&setTimeout(()=>{this.showFeather=!0},200)},immediate:!0}},methods:{handleParticle(){this.$emit("particle",{particle:!this.showFeather,key:"wind",weight:1})},handleRender(){var a,e,t,s;if(!this.map)setTimeout(()=>{this.handleRender()},500);else if(this.wind){const i=new Date().valueOf();let o=0,l=0,n=this.empty;if((a=this.wind)!=null&&a.active&&(n=(e=this.wind)==null?void 0:e.data),(t=this.map)!=null&&t.getSource(this.source))(s=this.map)==null||s.getSource(this.source).setData(n),l=new Date().valueOf()-(i+o),console.log("[wind] update elapsed: ",l,", total: ",o+=l);else{this.map.addSource(this.source,{type:"geojson",data:n});for(let c=0;c<(this.barbs??[]).length-1;c++){const d=(this.barbs??[])[c]||0,h=(this.barbs??[])[c+1]||0,p=d<10?`00${d}kts`:d<100?`0${d}kts`:`${d}kts`,f=new Image(72,72),_=Be[p],k="data:image/svg+xml;base64,"+window.btoa(unescape(encodeURIComponent(_)));f.src=k,f.onload=()=>{this.map.hasImage("barbIcon"+p)||this.map.addImage("barbIcon"+p,f),this.map.addLayer({id:p,type:"symbol",filter:["all",[">=","spd",d],["<","spd",h]],source:this.source,layout:{"symbol-placement":"point","icon-image":"barbIcon"+p,"icon-size":{base:1,stops:[[2,.3],[6,.5]]},"icon-offset":[0,-20],"icon-allow-overlap":!0,"icon-rotation-alignment":"map","icon-rotate":{property:"dir",stops:[[0,0],[360,360]]}},paint:{"icon-opacity":1}},this.beforeLayer),this.handleToggle()}}l=new Date().valueOf()-(i+o),console.log("[wind] add elapsed: ",l,", total: ",o+=l)}this.handleToggle()}},handleToggle(){for(const a of this.barbs??[]){const e=a<10?`00${a}kts`:a<100?`0${a}kts`:`${a}kts`;this.map.getLayer(e)&&this.map.setLayoutProperty(e,"visibility",this.showFeather?"visible":"none")}},handleClear(){for(const a of this.barbs??[]){const e=a<10?`00${a}kts`:a<100?`0${a}kts`:`${a}kts`;this.map.getLayer(e)&&this.map.removeLayer(e)}this.map.getSource(this.source)&&this.map.removeSource(this.source)}}},st={class:"switch-box"};function ot(a,e,t,s,i,o){var l;return(l=t.wind)!=null&&l.active&&!t.importReportLayers?(r.openBlock(),r.createElementBlock("div",{key:0,style:r.normalizeStyle({position:"absolute",right:t.right,bottom:t.bottom})},[r.createElementVNode("div",st,[i.showFeather?(r.openBlock(),r.createElementBlock("span",{key:0,class:"iconfont switch-on",onClick:e[0]||(e[0]=n=>i.showFeather=!1)},"")):r.createCommentVNode("",!0),i.showFeather?r.createCommentVNode("",!0):(r.openBlock(),r.createElementBlock("span",{key:1,class:"iconfont switch-off",onClick:e[1]||(e[1]=n=>i.showFeather=!0)},""))])],4)):r.createCommentVNode("",!0)}const nt=V(rt,[["render",ot],["__scopeId","data-v-d546ae7a"]]);class Te{constructor(e){X(this,"map");X(this,"mercator");X(this,"rampColorLayer");X(this,"rampColorSource");X(this,"particleLayer");X(this,"particleSource");X(this,"rampColorCanvas");X(this,"particleCanvas");X(this,"ratio");this.map=e,this.mercator=new Ne,this.rampColorLayer="ramp-color-layer",this.rampColorSource="ramp-color-source",this.particleLayer="particle-layer",this.particleSource="particle-source",this.rampColorCanvas=document.createElement("canvas"),this.particleCanvas=document.createElement("canvas"),this.ratio=window.devicePixelRatio}convertNLng(e,t=0){return e>180?this.convertNLng(e-360,t+1):e<-180?this.convertNLng(e+360,t+1):[e,t]}getBoundLngLat(){const e=this.map.getBounds();return[[e._sw.lng,e._ne.lat],[e._ne.lng,e._ne.lat],[e._ne.lng,e._sw.lat],[e._sw.lng,e._sw.lat]]}getBoundPixel(){const e=this.map.getBounds(),t=this.map.getZoom()+1,s=[e._ne.lng,e._ne.lat],i=[e._sw.lng,e._sw.lat],[o,l]=this.convertNLng(s[0]),[n,c]=this.convertNLng(i[0]),[d,h]=this.mercator.px([o,s[1]],t),[p,f]=this.mercator.px([n,i[1]],t),_=Math.round(this.mercator.size*Math.pow(2,t)*(l+c));return[p,f,d+_,h]}getBoundRange(){const e=this.map.getZoom()+1,t=this.mercator.size*Math.pow(2,e),s=this.getBoundPixel();return[s[0]/t,s[2]/t,s[3]/t,s[1]/t]}getWorldCopy(e,t){const s=2**t,[i,o,l,n]=e.map(h=>~~(h/(s*256))),c=[];for(let h=n;h<=o;h++)for(let p=i;p<=l;p++)c.push([p,h]);return c.map(h=>{const p=2**t*256;return[h[0]*p,h[1]*p,p]})}resize(){let e=this.map.getSource(this.rampColorSource);e.setCoordinates(this.getBoundLngLat()),e=this.map.getSource(this.particleSource),e.setCoordinates(this.getBoundLngLat()),this.rampColorCanvas.width=this.map._canvas.clientWidth,this.rampColorCanvas.height=this.map._canvas.clientHeight,this.particleCanvas.width=this.map._canvas.clientWidth,this.particleCanvas.height=this.map._canvas.clientHeight}toggle(e){this.map.setLayoutProperty(this.rampColorLayer,"visibility",e?"visible":"none")}toggleParticle(e){this.map.setLayoutProperty(this.particleLayer,"visibility",e?"visible":"none")}}class be{createShader(e,t,s){const i=e.createShader(t);if(i&&(e.shaderSource(i,s),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS)))throw new Error(e.getShaderInfoLog(i)||"error happened while create shader...");return i}createTexture(e,t,s,i,o,l,n){const c=e.createTexture();return e.bindTexture(e.TEXTURE_2D,c),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,s),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,i),o instanceof Uint8Array?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,l,n,0,e.RGBA,e.UNSIGNED_BYTE,o):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o),e.bindTexture(e.TEXTURE_2D,null),c}createDataBuffer(e,t,s){if(e){const i=e.createBuffer();return t==="array"?(e.bindBuffer(e.ARRAY_BUFFER,i),s&&e.bufferData(e.ARRAY_BUFFER,s,e.STATIC_DRAW)):t==="element"&&(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i),s&&e.bufferData(e.ELEMENT_ARRAY_BUFFER,s,e.STATIC_DRAW)),i}return null}createProgram(e,t,s){const i=e.createProgram(),o=this.createShader(e,e.VERTEX_SHADER,t),l=this.createShader(e,e.FRAGMENT_SHADER,s);if(i&&o&&l&&(e.attachShader(i,o),e.attachShader(i,l),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS)))throw new Error(e.getProgramInfoLog(i)||"error happened while creating ramp color program");return i}createProgramWrapper(e,t,s){const i=this.createProgram(e,t,s);if(i){const o={program:i},l=e.getProgramParameter(i,e.ACTIVE_ATTRIBUTES);for(let c=0;c<l;c++){const d=e.getActiveAttrib(i,c);o[d.name]=e.getAttribLocation(i,d.name)}const n=e.getProgramParameter(i,e.ACTIVE_UNIFORMS);for(let c=0;c<n;c++){const d=e.getActiveUniform(i,c);o[d.name]=e.getUniformLocation(i,d.name)}return o}}setup(e,t,s=!1,i,o){const l=document.createElement("canvas");l.width=256,l.height=1;const n=l.getContext("2d");if(n&&e){const c=n==null?void 0:n.createLinearGradient(0,0,256,0);return t.forEach(([d,h])=>{c.addColorStop(d,h)}),n.fillStyle=c,n.fillRect(0,0,256,1),{canvas:l,texture:this.createTexture(e,e.LINEAR,e.LINEAR,e.CLAMP_TO_EDGE,s?new Uint8Array(n.getImageData(0,0,256,1).data):l,i,o)}}}setupParticle(e,t=1e3){const s=Math.ceil(Math.sqrt(t)),i=s*s,o=new Uint8Array(i*4);for(let h=0;h<o.length;h++)o[h]=Math.floor(Math.random()*256);const l=this.createTexture(e,e.NEAREST,e.NEAREST,e.CLAMP_TO_EDGE,o,s,s),n=this.createTexture(e,e.NEAREST,e.NEAREST,e.CLAMP_TO_EDGE,o,s,s),c=new Float32Array(i);for(let h=0;h<i;h++)c[h]=h;const d=this.createDataBuffer(e,"array",c);return{resolution:s,total:i,texture0:l,texture1:n,indexBuffer:d}}bind(e,t,s){const i=this.createProgram(e,t,s);if(i){const o=this.createDataBuffer(e,"array",void 0),l=e.getAttribLocation(i,"a_position");e.enableVertexAttribArray(l),e.vertexAttribPointer(l,2,e.FLOAT,!1,0,0);const n=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);this.createDataBuffer(e,"array",n);const c=e.getAttribLocation(i,"a_texCoord");return e.enableVertexAttribArray(c),e.vertexAttribPointer(c,2,e.FLOAT,!1,0,0),{program:i,aPositionBuffer:o}}return{}}bindParticle(e,t,s,i,o,l){const n=this.createProgramWrapper(e,t,s),c=this.createProgramWrapper(e,i,o),d=this.createProgramWrapper(e,i,l),h=this.createDataBuffer(e,"array",new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1])),p=e.createFramebuffer();return{particle:n,screen:c,update:d,quadBuffer:h,frameBuffer:p}}draw(e,t,s,i,o,l,n){var c,d;if(t&&s){e.resize(),t==null||t.viewport(0,0,(c=t==null?void 0:t.canvas)==null?void 0:c.width,(d=t==null?void 0:t.canvas)==null?void 0:d.height),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT);try{const h=t.getUniformLocation(s,"u_resolution"),p=t.getUniformLocation(s,"u_image"),f=t.getUniformLocation(s,"u_color");if(t.useProgram(s),t.uniform2f(h,t.canvas.width*e.ratio,t.canvas.height*e.ratio),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,i),t.uniform1i(p,0),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,o),t.uniform1i(f,1),n!=null&&n.uvRange&&(n!=null&&n.sRange)){const C=t.getUniformLocation(s,"u_range_u_v"),g=t.getUniformLocation(s,"u_range_s");t.uniform2f(C,n.uvRange[0],n.uvRange[1]),t.uniform2f(g,n.sRange[0],n.sRange[1])}const _=t.getUniformLocation(s,"u_scale");t.uniform1f(_,(n==null?void 0:n.scale)||1);const k=e.getBoundPixel(),v=e.map.getZoom()+1,w=e.getWorldCopy(k,v);for(const C of w){const g=(C[0]-k[0])*e.ratio,b=(C[1]-k[3])*e.ratio,y=C[2]*e.ratio,[u,m,L,T]=[g,y+g,b,y+b],z=new Float32Array([u,L,m,L,u,T,u,T,m,L,m,T]);t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,z,t.STATIC_DRAW),t.drawArrays(t.TRIANGLES,0,6)}}catch(h){console.log(`render failed...${h}`)}}}drawParticle(e,t,s,i,o){var l,n;t&&(t==null||t.viewport(0,0,(l=t==null?void 0:t.canvas)==null?void 0:l.width,(n=t==null?void 0:t.canvas)==null?void 0:n.height),t.disable(t.DEPTH_TEST),t.disable(t.STENCIL_TEST),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,s),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,i.texture0),this.renderScreen(e,t,i,o),this.updateParticles(e,t,i,o))}renderScreen(e,t,s,i){t.bindFramebuffer(t.FRAMEBUFFER,s.frameBuffer),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s.screenTexture,0),t.viewport(0,0,t.canvas.width,t.canvas.height),this.renderScreenTexture(t,s.backgroundTexture,s.screen,s.quadBuffer,.95),this.renderParticles(e,t,s,i),t.bindFramebuffer(t.FRAMEBUFFER,null),this.renderScreenTexture(t,s.screenTexture,s.screen,s.quadBuffer,.6);const o=s.backgroundTexture;s.backgroundTexture=s.screenTexture,s.screenTexture=o}renderScreenTexture(e,t,s,i,o){e&&(e.useProgram(s.program),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(s.a_pos),e.vertexAttribPointer(s.a_pos,2,e.FLOAT,!1,0,0),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,t),e.uniform1i(s.u_screen,2),e.uniform1f(s.u_opacity,o),e.drawArrays(e.TRIANGLES,0,6))}renderParticles(e,t,s,i){if(t){t.useProgram(s.particle.program),t.bindBuffer(t.ARRAY_BUFFER,s.indexBuffer),t.enableVertexAttribArray(s.particle.a_index),t.vertexAttribPointer(s.particle.a_index,1,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,s.color.texture),t.uniform1i(s.particle.u_factor,0),t.uniform1i(s.particle.u_particles,1),t.uniform1i(s.particle.u_color_ramp,2),t.uniform1f(s.particle.u_particles_resolution,s.resolution*e.ratio),t.uniform1f(s.particle.u_point,e.ratio);const o=e.getBoundRange();t.uniform4f(s.particle.u_viewport,o[0],o[1],o[2],o[3]),t.uniform2f(s.particle.u_factor_min,i.uvRange[0],i.uvRange[0]),t.uniform2f(s.particle.u_factor_max,i.uvRange[1],i.uvRange[1]),t.drawArrays(t.POINTS,0,s.total)}}updateParticles(e,t,s,i){var l,n;if(t){t.bindFramebuffer(t.FRAMEBUFFER,s.frameBuffer),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s.texture1,0),t.viewport(0,0,s.resolution,s.resolution),t.useProgram(s.update.program),t.bindBuffer(t.ARRAY_BUFFER,s.quadBuffer),t.enableVertexAttribArray(s.update.a_pos),t.vertexAttribPointer(s.update.a_pos,2,t.FLOAT,!1,0,0),t.uniform1i(s.update.u_factor,0),t.uniform1i(s.update.u_particles,1);const c=e.getBoundRange();t.uniform4f(s.update.u_viewport,c[0],c[1],c[2],c[3]),t.uniform1f(s.update.u_rand_seed,Math.random()),t.uniform2f(s.update.u_factor_res,(l=s==null?void 0:s.image)==null?void 0:l.width,(n=s==null?void 0:s.image)==null?void 0:n.height),t.uniform2f(s.update.u_factor_min,i.uvRange[0],i.uvRange[0]),t.uniform2f(s.update.u_factor_max,i.uvRange[1],i.uvRange[1]),t.uniform1f(s.update.u_speed_factor,i.speedFactor*e.ratio),t.uniform1f(s.update.u_drop_rate,i.dropRate),t.uniform1f(s.update.u_drop_rate_bump,i.dropRateBump),t.drawArrays(t.TRIANGLES,0,6)}const o=s.texture0;s.texture0=s.texture1,s.texture1=o}resize(e,t){e.resize();const s=new Uint8Array(t.canvas.width*t.canvas.height*4).fill(0,0,t.canvas.width*t.canvas.height*4),i=this.createTexture(t,t.NEAREST,t.NEAREST,t.CLAMP_TO_EDGE,s,t.canvas.width,t.canvas.height),o=this.createTexture(t,t.NEAREST,t.NEAREST,t.CLAMP_TO_EDGE,s,t.canvas.width,t.canvas.height);return{screenTexture:i,backgroundTexture:o}}async loadImg(e){return new Promise(t=>{const s=new Blob([e],{type:e.type}),i=URL.createObjectURL(s),o=new Image;o.crossOrigin="anonymous",o.src=i,o.onload=()=>t(o)})}}class U{}X(U,"vertexSchema",`
//canvas 坐标系上的坐标 (x, y)
attribute vec2 a_position; //像素坐标
attribute vec2 a_texCoord; //纹理坐标
// canvas 宽高
uniform vec2 u_resolution; //全局变量
varying vec2 v_texCoord; //向fragmentSchema传值
void main() {
// 将屏幕坐标系转化为裁剪坐标(裁剪坐标系) convert the position from pixels to 0.0 to 1.0
vec2 position = (a_position / u_resolution) * 2.0 - 1.0;
// canvas的 Y 轴坐标方向和 设备坐标系的相反
gl_Position = vec4(position * vec2(1, -1), 0.0, 1.0);
v_texCoord = a_texCoord;
}`),X(U,"uvFragmentSchema",`
precision mediump float;
uniform sampler2D u_image;
uniform vec2 u_range_u_v;
uniform vec2 u_range_s;
uniform float u_scale;
uniform sampler2D u_color;
varying vec2 v_texCoord;
void main() {
vec4 uv = texture2D(u_image, v_texCoord);
float u = uv.r * (u_range_u_v.y - u_range_u_v.x) + u_range_u_v.x;
float v = uv.g * (u_range_u_v.y - u_range_u_v.x) + u_range_u_v.x;
float s = sqrt(u * u + v * v) * u_scale;
float r = (s - u_range_s.x) / (u_range_s.y - u_range_s.x);
float f = 1.0 - uv.b;
vec4 color = texture2D(u_color, vec2(r, 0.5)) * f;
gl_FragColor = color;
}`),X(U,"fragmentSchema",`
precision mediump float;
uniform sampler2D u_image; // 灰度
uniform sampler2D u_color; // 色值映射
varying vec2 v_texCoord;// 坐标
void main() {
vec4 rgba = texture2D(u_image, v_texCoord);
vec4 color = texture2D(u_color, vec2(rgba.r, 0));
gl_FragColor = color;
}`);class Y{}X(Y,"vertexSchema",`
precision highp float;
attribute float a_index; // 索引
uniform sampler2D u_particles; // 粒子纹理
uniform float u_particles_resolution; // Math.ceil(Math.sqrt(numParticles)))
uniform float u_point;
uniform vec4 u_viewport;
varying vec2 v_particle_pos_uv;
void main() {
vec4 color = texture2D(u_particles, vec2(
fract(a_index / u_particles_resolution),
floor(a_index / u_particles_resolution) / u_particles_resolution));
vec2 v_particle_pos = vec2(color.r / 255.0 + color.b, color.g / 255.0 + color.a);
v_particle_pos_uv = vec2(fract(v_particle_pos.x * (u_viewport.y - u_viewport.x) + u_viewport.x), v_particle_pos.y * (u_viewport.w - u_viewport.z) + u_viewport.z);
gl_PointSize = 1.0;
// gl_PointSize = u_point;
gl_Position = vec4(2.0 * v_particle_pos.x - 1.0, 1.0 - 2.0 * v_particle_pos.y, 0, 1);
}`),X(Y,"fragmentSchema",`
precision highp float;
uniform sampler2D u_factor;
uniform vec2 u_factor_min;
uniform vec2 u_factor_max;
uniform sampler2D u_color_ramp;
varying vec2 v_particle_pos_uv;
void main() {
vec4 uv = texture2D(u_factor, v_particle_pos_uv);
vec2 velocity = mix(u_factor_min, u_factor_max, uv.rg);
float speed_t = length(velocity) / length(u_factor_max);
// color ramp is encoded in a 16x16 texture
vec2 ramp_pos = vec2(
fract(16.0 * speed_t),
floor(16.0 * speed_t) / 16.0);
float f = 1.0 - uv.b;
gl_FragColor = texture2D(u_color_ramp, ramp_pos) * f;
}`),X(Y,"quadVertSchema",`
precision highp float;
attribute vec2 a_pos;
varying vec2 v_tex_pos;
void main() {
v_tex_pos = a_pos;
gl_Position = vec4(1.0 - 2.0 * a_pos, 0, 1);
}`),X(Y,"screenFragmentSchema",`
precision highp float;
uniform sampler2D u_screen;
uniform float u_opacity;
varying vec2 v_tex_pos;
void main() {
vec4 color = texture2D(u_screen, 1.0 - v_tex_pos);
// a hack to guarantee opacity fade out even with a value close to 1.0
gl_FragColor = vec4(floor(255.0 * color * u_opacity) / 255.0);
}`),X(Y,"updateFragmentSchema",`
precision highp float;
uniform sampler2D u_particles;
uniform sampler2D u_factor;
uniform vec2 u_factor_res;
uniform vec2 u_factor_min;
uniform vec2 u_factor_max;
uniform float u_rand_seed;
uniform float u_speed_factor;
uniform float u_drop_rate;
uniform float u_drop_rate_bump;
uniform vec4 u_viewport;
varying vec2 v_tex_pos;
// pseudo-random generator
const vec3 rand_constants = vec3(989.6543, 43.456, 287.6543);
float rand(const vec2 co) {
float t = dot(rand_constants.xy, co);
return fract(sin(t) * (rand_constants.z + t));
}
// factor speed lookup; use manual bilinear filtering based on 4 adjacent pixels for smooth interpolation
vec2 lookup_factor(const vec2 uv) {
vec2 px = 1.0 / u_factor_res;
vec2 vc = (floor(uv * u_factor_res)) * px;
vec2 f = fract(uv * u_factor_res);
vec2 tl = texture2D(u_factor, vc).rg;
vec2 tr = texture2D(u_factor, vc + vec2(px.x, 0)).rg;
vec2 bl = texture2D(u_factor, vc + vec2(0, px.y)).rg;
vec2 br = texture2D(u_factor, vc + px).rg;
return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);
}
void main() {
vec4 color = texture2D(u_particles, v_tex_pos);
// decode particle position from pixel RGBA
vec2 pos = vec2(
color.r / 255.0 + color.b,
color.g / 255.0 + color.a);
vec2 pos_uv = vec2(
fract(pos.x * (u_viewport.y - u_viewport.x) + u_viewport.x),
pos.y * (u_viewport.w - u_viewport.z) + u_viewport.z);
vec2 velocity = mix(u_factor_min, u_factor_max, lookup_factor(pos_uv));
float speed_t = length(velocity) / length(u_factor_max);
float b = texture2D(u_factor, pos_uv).b;
float p = (b / -1.0) + 1.0;
velocity = velocity * p;
speed_t = speed_t * p;
// take EPSG:4236 distortion into account for calculating where the particle moved
float distortion = cos(radians(pos.y * 180.0 - 90.0));
// float distortion = cos(radians(pos.y * 180.0 - 90.0));
vec2 offset = vec2(velocity.x, -velocity.y) * 0.0001 * u_speed_factor;
// update particle position, wrapping around the date line
pos = fract(1.0 + pos + offset);
// a random seed to use for the particle drop
vec2 seed = (pos + v_tex_pos) * u_rand_seed;
// drop rate is a chance a particle will restart at random position, to avoid degeneration
float drop_rate = u_drop_rate + speed_t * u_drop_rate_bump;
float drop = step(1.0 - drop_rate, rand(seed));
vec2 random_pos = vec2(
rand(seed + 1.3),
rand(seed + 2.1));
pos = mix(pos, random_pos, drop);
// 将新的粒子位置编码回RGBA
gl_FragColor = vec4(
fract(pos * 255.0),
floor(pos * 255.0) / 255.0);
}`);const Wi="",lt={name:"IdmWindParticle",props:{factor:{type:Object},viewport:{type:Te},left:{type:String,default:"10px"},bottom:{type:String,default:"70px"},right:{type:String,default:"10px"},showParticle:{type:Boolean,default:!1}},emits:["toggleParticle"],data(){return{program:void 0,context:void 0,texture:void 0,rampColor:void 0,aPositionBuffer:void 0,webgl:new be,etime:void 0,wrapper:void 0,animation:void 0,particleContext:void 0,particleTexture:void 0,particleOptions:{fadeOpacity:.8,speedFactor:.1,dropRate:.002,dropRateBump:.01,uvRange:[-25,26],sRange:[0,31.985]},paused:!1,initial:!0}},watch:{"factor.version":{handler(){var a;(a=this.factor)!=null&&a.active?this.handleRender():this.handleClear()},deep:!0}},methods:{handleRender(){if(!this.viewport)setTimeout(()=>{this.handleRender()},500);else if(this.factor){const a=new Date().valueOf();let e=0,t=0;this.handleDraw(),t=new Date().valueOf()-(a+e),console.log("[wind-particle] add elapsed: ",t,", total: ",e+=t)}},handleClear(){var a,e,t,s,i,o,l;(a=this.viewport)==null||a.toggle(!1),this.context=void 0,this.particleContext=void 0,this.etime=void 0,this.initial=!0,(t=(e=this.viewport)==null?void 0:e.map)==null||t.off("resize",this.handleResize),(i=(s=this.viewport)==null?void 0:s.map)==null||i.off("movestart",this.handlePause),(l=(o=this.viewport)==null?void 0:o.map)==null||l.off("moveend",this.handlePlay),this.handlePause()},handleSetup(){if(!this.context){this.context=this.viewport.rampColorCanvas.getContext("webgl");const a=[[0,"rgb(98, 113, 184, 0.8)"],[12/255,"rgb(98, 113, 184)"],[24/255,"rgb(61, 110, 163)"],[32/255,"rgb(74, 146, 148)"],[40/255,"rgb(77, 142, 124)"],[60/255,"rgb(76, 164, 76)"],[80/255,"rgb(103, 164, 54)"],[100/255,"rgb(162, 135, 64)"],[120/255,"rgb(162, 109, 92)"],[140/255,"rgb(141, 63, 92)"],[160/255,"rgb(151, 75, 145)"],[200/255,"rgb(95, 100, 160)"],[240/255,"rgb(91, 136, 161)"],[1,"rgb(91, 136, 161)"]];this.rampColor=this.webgl.setup(this.context,a);const{program:e,aPositionBuffer:t}=this.webgl.bind(this.context,U.vertexSchema,U.uvFragmentSchema);this.program=e,this.aPositionBuffer=t}this.handleParticleSetup()},handleParticleSetup(){if(!this.particleContext){this.particleContext=this.viewport.particleCanvas.getContext("webgl");const a=[[0,"rgb(205,255,255)"],[1,"rgb(235,255,255)"]];this.wrapper=this.webgl.bindParticle(this.particleContext,Y.vertexSchema,Y.fragmentSchema,Y.quadVertSchema,Y.screenFragmentSchema,Y.updateFragmentSchema),this.wrapper.color=this.webgl.setup(this.particleContext,a,!0,16,16),this.wrapper={...this.wrapper,...this.webgl.setupParticle(this.particleContext,1e4),...this.webgl.resize(this.viewport,this.particleContext)},this.viewport.map.on("resize",this.handleResize),this.viewport.map.on("movestart",this.handlePause),this.viewport.map.on("moveend",this.handlePlay)}},async handleDraw(){this.handleSetup(),this.etime=this.factor.etime;const a=await this.webgl.loadImg(this.factor.raw);this.texture=this.webgl.createTexture(this.context,this.context.NEAREST,this.context.LINEAR,this.context.CLAMP_TO_EDGE,a),this.particleTexture=this.webgl.createTexture(this.particleContext,this.particleContext.NEAREST,this.particleContext.LINEAR,this.particleContext.CLAMP_TO_EDGE,a),this.wrapper.image=a,this.initial&&(this.initial=!1,this.handlePlay()),this.webgl.draw(this.viewport,this.context,this.program,this.texture,this.rampColor.texture,this.aPositionBuffer,this.particleOptions),this.viewport.toggle(!0)},handleResize(){this.wrapper={...this.wrapper,...this.webgl.resize(this.viewport,this.particleContext)}},handlePause(){this.paused=!0,this.animation&&(cancelAnimationFrame(this.animation),this.viewport.toggleParticle(!1))},handlePlay(){this.paused=!1,this.animation=requestAnimationFrame(()=>{this.webgl.drawParticle(this.viewport,this.particleContext,this.particleTexture,this.wrapper,this.particleOptions),this.viewport.toggleParticle(!0),this.handlePlay()})}}};function ct(a,e,t,s,i,o){var l;return(l=t.factor)!=null&&l.active?(r.openBlock(),r.createElementBlock("div",{key:0,style:r.normalizeStyle([{position:"absolute"},{right:t.right,bottom:t.bottom}])},e[0]||(e[0]=[r.createStaticVNode('<div class="legend-box" data-v-6f8dfce8><div class="content" data-v-6f8dfce8><div class="text-bars" data-v-6f8dfce8><span data-v-6f8dfce8>60</span><span data-v-6f8dfce8>40</span><span data-v-6f8dfce8>30</span><span data-v-6f8dfce8>20</span><span data-v-6f8dfce8>10</span><span data-v-6f8dfce8>5</span><span data-v-6f8dfce8>0</span></div><div class="legend-bars" data-v-6f8dfce8></div></div><div class="unit" data-v-6f8dfce8>kts</div></div>',1)]),4)):r.createCommentVNode("",!0)}const ht=V(lt,[["render",ct],["__scopeId","data-v-6f8dfce8"]]),Oi="",dt={name:"IdmCurrent",props:{map:{type:Object},current:{type:Object},beforeLayer:{type:String},left:{type:String,default:"10px"},bottom:{type:String,default:"280px"},right:{type:String,default:"10px"},showParticle:{type:Boolean,default:!1},marginBottom:{type:String,default:"30px"},importReportLayers:{type:Boolean,default:!1}},emits:["particle"],data(){return{source:"current-source",directionLayer:"current-direction-layer",speedLayer:"current-speed-layer",speedLabelLayer:"current-speed-label-layer",empty:E.featureCollection([]),showJson:!1}},watch:{"current.version":{handler(){var a;(a=this.current)!=null&&a.active&&this.showJson?this.handleRender():this.handleClear()},deep:!0},showParticle:{handler(){this.showJson=!this.showParticle}},showJson:{handler(){var a,e;this.handleToggle(),this.handleParticle(),this.showJson&&((e=(a=this.map)==null?void 0:a.getLayer("grayland"))==null||e.setPaintProperty("raster-color","#bbbfc2"))}},importReportLayers:{handler(){this.importReportLayers&&setTimeout(()=>{this.showJson=!0},200)},immediate:!0}},methods:{handleParticle(){this.$emit("particle",{particle:!this.showJson,key:"current",weight:96})},handleRender(){var a,e;if(!this.map)setTimeout(()=>{this.handleRender()},500);else if(this.current){const t=new Date().valueOf();let s=0,i=0,o=this.empty;if(this.current.active&&(o=this.current.data),(a=this.map)!=null&&a.getSource(this.source))(e=this.map)==null||e.getSource(this.source).setData(o),i=new Date().valueOf()-(t+s),console.log("[current] update elapsed: ",i,", total: ",s+=i);else{this.map.addSource(this.source,{type:"geojson",data:o}),this.map.addLayer({id:this.speedLayer,type:"fill",source:this.source,filter:["==","$type","Polygon"],paint:{"fill-outline-color":"silver","fill-opacity":.5,"fill-color":["step",["get","val"],"#e1ffb3",1,"#ffff00",3,"#ff9500",4,"#f44336",5,"#f44336"]}},this.beforeLayer),this.map.addLayer({id:this.speedLabelLayer,type:"symbol",source:this.source,filter:["==","$type","Polygon"],layout:{"symbol-placement":"line","text-field":"{val} kts","text-allow-overlap":!0,"text-rotation-alignment":"viewport","text-size":12},paint:{"text-color":"rgba(0, 0, 0, 0.8)"}},this.beforeLayer);const l=new Image(72,72),n=`<svg t="1720751120185" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9420" width="200" height="200">
<path d="M481.386772 959.514313 481.386772 334.713224c-56.000432 37.288255-92.523253 55.876612-142.312216 57.787124 85.834924-84.884272 130.528845-195.16188