isard 0.5.1 → 0.6.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/CHANGELOG.md +40 -0
- package/README.md +10 -2
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +5 -4
- package/dist/decoder.worker.js +3 -3
- package/dist/decoder.worker.js.map +3 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/map.d.ts +14 -2
- package/dist/map.js +36 -2
- package/dist/map.js.map +1 -1
- package/dist/pmtiles.d.ts +68 -0
- package/dist/pmtiles.js +297 -0
- package/dist/pmtiles.js.map +1 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.js.map +1 -1
- package/dist/vectortiles.d.ts +30 -1
- package/dist/vectortiles.js +109 -3
- package/dist/vectortiles.js.map +1 -1
- package/dist/wasm/isard.d.ts +14 -0
- package/dist/wasm/isard.js +30 -1
- package/dist/wasm/isard_core.d.ts +14 -0
- package/dist/wasm/isard_core.js +30 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,46 @@
|
|
|
3
3
|
Every notable change of `isard` (published as `@ign-junn/isard` up to 0.1.1). The format follows [Keep a Changelog](https://keepachangelog.com), the
|
|
4
4
|
versions [Semantic Versioning](https://semver.org) (before 1.0.0, a minor version may change an API).
|
|
5
5
|
|
|
6
|
+
## [0.6.1] - 2026-10-20
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- `GeoMap.setViewshed` takes several observers (16 at most): what any of them sees is seen, what is hidden from all
|
|
11
|
+
those that reach it is hidden. The viewshed example: a click on the map adds an observer, a click on its pin opens
|
|
12
|
+
its settings in a popup (one open at a time), a button removes it or all of them; on a building, the observer
|
|
13
|
+
stands on its roof.
|
|
14
|
+
|
|
15
|
+
## [0.6.0] - 2026-10-19
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `GeoMap.setViewshed` (a prototype): what can be seen from a point within a range, tinted over the map, and what is
|
|
20
|
+
hidden. The relief, extrusions, 3D Tiles and models are drawn from the observer into a depth cube, as for the
|
|
21
|
+
shadows of a point light, and each pixel on screen compares its distance to the observer with it. All around, or
|
|
22
|
+
one way only as a camera: a cone given by a direction, a tilt and angles of view. Only what the map loaded for its
|
|
23
|
+
view hides anything. The viewshed example: from the Sacré-Cœur over Montmartre's buildings.
|
|
24
|
+
- The QGIS plugin "isard 3D view" (`integrations/qgis`, QGIS 3.28 to 4, `bun run qgis:package` → an archive for
|
|
25
|
+
"Install from ZIP"): the viewer in a panel (Qt WebEngine) or the browser, served by a local server; the camera
|
|
26
|
+
following the map canvas (and the other way round), vector layers sent as styled GeoJSON (extruded by a field),
|
|
27
|
+
XYZ, WMS, WMTS, MBTiles, vector tiles and COPC point clouds, clicks selecting the features in QGIS.
|
|
28
|
+
- PMTiles (v3) archives read by range requests, without a tile server: `map.addPmtiles(url)` (a raster layer, or
|
|
29
|
+
vector tiles drawn with a style, by default `basicStyle` of the archive's layers), `addRaster({ url: 'pmtiles://…' })`,
|
|
30
|
+
and `pmtiles://` sources in a style (as MapLibre's protocol names them), their tiles read in the basemap workers.
|
|
31
|
+
Directories cached per archive, gzip through `DecompressionStream`, `blob:` URLs; the reader exported (`PMTiles`,
|
|
32
|
+
`zxyToTileId`, `tileIdToZxy`).
|
|
33
|
+
- The viewer (`apps/viewer`, built into `apps/viewer/dist`, not in the package): a full-window map for local files
|
|
34
|
+
dropped or opened (GeoJSON, KML, GPX, TopoJSON, COPC, PMTiles, glTF), a list of layers, and a bridge other
|
|
35
|
+
applications drive with JSON messages (Server-Sent Events and POST, `postMessage`, `window.isardViewer`): camera,
|
|
36
|
+
basemap, relief, layers, selection to the viewer; ready, moves, clicks with the feature picked, errors back. Its
|
|
37
|
+
local server, `bun scripts/viewer.ts [files…] [--port] [--open]` (`bun run viewer`): the viewer, the bridge with
|
|
38
|
+
its state replayed, the files given with HTTP ranges, MBTiles as XYZ tiles (bun:sqlite), the files added as layers
|
|
39
|
+
on startup; 127.0.0.1 only, other hosts and origins refused. The guide's page "The viewer" describes the protocol.
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- The package's modules grow by about 5.5 KB gzipped (comments included; in a bundle only when used) and the basemap
|
|
44
|
+
worker by 1.6 KB, to 12.9 KB: the PMTiles reader.
|
|
45
|
+
|
|
6
46
|
## [0.5.1] - 2026-10-19
|
|
7
47
|
|
|
8
48
|
### Fixed
|
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ Live in the [documentation](https://graffkevin.github.io/isard/examples/), sourc
|
|
|
102
102
|
| [Labels](https://graffkevin.github.io/isard/layers/labels) | `addSymbols` | SDF fonts (Noto Sans by default, any glyphs), halos, along lines, collisions shared by all layers |
|
|
103
103
|
| [Buildings](https://graffkevin.github.io/isard/layers/buildings) | `addExtrusions` | tiles or one set, colored by values or by a network's times |
|
|
104
104
|
| [Ground shaders](https://graffkevin.github.io/isard/layers/ground) | `addGround` | your fragment shader over the ground: water depth, heat maps |
|
|
105
|
-
| [Rasters](https://graffkevin.github.io/isard/layers/rasters) | `addRaster` | XYZ, WMTS, WMS; in Web Mercator, or reprojected from another grid (longitudes and latitudes, Lambert-93, UTM, any CRS through proj4); or tiles drawn by your code |
|
|
105
|
+
| [Rasters](https://graffkevin.github.io/isard/layers/rasters) | `addRaster`, `addPmtiles` | XYZ, WMTS, WMS, PMTiles; in Web Mercator, or reprojected from another grid (longitudes and latitudes, Lambert-93, UTM, any CRS through proj4); or tiles drawn by your code |
|
|
106
106
|
| [3D Tiles](https://graffkevin.github.io/isard/layers/tiles3d) | `addTiles3d` | b3dm, pnts, glb, external tilesets, compressed or not |
|
|
107
107
|
| [glTF models](https://graffkevin.github.io/isard/layers/models) | `addModels` | a glTF model at many positions, instanced, on the relief, picked |
|
|
108
108
|
| [Point clouds](https://graffkevin.github.io/isard/layers/pointclouds) | `addPointCloud` | COPC (LiDAR HD) by range requests, pnts and glTF points; by class, altitude, intensity, EDL |
|
|
@@ -111,6 +111,13 @@ Live in the [documentation](https://graffkevin.github.io/isard/examples/), sourc
|
|
|
111
111
|
Plus markers, popups, controls, picking within a radius, `easeTo`, `flyTo`, a sky and fog for tilted views. All in
|
|
112
112
|
the [API reference](https://graffkevin.github.io/isard/api).
|
|
113
113
|
|
|
114
|
+
Local files on a map: `bun scripts/viewer.ts data.geojson lidar.copc.laz tiles.pmtiles` serves the viewer
|
|
115
|
+
(`apps/viewer`: files dropped or given, a layer list, a bridge any app can drive) on 127.0.0.1
|
|
116
|
+
([The viewer](https://graffkevin.github.io/isard/guide/viewer)).
|
|
117
|
+
|
|
118
|
+
In QGIS (3.28 and 4): the **isard 3D view** plugin shows the map canvas and its layers in 3D, in a panel or the
|
|
119
|
+
browser, the camera, layers and clicks in sync ([QGIS plugin](https://graffkevin.github.io/isard/guide/qgis)).
|
|
120
|
+
|
|
114
121
|
## Fast by design
|
|
115
122
|
|
|
116
123
|
Geometry uploaded once and only the view drawn, values in textures, the ground composited in one pass, frames on
|
|
@@ -139,10 +146,11 @@ crates/tiles3d/ 3D Tiles tree, traversal and decoding
|
|
|
139
146
|
crates/pointcloud/ COPC point clouds: header, octree hierarchy, traversal, LAZ chunks tested natively
|
|
140
147
|
crates/engine/ the WebAssembly core: the engine, the ground, the layers, picking
|
|
141
148
|
packages/isard/ the npm package isard: GeoMap, layer handles, overlays, workers
|
|
142
|
-
apps/ the demo
|
|
149
|
+
apps/ the demo, the viewer (local files, a bridge for other apps) and the benchmark
|
|
143
150
|
examples/ one page per example
|
|
144
151
|
docs/ the documentation site (VitePress)
|
|
145
152
|
scripts/ build, dev server, docs, release
|
|
153
|
+
integrations/qgis/ the QGIS plugin (Python), its server tested with python3 -m unittest
|
|
146
154
|
```
|
|
147
155
|
|
|
148
156
|
More in [Develop and release](https://graffkevin.github.io/isard/guide/develop).
|
package/dist/basemap.worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function ye(e){return e*360-180}function we(e){return Math.atan(Math.sinh(Math.PI*(1-2*e)))*180/Math.PI}class H{capacity;evict;entries=new Map;constructor(e,t){this.capacity=e;this.evict=t}get size(){return this.entries.size}get(e){let t=this.entries.get(e);if(t!==void 0)this.entries.delete(e),this.entries.set(e,t);return t}has(e){return this.entries.has(e)}set(e,t){this.entries.delete(e),this.entries.set(e,t);for(let[n,o]of this.entries){if(this.entries.size<=this.capacity)break;this.entries.delete(n),this.evict?.(o,n)}}delete(e){return this.entries.delete(e)}values(){return this.entries.values()}clear(){this.entries.clear()}}class ue{buf;end;pos;constructor(e,t=0,n=e.length){this.buf=e;this.end=n;this.pos=t}varint(){let e=0;for(let t=0;t<70;t+=7){let n=this.buf[this.pos++]??0;if(e+=(n&127)*2**t,n<128)break}return e}int64(){let e=0,t=0;for(let n=0;n<10;n+=1){let o=this.buf[this.pos++]??0,r=o&127;if(n<4)e|=r<<7*n;else if(n===4)e|=(r&15)<<28,t|=r>>4;else t|=r<<7*n-32;if(o<128)break}return(t|0)*4294967296+(e>>>0)}sint(){let e=this.varint();return e%2===1?-(e+1)/2:e/2}sub(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=new ue(this.buf,this.pos,t);return this.pos=t,n}string(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=qe.decode(this.buf.subarray(this.pos,t));return this.pos=t,n}float(){let e=this.pos+4<=this.end?this.view().getFloat32(this.pos,!0):0;return this.pos+=4,e}double(){let e=this.pos+8<=this.end?this.view().getFloat64(this.pos,!0):0;return this.pos+=8,e}view(){return new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength)}skip(e){if(e===0)this.varint();else if(e===1)this.pos+=8;else if(e===2)this.pos+=this.varint();else if(e===5)this.pos+=4}get more(){return this.pos<this.end}}var qe=new TextDecoder;function $e(e){let t="";while(e.more){let n=e.varint();switch(n>>3){case 1:t=e.string();break;case 2:t=e.float();break;case 3:t=e.double();break;case 4:t=e.int64();break;case 5:t=e.varint();break;case 6:t=e.sint();break;case 7:t=e.varint()!==0;break;default:e.skip(n&7)}}return t}function Ve(e){let t=[],n,[o,r]=[0,0];while(e.more){let i=e.varint(),a=i&7,s=i>>3;if(a===7){if(n&&n.length>=2)n.push(n[0]??0,n[1]??0);continue}for(let u=0;u<s&&e.more;u+=1){if(o+=e.sint(),r+=e.sint(),a===1)n=[],t.push(n);n?.push(o,r)}}return t}function xe(e,t){let n=new Map,o=new ue(e);while(o.more){let r=o.varint();if(r>>3!==3){o.skip(r&7);continue}let i=o.sub(),a="",s=4096,u=[],l=[],f=[];while(i.more){let m=i.varint();switch(m>>3){case 1:a=i.string();break;case 2:f.push(i.sub());break;case 3:u.push(i.string());break;case 4:l.push($e(i.sub()));break;case 5:s=i.varint();break;default:i.skip(m&7)}}if(t&&!t.has(a))continue;let g=[];for(let m of f){let I=1,c={},b=[];while(m.more){let k=m.varint();switch(k>>3){case 2:{let p=m.sub();while(p.more){let L=u[p.varint()],E=l[p.varint()];if(L!==void 0&&E!==void 0)c[L]=E}break}case 3:I=Math.min(3,Math.max(1,m.varint()));break;case 4:b=Ve(m.sub());break;default:m.skip(k&7)}}g.push({type:I,properties:c,geometry:b})}n.set(a,{extent:s,features:g})}return n}var Ue=96;function We(e,t,n,o,r,i){let a=new Uint8ClampedArray(i*i*4),s=i/r,u=r+1;for(let l=0;l<i;l+=1){let f=(l+0.5)/s,g=Math.min(r-1,Math.floor(f)),m=f-g;for(let I=0;I<i;I+=1){let c=(I+0.5)/s,b=Math.min(r-1,Math.floor(c)),k=c-b,p=2*(g*u+b),L=p+2*u,E=(1-k)*(1-m),W=k*(1-m),T=(1-k)*m,C=k*m,x=E*o[p]+W*o[p+2]+T*o[L]+C*o[L+2],v=E*o[p+1]+W*o[p+3]+T*o[L+1]+C*o[L+3],d=x-0.5,h=v-0.5;if(!(d>-1&&h>-1&&d<t&&h<n))continue;let A=Math.floor(d),y=Math.floor(h),N=d-A,S=h-y,F=0,J=0,M=0,R=0;for(let z=0;z<4;z+=1){let V=A+(z&1),O=y+(z>>1);if(V<0||O<0||V>=t||O>=n)continue;let B=4*(O*t+V),D=(z&1?N:1-N)*(z>>1?S:1-S)*e[B+3];F+=D*e[B],J+=D*e[B+1],M+=D*e[B+2],R+=D}if(R<=0)continue;let P=4*(l*i+I);a[P]=F/R,a[P+1]=J/R,a[P+2]=M/R,a[P+3]=R}}return a}function ve(e=Ue){let t=new Map,n=new Set,o=(l)=>{n.delete(l),l.then((f)=>f?.close(),()=>{return})},r=(l)=>{if(t.has(l))n.add(l);else o(l)},i=new H(e,r),a=(l)=>{let f=(t.get(l)??1)-1;if(f>0)t.set(l,f);else if(t.delete(l),n.has(l))o(l)},s=(l)=>{let f=i.get(l);if(!f)f=(async()=>{let g=await fetch(l);if(g.status===404||g.status===204||g.status===410)return null;if(!g.ok)throw Error(`isard: ${g.status} for a raster to reproject`);return createImageBitmap(await g.blob())})(),f.catch(()=>i.delete(l)),i.set(l,f);return t.set(f,(t.get(f)??0)+1),f};return{draw:async(l,f)=>{let g=l.sources.map((m)=>[m,s(m.url)]);try{let m=await Promise.all(g.map(async([p,L])=>[p,await L]));if(f.throwIfAborted(),!m.some(([,p])=>p))return null;let c=new OffscreenCanvas(l.width,l.height).getContext("2d",{willReadFrequently:!0});if(!c)throw Error("isard: no 2D canvas to reproject the tiles");for(let[p,L]of m)if(L)c.drawImage(L,p.x,p.y,p.w,p.h);let b=c.getImageData(0,0,l.width,l.height).data,k=We(b,l.width,l.height,l.mesh,l.n,l.size);return createImageBitmap(new ImageData(k,l.size,l.size),{premultiplyAlpha:"none"})}finally{for(let[,m]of g)a(m)}},cache:i,close:()=>{for(let l of i.values())r(l);i.clear()}}}function _e(e,t,n=Number.NEGATIVE_INFINITY){let o=e.length>>2,r=new Float32Array(o);if(t==="terrarium")for(let i=0,a=0;i<o;i+=1,a+=4){let s=e[a]*256+e[a+1]+e[a+2]/256-32768;r[i]=s>n?s:n}else for(let i=0,a=0;i<o;i+=1,a+=4){let s=-1e4+(e[a]*65536+e[a+1]*256+e[a+2])*0.1;r[i]=s>n?s:n}return r}async function ke(e,t,n,o,r){let i=await fetch(e,{signal:o});if(i.status===404||i.status===204||i.status===410)return null;if(!i.ok)throw Error(`${i.url}: ${i.status}`);let a=await createImageBitmap(await i.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"});try{r.canvas??=new OffscreenCanvas(256,256);let s=r.canvas.getContext("2d",{willReadFrequently:!0});if(!s)throw Error("no 2D context");return s.imageSmoothingEnabled=!1,s.clearRect(0,0,256,256),s.drawImage(a,0,0,256,256),_e(s.getImageData(0,0,256,256).data,t,n)}finally{a.close()}}var je="aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4 black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887 cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9 darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00 darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493 deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0 forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080 green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082 ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3 lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0 lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23 orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6 purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513 salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32",G;function He(e){if(!G){G=new Map;let t=je.split(" ");for(let n=0;n+1<t.length;n+=2)G.set(t[n],t[n+1])}return G.get(e)}var Q=(e)=>Number.isFinite(e)?Math.max(0,Math.min(1,e)):0;function Se(e){if(!/^[0-9a-f]+$/.test(e)||![3,4,6,8].includes(e.length))return;let t=e.length<=4?[...e].map((o)=>o+o).join(""):e,n=(o)=>Number.parseInt(t.slice(o,o+2),16)/255;return[n(0),n(2),n(4),t.length===8?n(6):1]}function Ze(e){if(e===void 0)return 1;return Q(e.endsWith("%")?Number.parseFloat(e)/100:Number.parseFloat(e))}function Ke(e,t,n){let o=n<0.5?n*(1+t):n+t-n*t,r=2*n-o,i=(a)=>{let s=(a%1+1)%1;if(s<0.16666666666666666)return r+(o-r)*6*s;if(s<0.5)return o;if(s<0.6666666666666666)return r+(o-r)*(0.6666666666666666-s)*6;return r};return[i(e+0.3333333333333333),i(e),i(e-0.3333333333333333)]}function Ae(e){if(typeof e!=="string")return;let t=e.trim().toLowerCase();if(t.startsWith("#"))return Se(t.slice(1));if(t==="transparent")return[0,0,0,0];let n=He(t);if(n)return Se(n);let o=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(t);if(!o?.[1]||o[2]===void 0)return;let r=o[2].split(/[\s,/]+/).filter(Boolean);if(r.length<3||r.slice(0,3).some((f)=>Number.isNaN(Number.parseFloat(f))))return;let i=Ze(r[3]);if(o[1].startsWith("rgb")){let f=(g)=>Q(g.endsWith("%")?Number.parseFloat(g)/100:Number.parseFloat(g)/255);return[f(r[0]),f(r[1]),f(r[2]),i]}let a=Number.parseFloat(r[0])/360,[s,u,l]=Ke(a,Q(Number.parseFloat(r[1])/100),Q(Number.parseFloat(r[2])/100));return[s,u,l,i]}var Xe=["Unknown","Point","LineString","Polygon"];function le(e,t){return{zoom:t,properties:e.properties,type:Xe[e.type]??"Unknown"}}function Z(e){return Ae(e)}function te([e,t,n,o]){return`rgba(${Math.round(e*255)},${Math.round(t*255)},${Math.round(n*255)},${o})`}function Ie(e,t,n,o=1){let r=n-t;if(r===0)return 0;let i=e-t;return o===1?i/r:(o**i-1)/(o**r-1)}function ce(e,t,n){if(typeof e==="number"&&typeof t==="number")return e+(t-e)*n;let o=Z(e),r=Z(t);if(o&&r)return te([0,1,2,3].map((i)=>(o[i]??0)+((r[i]??0)-(o[i]??0))*n));if(Array.isArray(e)&&Array.isArray(t))return e.map((i,a)=>ce(i,t[a],n));return n<0.5?e:t}function Ne(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.stops)}function Ye(e,t){let n=e.property===void 0?t.zoom:t.properties[e.property],o=e.stops,r=e.type??(e.property===void 0||typeof o[0]?.[0]==="number"?"exponential":"categorical");if(r==="identity")return n??e.default;if(r==="categorical")return o.find(([s])=>s===n)?.[1]??e.default;if(typeof n!=="number"||!o.length)return e.default??o[0]?.[1];let i=(s)=>typeof s[0]==="object"&&s[0]!==null?Number(s[0].zoom):Number(s[0]),a=o[0];if(!a)return e.default;if(n<=i(a))return a[1];for(let s=1;s<o.length;s+=1){let[u,l]=[o[s-1],o[s]];if(!u||!l)continue;if(n<i(l)){if(r==="interval")return u[1];return ce(u[1],l[1],Ie(n,i(u),i(l),e.base??1))}}return o.at(-1)?.[1]}function ee(e,t){if(t==="$type")return e.type;return typeof t==="string"?e.properties[t]:void 0}var Ge=new Set(["literal","zoom","get","has","!has","properties","id","geometry-type","concat","format","image","number-format","to-number","to-string","to-boolean","to-color","number","string","boolean","typeof","length","at","upcase","downcase","coalesce","!","all","any","==","!=","<","<=",">",">=","in","case","match","step","interpolate","interpolate-hcl","interpolate-lab","rgb","rgba","+","-","*","/","%","^","min","max","abs","round","floor","ceil","sqrt","ln","log10","log2","pi","e"]);function ne(e){return Array.isArray(e)&&typeof e[0]==="string"&&Ge.has(e[0])}var Me=new Set,K=(e)=>e===void 0||e===null?"":String(e);function q(e,t){if(Ne(e))return Ye(e,t);if(!Array.isArray(e))return e;let[n,...o]=e;if(typeof n!=="string")return e;let r=(s)=>q(o[s]??null,t),i=(s)=>Number(r(s)),a=()=>o.map((s,u)=>i(u));switch(n){case"literal":return o[0];case"zoom":return t.zoom;case"get":return ee(t,r(0));case"has":return ee(t,r(0))!==void 0;case"!has":return ee(t,r(0))===void 0;case"properties":return t.properties;case"id":return null;case"geometry-type":return t.type;case"concat":return o.map((s,u)=>K(r(u))).join("");case"format":return o.map((s,u)=>s!==null&&typeof s==="object"&&!Array.isArray(s)?"":K(r(u))).join("");case"image":return r(0);case"number-format":{let s=o[1]??{},u=i(0);if(!Number.isFinite(u))return"";return u.toLocaleString(s.locale,{minimumFractionDigits:s["min-fraction-digits"],maximumFractionDigits:s["max-fraction-digits"]})}case"to-number":{for(let s=0;s<o.length;s+=1){let u=r(s),l=typeof u==="string"&&u.trim()===""?Number.NaN:Number(u);if(u!==null&&u!==void 0&&!Number.isNaN(l))return l}return 0}case"to-string":return K(r(0));case"to-boolean":{let s=r(0);return!(s===""||s===0||s===!1||s===null||s===void 0||Number.isNaN(s))}case"to-color":case"number":case"string":case"boolean":{let s={"to-color":(u)=>Z(u)!==void 0,number:(u)=>typeof u==="number",string:(u)=>typeof u==="string",boolean:(u)=>typeof u==="boolean"};for(let u=0;u<o.length;u+=1){let l=r(u);if(s[n]?.(l))return l}return o.length?r(o.length-1):null}case"typeof":{let s=r(0);if(s===null||s===void 0)return"null";return Array.isArray(s)?"array":typeof s}case"length":{let s=r(0);return typeof s==="string"||Array.isArray(s)?s.length:0}case"at":{let s=r(1);return Array.isArray(s)?s[i(0)]??null:null}case"upcase":return K(r(0)).toUpperCase();case"downcase":return K(r(0)).toLowerCase();case"coalesce":for(let s=0;s<o.length;s+=1){let u=r(s);if(u!==void 0&&u!==null)return u}return null;case"!":return!r(0);case"all":return o.every((s,u)=>Boolean(r(u)));case"any":return o.some((s,u)=>Boolean(r(u)));case"==":return r(0)===r(1);case"!=":return r(0)!==r(1);case"<":return r(0)<r(1);case"<=":return r(0)<=r(1);case">":return r(0)>r(1);case">=":return r(0)>=r(1);case"in":{let s=r(1),u=r(0);if(typeof s==="string")return s.includes(String(u));return Array.isArray(s)&&s.includes(u)}case"case":{for(let s=0;s+1<o.length;s+=2)if(r(s))return r(s+1);return r(o.length-1)}case"match":{let s=r(0);for(let u=1;u+1<o.length;u+=2){let l=o[u];if(Array.isArray(l)?l.includes(s):l===s)return r(u+1)}return r(o.length-1)}case"step":{let s=i(0),u=r(1);for(let l=2;l+1<o.length;l+=2)if(s>=Number(o[l]))u=r(l+1);else break;return u}case"interpolate":case"interpolate-hcl":case"interpolate-lab":{let s=o[0],u=i(1),l=Array.isArray(s)&&s[0]==="exponential"?Number(s[1]):1,f=[];for(let m=2;m+1<o.length;m+=2)f.push([Number(o[m]),o[m+1]??null]);let g=f[0];if(!g)return null;if(u<=g[0])return q(g[1],t);for(let m=1;m<f.length;m+=1){let[I,c]=[f[m-1],f[m]];if(I&&c&&u<c[0])return ce(q(I[1],t),q(c[1],t),Ie(u,I[0],c[0],l))}return q(f.at(-1)?.[1]??null,t)}case"rgb":case"rgba":return te([i(0)/255,i(1)/255,i(2)/255,o.length>3?i(3):1]);case"+":return a().reduce((s,u)=>s+u,0);case"*":return a().reduce((s,u)=>s*u,1);case"-":return o.length===1?-i(0):i(0)-i(1);case"/":return i(0)/i(1);case"%":return i(0)%i(1);case"^":return i(0)**i(1);case"min":return Math.min(...a());case"max":return Math.max(...a());case"abs":return Math.abs(i(0));case"round":return Math.sign(i(0))*Math.round(Math.abs(i(0)));case"floor":return Math.floor(i(0));case"ceil":return Math.ceil(i(0));case"sqrt":return Math.sqrt(i(0));case"ln":return Math.log(i(0));case"log10":return Math.log10(i(0));case"log2":return Math.log2(i(0));case"pi":return Math.PI;case"e":return Math.E;default:if(!Me.has(n))Me.add(n),console.warn(`isard: the style expression "${n}" is not supported`);return null}}var Qe=new Set(["==","!=","<","<=",">",">="]);function et(e){let[t,n,...o]=e;if(typeof t!=="string"||typeof n!=="string"||o.some(Array.isArray))return!1;if(Qe.has(t))return e.length===3;if(t==="in")return e.length!==3||!Array.isArray(e[2]);return t==="!in"||t==="has"||t==="!has"}function tt(e,t){let[n,o,...r]=e,i=ee(t,o);switch(n){case"==":return i===r[0];case"!=":return i!==r[0];case"<":return i<r[0];case"<=":return i<=r[0];case">":return i>r[0];case">=":return i>=r[0];case"in":return r.includes(i);case"!in":return!r.includes(i);case"has":return i!==void 0;case"!has":return i===void 0;default:return!0}}var Ce=new WeakMap;function Le(e){if(!Array.isArray(e))return()=>Boolean(e);let t=Ce.get(e);if(t)return t;let n,o=e[0];if(o==="all"||o==="any"||o==="none"){let r=e.slice(1).map(Le);if(o==="all")n=(i)=>r.every((a)=>a(i));else if(o==="any")n=(i)=>r.some((a)=>a(i));else n=(i)=>!r.some((a)=>a(i))}else if(et(e))n=(r)=>tt(e,r);else n=(r)=>Boolean(q(e,r));return Ce.set(e,n),n}function fe(e,t){if(e===void 0||e===null)return!0;return Le(e)(t)}function X(e){if(e!==void 0&&Ne(e))return e.property!==void 0;if(!Array.isArray(e))return!1;if(["get","has","!has","geometry-type","properties","id"].includes(e[0]))return!0;return e.some((t)=>X(t))}function me(e,t){if(e===void 0||e===null)return"";if(typeof e==="string")return e.replace(/\{([^}]+)\}/g,(o,r)=>{let i=t.properties[r];return i===void 0?"":String(i)});let n=q(e,t);if(Array.isArray(n))return n.filter((o)=>typeof o==="string").join("");return n===void 0||n===null?"":String(n)}function Pe(e){return/Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(e)?e:`${e} Regular`}function pe(e){let t=new Set,n=(a)=>{if(!Array.isArray(a))return;let s=(u)=>Array.isArray(u)&&u[0]==="zoom";if((a[0]==="interpolate"||a[0]==="interpolate-hcl"||a[0]==="interpolate-lab")&&s(a[2]))for(let u=3;u<a.length;u+=2)t.add(Number(a[u]));else if(a[0]==="step"&&s(a[1]))for(let u=3;u<a.length;u+=2){let l=Number(a[u]);t.add(l),t.add(l-0.01)}for(let u of a)n(u)};n(e);let o=[...t].filter(Number.isFinite);if(o.length===0)o.push(0);let[r,i]=[Math.min(...o),Math.max(...o)];for(let a=Math.ceil(r);a<=Math.floor(i);a+=1)o.push(a);return[...new Set(o)].sort((a,s)=>a-s).map((a)=>[a,Number(q(e,{zoom:a,properties:{},type:"Unknown"}))])}function Je(e,t){for(let n of e.sprites){let o=n.icons[t];if(o)return{icon:o,image:n.image}}return}var re=new Map,Fe=96,oe=new H(Fe);function nt(e){return Math.max(16,Math.ceil(Fe/Math.max(1,e)))}var de=new Set,Y=new Set,ge=new Map,rt={},Re=ve(),be=new H(64,(e)=>e.then((t)=>setTimeout(()=>t?.close(),0),()=>{return}));function ot(e,t="auto"){let n=be.get(e);if(n)return n;let o=(async()=>{let i=await fetch(e,{priority:t});if(i.status===404||i.status===204)return;if(!i.ok)throw Error(`${e}: ${i.status}`);return createImageBitmap(await i.blob())})();return o.catch(()=>be.delete(e)),be.set(e,o),o}function Ee(e,t="auto"){let n=oe.get(e);if(n)return n;let o=(async()=>{for(let r=0;;r+=1){let a=await fetch(e,{priority:t});if(a.status===404||a.status===204)return;if(a.ok)return xe(new Uint8Array(await a.arrayBuffer()));if(r>=2)throw Error(`${e}: ${a.status}`);await new Promise((s)=>setTimeout(s,400*(r+1)))}})();return o.catch(()=>oe.delete(e)),oe.set(e,o),o}function it(e,t,n,o){let r=Math.max(0,Math.min(t-1,e.maxzoom)),i=t-r,a=2**Math.max(0,i),[s,u]=i>=0?[Math.floor(n/a),Math.floor(o/a)]:[n,o],l=e.tiles.replace("{z}",String(r)).replace("{x}",String(s)).replace("{y}",String(u)),f=1/a;return{url:l,vz:r,vx:s,vy:u,part:f,ox:n%a*f,oy:o%a*f}}var w=(e,t,n,o,r)=>{let i=e[t]?.[n];if(i===void 0)return r;let a=Array.isArray(i)&&!ne(i)?i:q(i,o);return a===void 0||a===null?r:a};function _(e,t){let n=Z(e)??[0,0,0,1];return te([n[0],n[1],n[2],n[3]*t])}function Te(e,t){if(e.layout?.visibility==="none")return!1;return t>=(e.minzoom??0)&&t<(e.maxzoom??24)}function st(e,t){if(e.patterns.has(t))return e.patterns.get(t);let n=Je(e,t),o;if(n&&n.icon.width>0&&n.icon.height>0){let{icon:r}=n;o=new OffscreenCanvas(r.width,r.height),o.getContext("2d")?.drawImage(n.image,r.x,r.y,r.width,r.height,0,0,r.width,r.height)}return e.patterns.set(t,o),o}var he=new Map;function at(e){let t=he.get(e)?.pop()??new OffscreenCanvas(e,e),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw Error("no 2D context");return n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.setLineDash([]),n.clearRect(0,0,e,e),{canvas:t,g:n}}function ut(e){let t=he.get(e.width)??[];if(he.set(e.width,t),t.length<4)t.push(e)}function lt(e,t,n){if(n)return Promise.resolve(e.transferToImageBitmap());return createImageBitmap(t.getImageData(0,0,e.width,e.height),{premultiplyAlpha:"none"})}async function ct(e,t,n,o,r,i,a){let s=it(e,t,n,o),u=await Ee(s.url,a);if(Y.has(i))return;let{canvas:l,g:f}=at(r);try{return await ft(e,s,u,l,f,t,n,o,r,i,a)}finally{ut(l)}}async function ft(e,t,n,o,r,i,a,s,u,l,f){let g=Math.max(0,i-1),m=u/256,I=!1,c=!1;for(let b of e.layers){if(!Te(b,g))continue;let k={zoom:g,properties:{},type:"Unknown"};if(b.type==="background"){let v=w(b,"paint","background-color",k,"#000"),d=Number(w(b,"paint","background-opacity",k,1));if(r.fillStyle=_(v,d),r.fillRect(0,0,u,u),(Z(v)??[0,0,0,1])[3]*d>=1)c=!0;I=!0;continue}if(b.type==="raster"){let v=b.source===void 0?void 0:e.rasters[b.source];if(!v)continue;let d=Math.max(0,Math.min(i-(v.tileSize>=512?1:0),v.maxzoom)),h=2**(i-d),A=v.tiles.replace("{z}",String(d)).replace("{x}",String(Math.floor(a/h))).replace("{y}",String(Math.floor(s/h))),y=await ot(A,f).catch(()=>{return});if(Y.has(l))return;if(!y)continue;let[N,S]=[y.width/h,y.height/h];r.globalAlpha=Number(w(b,"paint","raster-opacity",k,1)),r.drawImage(y,a%h*N,s%h*S,N,S,0,0,u,u),r.globalAlpha=1,I=!0;continue}let p=n?.get(b["source-layer"]??"");if(!p)continue;let L=u/(p.extent*t.part),[E,W]=[t.ox*p.extent,t.oy*p.extent],T=(v,d)=>{r.beginPath();for(let h of v.geometry){for(let A=0;A+1<h.length;A+=2){let[y,N]=[((h[A]??0)-E)*L,((h[A+1]??0)-W)*L];if(A===0)r.moveTo(y,N);else r.lineTo(y,N)}if(d)r.closePath()}},C=new Map,x=(v,d,h,A)=>{let y=C.get(d);if(y===void 0)y=X(b[v]?.[d]),C.set(d,y);return w(b,v,d,y?h:k,A)};for(let v of p.features){let d=le(v,g);if(!fe(b.filter,d))continue;if(b.type==="fill-extrusion"&&v.type===3)T(v,!0),r.fillStyle=_(x("paint","fill-extrusion-color",d,"#000"),Number(x("paint","fill-extrusion-opacity",d,1))),r.fill("evenodd"),I=!0;else if(b.type==="fill"&&v.type===3){let h=Number(x("paint","fill-opacity",d,1)),A=x("paint","fill-pattern",d,void 0);T(v,!0);let y=typeof A==="string"?Je(e,A)?.icon:void 0,N=y&&st(e,A);if(y&&N){let S=r.createPattern(N,"repeat");if(S)S.setTransform(new DOMMatrix().scale(m/(y.pixelRatio??1))),r.globalAlpha=h,r.fillStyle=S,r.fill("evenodd"),r.globalAlpha=1}else{r.fillStyle=_(x("paint","fill-color",d,"#000"),h),r.fill("evenodd");let S=x("paint","fill-outline-color",d,void 0);if(S!==void 0)r.strokeStyle=_(S,h),r.lineWidth=m,r.setLineDash([]),r.stroke()}I=!0}else if(b.type==="line"&&v.type!==1){let h=Number(x("paint","line-width",d,1));if(h<=0)continue;let A=Number(x("paint","line-gap-width",d,0));r.strokeStyle=_(x("paint","line-color",d,"#000"),Number(x("paint","line-opacity",d,1))),r.lineWidth=(A>0?A+2*h:h)*m,r.lineCap=String(x("layout","line-cap",d,"butt")),r.lineJoin=String(x("layout","line-join",d,"miter"));let y=x("paint","line-dasharray",d,void 0);r.setLineDash(Array.isArray(y)?y.map((N)=>Number(N)*h*m):[]),T(v,v.type===3),r.stroke(),I=!0}else if(b.type==="circle"&&v.type===1){let h=Number(x("paint","circle-radius",d,5))*m;r.fillStyle=_(x("paint","circle-color",d,"#000"),Number(x("paint","circle-opacity",d,1)));let A=Number(x("paint","circle-stroke-width",d,0))*m;r.strokeStyle=_(x("paint","circle-stroke-color",d,"#000"),Number(x("paint","circle-stroke-opacity",d,1))),r.lineWidth=A;for(let y of v.geometry)for(let N=0;N+1<y.length;N+=2)if(r.beginPath(),r.arc(((y[N]??0)-E)*L,((y[N+1]??0)-W)*L,h,0,2*Math.PI),r.fill(),A>0)r.stroke();I=!0}}}if(!I&&!n)return null;return lt(o,r,c)}function ze(e,t,n){let o=Boolean(w(e,"layout",`${t}-allow-overlap`,n,!1)),r=Boolean(w(e,"layout",`${t}-ignore-placement`,n,!1));if(o&&r)return!0;if(o)return"allow";return r?"ignore":!1}function mt(e,t){return Array.isArray(e)?[Number(e[0]??t[0]),Number(e[1]??t[1])]:t}function pt(e){let t=(Array.isArray(e)?e:[e]).map((a)=>Number(a)||0),[n=0,o=n,r=n,i=o]=t;return[n,o,r,i]}function dt(e,t){let n=0;for(let a=2;a+1<e.length;a+=2)n+=Math.hypot((e[a]??0)-(e[a-2]??0),(e[a+1]??0)-(e[a-1]??0));let o=[];if(!(n>0)||!(t>0))return o;let r=Math.min(t/2,n/2),i=0;for(let a=2;a+1<e.length;a+=2){let[s,u,l,f]=[e[a-2]??0,e[a-1]??0,e[a]??0,e[a+1]??0],g=Math.hypot(l-s,f-u);while(g>0&&r<=i+g){let m=(r-i)/g;o.push([s+(l-s)*m,u+(f-u)*m,s,u,l,f]),r+=t}i+=g}return o}function j(e,t,n,o,r,i){let a=2**e;return[ye((t+r/o)/a),we((n+i/o)/a)]}function bt(e,t,n,o,r){let i=w(e,"layout","icon-rotation-alignment",n,"auto"),a=String(w(e,"layout","icon-text-fit",n,"none")),s=w(e,"layout","icon-text-fit-padding",n,[0,0,0,0]);return{image:t,size:X(e.layout?.["icon-size"])?Number(w(e,"layout","icon-size",n,1)):r(e),anchor:String(w(e,"layout","icon-anchor",n,"center")),offset:mt(w(e,"layout","icon-offset",n,[0,0]),[0,0]),rotate:Number(w(e,"layout","icon-rotate",n,0))||0,alignment:i==="map"||i==="auto"&&o==="line"?"map":"viewport",overlap:ze(e,"icon",n),optional:Boolean(w(e,"layout","icon-optional",n,!1)),fit:a==="width"||a==="height"||a==="both"?a:"none",padding:pt(s),color:String(w(e,"paint","icon-color",n,"#000")),opacity:Number(w(e,"paint","icon-opacity",n,1))}}async function gt(e,t,n,o,r,i,a=t){let s=e.tiles.replace("{z}",String(t)).replace("{x}",String(n)).replace("{y}",String(o)),u=await Ee(s,i);if(!u||Y.has(r))return[];let l=[],f=new Map,g=(c)=>{let b=f.get(c);if(b===void 0){let k=c.layout?.["text-size"]??16;b=ne(k)?pe(k):k,f.set(c,b)}return b},m=new Map,I=(c)=>{let b=m.get(c);if(b===void 0){let k=c.layout?.["icon-size"]??1;b=ne(k)?pe(k):k,m.set(c,b)}return b};return e.layers.forEach((c,b)=>{let k=c.layout??{};if(c.type!=="symbol"||!Te(c,a))return;if(k["text-field"]===void 0&&k["icon-image"]===void 0)return;let p=u.get(c["source-layer"]??"");if(!p)return;let L={zoom:a,properties:{},type:"Unknown"},E=w(c,"layout","symbol-placement",L,"point")==="line"?"line":"point",W=E==="line"&&w(c,"layout","text-rotation-alignment",L,"auto")!=="viewport";for(let T of p.features){let C=le(T,a);if(!fe(c.filter,C))continue;let x=me(k["text-field"],C).trim(),v=me(k["icon-image"],C).trim();if(!x&&!v)continue;let d=w(c,"layout","text-transform",C,"none");if(d==="uppercase")x=x.toUpperCase();else if(d==="lowercase")x=x.toLowerCase();let h=w(c,"layout","text-font",C,["Noto Sans Regular"]),A=Pe(Array.isArray(h)&&typeof h[0]==="string"?h[0]:"Noto Sans Regular"),y=w(c,"layout","text-offset",C,[0,0]),N={layer:b,text:x,font:A,size:X(c.layout?.["text-size"])?Number(w(c,"layout","text-size",C,16)):g(c),color:String(w(c,"paint","text-color",C,"#000")),haloColor:String(w(c,"paint","text-halo-color",C,"rgba(0,0,0,0)")),haloWidth:Number(w(c,"paint","text-halo-width",C,0)),anchor:String(w(c,"layout","text-anchor",C,"center")),offset:Array.isArray(y)?[Number(y[0]??0),Number(y[1]??0)]:[0,0],maxWidth:Number(w(c,"layout","text-max-width",C,10)),lineHeight:Number(w(c,"layout","text-line-height",C,1.2)),overlap:ze(c,"text",C),...W?{textAlong:W}:{},...w(c,"layout","text-optional",C,!1)?{textOptional:!0}:{},...v?{icon:bt(c,v,C,E,I)}:{}};if(T.type===1)for(let S of T.geometry)for(let F=0;F+1<S.length;F+=2){let[J,M]=[S[F]??0,S[F+1]??0];if(J<0||M<0||J>=p.extent||M>=p.extent)continue;let[R,P]=j(t,n,o,p.extent,J,M);l.push({...N,lon:R,lat:P})}else if(!x&&E==="line"){let S=Number(w(c,"layout","symbol-spacing",C,250))*p.extent/(512*2**(a-t));for(let F of T.geometry)for(let[J=0,M=0,R=0,P=0,z=0,V=0]of dt(F,Math.max(S,1))){if(J<0||M<0||J>=p.extent||M>=p.extent)continue;let[O,B]=j(t,n,o,p.extent,J,M),[D,ie]=j(t,n,o,p.extent,z,V),[se,ae]=j(t,n,o,p.extent,R,P);l.push({...N,lon:O,lat:B,along:[D-se,ie-ae]})}}else{let S,F=0;for(let M of T.geometry){let R=0;for(let P=2;P+1<M.length;P+=2)R+=Math.hypot((M[P]??0)-(M[P-2]??0),(M[P+1]??0)-(M[P-1]??0));if(R>F)F=R,S=M}if(!S||F<p.extent/32)continue;let J=F/2;for(let M=2;M+1<S.length;M+=2){let[R,P,z,V]=[S[M-2]??0,S[M-1]??0,S[M]??0,S[M+1]??0],O=Math.hypot(z-R,V-P);if(O>=J&&O>0){let[B,D]=[R+(z-R)*J/O,P+(V-P)*J/O];if(B<0||D<0||B>=p.extent||D>=p.extent)break;let[ie,se]=j(t,n,o,p.extent,B,D),[ae,Oe]=j(t,n,o,p.extent,z,V),[Be,De]=j(t,n,o,p.extent,R,P);l.push({...N,lon:ie,lat:se,...E==="line"?{along:[ae-Be,Oe-De]}:{}});break}J-=O}}}}),l}var U=(e,t=[])=>self.postMessage(e,t);self.onmessage=async({data:e})=>{if(e.type==="init"){if(e.workers!==void 0)oe.capacity=nt(e.workers);re.set(e.key,{tiles:e.tiles,maxzoom:e.maxzoom,layers:e.layers,rasters:e.rasters??{},sprites:e.sprites??[],patterns:new Map});return}if(e.type==="drop"){for(let n of re.get(e.key)?.sprites??[])n.image.close();re.delete(e.key);return}if(e.type==="abort"){if(de.has(e.id))Y.add(e.id);ge.get(e.id)?.abort();return}if(e.type==="heights"||e.type==="reproject"){await ht(e);return}de.add(e.id);let t=re.get(e.key);try{if(!t)throw Error(`no renderer ${e.key}`);if(e.type==="render"){let n=await ct(t,e.z,e.x,e.y,e.size,e.id,e.priority);if(n)U({id:e.id,image:n},[n]);else U({id:e.id,missing:!0})}else U({id:e.id,labels:await gt(t,e.z,e.x,e.y,e.id,e.priority,e.zoom)})}catch(n){U({id:e.id,error:String(n)})}finally{de.delete(e.id),Y.delete(e.id)}};async function ht(e){let t=new AbortController;ge.set(e.id,t);try{if(e.type==="heights"){let n=await ke(e.url,e.encoding,e.floor,t.signal,rt);if(n)U({id:e.id,heights:n},[n.buffer]);else U({id:e.id,missing:!0})}else{Re.cache.capacity=e.cached;let n=await Re.draw(e.job,t.signal);if(n)U({id:e.id,image:n},[n]);else U({id:e.id,missing:!0})}}catch(n){U({id:e.id,error:String(n)})}finally{ge.delete(e.id)}}export{nt as cacheShare,dt as lineAnchors,lt as tileImage};
|
|
1
|
+
function ve(e){return e*360-180}function ke(e){return Math.atan(Math.sinh(Math.PI*(1-2*e)))*180/Math.PI}class H{capacity;evict;entries=new Map;constructor(e,t){this.capacity=e;this.evict=t}get size(){return this.entries.size}get(e){let t=this.entries.get(e);if(t!==void 0)this.entries.delete(e),this.entries.set(e,t);return t}has(e){return this.entries.has(e)}set(e,t){this.entries.delete(e),this.entries.set(e,t);for(let[n,o]of this.entries){if(this.entries.size<=this.capacity)break;this.entries.delete(n),this.evict?.(o,n)}}delete(e){return this.entries.delete(e)}values(){return this.entries.values()}clear(){this.entries.clear()}}class le{buf;end;pos;constructor(e,t=0,n=e.length){this.buf=e;this.end=n;this.pos=t}varint(){let e=0;for(let t=0;t<70;t+=7){let n=this.buf[this.pos++]??0;if(e+=(n&127)*2**t,n<128)break}return e}int64(){let e=0,t=0;for(let n=0;n<10;n+=1){let o=this.buf[this.pos++]??0,r=o&127;if(n<4)e|=r<<7*n;else if(n===4)e|=(r&15)<<28,t|=r>>4;else t|=r<<7*n-32;if(o<128)break}return(t|0)*4294967296+(e>>>0)}sint(){let e=this.varint();return e%2===1?-(e+1)/2:e/2}sub(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=new le(this.buf,this.pos,t);return this.pos=t,n}string(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=Ze.decode(this.buf.subarray(this.pos,t));return this.pos=t,n}float(){let e=this.pos+4<=this.end?this.view().getFloat32(this.pos,!0):0;return this.pos+=4,e}double(){let e=this.pos+8<=this.end?this.view().getFloat64(this.pos,!0):0;return this.pos+=8,e}view(){return new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength)}skip(e){if(e===0)this.varint();else if(e===1)this.pos+=8;else if(e===2)this.pos+=this.varint();else if(e===5)this.pos+=4}get more(){return this.pos<this.end}}var Ze=new TextDecoder;function je(e){let t="";while(e.more){let n=e.varint();switch(n>>3){case 1:t=e.string();break;case 2:t=e.float();break;case 3:t=e.double();break;case 4:t=e.int64();break;case 5:t=e.varint();break;case 6:t=e.sint();break;case 7:t=e.varint()!==0;break;default:e.skip(n&7)}}return t}function _e(e){let t=[],n,[o,r]=[0,0];while(e.more){let i=e.varint(),a=i&7,s=i>>3;if(a===7){if(n&&n.length>=2)n.push(n[0]??0,n[1]??0);continue}for(let u=0;u<s&&e.more;u+=1){if(o+=e.sint(),r+=e.sint(),a===1)n=[],t.push(n);n?.push(o,r)}}return t}function ce(e,t){let n=new Map,o=new le(e);while(o.more){let r=o.varint();if(r>>3!==3){o.skip(r&7);continue}let i=o.sub(),a="",s=4096,u=[],l=[],c=[];while(i.more){let m=i.varint();switch(m>>3){case 1:a=i.string();break;case 2:c.push(i.sub());break;case 3:u.push(i.string());break;case 4:l.push(je(i.sub()));break;case 5:s=i.varint();break;default:i.skip(m&7)}}if(t&&!t.has(a))continue;let h=[];for(let m of c){let C=1,f={},b=[];while(m.more){let k=m.varint();switch(k>>3){case 2:{let d=m.sub();while(d.more){let L=u[d.varint()],J=l[d.varint()];if(L!==void 0&&J!==void 0)f[L]=J}break}case 3:C=Math.min(3,Math.max(1,m.varint()));break;case 4:b=_e(m.sub());break;default:m.skip(k&7)}}h.push({type:C,properties:f,geometry:b})}n.set(a,{extent:s,features:h})}return n}var Ke=127,Xe=16384,Ye=["unknown","mvt","png","jpeg","webp","avif"],Ge=(e)=>(4**e-1)/3;function Qe(e,t,n){if(e>26)throw Error(`isard: PMTiles level ${e} past 26`);let o=2**e;if(t<0||n<0||t>=o||n>=o)throw Error(`isard: PMTiles tile ${e}/${t}/${n} out of its level`);let[r,i]=[t,n],a=0;for(let s=o/2;s>=1;s/=2){let u=(r&s)>0?1:0,l=(i&s)>0?1:0;if(a+=s*s*(3*u^l),l===0){if(u===1)[r,i]=[s-1-r,s-1-i];[r,i]=[i,r]}}return Ge(e)+a}class Me{bytes;pos=0;constructor(e){this.bytes=e}next(){let e=0,t=1;for(;;){let n=this.bytes[this.pos++];if(n===void 0)throw Error("isard: PMTiles directory truncated");if(e+=(n&127)*t,n<128)return e;if(t*=128,t>9223372036854776000)throw Error("isard: PMTiles varint too long")}}}function Ae(e){let t=new Me(e),n=t.next();if(n>e.length)throw Error("isard: PMTiles directory larger than its bytes");let o=[],r=0;for(let i=0;i<n;i+=1)r+=t.next(),o.push({tileId:r,offset:0,length:0,runLength:1});for(let i of o)i.runLength=t.next();for(let i of o)i.length=t.next();return o.forEach((i,a)=>{let s=t.next(),u=o[a-1];i.offset=s===0&&u?u.offset+u.length:s-1}),o}function et(e,t){let[n,o]=[0,e.length-1];while(n<=o){let i=n+o>>1,a=e[i];if(a.tileId===t)return a;if(a.tileId<t)n=i+1;else o=i-1}let r=e[o];if(!r)return;if(r.runLength===0||t-r.tileId<r.runLength)return r;return}function tt(e){if(e.length<Ke||String.fromCharCode(...e.subarray(0,7))!=="PMTiles")throw Error("isard: not a PMTiles archive");if(e[7]!==3)throw Error(`isard: PMTiles version ${e[7]} (only 3 is read)`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(r)=>Number(t.getBigUint64(r,!0)),o=(r)=>t.getInt32(r,!0)/1e7;return{rootDirectoryOffset:n(8),rootDirectoryLength:n(16),metadataOffset:n(24),metadataLength:n(32),leafDirectoryOffset:n(40),leafDirectoryLength:n(48),tileDataOffset:n(56),tileDataLength:n(64),internalCompression:t.getUint8(97),tileCompression:t.getUint8(98),tileType:Ye[t.getUint8(99)]??"unknown",minZoom:t.getUint8(100),maxZoom:t.getUint8(101),bounds:[o(102),o(106),o(110),o(114)],center:[o(119),o(123),t.getUint8(118)]}}async function G(e,t){if(t===0||t===1)return e;if(t!==2)throw Error(`isard: PMTiles compression ${t===3?"brotli":"zstd"} is not read (gzip only)`);let n=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(n).arrayBuffer())}var nt=67108864;class Pe{source;head;leaves=new H(64);whole;constructor(e){this.source=e}async range(e,t,n){if(typeof this.source!=="string")return new Uint8Array(await this.source.slice(e,e+t).arrayBuffer());if(this.whole)return(await this.whole).subarray(e,e+t);let o=await fetch(this.source,{headers:{Range:`bytes=${e}-${e+Math.max(t,1)-1}`},...n?{signal:n}:{}});if(!o.ok)throw Error(`${this.source}: HTTP ${o.status}`);if(o.status===206)return new Uint8Array(await o.arrayBuffer());if(Number(o.headers.get("Content-Length"))>nt)throw await o.body?.cancel(),Error(`${this.source}: the server ignores range requests (HTTP 206 expected)`);let i=o.arrayBuffer().then((a)=>new Uint8Array(a));return this.whole=i,i.catch(()=>{this.whole=void 0}),(await i).subarray(e,e+t)}load(){return this.head??=(async()=>{let e=await this.range(0,Xe),t=tt(e),{rootDirectoryOffset:n,rootDirectoryLength:o}=t,r=n+o<=e.length?e.subarray(n,n+o):await this.range(n,o),i=Ae(await G(r,t.internalCompression));return{header:t,root:i}})(),this.head.catch(()=>{this.head=void 0}),this.head}async header(){return(await this.load()).header}async metadata(){let{header:e}=await this.load();if(e.metadataLength===0)return{};let t=await this.range(e.metadataOffset,e.metadataLength),n=new TextDecoder().decode(await G(t,e.internalCompression)),o=JSON.parse(n);return o&&typeof o==="object"&&!Array.isArray(o)?o:{}}leaf(e,t){let n=e.leafDirectoryOffset+t.offset,o=this.leaves.get(n);if(!o)o=this.range(n,t.length).then(async(r)=>Ae(await G(r,e.internalCompression))),o.catch(()=>this.leaves.delete(n)),this.leaves.set(n,o);return o}async tile(e,t,n,o){let{header:r,root:i}=await this.load();if(e<r.minZoom||e>r.maxZoom)return;let a=Qe(e,t,n),s=i;for(let u=0;u<4;u+=1){let l=et(s,a);if(!l)return;if(l.runLength>0){let c=await this.range(r.tileDataOffset+l.offset,l.length,o);return G(c,r.tileCompression)}s=await this.leaf(r,l)}throw Error("isard: PMTiles directories nested too deep")}}var Se=new H(16);function rt(e){let t=Se.get(e);if(!t)t=new Pe(e),Se.set(e,t);return t}function fe(e,t){let n=/^pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)$/.exec(e);if(!n)return!1;let[,o="",r,i,a]=n;return rt(o).tile(Number(r),Number(i),Number(a),t)}var ot=96;function it(e,t,n,o,r,i){let a=new Uint8ClampedArray(i*i*4),s=i/r,u=r+1;for(let l=0;l<i;l+=1){let c=(l+0.5)/s,h=Math.min(r-1,Math.floor(c)),m=c-h;for(let C=0;C<i;C+=1){let f=(C+0.5)/s,b=Math.min(r-1,Math.floor(f)),k=f-b,d=2*(h*u+b),L=d+2*u,J=(1-k)*(1-m),W=k*(1-m),O=(1-k)*m,P=k*m,x=J*o[d]+W*o[d+2]+O*o[L]+P*o[L+2],v=J*o[d+1]+W*o[d+3]+O*o[L+1]+P*o[L+3],p=x-0.5,g=v-0.5;if(!(p>-1&&g>-1&&p<t&&g<n))continue;let S=Math.floor(p),y=Math.floor(g),I=p-S,A=g-y,R=0,E=0,M=0,T=0;for(let D=0;D<4;D+=1){let q=S+(D&1),F=y+(D>>1);if(q<0||F<0||q>=t||F>=n)continue;let B=4*(F*t+q),z=(D&1?I:1-I)*(D>>1?A:1-A)*e[B+3];R+=z*e[B],E+=z*e[B+1],M+=z*e[B+2],T+=z}if(T<=0)continue;let N=4*(l*i+C);a[N]=R/T,a[N+1]=E/T,a[N+2]=M/T,a[N+3]=T}}return a}function Ce(e=ot){let t=new Map,n=new Set,o=(l)=>{n.delete(l),l.then((c)=>c?.close(),()=>{return})},r=(l)=>{if(t.has(l))n.add(l);else o(l)},i=new H(e,r),a=(l)=>{let c=(t.get(l)??1)-1;if(c>0)t.set(l,c);else if(t.delete(l),n.has(l))o(l)},s=(l)=>{let c=i.get(l);if(!c)c=(async()=>{let h=await fetch(l);if(h.status===404||h.status===204||h.status===410)return null;if(!h.ok)throw Error(`isard: ${h.status} for a raster to reproject`);return createImageBitmap(await h.blob())})(),c.catch(()=>i.delete(l)),i.set(l,c);return t.set(c,(t.get(c)??0)+1),c};return{draw:async(l,c)=>{let h=l.sources.map((m)=>[m,s(m.url)]);try{let m=await Promise.all(h.map(async([d,L])=>[d,await L]));if(c.throwIfAborted(),!m.some(([,d])=>d))return null;let f=new OffscreenCanvas(l.width,l.height).getContext("2d",{willReadFrequently:!0});if(!f)throw Error("isard: no 2D canvas to reproject the tiles");for(let[d,L]of m)if(L)f.drawImage(L,d.x,d.y,d.w,d.h);let b=f.getImageData(0,0,l.width,l.height).data,k=it(b,l.width,l.height,l.mesh,l.n,l.size);return createImageBitmap(new ImageData(k,l.size,l.size),{premultiplyAlpha:"none"})}finally{for(let[,m]of h)a(m)}},cache:i,close:()=>{for(let l of i.values())r(l);i.clear()}}}function st(e,t,n=Number.NEGATIVE_INFINITY){let o=e.length>>2,r=new Float32Array(o);if(t==="terrarium")for(let i=0,a=0;i<o;i+=1,a+=4){let s=e[a]*256+e[a+1]+e[a+2]/256-32768;r[i]=s>n?s:n}else for(let i=0,a=0;i<o;i+=1,a+=4){let s=-1e4+(e[a]*65536+e[a+1]*256+e[a+2])*0.1;r[i]=s>n?s:n}return r}async function Ie(e,t,n,o,r){let i=await fetch(e,{signal:o});if(i.status===404||i.status===204||i.status===410)return null;if(!i.ok)throw Error(`${i.url}: ${i.status}`);let a=await createImageBitmap(await i.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"});try{r.canvas??=new OffscreenCanvas(256,256);let s=r.canvas.getContext("2d",{willReadFrequently:!0});if(!s)throw Error("no 2D context");return s.imageSmoothingEnabled=!1,s.clearRect(0,0,256,256),s.drawImage(a,0,0,256,256),st(s.getImageData(0,0,256,256).data,t,n)}finally{a.close()}}var at="aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4 black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887 cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9 darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00 darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493 deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0 forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080 green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082 ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3 lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0 lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23 orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6 purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513 salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32",Q;function ut(e){if(!Q){Q=new Map;let t=at.split(" ");for(let n=0;n+1<t.length;n+=2)Q.set(t[n],t[n+1])}return Q.get(e)}var ee=(e)=>Number.isFinite(e)?Math.max(0,Math.min(1,e)):0;function Le(e){if(!/^[0-9a-f]+$/.test(e)||![3,4,6,8].includes(e.length))return;let t=e.length<=4?[...e].map((o)=>o+o).join(""):e,n=(o)=>Number.parseInt(t.slice(o,o+2),16)/255;return[n(0),n(2),n(4),t.length===8?n(6):1]}function lt(e){if(e===void 0)return 1;return ee(e.endsWith("%")?Number.parseFloat(e)/100:Number.parseFloat(e))}function ct(e,t,n){let o=n<0.5?n*(1+t):n+t-n*t,r=2*n-o,i=(a)=>{let s=(a%1+1)%1;if(s<0.16666666666666666)return r+(o-r)*6*s;if(s<0.5)return o;if(s<0.6666666666666666)return r+(o-r)*(0.6666666666666666-s)*6;return r};return[i(e+0.3333333333333333),i(e),i(e-0.3333333333333333)]}function Ne(e){if(typeof e!=="string")return;let t=e.trim().toLowerCase();if(t.startsWith("#"))return Le(t.slice(1));if(t==="transparent")return[0,0,0,0];let n=ut(t);if(n)return Le(n);let o=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(t);if(!o?.[1]||o[2]===void 0)return;let r=o[2].split(/[\s,/]+/).filter(Boolean);if(r.length<3||r.slice(0,3).some((c)=>Number.isNaN(Number.parseFloat(c))))return;let i=lt(r[3]);if(o[1].startsWith("rgb")){let c=(h)=>ee(h.endsWith("%")?Number.parseFloat(h)/100:Number.parseFloat(h)/255);return[c(r[0]),c(r[1]),c(r[2]),i]}let a=Number.parseFloat(r[0])/360,[s,u,l]=ct(a,ee(Number.parseFloat(r[1])/100),ee(Number.parseFloat(r[2])/100));return[s,u,l,i]}var ft=["Unknown","Point","LineString","Polygon"];function me(e,t){return{zoom:t,properties:e.properties,type:ft[e.type]??"Unknown"}}function _(e){return Ne(e)}function ne([e,t,n,o]){return`rgba(${Math.round(e*255)},${Math.round(t*255)},${Math.round(n*255)},${o})`}function Re(e,t,n,o=1){let r=n-t;if(r===0)return 0;let i=e-t;return o===1?i/r:(o**i-1)/(o**r-1)}function de(e,t,n){if(typeof e==="number"&&typeof t==="number")return e+(t-e)*n;let o=_(e),r=_(t);if(o&&r)return ne([0,1,2,3].map((i)=>(o[i]??0)+((r[i]??0)-(o[i]??0))*n));if(Array.isArray(e)&&Array.isArray(t))return e.map((i,a)=>de(i,t[a],n));return n<0.5?e:t}function Je(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.stops)}function mt(e,t){let n=e.property===void 0?t.zoom:t.properties[e.property],o=e.stops,r=e.type??(e.property===void 0||typeof o[0]?.[0]==="number"?"exponential":"categorical");if(r==="identity")return n??e.default;if(r==="categorical")return o.find(([s])=>s===n)?.[1]??e.default;if(typeof n!=="number"||!o.length)return e.default??o[0]?.[1];let i=(s)=>typeof s[0]==="object"&&s[0]!==null?Number(s[0].zoom):Number(s[0]),a=o[0];if(!a)return e.default;if(n<=i(a))return a[1];for(let s=1;s<o.length;s+=1){let[u,l]=[o[s-1],o[s]];if(!u||!l)continue;if(n<i(l)){if(r==="interval")return u[1];return de(u[1],l[1],Re(n,i(u),i(l),e.base??1))}}return o.at(-1)?.[1]}function te(e,t){if(t==="$type")return e.type;return typeof t==="string"?e.properties[t]:void 0}var dt=new Set(["literal","zoom","get","has","!has","properties","id","geometry-type","concat","format","image","number-format","to-number","to-string","to-boolean","to-color","number","string","boolean","typeof","length","at","upcase","downcase","coalesce","!","all","any","==","!=","<","<=",">",">=","in","case","match","step","interpolate","interpolate-hcl","interpolate-lab","rgb","rgba","+","-","*","/","%","^","min","max","abs","round","floor","ceil","sqrt","ln","log10","log2","pi","e"]);function re(e){return Array.isArray(e)&&typeof e[0]==="string"&&dt.has(e[0])}var Te=new Set,K=(e)=>e===void 0||e===null?"":String(e);function U(e,t){if(Je(e))return mt(e,t);if(!Array.isArray(e))return e;let[n,...o]=e;if(typeof n!=="string")return e;let r=(s)=>U(o[s]??null,t),i=(s)=>Number(r(s)),a=()=>o.map((s,u)=>i(u));switch(n){case"literal":return o[0];case"zoom":return t.zoom;case"get":return te(t,r(0));case"has":return te(t,r(0))!==void 0;case"!has":return te(t,r(0))===void 0;case"properties":return t.properties;case"id":return null;case"geometry-type":return t.type;case"concat":return o.map((s,u)=>K(r(u))).join("");case"format":return o.map((s,u)=>s!==null&&typeof s==="object"&&!Array.isArray(s)?"":K(r(u))).join("");case"image":return r(0);case"number-format":{let s=o[1]??{},u=i(0);if(!Number.isFinite(u))return"";return u.toLocaleString(s.locale,{minimumFractionDigits:s["min-fraction-digits"],maximumFractionDigits:s["max-fraction-digits"]})}case"to-number":{for(let s=0;s<o.length;s+=1){let u=r(s),l=typeof u==="string"&&u.trim()===""?Number.NaN:Number(u);if(u!==null&&u!==void 0&&!Number.isNaN(l))return l}return 0}case"to-string":return K(r(0));case"to-boolean":{let s=r(0);return!(s===""||s===0||s===!1||s===null||s===void 0||Number.isNaN(s))}case"to-color":case"number":case"string":case"boolean":{let s={"to-color":(u)=>_(u)!==void 0,number:(u)=>typeof u==="number",string:(u)=>typeof u==="string",boolean:(u)=>typeof u==="boolean"};for(let u=0;u<o.length;u+=1){let l=r(u);if(s[n]?.(l))return l}return o.length?r(o.length-1):null}case"typeof":{let s=r(0);if(s===null||s===void 0)return"null";return Array.isArray(s)?"array":typeof s}case"length":{let s=r(0);return typeof s==="string"||Array.isArray(s)?s.length:0}case"at":{let s=r(1);return Array.isArray(s)?s[i(0)]??null:null}case"upcase":return K(r(0)).toUpperCase();case"downcase":return K(r(0)).toLowerCase();case"coalesce":for(let s=0;s<o.length;s+=1){let u=r(s);if(u!==void 0&&u!==null)return u}return null;case"!":return!r(0);case"all":return o.every((s,u)=>Boolean(r(u)));case"any":return o.some((s,u)=>Boolean(r(u)));case"==":return r(0)===r(1);case"!=":return r(0)!==r(1);case"<":return r(0)<r(1);case"<=":return r(0)<=r(1);case">":return r(0)>r(1);case">=":return r(0)>=r(1);case"in":{let s=r(1),u=r(0);if(typeof s==="string")return s.includes(String(u));return Array.isArray(s)&&s.includes(u)}case"case":{for(let s=0;s+1<o.length;s+=2)if(r(s))return r(s+1);return r(o.length-1)}case"match":{let s=r(0);for(let u=1;u+1<o.length;u+=2){let l=o[u];if(Array.isArray(l)?l.includes(s):l===s)return r(u+1)}return r(o.length-1)}case"step":{let s=i(0),u=r(1);for(let l=2;l+1<o.length;l+=2)if(s>=Number(o[l]))u=r(l+1);else break;return u}case"interpolate":case"interpolate-hcl":case"interpolate-lab":{let s=o[0],u=i(1),l=Array.isArray(s)&&s[0]==="exponential"?Number(s[1]):1,c=[];for(let m=2;m+1<o.length;m+=2)c.push([Number(o[m]),o[m+1]??null]);let h=c[0];if(!h)return null;if(u<=h[0])return U(h[1],t);for(let m=1;m<c.length;m+=1){let[C,f]=[c[m-1],c[m]];if(C&&f&&u<f[0])return de(U(C[1],t),U(f[1],t),Re(u,C[0],f[0],l))}return U(c.at(-1)?.[1]??null,t)}case"rgb":case"rgba":return ne([i(0)/255,i(1)/255,i(2)/255,o.length>3?i(3):1]);case"+":return a().reduce((s,u)=>s+u,0);case"*":return a().reduce((s,u)=>s*u,1);case"-":return o.length===1?-i(0):i(0)-i(1);case"/":return i(0)/i(1);case"%":return i(0)%i(1);case"^":return i(0)**i(1);case"min":return Math.min(...a());case"max":return Math.max(...a());case"abs":return Math.abs(i(0));case"round":return Math.sign(i(0))*Math.round(Math.abs(i(0)));case"floor":return Math.floor(i(0));case"ceil":return Math.ceil(i(0));case"sqrt":return Math.sqrt(i(0));case"ln":return Math.log(i(0));case"log10":return Math.log10(i(0));case"log2":return Math.log2(i(0));case"pi":return Math.PI;case"e":return Math.E;default:if(!Te.has(n))Te.add(n),console.warn(`isard: the style expression "${n}" is not supported`);return null}}var pt=new Set(["==","!=","<","<=",">",">="]);function bt(e){let[t,n,...o]=e;if(typeof t!=="string"||typeof n!=="string"||o.some(Array.isArray))return!1;if(pt.has(t))return e.length===3;if(t==="in")return e.length!==3||!Array.isArray(e[2]);return t==="!in"||t==="has"||t==="!has"}function ht(e,t){let[n,o,...r]=e,i=te(t,o);switch(n){case"==":return i===r[0];case"!=":return i!==r[0];case"<":return i<r[0];case"<=":return i<=r[0];case">":return i>r[0];case">=":return i>=r[0];case"in":return r.includes(i);case"!in":return!r.includes(i);case"has":return i!==void 0;case"!has":return i===void 0;default:return!0}}var Ee=new WeakMap;function Oe(e){if(!Array.isArray(e))return()=>Boolean(e);let t=Ee.get(e);if(t)return t;let n,o=e[0];if(o==="all"||o==="any"||o==="none"){let r=e.slice(1).map(Oe);if(o==="all")n=(i)=>r.every((a)=>a(i));else if(o==="any")n=(i)=>r.some((a)=>a(i));else n=(i)=>!r.some((a)=>a(i))}else if(bt(e))n=(r)=>ht(e,r);else n=(r)=>Boolean(U(e,r));return Ee.set(e,n),n}function pe(e,t){if(e===void 0||e===null)return!0;return Oe(e)(t)}function X(e){if(e!==void 0&&Je(e))return e.property!==void 0;if(!Array.isArray(e))return!1;if(["get","has","!has","geometry-type","properties","id"].includes(e[0]))return!0;return e.some((t)=>X(t))}function be(e,t){if(e===void 0||e===null)return"";if(typeof e==="string")return e.replace(/\{([^}]+)\}/g,(o,r)=>{let i=t.properties[r];return i===void 0?"":String(i)});let n=U(e,t);if(Array.isArray(n))return n.filter((o)=>typeof o==="string").join("");return n===void 0||n===null?"":String(n)}function De(e){return/Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(e)?e:`${e} Regular`}function he(e){let t=new Set,n=(a)=>{if(!Array.isArray(a))return;let s=(u)=>Array.isArray(u)&&u[0]==="zoom";if((a[0]==="interpolate"||a[0]==="interpolate-hcl"||a[0]==="interpolate-lab")&&s(a[2]))for(let u=3;u<a.length;u+=2)t.add(Number(a[u]));else if(a[0]==="step"&&s(a[1]))for(let u=3;u<a.length;u+=2){let l=Number(a[u]);t.add(l),t.add(l-0.01)}for(let u of a)n(u)};n(e);let o=[...t].filter(Number.isFinite);if(o.length===0)o.push(0);let[r,i]=[Math.min(...o),Math.max(...o)];for(let a=Math.ceil(r);a<=Math.floor(i);a+=1)o.push(a);return[...new Set(o)].sort((a,s)=>a-s).map((a)=>[a,Number(U(e,{zoom:a,properties:{},type:"Unknown"}))])}function Be(e,t){for(let n of e.sprites){let o=n.icons[t];if(o)return{icon:o,image:n.image}}return}var oe=new Map,ze=96,ie=new H(ze);function gt(e){return Math.max(16,Math.ceil(ze/Math.max(1,e)))}var ge=new Set,Y=new Set,we=new Map,yt={},Fe=Ce(),ye=new H(64,(e)=>e.then((t)=>setTimeout(()=>t?.close(),0),()=>{return}));function wt(e,t="auto"){let n=ye.get(e);if(n)return n;let o=(async()=>{let r=fe(e);if(r){let s=await r;return s&&createImageBitmap(new Blob([s]))}let a=await fetch(e,{priority:t});if(a.status===404||a.status===204)return;if(!a.ok)throw Error(`${e}: ${a.status}`);return createImageBitmap(await a.blob())})();return o.catch(()=>ye.delete(e)),ye.set(e,o),o}function Ue(e,t="auto"){let n=ie.get(e);if(n)return n;let o=(async()=>{let r=fe(e);if(r){let i=await r;return i&&ce(i)}for(let i=0;;i+=1){let s=await fetch(e,{priority:t});if(s.status===404||s.status===204)return;if(s.ok)return ce(new Uint8Array(await s.arrayBuffer()));if(i>=2)throw Error(`${e}: ${s.status}`);await new Promise((u)=>setTimeout(u,400*(i+1)))}})();return o.catch(()=>ie.delete(e)),ie.set(e,o),o}function xt(e,t,n,o){let r=Math.max(0,Math.min(t-1,e.maxzoom)),i=t-r,a=2**Math.max(0,i),[s,u]=i>=0?[Math.floor(n/a),Math.floor(o/a)]:[n,o],l=e.tiles.replace("{z}",String(r)).replace("{x}",String(s)).replace("{y}",String(u)),c=1/a;return{url:l,vz:r,vx:s,vy:u,part:c,ox:n%a*c,oy:o%a*c}}var w=(e,t,n,o,r)=>{let i=e[t]?.[n];if(i===void 0)return r;let a=Array.isArray(i)&&!re(i)?i:U(i,o);return a===void 0||a===null?r:a};function Z(e,t){let n=_(e)??[0,0,0,1];return ne([n[0],n[1],n[2],n[3]*t])}function $e(e,t){if(e.layout?.visibility==="none")return!1;return t>=(e.minzoom??0)&&t<(e.maxzoom??24)}function vt(e,t){if(e.patterns.has(t))return e.patterns.get(t);let n=Be(e,t),o;if(n&&n.icon.width>0&&n.icon.height>0){let{icon:r}=n;o=new OffscreenCanvas(r.width,r.height),o.getContext("2d")?.drawImage(n.image,r.x,r.y,r.width,r.height,0,0,r.width,r.height)}return e.patterns.set(t,o),o}var xe=new Map;function kt(e){let t=xe.get(e)?.pop()??new OffscreenCanvas(e,e),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw Error("no 2D context");return n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.setLineDash([]),n.clearRect(0,0,e,e),{canvas:t,g:n}}function At(e){let t=xe.get(e.width)??[];if(xe.set(e.width,t),t.length<4)t.push(e)}function St(e,t,n){if(n)return Promise.resolve(e.transferToImageBitmap());return createImageBitmap(t.getImageData(0,0,e.width,e.height),{premultiplyAlpha:"none"})}async function Mt(e,t,n,o,r,i,a){let s=xt(e,t,n,o),u=await Ue(s.url,a);if(Y.has(i))return;let{canvas:l,g:c}=kt(r);try{return await Pt(e,s,u,l,c,t,n,o,r,i,a)}finally{At(l)}}async function Pt(e,t,n,o,r,i,a,s,u,l,c){let h=Math.max(0,i-1),m=u/256,C=!1,f=!1;for(let b of e.layers){if(!$e(b,h))continue;let k={zoom:h,properties:{},type:"Unknown"};if(b.type==="background"){let v=w(b,"paint","background-color",k,"#000"),p=Number(w(b,"paint","background-opacity",k,1));if(r.fillStyle=Z(v,p),r.fillRect(0,0,u,u),(_(v)??[0,0,0,1])[3]*p>=1)f=!0;C=!0;continue}if(b.type==="raster"){let v=b.source===void 0?void 0:e.rasters[b.source];if(!v)continue;let p=Math.max(0,Math.min(i-(v.tileSize>=512?1:0),v.maxzoom)),g=2**(i-p),S=v.tiles.replace("{z}",String(p)).replace("{x}",String(Math.floor(a/g))).replace("{y}",String(Math.floor(s/g))),y=await wt(S,c).catch(()=>{return});if(Y.has(l))return;if(!y)continue;let[I,A]=[y.width/g,y.height/g];r.globalAlpha=Number(w(b,"paint","raster-opacity",k,1)),r.drawImage(y,a%g*I,s%g*A,I,A,0,0,u,u),r.globalAlpha=1,C=!0;continue}let d=n?.get(b["source-layer"]??"");if(!d)continue;let L=u/(d.extent*t.part),[J,W]=[t.ox*d.extent,t.oy*d.extent],O=(v,p)=>{r.beginPath();for(let g of v.geometry){for(let S=0;S+1<g.length;S+=2){let[y,I]=[((g[S]??0)-J)*L,((g[S+1]??0)-W)*L];if(S===0)r.moveTo(y,I);else r.lineTo(y,I)}if(p)r.closePath()}},P=new Map,x=(v,p,g,S)=>{let y=P.get(p);if(y===void 0)y=X(b[v]?.[p]),P.set(p,y);return w(b,v,p,y?g:k,S)};for(let v of d.features){let p=me(v,h);if(!pe(b.filter,p))continue;if(b.type==="fill-extrusion"&&v.type===3)O(v,!0),r.fillStyle=Z(x("paint","fill-extrusion-color",p,"#000"),Number(x("paint","fill-extrusion-opacity",p,1))),r.fill("evenodd"),C=!0;else if(b.type==="fill"&&v.type===3){let g=Number(x("paint","fill-opacity",p,1)),S=x("paint","fill-pattern",p,void 0);O(v,!0);let y=typeof S==="string"?Be(e,S)?.icon:void 0,I=y&&vt(e,S);if(y&&I){let A=r.createPattern(I,"repeat");if(A)A.setTransform(new DOMMatrix().scale(m/(y.pixelRatio??1))),r.globalAlpha=g,r.fillStyle=A,r.fill("evenodd"),r.globalAlpha=1}else{r.fillStyle=Z(x("paint","fill-color",p,"#000"),g),r.fill("evenodd");let A=x("paint","fill-outline-color",p,void 0);if(A!==void 0)r.strokeStyle=Z(A,g),r.lineWidth=m,r.setLineDash([]),r.stroke()}C=!0}else if(b.type==="line"&&v.type!==1){let g=Number(x("paint","line-width",p,1));if(g<=0)continue;let S=Number(x("paint","line-gap-width",p,0));r.strokeStyle=Z(x("paint","line-color",p,"#000"),Number(x("paint","line-opacity",p,1))),r.lineWidth=(S>0?S+2*g:g)*m,r.lineCap=String(x("layout","line-cap",p,"butt")),r.lineJoin=String(x("layout","line-join",p,"miter"));let y=x("paint","line-dasharray",p,void 0);r.setLineDash(Array.isArray(y)?y.map((I)=>Number(I)*g*m):[]),O(v,v.type===3),r.stroke(),C=!0}else if(b.type==="circle"&&v.type===1){let g=Number(x("paint","circle-radius",p,5))*m;r.fillStyle=Z(x("paint","circle-color",p,"#000"),Number(x("paint","circle-opacity",p,1)));let S=Number(x("paint","circle-stroke-width",p,0))*m;r.strokeStyle=Z(x("paint","circle-stroke-color",p,"#000"),Number(x("paint","circle-stroke-opacity",p,1))),r.lineWidth=S;for(let y of v.geometry)for(let I=0;I+1<y.length;I+=2)if(r.beginPath(),r.arc(((y[I]??0)-J)*L,((y[I+1]??0)-W)*L,g,0,2*Math.PI),r.fill(),S>0)r.stroke();C=!0}}}if(!C&&!n)return null;return St(o,r,f)}function qe(e,t,n){let o=Boolean(w(e,"layout",`${t}-allow-overlap`,n,!1)),r=Boolean(w(e,"layout",`${t}-ignore-placement`,n,!1));if(o&&r)return!0;if(o)return"allow";return r?"ignore":!1}function Ct(e,t){return Array.isArray(e)?[Number(e[0]??t[0]),Number(e[1]??t[1])]:t}function It(e){let t=(Array.isArray(e)?e:[e]).map((a)=>Number(a)||0),[n=0,o=n,r=n,i=o]=t;return[n,o,r,i]}function Lt(e,t){let n=0;for(let a=2;a+1<e.length;a+=2)n+=Math.hypot((e[a]??0)-(e[a-2]??0),(e[a+1]??0)-(e[a-1]??0));let o=[];if(!(n>0)||!(t>0))return o;let r=Math.min(t/2,n/2),i=0;for(let a=2;a+1<e.length;a+=2){let[s,u,l,c]=[e[a-2]??0,e[a-1]??0,e[a]??0,e[a+1]??0],h=Math.hypot(l-s,c-u);while(h>0&&r<=i+h){let m=(r-i)/h;o.push([s+(l-s)*m,u+(c-u)*m,s,u,l,c]),r+=t}i+=h}return o}function j(e,t,n,o,r,i){let a=2**e;return[ve((t+r/o)/a),ke((n+i/o)/a)]}function Nt(e,t,n,o,r){let i=w(e,"layout","icon-rotation-alignment",n,"auto"),a=String(w(e,"layout","icon-text-fit",n,"none")),s=w(e,"layout","icon-text-fit-padding",n,[0,0,0,0]);return{image:t,size:X(e.layout?.["icon-size"])?Number(w(e,"layout","icon-size",n,1)):r(e),anchor:String(w(e,"layout","icon-anchor",n,"center")),offset:Ct(w(e,"layout","icon-offset",n,[0,0]),[0,0]),rotate:Number(w(e,"layout","icon-rotate",n,0))||0,alignment:i==="map"||i==="auto"&&o==="line"?"map":"viewport",overlap:qe(e,"icon",n),optional:Boolean(w(e,"layout","icon-optional",n,!1)),fit:a==="width"||a==="height"||a==="both"?a:"none",padding:It(s),color:String(w(e,"paint","icon-color",n,"#000")),opacity:Number(w(e,"paint","icon-opacity",n,1))}}async function Tt(e,t,n,o,r,i,a=t){let s=e.tiles.replace("{z}",String(t)).replace("{x}",String(n)).replace("{y}",String(o)),u=await Ue(s,i);if(!u||Y.has(r))return[];let l=[],c=new Map,h=(f)=>{let b=c.get(f);if(b===void 0){let k=f.layout?.["text-size"]??16;b=re(k)?he(k):k,c.set(f,b)}return b},m=new Map,C=(f)=>{let b=m.get(f);if(b===void 0){let k=f.layout?.["icon-size"]??1;b=re(k)?he(k):k,m.set(f,b)}return b};return e.layers.forEach((f,b)=>{let k=f.layout??{};if(f.type!=="symbol"||!$e(f,a))return;if(k["text-field"]===void 0&&k["icon-image"]===void 0)return;let d=u.get(f["source-layer"]??"");if(!d)return;let L={zoom:a,properties:{},type:"Unknown"},J=w(f,"layout","symbol-placement",L,"point")==="line"?"line":"point",W=J==="line"&&w(f,"layout","text-rotation-alignment",L,"auto")!=="viewport";for(let O of d.features){let P=me(O,a);if(!pe(f.filter,P))continue;let x=be(k["text-field"],P).trim(),v=be(k["icon-image"],P).trim();if(!x&&!v)continue;let p=w(f,"layout","text-transform",P,"none");if(p==="uppercase")x=x.toUpperCase();else if(p==="lowercase")x=x.toLowerCase();let g=w(f,"layout","text-font",P,["Noto Sans Regular"]),S=De(Array.isArray(g)&&typeof g[0]==="string"?g[0]:"Noto Sans Regular"),y=w(f,"layout","text-offset",P,[0,0]),I={layer:b,text:x,font:S,size:X(f.layout?.["text-size"])?Number(w(f,"layout","text-size",P,16)):h(f),color:String(w(f,"paint","text-color",P,"#000")),haloColor:String(w(f,"paint","text-halo-color",P,"rgba(0,0,0,0)")),haloWidth:Number(w(f,"paint","text-halo-width",P,0)),anchor:String(w(f,"layout","text-anchor",P,"center")),offset:Array.isArray(y)?[Number(y[0]??0),Number(y[1]??0)]:[0,0],maxWidth:Number(w(f,"layout","text-max-width",P,10)),lineHeight:Number(w(f,"layout","text-line-height",P,1.2)),overlap:qe(f,"text",P),...W?{textAlong:W}:{},...w(f,"layout","text-optional",P,!1)?{textOptional:!0}:{},...v?{icon:Nt(f,v,P,J,C)}:{}};if(O.type===1)for(let A of O.geometry)for(let R=0;R+1<A.length;R+=2){let[E,M]=[A[R]??0,A[R+1]??0];if(E<0||M<0||E>=d.extent||M>=d.extent)continue;let[T,N]=j(t,n,o,d.extent,E,M);l.push({...I,lon:T,lat:N})}else if(!x&&J==="line"){let A=Number(w(f,"layout","symbol-spacing",P,250))*d.extent/(512*2**(a-t));for(let R of O.geometry)for(let[E=0,M=0,T=0,N=0,D=0,q=0]of Lt(R,Math.max(A,1))){if(E<0||M<0||E>=d.extent||M>=d.extent)continue;let[F,B]=j(t,n,o,d.extent,E,M),[z,se]=j(t,n,o,d.extent,D,q),[ae,ue]=j(t,n,o,d.extent,T,N);l.push({...I,lon:F,lat:B,along:[z-ae,se-ue]})}}else{let A,R=0;for(let M of O.geometry){let T=0;for(let N=2;N+1<M.length;N+=2)T+=Math.hypot((M[N]??0)-(M[N-2]??0),(M[N+1]??0)-(M[N-1]??0));if(T>R)R=T,A=M}if(!A||R<d.extent/32)continue;let E=R/2;for(let M=2;M+1<A.length;M+=2){let[T,N,D,q]=[A[M-2]??0,A[M-1]??0,A[M]??0,A[M+1]??0],F=Math.hypot(D-T,q-N);if(F>=E&&F>0){let[B,z]=[T+(D-T)*E/F,N+(q-N)*E/F];if(B<0||z<0||B>=d.extent||z>=d.extent)break;let[se,ae]=j(t,n,o,d.extent,B,z),[ue,He]=j(t,n,o,d.extent,D,q),[Ve,We]=j(t,n,o,d.extent,T,N);l.push({...I,lon:se,lat:ae,...J==="line"?{along:[ue-Ve,He-We]}:{}});break}E-=F}}}}),l}var V=(e,t=[])=>self.postMessage(e,t);self.onmessage=async({data:e})=>{if(e.type==="init"){if(e.workers!==void 0)ie.capacity=gt(e.workers);oe.set(e.key,{tiles:e.tiles,maxzoom:e.maxzoom,layers:e.layers,rasters:e.rasters??{},sprites:e.sprites??[],patterns:new Map});return}if(e.type==="drop"){for(let n of oe.get(e.key)?.sprites??[])n.image.close();oe.delete(e.key);return}if(e.type==="abort"){if(ge.has(e.id))Y.add(e.id);we.get(e.id)?.abort();return}if(e.type==="heights"||e.type==="reproject"){await Et(e);return}ge.add(e.id);let t=oe.get(e.key);try{if(!t)throw Error(`no renderer ${e.key}`);if(e.type==="render"){let n=await Mt(t,e.z,e.x,e.y,e.size,e.id,e.priority);if(n)V({id:e.id,image:n},[n]);else V({id:e.id,missing:!0})}else V({id:e.id,labels:await Tt(t,e.z,e.x,e.y,e.id,e.priority,e.zoom)})}catch(n){V({id:e.id,error:String(n)})}finally{ge.delete(e.id),Y.delete(e.id)}};async function Et(e){let t=new AbortController;we.set(e.id,t);try{if(e.type==="heights"){let n=await Ie(e.url,e.encoding,e.floor,t.signal,yt);if(n)V({id:e.id,heights:n},[n.buffer]);else V({id:e.id,missing:!0})}else{Fe.cache.capacity=e.cached;let n=await Fe.draw(e.job,t.signal);if(n)V({id:e.id,image:n},[n]);else V({id:e.id,missing:!0})}}catch(n){V({id:e.id,error:String(n)})}finally{we.delete(e.id)}}export{gt as cacheShare,Lt as lineAnchors,St as tileImage};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=4B53832590FE8C0564756E2164756E21
|
|
4
4
|
//# sourceMappingURL=basemap.worker.js.map
|