@idmwx/idmui-gl3
Version:
idm webgl3
190 lines (154 loc) • 345 kB
JavaScript
(function(U,te){typeof exports=="object"&&typeof module<"u"?te(exports,require("@idm-plugin/tag"),require("moment"),require("axios"),require("vue"),require("@turf/turf"),require("@mapbox/sphericalmercator"),require("mapbox-gl"),require("@idm-plugin/geo"),require("@idm-plugin/meteo"),require("moment-timezone")):typeof define=="function"&&define.amd?define(["exports","@idm-plugin/tag","moment","axios","vue","@turf/turf","@mapbox/sphericalmercator","mapbox-gl","@idm-plugin/geo","@idm-plugin/meteo","moment-timezone"],te):(U=typeof globalThis<"u"?globalThis:U||self,te(U["idm-gl"]={},U["@idm-plugin/tag"],U.moment,U.axios,U.Vue,U["@turf/turf"],U["@mapbox/sphericalmercator"],U["mapbox-gl"],U["@idm-plugin/geo"],U["@idm-plugin/meteo"],U["moment-timezone"]))})(this,function(U,te,j,xe,t,qe,Je,Ie,W,De,Me){"use strict";var Do=Object.defineProperty;var No=(U,te,j)=>te in U?Do(U,te,{enumerable:!0,configurable:!0,writable:!0,value:j}):U[te]=j;var Z=(U,te,j)=>(No(U,typeof te!="symbol"?te+"":te,j),j);function Ze(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const a in i)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(i,a);Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>i[a]})}}return e.default=i,Object.freeze(e)}const P=Ze(qe),zo="",Po="",O=(i,e)=>{const a=i.__vccOpts||i;for(const[o,r]of e)a[o]=r;return a},$e={name:"IdmGlLayer",props:{map:{type:Object},mapProjection:{type:String},gateway:{type:String},token:{type:String},top:{type:Number,default:60},layerToggle:{type:Boolean,default:!1},toggleVersion:{type:Number},isLogin:{type:Boolean,default:void 0},showWindFeather:{type:Boolean,default:void 0},showWindParticle:{type:Boolean,default:void 0},showCurrentIsoband:{type:Boolean,default:void 0},showCurrentParticle:{type:Boolean,default:void 0},forecastModel:{type:String}},emits:["weather","other","toggleWindParticle","toggleWindFeather","toggleCurrentParticle","toggleCurrentIsoband","toggleWindParticeVersion","toggleCurrentParticeVersion","coordinate","measure","point","3d","layerToggle","handleToggleVersion","login","forecastModel"],data(){return{autoActive:!0,layers:{weather:[...te.LayerHelper.WEATHER_LAYERS.filter(i=>i.enabled&&!["swell-height","swell-direction","current-direction","current-speed"].includes(i.key))],other:[...te.LayerHelper.OTHER_LAYERS.filter(i=>i.enabled)]},activeWeatherLayers:[],activeWeatherLayersCollected:[],activeOtherLayers:[],autoActiveCache:"autoActiveCache",activeWeatherLayersCache:"activeWeatherLayersCache",activeOtherLayersCache:"activeOtherLayersCache",collectedLayerCache:"collectedLayerCache",sourceCache:"defaultSourceCache",windFeatherCollectedCache:"windFeatherCollectedCache",currentIsobandCollectedCache:"currentIsobandCollectedCache",showCoord:!1,showMeasure:!1,showPoint:!1,show3d:!1,version:{v:"0.1.1",k:"glCacheVersion"},source:"Best Match",sourceList:[],right:10,rampColorLayers:["visibility","precip3h","temp","water-temp","ice-thickness","ice-cover"],showWindParticleCollected:!1,showWindFeatherCollected:!0,showCurrentParticleCollected:!1,showCurrentIsobandCollected:!1}},computed:{computeLayerClass(){return function(i,e){var o;let a="layer flex-between";return e.some(r=>r.key===i.key)&&(a=a+" active"),(!i.enabled||(o=this.layers.weather)!=null&&o.some(r=>r.key===i.key)&&!this.autoActive||this.rampColorLayers.includes(i.key)&&this.mapProjection==="globe")&&(a=a+" disabled"),a}},hasCollectedLayers(){var i;return((i=this.layers.weather.filter(e=>e.collected))==null?void 0:i.length)>0},computeDateZ(){return function(i){var e;if(i){const a=j(i);return`${(e=a==null?void 0:a.utc())==null?void 0:e.format("MMM-DD/HHmm")}Z`}return"-"}},sourceCode(){var i;return(i=this.sourceList.find(e=>e.name===this.source))==null?void 0:i.code}},watch:{toggleVersion:{handler(){this.$nextTick(()=>{var i;this.right=(((i=document.getElementsByClassName("right-bar")[0])==null?void 0:i.clientWidth)||0)+10})}},source:{handler(i,e){i&&i!==e&&this.$emit("forecastModel",this.source),i&&e&&i!==e&&this.handleConfirm()}},activeWeatherLayers:{handler(i,e){this.autoActive&&(this.activeWeatherLayersCollected=this.activeWeatherLayers,localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify(this.activeWeatherLayers)))}},showWindParticle:{handler(i,e){this.autoActive&&(this.showWindParticleCollected=this.showWindParticle)}},showWindFeather:{handler(i,e){this.autoActive&&(this.showWindFeatherCollected=this.showWindFeather,localStorage.setItem(this.windFeatherCollectedCache,this.showWindFeatherCollected))}},showCurrentParticle:{handler(i,e){this.autoActive&&(this.showCurrentParticleCollected=this.showCurrentParticle)}},showCurrentIsoband:{handler(i,e){this.autoActive&&(this.showCurrentIsobandCollected=this.showCurrentIsoband,localStorage.setItem(this.currentIsobandCollectedCache,this.showCurrentIsobandCollected))}}},async mounted(){await this.fetchMeteoSource(),this.fetchCache(),this.handleConfirm()},methods:{async fetchMeteoSource(){var e;this.sourceList=[];let i=await xe.get(`${this.gateway}/api/arc/meteo2/models`,{headers:{Authorization:this.token}});(i==null?void 0:i.data.code)===0&&(this.sourceList=(e=i==null?void 0:i.data.data)==null?void 0:e.weather)},fetchCache(){const i=localStorage.getItem(this.version.k);this.version.v!==i&&(localStorage.removeItem(this.autoActiveCache),localStorage.removeItem(this.activeWeatherLayersCache),localStorage.removeItem(this.activeOtherLayersCache),localStorage.removeItem(this.windFeatherCollectedCache),localStorage.removeItem(this.currentIsobandCollectedCache),localStorage.setItem(this.version.k,this.version.v));let e=localStorage.getItem(this.autoActiveCache);this.autoActive=e!=="false",e=localStorage.getItem(this.collectedLayerCache);let a=JSON.parse(e||'[{"weight": 16, "name": "Sig Waves", "key": "sig-wave-height", "collected": true},{"weight": 1, "name": "Wind", "key": "wind", "h5": true, "collected": true},{"weight": 96, "name": "Current", "key": "current", "collected": true},{"weight": 256,"name": "Tropicals","key": "tropicals", "collected": true}]');this.layers.weather.forEach(o=>{o.collected=!!a.some(r=>r.key===o.key&&r.collected)}),e=localStorage.getItem(this.activeWeatherLayersCache),e||localStorage.setItem(this.activeWeatherLayersCache,JSON.stringify([{weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!1},{weight:16,name:"Sig Waves",key:"sig-wave-height",enabled:!0,type:"json"},{weight:256,name:"Tropicals",key:"tropicals",enabled:!0,type:"json"}])),e=localStorage.getItem(this.activeWeatherLayersCache),a=JSON.parse(e),this.autoActive?this.activeWeatherLayers=[...a]:this.activeWeatherLayersCollected=[...a],a.some(o=>o.key==="wind"&&o.particle)&&(this.$emit("toggleWindParticle",!0),this.showWindParticleCollected=!0),a.some(o=>o.key==="current"&&o.particle)&&(this.$emit("toggleCurrentParticle",!0),this.showCurrentParticleCollected=!0),this.showWindFeatherCollected=JSON.parse(localStorage.getItem(this.windFeatherCollectedCache))?JSON.parse(localStorage.getItem(this.windFeatherCollectedCache)):this.showWindFeatherCollected,this.showCurrentIsobandCollected=JSON.parse(localStorage.getItem(this.currentIsobandCollectedCache))?JSON.parse(localStorage.getItem(this.currentIsobandCollectedCache)):this.showCurrentIsobandCollected,this.autoActive&&(this.$emit("toggleWindFeather",this.showWindFeatherCollected),this.$emit("toggleCurrentIsoband",this.showCurrentIsobandCollected)),a.some(o=>o.key==="wind"&&!o.particle&&!this.showWindFeatherCollected)&&(a=a.filter(o=>o.key!=="wind")),a.some(o=>o.key==="current"&&!o.particle&&!this.showCurrentIsobandCollected)&&(a=a.filter(o=>o.key!=="current")),e=localStorage.getItem(this.activeOtherLayersCache),a=JSON.parse(e||'[{"weight":4,"name":"ECA Zones","key":"eca-zones","enabled":true,"type":"json"}, {"weight": 2048,"name": "ENC","key": "enc","h5": true,"enabled": true,"type": "origin"}]'),this.activeOtherLayers=a,e=localStorage.getItem(this.sourceCache),this.source=this.forecastModel?this.forecastModel:e?e==="CMEMS"?"ECMWF":e:this.source,this.$emit("forecastModel",this.source)},handleConfirm(){this.autoActive&&this.$emit("weather",JSON.parse(localStorage.getItem(this.activeWeatherLayersCache)),this.sourceCode),this.$emit("other",this.activeOtherLayers),localStorage.setItem(this.autoActiveCache,this.autoActive),localStorage.setItem(this.sourceCache,this.source)},handleWeatherLayerPick(i){if(this.activeWeatherLayers=JSON.parse(localStorage.getItem(this.activeWeatherLayersCache)),this.rampColorLayers.includes(i.key)&&this.mapProjection==="globe"||!this.autoActive)return!1;(i.key==="wind"&&!this.showWindFeather||i.key==="current"&&!this.showCurrentIsoband)&&(i.particle=!0),this.activeWeatherLayers.some(e=>e.key===i.key)?this.activeWeatherLayers=this.activeWeatherLayers.filter(e=>e.key!==i.key):this.activeWeatherLayers.length<6&&i.enabled&&(["png","jpg"].includes(i.type)?(this.activeWeatherLayers.forEach(e=>{(e.key==="wind"&&this.showWindFeather||i.key==="current"&&this.showCurrentIsoband)&&(e.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(e=>e.type==="json"&&!(["wind","current"].includes(e.key)&&e.particle))):i.key==="wind"?(this.activeWeatherLayers.forEach(e=>{e.key==="current"&&this.showCurrentIsoband&&(e.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(e=>e.type==="json"&&!(["wind","current"].includes(e.key)&&e.particle))):i.key==="current"&&(this.activeWeatherLayers.forEach(e=>{e.key==="wind"&&this.showWindFeather&&(e.particle=!1)}),this.activeWeatherLayers=this.activeWeatherLayers.filter(e=>e.type==="json"&&!(["wind","current"].includes(e.key)&&e.particle))),i.key==="sig-wave-height"&&(this.activeWeatherLayers=this.activeWeatherLayers.filter(e=>e.key!=="sig-wave")),i.key==="sig-wave"&&(this.activeWeatherLayers=this.activeWeatherLayers.filter(e=>e.key!=="sig-wave-height")),this.activeWeatherLayers.push(i)),this.$emit("weather",this.activeWeatherLayers,this.sourceCode)},handleWeatherLayerCollect(i){var e;if(!this.autoActive)return!1;!i.collected&&((e=this.layers.weather.filter(a=>a.collected))==null?void 0:e.length)>=6&&(this.layers.weather.filter(a=>a.collected)[0].collected=!1),i.collected=!i.collected,localStorage.setItem(this.collectedLayerCache,JSON.stringify(this.layers.weather)),this.$emit("handleToggleVersion")},handleToggleWindParticle(){!this.showWindFeather&&this.showWindParticle?this.handleWeatherLayerPick({weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!1}):(this.showCurrentParticle&&(this.$emit("toggleCurrentParticle",!1),this.showCurrentIsoband||(this.activeWeatherLayers=this.activeWeatherLayers.filter(i=>i.key!=="current"))),this.$emit("toggleWindParticle",!this.showWindParticle),this.$emit("toggleWindParticeVersion"))},handleToggleWindFeather(){this.showWindFeather&&!this.showWindParticle&&this.handleWeatherLayerPick({weight:1,name:"Wind",key:"wind",enabled:!0,type:"json",particle:!1}),this.$emit("toggleWindFeather",!this.showWindFeather)},handleToggleCurrentParticle(){!this.showCurrentIsoband&&this.showCurrentParticle?this.handleWeatherLayerPick({weight:96,name:"Current",key:"current",enabled:!0,type:"json",particle:!1}):(this.showWindParticle&&(this.$emit("toggleWindParticle",!1),this.showWindFeather||(this.activeWeatherLayers=this.activeWeatherLayers.filter(i=>i.key!=="wind"))),this.$emit("toggleCurrentParticle",!this.showCurrentParticle),this.$emit("toggleCurrentParticeVersion"))},handleToggleCurrentIsoband(){this.showCurrentIsoband&&!this.showCurrentParticle&&this.handleWeatherLayerPick({weight:96,name:"Current",key:"current",enabled:!0,type:"json",particle:!1}),this.$emit("toggleCurrentIsoband",!this.showCurrentIsoband)},handleOtherLayerPick(i){this.activeOtherLayers.some(e=>e.key===i.key)?this.activeOtherLayers=this.activeOtherLayers.filter(e=>e.key!==i.key):i.enabled&&this.activeOtherLayers.push(i),localStorage.setItem(this.activeOtherLayersCache,JSON.stringify(this.activeOtherLayers)),this.$emit("other",this.activeOtherLayers)},handleMenuToggle(){this.$emit("layerToggle",!this.layerToggle)},toggleAutoActive(){this.autoActive=!this.autoActive,localStorage.setItem(this.autoActiveCache,this.autoActive),this.autoActive?(this.$emit("weather",this.activeWeatherLayersCollected,this.sourceCode),this.$emit("toggleWindFeather",localStorage.getItem(this.windFeatherCollectedCache)==="true"),this.$emit("toggleCurrentIsoband",localStorage.getItem(this.currentIsobandCollectedCache)==="true")):(this.$emit("weather",[],this.sourceCode),this.$emit("toggleWindFeather",!1),this.$emit("toggleCurrentIsoband",!1))},handleCoordToggle(){this.showCoord=!this.showCoord,this.$emit("coordinate",this.showCoord)},handlePointToggle(){this.isLogin?(this.showPoint=!this.showPoint,this.$emit("point",this.showPoint)):this.$emit("login")},handleMeasureToggle(){this.showMeasure=!this.showMeasure,this.$emit("measure",this.showMeasure)},handle3DToggle(){this.show3d=!this.show3d,this.$emit("3d",this.show3d)}}},et={class:"idm-gl3-layer"},tt={class:"bar-item layer-bars"},at={class:"bar-item tool-bars"},it={class:"flex-between"},rt={key:0,class:"iconfont active"},ot={key:1,class:"iconfont"},st=["onClick"],nt=["onClick"],lt={key:0,class:"flex-start"},ct={key:1,class:"flex-start"},ht={class:"header-box flex-between"},dt={class:"weather-layers card-bg"},mt={class:"layers-title flex-between"},pt={key:0,class:"iconfont active"},gt={key:1,class:"iconfont"},yt={class:"layers-body"},ut={class:"flex-start"},ft=["onClick"],At=["onClick"],wt={key:0,class:"flex-start"},bt={key:1,class:"flex-start"},Lt=["onClick"],Ct={key:0,class:"iconfont bookmark-icon active"},vt={key:1,class:"iconfont bookmark-icon inactive"},xt={class:"other-layers card-bg"},Et={class:"layers-body"},Bt=["onClick"],_t={class:"flex-start"},kt={class:"switch flex-center"},It={key:0,class:"iconfont active"},Dt={key:1,class:"iconfont"},Nt={class:"source-layers card-bg"},zt={class:"layers-body"},Pt={key:0},Mt={key:1,class:"radio-tip"},St={key:2,class:"radio-tip"};function Tt(i,e,a,o,r,s){const n=t.resolveComponent("ElTooltip"),l=t.resolveComponent("ElRadio"),h=t.resolveComponent("ElRadioGroup"),d=t.resolveComponent("ElScrollbar");return t.openBlock(),t.createElementBlock("div",et,[t.createElementVNode("div",{class:"menu-bar-box",style:t.normalizeStyle({top:a.top+10+"px",right:r.right+"px"})},[t.createElementVNode("div",tt,[t.createVNode(n,{placement:"left",effect:"light",content:"Menu","show-after":1e3},{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(a.layerToggle?"menu-icon active":"menu-icon"),onClick:e[0]||(e[0]=(...c)=>s.handleMenuToggle&&s.handleMenuToggle(...c))},e[17]||(e[17]=[t.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1})])],4),t.createElementVNode("div",{class:"menu-bar-box",style:t.normalizeStyle({top:a.top+160+"px",right:r.right+"px"})},[t.createElementVNode("div",at,[t.createVNode(n,{placement:"left",effect:"light",content:"Measure","show-after":1e3},{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(r.showMeasure?"menu-icon active":"menu-icon"),onClick:e[1]||(e[1]=(...c)=>s.handleMeasureToggle&&s.handleMeasureToggle(...c))},e[18]||(e[18]=[t.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),t.createVNode(n,{placement:"left",effect:"light",content:"Point Meteo","show-after":1e3},{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(r.showPoint?"menu-icon active":"menu-icon"),onClick:e[2]||(e[2]=(...c)=>s.handlePointToggle&&s.handlePointToggle(...c))},e[19]||(e[19]=[t.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),t.createVNode(n,{placement:"left",effect:"light",content:"Grid","show-after":1e3},{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(r.showCoord?"menu-icon active":"menu-icon"),onClick:e[3]||(e[3]=(...c)=>s.handleCoordToggle&&s.handleCoordToggle(...c))},e[20]||(e[20]=[t.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1}),t.createVNode(n,{placement:"left",effect:"light",content:"3D","show-after":1e3},{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(r.show3d?"menu-icon active":"menu-icon"),onClick:e[4]||(e[4]=(...c)=>s.handle3DToggle&&s.handle3DToggle(...c))},e[21]||(e[21]=[t.createElementVNode("span",{class:"iconfont"},"",-1)]),2)]),_:1})])],4),s.hasCollectedLayers?(t.openBlock(),t.createElementBlock("div",{key:0,class:"active-layers",style:t.normalizeStyle({right:r.right+"px",bottom:"100px"})},[t.createElementVNode("div",it,[e[22]||(e[22]=t.createElementVNode("div",{style:{margin:"2px 5px"}},"Weather Layers",-1)),t.createElementVNode("div",{class:"switch flex-center",style:{"font-size":"28px","margin-right":"0"},onClick:e[5]||(e[5]=(...c)=>s.toggleAutoActive&&s.toggleAutoActive(...c))},[r.autoActive?(t.openBlock(),t.createElementBlock("i",rt,"")):(t.openBlock(),t.createElementBlock("i",ot,""))])]),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.layers.weather.filter(c=>c.collected),c=>(t.openBlock(),t.createElementBlock("div",{key:c.key,class:t.normalizeClass(s.computeLayerClass(c,r.activeWeatherLayersCollected))},[t.createElementVNode("div",{class:"checkbox",onClick:m=>s.handleWeatherLayerPick(c)},null,8,st),t.createElementVNode("span",{class:"name",onClick:m=>s.handleWeatherLayerPick(c)},t.toDisplayString(c.name),9,nt),c.key==="wind"&&r.activeWeatherLayersCollected.some(m=>m.key===c.key)?(t.openBlock(),t.createElementBlock("div",lt,[t.createElementVNode("i",{class:t.normalizeClass(["iconfont sub-layer-icon",r.showWindParticleCollected?"active":""]),onClick:e[6]||(e[6]=m=>s.handleToggleWindParticle())},"",2),t.createElementVNode("i",{class:t.normalizeClass(["iconfont sub-layer-icon",r.showWindFeatherCollected?"active":""]),onClick:e[7]||(e[7]=m=>s.handleToggleWindFeather())},"",2)])):t.createCommentVNode("",!0),c.key==="current"&&r.activeWeatherLayersCollected.some(m=>m.key===c.key)?(t.openBlock(),t.createElementBlock("div",ct,[t.createElementVNode("i",{class:t.normalizeClass(["iconfont sub-layer-icon",r.showCurrentParticleCollected?"active":""]),onClick:e[8]||(e[8]=m=>s.handleToggleCurrentParticle())},"",2),t.createElementVNode("i",{class:t.normalizeClass(["iconfont sub-layer-icon",r.showCurrentIsobandCollected?"active":""]),onClick:e[9]||(e[9]=m=>s.handleToggleCurrentIsoband())},"",2)])):t.createCommentVNode("",!0)],2))),128))],4)):t.createCommentVNode("",!0),t.createElementVNode("div",{class:"available-layers flex-center",style:t.normalizeStyle({top:a.top+"px",right:a.layerToggle?"0px":"-240px"})},[t.createElementVNode("div",{class:t.normalizeClass(["list-box",a.layerToggle?"right-bar":""])},[t.createElementVNode("div",ht,[e[23]||(e[23]=t.createElementVNode("div",null,"Layers",-1)),t.createElementVNode("div",{class:"iconfont close-btn",onClick:e[10]||(e[10]=(...c)=>s.handleMenuToggle&&s.handleMenuToggle(...c))},"")]),t.createVNode(d,{style:{flex:"1"}},{default:t.withCtx(()=>[t.createElementVNode("div",dt,[t.createElementVNode("div",mt,[e[24]||(e[24]=t.createElementVNode("div",null,"Weather Layers",-1)),t.createElementVNode("div",{class:"switch flex-center",style:{"margin-right":"0"},onClick:e[11]||(e[11]=(...c)=>s.toggleAutoActive&&s.toggleAutoActive(...c))},[r.autoActive?(t.openBlock(),t.createElementBlock("i",pt,"")):(t.openBlock(),t.createElementBlock("i",gt,""))])]),t.createElementVNode("div",yt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.layers.weather,c=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:c.key},[c.hide?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(s.computeLayerClass(c,r.activeWeatherLayersCollected))},[t.createElementVNode("div",ut,[t.createElementVNode("div",{class:"checkbox",onClick:m=>s.handleWeatherLayerPick(c)},null,8,ft),t.createElementVNode("span",{class:"name",onClick:m=>s.handleWeatherLayerPick(c)},t.toDisplayString(c.name),9,At),c.key==="wind"&&r.activeWeatherLayersCollected.some(m=>m.key===c.key)?(t.openBlock(),t.createElementBlock("div",wt,[t.createElementVNode("i",{class:t.normalizeClass(["iconfont sub-layer-icon",r.showWindParticleCollected?"active":""]),onClick:e[12]||(e[12]=m=>s.handleToggleWindParticle())},"",2),t.createElementVNode("i",{class:t.normalizeClass(["iconfont sub-layer-icon",r.showWindFeatherCollected?"active":""]),onClick:e[13]||(e[13]=m=>s.handleToggleWindFeather())},"",2)])):t.createCommentVNode("",!0),c.key==="current"&&r.activeWeatherLayersCollected.some(m=>m.key===c.key)?(t.openBlock(),t.createElementBlock("div",bt,[t.createElementVNode("i",{class:t.normalizeClass(["iconfont sub-layer-icon",r.showCurrentParticleCollected?"active":""]),onClick:e[14]||(e[14]=m=>s.handleToggleCurrentParticle())},"",2),t.createElementVNode("i",{class:t.normalizeClass(["iconfont sub-layer-icon",r.showCurrentIsobandCollected?"active":""]),onClick:e[15]||(e[15]=m=>s.handleToggleCurrentIsoband())},"",2)])):t.createCommentVNode("",!0)]),t.createElementVNode("div",{onClick:m=>s.handleWeatherLayerCollect(c)},[c.collected?(t.openBlock(),t.createElementBlock("i",Ct,"")):(t.openBlock(),t.createElementBlock("i",vt,""))],8,Lt)],2))],64))),128)),e[25]||(e[25]=t.createElementVNode("div",{class:"tip flex-start"},[t.createElementVNode("i",{class:"iconfont bookmark-icon",style:{"align-self":"flex-start",padding:"5px 5px 0 0"}},""),t.createElementVNode("div",null,"You can add the layers to your favorites. (Max 6)")],-1))])]),t.createElementVNode("div",xt,[e[26]||(e[26]=t.createElementVNode("div",{class:"layers-title"},"Other Layers",-1)),t.createElementVNode("div",Et,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.layers.other,c=>{var m;return t.openBlock(),t.createElementBlock("div",{key:c.key,class:t.normalizeClass(["layer flex-between",s.computeLayerClass(c,r.activeOtherLayers)]),onClick:b=>s.handleOtherLayerPick(c)},[t.createElementVNode("div",_t,[t.createElementVNode("div",kt,[(m=s.computeLayerClass(c,r.activeOtherLayers))!=null&&m.includes("active")?(t.openBlock(),t.createElementBlock("i",It,"")):(t.openBlock(),t.createElementBlock("i",Dt,""))]),t.createElementVNode("span",null,t.toDisplayString(c.name),1)])],10,Bt)}),128))])]),t.createElementVNode("div",Nt,[e[27]||(e[27]=t.createElementVNode("span",{class:"layers-title"},"Forecast Model",-1)),t.createElementVNode("div",zt,[t.createVNode(h,{modelValue:r.source,"onUpdate:modelValue":e[16]||(e[16]=c=>r.source=c),class:"layer-radio flex-col-start-start",style:{width:"180px","align-items":"flex-start"}},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.sourceList,(c,m)=>(t.openBlock(),t.createBlock(l,{key:`source${c.name}`,value:c.name},{default:t.withCtx(()=>{var b,B,x,g,E,C;return[t.createTextVNode(t.toDisplayString(c.name)+" ",1),m!==0?(t.openBlock(),t.createElementBlock("span",Pt,t.toDisplayString(c.resolution)+"km "+t.toDisplayString(c.length)+"days",1)):t.createCommentVNode("",!0),m===0?(t.openBlock(),t.createElementBlock("div",Mt,"Provides the best forecast")):(x=(B=(b=c==null?void 0:c.update)==null?void 0:b.default)==null?void 0:B.meta)!=null&&x.initialisationTime?(t.openBlock(),t.createElementBlock("div",St,"Update: "+t.toDisplayString(s.computeDateZ((C=(E=(g=c==null?void 0:c.update)==null?void 0:g.default)==null?void 0:E.meta)==null?void 0:C.initialisationTime)),1)):t.createCommentVNode("",!0)]}),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])])])]),_:1})],2)],4)])}const Qt=O($e,[["render",Tt]]),Mo="",Vt={name:"IdmWindBarb",props:{map:{type:Object},wind:{type:Object},current:{type:Object},beforeLayer:{type:String},mapProjection:{type:String},showWindFeather:{type:Boolean,default:!1},showWindParticle:{type:Boolean,default:!1},toggleParticeVersion:{type:Number},toggleVersion:{type:Number}},emits:["particle","showWindFeather"],data(){return{source:"wind-barb-source",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:P.featureCollection([]),right:10,bottom:125,windBarbLoaded:!1}},watch:{"wind.version":{handler(){var i;(i=this.wind)!=null&&i.active&&this.showWindFeather?this.handleRender():this.handleClear()},deep:!0},toggleParticeVersion:{handler(){this.handleParticle()}},showWindFeather:{handler(){this.handleToggle()}}},methods:{handleParticle(){this.$emit("particle",{particle:this.showWindParticle,key:"wind",weight:1})},handleRender(){var i,e,a,o;if(!this.map)setTimeout(()=>{this.handleRender()},500);else if(this.wind){const r=new Date().valueOf();let s=0,n=0,l=this.empty;if((i=this.wind)!=null&&i.active&&(l=(e=this.wind)==null?void 0:e.data),(a=this.map)!=null&&a.getSource(this.source))(o=this.map)==null||o.getSource(this.source).setData(l),n=new Date().valueOf()-(r+s),console.log("[wind] update elapsed: ",n,", total: ",s+=n);else{this.map.addSource(this.source,{type:"geojson",data:l});for(let h=0;h<(this.barbs??[]).length-1;h++){const d=(this.barbs??[])[h]||0,c=(this.barbs??[])[h+1]||0,m=d<10?`00${d}kts`:d<100?`0${d}kts`:`${d}kts`;this.map.addLayer({id:m,type:"symbol",filter:["all",[">=","spd",d],["<","spd",c]],source:this.source,layout:{"symbol-placement":"point","icon-image":m,"icon-size":.14,"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,"text-color":"#222"}},this.beforeLayer)}this.windBarbLoaded=!0,n=new Date().valueOf()-(r+s),console.log("[wind] add elapsed: ",n,", total: ",s+=n)}}},handleToggle(){if(!this.windBarbLoaded)this.handleRender();else for(const i of this.barbs??[]){const e=i<10?`00${i}kts`:i<100?`0${i}kts`:`${i}kts`;this.map.getLayer(e)&&this.map.setLayoutProperty(e,"visibility",this.showWindFeather?"visible":"none")}},handleClear(){for(const i of this.barbs??[]){const e=i<10?`00${i}kts`:i<100?`0${i}kts`:`${i}kts`;this.map.getLayer(e)&&this.map.removeLayer(e)}this.map.getSource(this.source)&&this.map.removeSource(this.source),this.windBarbLoaded=!1}}};function Ht(i,e,a,o,r,s){return null}const Ft=O(Vt,[["render",Ht]]);class Qe{constructor(e){Z(this,"map");Z(this,"mercator");Z(this,"rampColorLayer");Z(this,"rampColorSource");Z(this,"particleLayer");Z(this,"particleSource");Z(this,"rampColorCanvas");Z(this,"particleCanvas");Z(this,"ratio");this.map=e,this.mercator=new Je,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,a=0){return e>180?this.convertNLng(e-360,a+1):e<-180?this.convertNLng(e+360,a+1):[e,a]}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(),a=this.map.getZoom()+1,o=[e._ne.lng,e._ne.lat],r=[e._sw.lng,e._sw.lat],[s,n]=this.convertNLng(o[0]),[l,h]=this.convertNLng(r[0]),[d,c]=this.mercator.px([s,o[1]],a),[m,b]=this.mercator.px([l,r[1]],a),B=Math.round(this.mercator.size*Math.pow(2,a)*(n+h));return[m,b,d+B,c]}getBoundRange(){const e=this.map.getZoom()+1,a=this.mercator.size*Math.pow(2,e),o=this.getBoundPixel();return[o[0]/a,o[2]/a,o[3]/a,o[1]/a]}getWorldCopy(e,a){const o=2**a,[r,s,n,l]=e.map(c=>~~(c/(o*256))),h=[];for(let c=l;c<=s;c++)for(let m=r;m<=n;m++)h.push([m,c]);return h.map(c=>{const m=2**a*256;return[c[0]*m,c[1]*m,m]})}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){const a=this.map.getLayoutProperty(this.rampColorLayer,"visibility"),o=e?"visible":"none";a!==o&&this.map.setLayoutProperty(this.rampColorLayer,"visibility",o)}toggleParticle(e){const a=this.map.getLayoutProperty(this.particleLayer,"visibility"),o=e?"visible":"none";a!==o&&this.map.setLayoutProperty(this.particleLayer,"visibility",o)}}class Ee{createShader(e,a,o){const r=e.createShader(a);if(r&&(e.shaderSource(r,o),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)))throw new Error(e.getShaderInfoLog(r)||"error happened while create shader...");return r}createTexture(e,a,o,r,s,n,l){const h=e.createTexture();return e.bindTexture(e.TEXTURE_2D,h),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,r),s instanceof Uint8Array?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n,l,0,e.RGBA,e.UNSIGNED_BYTE,s):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,s),e.bindTexture(e.TEXTURE_2D,null),h}createDataBuffer(e,a,o){if(e){const r=e.createBuffer();return a==="array"?(e.bindBuffer(e.ARRAY_BUFFER,r),o&&e.bufferData(e.ARRAY_BUFFER,o,e.STATIC_DRAW)):a==="element"&&(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r),o&&e.bufferData(e.ELEMENT_ARRAY_BUFFER,o,e.STATIC_DRAW)),r}return null}createProgram(e,a,o){const r=e.createProgram(),s=this.createShader(e,e.VERTEX_SHADER,a),n=this.createShader(e,e.FRAGMENT_SHADER,o);if(r&&s&&n&&(e.attachShader(r,s),e.attachShader(r,n),e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS)))throw new Error(e.getProgramInfoLog(r)||"error happened while creating ramp color program");return r}createProgramWrapper(e,a,o){const r=this.createProgram(e,a,o);if(r){const s={program:r},n=e.getProgramParameter(r,e.ACTIVE_ATTRIBUTES);for(let h=0;h<n;h++){const d=e.getActiveAttrib(r,h);s[d.name]=e.getAttribLocation(r,d.name)}const l=e.getProgramParameter(r,e.ACTIVE_UNIFORMS);for(let h=0;h<l;h++){const d=e.getActiveUniform(r,h);s[d.name]=e.getUniformLocation(r,d.name)}return s}}setup(e,a,o=!1,r,s){const n=document.createElement("canvas");n.width=256,n.height=1;const l=n.getContext("2d");if(l&&e){const h=l==null?void 0:l.createLinearGradient(0,0,256,0);return a.forEach(([d,c])=>{h.addColorStop(d,c)}),l.fillStyle=h,l.fillRect(0,0,256,1),{canvas:n,texture:this.createTexture(e,e.LINEAR,e.LINEAR,e.CLAMP_TO_EDGE,o?new Uint8Array(l.getImageData(0,0,256,1).data):n,r,s)}}}setupParticle(e,a=1e3){const o=Math.ceil(Math.sqrt(a)),r=o*o,s=new Uint8Array(r*4);for(let c=0;c<s.length;c++)s[c]=Math.floor(Math.random()*256);const n=this.createTexture(e,e.NEAREST,e.NEAREST,e.CLAMP_TO_EDGE,s,o,o),l=this.createTexture(e,e.NEAREST,e.NEAREST,e.CLAMP_TO_EDGE,s,o,o),h=new Float32Array(r);for(let c=0;c<r;c++)h[c]=c;const d=this.createDataBuffer(e,"array",h);return{resolution:o,total:r,texture0:n,texture1:l,indexBuffer:d}}bind(e,a,o){const r=this.createProgram(e,a,o);if(r){const s=this.createDataBuffer(e,"array",void 0),n=e.getAttribLocation(r,"a_position");e.enableVertexAttribArray(n),e.vertexAttribPointer(n,2,e.FLOAT,!1,0,0);const l=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);this.createDataBuffer(e,"array",l);const h=e.getAttribLocation(r,"a_texCoord");return e.enableVertexAttribArray(h),e.vertexAttribPointer(h,2,e.FLOAT,!1,0,0),{program:r,aPositionBuffer:s}}return{}}bindParticle(e,a,o,r,s,n){const l=this.createProgramWrapper(e,a,o),h=this.createProgramWrapper(e,r,s),d=this.createProgramWrapper(e,r,n),c=this.createDataBuffer(e,"array",new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1])),m=e.createFramebuffer();return{particle:l,screen:h,update:d,quadBuffer:c,frameBuffer:m}}draw(e,a,o,r,s,n,l){var h,d;if(a&&o){e.resize(),a==null||a.viewport(0,0,(h=a==null?void 0:a.canvas)==null?void 0:h.width,(d=a==null?void 0:a.canvas)==null?void 0:d.height),a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT);try{a.useProgram(o);const c={resolution:a.getUniformLocation(o,"u_resolution"),image:a.getUniformLocation(o,"u_image"),color:a.getUniformLocation(o,"u_color"),scale:a.getUniformLocation(o,"u_scale"),uvRange:a.getUniformLocation(o,"u_range_u_v"),sRange:a.getUniformLocation(o,"u_range_s")};c.resolution&&a.uniform2f(c.resolution,a.canvas.width*e.ratio,a.canvas.height*e.ratio),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,r),c.image&&a.uniform1i(c.image,0),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,s),c.color&&a.uniform1i(c.color,1),l!=null&&l.uvRange&&(l!=null&&l.sRange)&&(c.uvRange&&a.uniform2f(c.uvRange,l.uvRange[0],l.uvRange[1]),c.sRange&&a.uniform2f(c.sRange,l.sRange[0],l.sRange[1])),c.scale&&a.uniform1f(c.scale,(l==null?void 0:l.scale)||1);const m=e.getBoundPixel(),b=e.map.getZoom()+1,B=e.getWorldCopy(m,b);for(const x of B){const g=(x[0]-m[0])*e.ratio,E=(x[1]-m[3])*e.ratio,C=x[2]*e.ratio,[y,A,p,w]=[g,C+g,E,C+E],u=new Float32Array([y,p,A,p,y,w,y,w,A,p,A,w]);a.bindBuffer(a.ARRAY_BUFFER,n),a.bufferData(a.ARRAY_BUFFER,u,a.STATIC_DRAW),a.drawArrays(a.TRIANGLES,0,6)}}catch(c){console.log(`render failed...${c}`)}}}drawParticle(e,a,o,r,s){var n,l;a&&(a==null||a.viewport(0,0,(n=a==null?void 0:a.canvas)==null?void 0:n.width,(l=a==null?void 0:a.canvas)==null?void 0:l.height),a.disable(a.DEPTH_TEST),a.disable(a.STENCIL_TEST),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,o),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,r.texture0),this.renderScreen(e,a,r,s),this.updateParticles(e,a,r,s))}renderScreen(e,a,o,r){a.bindFramebuffer(a.FRAMEBUFFER,o.frameBuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,o.screenTexture,0),a.viewport(0,0,a.canvas.width,a.canvas.height),this.renderScreenTexture(a,o.backgroundTexture,o.screen,o.quadBuffer,.95),this.renderParticles(e,a,o,r),a.bindFramebuffer(a.FRAMEBUFFER,null),this.renderScreenTexture(a,o.screenTexture,o.screen,o.quadBuffer,1);const s=o.backgroundTexture;o.backgroundTexture=o.screenTexture,o.screenTexture=s}renderScreenTexture(e,a,o,r,s){e&&(e.useProgram(o.program),e.bindBuffer(e.ARRAY_BUFFER,r),e.enableVertexAttribArray(o.a_pos),e.vertexAttribPointer(o.a_pos,2,e.FLOAT,!1,0,0),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,a),e.uniform1i(o.u_screen,2),e.uniform1f(o.u_opacity,s),e.drawArrays(e.TRIANGLES,0,6))}renderParticles(e,a,o,r){if(a){a.useProgram(o.particle.program),a.bindBuffer(a.ARRAY_BUFFER,o.indexBuffer),a.enableVertexAttribArray(o.particle.a_index),a.vertexAttribPointer(o.particle.a_index,1,a.FLOAT,!1,0,0),a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,o.color.texture),a.uniform1i(o.particle.u_factor,0),a.uniform1i(o.particle.u_particles,1),a.uniform1i(o.particle.u_color_ramp,2),a.uniform1f(o.particle.u_particles_resolution,o.resolution*e.ratio),a.uniform1f(o.particle.u_point,e.ratio);const s=e.getBoundRange();a.uniform4f(o.particle.u_viewport,s[0],s[1],s[2],s[3]),a.uniform2f(o.particle.u_factor_min,r.uvRange[0],r.uvRange[0]),a.uniform2f(o.particle.u_factor_max,r.uvRange[1],r.uvRange[1]),a.drawArrays(a.POINTS,0,o.total)}}updateParticles(e,a,o,r){var n,l;if(a){a.bindFramebuffer(a.FRAMEBUFFER,o.frameBuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,o.texture1,0),a.viewport(0,0,o.resolution,o.resolution),a.useProgram(o.update.program),a.bindBuffer(a.ARRAY_BUFFER,o.quadBuffer),a.enableVertexAttribArray(o.update.a_pos),a.vertexAttribPointer(o.update.a_pos,2,a.FLOAT,!1,0,0),a.uniform1i(o.update.u_factor,0),a.uniform1i(o.update.u_particles,1);const h=e.getBoundRange();a.uniform4f(o.update.u_viewport,h[0],h[1],h[2],h[3]),a.uniform1f(o.update.u_rand_seed,Math.random()),a.uniform2f(o.update.u_factor_res,(n=o==null?void 0:o.image)==null?void 0:n.width,(l=o==null?void 0:o.image)==null?void 0:l.height),a.uniform2f(o.update.u_factor_min,r.uvRange[0],r.uvRange[0]),a.uniform2f(o.update.u_factor_max,r.uvRange[1],r.uvRange[1]),a.uniform1f(o.update.u_speed_factor,r.speedFactor*e.ratio),a.uniform1f(o.update.u_drop_rate,r.dropRate),a.uniform1f(o.update.u_drop_rate_bump,r.dropRateBump),a.drawArrays(a.TRIANGLES,0,6)}const s=o.texture0;o.texture0=o.texture1,o.texture1=s}resize(e,a){e.resize();const o=new Uint8Array(a.canvas.width*a.canvas.height*4).fill(0,0,a.canvas.width*a.canvas.height*4),r=this.createTexture(a,a.NEAREST,a.NEAREST,a.CLAMP_TO_EDGE,o,a.canvas.width,a.canvas.height),s=this.createTexture(a,a.NEAREST,a.NEAREST,a.CLAMP_TO_EDGE,o,a.canvas.width,a.canvas.height);return{screenTexture:r,backgroundTexture:s}}async loadImg(e){return new Promise(a=>{const o=new Blob([e],{type:e.type}),r=URL.createObjectURL(o),s=new Image;s.crossOrigin="anonymous",s.src=r,s.onload=()=>a(s)})}}class J{}Z(J,"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;
}`),Z(J,"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;
}`),Z(J,"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 ye{}Z(ye,"vertexSchema",`
precision mediump 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);
}`),Z(ye,"fragmentSchema",`
precision mediump 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;
}`),Z(ye,"quadVertSchema",`
precision mediump 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);
}`),Z(ye,"screenFragmentSchema",`
precision mediump 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);
}`),Z(ye,"updateFragmentSchema",`
precision mediump 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);
}`);class Fe{constructor(e="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNseTVudHJzYzAwNWUwbHBsZHkyaDRqczMiLCJyb2xlIjoxLCJuYW1lIjoiZmFrZUBvcm13eC5jb20iLCJwbGF0SWQiOiJnZDBtdDFkIiwiY29tcGFueSI6eyJpZCI6bnVsbCwiY2hpbGRyZW4iOltdfSwiaWF0IjoxNzIzMDI0MDI0LCJleHAiOjM5MzA1NDQwMjR9.RrKcdcMnq-FxBLJQ-i6lx2FscDE46y8EvHIemPW4HTg"){Z(this,"token");Z(this,"mapboxCustomer");Z(this,"i4");Z(this,"hi");Z(this,"td");Z(this,"windy");this.token=e,this.mapboxCustomer={source:this.initialOnlineStyle().sources.composite,layers:{water:{id:"water",type:"fill",source:"composite","source-layer":"water",metadata:{"mapbox:featureComponent":"land-and-water","mapbox:group":"Land & water, water"},paint:{"fill-color":"hsl(205, 75%, 70%)"}},waterDeplth:{id:"water-depth",type:"fill",source:"composite","source-layer":"depth",metadata:{"mapbox:featureComponent":"land-and-water","mapbox:group":"Land & water, water"},maxzoom:8,paint:{"fill-antialias":!1,"fill-color":["interpolate",["linear"],["zoom"],6,["interpolate",["linear"],["get","min_depth"],0,"hsla(205, 75%, 70%, 0.35)",200,"hsla(205, 75%, 63%, 0.35)",7e3,"hsla(205, 75%, 56%, 0.35)"],8,["interpolate",["linear"],["get","min_depth"],0,"hsla(205, 75%, 70%, 0)",200,"hsla(205, 75%, 63%, 0)",7e3,"hsla(205, 75%, 53%, 0)"]]}},countryBoundary:{id:"country-boundaries",type:"fill",source:"composite","source-layer":"country_boundaries",layout:{visibility:"visible"},paint:{"fill-color":"#d9d8d8"}},countryAdmin0BoundaryBg:{id:"admin-0-boundary-bg",type:"line",source:"composite","source-layer":"admin",metadata:{"mapbox:featureComponent":"admin-boundaries","mapbox:group":"Administrative boundaries, admin"},minzoom:1,filter:["all",["==",["get","admin_level"],0],["==",["get","maritime"],"false"],["match",["get","worldview"],["all","CN"],!0,!1]],paint:{"line-width":["interpolate",["linear"],["zoom"],3,4,12,8],"line-color":"rgb(193, 190, 190)","line-opacity":["interpolate",["linear"],["zoom"],3,0,4,.5],"line-blur":["interpolate",["linear"],["zoom"],3,0,12,2]}},countryAdmin0Boundary:{id:"admin-0-boundary",type:"line",source:"composite","source-layer":"admin",metadata:{"mapbox:featureComponent":"admin-boundaries","mapbox:group":"Administrative boundaries, admin"},minzoom:1,filter:["all",["==",["get","admin_level"],0],["==",["get","disputed"],"false"],["==",["get","maritime"],"false"],["match",["get","worldview"],["all","CN"],!0,!1]],paint:{"line-color":"rgb(114, 110, 111)","line-width":["interpolate",["linear"],["zoom"],3,.5,12,2],"line-dasharray":["step",["zoom"],["literal",[2,0]],7,["literal",[2,2,6,2]]]}},countryAdmin0BoundaryDisputed:{id:"admin-0-boundary-disputed",type:"line",source:"composite","source-layer":"admin",metadata:{"mapbox:featureComponent":"admin-boundaries","mapbox:group":"Administrative boundaries, admin"},minzoom:1,filter:["all",["==",["get","disputed"],"true"],["==",["get","admin_level"],0],["==",["get","maritime"],"false"],["match",["get","worldview"],["all","CN"],!0,!1]],paint:{"line-color":"rgb(95, 93, 94)","line-width":["interpolate",["linear"],["zoom"],3,.5,12,2],"line-dasharray":["step",["zoom"],["literal",[3,2,5]],7,["literal",[2,1.5]]]}},countryLabel:{id:"country-label",type:"symbol",source:"composite","source-layer":"place_label",metadata:{"mapbox:featureComponent":"place-labels","mapbox:group":"Place labels, place-labels"},layout:{visibility:"visible","text-field":["coalesce",["get","name_en"],["get","name"]],"text-line-height":1.1,"text-max-width":6,"text-font":["HelveticaNeueThin"],"text-radial-offset":["step",["zoom"],.6,8,0],"text-justify":["step",["zoom"],["match",["get","text_anchor"],["left","bottom-left","top-left"],"left",["right","bottom-right","top-right"],"right","center"],7,"auto"],"text-size":["interpolate",["cubic-bezier",.2,0,.7,1],["zoom"],1,["step",["get","symbolrank"],11,4,9,5,8],9,["step",["get","symbolrank"],22,4,19,5,17]]},paint:{"text-color":"rgba(255,255,255,0)"}},world12nm:{id:"world-12nm-v4-20231025",type:"line",source:"composite","source-layer":"eez_12nm_new1-6jzkww",minzoom:0,layout:{"line-join":"round",visibility:"none"},paint:{"line-color":"hsl(2, 88%, 55%)","line-opacity":.62,"line-width":["interpolate",["linear"],["zoom"],0,2,22,2],"line-translate":[0,0]}},worldMarineLine:{id:"ne-10m-outline",type:"line",source:"composite","source-layer":"ne_10m_geography_marine_polys-3968bv",minzoom:1,layout:{"line-join":"round",visibility:"none"},paint:{"line-color":"hsl(0, 0.60%, 34.70%)","line-opacity":1,"line-width":["interpolate",["linear"],["zoom"],0,2,22,2],"line-translate":[0,0]}},worldMarineLabel:{id:"ne-10m-label",type:"symbol",source:"composite","source-layer":"ne_10m_geography_marine_polys-3968bv",minzoom:1,layout:{"text-field":["to-string",["get","name"]],"text-size":13,visibility:"none"},paint:{"text-halo-color":"hsl(0, 0%, 100%)","text-halo-width":1,"text-halo-blur":1}},chinaRouteLine:{id:"china-route-line",type:"line",source:"composite","source-layer":"china_route-bdtx5d",layout:{visibility:"none"},paint:{"line-color":["interpolate",["linear"],["zoom"],0,"rgb(2,196,140)",22,"rgb(2,196,140)"],"line-width":2}},chinaRouteFill:{id:"china-route-fill",type:"fill",source:"composite","source-layer":"china_route-bdtx5d",filter:["match",["get","featureType"],["route"],!0,!1],layout:{visibility:"none"},paint:{"fill-color":"rgb(2,196,140)","fill-opacity":.2}},chinaRouteLabel:{id:"china-route-label",type:"symbol",source:"composite","source-layer":"china_route-bdtx5d",layout:{"text-field":["to-string",["get","RouteName"]],"text-size":12,visibility:"none"},paint:{"text-halo-color":"hsl(0, 0%, 96%)","text-halo-width":1,"text-color":"hsl(0, 1%, 2%)"}}}},this.td={source:{type:"raster",tiles:["https://t0.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=3b3833b65e3705d5dc51a5e473b41da8","https://t1.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=3b3833b65e3705d5dc51a5e473b41da8","https://t2.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=3b3833b65e3705d5dc51a5e473b41da8","https://t3.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=3b3833b65e3705d5dc51a5e473b41da8","https://t4.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=3b3833b65e3705d5dc51a5e473b41da8","https://t5.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=3b3833b65e3705d5dc51a5e473b41da8","https://t6.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=3b3833b65e3705d5dc51a5e473b41da8","https://t7.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=3b3833b65e3705d5dc51a5e473b41da8"],tileSize:256},layer:{id:"td",type:"raster",source:"td",layout:{visibility:"visible"}}},this.i4={source:{type:"raster",tiles:["https://osshz.idmwx.com/nautical/{z}/{x}/{y}.png","https://osshz1.idmwx.com/nautical/{z}/{x}/{y}.png","https://osshz2.idmwx.com/nautical/{z}/{x}/{y}.png","https://osshz3.idmwx.com/nautical/{z}/{x}/{y}.png","https://osshz4.idmwx.com/nautical/{z}/{x}/{y}.png","https://osshz5.idmwx.com/nautical/{z}/{x}/{y}.png","https://osshz6.idmwx.com/nautical/{z}/{x}/{y}.png","https://osshz7.idmwx.com/nautical/{z}/{x}/{y}.png"],tileSize:256},layer:{id:"i4",type:"raster",source:"i4",m