Switch to vector maps (MapLibre GL JS + PMTiles) and add RainViewer radar
Replace Leaflet/raster tiles with MapLibre GL JS: an online OpenFreeMap style and an offline style built from a local PMTiles archive via pmtiles.js and protomaps-themes-base (no glyphs/labels offline by design, see docs/architecture.adoc). Frontend libraries are vendored locally rather than loaded from a CDN so the app keeps working with no internet access. Also add an animated RainViewer precipitation radar overlay (toggle, play/pause, scrub slider), matching the default time window of the weather-radar-card Home Assistant integration.
This commit is contained in:
1 parent
7329497e95
commit
5afb130c45
19 files changed
+1378
-14
No files matched your search
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* MapLibre GL JS
|
||||
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.6.0/LICENSE.txt
|
||||
*/
|
||||
import{B as e,Br as t,D as n,Dt as r,Ht as i,I as a,In as o,K as s,Mn as c,On as l,Ot as u,P as d,Pn as f,S as p,Sr as m,U as h,Vi as g,Vn as _,W as v,Wr as y,ar as b,bn as x,br as S,c as C,d as w,dt as T,g as E,hn as D,hr as O,ht as ee,i as k,kn as A,l as j,m as M,n as N,nn as P,o as F,on as I,p as L,pr as R,rn as z,sr as B,x as V,xt as H,yn as U,zn as W}from"./maplibre-gl-shared.mjs";var G=class{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(e,t,n){for(let t of e){this._layerConfigs[t.id]=t;let e=this._layers[t.id]=p(t,n);e._featureFilter=U(e.filter,`layers[${t.id}].filter`,n),this.keyCache[t.id]&&delete this.keyCache[t.id]}for(let e of t)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};let r=x(Object.values(this._layerConfigs),this.keyCache);for(let e of r){let t=e.map(e=>this._layers[e.id]),n=t[0];if(n.isHidden())continue;let r=n.source||``,i=this.familiesBySource[r];i||=this.familiesBySource[r]={};let a=n.sourceLayer||`_geojsonTileLayer`,o=i[a];o||=i[a]=[],o.push(t)}}},K=class{constructor(e){let t={},n=[];for(let r in e){let i=e[r],a=t[r]={};for(let e in i){let t=i[+e];if(!t||t.bitmap.width===0||t.bitmap.height===0)continue;let r={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(r),a[e]={rect:r,metrics:t.metrics}}}let{w:i,h:o}=a(n),s=new r({width:i||1,height:o||1});for(let n in e){let i=e[n];for(let e in i){let a=i[+e];if(!a||a.bitmap.width===0||a.bitmap.height===0)continue;let o=t[n][e].rect;r.copy(a.bitmap,s,{x:0,y:0},{x:o.x+1,y:o.y+1},a.bitmap)}}this.image=s,this.positions=t}};I(`GlyphAtlas`,K);var q=class{constructor(e){this.tileID=new E(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}async parse(e,r,a,o,c){this.data=e,this.collisionBoxArray=new i;let l=new w(Object.keys(e.layers).sort()),u=new C(this.tileID,this.promoteId);u.bucketLayerIDs=[];let f={},p={featureIndex:u,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:a,subdivisionGranularity:c},g=r.familiesBySource[this.source];for(let n in g){let r=e.layers[n];if(!r)continue;r.version===1&&t(`Vector tile source "${this.source}" layer "${n}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let i=l.encode(n),o=[];for(let e=0;e<r.length;e++){let t=r.feature(e),a=u.getId(t,n);o.push({feature:t,id:a,index:e,sourceLayerIndex:i})}for(let e of g[n]){let n=e[0];n.source!==this.source&&t(`layer.source = ${n.source} does not equal this.source = ${this.source}`),!n.isHidden(this.zoom,!0)&&(J(e,this.zoom,a),(f[n.id]=n.createBucket({index:u.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:i,sourceID:this.source})).populate(o,p,this.tileID.canonical),u.bucketLayerIDs.push(e.map(e=>e.id)))}}let _=m(p.glyphDependencies,e=>Object.keys(e).map(Number));for(let e of this.inFlightDependencies)e?.abort();this.inFlightDependencies=[];let v=Promise.resolve({});if(Object.keys(_).length){let e=new AbortController;this.inFlightDependencies.push(e),v=o.sendAsync({type:`GG`,data:{stacks:_,source:this.source,tileID:this.tileID,type:`glyphs`}},e)}let y=Object.keys(p.iconDependencies),b=Promise.resolve({});if(y.length){let e=new AbortController;this.inFlightDependencies.push(e),b=o.sendAsync({type:`GI`,data:{icons:y,source:this.source,tileID:this.tileID,type:`icons`}},e)}let x=Object.keys(p.patternDependencies),S=Promise.resolve({});if(x.length){let e=new AbortController;this.inFlightDependencies.push(e),S=o.sendAsync({type:`GI`,data:{icons:x,source:this.source,tileID:this.tileID,type:`patterns`}},e)}let T=p.dashDependencies,E=Promise.resolve({});if(Object.keys(T).length){let e=new AbortController;this.inFlightDependencies.push(e),E=o.sendAsync({type:`GDA`,data:{dashes:T}},e)}let[D,O,k,A]=await Promise.all([v,b,S,E]),j=new K(D),M=new d(O,k);for(let e in f){let t=f[e];t instanceof n?(J(t.layers,this.zoom,a),N({bucket:t,glyphMap:D,glyphPositions:j.positions,imageMap:O,imagePositions:M.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:p.subdivisionGranularity})):t.hasDependencies&&(t instanceof ee||t instanceof s||t instanceof h)&&(J(t.layers,this.zoom,a),t.addFeatures(p,this.tileID.canonical,M.patternPositions,A))}return{buckets:Object.values(f).filter(e=>!e.isEmpty()),featureIndex:u,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:j.image,imageAtlas:M,dashPositions:A,glyphMap:thisLine truncated
|
||||
//# sourceMappingURL=maplibre-gl-worker.mjs.map
|
||||
Reference in new issue
Block a user