isard 0.2.1 → 0.4.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +8 -4
  3. package/dist/animation.d.ts +18 -0
  4. package/dist/animation.js +84 -0
  5. package/dist/animation.js.map +1 -0
  6. package/dist/basemap.worker.d.ts +26 -4
  7. package/dist/basemap.worker.js +2 -2
  8. package/dist/basemap.worker.js.map +9 -5
  9. package/dist/crs.d.ts +72 -0
  10. package/dist/crs.js +243 -0
  11. package/dist/crs.js.map +1 -0
  12. package/dist/decoder.worker.js +4 -4
  13. package/dist/decoder.worker.js.map +4 -4
  14. package/dist/engine-loader.d.ts +28 -0
  15. package/dist/engine-loader.js +112 -0
  16. package/dist/engine-loader.js.map +1 -0
  17. package/dist/features.d.ts +8 -0
  18. package/dist/features.js +17 -10
  19. package/dist/features.js.map +1 -1
  20. package/dist/geo.d.ts +16 -0
  21. package/dist/geo.js +32 -0
  22. package/dist/geo.js.map +1 -0
  23. package/dist/geoplateforme.d.ts +21 -5
  24. package/dist/geoplateforme.js +47 -12
  25. package/dist/geoplateforme.js.map +1 -1
  26. package/dist/glyphs.d.ts +13 -3
  27. package/dist/glyphs.js +26 -4
  28. package/dist/glyphs.js.map +1 -1
  29. package/dist/gpx.d.ts +11 -0
  30. package/dist/gpx.js +74 -0
  31. package/dist/gpx.js.map +1 -0
  32. package/dist/grid.d.ts +81 -0
  33. package/dist/grid.js +270 -0
  34. package/dist/grid.js.map +1 -0
  35. package/dist/icons.d.ts +146 -0
  36. package/dist/icons.js +333 -0
  37. package/dist/icons.js.map +1 -0
  38. package/dist/index.d.ts +11 -4
  39. package/dist/index.js +6 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/interaction.d.ts +0 -4
  42. package/dist/interaction.js +8 -4
  43. package/dist/interaction.js.map +1 -1
  44. package/dist/isard_bg.wasm +0 -0
  45. package/dist/isard_core_bg.wasm +0 -0
  46. package/dist/kml.d.ts +12 -0
  47. package/dist/kml.js +159 -0
  48. package/dist/kml.js.map +1 -0
  49. package/dist/layers.d.ts +89 -2
  50. package/dist/layers.js +171 -15
  51. package/dist/layers.js.map +1 -1
  52. package/dist/lru.d.ts +22 -0
  53. package/dist/lru.js +52 -0
  54. package/dist/lru.js.map +1 -0
  55. package/dist/map.d.ts +45 -7
  56. package/dist/map.js +138 -310
  57. package/dist/map.js.map +1 -1
  58. package/dist/resample.d.ts +41 -0
  59. package/dist/resample.js +164 -0
  60. package/dist/resample.js.map +1 -0
  61. package/dist/settings.d.ts +39 -0
  62. package/dist/settings.js +104 -0
  63. package/dist/settings.js.map +1 -0
  64. package/dist/symbols.d.ts +54 -9
  65. package/dist/symbols.js +278 -55
  66. package/dist/symbols.js.map +1 -1
  67. package/dist/terrain.d.ts +19 -7
  68. package/dist/terrain.js +40 -28
  69. package/dist/terrain.js.map +1 -1
  70. package/dist/topojson.d.ts +29 -0
  71. package/dist/topojson.js +66 -0
  72. package/dist/topojson.js.map +1 -0
  73. package/dist/types.d.ts +14 -6
  74. package/dist/types.js.map +1 -1
  75. package/dist/vectorstyle.d.ts +32 -3
  76. package/dist/vectorstyle.js.map +1 -1
  77. package/dist/vectortiles.d.ts +19 -7
  78. package/dist/vectortiles.js +117 -69
  79. package/dist/vectortiles.js.map +1 -1
  80. package/dist/wasm/isard.d.ts +55 -7
  81. package/dist/wasm/isard.js +117 -6
  82. package/dist/wasm/isard_core.d.ts +29 -4
  83. package/dist/wasm/isard_core.js +84 -5
  84. package/dist/wmts.d.ts +14 -0
  85. package/dist/wmts.js +76 -0
  86. package/dist/wmts.js.map +1 -0
  87. package/dist/xml.d.ts +26 -0
  88. package/dist/xml.js +109 -0
  89. package/dist/xml.js.map +1 -0
  90. package/package.json +1 -1
  91. package/dist/equirectangular.d.ts +0 -35
  92. package/dist/equirectangular.js +0 -143
  93. package/dist/equirectangular.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,99 @@
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.4.0] - 2026-10-18
7
+
8
+ ### Added
9
+
10
+ - Icons in the symbol layers: a vector basemap's icons from the `sprite` of its style (one sprite or several with
11
+ their ids, `@2x` on high-density screens), points of interest, road shields with their numbers centred, one-way
12
+ arrows every `symbol-spacing` along the roads; `icon-image` (tokens and expressions), `icon-size`, `icon-anchor`,
13
+ `icon-offset`, `icon-rotate`, `icon-rotation-alignment`, `icon-allow-overlap`, `icon-ignore-placement`,
14
+ `icon-optional`, `text-optional`, `text-ignore-placement`, `icon-text-fit` with its padding (an image's `stretchX`,
15
+ `stretchY` and `content` kept), `icon-color` of signed distance field images, `icon-opacity`. The text and the icon
16
+ of a label have their own boxes in the collision grid. The images used are packed into one RGBA atlas.
17
+ - `map.addImage(name, image, { pixelRatio, sdf, stretchX, stretchY, content })`, `hasImage`, `removeImage`, and the
18
+ symbol layers' `icon`, `iconSize`, `iconAnchor`, `iconOffset`, `iconRotate`, `iconRotationAlignment`, `iconOverlap`,
19
+ `iconOptional`, `iconTextFit`, `iconTextFitPadding`, `iconColor`, `iconOpacity` and `textOptional`; `overlap` also
20
+ takes `'allow'` and `'ignore'`; `placement` may be a function of the feature.
21
+ - Custom layers: `map.addCustomLayer({ renderingMode, onAdd, render, onRemove })`, the page's own WebGL drawing (raw,
22
+ or a three.js scene) called at its place among the layers in every frame, as MapLibre's; `frame.matrixAt(lonLat,
23
+ altitude)` gives the model-view-projection of a local east-north-up frame in metres there, made in f64 relative to
24
+ the camera (exact at any zoom, on the plane and the globe); `'3d'` shares the depth buffer of the relief, the
25
+ buildings and the 3D Tiles; the WebGL state the page changes is set back after it; `onAdd` again after a context
26
+ loss. The `threejs` example.
27
+ - glTF models: `map.addModels({ url | data, instances: [{ lonLat, altitude, heading, pitch, roll, scale }],
28
+ altitudeReference })`, a glTF binary drawn at positions in one instanced draw per primitive, decoded as 3D Tiles
29
+ content is (meshopt, quantization, Draco and KTX2 in the workers), standing on the relief by default, with depth;
30
+ `setInstances`; `pickFeature` gives the instance's index. Textured surfaces unlit as the 3D Tiles, the others in
31
+ their material's base color, lit from above. The first model loads the engine with 3D Tiles, as a 3D Tiles layer
32
+ does. The `models` example.
33
+
34
+ ### Changed
35
+
36
+ - A vector basemap's text written over its icon (a road shield's number) is drawn with it, no longer left out;
37
+ `text-rotation-alignment: viewport` keeps a text along a line horizontal; `symbol-placement` may be an expression;
38
+ past the source's deepest level, the labels take the style's layers of the view's zoom (points of interest at 17).
39
+ - The decoder keeps the base color factor of a glTF material (`color` of the decoded primitives, when not white).
40
+
41
+ ## [0.3.0] - 2026-10-18
42
+
43
+ ### Changed
44
+
45
+ - Fill layers share their vertices (the caps index the points of the rings, the walls stand on them) and build the
46
+ prism of the relief only on their first frame in relief: 100,000 pentagons upload 17 MB flat and 49 MB in relief,
47
+ instead of 123 MB either way, and are triangulated in 37 ms instead of 59.
48
+ - Extrusion layers draw only the blocks in view: a batch is sorted by square of a grid over its blocks, as the
49
+ lines and fills are (one batch for a whole city drew every building every frame).
50
+ - The style of the features takes the texels its layer reads: 48 bytes a feature for lines, 96 for circles, 80 for
51
+ extrusions, 16 for fills (128 for all before).
52
+ - The symbol layers keep their tables from one set of labels to the next while they fit (two textures were created
53
+ and deleted at each update, several times a second while the map moves).
54
+ - 3D Tiles: a mesh used by several nodes of a tile is read once, its texture coordinates and triangles shared by its
55
+ instances; an image used by several primitives is handed over and decoded once, and uploaded once (on the main
56
+ thread, or when the decoding workers give the same bitmap); the selection of the tiles reuses its buffers from frame
57
+ to frame.
58
+ - Fill and extrusion layers: a polygon whose rings start before the previous polygon's end takes only those after it
59
+ (no ring shared by two polygons): malformed offsets cost no more than the rings there are.
60
+ - Ground layers: `ISARD_CIRCUMFERENCE`, the body's circumference in metres (`ISARD_EARTH` still works).
61
+ - The basemap's labels are shaped once per vector tile while it is kept: as the view moves, only the labels of the
62
+ tiles coming into view are shaped (an update of 36 tiles of 150 labels after a pan of one column: 55 ms → 11 ms on
63
+ the main thread), the others reused as they were.
64
+ - The Terrarium and Terrain-RGB relief is decoded and the equirectangular rasters are reprojected by the vector
65
+ basemap's workers (OffscreenCanvas), off the main thread; in the page with `workers: false`.
66
+ - The glyph atlas sent again (a new engine, more pages) is sent down to the last glyph of each page only.
67
+ - Equirectangular rasters are reprojected as any other grid (each tile planned in the page through a mesh of 17 × 17
68
+ points, sampled in a worker), their colors interpolated between source rows as along them.
69
+
70
+ ### Added
71
+
72
+ - `basemapTileSize`: the texture size of the vector basemap's tiles (default 512; 256 for a quarter of the drawing,
73
+ uploads and GPU memory, lines a little softer).
74
+ - Data in other CRSs, reprojected into the map (no new view projection): built-in EPSG:4326, EPSG:3857, Lambert-93
75
+ (EPSG:2154), the CC zones (EPSG:3942 to 3950) and the UTM zones of WGS 84 and ETRS89, within 0.1 mm of PROJ; any
76
+ other through an object with `forward` and `inverse` such as `proj4('EPSG:…')`, directly or named by `registerCrs`;
77
+ `getCrs`, `lambertConformalConic`, `transverseMercator`.
78
+ - Rasters in another tile grid: `addRaster({ url, grid: { crs, matrices, bounds } })` for the tile matrices of a WMTS
79
+ in any CRS, or a grid without matrices for a WMS asked for each tile's `{bbox}` in its CRS; reprojected by the map's
80
+ workers through a mesh of control points, without seams (PLAN IGN from Lambert-93 matches its Web Mercator tiles to
81
+ within 0.06 pixel). `wmtsGrid` and `parseWmtsGrid` read the grid of a layer from WMTS capabilities.
82
+ - Géoplateforme: `geoplateformeWmts(layer, { matrixSet: '2154_10cm_6_20' })` for its Lambert-93 layers (PLAN IGN,
83
+ orthophotos, cadastre…), `geoplateformeWms(layers, { crs: 'EPSG:2154' })`, `geoplateformeWfs(…, { srsName })`.
84
+ - GeoJSON in another CRS: the feature layers reproject a collection whose `crs` member names one (a WFS's output in
85
+ EPSG:2154); `reproject(data, crs)` for the others.
86
+ - `parseKml`, `parseGpx`, `parseTopoJson`: KML (placemarks, MultiGeometry, gx:Track, extended data, style colors), GPX
87
+ (waypoints, routes, tracks with altitudes and times) and TopoJSON as GeoJSON, with their own XML reader (no
88
+ `DOMParser`: in workers too), each a module of its own.
89
+ - The Lambert-93 example: PLAN IGN reprojected from Lambert-93, the arrondissements of Paris from a WFS in EPSG:2154, a
90
+ GPX file.
91
+
92
+ ### Fixed
93
+
94
+ - Picking in relief: lines, circles and networks hidden by a hill (or by extruded blocks drawn before them) are no
95
+ longer picked: the ground's depth is drawn into the picking pass and the layers are tested against it as on screen.
96
+ - Each frame starts from the full GL state (depth and stencil writes, scissor, tests, blending), whatever a layer or a
97
+ picking pass left.
98
+
6
99
  ## [0.2.1] - 2026-10-18
7
100
 
8
101
  ### Changed
package/README.md CHANGED
@@ -42,7 +42,9 @@ 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
- - 🦀 **Small and exact.** 220 KB of WebAssembly gzipped (330 KB once a 3D Tiles layer is added), f64 on the CPU and f32 relative to the camera on the GPU
45
+ - 🧊 **Your own 3D.** glTF models at positions, instanced and picked; custom layers for your WebGL code or a three.js
46
+ scene, in the map's frame and depth, with camera-relative matrices exact at any zoom.
47
+ - 🦀 **Small and exact.** 225 KB of WebAssembly gzipped (345 KB once a 3D Tiles layer or a model is added), f64 on the CPU and f32 relative to the camera on the GPU
46
48
  (centimetres at any zoom), frames on demand only, strict TypeScript types end to end.
47
49
 
48
50
  ## Quick start
@@ -94,12 +96,14 @@ Live in the [documentation](https://graffkevin.github.io/isard/examples/), sourc
94
96
  | Layer | | |
95
97
  |---|---|---|
96
98
  | [Networks](https://graffkevin.github.io/isard/layers/networks) | `addNetwork` | millions of edges colored by a value per node, worked out per pixel along the edges |
97
- | [Lines, circles, fills](https://graffkevin.github.io/isard/layers/features) | `addLines`, `addCircles`, `addFills` | GeoJSON styled per feature: zoom stops, functions, values through a ramp, filters |
99
+ | [Lines, circles, fills](https://graffkevin.github.io/isard/layers/features) | `addLines`, `addCircles`, `addFills` | GeoJSON styled per feature: zoom stops, functions, values through a ramp, filters; in any CRS, KML, GPX and TopoJSON parsed |
98
100
  | [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 |
99
101
  | [Buildings](https://graffkevin.github.io/isard/layers/buildings) | `addExtrusions` | tiles or one set, colored by values or by a network's times |
100
102
  | [Ground shaders](https://graffkevin.github.io/isard/layers/ground) | `addGround` | your fragment shader over the ground: water depth, heat maps |
101
- | [Rasters](https://graffkevin.github.io/isard/layers/rasters) | `addRaster` | XYZ, WMTS, WMS, equirectangular tiles reprojected, or tiles drawn by your code |
103
+ | [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
104
  | [3D Tiles](https://graffkevin.github.io/isard/layers/tiles3d) | `addTiles3d` | b3dm, glb, external tilesets, compressed or not |
105
+ | [glTF models](https://graffkevin.github.io/isard/layers/models) | `addModels` | a glTF model at many positions, instanced, on the relief, picked |
106
+ | [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
107
 
104
108
  Plus markers, popups, controls, picking within a radius, `easeTo`, `flyTo`, a sky and fog for tilted views. All in
105
109
  the [API reference](https://graffkevin.github.io/isard/api).
@@ -142,7 +146,7 @@ More in [Develop and release](https://graffkevin.github.io/isard/guide/develop).
142
146
  ## Roadmap
143
147
 
144
148
  - Flood maps over the relief (water depth as a ground shader) as a full example.
145
- - Icons of the basemaps' symbol layers (sprites), text along curved lines.
149
+ - Text along curved lines, and repeated along long ones.
146
150
  - Labels fading in and out instead of popping.
147
151
 
148
152
  ## Licence
@@ -0,0 +1,18 @@
1
+ import type { AnimationOptions, FlyToOptions } from './types.ts';
2
+ import type { Camera, Engine } from './wasm/isard.js';
3
+ /** A step of an animation, at `now` (milliseconds, the frame's time): false once done */
4
+ export type Step = (now: number) => boolean;
5
+ /** What a step needs of the engine, read at each frame */
6
+ type Target = () => Pick<Engine, 'setCamera' | 'clearPreload'>;
7
+ /** MapLibre's default easing: cubic Bézier (0.25, 0.1, 0.25, 1) */
8
+ export declare function defaultEasing(t: number): number;
9
+ /** The step of an animated move from `from` to `to`: over `duration` milliseconds (or the options), ease-out by
10
+ * default, the bearing turning the shortest way round */
11
+ export declare function easeTo(engine: Target, from: Camera, to: Camera, options?: number | AnimationOptions): Step;
12
+ /**
13
+ * The step of a flight from `from` to `to` that zooms out on its way and back in (van Wijk and Nuij's optimal path, as
14
+ * MapLibre's `flyTo`): long moves stay readable. Pitch and bearing follow the progress. `viewport`: the larger side of
15
+ * the canvas, CSS pixels.
16
+ */
17
+ export declare function flyTo(engine: Target, from: Camera, to: Camera, viewport: number, options?: FlyToOptions): Step;
18
+ export {};
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Camera animations: each is a step run every frame by the map (`GeoMap.animate`) until it returns false, setting the
3
+ * camera of the engine in use at that frame (it may be replaced during a flight).
4
+ */
5
+ import { fromMercator, toMercator } from "./geo.js";
6
+ /** MapLibre's default easing: cubic Bézier (0.25, 0.1, 0.25, 1) */
7
+ export function defaultEasing(t) {
8
+ if (t <= 0 || t >= 1)
9
+ return Math.max(0, Math.min(1, t));
10
+ // Solve x(u) = t for the curve parameter, Newton then bisection
11
+ const [x1, y1, x2, y2] = [0.25, 0.1, 0.25, 1];
12
+ const bezier = (u, a, b) => 3 * a * u * (1 - u) ** 2 + 3 * b * u * u * (1 - u) + u ** 3;
13
+ let u = t;
14
+ for (let i = 0; i < 8; i += 1) {
15
+ const x = bezier(u, x1, x2) - t;
16
+ const dx = 3 * x1 * (1 - u) ** 2 + 6 * (x2 - x1) * u * (1 - u) + 3 * (1 - x2) * u * u;
17
+ if (Math.abs(x) < 1e-6 || dx === 0)
18
+ break;
19
+ u = Math.max(0, Math.min(1, u - x / dx));
20
+ }
21
+ return bezier(u, y1, y2);
22
+ }
23
+ /** The step of an animated move from `from` to `to`: over `duration` milliseconds (or the options), ease-out by
24
+ * default, the bearing turning the shortest way round */
25
+ export function easeTo(engine, from, to, options = 600) {
26
+ const { duration = 600, easing = (t) => 1 - (1 - t) ** 3 } = typeof options === 'number' ? { duration: options } : options;
27
+ // Shortest way round
28
+ const turn = ((to.bearing - from.bearing + 540) % 360) - 180;
29
+ const start = performance.now();
30
+ return (now) => {
31
+ if (now - start >= duration)
32
+ engine().clearPreload();
33
+ const t = duration > 0 ? Math.min(1, (now - start) / duration) : 1;
34
+ const k = easing(t);
35
+ const mix = (a, b) => a + (b - a) * k;
36
+ engine().setCamera(mix(from.center[0], to.center[0]), mix(from.center[1], to.center[1]), mix(from.zoom, to.zoom), mix(from.pitch, to.pitch), from.bearing + turn * k);
37
+ return t < 1;
38
+ };
39
+ }
40
+ /**
41
+ * The step of a flight from `from` to `to` that zooms out on its way and back in (van Wijk and Nuij's optimal path, as
42
+ * MapLibre's `flyTo`): long moves stay readable. Pitch and bearing follow the progress. `viewport`: the larger side of
43
+ * the canvas, CSS pixels.
44
+ */
45
+ export function flyTo(engine, from, to, viewport, options = {}) {
46
+ const { curve: rho = 1.42, speed = 1.2, easing = defaultEasing } = options;
47
+ const [x0, y0] = toMercator(from.center);
48
+ const [x1, y1] = toMercator(to.center);
49
+ // Across the antimeridian, the short way
50
+ const dx = x1 - x0 - Math.round(x1 - x0);
51
+ const dy = y1 - y0;
52
+ // In pixels at the start zoom (512 px world at zoom 0)
53
+ const world = 512 * 2 ** from.zoom;
54
+ const u1 = Math.hypot(dx, dy) * world;
55
+ const w0 = Math.max(viewport, 1);
56
+ const w1 = w0 / 2 ** (to.zoom - from.zoom);
57
+ const rho2 = rho * rho;
58
+ const r = (i) => {
59
+ const b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);
60
+ return Math.log(Math.sqrt(b * b + 1) - b);
61
+ };
62
+ // No move on the ground (or nearly): a plain zoom
63
+ const still = u1 < 1e-6 || !Number.isFinite(r(0)) || !Number.isFinite(r(1));
64
+ const r0 = still ? 0 : r(0);
65
+ const length = still ? Math.abs(Math.log(w1 / w0)) / rho : (r(1) - r0) / rho;
66
+ const width = (s) => still ? Math.exp((w1 < w0 ? -1 : 1) * rho * s) : Math.cosh(r0) / Math.cosh(r0 + rho * s);
67
+ const along = (s) => still ? 0 : (w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2)) / u1;
68
+ const duration = options.duration ?? (1000 * length) / speed;
69
+ const turn = ((to.bearing - from.bearing + 540) % 360) - 180;
70
+ const start = performance.now();
71
+ return (now) => {
72
+ if (now - start >= duration)
73
+ engine().clearPreload();
74
+ const t = duration > 0 ? Math.min(1, (now - start) / duration) : 1;
75
+ const k = easing(t);
76
+ const s = k * length;
77
+ const u = t >= 1 ? 1 : along(s);
78
+ const zoom = t >= 1 ? to.zoom : from.zoom + Math.log2(1 / width(s));
79
+ const [lon, lat] = fromMercator([x0 + dx * u, y0 + dy * u]);
80
+ engine().setCamera(lon, lat, zoom, from.pitch + (to.pitch - from.pitch) * k, from.bearing + turn * k);
81
+ return t < 1;
82
+ };
83
+ }
84
+ //# sourceMappingURL=animation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation.js","sourceRoot":"","sources":["../src/animation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAUpD,mEAAmE;AACnE,MAAM,UAAU,aAAa,CAAC,CAAS;IACrC,IAAI,CAAC,IAAI,CAAC,IAAI,C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CAAC;QACnE,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACpB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;QACrB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5D,MAAM,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;QACtG,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Camera animations: each is a step run every frame by the map (`GeoMap.animate`) until it returns false, setting the\n * camera of the engine in use at that frame (it may be replaced during a flight).\n */\nimport { fromMercator, toMercator } from './geo.ts';\nimport type { AnimationOptions, FlyToOptions } from './types.ts';\nimport type { Camera, Engine } from './wasm/isard.js';\n\n/** A step of an animation, at `now` (milliseconds, the frame's time): false once done */\nexport type Step = (now: number) => boolean;\n\n/** What a step needs of the engine, read at each frame */\ntype Target = () => Pick<Engine, 'setCamera' | 'clearPreload'>;\n\n/** MapLibre's default easing: cubic Bézier (0.25, 0.1, 0.25, 1) */\nexport function defaultEasing(t: number): number {\n if (t <= 0 || t >= 1) return Math.max(0, Math.min(1, t));\n // Solve x(u) = t for the curve parameter, Newton then bisection\n const [x1, y1, x2, y2] = [0.25, 0.1, 0.25, 1];\n const bezier = (u: number, a: number, b: number) => 3 * a * u * (1 - u) ** 2 + 3 * b * u * u * (1 - u) + u ** 3;\n let u = t;\n for (let i = 0; i < 8; i += 1) {\n const x = bezier(u, x1, x2) - t;\n const dx = 3 * x1 * (1 - u) ** 2 + 6 * (x2 - x1) * u * (1 - u) + 3 * (1 - x2) * u * u;\n if (Math.abs(x) < 1e-6 || dx === 0) break;\n u = Math.max(0, Math.min(1, u - x / dx));\n }\n return bezier(u, y1, y2);\n}\n\n/** The step of an animated move from `from` to `to`: over `duration` milliseconds (or the options), ease-out by\n * default, the bearing turning the shortest way round */\nexport function easeTo(engine: Target, from: Camera, to: Camera, options: number | AnimationOptions = 600): Step {\n const { duration = 600, easing = (t: number) => 1 - (1 - t) ** 3 } =\n typeof options === 'number' ? { duration: options } : options;\n // Shortest way round\n const turn = ((to.bearing - from.bearing + 540) % 360) - 180;\n const start = performance.now();\n return (now) => {\n if (now - start >= duration) engine().clearPreload();\n const t = duration > 0 ? Math.min(1, (now - start) / duration) : 1;\n const k = easing(t);\n const mix = (a: number, b: number) => a + (b - a) * k;\n engine().setCamera(\n mix(from.center[0], to.center[0]),\n mix(from.center[1], to.center[1]),\n mix(from.zoom, to.zoom),\n mix(from.pitch, to.pitch),\n from.bearing + turn * k,\n );\n return t < 1;\n };\n}\n\n/**\n * The step of a flight from `from` to `to` that zooms out on its way and back in (van Wijk and Nuij's optimal path, as\n * MapLibre's `flyTo`): long moves stay readable. Pitch and bearing follow the progress. `viewport`: the larger side of\n * the canvas, CSS pixels.\n */\nexport function flyTo(engine: Target, from: Camera, to: Camera, viewport: number, options: FlyToOptions = {}): Step {\n const { curve: rho = 1.42, speed = 1.2, easing = defaultEasing } = options;\n const [x0, y0] = toMercator(from.center);\n const [x1, y1] = toMercator(to.center);\n // Across the antimeridian, the short way\n const dx = x1 - x0 - Math.round(x1 - x0);\n const dy = y1 - y0;\n // In pixels at the start zoom (512 px world at zoom 0)\n const world = 512 * 2 ** from.zoom;\n const u1 = Math.hypot(dx, dy) * world;\n const w0 = Math.max(viewport, 1);\n const w1 = w0 / 2 ** (to.zoom - from.zoom);\n const rho2 = rho * rho;\n const r = (i: 0 | 1) => {\n const b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);\n return Math.log(Math.sqrt(b * b + 1) - b);\n };\n // No move on the ground (or nearly): a plain zoom\n const still = u1 < 1e-6 || !Number.isFinite(r(0)) || !Number.isFinite(r(1));\n const r0 = still ? 0 : r(0);\n const length = still ? Math.abs(Math.log(w1 / w0)) / rho : (r(1) - r0) / rho;\n const width = (s: number) =>\n still ? Math.exp((w1 < w0 ? -1 : 1) * rho * s) : Math.cosh(r0) / Math.cosh(r0 + rho * s);\n const along = (s: number) =>\n still ? 0 : (w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2)) / u1;\n const duration = options.duration ?? (1000 * length) / speed;\n const turn = ((to.bearing - from.bearing + 540) % 360) - 180;\n const start = performance.now();\n return (now) => {\n if (now - start >= duration) engine().clearPreload();\n const t = duration > 0 ? Math.min(1, (now - start) / duration) : 1;\n const k = easing(t);\n const s = k * length;\n const u = t >= 1 ? 1 : along(s);\n const zoom = t >= 1 ? to.zoom : from.zoom + Math.log2(1 / width(s));\n const [lon, lat] = fromMercator([x0 + dx * u, y0 + dy * u]);\n engine().setCamera(lon, lat, zoom, from.pitch + (to.pitch - from.pitch) * k, from.bearing + turn * k);\n return t < 1;\n };\n}\n"]}
@@ -1,8 +1,11 @@
1
+ import { type Job } from './resample.ts';
2
+ import { type PngEncoding } from './terrain.ts';
1
3
  import { type LabelCandidate, type RasterSource, type StyleLayer } from './vectorstyle.ts';
2
4
  export type { LabelCandidate, RasterSource };
3
5
  /** Fetch priority of a request (`fetch`'s `priority`, a hint to the browser) */
4
6
  export type Priority = 'high' | 'low' | 'auto';
5
- /** A tile's image or labels, asked of a worker */
7
+ /** A tile's image or labels, asked of a worker; or a tile of another layer decoded: the altitudes of a PNG relief
8
+ * tile, a Mercator tile reprojected from the source images of its plan (keeping `cached` of them) */
6
9
  export type BasemapWork = {
7
10
  type: 'render';
8
11
  key: string;
@@ -11,13 +14,25 @@ export type BasemapWork = {
11
14
  y: number;
12
15
  size: number;
13
16
  priority?: Priority;
14
- } | {
17
+ }
18
+ /** `zoom`: the zoom the style is evaluated at, past the source's deepest level (`z` by default) */
19
+ | {
15
20
  type: 'labels';
16
21
  key: string;
17
22
  z: number;
18
23
  x: number;
19
24
  y: number;
25
+ zoom?: number;
20
26
  priority?: Priority;
27
+ } | {
28
+ type: 'heights';
29
+ url: string;
30
+ encoding: PngEncoding;
31
+ floor?: number;
32
+ } | {
33
+ type: 'reproject';
34
+ job: Job;
35
+ cached: number;
21
36
  };
22
37
  export type BasemapRequest = {
23
38
  type: 'init';
@@ -28,8 +43,8 @@ export type BasemapRequest = {
28
43
  layers: StyleLayer[];
29
44
  /** The style's raster sources, by name, for its raster layers */
30
45
  rasters?: Record<string, RasterSource>;
31
- /** The style's sprite, for the fill patterns (loaded once by the page) */
32
- sprite?: Sprite;
46
+ /** The style's sprites, for the fill patterns (loaded once by the page) */
47
+ sprites?: Sprite[];
33
48
  /** Workers of the pool: each keeps its share of the decoded tiles */
34
49
  workers?: number;
35
50
  } | (BasemapWork & {
@@ -55,7 +70,11 @@ export type BasemapResponse = {
55
70
  } | {
56
71
  id: number;
57
72
  labels: LabelCandidate[];
73
+ } | {
74
+ id: number;
75
+ heights: Float32Array;
58
76
  };
77
+ /** A sprite of the style: its images by name (`id:name` but in the default sprite) and its sheet */
59
78
  export interface Sprite {
60
79
  image: ImageBitmap;
61
80
  icons: Record<string, {
@@ -74,3 +93,6 @@ export declare function cacheShare(workers: number): number;
74
93
  * there; another one is read back unpremultiplied, copied
75
94
  */
76
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[][];
@@ -1,4 +1,4 @@
1
- class Q{buf;end;pos;constructor(e,n=0,r=e.length){this.buf=e;this.end=r;this.pos=n}varint(){let e=0;for(let n=0;n<70;n+=7){let r=this.buf[this.pos++]??0;if(e+=(r&127)*2**n,r<128)break}return e}int64(){let e=0,n=0;for(let r=0;r<10;r+=1){let i=this.buf[this.pos++]??0,t=i&127;if(r<4)e|=t<<7*r;else if(r===4)e|=(t&15)<<28,n|=t>>4;else n|=t<<7*r-32;if(i<128)break}return(n|0)*4294967296+(e>>>0)}sint(){let e=this.varint();return e%2===1?-(e+1)/2:e/2}sub(){let e=this.varint(),n=Math.min(this.pos+e,this.end),r=new Q(this.buf,this.pos,n);return this.pos=n,r}string(){let e=this.varint(),n=Math.min(this.pos+e,this.end),r=Ae.decode(this.buf.subarray(this.pos,n));return this.pos=n,r}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 Ae=new TextDecoder;function Ce(e){let n="";while(e.more){let r=e.varint();switch(r>>3){case 1:n=e.string();break;case 2:n=e.float();break;case 3:n=e.double();break;case 4:n=e.int64();break;case 5:n=e.varint();break;case 6:n=e.sint();break;case 7:n=e.varint()!==0;break;default:e.skip(r&7)}}return n}function Ne(e){let n=[],r,[i,t]=[0,0];while(e.more){let s=e.varint(),u=s&7,o=s>>3;if(u===7){if(r&&r.length>=2)r.push(r[0]??0,r[1]??0);continue}for(let a=0;a<o&&e.more;a+=1){if(i+=e.sint(),t+=e.sint(),u===1)r=[],n.push(r);r?.push(i,t)}}return n}function ie(e,n){let r=new Map,i=new Q(e);while(i.more){let t=i.varint();if(t>>3!==3){i.skip(t&7);continue}let s=i.sub(),u="",o=4096,a=[],c=[],x=[];while(s.more){let g=s.varint();switch(g>>3){case 1:u=s.string();break;case 2:x.push(s.sub());break;case 3:a.push(s.string());break;case 4:c.push(Ce(s.sub()));break;case 5:o=s.varint();break;default:s.skip(g&7)}}if(n&&!n.has(u))continue;let f=[];for(let g of x){let h=1,v={},L=[];while(g.more){let d=g.varint();switch(d>>3){case 2:{let S=g.sub();while(S.more){let N=a[S.varint()],R=c[S.varint()];if(N!==void 0&&R!==void 0)v[N]=R}break}case 3:h=Math.min(3,Math.max(1,g.varint()));break;case 4:L=Ne(g.sub());break;default:g.skip(d&7)}}f.push({type:h,properties:v,geometry:L})}r.set(u,{extent:o,features:f})}return r}var Re="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",E;function Le(e){if(!E){E=new Map;let n=Re.split(" ");for(let r=0;r+1<n.length;r+=2)E.set(n[r],n[r+1])}return E.get(e)}var W=(e)=>Number.isFinite(e)?Math.max(0,Math.min(1,e)):0;function oe(e){if(!/^[0-9a-f]+$/.test(e)||![3,4,6,8].includes(e.length))return;let n=e.length<=4?[...e].map((i)=>i+i).join(""):e,r=(i)=>Number.parseInt(n.slice(i,i+2),16)/255;return[r(0),r(2),r(4),n.length===8?r(6):1]}function Je(e){if(e===void 0)return 1;return W(e.endsWith("%")?Number.parseFloat(e)/100:Number.parseFloat(e))}function Pe(e,n,r){let i=r<0.5?r*(1+n):r+n-r*n,t=2*r-i,s=(u)=>{let o=(u%1+1)%1;if(o<0.16666666666666666)return t+(i-t)*6*o;if(o<0.5)return i;if(o<0.6666666666666666)return t+(i-t)*(0.6666666666666666-o)*6;return t};return[s(e+0.3333333333333333),s(e),s(e-0.3333333333333333)]}function se(e){if(typeof e!=="string")return;let n=e.trim().toLowerCase();if(n.startsWith("#"))return oe(n.slice(1));if(n==="transparent")return[0,0,0,0];let r=Le(n);if(r)return oe(r);let i=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(n);if(!i?.[1]||i[2]===void 0)return;let t=i[2].split(/[\s,/]+/).filter(Boolean);if(t.length<3||t.slice(0,3).some((x)=>Number.isNaN(Number.parseFloat(x))))return;let s=Je(t[3]);if(i[1].startsWith("rgb")){let x=(f)=>W(f.endsWith("%")?Number.parseFloat(f)/100:Number.parseFloat(f)/255);return[x(t[0]),x(t[1]),x(t[2]),s]}let u=Number.parseFloat(t[0])/360,[o,a,c]=Pe(u,W(Number.parseFloat(t[1])/100),W(Number.parseFloat(t[2])/100));return[o,a,c,s]}var Fe=["Unknown","Point","LineString","Polygon"];function X(e,n){return{zoom:n,properties:e.properties,type:Fe[e.type]??"Unknown"}}function B(e){return se(e)}function j([e,n,r,i]){return`rgba(${Math.round(e*255)},${Math.round(n*255)},${Math.round(r*255)},${i})`}function le(e,n,r,i=1){let t=r-n;if(t===0)return 0;let s=e-n;return i===1?s/t:(i**s-1)/(i**t-1)}function Z(e,n,r){if(typeof e==="number"&&typeof n==="number")return e+(n-e)*r;let i=B(e),t=B(n);if(i&&t)return j([0,1,2,3].map((s)=>(i[s]??0)+((t[s]??0)-(i[s]??0))*r));if(Array.isArray(e)&&Array.isArray(n))return e.map((s,u)=>Z(s,n[u],r));return r<0.5?e:n}function ce(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.stops)}function ze(e,n){let r=e.property===void 0?n.zoom:n.properties[e.property],i=e.stops,t=e.type??(e.property===void 0||typeof i[0]?.[0]==="number"?"exponential":"categorical");if(t==="identity")return r??e.default;if(t==="categorical")return i.find(([o])=>o===r)?.[1]??e.default;if(typeof r!=="number"||!i.length)return e.default??i[0]?.[1];let s=(o)=>typeof o[0]==="object"&&o[0]!==null?Number(o[0].zoom):Number(o[0]),u=i[0];if(!u)return e.default;if(r<=s(u))return u[1];for(let o=1;o<i.length;o+=1){let[a,c]=[i[o-1],i[o]];if(!a||!c)continue;if(r<s(c)){if(t==="interval")return a[1];return Z(a[1],c[1],le(r,s(a),s(c),e.base??1))}}return i.at(-1)?.[1]}function V(e,n){if(n==="$type")return e.type;return typeof n==="string"?e.properties[n]:void 0}var Te=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 ee(e){return Array.isArray(e)&&typeof e[0]==="string"&&Te.has(e[0])}var ae=new Set,O=(e)=>e===void 0||e===null?"":String(e);function J(e,n){if(ce(e))return ze(e,n);if(!Array.isArray(e))return e;let[r,...i]=e;if(typeof r!=="string")return e;let t=(o)=>J(i[o]??null,n),s=(o)=>Number(t(o)),u=()=>i.map((o,a)=>s(a));switch(r){case"literal":return i[0];case"zoom":return n.zoom;case"get":return V(n,t(0));case"has":return V(n,t(0))!==void 0;case"!has":return V(n,t(0))===void 0;case"properties":return n.properties;case"id":return null;case"geometry-type":return n.type;case"concat":return i.map((o,a)=>O(t(a))).join("");case"format":return i.map((o,a)=>o!==null&&typeof o==="object"&&!Array.isArray(o)?"":O(t(a))).join("");case"image":return t(0);case"number-format":{let o=i[1]??{},a=s(0);if(!Number.isFinite(a))return"";return a.toLocaleString(o.locale,{minimumFractionDigits:o["min-fraction-digits"],maximumFractionDigits:o["max-fraction-digits"]})}case"to-number":{for(let o=0;o<i.length;o+=1){let a=t(o),c=typeof a==="string"&&a.trim()===""?Number.NaN:Number(a);if(a!==null&&a!==void 0&&!Number.isNaN(c))return c}return 0}case"to-string":return O(t(0));case"to-boolean":{let o=t(0);return!(o===""||o===0||o===!1||o===null||o===void 0||Number.isNaN(o))}case"to-color":case"number":case"string":case"boolean":{let o={"to-color":(a)=>B(a)!==void 0,number:(a)=>typeof a==="number",string:(a)=>typeof a==="string",boolean:(a)=>typeof a==="boolean"};for(let a=0;a<i.length;a+=1){let c=t(a);if(o[r]?.(c))return c}return i.length?t(i.length-1):null}case"typeof":{let o=t(0);if(o===null||o===void 0)return"null";return Array.isArray(o)?"array":typeof o}case"length":{let o=t(0);return typeof o==="string"||Array.isArray(o)?o.length:0}case"at":{let o=t(1);return Array.isArray(o)?o[s(0)]??null:null}case"upcase":return O(t(0)).toUpperCase();case"downcase":return O(t(0)).toLowerCase();case"coalesce":for(let o=0;o<i.length;o+=1){let a=t(o);if(a!==void 0&&a!==null)return a}return null;case"!":return!t(0);case"all":return i.every((o,a)=>Boolean(t(a)));case"any":return i.some((o,a)=>Boolean(t(a)));case"==":return t(0)===t(1);case"!=":return t(0)!==t(1);case"<":return t(0)<t(1);case"<=":return t(0)<=t(1);case">":return t(0)>t(1);case">=":return t(0)>=t(1);case"in":{let o=t(1),a=t(0);if(typeof o==="string")return o.includes(String(a));return Array.isArray(o)&&o.includes(a)}case"case":{for(let o=0;o+1<i.length;o+=2)if(t(o))return t(o+1);return t(i.length-1)}case"match":{let o=t(0);for(let a=1;a+1<i.length;a+=2){let c=i[a];if(Array.isArray(c)?c.includes(o):c===o)return t(a+1)}return t(i.length-1)}case"step":{let o=s(0),a=t(1);for(let c=2;c+1<i.length;c+=2)if(o>=Number(i[c]))a=t(c+1);else break;return a}case"interpolate":case"interpolate-hcl":case"interpolate-lab":{let o=i[0],a=s(1),c=Array.isArray(o)&&o[0]==="exponential"?Number(o[1]):1,x=[];for(let g=2;g+1<i.length;g+=2)x.push([Number(i[g]),i[g+1]??null]);let f=x[0];if(!f)return null;if(a<=f[0])return J(f[1],n);for(let g=1;g<x.length;g+=1){let[h,v]=[x[g-1],x[g]];if(h&&v&&a<v[0])return Z(J(h[1],n),J(v[1],n),le(a,h[0],v[0],c))}return J(x.at(-1)?.[1]??null,n)}case"rgb":case"rgba":return j([s(0)/255,s(1)/255,s(2)/255,i.length>3?s(3):1]);case"+":return u().reduce((o,a)=>o+a,0);case"*":return u().reduce((o,a)=>o*a,1);case"-":return i.length===1?-s(0):s(0)-s(1);case"/":return s(0)/s(1);case"%":return s(0)%s(1);case"^":return s(0)**s(1);case"min":return Math.min(...u());case"max":return Math.max(...u());case"abs":return Math.abs(s(0));case"round":return Math.sign(s(0))*Math.round(Math.abs(s(0)));case"floor":return Math.floor(s(0));case"ceil":return Math.ceil(s(0));case"sqrt":return Math.sqrt(s(0));case"ln":return Math.log(s(0));case"log10":return Math.log10(s(0));case"log2":return Math.log2(s(0));case"pi":return Math.PI;case"e":return Math.E;default:if(!ae.has(r))ae.add(r),console.warn(`isard: the style expression "${r}" is not supported`);return null}}var Ie=new Set(["==","!=","<","<=",">",">="]);function Be(e){let[n,r,...i]=e;if(typeof n!=="string"||typeof r!=="string"||i.some(Array.isArray))return!1;if(Ie.has(n))return e.length===3;if(n==="in")return e.length!==3||!Array.isArray(e[2]);return n==="!in"||n==="has"||n==="!has"}function Oe(e,n){let[r,i,...t]=e,s=V(n,i);switch(r){case"==":return s===t[0];case"!=":return s!==t[0];case"<":return s<t[0];case"<=":return s<=t[0];case">":return s>t[0];case">=":return s>=t[0];case"in":return t.includes(s);case"!in":return!t.includes(s);case"has":return s!==void 0;case"!has":return s===void 0;default:return!0}}var ue=new WeakMap;function fe(e){if(!Array.isArray(e))return()=>Boolean(e);let n=ue.get(e);if(n)return n;let r,i=e[0];if(i==="all"||i==="any"||i==="none"){let t=e.slice(1).map(fe);if(i==="all")r=(s)=>t.every((u)=>u(s));else if(i==="any")r=(s)=>t.some((u)=>u(s));else r=(s)=>!t.some((u)=>u(s))}else if(Be(e))r=(t)=>Oe(e,t);else r=(t)=>Boolean(J(e,t));return ue.set(e,r),r}function te(e,n){if(e===void 0||e===null)return!0;return fe(e)(n)}function U(e){if(e!==void 0&&ce(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((n)=>U(n))}function me(e,n){if(e===void 0||e===null)return"";if(typeof e==="string")return e.replace(/\{([^}]+)\}/g,(i,t)=>{let s=n.properties[t];return s===void 0?"":String(s)});let r=J(e,n);if(Array.isArray(r))return r.filter((i)=>typeof i==="string").join("");return r===void 0||r===null?"":String(r)}function de(e){return/Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(e)?e:`${e} Regular`}function pe(e){let n=new Set,r=(u)=>{if(!Array.isArray(u))return;let o=(a)=>Array.isArray(a)&&a[0]==="zoom";if((u[0]==="interpolate"||u[0]==="interpolate-hcl"||u[0]==="interpolate-lab")&&o(u[2]))for(let a=3;a<u.length;a+=2)n.add(Number(u[a]));else if(u[0]==="step"&&o(u[1]))for(let a=3;a<u.length;a+=2){let c=Number(u[a]);n.add(c),n.add(c-0.01)}for(let a of u)r(a)};r(e);let i=[...n].filter(Number.isFinite);if(i.length===0)i.push(0);let[t,s]=[Math.min(...i),Math.max(...i)];for(let u=Math.ceil(t);u<=Math.floor(s);u+=1)i.push(u);return[...new Set(i)].sort((u,o)=>u-o).map((u)=>[u,Number(J(e,{zoom:u,properties:{},type:"Unknown"}))])}var _=new Map,P=new Map,be=96,ge=be;function qe(e){return Math.max(16,Math.ceil(be/Math.max(1,e)))}var ne=new Set,q=new Set,F=new Map,De=64;function Ee(e,n="auto"){let r=F.get(e);if(r)return F.delete(e),F.set(e,r),r;let i=(async()=>{let s=await fetch(e,{priority:n});if(s.status===404||s.status===204)return;if(!s.ok)throw Error(`${e}: ${s.status}`);return createImageBitmap(await s.blob())})();i.catch(()=>F.delete(e)),F.set(e,i);while(F.size>De){let[t,s]=F.entries().next().value??[];if(t===void 0||s===void 0)break;F.delete(t),s.then((u)=>setTimeout(()=>u?.close(),0),()=>{return})}return i}function he(e,n="auto"){let r=P.get(e);if(r)return P.delete(e),P.set(e,r),r;let i=(async()=>{for(let t=0;;t+=1){let u=await fetch(e,{priority:n});if(u.status===404||u.status===204)return;if(u.ok)return ie(new Uint8Array(await u.arrayBuffer()));if(t>=2)throw Error(`${e}: ${u.status}`);await new Promise((o)=>setTimeout(o,400*(t+1)))}})();i.catch(()=>P.delete(e)),P.set(e,i);while(P.size>ge){let t=P.keys().next().value;if(t===void 0)break;P.delete(t)}return i}function We(e,n,r,i){let t=Math.max(0,Math.min(n-1,e.maxzoom)),s=n-t,u=2**Math.max(0,s),[o,a]=s>=0?[Math.floor(r/u),Math.floor(i/u)]:[r,i],c=e.tiles.replace("{z}",String(t)).replace("{x}",String(o)).replace("{y}",String(a)),x=1/u;return{url:c,vz:t,vx:o,vy:a,part:x,ox:r%u*x,oy:i%u*x}}var A=(e,n,r,i,t)=>{let s=e[n]?.[r];if(s===void 0)return t;let u=Array.isArray(s)&&!ee(s)?s:J(s,i);return u===void 0||u===null?t:u};function z(e,n){let r=B(e)??[0,0,0,1];return j([r[0],r[1],r[2],r[3]*n])}function ye(e,n){if(e.layout?.visibility==="none")return!1;return n>=(e.minzoom??0)&&n<(e.maxzoom??24)}function $e(e,n){if(e.patterns.has(n))return e.patterns.get(n);let r=e.sprite?.icons[n],i;if(e.sprite&&r&&r.width>0&&r.height>0)i=new OffscreenCanvas(r.width,r.height),i.getContext("2d")?.drawImage(e.sprite.image,r.x,r.y,r.width,r.height,0,0,r.width,r.height);return e.patterns.set(n,i),i}var re=new Map;function Ve(e){let n=re.get(e)?.pop()??new OffscreenCanvas(e,e),r=n.getContext("2d",{willReadFrequently:!0});if(!r)throw Error("no 2D context");return r.setTransform(1,0,0,1,0,0),r.globalAlpha=1,r.setLineDash([]),r.clearRect(0,0,e,e),{canvas:n,g:r}}function je(e){let n=re.get(e.width)??[];if(re.set(e.width,n),n.length<4)n.push(e)}function Ue(e,n,r){if(r)return Promise.resolve(e.transferToImageBitmap());return createImageBitmap(n.getImageData(0,0,e.width,e.height),{premultiplyAlpha:"none"})}async function _e(e,n,r,i,t,s,u){let o=We(e,n,r,i),a=await he(o.url,u);if(q.has(s))return;let{canvas:c,g:x}=Ve(t);try{return await He(e,o,a,c,x,n,r,i,t,s,u)}finally{je(c)}}async function He(e,n,r,i,t,s,u,o,a,c,x){let f=e.sprite,g=Math.max(0,s-1),h=a/256,v=!1,L=!1;for(let d of e.layers){if(!ye(d,g))continue;let S={zoom:g,properties:{},type:"Unknown"};if(d.type==="background"){let b=A(d,"paint","background-color",S,"#000"),l=Number(A(d,"paint","background-opacity",S,1));if(t.fillStyle=z(b,l),t.fillRect(0,0,a,a),(B(b)??[0,0,0,1])[3]*l>=1)L=!0;v=!0;continue}if(d.type==="raster"){let b=d.source===void 0?void 0:e.rasters[d.source];if(!b)continue;let l=Math.max(0,Math.min(s-(b.tileSize>=512?1:0),b.maxzoom)),m=2**(s-l),p=b.tiles.replace("{z}",String(l)).replace("{x}",String(Math.floor(u/m))).replace("{y}",String(Math.floor(o/m))),w=await Ee(p,x).catch(()=>{return});if(q.has(c))return;if(!w)continue;let[k,M]=[w.width/m,w.height/m];t.globalAlpha=Number(A(d,"paint","raster-opacity",S,1)),t.drawImage(w,u%m*k,o%m*M,k,M,0,0,a,a),t.globalAlpha=1,v=!0;continue}let N=r?.get(d["source-layer"]??"");if(!N)continue;let R=a/(N.extent*n.part),[D,T]=[n.ox*N.extent,n.oy*N.extent],I=(b,l)=>{t.beginPath();for(let m of b.geometry){for(let p=0;p+1<m.length;p+=2){let[w,k]=[((m[p]??0)-D)*R,((m[p+1]??0)-T)*R];if(p===0)t.moveTo(w,k);else t.lineTo(w,k)}if(l)t.closePath()}},C=new Map,y=(b,l,m,p)=>{let w=C.get(l);if(w===void 0)w=U(d[b]?.[l]),C.set(l,w);return A(d,b,l,w?m:S,p)};for(let b of N.features){let l=X(b,g);if(!te(d.filter,l))continue;if(d.type==="fill-extrusion"&&b.type===3)I(b,!0),t.fillStyle=z(y("paint","fill-extrusion-color",l,"#000"),Number(y("paint","fill-extrusion-opacity",l,1))),t.fill("evenodd"),v=!0;else if(d.type==="fill"&&b.type===3){let m=Number(y("paint","fill-opacity",l,1)),p=y("paint","fill-pattern",l,void 0);I(b,!0);let w=typeof p==="string"?f?.icons[p]:void 0,k=w&&$e(e,p);if(w&&k){let M=t.createPattern(k,"repeat");if(M)M.setTransform(new DOMMatrix().scale(h/(w.pixelRatio??1))),t.globalAlpha=m,t.fillStyle=M,t.fill("evenodd"),t.globalAlpha=1}else{t.fillStyle=z(y("paint","fill-color",l,"#000"),m),t.fill("evenodd");let M=y("paint","fill-outline-color",l,void 0);if(M!==void 0)t.strokeStyle=z(M,m),t.lineWidth=h,t.setLineDash([]),t.stroke()}v=!0}else if(d.type==="line"&&b.type!==1){let m=Number(y("paint","line-width",l,1));if(m<=0)continue;let p=Number(y("paint","line-gap-width",l,0));t.strokeStyle=z(y("paint","line-color",l,"#000"),Number(y("paint","line-opacity",l,1))),t.lineWidth=(p>0?p+2*m:m)*h,t.lineCap=String(y("layout","line-cap",l,"butt")),t.lineJoin=String(y("layout","line-join",l,"miter"));let w=y("paint","line-dasharray",l,void 0);t.setLineDash(Array.isArray(w)?w.map((k)=>Number(k)*m*h):[]),I(b,b.type===3),t.stroke(),v=!0}else if(d.type==="circle"&&b.type===1){let m=Number(y("paint","circle-radius",l,5))*h;t.fillStyle=z(y("paint","circle-color",l,"#000"),Number(y("paint","circle-opacity",l,1)));let p=Number(y("paint","circle-stroke-width",l,0))*h;t.strokeStyle=z(y("paint","circle-stroke-color",l,"#000"),Number(y("paint","circle-stroke-opacity",l,1))),t.lineWidth=p;for(let w of b.geometry)for(let k=0;k+1<w.length;k+=2)if(t.beginPath(),t.arc(((w[k]??0)-D)*R,((w[k+1]??0)-T)*R,m,0,2*Math.PI),t.fill(),p>0)t.stroke();v=!0}}}if(!v&&!r)return null;return Ue(i,t,L)}function Ge(e){let{layout:n={},paint:r={}}=e;return n["icon-image"]!==void 0&&r["text-halo-width"]===void 0&&r["text-halo-color"]===void 0&&n["text-offset"]===void 0&&(n["text-anchor"]??"center")==="center"}function H(e,n,r,i,t,s){let u=2**e,o=(n+t/i)/u,a=(r+s/i)/u;return[o*360-180,Math.atan(Math.sinh(Math.PI*(1-2*a)))*180/Math.PI]}async function Ye(e,n,r,i,t,s){let u=e.tiles.replace("{z}",String(n)).replace("{x}",String(r)).replace("{y}",String(i)),o=await he(u,s);if(!o||q.has(t))return[];let a=[],c=new Map,x=(f)=>{let g=c.get(f);if(g===void 0){let h=f.layout?.["text-size"]??16;g=ee(h)?pe(h):h,c.set(f,g)}return g};return e.layers.forEach((f,g)=>{if(f.type!=="symbol"||!ye(f,n)||f.layout?.["text-field"]===void 0)return;if(Ge(f))return;let h=o.get(f["source-layer"]??"");if(!h)return;let v=f.layout?.["symbol-placement"]==="line"?"line":"point";for(let L of h.features){let d=X(L,n);if(!te(f.filter,d))continue;let S=me(f.layout?.["text-field"],d).trim();if(!S)continue;let N=A(f,"layout","text-transform",d,"none");if(N==="uppercase")S=S.toUpperCase();else if(N==="lowercase")S=S.toLowerCase();let R=A(f,"layout","text-font",d,["Noto Sans Regular"]),D=de(Array.isArray(R)&&typeof R[0]==="string"?R[0]:"Noto Sans Regular"),T=A(f,"layout","text-offset",d,[0,0]),I={layer:g,text:S,font:D,size:U(f.layout?.["text-size"])?Number(A(f,"layout","text-size",d,16)):x(f),color:String(A(f,"paint","text-color",d,"#000")),haloColor:String(A(f,"paint","text-halo-color",d,"rgba(0,0,0,0)")),haloWidth:Number(A(f,"paint","text-halo-width",d,0)),anchor:String(A(f,"layout","text-anchor",d,"center")),offset:Array.isArray(T)?[Number(T[0]??0),Number(T[1]??0)]:[0,0],maxWidth:Number(A(f,"layout","text-max-width",d,10)),lineHeight:Number(A(f,"layout","text-line-height",d,1.2)),overlap:Boolean(A(f,"layout","text-allow-overlap",d,!1))};if(L.type===1)for(let C of L.geometry)for(let y=0;y+1<C.length;y+=2){let[b,l]=[C[y]??0,C[y+1]??0];if(b<0||l<0||b>=h.extent||l>=h.extent)continue;let[m,p]=H(n,r,i,h.extent,b,l);a.push({...I,lon:m,lat:p})}else{let C,y=0;for(let l of L.geometry){let m=0;for(let p=2;p+1<l.length;p+=2)m+=Math.hypot((l[p]??0)-(l[p-2]??0),(l[p+1]??0)-(l[p-1]??0));if(m>y)y=m,C=l}if(!C||y<h.extent/32)continue;let b=y/2;for(let l=2;l+1<C.length;l+=2){let[m,p,w,k]=[C[l-2]??0,C[l-1]??0,C[l]??0,C[l+1]??0],M=Math.hypot(w-m,k-p);if(M>=b&&M>0){let[Y,K]=[m+(w-m)*b/M,p+(k-p)*b/M];if(Y<0||K<0||Y>=h.extent||K>=h.extent)break;let[we,xe]=H(n,r,i,h.extent,Y,K),[ke,ve]=H(n,r,i,h.extent,w,k),[Se,Me]=H(n,r,i,h.extent,m,p);a.push({...I,lon:we,lat:xe,...v==="line"?{along:[ke-Se,ve-Me]}:{}});break}b-=M}}}}),a}var G=(e,n=[])=>self.postMessage(e,n);self.onmessage=async({data:e})=>{if(e.type==="init"){if(e.workers!==void 0)ge=qe(e.workers);_.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"){_.get(e.key)?.sprite?.image.close(),_.delete(e.key);return}if(e.type==="abort"){if(ne.has(e.id))q.add(e.id);return}ne.add(e.id);let n=_.get(e.key);try{if(!n)throw Error(`no renderer ${e.key}`);if(e.type==="render"){let r=await _e(n,e.z,e.x,e.y,e.size,e.id,e.priority);if(r)G({id:e.id,image:r},[r]);else G({id:e.id,missing:!0})}else G({id:e.id,labels:await Ye(n,e.z,e.x,e.y,e.id,e.priority)})}catch(r){G({id:e.id,error:String(r)})}finally{ne.delete(e.id),q.delete(e.id)}};export{qe as cacheShare,Ue 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=01D6BC7A49684B7264756E2164756E21
3
+ //# debugId=387083002A9A758864756E2164756E21
4
4
  //# sourceMappingURL=basemap.worker.js.map