@idmwx/idmui-gl3 6.5.0 → 6.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ const Y = (a, e) => {
|
|
|
72
72
|
autoActive: !0,
|
|
73
73
|
layers: {
|
|
74
74
|
weather: [
|
|
75
|
-
...$e.WEATHER_LAYERS.filter((a) => !["swell-height", "swell-direction", "current-direction", "current-speed"].includes(a.key))
|
|
75
|
+
...$e.WEATHER_LAYERS.filter((a) => a.enabled && !["swell-height", "swell-direction", "current-direction", "current-speed"].includes(a.key))
|
|
76
76
|
],
|
|
77
77
|
other: [...$e.OTHER_LAYERS.filter((a) => a.enabled)]
|
|
78
78
|
},
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(U,ee){typeof exports=="object"&&typeof module<"u"?ee(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"],ee):(U=typeof globalThis<"u"?globalThis:U||self,ee(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,ee,j,xe,t,qe,Je,Ie,W,De,Me){"use strict";var Do=Object.defineProperty;var No=(U,ee,j)=>ee in U?Do(U,ee,{enumerable:!0,configurable:!0,writable:!0,value:j}):U[ee]=j;var Z=(U,ee,j)=>(No(U,typeof ee!="symbol"?ee+"":ee,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 z=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:[...ee.LayerHelper.WEATHER_LAYERS.filter(i=>!["swell-height","swell-direction","current-direction","current-speed"].includes(i.key))],other:[...ee.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,C,B,u,E,v;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")):(B=(C=(b=c==null?void 0:c.update)==null?void 0:b.default)==null?void 0:C.meta)!=null&&B.initialisationTime?(t.openBlock(),t.createElementBlock("div",St,"Update: "+t.toDisplayString(s.computeDateZ((v=(E=(u=c==null?void 0:c.update)==null?void 0:u.default)==null?void 0:E.meta)==null?void 0:v.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:z.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),C=Math.round(this.mercator.size*Math.pow(2,a)*(n+h));return[m,b,d+C,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,C=e.getWorldCopy(m,b);for(const B of C){const u=(B[0]-m[0])*e.ratio,E=(B[1]-m[3])*e.ratio,v=B[2]*e.ratio,[g,A,p,w]=[u,v+u,E,v+E],y=new Float32Array([g,p,A,p,g,w,g,w,A,p,A,w]);a.bindBuffer(a.ARRAY_BUFFER,n),a.bufferData(a.ARRAY_BUFFER,y,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 q{}Z(q,"vertexSchema",`
|
|
1
|
+
(function(U,ee){typeof exports=="object"&&typeof module<"u"?ee(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"],ee):(U=typeof globalThis<"u"?globalThis:U||self,ee(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,ee,j,xe,t,qe,Je,Ie,W,De,Me){"use strict";var Do=Object.defineProperty;var No=(U,ee,j)=>ee in U?Do(U,ee,{enumerable:!0,configurable:!0,writable:!0,value:j}):U[ee]=j;var Z=(U,ee,j)=>(No(U,typeof ee!="symbol"?ee+"":ee,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 z=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:[...ee.LayerHelper.WEATHER_LAYERS.filter(i=>i.enabled&&!["swell-height","swell-direction","current-direction","current-speed"].includes(i.key))],other:[...ee.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,C,B,u,E,v;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")):(B=(C=(b=c==null?void 0:c.update)==null?void 0:b.default)==null?void 0:C.meta)!=null&&B.initialisationTime?(t.openBlock(),t.createElementBlock("div",St,"Update: "+t.toDisplayString(s.computeDateZ((v=(E=(u=c==null?void 0:c.update)==null?void 0:u.default)==null?void 0:E.meta)==null?void 0:v.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:z.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),C=Math.round(this.mercator.size*Math.pow(2,a)*(n+h));return[m,b,d+C,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,C=e.getWorldCopy(m,b);for(const B of C){const u=(B[0]-m[0])*e.ratio,E=(B[1]-m[3])*e.ratio,v=B[2]*e.ratio,[g,A,p,w]=[u,v+u,E,v+E],y=new Float32Array([g,p,A,p,g,w,g,w,A,p,A,w]);a.bindBuffer(a.ARRAY_BUFFER,n),a.bufferData(a.ARRAY_BUFFER,y,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 q{}Z(q,"vertexSchema",`
|
|
2
2
|
//canvas 坐标系上的坐标 (x, y)
|
|
3
3
|
attribute vec2 a_position; //像素坐标
|
|
4
4
|
attribute vec2 a_texCoord; //纹理坐标
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idmwx/idmui-gl3",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "6.5.
|
|
4
|
+
"version": "6.5.1",
|
|
5
5
|
"description": "idm webgl3",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@idm-plugin/geo": "^1.8.6",
|
|
50
50
|
"@idm-plugin/meteo": "^0.5.6",
|
|
51
|
-
"@idm-plugin/tag": "^0.3.
|
|
51
|
+
"@idm-plugin/tag": "^0.3.6",
|
|
52
52
|
"@idmui/style": "^0.1.7",
|
|
53
53
|
"@types/mapbox-gl": "^3.1.0",
|
|
54
54
|
"@types/node": "^18.14.2",
|