isard 0.3.0 → 0.5.0
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 +68 -0
- package/README.md +11 -3
- package/dist/basemap.worker.d.ts +10 -3
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +4 -4
- package/dist/decoder.worker.js +4 -4
- package/dist/decoder.worker.js.map +7 -6
- package/dist/decoders.d.ts +3 -2
- package/dist/decoders.js +28 -5
- package/dist/decoders.js.map +1 -1
- package/dist/engine-loader.d.ts +8 -4
- package/dist/engine-loader.js +10 -3
- package/dist/engine-loader.js.map +1 -1
- package/dist/formats.d.ts +11 -0
- package/dist/formats.js +12 -0
- package/dist/formats.js.map +1 -0
- package/dist/glyphs.d.ts +3 -0
- package/dist/glyphs.js +12 -2
- package/dist/glyphs.js.map +1 -1
- package/dist/icons.d.ts +146 -0
- package/dist/icons.js +333 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +8 -5
- 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/isard_points_bg.wasm +0 -0
- package/dist/layers.d.ts +88 -1
- package/dist/layers.js +165 -4
- package/dist/layers.js.map +1 -1
- package/dist/loader.d.ts +9 -3
- package/dist/loader.js +22 -3
- package/dist/loader.js.map +1 -1
- package/dist/map.d.ts +37 -3
- package/dist/map.js +76 -10
- package/dist/map.js.map +1 -1
- package/dist/pointclouds.d.ts +98 -0
- package/dist/pointclouds.js +232 -0
- package/dist/pointclouds.js.map +1 -0
- package/dist/projections.d.ts +13 -0
- package/dist/projections.js +13 -0
- package/dist/projections.js.map +1 -0
- package/dist/protocol.d.ts +17 -0
- package/dist/protocol.js.map +1 -1
- package/dist/symbols.d.ts +42 -8
- package/dist/symbols.js +160 -35
- package/dist/symbols.js.map +1 -1
- package/dist/types.d.ts +8 -3
- package/dist/types.js.map +1 -1
- package/dist/vectorstyle.d.ts +32 -3
- package/dist/vectorstyle.js.map +1 -1
- package/dist/vectortiles.d.ts +10 -5
- package/dist/vectortiles.js +54 -29
- package/dist/vectortiles.js.map +1 -1
- package/dist/wasm/isard.d.ts +168 -11
- package/dist/wasm/isard.js +234 -9
- package/dist/wasm/isard_core.d.ts +28 -3
- package/dist/wasm/isard_core.js +77 -4
- package/dist/wasm/isard_points.d.ts +43 -0
- package/dist/wasm/isard_points.js +212 -0
- package/package.json +17 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,74 @@
|
|
|
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.5.0] - 2026-10-19
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- Entry points by theme: `isard/formats` (KML, GPX, TopoJSON), `isard/projections` (CRSs, reprojection, WMTS grids)
|
|
11
|
+
and `isard/geoplateforme` (the IGN's WMTS, WMS, WFS, the Lambert-93 grid); `isard` still exports all of them.
|
|
12
|
+
- Point clouds, `map.addPointCloud({ url })` → `PointCloudLayer` (`setStyle`, `stats`, `info`, `remove`): COPC files
|
|
13
|
+
(LAZ 1.4 point formats 6 to 8 with their octree, read by HTTP range requests: the IGN's LiDAR HD), and 3D Tiles
|
|
14
|
+
point clouds (`format: '3dtiles'`, the default for a `.json` URL). The octree traversed by screen-space error within
|
|
15
|
+
a point budget (`pointBudget`, 3 million), the nearest, coarsest and most central nodes first, their downloads
|
|
16
|
+
aborted once out of the selection, a GPU memory budget; colored by RGB, class (the ASPRS and LiDAR HD palette,
|
|
17
|
+
`classifications` to recolor or hide classes), altitude (a ramp) or intensity; points of a fixed size or sized by
|
|
18
|
+
the spacing of their level, round or square; Eye-Dome Lighting (`edl`); depth shared with the relief, the buildings
|
|
19
|
+
and the 3D Tiles; `pickFeature` gives a point with its class, intensity, altitude, returns and color, read back from
|
|
20
|
+
the GPU.
|
|
21
|
+
- COPC positions reprojected as they are decoded, in the workers: the CRS from the file's WKT (built-in CRSs, or
|
|
22
|
+
`registerCrs`) or `crs` (any proj4 CRS), computed exactly on a grid of each node and interpolated within a
|
|
23
|
+
millimetre; NGF-IGN69 altitudes (Lambert-93, the CC zones; `geoid`) raised by the RAF20 geoid height onto the
|
|
24
|
+
ellipsoid of the relief; `verticalScale` (the WKT's vertical unit by default).
|
|
25
|
+
- The point cloud module, `isard_points_bg.wasm` (43 KB gzipped, the LAZ decoder of the `laz` crate): loaded by the
|
|
26
|
+
decoding workers with the first COPC chunk, the engines do not hold it (`pointsWasmUrl` when a bundler moves it).
|
|
27
|
+
- Requests held to a rate (`requestsPerSecond`, 8 a second for the Géoplateforme), answers `429` asked again after a
|
|
28
|
+
pause.
|
|
29
|
+
- 3D Tiles: `.pnts` tiles (positions plain or quantized, RGB, RGBA, RGB565, constant colors, normals plain or
|
|
30
|
+
oct-encoded, `3DTILES_draco_point_compression`) and glTF points (mode 0, meshopt, quantization, Draco), lit by their
|
|
31
|
+
normals; `pointSize` in the style of a 3D Tiles layer.
|
|
32
|
+
- The point clouds example: Notre-Dame de Paris in the IGN's LiDAR HD; the Géoplateforme guide on LiDAR HD.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- The engine with 3D Tiles is 385 KB gzipped (was 345 KB): the point clouds (their program, the COPC layer, the pnts
|
|
37
|
+
and glTF points); the engine without 3D Tiles does not change.
|
|
38
|
+
|
|
39
|
+
## [0.4.0] - 2026-10-18
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- Icons in the symbol layers: a vector basemap's icons from the `sprite` of its style (one sprite or several with
|
|
44
|
+
their ids, `@2x` on high-density screens), points of interest, road shields with their numbers centred, one-way
|
|
45
|
+
arrows every `symbol-spacing` along the roads; `icon-image` (tokens and expressions), `icon-size`, `icon-anchor`,
|
|
46
|
+
`icon-offset`, `icon-rotate`, `icon-rotation-alignment`, `icon-allow-overlap`, `icon-ignore-placement`,
|
|
47
|
+
`icon-optional`, `text-optional`, `text-ignore-placement`, `icon-text-fit` with its padding (an image's `stretchX`,
|
|
48
|
+
`stretchY` and `content` kept), `icon-color` of signed distance field images, `icon-opacity`. The text and the icon
|
|
49
|
+
of a label have their own boxes in the collision grid. The images used are packed into one RGBA atlas.
|
|
50
|
+
- `map.addImage(name, image, { pixelRatio, sdf, stretchX, stretchY, content })`, `hasImage`, `removeImage`, and the
|
|
51
|
+
symbol layers' `icon`, `iconSize`, `iconAnchor`, `iconOffset`, `iconRotate`, `iconRotationAlignment`, `iconOverlap`,
|
|
52
|
+
`iconOptional`, `iconTextFit`, `iconTextFitPadding`, `iconColor`, `iconOpacity` and `textOptional`; `overlap` also
|
|
53
|
+
takes `'allow'` and `'ignore'`; `placement` may be a function of the feature.
|
|
54
|
+
- Custom layers: `map.addCustomLayer({ renderingMode, onAdd, render, onRemove })`, the page's own WebGL drawing (raw,
|
|
55
|
+
or a three.js scene) called at its place among the layers in every frame, as MapLibre's; `frame.matrixAt(lonLat,
|
|
56
|
+
altitude)` gives the model-view-projection of a local east-north-up frame in metres there, made in f64 relative to
|
|
57
|
+
the camera (exact at any zoom, on the plane and the globe); `'3d'` shares the depth buffer of the relief, the
|
|
58
|
+
buildings and the 3D Tiles; the WebGL state the page changes is set back after it; `onAdd` again after a context
|
|
59
|
+
loss. The `threejs` example.
|
|
60
|
+
- glTF models: `map.addModels({ url | data, instances: [{ lonLat, altitude, heading, pitch, roll, scale }],
|
|
61
|
+
altitudeReference })`, a glTF binary drawn at positions in one instanced draw per primitive, decoded as 3D Tiles
|
|
62
|
+
content is (meshopt, quantization, Draco and KTX2 in the workers), standing on the relief by default, with depth;
|
|
63
|
+
`setInstances`; `pickFeature` gives the instance's index. Textured surfaces unlit as the 3D Tiles, the others in
|
|
64
|
+
their material's base color, lit from above. The first model loads the engine with 3D Tiles, as a 3D Tiles layer
|
|
65
|
+
does. The `models` example.
|
|
66
|
+
|
|
67
|
+
### Changed
|
|
68
|
+
|
|
69
|
+
- A vector basemap's text written over its icon (a road shield's number) is drawn with it, no longer left out;
|
|
70
|
+
`text-rotation-alignment: viewport` keeps a text along a line horizontal; `symbol-placement` may be an expression;
|
|
71
|
+
past the source's deepest level, the labels take the style's layers of the view's zoom (points of interest at 17).
|
|
72
|
+
- The decoder keeps the base color factor of a glTF material (`color` of the decoded primitives, when not white).
|
|
73
|
+
|
|
6
74
|
## [0.3.0] - 2026-10-18
|
|
7
75
|
|
|
8
76
|
### Changed
|
package/README.md
CHANGED
|
@@ -42,7 +42,11 @@ General-purpose map libraries spend their time on things these maps do not need.
|
|
|
42
42
|
digs Valles Marineris and the lunar craters from NASA's LOLA and MOLA models.
|
|
43
43
|
- 🏙️ **Buildings and 3D Tiles.** Buildings colored by a value or by a network's travel times, photomeshes and city
|
|
44
44
|
models in 3D Tiles (Draco, meshopt, KTX2).
|
|
45
|
-
-
|
|
45
|
+
- ☁️ **Point clouds.** LiDAR in COPC read by range requests (the IGN's LiDAR HD, reprojected from Lambert-93 onto the
|
|
46
|
+
relief), 3D Tiles points; colored by RGB, class, altitude or intensity, Eye-Dome Lighting, a point budget, picked.
|
|
47
|
+
- 🧊 **Your own 3D.** glTF models at positions, instanced and picked; custom layers for your WebGL code or a three.js
|
|
48
|
+
scene, in the map's frame and depth, with camera-relative matrices exact at any zoom.
|
|
49
|
+
- 🦀 **Small and exact.** 225 KB of WebAssembly gzipped (385 KB once a 3D Tiles layer, a model or a point cloud is added), f64 on the CPU and f32 relative to the camera on the GPU
|
|
46
50
|
(centimetres at any zoom), frames on demand only, strict TypeScript types end to end.
|
|
47
51
|
|
|
48
52
|
## Quick start
|
|
@@ -99,7 +103,10 @@ Live in the [documentation](https://graffkevin.github.io/isard/examples/), sourc
|
|
|
99
103
|
| [Buildings](https://graffkevin.github.io/isard/layers/buildings) | `addExtrusions` | tiles or one set, colored by values or by a network's times |
|
|
100
104
|
| [Ground shaders](https://graffkevin.github.io/isard/layers/ground) | `addGround` | your fragment shader over the ground: water depth, heat maps |
|
|
101
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 |
|
|
102
|
-
| [3D Tiles](https://graffkevin.github.io/isard/layers/tiles3d) | `addTiles3d` | b3dm, glb, external tilesets, compressed or not |
|
|
106
|
+
| [3D Tiles](https://graffkevin.github.io/isard/layers/tiles3d) | `addTiles3d` | b3dm, pnts, glb, external tilesets, compressed or not |
|
|
107
|
+
| [glTF models](https://graffkevin.github.io/isard/layers/models) | `addModels` | a glTF model at many positions, instanced, on the relief, picked |
|
|
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 |
|
|
109
|
+
| [Custom layers](https://graffkevin.github.io/isard/layers/custom) | `addCustomLayer` | your WebGL code or a three.js scene in the map's frame, sharing its depth |
|
|
103
110
|
|
|
104
111
|
Plus markers, popups, controls, picking within a radius, `easeTo`, `flyTo`, a sky and fog for tilted views. All in
|
|
105
112
|
the [API reference](https://graffkevin.github.io/isard/api).
|
|
@@ -129,6 +136,7 @@ drives both.
|
|
|
129
136
|
```
|
|
130
137
|
crates/geo/ camera, projections, geodesy and geoid, tile selection, label placement, polygons tested natively
|
|
131
138
|
crates/tiles3d/ 3D Tiles tree, traversal and decoding tested natively
|
|
139
|
+
crates/pointcloud/ COPC point clouds: header, octree hierarchy, traversal, LAZ chunks tested natively
|
|
132
140
|
crates/engine/ the WebAssembly core: the engine, the ground, the layers, picking
|
|
133
141
|
packages/isard/ the npm package isard: GeoMap, layer handles, overlays, workers
|
|
134
142
|
apps/ the demo and the benchmark (Isard, iTowns, 3DTilesRendererJS)
|
|
@@ -142,7 +150,7 @@ More in [Develop and release](https://graffkevin.github.io/isard/guide/develop).
|
|
|
142
150
|
## Roadmap
|
|
143
151
|
|
|
144
152
|
- Flood maps over the relief (water depth as a ground shader) as a full example.
|
|
145
|
-
-
|
|
153
|
+
- Text along curved lines, and repeated along long ones.
|
|
146
154
|
- Labels fading in and out instead of popping.
|
|
147
155
|
|
|
148
156
|
## Licence
|
package/dist/basemap.worker.d.ts
CHANGED
|
@@ -14,12 +14,15 @@ export type BasemapWork = {
|
|
|
14
14
|
y: number;
|
|
15
15
|
size: number;
|
|
16
16
|
priority?: Priority;
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
/** `zoom`: the zoom the style is evaluated at, past the source's deepest level (`z` by default) */
|
|
19
|
+
| {
|
|
18
20
|
type: 'labels';
|
|
19
21
|
key: string;
|
|
20
22
|
z: number;
|
|
21
23
|
x: number;
|
|
22
24
|
y: number;
|
|
25
|
+
zoom?: number;
|
|
23
26
|
priority?: Priority;
|
|
24
27
|
} | {
|
|
25
28
|
type: 'heights';
|
|
@@ -40,8 +43,8 @@ export type BasemapRequest = {
|
|
|
40
43
|
layers: StyleLayer[];
|
|
41
44
|
/** The style's raster sources, by name, for its raster layers */
|
|
42
45
|
rasters?: Record<string, RasterSource>;
|
|
43
|
-
/** The style's
|
|
44
|
-
|
|
46
|
+
/** The style's sprites, for the fill patterns (loaded once by the page) */
|
|
47
|
+
sprites?: Sprite[];
|
|
45
48
|
/** Workers of the pool: each keeps its share of the decoded tiles */
|
|
46
49
|
workers?: number;
|
|
47
50
|
} | (BasemapWork & {
|
|
@@ -71,6 +74,7 @@ export type BasemapResponse = {
|
|
|
71
74
|
id: number;
|
|
72
75
|
heights: Float32Array;
|
|
73
76
|
};
|
|
77
|
+
/** A sprite of the style: its images by name (`id:name` but in the default sprite) and its sheet */
|
|
74
78
|
export interface Sprite {
|
|
75
79
|
image: ImageBitmap;
|
|
76
80
|
icons: Record<string, {
|
|
@@ -89,3 +93,6 @@ export declare function cacheShare(workers: number): number;
|
|
|
89
93
|
* there; another one is read back unpremultiplied, copied
|
|
90
94
|
*/
|
|
91
95
|
export declare function tileImage(canvas: OffscreenCanvas, g: OffscreenCanvasRenderingContext2D, opaque: boolean): Promise<ImageBitmap>;
|
|
96
|
+
/** Points every `spacing` along a line (tile units, x and y interleaved), the first half a spacing in (the middle of a
|
|
97
|
+
* shorter line): each point and the segment it lies on (x, y, x0, y0, x1, y1) */
|
|
98
|
+
export declare function lineAnchors(line: readonly number[], spacing: number): number[][];
|
package/dist/basemap.worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function pe(e){return e*360-180}function de(e){return Math.atan(Math.sinh(Math.PI*(1-2*e)))*180/Math.PI}class W{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 oe{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 oe(this.buf,this.pos,t);return this.pos=t,n}string(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=Je.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 Je=new TextDecoder;function Fe(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 Ee(e){let t=[],n,[o,r]=[0,0];while(e.more){let i=e.varint(),u=i&7,s=i>>3;if(u===7){if(n&&n.length>=2)n.push(n[0]??0,n[1]??0);continue}for(let a=0;a<s&&e.more;a+=1){if(o+=e.sint(),r+=e.sint(),u===1)n=[],t.push(n);n?.push(o,r)}}return t}function be(e,t){let n=new Map,o=new oe(e);while(o.more){let r=o.varint();if(r>>3!==3){o.skip(r&7);continue}let i=o.sub(),u="",s=4096,a=[],l=[],m=[];while(i.more){let p=i.varint();switch(p>>3){case 1:u=i.string();break;case 2:m.push(i.sub());break;case 3:a.push(i.string());break;case 4:l.push(Fe(i.sub()));break;case 5:s=i.varint();break;default:i.skip(p&7)}}if(t&&!t.has(u))continue;let f=[];for(let p of m){let y=1,v={},I=[];while(p.more){let d=p.varint();switch(d>>3){case 2:{let x=p.sub();while(x.more){let A=a[x.varint()],P=l[x.varint()];if(A!==void 0&&P!==void 0)v[A]=P}break}case 3:y=Math.min(3,Math.max(1,p.varint()));break;case 4:I=Ee(p.sub());break;default:p.skip(d&7)}}f.push({type:y,properties:v,geometry:I})}n.set(u,{extent:s,features:f})}return n}var Te=96;function ze(e,t,n,o,r,i){let u=new Uint8ClampedArray(i*i*4),s=i/r,a=r+1;for(let l=0;l<i;l+=1){let m=(l+0.5)/s,f=Math.min(r-1,Math.floor(m)),p=m-f;for(let y=0;y<i;y+=1){let v=(y+0.5)/s,I=Math.min(r-1,Math.floor(v)),d=v-I,x=2*(f*a+I),A=x+2*a,P=(1-d)*(1-p),z=d*(1-p),L=(1-d)*p,J=d*p,C=P*o[x]+z*o[x+2]+L*o[A]+J*o[A+2],w=P*o[x+1]+z*o[x+3]+L*o[A+1]+J*o[A+3],b=C-0.5,c=w-0.5;if(!(b>-1&&c>-1&&b<t&&c<n))continue;let g=Math.floor(b),h=Math.floor(c),k=b-g,S=c-h,M=0,D=0,O=0,E=0;for(let T=0;T<4;T+=1){let _=g+(T&1),j=h+(T>>1);if(_<0||j<0||_>=t||j>=n)continue;let V=4*(j*t+_),K=(T&1?k:1-k)*(T>>1?S:1-S)*e[V+3];M+=K*e[V],D+=K*e[V+1],O+=K*e[V+2],E+=K}if(E<=0)continue;let q=4*(l*i+y);u[q]=M/E,u[q+1]=D/E,u[q+2]=O/E,u[q+3]=E}}return u}function ge(e=Te){let t=new Map,n=new Set,o=(l)=>{n.delete(l),l.then((m)=>m?.close(),()=>{return})},r=(l)=>{if(t.has(l))n.add(l);else o(l)},i=new W(e,r),u=(l)=>{let m=(t.get(l)??1)-1;if(m>0)t.set(l,m);else if(t.delete(l),n.has(l))o(l)},s=(l)=>{let m=i.get(l);if(!m)m=(async()=>{let f=await fetch(l);if(f.status===404||f.status===204||f.status===410)return null;if(!f.ok)throw Error(`isard: ${f.status} for a raster to reproject`);return createImageBitmap(await f.blob())})(),m.catch(()=>i.delete(l)),i.set(l,m);return t.set(m,(t.get(m)??0)+1),m};return{draw:async(l,m)=>{let f=l.sources.map((p)=>[p,s(p.url)]);try{let p=await Promise.all(f.map(async([x,A])=>[x,await A]));if(m.throwIfAborted(),!p.some(([,x])=>x))return null;let v=new OffscreenCanvas(l.width,l.height).getContext("2d",{willReadFrequently:!0});if(!v)throw Error("isard: no 2D canvas to reproject the tiles");for(let[x,A]of p)if(A)v.drawImage(A,x.x,x.y,x.w,x.h);let I=v.getImageData(0,0,l.width,l.height).data,d=ze(I,l.width,l.height,l.mesh,l.n,l.size);return createImageBitmap(new ImageData(d,l.size,l.size),{premultiplyAlpha:"none"})}finally{for(let[,p]of f)u(p)}},cache:i,close:()=>{for(let l of i.values())r(l);i.clear()}}}function Be(e,t,n=Number.NEGATIVE_INFINITY){let o=e.length>>2,r=new Float32Array(o);if(t==="terrarium")for(let i=0,u=0;i<o;i+=1,u+=4){let s=e[u]*256+e[u+1]+e[u+2]/256-32768;r[i]=s>n?s:n}else for(let i=0,u=0;i<o;i+=1,u+=4){let s=-1e4+(e[u]*65536+e[u+1]*256+e[u+2])*0.1;r[i]=s>n?s:n}return r}async function he(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 u=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(u,0,0,256,256),Be(s.getImageData(0,0,256,256).data,t,n)}finally{u.close()}}var De="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",X;function Oe(e){if(!X){X=new Map;let t=De.split(" ");for(let n=0;n+1<t.length;n+=2)X.set(t[n],t[n+1])}return X.get(e)}var Y=(e)=>Number.isFinite(e)?Math.max(0,Math.min(1,e)):0;function ye(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 qe(e){if(e===void 0)return 1;return Y(e.endsWith("%")?Number.parseFloat(e)/100:Number.parseFloat(e))}function Ve(e,t,n){let o=n<0.5?n*(1+t):n+t-n*t,r=2*n-o,i=(u)=>{let s=(u%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 we(e){if(typeof e!=="string")return;let t=e.trim().toLowerCase();if(t.startsWith("#"))return ye(t.slice(1));if(t==="transparent")return[0,0,0,0];let n=Oe(t);if(n)return ye(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((m)=>Number.isNaN(Number.parseFloat(m))))return;let i=qe(r[3]);if(o[1].startsWith("rgb")){let m=(f)=>Y(f.endsWith("%")?Number.parseFloat(f)/100:Number.parseFloat(f)/255);return[m(r[0]),m(r[1]),m(r[2]),i]}let u=Number.parseFloat(r[0])/360,[s,a,l]=Ve(u,Y(Number.parseFloat(r[1])/100),Y(Number.parseFloat(r[2])/100));return[s,a,l,i]}var $e=["Unknown","Point","LineString","Polygon"];function ie(e,t){return{zoom:t,properties:e.properties,type:$e[e.type]??"Unknown"}}function U(e){return we(e)}function Q([e,t,n,o]){return`rgba(${Math.round(e*255)},${Math.round(t*255)},${Math.round(n*255)},${o})`}function ve(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 se(e,t,n){if(typeof e==="number"&&typeof t==="number")return e+(t-e)*n;let o=U(e),r=U(t);if(o&&r)return Q([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,u)=>se(i,t[u],n));return n<0.5?e:t}function Se(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.stops)}function We(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]),u=o[0];if(!u)return e.default;if(n<=i(u))return u[1];for(let s=1;s<o.length;s+=1){let[a,l]=[o[s-1],o[s]];if(!a||!l)continue;if(n<i(l)){if(r==="interval")return a[1];return se(a[1],l[1],ve(n,i(a),i(l),e.base??1))}}return o.at(-1)?.[1]}function G(e,t){if(t==="$type")return e.type;return typeof t==="string"?e.properties[t]:void 0}var Ue=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 ae(e){return Array.isArray(e)&&typeof e[0]==="string"&&Ue.has(e[0])}var xe=new Set,H=(e)=>e===void 0||e===null?"":String(e);function R(e,t){if(Se(e))return We(e,t);if(!Array.isArray(e))return e;let[n,...o]=e;if(typeof n!=="string")return e;let r=(s)=>R(o[s]??null,t),i=(s)=>Number(r(s)),u=()=>o.map((s,a)=>i(a));switch(n){case"literal":return o[0];case"zoom":return t.zoom;case"get":return G(t,r(0));case"has":return G(t,r(0))!==void 0;case"!has":return G(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,a)=>H(r(a))).join("");case"format":return o.map((s,a)=>s!==null&&typeof s==="object"&&!Array.isArray(s)?"":H(r(a))).join("");case"image":return r(0);case"number-format":{let s=o[1]??{},a=i(0);if(!Number.isFinite(a))return"";return a.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 a=r(s),l=typeof a==="string"&&a.trim()===""?Number.NaN:Number(a);if(a!==null&&a!==void 0&&!Number.isNaN(l))return l}return 0}case"to-string":return H(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":(a)=>U(a)!==void 0,number:(a)=>typeof a==="number",string:(a)=>typeof a==="string",boolean:(a)=>typeof a==="boolean"};for(let a=0;a<o.length;a+=1){let l=r(a);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 H(r(0)).toUpperCase();case"downcase":return H(r(0)).toLowerCase();case"coalesce":for(let s=0;s<o.length;s+=1){let a=r(s);if(a!==void 0&&a!==null)return a}return null;case"!":return!r(0);case"all":return o.every((s,a)=>Boolean(r(a)));case"any":return o.some((s,a)=>Boolean(r(a)));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),a=r(0);if(typeof s==="string")return s.includes(String(a));return Array.isArray(s)&&s.includes(a)}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 a=1;a+1<o.length;a+=2){let l=o[a];if(Array.isArray(l)?l.includes(s):l===s)return r(a+1)}return r(o.length-1)}case"step":{let s=i(0),a=r(1);for(let l=2;l+1<o.length;l+=2)if(s>=Number(o[l]))a=r(l+1);else break;return a}case"interpolate":case"interpolate-hcl":case"interpolate-lab":{let s=o[0],a=i(1),l=Array.isArray(s)&&s[0]==="exponential"?Number(s[1]):1,m=[];for(let p=2;p+1<o.length;p+=2)m.push([Number(o[p]),o[p+1]??null]);let f=m[0];if(!f)return null;if(a<=f[0])return R(f[1],t);for(let p=1;p<m.length;p+=1){let[y,v]=[m[p-1],m[p]];if(y&&v&&a<v[0])return se(R(y[1],t),R(v[1],t),ve(a,y[0],v[0],l))}return R(m.at(-1)?.[1]??null,t)}case"rgb":case"rgba":return Q([i(0)/255,i(1)/255,i(2)/255,o.length>3?i(3):1]);case"+":return u().reduce((s,a)=>s+a,0);case"*":return u().reduce((s,a)=>s*a,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(...u());case"max":return Math.max(...u());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(!xe.has(n))xe.add(n),console.warn(`isard: the style expression "${n}" is not supported`);return null}}var _e=new Set(["==","!=","<","<=",">",">="]);function je(e){let[t,n,...o]=e;if(typeof t!=="string"||typeof n!=="string"||o.some(Array.isArray))return!1;if(_e.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 He(e,t){let[n,o,...r]=e,i=G(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 ke=new WeakMap;function Ae(e){if(!Array.isArray(e))return()=>Boolean(e);let t=ke.get(e);if(t)return t;let n,o=e[0];if(o==="all"||o==="any"||o==="none"){let r=e.slice(1).map(Ae);if(o==="all")n=(i)=>r.every((u)=>u(i));else if(o==="any")n=(i)=>r.some((u)=>u(i));else n=(i)=>!r.some((u)=>u(i))}else if(je(e))n=(r)=>He(e,r);else n=(r)=>Boolean(R(e,r));return ke.set(e,n),n}function ue(e,t){if(e===void 0||e===null)return!0;return Ae(e)(t)}function ee(e){if(e!==void 0&&Se(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)=>ee(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=R(e,t);if(Array.isArray(n))return n.filter((o)=>typeof o==="string").join("");return n===void 0||n===null?"":String(n)}function Ce(e){return/Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(e)?e:`${e} Regular`}function Ie(e){let t=new Set,n=(u)=>{if(!Array.isArray(u))return;let s=(a)=>Array.isArray(a)&&a[0]==="zoom";if((u[0]==="interpolate"||u[0]==="interpolate-hcl"||u[0]==="interpolate-lab")&&s(u[2]))for(let a=3;a<u.length;a+=2)t.add(Number(u[a]));else if(u[0]==="step"&&s(u[1]))for(let a=3;a<u.length;a+=2){let l=Number(u[a]);t.add(l),t.add(l-0.01)}for(let a of u)n(a)};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 u=Math.ceil(r);u<=Math.floor(i);u+=1)o.push(u);return[...new Set(o)].sort((u,s)=>u-s).map((u)=>[u,Number(R(e,{zoom:u,properties:{},type:"Unknown"}))])}var te=new Map,Pe=96,re=new W(Pe);function Ze(e){return Math.max(16,Math.ceil(Pe/Math.max(1,e)))}var le=new Set,Z=new Set,fe=new Map,Ke={},Ne=ge(),ce=new W(64,(e)=>e.then((t)=>setTimeout(()=>t?.close(),0),()=>{return}));function Xe(e,t="auto"){let n=ce.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(()=>ce.delete(e)),ce.set(e,o),o}function Re(e,t="auto"){let n=re.get(e);if(n)return n;let o=(async()=>{for(let r=0;;r+=1){let u=await fetch(e,{priority:t});if(u.status===404||u.status===204)return;if(u.ok)return be(new Uint8Array(await u.arrayBuffer()));if(r>=2)throw Error(`${e}: ${u.status}`);await new Promise((s)=>setTimeout(s,400*(r+1)))}})();return o.catch(()=>re.delete(e)),re.set(e,o),o}function Ye(e,t,n,o){let r=Math.max(0,Math.min(t-1,e.maxzoom)),i=t-r,u=2**Math.max(0,i),[s,a]=i>=0?[Math.floor(n/u),Math.floor(o/u)]:[n,o],l=e.tiles.replace("{z}",String(r)).replace("{x}",String(s)).replace("{y}",String(a)),m=1/u;return{url:l,vz:r,vx:s,vy:a,part:m,ox:n%u*m,oy:o%u*m}}var N=(e,t,n,o,r)=>{let i=e[t]?.[n];if(i===void 0)return r;let u=Array.isArray(i)&&!ae(i)?i:R(i,o);return u===void 0||u===null?r:u};function B(e,t){let n=U(e)??[0,0,0,1];return Q([n[0],n[1],n[2],n[3]*t])}function Le(e,t){if(e.layout?.visibility==="none")return!1;return t>=(e.minzoom??0)&&t<(e.maxzoom??24)}function Ge(e,t){if(e.patterns.has(t))return e.patterns.get(t);let n=e.sprite?.icons[t],o;if(e.sprite&&n&&n.width>0&&n.height>0)o=new OffscreenCanvas(n.width,n.height),o.getContext("2d")?.drawImage(e.sprite.image,n.x,n.y,n.width,n.height,0,0,n.width,n.height);return e.patterns.set(t,o),o}var me=new Map;function Qe(e){let t=me.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 et(e){let t=me.get(e.width)??[];if(me.set(e.width,t),t.length<4)t.push(e)}function tt(e,t,n){if(n)return Promise.resolve(e.transferToImageBitmap());return createImageBitmap(t.getImageData(0,0,e.width,e.height),{premultiplyAlpha:"none"})}async function nt(e,t,n,o,r,i,u){let s=Ye(e,t,n,o),a=await Re(s.url,u);if(Z.has(i))return;let{canvas:l,g:m}=Qe(r);try{return await rt(e,s,a,l,m,t,n,o,r,i,u)}finally{et(l)}}async function rt(e,t,n,o,r,i,u,s,a,l,m){let f=e.sprite,p=Math.max(0,i-1),y=a/256,v=!1,I=!1;for(let d of e.layers){if(!Le(d,p))continue;let x={zoom:p,properties:{},type:"Unknown"};if(d.type==="background"){let b=N(d,"paint","background-color",x,"#000"),c=Number(N(d,"paint","background-opacity",x,1));if(r.fillStyle=B(b,c),r.fillRect(0,0,a,a),(U(b)??[0,0,0,1])[3]*c>=1)I=!0;v=!0;continue}if(d.type==="raster"){let b=d.source===void 0?void 0:e.rasters[d.source];if(!b)continue;let c=Math.max(0,Math.min(i-(b.tileSize>=512?1:0),b.maxzoom)),g=2**(i-c),h=b.tiles.replace("{z}",String(c)).replace("{x}",String(Math.floor(u/g))).replace("{y}",String(Math.floor(s/g))),k=await Xe(h,m).catch(()=>{return});if(Z.has(l))return;if(!k)continue;let[S,M]=[k.width/g,k.height/g];r.globalAlpha=Number(N(d,"paint","raster-opacity",x,1)),r.drawImage(k,u%g*S,s%g*M,S,M,0,0,a,a),r.globalAlpha=1,v=!0;continue}let A=n?.get(d["source-layer"]??"");if(!A)continue;let P=a/(A.extent*t.part),[z,L]=[t.ox*A.extent,t.oy*A.extent],J=(b,c)=>{r.beginPath();for(let g of b.geometry){for(let h=0;h+1<g.length;h+=2){let[k,S]=[((g[h]??0)-z)*P,((g[h+1]??0)-L)*P];if(h===0)r.moveTo(k,S);else r.lineTo(k,S)}if(c)r.closePath()}},C=new Map,w=(b,c,g,h)=>{let k=C.get(c);if(k===void 0)k=ee(d[b]?.[c]),C.set(c,k);return N(d,b,c,k?g:x,h)};for(let b of A.features){let c=ie(b,p);if(!ue(d.filter,c))continue;if(d.type==="fill-extrusion"&&b.type===3)J(b,!0),r.fillStyle=B(w("paint","fill-extrusion-color",c,"#000"),Number(w("paint","fill-extrusion-opacity",c,1))),r.fill("evenodd"),v=!0;else if(d.type==="fill"&&b.type===3){let g=Number(w("paint","fill-opacity",c,1)),h=w("paint","fill-pattern",c,void 0);J(b,!0);let k=typeof h==="string"?f?.icons[h]:void 0,S=k&&Ge(e,h);if(k&&S){let M=r.createPattern(S,"repeat");if(M)M.setTransform(new DOMMatrix().scale(y/(k.pixelRatio??1))),r.globalAlpha=g,r.fillStyle=M,r.fill("evenodd"),r.globalAlpha=1}else{r.fillStyle=B(w("paint","fill-color",c,"#000"),g),r.fill("evenodd");let M=w("paint","fill-outline-color",c,void 0);if(M!==void 0)r.strokeStyle=B(M,g),r.lineWidth=y,r.setLineDash([]),r.stroke()}v=!0}else if(d.type==="line"&&b.type!==1){let g=Number(w("paint","line-width",c,1));if(g<=0)continue;let h=Number(w("paint","line-gap-width",c,0));r.strokeStyle=B(w("paint","line-color",c,"#000"),Number(w("paint","line-opacity",c,1))),r.lineWidth=(h>0?h+2*g:g)*y,r.lineCap=String(w("layout","line-cap",c,"butt")),r.lineJoin=String(w("layout","line-join",c,"miter"));let k=w("paint","line-dasharray",c,void 0);r.setLineDash(Array.isArray(k)?k.map((S)=>Number(S)*g*y):[]),J(b,b.type===3),r.stroke(),v=!0}else if(d.type==="circle"&&b.type===1){let g=Number(w("paint","circle-radius",c,5))*y;r.fillStyle=B(w("paint","circle-color",c,"#000"),Number(w("paint","circle-opacity",c,1)));let h=Number(w("paint","circle-stroke-width",c,0))*y;r.strokeStyle=B(w("paint","circle-stroke-color",c,"#000"),Number(w("paint","circle-stroke-opacity",c,1))),r.lineWidth=h;for(let k of b.geometry)for(let S=0;S+1<k.length;S+=2)if(r.beginPath(),r.arc(((k[S]??0)-z)*P,((k[S+1]??0)-L)*P,g,0,2*Math.PI),r.fill(),h>0)r.stroke();v=!0}}}if(!v&&!n)return null;return tt(o,r,I)}function ot(e){let{layout:t={},paint:n={}}=e;return t["icon-image"]!==void 0&&n["text-halo-width"]===void 0&&n["text-halo-color"]===void 0&&t["text-offset"]===void 0&&(t["text-anchor"]??"center")==="center"}function ne(e,t,n,o,r,i){let u=2**e;return[pe((t+r/o)/u),de((n+i/o)/u)]}async function it(e,t,n,o,r,i){let u=e.tiles.replace("{z}",String(t)).replace("{x}",String(n)).replace("{y}",String(o)),s=await Re(u,i);if(!s||Z.has(r))return[];let a=[],l=new Map,m=(f)=>{let p=l.get(f);if(p===void 0){let y=f.layout?.["text-size"]??16;p=ae(y)?Ie(y):y,l.set(f,p)}return p};return e.layers.forEach((f,p)=>{if(f.type!=="symbol"||!Le(f,t)||f.layout?.["text-field"]===void 0)return;if(ot(f))return;let y=s.get(f["source-layer"]??"");if(!y)return;let v=f.layout?.["symbol-placement"]==="line"?"line":"point";for(let I of y.features){let d=ie(I,t);if(!ue(f.filter,d))continue;let x=Me(f.layout?.["text-field"],d).trim();if(!x)continue;let A=N(f,"layout","text-transform",d,"none");if(A==="uppercase")x=x.toUpperCase();else if(A==="lowercase")x=x.toLowerCase();let P=N(f,"layout","text-font",d,["Noto Sans Regular"]),z=Ce(Array.isArray(P)&&typeof P[0]==="string"?P[0]:"Noto Sans Regular"),L=N(f,"layout","text-offset",d,[0,0]),J={layer:p,text:x,font:z,size:ee(f.layout?.["text-size"])?Number(N(f,"layout","text-size",d,16)):m(f),color:String(N(f,"paint","text-color",d,"#000")),haloColor:String(N(f,"paint","text-halo-color",d,"rgba(0,0,0,0)")),haloWidth:Number(N(f,"paint","text-halo-width",d,0)),anchor:String(N(f,"layout","text-anchor",d,"center")),offset:Array.isArray(L)?[Number(L[0]??0),Number(L[1]??0)]:[0,0],maxWidth:Number(N(f,"layout","text-max-width",d,10)),lineHeight:Number(N(f,"layout","text-line-height",d,1.2)),overlap:Boolean(N(f,"layout","text-allow-overlap",d,!1))};if(I.type===1)for(let C of I.geometry)for(let w=0;w+1<C.length;w+=2){let[b,c]=[C[w]??0,C[w+1]??0];if(b<0||c<0||b>=y.extent||c>=y.extent)continue;let[g,h]=ne(t,n,o,y.extent,b,c);a.push({...J,lon:g,lat:h})}else{let C,w=0;for(let c of I.geometry){let g=0;for(let h=2;h+1<c.length;h+=2)g+=Math.hypot((c[h]??0)-(c[h-2]??0),(c[h+1]??0)-(c[h-1]??0));if(g>w)w=g,C=c}if(!C||w<y.extent/32)continue;let b=w/2;for(let c=2;c+1<C.length;c+=2){let[g,h,k,S]=[C[c-2]??0,C[c-1]??0,C[c]??0,C[c+1]??0],M=Math.hypot(k-g,S-h);if(M>=b&&M>0){let[D,O]=[g+(k-g)*b/M,h+(S-h)*b/M];if(D<0||O<0||D>=y.extent||O>=y.extent)break;let[E,q]=ne(t,n,o,y.extent,D,O),[T,_]=ne(t,n,o,y.extent,k,S),[j,V]=ne(t,n,o,y.extent,g,h);a.push({...J,lon:E,lat:q,...v==="line"?{along:[T-j,_-V]}:{}});break}b-=M}}}}),a}var F=(e,t=[])=>self.postMessage(e,t);self.onmessage=async({data:e})=>{if(e.type==="init"){if(e.workers!==void 0)re.capacity=Ze(e.workers);te.set(e.key,{tiles:e.tiles,maxzoom:e.maxzoom,layers:e.layers,rasters:e.rasters??{},sprite:e.sprite,patterns:new Map});return}if(e.type==="drop"){te.get(e.key)?.sprite?.image.close(),te.delete(e.key);return}if(e.type==="abort"){if(le.has(e.id))Z.add(e.id);fe.get(e.id)?.abort();return}if(e.type==="heights"||e.type==="reproject"){await st(e);return}le.add(e.id);let t=te.get(e.key);try{if(!t)throw Error(`no renderer ${e.key}`);if(e.type==="render"){let n=await nt(t,e.z,e.x,e.y,e.size,e.id,e.priority);if(n)F({id:e.id,image:n},[n]);else F({id:e.id,missing:!0})}else F({id:e.id,labels:await it(t,e.z,e.x,e.y,e.id,e.priority)})}catch(n){F({id:e.id,error:String(n)})}finally{le.delete(e.id),Z.delete(e.id)}};async function st(e){let t=new AbortController;fe.set(e.id,t);try{if(e.type==="heights"){let n=await he(e.url,e.encoding,e.floor,t.signal,Ke);if(n)F({id:e.id,heights:n},[n.buffer]);else F({id:e.id,missing:!0})}else{Ne.cache.capacity=e.cached;let n=await Ne.draw(e.job,t.signal);if(n)F({id:e.id,image:n},[n]);else F({id:e.id,missing:!0})}}catch(n){F({id:e.id,error:String(n)})}finally{fe.delete(e.id)}}export{Ze as cacheShare,tt as tileImage};
|
|
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};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=387083002A9A758864756E2164756E21
|
|
4
4
|
//# sourceMappingURL=basemap.worker.js.map
|