isard 1.1.0 → 1.3.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 (254) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +44 -39
  3. package/dist/basemap/basemaps.d.ts +1 -1
  4. package/dist/basemap/basemaps.js +2 -2
  5. package/dist/basemap/basemaps.js.map +1 -1
  6. package/dist/basemap/grid.d.ts +5 -5
  7. package/dist/basemap/grid.js +59 -65
  8. package/dist/basemap/grid.js.map +1 -1
  9. package/dist/basemap/mvt.d.ts +1 -1
  10. package/dist/basemap/mvt.js +6 -6
  11. package/dist/basemap/mvt.js.map +1 -1
  12. package/dist/basemap/pmtiles.d.ts +10 -10
  13. package/dist/basemap/pmtiles.js +39 -31
  14. package/dist/basemap/pmtiles.js.map +1 -1
  15. package/dist/basemap/pmtileslayer.d.ts +33 -0
  16. package/dist/basemap/pmtileslayer.js +97 -0
  17. package/dist/basemap/pmtileslayer.js.map +1 -0
  18. package/dist/basemap/resample.d.ts +2 -2
  19. package/dist/basemap/resample.js +16 -14
  20. package/dist/basemap/resample.js.map +1 -1
  21. package/dist/basemap/terrain.d.ts +3 -3
  22. package/dist/basemap/terrain.js +6 -6
  23. package/dist/basemap/terrain.js.map +1 -1
  24. package/dist/basemap/trees.d.ts +26 -0
  25. package/dist/basemap/trees.js +141 -0
  26. package/dist/basemap/trees.js.map +1 -0
  27. package/dist/basemap/vectorstyle.d.ts +22 -10
  28. package/dist/basemap/vectorstyle.js +163 -110
  29. package/dist/basemap/vectorstyle.js.map +1 -1
  30. package/dist/basemap/vectortiles.d.ts +70 -47
  31. package/dist/basemap/vectortiles.js +480 -358
  32. package/dist/basemap/vectortiles.js.map +1 -1
  33. package/dist/basemap/wmts.d.ts +3 -3
  34. package/dist/basemap/wmts.js +16 -11
  35. package/dist/basemap/wmts.js.map +1 -1
  36. package/dist/basemap/workerpool.d.ts +17 -0
  37. package/dist/basemap/workerpool.js +194 -0
  38. package/dist/basemap/workerpool.js.map +1 -0
  39. package/dist/basemap.worker.js +2 -2
  40. package/dist/basemap.worker.js.map +21 -13
  41. package/dist/bind/layers.d.ts +13 -4
  42. package/dist/bind/layers.js +64 -40
  43. package/dist/bind/layers.js.map +1 -1
  44. package/dist/data/crs.d.ts +10 -10
  45. package/dist/data/crs.js +38 -34
  46. package/dist/data/crs.js.map +1 -1
  47. package/dist/data/gpx.d.ts +1 -1
  48. package/dist/data/gpx.js +20 -20
  49. package/dist/data/gpx.js.map +1 -1
  50. package/dist/data/kml.d.ts +1 -1
  51. package/dist/data/kml.js +42 -39
  52. package/dist/data/kml.js.map +1 -1
  53. package/dist/data/topojson.d.ts +1 -1
  54. package/dist/data/topojson.js +15 -10
  55. package/dist/data/topojson.js.map +1 -1
  56. package/dist/data/xml.d.ts +5 -5
  57. package/dist/data/xml.js +19 -18
  58. package/dist/data/xml.js.map +1 -1
  59. package/dist/decoder.worker.js +4 -4
  60. package/dist/decoder.worker.js.map +6 -6
  61. package/dist/engine/decoders.d.ts +2 -2
  62. package/dist/engine/decoders.js +28 -25
  63. package/dist/engine/decoders.js.map +1 -1
  64. package/dist/engine/loader.js +13 -14
  65. package/dist/engine/loader.js.map +1 -1
  66. package/dist/engine/requests.d.ts +1 -1
  67. package/dist/engine/requests.js +19 -16
  68. package/dist/engine/requests.js.map +1 -1
  69. package/dist/engine-loader.d.ts +13 -9
  70. package/dist/engine-loader.js +38 -28
  71. package/dist/engine-loader.js.map +1 -1
  72. package/dist/geoplateforme.d.ts +26 -10
  73. package/dist/geoplateforme.js +45 -20
  74. package/dist/geoplateforme.js.map +1 -1
  75. package/dist/index.d.ts +12 -4
  76. package/dist/index.js +9 -2
  77. package/dist/index.js.map +1 -1
  78. package/dist/isard_bg.wasm +0 -0
  79. package/dist/isard_core_bg.wasm +0 -0
  80. package/dist/isard_points_bg.wasm +0 -0
  81. package/dist/isard_tess_bg.wasm +0 -0
  82. package/dist/layers/extrusions.d.ts +1 -1
  83. package/dist/layers/extrusions.js +10 -5
  84. package/dist/layers/extrusions.js.map +1 -1
  85. package/dist/layers/features.d.ts +10 -10
  86. package/dist/layers/features.js +41 -42
  87. package/dist/layers/features.js.map +1 -1
  88. package/dist/layers/glyphs.d.ts +3 -3
  89. package/dist/layers/glyphs.js +34 -40
  90. package/dist/layers/glyphs.js.map +1 -1
  91. package/dist/layers/icons.d.ts +8 -8
  92. package/dist/layers/icons.js +76 -68
  93. package/dist/layers/icons.js.map +1 -1
  94. package/dist/layers/layers.d.ts +1 -1
  95. package/dist/layers/layers.js +42 -29
  96. package/dist/layers/layers.js.map +1 -1
  97. package/dist/layers/panoramas.d.ts +2 -2
  98. package/dist/layers/panoramas.js +52 -41
  99. package/dist/layers/panoramas.js.map +1 -1
  100. package/dist/layers/pointclouds.d.ts +3 -3
  101. package/dist/layers/pointclouds.js +25 -33
  102. package/dist/layers/pointclouds.js.map +1 -1
  103. package/dist/layers/symbols.d.ts +1 -1
  104. package/dist/layers/symbols.js +68 -71
  105. package/dist/layers/symbols.js.map +1 -1
  106. package/dist/layers/vectors.d.ts +60 -0
  107. package/dist/layers/vectors.js +130 -0
  108. package/dist/layers/vectors.js.map +1 -0
  109. package/dist/map/basemap-layers.d.ts +26 -0
  110. package/dist/map/basemap-layers.js +61 -0
  111. package/dist/map/basemap-layers.js.map +1 -0
  112. package/dist/map/canvas.d.ts +17 -0
  113. package/dist/map/canvas.js +56 -0
  114. package/dist/map/canvas.js.map +1 -0
  115. package/dist/map/checks.d.ts +11 -0
  116. package/dist/map/checks.js +39 -0
  117. package/dist/map/checks.js.map +1 -0
  118. package/dist/map/credits.d.ts +17 -0
  119. package/dist/map/credits.js +34 -0
  120. package/dist/map/credits.js.map +1 -0
  121. package/dist/map/engine-settings.d.ts +15 -0
  122. package/dist/map/engine-settings.js +45 -0
  123. package/dist/map/engine-settings.js.map +1 -0
  124. package/dist/map/engines.d.ts +41 -0
  125. package/dist/map/engines.js +77 -0
  126. package/dist/map/engines.js.map +1 -0
  127. package/dist/map/events.d.ts +14 -0
  128. package/dist/map/events.js +46 -0
  129. package/dist/map/events.js.map +1 -0
  130. package/dist/map/frame-loop.d.ts +64 -0
  131. package/dist/map/frame-loop.js +145 -0
  132. package/dist/map/frame-loop.js.map +1 -0
  133. package/dist/map/hover-pick.d.ts +30 -0
  134. package/dist/map/hover-pick.js +56 -0
  135. package/dist/map/hover-pick.js.map +1 -0
  136. package/dist/map/layer-spec.d.ts +42 -0
  137. package/dist/map/layer-spec.js +34 -0
  138. package/dist/map/layer-spec.js.map +1 -0
  139. package/dist/map/layer-stack.d.ts +36 -0
  140. package/dist/map/layer-stack.js +101 -0
  141. package/dist/map/layer-stack.js.map +1 -0
  142. package/dist/map/overlay-host.d.ts +36 -0
  143. package/dist/map/overlay-host.js +101 -0
  144. package/dist/map/overlay-host.js.map +1 -0
  145. package/dist/map/panorama-host.d.ts +5 -0
  146. package/dist/map/panorama-host.js +32 -0
  147. package/dist/map/panorama-host.js.map +1 -0
  148. package/dist/map/raster-source.d.ts +11 -0
  149. package/dist/map/raster-source.js +26 -0
  150. package/dist/map/raster-source.js.map +1 -0
  151. package/dist/map/symbol-atlases.d.ts +26 -0
  152. package/dist/map/symbol-atlases.js +59 -0
  153. package/dist/map/symbol-atlases.js.map +1 -0
  154. package/dist/map/viewshed.d.ts +5 -0
  155. package/dist/map/viewshed.js +28 -0
  156. package/dist/map/viewshed.js.map +1 -0
  157. package/dist/map/workers.d.ts +46 -0
  158. package/dist/map/workers.js +73 -0
  159. package/dist/map/workers.js.map +1 -0
  160. package/dist/map.d.ts +54 -126
  161. package/dist/map.js +227 -698
  162. package/dist/map.js.map +1 -1
  163. package/dist/react/Control.d.ts +11 -0
  164. package/dist/react/Control.js +18 -0
  165. package/dist/react/Control.js.map +1 -0
  166. package/dist/react/CustomLayer.d.ts +11 -0
  167. package/dist/react/CustomLayer.js +30 -0
  168. package/dist/react/CustomLayer.js.map +1 -0
  169. package/dist/react/IsardMap.d.ts +43 -0
  170. package/dist/react/IsardMap.js +147 -0
  171. package/dist/react/IsardMap.js.map +1 -0
  172. package/dist/react/Layer.d.ts +42 -0
  173. package/dist/react/Layer.js +74 -0
  174. package/dist/react/Layer.js.map +1 -0
  175. package/dist/react/Marker.d.ts +24 -0
  176. package/dist/react/Marker.js +53 -0
  177. package/dist/react/Marker.js.map +1 -0
  178. package/dist/react/Panel.d.ts +11 -0
  179. package/dist/react/Panel.js +37 -0
  180. package/dist/react/Panel.js.map +1 -0
  181. package/dist/react/Popup.d.ts +18 -0
  182. package/dist/react/Popup.js +60 -0
  183. package/dist/react/Popup.js.map +1 -0
  184. package/dist/react/Swipe.d.ts +16 -0
  185. package/dist/react/Swipe.js +52 -0
  186. package/dist/react/Swipe.js.map +1 -0
  187. package/dist/react/VectorGeometry.d.ts +35 -0
  188. package/dist/react/VectorGeometry.js +82 -0
  189. package/dist/react/VectorGeometry.js.map +1 -0
  190. package/dist/react/Viewshed.d.ts +5 -0
  191. package/dist/react/Viewshed.js +28 -0
  192. package/dist/react/Viewshed.js.map +1 -0
  193. package/dist/react/context.d.ts +33 -0
  194. package/dist/react/context.js +20 -0
  195. package/dist/react/context.js.map +1 -0
  196. package/dist/react/index.d.ts +16 -108
  197. package/dist/react/index.js +11 -397
  198. package/dist/react/index.js.map +1 -1
  199. package/dist/settings.d.ts +5 -9
  200. package/dist/settings.js +17 -15
  201. package/dist/settings.js.map +1 -1
  202. package/dist/types.d.ts +27 -4
  203. package/dist/types.js.map +1 -1
  204. package/dist/ui/controls.js +6 -4
  205. package/dist/ui/controls.js.map +1 -1
  206. package/dist/ui/interaction.d.ts +2 -2
  207. package/dist/ui/interaction.js +8 -7
  208. package/dist/ui/interaction.js.map +1 -1
  209. package/dist/ui/minimap.d.ts +25 -0
  210. package/dist/ui/minimap.js +90 -0
  211. package/dist/ui/minimap.js.map +1 -0
  212. package/dist/ui/overlay.js +18 -20
  213. package/dist/ui/overlay.js.map +1 -1
  214. package/dist/ui/scale.d.ts +19 -0
  215. package/dist/ui/scale.js +44 -0
  216. package/dist/ui/scale.js.map +1 -0
  217. package/dist/ui/search.d.ts +25 -0
  218. package/dist/ui/search.js +119 -0
  219. package/dist/ui/search.js.map +1 -0
  220. package/dist/ui/style.d.ts +1 -1
  221. package/dist/ui/style.js +19 -2
  222. package/dist/ui/style.js.map +1 -1
  223. package/dist/util/animation.d.ts +3 -3
  224. package/dist/util/animation.js +6 -6
  225. package/dist/util/animation.js.map +1 -1
  226. package/dist/util/color.d.ts +1 -1
  227. package/dist/util/color.js +14 -16
  228. package/dist/util/color.js.map +1 -1
  229. package/dist/util/geo.d.ts +6 -6
  230. package/dist/util/geo.js +12 -12
  231. package/dist/util/geo.js.map +1 -1
  232. package/dist/util/guards.d.ts +7 -0
  233. package/dist/util/guards.js +8 -0
  234. package/dist/util/guards.js.map +1 -0
  235. package/dist/util/lru.js.map +1 -1
  236. package/dist/util/sun.d.ts +11 -0
  237. package/dist/util/sun.js +26 -0
  238. package/dist/util/sun.js.map +1 -0
  239. package/dist/wasm/isard.d.ts +250 -7
  240. package/dist/wasm/isard.js +375 -8
  241. package/dist/wasm/isard_core.d.ts +226 -7
  242. package/dist/wasm/isard_core.js +351 -8
  243. package/dist/wasm/isard_tess.d.ts +109 -0
  244. package/dist/wasm/isard_tess.js +398 -0
  245. package/dist/workers/basemap/geometry.d.ts +72 -0
  246. package/dist/workers/basemap/labels.d.ts +8 -0
  247. package/dist/workers/basemap/raster.d.ts +10 -0
  248. package/dist/workers/basemap/tiles.d.ts +65 -0
  249. package/dist/workers/basemap/trees.d.ts +19 -0
  250. package/dist/workers/basemap.worker.d.ts +126 -22
  251. package/dist/workers/basemap.worker.js +76 -544
  252. package/dist/workers/basemap.worker.js.map +1 -1
  253. package/package.json +5 -4
  254. package/vite.js +10 -2
@@ -1 +1 @@
1
- {"version":3,"file":"vectortiles.js","sourceRoot":"","sources":["../../src/basemap/vectortiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW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,KAAgC,CAAC,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IACpH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Vector basemaps from a MapLibre style (OpenFreeMap's Positron by default): the fills, lines, circles and raster\n * layers drawn tile by tile in workers into the raster pool, so that they lie on the relief like any basemap and\n * composite with the hillshade in one pass; and the labels of the style's symbol layers in a symbol layer of their own,\n * kept above the application's layers (as MapLibre's `beforeId: firstSymbol` does), listed by the workers, shaped in\n * the page once per vector tile, placed by the engine.\n *\n * Any subset of the style can be drawn on its own raster layer (`raster({ layers })`), at its own place in the stack:\n * rivers from the basemap's data over a flood layer, for instance, restyled with `extraLayers`.\n */\n\nimport { headerRules, onHeaderRules, withHeaders } from '../engine/requests.ts';\nimport { assetUrl } from '../engine-loader.ts';\nimport { IGN_ATTRIBUTION } from '../geoplateforme.ts';\nimport type { Feature, Size } from '../layers/features.ts';\nimport { type LoadedSprite, loadSprites, readPixels } from '../layers/icons.ts';\nimport type { Layer, RasterLayer } from '../layers/layers.ts';\nimport type { SymbolLayer } from '../layers/symbols.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { RasterOptions } from '../types.ts';\nimport type { Anchor } from '../ui/overlay.ts';\nimport { mercatorX, mercatorY } from '../util/geo.ts';\nimport { Lru } from '../util/lru.ts';\nimport type { Camera } from '../wasm/isard.js';\nimport type { BasemapRequest, BasemapResponse, BasemapWork, Priority, Sprite } from '../workers/basemap.worker.ts';\nimport { OPENFREEMAP_ATTRIBUTION } from './basemaps.ts';\nimport { pmtiles, pmtilesUrl } from './pmtiles.ts';\nimport { type Job, SOURCE_CACHE } from './resample.ts';\nimport type { PngEncoding } from './terrain.ts';\nimport {\n type Json,\n type LabelCandidate,\n labelFont,\n type RasterSource,\n type Style,\n type StyleLayer,\n} from './vectorstyle.ts';\n\n/** OpenFreeMap's styles: OpenStreetMap data in the OpenMapTiles schema, worldwide, free and without a key */\nexport const OPENFREEMAP_STYLES = {\n positron: 'https://tiles.openfreemap.org/styles/positron',\n liberty: 'https://tiles.openfreemap.org/styles/liberty',\n bright: 'https://tiles.openfreemap.org/styles/bright',\n} as const;\n\n/** PLAN.IGN vector styles of the Géoplateforme (France) */\nexport const PLAN_STYLES = {\n standard: 'https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/standard.json',\n grey: 'https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/gris.json',\n} as const;\n\n/** Vector basemaps by name (see `BasemapName`) */\nexport const VECTOR_BASEMAPS = {\n 'osm-positron': OPENFREEMAP_STYLES.positron,\n 'osm-liberty': OPENFREEMAP_STYLES.liberty,\n 'osm-bright': OPENFREEMAP_STYLES.bright,\n 'ign-plan-vector': PLAN_STYLES.standard,\n 'ign-plan-grey-vector': PLAN_STYLES.grey,\n} as const;\n\nexport interface VectorTilesOptions {\n /** A style URL or object (default OpenFreeMap's Positron) */\n style?: string | Style;\n /** Workers drawing the tiles (default cores - 1, 1 to 4). The vector tiles of a map share its workers (and their\n * decoded tiles); another count gives these tiles workers of their own */\n workers?: number;\n /** Where to load the worker from, when a bundler does not resolve the default URL (default the map's\n * `basemapWorkerUrl`); another URL than the map's gives these tiles workers of their own */\n workerUrl?: string | URL;\n /** Credits of the tiles, shown while its raster layers are on the map (default: OpenFreeMap's for its styles, the\n * IGN's for PLAN.IGN's) */\n attribution?: string;\n}\n\n/** The credits of a known style: OpenFreeMap's, PLAN.IGN's */\nexport function styleAttribution(style: string | Style): string | undefined {\n if (typeof style !== 'string') return undefined;\n if ((Object.values(OPENFREEMAP_STYLES) as string[]).includes(style)) return OPENFREEMAP_ATTRIBUTION;\n if ((Object.values(PLAN_STYLES) as string[]).includes(style)) return IGN_ATTRIBUTION;\n return undefined;\n}\n\n/** Text or icon size of a style (a number, legacy stops, or the stops of a zoom expression made by the worker) as a\n * size for the symbol layer */\nexport function size(value: Json, fallback = 16): Size {\n if (typeof value === 'number') return value;\n if (Array.isArray(value) && value.length > 0 && value.every(Array.isArray)) {\n return value.map((s) => [Number((s as Json[])[0]), Number((s as Json[])[1])] as [number, number]);\n }\n if (value && typeof value === 'object' && !Array.isArray(value) && Array.isArray(value.stops)) {\n return (value.stops as Json[]).map((s) => {\n const [z, v] = s as [number, number];\n return [Number(z), Number(v)] as [number, number];\n });\n }\n return fallback;\n}\n\n/** Fetches a JSON document (a style, a TileJSON) */\nasync function json<T>(url: string): Promise<T> {\n const response = await fetch(url, withHeaders(url));\n if (!response.ok) throw new Error(`${url}: ${response.status}`);\n return (await response.json()) as T;\n}\n\n/**\n * A style source's tiles and deepest level: a `pmtiles://` archive (its `url`, or a `tiles` template) read for its\n * header, its tiles then named `pmtiles://<absolute archive URL>/{z}/{x}/{y}` for the workers; other sources as they are\n */\nasync function resolveSource(source: Style['sources'][string]): Promise<{ tiles?: string[]; maxzoom?: number }> {\n const given = source.url ?? source.tiles?.[0] ?? '';\n const archive = pmtilesUrl(given.replace(/\\/\\{z\\}\\/\\{x\\}\\/\\{y\\}$/, ''));\n if (!archive)\n return {\n ...(source.tiles ? { tiles: source.tiles } : {}),\n ...(source.maxzoom === undefined ? {} : { maxzoom: source.maxzoom }),\n };\n const header = await pmtiles(archive).header();\n return { tiles: [`pmtiles://${archive}/{z}/{x}/{y}`], maxzoom: source.maxzoom ?? header.maxZoom };\n}\n\n/** Pause before the labels of tiles that failed are asked for again, when no move brings an update (ms) */\nconst RETRY_LABELS_MS = 3000;\n\n/** Default size of a basemap worker pool: cores - 1, 1 to 4 */\nexport function defaultWorkerCount(): number {\n return Math.min(4, Math.max(1, (typeof navigator !== 'undefined' ? navigator.hardwareConcurrency || 2 : 2) - 1));\n}\n\n/** Default URL of the basemap worker: in the page's assets folder (`isard/vite`), else next to the module */\nexport function defaultWorkerUrl(assetsUrl?: string | URL): string | URL {\n return assetUrl('basemap.worker.js', undefined, assetsUrl);\n}\n\n/** Fetch priority of a raster tile drawn by the workers: 'high' near the center of the view, at the current zoom or\n * coarser; 'low' far from it or finer (prefetch); 'auto' between */\nexport function tilePriority(z: number, x: number, y: number, camera: Pick<Camera, 'center' | 'zoom'>): Priority {\n // A raster tile of level z covers the map at zoom z - 1\n if (z - 1 > camera.zoom + 1) return 'low';\n const n = 2 ** z;\n const [lon, lat] = camera.center;\n const cx = mercatorX(lon) * n;\n const cy = mercatorY(lat) * n;\n // Across the antimeridian, the short way\n let dx = Math.abs(x + 0.5 - cx) % n;\n dx = Math.min(dx, n - dx);\n const d = Math.hypot(dx, y + 0.5 - cy);\n if (d <= 1.5) return 'high';\n return d >= 4 ? 'low' : 'auto';\n}\n\n/** The worker of a vector tile among `count`: always the same one */\nexport function workerIndex(vz: number, vx: number, vy: number, count: number): number {\n // Unsigned: every worker gets its share\n return ((Math.imul(vx, 73856093) ^ Math.imul(vy, 19349663) ^ vz) >>> 0) % Math.max(1, count);\n}\n\n/** The worker-side key of a renderer: unique across the `VectorTiles` sharing a pool */\nexport function rendererKey(namespace: string, n: number): string {\n return `${namespace}:r${n}`;\n}\n\n/** What the pool needs of a worker (a `Worker`, or a stand-in in tests) */\nexport type PoolWorker = Pick<Worker, 'postMessage' | 'terminate' | 'onmessage' | 'onerror' | 'onmessageerror'>;\n\n/**\n * @internal Workers drawing vector tiles, shared by the `VectorTiles` of a map: each vector tile always goes to the\n * same worker, which keeps it decoded for every style drawn from it. Requests are tracked one by one, with their\n * owner, so that one `VectorTiles` going away cancels its own requests only.\n */\nexport class BasemapWorkers {\n private readonly workers: PoolWorker[];\n private readonly pending = new Map<\n number,\n { resolve: (r: BasemapResponse) => void; reject: (e: Error) => void; worker: PoolWorker; owner: object }\n >();\n private next = 1;\n private namespaces = 0;\n private terminated = false;\n /** Stops following the page's request headers */\n private readonly unfollow: () => void;\n\n constructor(\n readonly count: number,\n readonly url: string | URL,\n create: (url: string | URL) => PoolWorker = (u) => new Worker(u, { type: 'module' }),\n ) {\n this.workers = Array.from({ length: Math.max(1, count) }, () => {\n const worker = create(url);\n worker.onmessage = ({ data }: MessageEvent<BasemapResponse>) => {\n const p = this.pending.get(data.id);\n if (!p) return;\n this.pending.delete(data.id);\n if ('error' in data) p.reject(new Error(data.error));\n else p.resolve(data);\n };\n // A worker that fails to load (a bundler serving it from elsewhere) or to read a message fails its requests\n worker.onerror = (event) => {\n event.preventDefault();\n this.fail(worker, `the vector basemap worker ${url} failed${event.message ? `: ${event.message}` : ''}`);\n };\n worker.onmessageerror = () => this.fail(worker, `the vector basemap worker ${url} sent an unreadable message`);\n const rules = headerRules();\n if (rules.length > 0) worker.postMessage({ type: 'headers', rules } satisfies BasemapRequest);\n return worker;\n });\n this.unfollow = onHeaderRules((rules) => {\n for (const w of this.workers) w.postMessage({ type: 'headers', rules } satisfies BasemapRequest);\n });\n }\n\n /** A prefix for the renderer keys of one `VectorTiles` */\n namespace(): string {\n return `v${this.namespaces++}`;\n }\n\n /** Requests in progress */\n get size(): number {\n return this.pending.size;\n }\n\n /** Rejects the requests of a failed worker */\n private fail(worker: PoolWorker, message: string): void {\n const error = new Error(\n `isard: ${message}. If a bundler moves the worker, give its URL in the \\`basemapWorkerUrl\\` option (see \"With a bundler\" in the guide)`,\n );\n for (const [id, p] of this.pending) {\n if (p.worker !== worker) continue;\n this.pending.delete(id);\n p.reject(error);\n }\n }\n\n /** The worker of a vector tile */\n worker(vz: number, vx: number, vy: number): PoolWorker {\n return this.workers[workerIndex(vz, vx, vy, this.workers.length)] ?? (this.workers[0] as PoolWorker);\n }\n\n /** Sends a message to every worker (a renderer, or its removal) */\n broadcast(message: Extract<BasemapRequest, { type: 'init' } | { type: 'drop' }>): void {\n if (this.terminated) return;\n // A renderer tells the workers how many they are: they share the decoded tiles' budget\n const sent = message.type === 'init' ? { ...message, workers: this.workers.length } : message;\n // A sprite image is copied to each worker (structured clone)\n for (const w of this.workers) w.postMessage(sent);\n }\n\n /** Asks a worker for a tile's image or labels, on behalf of `owner` */\n request(worker: PoolWorker, work: BasemapWork, owner: object, signal?: AbortSignal): Promise<BasemapResponse> {\n return new Promise<BasemapResponse>((resolve, reject) => {\n if (this.terminated) return reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n if (signal?.aborted) return reject(new DOMException('aborted', 'AbortError'));\n const id = this.next++;\n const abort = () => {\n if (!this.pending.delete(id)) return;\n worker.postMessage({ type: 'abort', id } satisfies BasemapRequest);\n reject(new DOMException('aborted', 'AbortError'));\n };\n // The listener goes once the request is settled\n const settle = () => signal?.removeEventListener('abort', abort);\n this.pending.set(id, {\n resolve: (r) => {\n settle();\n resolve(r);\n },\n reject: (e) => {\n settle();\n reject(e);\n },\n worker,\n owner,\n });\n signal?.addEventListener('abort', abort, { once: true });\n worker.postMessage({ ...work, id } satisfies BasemapRequest);\n });\n }\n\n /** The altitudes of a PNG relief tile `z`/`x`/`y` at `url`, decoded by a worker (see `fetchHeights`) */\n heights(\n url: string,\n encoding: PngEncoding,\n floor: number | undefined,\n [z, x, y]: [number, number, number],\n signal: AbortSignal,\n owner: object,\n ): Promise<Float32Array | null> {\n const work: BasemapWork = { type: 'heights', url, encoding, ...(floor === undefined ? {} : { floor }) };\n return this.request(this.worker(z, x, y), work, owner, signal).then((r) => ('heights' in r ? r.heights : null));\n }\n\n /** Mercator tile `z`/`x`/`y` reprojected by a worker from the source images of its plan (see `resampler`) */\n reproject(\n job: Job,\n [z, x, y]: [number, number, number],\n signal: AbortSignal,\n owner: object,\n ): Promise<ImageBitmap | null> {\n // Blocks of 4 × 4 Mercator tiles go to the same worker: neighbours share source tiles, each worker keeps its share\n const worker = this.worker(Math.max(0, z - 2), x >> 2, y >> 2);\n const cached = Math.max(16, Math.ceil(SOURCE_CACHE / this.workers.length));\n const work: BasemapWork = { type: 'reproject', job, cached };\n return this.request(worker, work, owner, signal).then((r) => ('image' in r ? r.image : null));\n }\n\n /** Cancels the requests of an owner (the workers stop them) */\n cancel(owner: object): void {\n for (const [id, p] of this.pending) {\n if (p.owner !== owner) continue;\n this.pending.delete(id);\n p.worker.postMessage({ type: 'abort', id } satisfies BasemapRequest);\n p.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n }\n }\n\n /** Stops the workers; their requests fail */\n terminate(): void {\n if (this.terminated) return;\n this.terminated = true;\n this.unfollow();\n for (const w of this.workers) w.terminate();\n const pending = [...this.pending.values()];\n this.pending.clear();\n for (const p of pending) p.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n }\n}\n\n/** The labels of a vector tile: features by style layer (its index in the style), the higher layers first */\ntype TileLabels = [layer: number, features: Feature<LabelCandidate>[]][];\n\n/** A tile's label candidates as features, by style layer */\nexport function tileLabels(candidates: readonly LabelCandidate[]): TileLabels {\n const byLayer = new Map<number, Feature<LabelCandidate>[]>();\n for (const p of candidates) {\n const feature: Feature<LabelCandidate> = {\n type: 'Feature',\n properties: p,\n geometry: p.along\n ? {\n type: 'LineString',\n coordinates: [\n [p.lon - p.along[0] / 2, p.lat - p.along[1] / 2],\n [p.lon + p.along[0] / 2, p.lat + p.along[1] / 2],\n ],\n }\n : { type: 'Point', coordinates: [p.lon, p.lat] },\n };\n const list = byLayer.get(p.layer);\n if (list) list.push(feature);\n else byLayer.set(p.layer, [feature]);\n }\n return [...byLayer].sort((a, b) => b[0] - a[0]);\n}\n\nexport class VectorTiles {\n private readonly pool: BasemapWorkers;\n /** The pool is this instance's own (a worker count or URL other than the map's): stopped with it */\n private readonly ownPool: boolean;\n /** Prefix of its renderer keys in the pool's workers */\n private readonly namespace: string;\n private destroyed = false;\n private keys = 0;\n /** Renderers sent to the workers, dropped on destroy */\n private readonly renderers: string[] = [];\n private readonly cleanup: (() => void)[] = [];\n /** Credits of its raster layers */\n private readonly attribution: string | undefined;\n /** Its raster and label layers, removed with it */\n private readonly layers: Layer[] = [];\n /** Its first raster layer: the ground its labels follow */\n private ground: RasterLayer | undefined;\n /** The style once loaded, with its source resolved */\n readonly ready: Promise<{ style: Style; tiles: string; maxzoom: number; rasters: Record<string, RasterSource> }>;\n\n /**\n * Its workers are the map's (shared by every `VectorTiles` of the map, a vector tile decoded once for all of them),\n * unless `workers` or `workerUrl` asks for others than the map's: then it has workers of its own\n */\n constructor(\n private readonly map: GeoMap,\n options: VectorTilesOptions = {},\n ) {\n const { pool, own } = map.basemapWorkers(options.workers, options.workerUrl);\n this.pool = pool;\n this.ownPool = own;\n this.namespace = pool.namespace();\n const style = options.style ?? OPENFREEMAP_STYLES.positron;\n this.attribution = options.attribution ?? styleAttribution(style);\n this.ready = this.load(style);\n // Reported once here; `ready`, the raster tiles and the labels fail with it\n this.ready.catch((error: unknown) => {\n if (!this.destroyed) console.warn('isard: vector tiles', error);\n });\n }\n\n private async load(input: string | Style) {\n const style = typeof input === 'string' ? await json<Style>(input) : input;\n const [name, source] = Object.entries(style.sources).find(([, s]) => s.type === 'vector') ?? [];\n if (!name || !source) throw new Error('the style has no vector source');\n let { tiles, maxzoom } = await resolveSource(source);\n if (!tiles && source.url) {\n const tilejson = await json<{ tiles: string[]; maxzoom?: number }>(source.url);\n tiles = tilejson.tiles;\n maxzoom ??= tilejson.maxzoom;\n }\n const template = tiles?.[0];\n if (!template) throw new Error(`source ${name} has no tiles`);\n // Its raster sources of tiles, drawn into the same images (the shaded relief of a style at low zoom)\n const rasters: Record<string, RasterSource> = {};\n for (const [key, s] of Object.entries(style.sources)) {\n if (s.type !== 'raster') continue;\n const r = await resolveSource(s);\n const url = r.tiles?.[0];\n if (url) rasters[key] = { tiles: url, maxzoom: r.maxzoom ?? 22, tileSize: s.tileSize ?? 512 };\n }\n // Only the layers of those sources (and the background); other types (hillshade, heatmap…) are left out. The\n // application's style object stays as it is\n const layers = style.layers.filter(\n (l) =>\n l.type === 'background' ||\n (l.source === name && l.type !== 'raster') ||\n (l.type === 'raster' && l.source !== undefined && rasters[l.source] !== undefined),\n );\n return { style: { ...style, layers }, tiles: template, maxzoom: maxzoom ?? 14, rasters };\n }\n\n /** The fonts of the style's labels, for its glyphs (the first of each `text-font`, as the workers take it) */\n private static fonts(style: Style): string[] {\n const fonts = new Set<string>();\n for (const layer of style.layers) {\n const font = layer.layout?.['text-font'];\n if (layer.type === 'symbol' && Array.isArray(font) && typeof font[0] === 'string') fonts.add(labelFont(font[0]));\n }\n return [...fonts];\n }\n\n /** The style's sprites (their JSON and their images), loaded once, for the fill patterns and the icons */\n private sprites: Promise<LoadedSprite[]> | undefined;\n\n private loadSprites(sprite: Style['sprite']): Promise<LoadedSprite[]> {\n this.sprites ??= loadSprites(sprite).catch(() => []);\n return this.sprites;\n }\n\n /** Prefix of the names of its sprites' images among the map's icons */\n private get iconPrefix(): string {\n return `${this.namespace}/`;\n }\n\n private request(vz: number, vx: number, vy: number, work: BasemapWork, signal?: AbortSignal) {\n if (this.destroyed) return Promise.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n return this.pool.request(this.pool.worker(vz, vx, vy), work, this, signal);\n }\n\n /** Sends a renderer of these layers to every worker; returns its key */\n private async renderer(select: (layer: StyleLayer) => boolean, extra: StyleLayer[]) {\n const { style, tiles, maxzoom, rasters } = await this.ready;\n const key = rendererKey(this.namespace, this.keys++);\n const layers = [...style.layers.filter(select), ...extra];\n const patterns = layers.some((l) => l.paint?.['fill-pattern'] !== undefined);\n // The images are downloaded once, copied to each worker\n const sprites: Sprite[] = patterns && style.sprite ? await this.loadSprites(style.sprite) : [];\n if (this.destroyed) throw new DOMException('isard: vector tiles destroyed', 'AbortError');\n this.pool.broadcast({ type: 'init', key, tiles, maxzoom, layers, rasters, ...(sprites.length ? { sprites } : {}) });\n this.renderers.push(key);\n return { key, maxzoom };\n }\n\n /**\n * A raster layer drawing the style's fills, lines and circles (or those `layers` keeps, then `extraLayers`, of the\n * same source); `size`: texture size of its tiles (512 by default: sharp lines)\n */\n raster(\n options: {\n layers?: (layer: StyleLayer) => boolean;\n extraLayers?: StyleLayer[];\n size?: number;\n opacity?: number;\n minZoom?: number;\n maxZoom?: number;\n before?: Parameters<GeoMap['addRaster']>[0]['before'];\n } = {},\n ): RasterLayer {\n const { layers = () => true, extraLayers = [], size: texture = 512, opacity = 1, before } = options;\n const drawn = (l: StyleLayer) => l.type !== 'symbol' && layers(l);\n const renderer = this.renderer(drawn, extraLayers);\n // Its failure is reported by `ready` and each tile\n renderer.catch(() => undefined);\n const loader = async (z: number, x: number, y: number, signal: AbortSignal) => {\n const { key, maxzoom } = await renderer;\n // The vector tile it is drawn from (see the worker)\n const vz = Math.max(0, Math.min(z - 1, maxzoom));\n const shift = z - vz;\n const priority = tilePriority(z, x, y, this.map.getCamera());\n const response = await this.request(\n vz,\n x >> shift,\n y >> shift,\n { type: 'render', key, z, x, y, size: texture, priority },\n signal,\n );\n return 'image' in response ? response.image : null;\n };\n const layer = this.map.addRaster({\n url: '',\n size: texture,\n opacity,\n minZoom: options.minZoom ?? 0,\n maxZoom: options.maxZoom ?? 20,\n loader,\n ...(this.attribution ? { attribution: this.attribution } : {}),\n ...(before ? { before } : {}),\n });\n this.layers.push(layer);\n this.ground ??= layer;\n return layer;\n }\n\n /**\n * A symbol layer with the labels of the style's symbol layers (or those `layers` keeps), updated as the view\n * moves: the labels of the vector tiles in view, the higher style layers placed first. With a raster layer of\n * the style (`raster`), the tiles follow the levels the ground is drawn at: a tilted view takes coarser tiles far\n * away, with the few labels of a lower zoom, as near the camera it takes the fine ones. Without, the tiles around\n * the center at the zoom of the view. It stays above the layers added after it unless one is moved over it.\n */\n labels(options: { layers?: (layer: StyleLayer) => boolean; maxTiles?: number } = {}): SymbolLayer<LabelCandidate> {\n const { layers = () => true, maxTiles = 36 } = options;\n const symbol = this.map.addSymbols<LabelCandidate>({\n data: [],\n text: (p) => p.text,\n font: (p) => p.font,\n size: (p) => size(p.size),\n color: (p) => p.color,\n haloColor: (p) => p.haloColor,\n haloWidth: (p) => p.haloWidth,\n anchor: (p) => p.anchor as Anchor,\n offset: (p) => p.offset,\n maxWidth: (p) => p.maxWidth,\n lineHeight: (p) => p.lineHeight,\n overlap: (p) => p.overlap,\n placement: (p) => (p.textAlong ? 'line' : 'point'),\n textOptional: (p) => p.textOptional === true,\n icon: (p) => (p.icon ? this.iconPrefix + p.icon.image : ''),\n iconSize: (p) => size(p.icon?.size ?? 1, 1),\n iconAnchor: (p) => (p.icon?.anchor ?? 'center') as Anchor,\n iconOffset: (p) => p.icon?.offset ?? [0, 0],\n iconRotate: (p) => p.icon?.rotate ?? 0,\n iconRotationAlignment: (p) => p.icon?.alignment ?? 'viewport',\n iconOverlap: (p) => p.icon?.overlap ?? false,\n iconOptional: (p) => p.icon?.optional ?? false,\n iconTextFit: (p) => p.icon?.fit ?? 'none',\n iconTextFitPadding: (p) => p.icon?.padding ?? [0, 0, 0, 0],\n iconColor: (p) => p.icon?.color ?? '#000',\n iconOpacity: (p) => p.icon?.opacity ?? 1,\n });\n this.map.keepOnTop(symbol);\n this.layers.push(symbol);\n const renderer = this.ready.then(async ({ style }) => {\n // The style's fonts from its own glyphs\n if (style.glyphs) this.map.glyphs.register(style.glyphs, VectorTiles.fonts(style));\n // Its icons from its sprites, before the first labels\n const icons = style.layers.some((l) => l.type === 'symbol' && l.layout?.['icon-image'] !== undefined);\n if (icons && style.sprite) {\n for (const sprite of await this.loadSprites(style.sprite)) {\n if (!this.destroyed) this.map.icons.addSprite(this.iconPrefix, sprite.icons, () => readPixels(sprite.image));\n }\n }\n return this.renderer((l) => l.type === 'symbol' && layers(l), []);\n });\n renderer.catch(() => undefined);\n /** The labels of the tiles, as features by style layer, the higher layers first: each list is given to the symbol\n * layer as a group, shaped once while the tile is kept */\n const tiles = new Lru<string, Promise<TileLabels>>(256);\n let generation = 0;\n /** The tiles whose labels are shown */\n let shown = '';\n /** The update asked again after tiles failed */\n let retry = 0;\n const update = async () => {\n if (this.destroyed) return;\n const { key, maxzoom } = await renderer;\n const run = ++generation;\n const camera = this.map.getCamera();\n const zoom = Math.max(0, Math.min(Math.floor(camera.zoom), 24));\n const ground = this.ground && this.map.hasLayer(this.ground) ? this.map.engine.wantedTiles(this.ground.id) : [];\n const keys: string[] = [];\n if (ground.length > 0) {\n // The ground's tiles, the nearest first: a tile so many levels coarser than the finest in view has its\n // labels of a zoom as many under the view's, past the source's deepest level those of that level at the zoom\n let top = 0;\n for (let i = 0; i < ground.length; i += 3) top = Math.max(top, ground[i] as number);\n for (let i = 0; i < ground.length && keys.length < maxTiles; i += 3) {\n const [z, x, y] = [ground[i], ground[i + 1], ground[i + 2]] as [number, number, number];\n const at = Math.max(0, zoom - (top - z));\n const tz = Math.min(at, maxzoom, z);\n const shift = 2 ** (z - tz);\n const key = `${tz}/${Math.floor(x / shift)}/${Math.floor(y / shift)}${at > tz ? `@${at}` : ''}`;\n if (!keys.includes(key)) keys.push(key);\n }\n } else {\n const z = Math.min(zoom, maxzoom);\n const n = 2 ** z;\n const [west, south, east, north] = this.map.getBounds();\n const tx = (lon: number) => Math.floor(mercatorX(lon) * n);\n const ty = (lat: number) => Math.floor(mercatorY(lat) * n);\n const [cx, cy] = [mercatorX(camera.center[0]) * n, ty(camera.center[1])];\n // The tiles of the bounds, within a window around the center: a tilted view's bounds reach far, and only\n // the nearest `maxTiles` are kept anyway\n const reach = Math.ceil(Math.sqrt(maxTiles)) + 2;\n const [x0, x1] = [\n Math.max(0, tx(west), Math.floor(cx) - reach),\n Math.min(n - 1, tx(east), Math.floor(cx) + reach),\n ];\n const [y0, y1] = [\n Math.max(0, ty(north), Math.floor(cy) - reach),\n Math.min(n - 1, ty(south), Math.floor(cy) + reach),\n ];\n const wanted: [number, number][] = [];\n for (let y = y0; y <= y1; y += 1) for (let x = x0; x <= x1; x += 1) wanted.push([x, y]);\n // Nearest to the center first, at most `maxTiles` (tilted views reach far)\n wanted.sort(\n (a, b) => Math.hypot(a[0] + 0.5 - cx, a[1] + 0.5 - cy) - Math.hypot(b[0] + 0.5 - cx, b[1] + 0.5 - cy),\n );\n // Past the source's deepest level, its tiles' labels at the zoom of the view (the layers of the deeper zooms)\n for (const [x, y] of wanted.slice(0, maxTiles)) keys.push(`${z}/${x}/${y}${zoom > z ? `@${zoom}` : ''}`);\n }\n // The same tiles as the labels shown: nothing to do\n const set = keys.join(' ');\n if (set === shown) return;\n const lists = await Promise.all(\n keys.map((k, index) => {\n let p = tiles.get(k);\n if (p) return p;\n const [tile, deeper] = k.split('@');\n const [tz, x, y] = (tile ?? '').split('/').map(Number) as [number, number, number];\n // The nearest tiles first: the others wait for the raster tiles\n const priority: Priority = index < 4 ? 'auto' : 'low';\n const work: BasemapWork = {\n type: 'labels',\n key,\n z: tz,\n x,\n y,\n priority,\n ...(deeper === undefined ? {} : { zoom: Number(deeper) }),\n };\n p = this.request(tz, x, y, work).then(\n (r) => tileLabels('labels' in r ? r.labels : []),\n () => {\n // A network error is not kept: the tile is asked for again on the next update\n tiles.delete(k);\n return [];\n },\n );\n // A bounded cache of tiles' labels, the least recently used dropped\n tiles.set(k, p);\n return p;\n }),\n );\n if (run !== generation || this.destroyed) return;\n // A tile that failed is missing: the next update asks for it again, after a pause if no move brings one\n shown = keys.every((k) => tiles.has(k)) ? set : '';\n if (shown === '' && !retry) {\n retry = window.setTimeout(() => {\n retry = 0;\n refresh();\n }, RETRY_LABELS_MS);\n }\n // The labels of the higher style layers first: they win the collisions; for each style layer, the tiles nearest\n // to the center first\n const layerIds = [...new Set(lists.flatMap((list) => list.map(([layer]) => layer)))].sort((a, b) => b - a);\n const groups: Feature<LabelCandidate>[][] = [];\n for (const layer of layerIds) {\n for (const list of lists) {\n const group = list.find(([l]) => l === layer)?.[1];\n if (group) groups.push(group);\n }\n }\n symbol.setGroups(groups);\n };\n // The style failed to load: reported by `ready`\n const refresh = () => {\n update().catch(() => undefined);\n };\n let timer = 0;\n const schedule = () => {\n if (timer) return;\n timer = window.setTimeout(() => {\n timer = 0;\n refresh();\n }, 250);\n };\n this.cleanup.push(this.map.on('move', schedule), this.map.on('moveend', refresh), () => {\n clearTimeout(timer);\n clearTimeout(retry);\n });\n refresh();\n return symbol;\n }\n\n /** Stops its workers' work and removes its raster and label layers from the map (those still there) */\n destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n for (const off of this.cleanup) off();\n this.cleanup.length = 0;\n for (const layer of this.layers) if (this.map.hasLayer(layer)) layer.remove();\n this.layers.length = 0;\n this.map.dropVectorTiles(this);\n // The page's copy of the sprites (the workers have theirs), and their icons\n this.sprites\n ?.then((sprites) => {\n for (const sprite of sprites) sprite.image.close();\n this.map.icons.remove(this.iconPrefix, true);\n })\n .catch(() => undefined);\n if (this.ownPool) {\n this.pool.terminate();\n } else {\n // Shared workers: only its requests stop and its renderers go\n this.pool.cancel(this);\n for (const key of this.renderers) this.pool.broadcast({ type: 'drop', key });\n }\n this.renderers.length = 0;\n }\n}\n\n/** Colors of the layers of `basicStyle`, in turn */\nconst BASIC_COLORS = ['#2f6fd1', '#d1495b', '#2a9d8f', '#e9a03b', '#7b5ea7', '#5c7a29', '#c8553d', '#3d8eb9'];\n\n/**\n * A plain style for vector tiles known only by their layers' names (a PMTiles archive's `vector_layers`, an MBTiles'\n * metadata): each layer's polygons filled, its lines and outlines stroked and its points as circles, a color per\n * layer, the `name` of points as labels. `source` is the style's vector source (`url`: TileJSON or `pmtiles://…`, or\n * `tiles`)\n */\nexport function basicStyle(\n source: { url?: string; tiles?: string[]; minzoom?: number; maxzoom?: number },\n layers: readonly string[],\n): Style {\n const out: StyleLayer[] = [];\n layers.forEach((name, i) => {\n const color = BASIC_COLORS[i % BASIC_COLORS.length] as string;\n const base = { source: 'data', 'source-layer': name };\n out.push(\n { id: `${name}-fill`, type: 'fill', ...base, paint: { 'fill-color': color, 'fill-opacity': 0.18 } },\n { id: `${name}-line`, type: 'line', ...base, paint: { 'line-color': color, 'line-width': 1.2 } },\n {\n id: `${name}-circle`,\n type: 'circle',\n ...base,\n paint: { 'circle-color': color, 'circle-radius': 3.5, 'circle-stroke-color': '#fff', 'circle-stroke-width': 1 },\n },\n );\n });\n layers.forEach((name) => {\n out.push({\n id: `${name}-label`,\n type: 'symbol',\n source: 'data',\n 'source-layer': name,\n filter: ['all', ['==', ['geometry-type'], 'Point'], ['has', 'name']],\n layout: { 'text-field': ['get', 'name'], 'text-size': 12, 'text-offset': [0, 0.9], 'text-anchor': 'top' },\n paint: { 'text-color': '#1d2433', 'text-halo-color': '#fff', 'text-halo-width': 1.5 },\n });\n });\n return { version: 8, sources: { data: { type: 'vector', ...source } }, layers: out };\n}\n\n/** Options of `GeoMap.addPmtiles` */\nexport interface PmtilesOptions {\n /** What the archive holds (default from its header: raster images or vector tiles) */\n kind?: 'raster' | 'vector';\n /** A MapLibre style for vector tiles (its vector source `pmtiles://…`); default `basicStyle` of the archive's layers */\n style?: Style;\n opacity?: number;\n /** Texture size of raster tiles (default 256; 512 for the sharper tiles of a 512 px archive) */\n size?: number;\n /** Credits, HTML (default the archive's `attribution` metadata, as text) */\n attribution?: string;\n before?: Layer;\n}\n\n/** HTML of a file reduced to its text, escaped: credits from an archive's metadata cannot run in the page */\nfunction plainText(html: string): string {\n return html\n .replace(/<[^>]*>/g, '')\n .replace(/&(?!(amp|lt|gt|quot|copy|#\\d+);)/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;');\n}\n\n/** @internal `GeoMap.addPmtiles`: a raster layer of the archive's images, or vector tiles with their raster layer and\n * labels */\nexport async function pmtilesLayer(\n map: GeoMap,\n url: string,\n options: PmtilesOptions,\n): Promise<RasterLayer | VectorTiles> {\n const archiveUrl = pmtilesUrl(url.startsWith('pmtiles://') ? url : `pmtiles://${url}`) as string;\n const archive = pmtiles(archiveUrl);\n const [header, metadata] = await Promise.all([archive.header(), archive.metadata().catch(() => ({}))]);\n const credit = (metadata as { attribution?: unknown }).attribution;\n const attribution = options.attribution ?? (typeof credit === 'string' && credit ? plainText(credit) : undefined);\n const kind = options.kind ?? (header.tileType === 'mvt' ? 'vector' : 'raster');\n const credits = attribution ? { attribution } : {};\n if (kind === 'raster') {\n return map.addRaster({\n url: `pmtiles://${archiveUrl}`,\n minZoom: header.minZoom,\n maxZoom: Math.max(header.maxZoom, 19),\n ...(options.opacity === undefined ? {} : { opacity: options.opacity }),\n ...(options.size === undefined ? {} : { size: options.size }),\n ...(options.before ? { before: options.before } : {}),\n ...credits,\n });\n }\n const layers = (metadata as { vector_layers?: { id?: unknown }[] }).vector_layers;\n const names = Array.isArray(layers) ? layers.map((l) => l?.id).filter((id) => typeof id === 'string') : [];\n const style = options.style ?? basicStyle({ url: `pmtiles://${archiveUrl}` }, names);\n const tiles = map.vectorTiles({ style, ...credits });\n tiles.raster({\n ...(options.opacity === undefined ? {} : { opacity: options.opacity }),\n ...(options.before ? { before: options.before } : {}),\n });\n tiles.labels();\n return tiles;\n}\n\n/** A raster loader reading the tiles of a `pmtiles://` archive URL (images of any size, drawn at `size`); undefined\n * for another URL */\nexport function pmtilesRasterLoader(url: string, size: number): RasterOptions['loader'] {\n const archiveUrl = pmtilesUrl(url);\n if (!archiveUrl) return undefined;\n const archive = pmtiles(archiveUrl);\n return async (z, x, y, signal) => {\n const bytes = await archive.tile(z, x, y, signal);\n if (!bytes) return null;\n return createImageBitmap(new Blob([bytes as Uint8Array<ArrayBuffer>]), { resizeWidth: size, resizeHeight: size });\n };\n}\n"]}
1
+ {"version":3,"file":"vectortiles.js","sourceRoot":"","sources":["../../src/basemap/vectortiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAqB,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMhF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,Y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KAAuB,EAAE,IAAY,EAA+B,EAAE;IACrF,MAAM,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAEnG,OAAO,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACtD,CAAC,CAAC;AAEF;;wEAEwE;AACxE,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,6FAA6F;AAC7F,MAAM,YAAY,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAEpF,0FAA0F;AAC1F,MAAM,sBAAsB,GAAG,GAAG,CAAC","sourcesContent":["/**\n * Vector basemaps from a MapLibre style (OpenFreeMap's Positron by default): the fills, lines, circles and raster\n * layers drawn tile by tile in workers into the raster pool, so that they lie on the relief like any basemap and\n * composite with the hillshade in one pass; and the labels of the style's symbol layers in a symbol layer of their own,\n * kept above the application's layers (as MapLibre's `beforeId: firstSymbol` does), listed by the workers, shaped in\n * the page once per vector tile, placed by the engine.\n *\n * Any subset of the style can be drawn on its own raster layer (`raster({ layers })`), at its own place in the stack:\n * rivers from the basemap's data over a flood layer, for instance, restyled with `extraLayers`.\n */\n\nimport { withHeaders } from '../engine/requests.ts';\nimport { IGN_ATTRIBUTION } from '../geoplateforme.ts';\nimport type { ExtrusionLayer, ExtrusionOptions } from '../layers/extrusions.ts';\nimport type { Feature, Size } from '../layers/features.ts';\nimport { type LoadedSprite, loadSprites, readPixels } from '../layers/icons.ts';\nimport type { Layer, ModelLayer, RasterLayer } from '../layers/layers.ts';\nimport type { SymbolLayer } from '../layers/symbols.ts';\nimport type { VectorLayer, VectorSublayer } from '../layers/vectors.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { Anchor } from '../ui/overlay.ts';\nimport { mercatorX, mercatorY } from '../util/geo.ts';\nimport { isRecord } from '../util/guards.ts';\nimport { Lru } from '../util/lru.ts';\nimport type { Camera } from '../wasm/isard.js';\nimport type { BasemapWork, Priority, Sprite, TilePolygons } from '../workers/basemap.worker.ts';\nimport { OPENFREEMAP_ATTRIBUTION } from './basemaps.ts';\nimport { pmtiles, pmtilesUrl } from './pmtiles.ts';\nimport { isWoodland, TREE_NUMBERS, type TreeColors, treeModel, treeSpacing } from './trees.ts';\nimport {\n evaluate,\n isExpression,\n isStyle,\n type Json,\n type LabelCandidate,\n labelFont,\n type RasterSource,\n type Style,\n type StyleLayer,\n vectorKind,\n zoomOnly,\n} from './vectorstyle.ts';\nimport { type BasemapWorkers, rendererKey, tilePriority } from './workerpool.ts';\n\n/** OpenFreeMap's styles: OpenStreetMap data in the OpenMapTiles schema, worldwide, free and without a key */\nexport const OPENFREEMAP_STYLES = {\n positron: 'https://tiles.openfreemap.org/styles/positron',\n liberty: 'https://tiles.openfreemap.org/styles/liberty',\n bright: 'https://tiles.openfreemap.org/styles/bright',\n} as const;\n\n/** PLAN.IGN vector styles of the Géoplateforme (France) */\nexport const PLAN_STYLES = {\n standard: 'https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/standard.json',\n grey: 'https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/gris.json',\n} as const;\n\n/** Vector basemaps by name (see `BasemapName`) */\nexport const VECTOR_BASEMAPS = {\n 'osm-positron': OPENFREEMAP_STYLES.positron,\n 'osm-liberty': OPENFREEMAP_STYLES.liberty,\n 'osm-bright': OPENFREEMAP_STYLES.bright,\n 'ign-plan-vector': PLAN_STYLES.standard,\n 'ign-plan-grey-vector': PLAN_STYLES.grey,\n} as const;\n\nexport interface VectorTilesOptions {\n /** A style URL or object (default OpenFreeMap's Positron) */\n style?: string | Style;\n /** Workers drawing the tiles (default cores - 1, 1 to 4). The vector tiles of a map share its workers (and their\n * decoded tiles); another count gives these tiles workers of their own */\n workers?: number;\n /** Where to load the worker from, when a bundler does not resolve the default URL (default the map's\n * `basemapWorkerUrl`); another URL than the map's gives these tiles workers of their own */\n workerUrl?: string | URL;\n /** Credits of the tiles, shown while its raster layers are on the map (default: OpenFreeMap's for its styles, the\n * IGN's for PLAN.IGN's) */\n attribution?: string;\n}\n\n/** The credits of a known style: OpenFreeMap's, PLAN.IGN's */\nexport const styleAttribution = (style: string | Style): string | undefined => {\n if (typeof style !== 'string') return undefined;\n if (Object.values(OPENFREEMAP_STYLES).some((s) => s === style)) return OPENFREEMAP_ATTRIBUTION;\n if (Object.values(PLAN_STYLES).some((s) => s === style)) return IGN_ATTRIBUTION;\n\n return undefined;\n};\n\n/** Text or icon size of a style (a number, legacy stops, or the stops of a zoom expression made by the worker) as a\n * size for the symbol layer */\nexport const size = (value: Json, fallback = 16): Size => {\n const stop = (s: Json): [number, number] => {\n const [z, v] = Array.isArray(s) ? s : [];\n\n return [Number(z), Number(v)];\n };\n\n if (typeof value === 'number') return value;\n if (Array.isArray(value) && value.length > 0 && value.every(Array.isArray)) return value.map(stop);\n if (isRecord(value) && Array.isArray(value.stops)) return value.stops.map(stop);\n\n return fallback;\n};\n\n/** The anchors of the symbol layer */\nconst ANCHORS: ReadonlySet<string> = new Set<Anchor>([\n 'center',\n 'top',\n 'bottom',\n 'left',\n 'right',\n 'top-left',\n 'top-right',\n 'bottom-left',\n 'bottom-right',\n]);\n\nconst isAnchor = (value: string | undefined): value is Anchor => value !== undefined && ANCHORS.has(value);\n\n/** A style's anchor (`text-anchor`, `icon-anchor`) for the symbol layer: `center` if it is none */\nconst anchor = (value: string | undefined): Anchor => (isAnchor(value) ? value : 'center');\n\n/** Fetches a JSON document (a style, a TileJSON) */\nconst json = async (url: string): Promise<unknown> => {\n const response = await fetch(url, withHeaders(url));\n\n if (!response.ok) throw new Error(`${url}: ${response.status}`);\n\n return response.json();\n};\n\n/** A style fetched: a MapLibre style, or an error */\nconst fetchStyle = async (url: string): Promise<Style> => {\n const style = await json(url);\n\n if (!isStyle(style)) throw new Error(`${url}: not a MapLibre style`);\n\n return style;\n};\n\n/** What a basemap reads of a TileJSON */\ninterface TileJson {\n tiles: string[];\n maxzoom?: number;\n}\n\nconst isTileJson = (value: unknown): value is TileJson =>\n isRecord(value) &&\n Array.isArray(value.tiles) &&\n value.tiles.every((t) => typeof t === 'string') &&\n (value.maxzoom === undefined || typeof value.maxzoom === 'number');\n\n/** A TileJSON fetched, or an error */\nconst fetchTileJson = async (url: string): Promise<TileJson> => {\n const tilejson = await json(url);\n\n if (!isTileJson(tilejson)) throw new Error(`${url}: not a TileJSON`);\n\n return tilejson;\n};\n\n/**\n * A style source's tiles and deepest level: a `pmtiles://` archive (its `url`, or a `tiles` template) read for its\n * header, its tiles then named `pmtiles://<absolute archive URL>/{z}/{x}/{y}` for the workers; other sources as they are\n */\nconst resolveSource = async (source: Style['sources'][string]): Promise<{ tiles?: string[]; maxzoom?: number }> => {\n const given = source.url ?? source.tiles?.[0] ?? '';\n const archive = pmtilesUrl(given.replace(/\\/\\{z\\}\\/\\{x\\}\\/\\{y\\}$/, ''));\n\n if (!archive)\n return {\n ...(source.tiles ? { tiles: source.tiles } : {}),\n ...(source.maxzoom === undefined ? {} : { maxzoom: source.maxzoom }),\n };\n\n const header = await pmtiles(archive).header();\n\n return { tiles: [`pmtiles://${archive}/{z}/{x}/{y}`], maxzoom: source.maxzoom ?? header.maxZoom };\n};\n\n/** Pause before the labels of tiles that failed are asked for again, when no move brings an update (ms) */\nconst RETRY_LABELS_MS = 3000;\n\n/** The style layers of buildings, by default: PLAN IGN's `bati_surf` (not its built-up areas nor its parks), the\n * OpenMapTiles' `building` */\nconst isBuildings = (layer: StyleLayer): boolean => ['bati_surf', 'building'].includes(layer['source-layer'] ?? '');\n\n/**\n * The tiles of level `z` in view, within a window around the center (a tilted view's bounds reach far), the\n * `maxTiles` nearest to the center first\n */\nconst tilesAround = (map: GeoMap, camera: Camera, z: number, maxTiles: number): [x: number, y: number][] => {\n const n = 2 ** z;\n const [west, south, east, north] = map.getBounds();\n const tx = (lon: number) => Math.floor(mercatorX(lon) * n);\n const ty = (lat: number) => Math.floor(mercatorY(lat) * n);\n const [cx, cy] = [mercatorX(camera.center[0]) * n, mercatorY(camera.center[1]) * n];\n const reach = Math.ceil(Math.sqrt(maxTiles)) + 2;\n const [x0, x1] = [Math.max(0, tx(west), Math.floor(cx) - reach), Math.min(n - 1, tx(east), Math.floor(cx) + reach)];\n const [y0, y1] = [Math.max(0, ty(north), Math.floor(cy) - reach), Math.min(n - 1, ty(south), Math.floor(cy) + reach)];\n const wanted = Array.from({ length: Math.max(0, y1 - y0 + 1) }, (_, j) => y0 + j).flatMap((y) =>\n Array.from({ length: Math.max(0, x1 - x0 + 1) }, (_, i): [number, number] => [x0 + i, y]),\n );\n\n wanted.sort((a, b) => Math.hypot(a[0] + 0.5 - cx, a[1] + 0.5 - cy) - Math.hypot(b[0] + 0.5 - cx, b[1] + 0.5 - cy));\n\n return wanted.slice(0, maxTiles);\n};\n\n/** The labels of a vector tile: features by style layer (its index in the style), the higher layers first */\ntype TileLabels = [layer: number, features: Feature<LabelCandidate>[]][];\n\n/** A tile's label candidates as features, by style layer */\nexport const tileLabels = (candidates: readonly LabelCandidate[]): TileLabels => {\n const byLayer = new Map<number, Feature<LabelCandidate>[]>();\n\n candidates.forEach((p) => {\n const feature: Feature<LabelCandidate> = {\n type: 'Feature',\n properties: p,\n geometry: p.along\n ? {\n type: 'LineString',\n coordinates: [\n [p.lon - p.along[0] / 2, p.lat - p.along[1] / 2],\n [p.lon + p.along[0] / 2, p.lat + p.along[1] / 2],\n ],\n }\n : { type: 'Point', coordinates: [p.lon, p.lat] },\n };\n const list = byLayer.get(p.layer);\n\n if (list) list.push(feature);\n else byLayer.set(p.layer, [feature]);\n });\n\n return [...byLayer].sort((a, b) => b[0] - a[0]);\n};\n\nexport class VectorTiles {\n private readonly pool: BasemapWorkers;\n /** The pool is this instance's own (a worker count or URL other than the map's): stopped with it */\n private readonly ownPool: boolean;\n /** Prefix of its renderer keys in the pool's workers */\n private readonly namespace: string;\n private destroyed = false;\n private keys = 0;\n /** Renderers sent to the workers, dropped on destroy */\n private readonly renderers: string[] = [];\n private readonly cleanup: (() => void)[] = [];\n /** Credits of its raster layers */\n private readonly attribution: string | undefined;\n /** Its raster and label layers, removed with it */\n private readonly layers: Layer[] = [];\n /** Its first raster layer: the ground its labels follow */\n private ground: RasterLayer | undefined;\n /** The style once loaded, with its source resolved */\n readonly ready: Promise<{ style: Style; tiles: string; maxzoom: number; rasters: Record<string, RasterSource> }>;\n\n /**\n * Its workers are the map's (shared by every `VectorTiles` of the map, a vector tile decoded once for all of them),\n * unless `workers` or `workerUrl` asks for others than the map's: then it has workers of its own\n */\n constructor(\n private readonly map: GeoMap,\n options: VectorTilesOptions = {},\n ) {\n const { pool, own } = map.basemapWorkers(options.workers, options.workerUrl);\n\n this.pool = pool;\n this.ownPool = own;\n this.namespace = pool.namespace();\n\n const style = options.style ?? OPENFREEMAP_STYLES.positron;\n\n this.attribution = options.attribution ?? styleAttribution(style);\n this.ready = this.load(style);\n // Reported once here; `ready`, the raster tiles and the labels fail with it\n this.ready.catch((error: unknown) => {\n if (!this.destroyed) console.warn('isard: vector tiles', error);\n });\n }\n\n private async load(input: string | Style) {\n const style = typeof input === 'string' ? await fetchStyle(input) : input;\n const [name, source] = Object.entries(style.sources).find(([, s]) => s.type === 'vector') ?? [];\n\n if (!name || !source) throw new Error('the style has no vector source');\n\n const resolved = await resolveSource(source);\n const tilejson = !resolved.tiles && source.url ? await fetchTileJson(source.url) : undefined;\n const tiles = tilejson === undefined ? resolved.tiles : tilejson.tiles;\n const maxzoom = resolved.maxzoom ?? tilejson?.maxzoom;\n const template = tiles?.[0];\n\n if (!template) throw new Error(`source ${name} has no tiles`);\n\n // Its raster sources of tiles, drawn into the same images (the shaded relief of a style at low zoom)\n const rasters: Record<string, RasterSource> = {};\n\n for (const [key, s] of Object.entries(style.sources)) {\n if (s.type !== 'raster') continue;\n\n const r = await resolveSource(s);\n const url = r.tiles?.[0];\n\n if (url) rasters[key] = { tiles: url, maxzoom: r.maxzoom ?? 22, tileSize: s.tileSize ?? 512 };\n }\n\n // Only the layers of those sources (and the background); other types (hillshade, heatmap…) are left out. The\n // application's style object stays as it is\n const layers = style.layers.filter(\n (l) =>\n l.type === 'background' ||\n (l.source === name && l.type !== 'raster') ||\n (l.type === 'raster' && l.source !== undefined && rasters[l.source] !== undefined),\n );\n\n return { style: { ...style, layers }, tiles: template, maxzoom: maxzoom ?? 14, rasters };\n }\n\n /** The fonts of the style's labels, for its glyphs (the first of each `text-font`, as the workers take it) */\n private static fonts(style: Style): string[] {\n const fonts = new Set<string>();\n\n style.layers.forEach((layer) => {\n const font = layer.layout?.['text-font'];\n\n if (layer.type === 'symbol' && Array.isArray(font) && typeof font[0] === 'string') fonts.add(labelFont(font[0]));\n });\n\n return [...fonts];\n }\n\n /** The style's sprites (their JSON and their images), loaded once, for the fill patterns and the icons */\n private sprites: Promise<LoadedSprite[]> | undefined;\n\n private loadSprites(sprite: Style['sprite']): Promise<LoadedSprite[]> {\n this.sprites ??= loadSprites(sprite).catch(() => []);\n\n return this.sprites;\n }\n\n /** Prefix of the names of its sprites' images among the map's icons */\n private get iconPrefix(): string {\n return `${this.namespace}/`;\n }\n\n private request(vz: number, vx: number, vy: number, work: BasemapWork, signal?: AbortSignal) {\n if (this.destroyed) return Promise.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n\n return this.pool.request(this.pool.worker(vz, vx, vy), work, this, signal);\n }\n\n /** Sends a renderer of these layers to every worker (again under `again`, restyled); returns its key */\n private async renderer(select: (layer: StyleLayer) => boolean, extra: StyleLayer[], again?: string) {\n const { style, tiles, maxzoom, rasters } = await this.ready;\n const key = again ?? rendererKey(this.namespace, this.keys++);\n const layers = [...style.layers.filter(select), ...extra];\n const patterns = layers.some((l) => l.paint?.['fill-pattern'] !== undefined);\n // The images are downloaded once, copied to each worker\n const sprites: Sprite[] = patterns && style.sprite ? await this.loadSprites(style.sprite) : [];\n\n if (this.destroyed) throw new DOMException('isard: vector tiles destroyed', 'AbortError');\n this.pool.broadcast({ type: 'init', key, tiles, maxzoom, layers, rasters, ...(sprites.length ? { sprites } : {}) });\n if (!again) this.renderers.push(key);\n\n return { key, maxzoom, layers };\n }\n\n /**\n * A raster layer drawing the style's fills, lines and circles (or those `layers` keeps, then `extraLayers`, of the\n * same source); `size`: texture size of its tiles (512 by default: sharp lines)\n */\n raster(\n options: {\n layers?: (layer: StyleLayer) => boolean;\n extraLayers?: StyleLayer[];\n size?: number;\n opacity?: number;\n minZoom?: number;\n maxZoom?: number;\n before?: Parameters<GeoMap['addRaster']>[0]['before'];\n } = {},\n ): RasterLayer {\n const { layers = () => true, extraLayers = [], size: texture = 512, opacity = 1, before } = options;\n const drawn = (l: StyleLayer) => l.type !== 'symbol' && layers(l);\n const renderer = this.renderer(drawn, extraLayers);\n\n // Its failure is reported by `ready` and each tile\n renderer.catch(() => undefined);\n\n const loader = async (z: number, x: number, y: number, signal: AbortSignal) => {\n const { key, maxzoom } = await renderer;\n // The vector tile it is drawn from (see the worker)\n const vz = Math.max(0, Math.min(z - 1, maxzoom));\n const shift = z - vz;\n const priority = tilePriority(z, x, y, this.map.getCamera());\n const response = await this.request(\n vz,\n x >> shift,\n y >> shift,\n { type: 'render', key, z, x, y, size: texture, priority },\n signal,\n );\n\n return 'image' in response ? response.image : null;\n };\n const layer = this.map.addRaster({\n url: '',\n size: texture,\n opacity,\n minZoom: options.minZoom ?? 0,\n maxZoom: options.maxZoom ?? 20,\n loader,\n ...(this.attribution ? { attribution: this.attribution } : {}),\n ...(before ? { before } : {}),\n });\n\n this.layers.push(layer);\n this.ground ??= layer;\n\n return layer;\n }\n\n /**\n * An extrusion layer of the polygons of the style's fill layers that `layers` keeps (by default its buildings: the\n * fill or fill-extrusion layers of PLAN IGN's `bati_surf` or OpenMapTiles' `building`), raised by the style\n * given (`height`, `base`, `color`, `ramp`…; the properties of the tiles' features). Its tiles follow the view: at\n * the source's deepest level, the `maxTiles` nearest to the center, from `minZoom` on (15 by default); the tiles\n * leaving the view are dropped.\n */\n extrusions<P = Record<string, unknown>>(\n options: Omit<ExtrusionOptions<P>, 'data'> & {\n layers?: (layer: StyleLayer) => boolean;\n minZoom?: number;\n maxTiles?: number;\n } = {},\n ): ExtrusionLayer<P> {\n const { layers = isBuildings, minZoom = 15, maxTiles = 36, ...style } = options;\n const extrusions = this.map.addExtrusions<P>(style);\n const renderer = this.renderer((l) => (l.type === 'fill' || l.type === 'fill-extrusion') && layers(l), []);\n\n renderer.catch(() => undefined);\n this.layers.push(extrusions);\n\n /** The tiles held or asked for, by key */\n const held = new Map<string, AbortController>();\n const update = async () => {\n if (this.destroyed) return;\n\n const { key, maxzoom } = await renderer;\n const camera = this.map.getCamera();\n const z = maxzoom;\n const wanted = camera.zoom < minZoom ? [] : tilesAround(this.map, camera, z, maxTiles);\n const keys = new Set(wanted.map(([x, y]) => `${z}/${x}/${y}`));\n\n // Out of view: dropped, or no longer asked for\n [...held].forEach(([k, controller]) => {\n if (keys.has(k)) return;\n controller.abort();\n held.delete(k);\n extrusions.removeTile(k);\n });\n wanted.forEach(([x, y], index) => {\n const k = `${z}/${x}/${y}`;\n\n if (held.has(k)) return;\n\n const controller = new AbortController();\n const work: BasemapWork = { type: 'polygons', key, z, x, y, priority: index < 4 ? 'auto' : 'low' };\n\n held.set(k, controller);\n this.request(z, x, y, work, controller.signal).then(\n (r) => {\n if (controller.signal.aborted || !('polygons' in r)) return;\n\n const tile: TilePolygons = r.polygons;\n\n // The features' properties as the style reads them\n extrusions.setTile(k, { arrays: tile.arrays, properties: tile.properties as P[] });\n },\n () => {\n // A failure is asked for again on the next update\n if (held.get(k) === controller) held.delete(k);\n },\n );\n });\n };\n this.followView(update, held, update);\n\n return extrusions;\n }\n\n /**\n * Trees on the style's woods, forests and grass (or the fill layers `layers` keeps) as 3D models, from street level\n * (`minZoom`, default 15): the workers scatter them over the polygons of the vector tiles around the view, `spacing`\n * metres apart (by style layer: 9 in woods, 25 on grass, by default) on a jittered grid, the same trees whenever a\n * tile comes back; the engine draws them all in one instanced draw, on the relief. A low-poly tree by default (its\n * `colors`), or your own glTF (`url`, `data`, about 10 metres high, standing on its origin). Dense around the\n * view's center, fewer and fewer away from it (as the camera moves too), at most `maxInstances` drawn (default\n * 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000). The models load the\n * engine with 3D Tiles.\n */\n trees(\n options: {\n layers?: (layer: StyleLayer) => boolean;\n spacing?: number | ((layer: StyleLayer) => number);\n minZoom?: number;\n maxTiles?: number;\n maxTrees?: number;\n maxInstances?: number;\n colors?: Partial<TreeColors>;\n url?: string;\n data?: ArrayBuffer | ArrayBufferView<ArrayBuffer>;\n before?: Layer;\n } = {},\n ): ModelLayer {\n const {\n layers = isWoodland,\n spacing = treeSpacing,\n minZoom = 15,\n maxTiles = 9,\n maxTrees = 30000,\n maxInstances = 25000,\n } = options;\n const model = options.url ? { url: options.url } : { data: options.data ?? treeModel(options.colors) };\n const trees = this.map.addModels({\n ...model,\n instances: [],\n ...(options.before ? { before: options.before } : {}),\n });\n const renderer = this.renderer((l) => l.type === 'fill' && layers(l), []);\n\n renderer.catch(() => undefined);\n this.layers.push(trees);\n\n /** The tiles held or asked for, by key, and the trees of those that came */\n const held = new Map<string, AbortController>();\n const found = new Map<string, Float64Array>();\n /** The trees drawn to the engine (longitude, latitude, altitude, heading, pitch, roll, scale each): all of them\n * near the view's center, past `near` metres those of a rank under (near / distance)², at most `maxInstances` */\n const send = () => {\n const { center, zoom } = this.map.getCamera();\n const near = TREES_NEAR_METRES * 2 ** (16 - zoom);\n const metresPerDegree = 111320;\n const cos = Math.cos((center[1] * Math.PI) / 180);\n const chosen: [score: number, tile: Float64Array, i: number][] = [];\n\n found.forEach((t) => {\n for (let i = 0; i < t.length / TREE_NUMBERS; i += 1) {\n const dx = ((t[i * TREE_NUMBERS] ?? 0) - center[0]) * metresPerDegree * cos;\n const dy = ((t[i * TREE_NUMBERS + 1] ?? 0) - center[1]) * metresPerDegree;\n const far = (dx * dx + dy * dy) / (near * near);\n const score = (t[i * TREE_NUMBERS + 4] ?? 0) * Math.max(1, far);\n\n if (score < 1) chosen.push([score, t, i]);\n }\n });\n if (chosen.length > maxInstances) chosen.sort((a, b) => a[0] - b[0]).splice(maxInstances);\n\n const out = new Float64Array(chosen.length * 7);\n\n chosen.forEach(([, t, i], k) => {\n const at = i * TREE_NUMBERS;\n\n out.set([t[at] ?? 0, t[at + 1] ?? 0, 0, t[at + 3] ?? 0, 0, 0, t[at + 2] ?? 1], k * 7);\n });\n trees.setInstanceNumbers(out);\n };\n const update = async () => {\n if (this.destroyed) return;\n\n const { key, maxzoom, layers: list } = await renderer;\n const camera = this.map.getCamera();\n const z = maxzoom;\n const wanted = camera.zoom < minZoom ? [] : tilesAround(this.map, camera, z, maxTiles);\n const keys = new Set(wanted.map(([x, y]) => `${z}/${x}/${y}`));\n const metres = list.map((l) => (typeof spacing === 'number' ? spacing : spacing(l)));\n const dropped = [...held.keys()].filter((k) => !keys.has(k));\n\n // Out of view: dropped, or no longer asked for\n dropped.forEach((k) => {\n held.get(k)?.abort();\n held.delete(k);\n found.delete(k);\n });\n // Dense around the new center\n send();\n wanted.forEach(([x, y], index) => {\n const k = `${z}/${x}/${y}`;\n\n if (held.has(k)) return;\n\n const controller = new AbortController();\n const priority = index < 4 ? 'auto' : 'low';\n const work: BasemapWork = { type: 'trees', key, z, x, y, spacing: metres, maxTrees, priority };\n\n held.set(k, controller);\n this.request(z, x, y, work, controller.signal).then(\n (r) => {\n if (controller.signal.aborted || !('trees' in r)) return;\n found.set(k, r.trees);\n send();\n },\n () => {\n // A failure is asked for again on the next update\n if (held.get(k) === controller) held.delete(k);\n },\n );\n });\n };\n // While the camera moves, the trees drawn follow its center (dense near it)\n this.followView(update, held, send);\n\n return trees;\n }\n\n /**\n * A layer drawing the style's fills, lines and buildings (or those `layers` keeps; backgrounds as fills, the\n * `fill-extrusion` layers raised into buildings by their height and base height) as geometry instead of images: the\n * workers cut the vector tiles in view into polygons and lines, which the engine draws on the globe and the relief,\n * in the style's order, each style layer over its zoom range. Sharp at any zoom\n * and pitch, picked by feature (`pick` gives its properties and style layer), restyled without cutting the tiles\n * again (`setPaintProperty`, `setLayoutProperty`). Its tiles follow the view, while it moves too, coarser far away in a\n * tilted view, and those leaving it stay until the ones replacing them are there; past the source's deepest level,\n * cut again from its tiles down to level 18 (overzoom: their filters and styles those of their level). The fills' outlines are drawn one\n * pixel wide, the lines' ends as their `line-cap` says (their joins round), the colors follow the camera's zoom. The\n * layers drawn with a pattern and the circles are left out (the raster path draws them), as are `line-offset`,\n * `line-blur` and the translations (`fill-translate`, `line-translate`); `raster` stays the lighter path for heavy\n * styles and small devices. At night (`setSun`) the line layers `streets` keeps glow (by default those whose id names\n * a road, not its casing, a railway, a path or a tunnel).\n */\n vectors(\n options: { layers?: (layer: StyleLayer) => boolean; streets?: (layer: StyleLayer) => boolean; before?: Layer } = {},\n ): VectorLayer {\n const { layers = () => true, streets = isStreet, before } = options;\n const vector = this.map.addVectorLayer(before);\n const state: {\n renderer: ReturnType<VectorTiles['renderer']>;\n /** The style layers as the application changed them (`setPaintProperty`…): a copy, its style left as it is */\n own?: StyleLayer[];\n /** Bumped by each update: only the last one drops the tiles out of its view */\n update: number;\n /** Bumped by each restyle: a tile cut under an older style is restyled once it is there */\n style: number;\n } = { renderer: this.renderer((l) => vectorKind(l) !== undefined && layers(l), []), update: 0, style: 0 };\n\n state.renderer.catch(() => undefined);\n this.layers.push(vector);\n\n const sublayers = (list: StyleLayer[]): VectorSublayer[] => {\n const zoom = this.map.getCamera().zoom;\n\n return list.map((l) => ({\n id: l.id,\n sourceLayer: l['source-layer'],\n kind: vectorKind(l) ?? 'fill',\n minZoom: l.minzoom ?? 0,\n maxZoom: l.maxzoom ?? 24,\n visible: l.layout?.visibility !== 'none',\n opacity: zoomOnly(l.paint?.[`${l.type}-opacity`], 1) ?? 1,\n cap: lineCap(l.layout?.['line-cap'], zoom),\n lit: l.type === 'line' && streets(l),\n dash: l.type === 'line' ? dashes(l.paint?.['line-dasharray'], zoom) : [0, 0, 0, 0],\n }));\n };\n\n /** The tiles held or asked for, by `z/x/y` */\n const held = new Map<string, AbortController>();\n /** A tile's geometry, or its styles alone, asked of the worker of its tile of the source's level (which keeps the\n * decoded tile its deeper tiles are cut from) */\n const ask = (\n { key, maxzoom }: { key: string; maxzoom: number },\n [z = 0, x = 0, y = 0]: number[],\n styles: boolean,\n priority: Priority,\n signal?: AbortSignal,\n ) => {\n const d = Math.max(0, z - maxzoom);\n const work: BasemapWork = { type: 'vectors', key, z, x, y, deepest: deepestLevel(maxzoom), priority };\n\n // The geometry made ready for the GPU in the workers, with the prisms the relief needs\n return this.request(\n z - d,\n Math.floor(x / 2 ** d),\n Math.floor(y / 2 ** d),\n styles ? { ...work, styles } : { ...work, prism: this.map.hasRelief },\n signal,\n );\n };\n\n // The workers tessellate the tiles (the main thread only uploads them), once they know the module\n this.pool.broadcast({ type: 'tess', url: this.map.tessUrl });\n /** The styles of a tile held asked for again, the tile kept as it is */\n const restyleTile = async (renderer: { key: string; maxzoom: number }, k: string) => {\n const r = await ask(renderer, k.split('/').map(Number), true, 'auto').catch(() => undefined);\n\n if (r && 'styles' in r) vector.setTileStyles(k, r.styles);\n };\n const update = async () => {\n if (this.destroyed) return;\n\n const generation = ++state.update;\n const { key, maxzoom, layers: list } = await state.renderer;\n\n vector.setSublayers(sublayers(state.own ?? list));\n\n const view = this.map.engine.vectorTilesInView(0, deepestLevel(maxzoom));\n const wanted = Array.from({ length: Math.floor(view.length / 3) }, (_, i) => [\n ...view.subarray(i * 3, i * 3 + 3),\n ]);\n const keys = new Set(wanted.map((t) => t.join('/')));\n const loads = wanted.flatMap((t, index) => {\n const k = t.join('/');\n\n if (held.has(k)) return [];\n\n const controller = new AbortController();\n const style = state.style;\n\n held.set(k, controller);\n\n return [\n ask({ key, maxzoom }, t, false, index < 4 ? 'high' : 'auto', controller.signal).then(\n async (r) => {\n if (controller.signal.aborted || !('vectors' in r)) return;\n vector.setTile(k, r.vectors);\n // Cut under a style changed since: its styles asked for again\n if (style !== state.style) await restyleTile(await state.renderer, k);\n },\n () => {\n // A failure is asked for again on the next update\n if (held.get(k) === controller) held.delete(k);\n },\n ),\n ];\n });\n // Out of view: those still asked for go at once, those drawn once their replacements are there (no hole)\n const drop = (drawn: boolean) => {\n const shown = new Set(vector.tileKeys);\n\n [...held].forEach(([k, controller]) => {\n if (keys.has(k) || shown.has(k) !== drawn) return;\n controller.abort();\n held.delete(k);\n vector.removeTile(k);\n });\n };\n\n drop(false);\n await Promise.all(loads);\n // A later update (the view moved again meanwhile) drops for its own view: these keys are no longer the view\n if (!this.destroyed && generation === state.update) drop(true);\n };\n const refresh = () => {\n update().catch(() => undefined);\n };\n /** The style layers changed: the workers' copy, then the styles of the tiles held */\n const restyle = async (list: StyleLayer[]) => {\n state.own = list;\n state.style++;\n state.renderer = state.renderer.then(({ key }) => this.renderer(() => false, list, key));\n\n const renderer = await state.renderer;\n\n vector.setSublayers(sublayers(list));\n await Promise.all(vector.tileKeys.map((k) => restyleTile(renderer, k)));\n };\n\n vector.restyle = (id, group, name, value) => {\n state.renderer\n .then(({ layers: list }) => {\n const next = (state.own ?? list).map((l) =>\n l.id === id ? { ...l, [group]: { ...l[group], [name]: value } } : l,\n );\n\n // Visibility and dashes are the engine's: the tiles stay as they are\n if ((group === 'layout' && name === 'visibility') || name === 'line-dasharray') {\n state.own = next;\n vector.setSublayers(sublayers(next));\n\n return undefined;\n }\n // An outline added or taken away: a feature more or less in each tile, cut again\n if (name === 'fill-outline-color' || name === 'fill-antialias') {\n state.own = next;\n state.style++;\n state.renderer = state.renderer.then(({ key }) => this.renderer(() => false, next, key));\n vector.setSublayers(sublayers(next));\n vector.recut?.();\n\n return undefined;\n }\n\n return restyle(next);\n })\n .catch(() => undefined);\n };\n vector.recut = () => {\n held.forEach((controller) => {\n controller.abort();\n });\n held.clear();\n refresh();\n };\n vector.styled = state.renderer.then(({ layers: list }) => {\n if (!this.destroyed) vector.setSublayers(sublayers(state.own ?? list));\n });\n // Reported by the style's `ready`\n vector.styled.catch(() => undefined);\n\n // While the camera moves, the tiles follow it (as the labels do: a long drag or flight does not leave the view of\n // its start drawn)\n this.followView(update, held, update);\n\n return vector;\n }\n\n /**\n * A symbol layer with the labels of the style's symbol layers (or those `layers` keeps), updated as the view\n * moves: the labels of the vector tiles in view, the higher style layers placed first. With a raster layer of\n * the style (`raster`), the tiles follow the levels the ground is drawn at: a tilted view takes coarser tiles far\n * away, with the few labels of a lower zoom, as near the camera it takes the fine ones. Without, the tiles around\n * the center at the zoom of the view. It stays above the layers added after it unless one is moved over it.\n */\n labels(options: { layers?: (layer: StyleLayer) => boolean; maxTiles?: number } = {}): SymbolLayer<LabelCandidate> {\n const { layers = () => true, maxTiles = 36 } = options;\n const symbol = this.map.addSymbols<LabelCandidate>({\n data: [],\n text: (p) => p.text,\n font: (p) => p.font,\n size: (p) => size(p.size),\n color: (p) => p.color,\n haloColor: (p) => p.haloColor,\n haloWidth: (p) => p.haloWidth,\n anchor: (p) => anchor(p.anchor),\n offset: (p) => p.offset,\n maxWidth: (p) => p.maxWidth,\n lineHeight: (p) => p.lineHeight,\n overlap: (p) => p.overlap,\n placement: (p) => (p.textAlong ? 'line' : 'point'),\n textOptional: (p) => p.textOptional === true,\n icon: (p) => (p.icon ? this.iconPrefix + p.icon.image : ''),\n iconSize: (p) => size(p.icon?.size ?? 1, 1),\n iconAnchor: (p) => anchor(p.icon?.anchor),\n iconOffset: (p) => p.icon?.offset ?? [0, 0],\n iconRotate: (p) => p.icon?.rotate ?? 0,\n iconRotationAlignment: (p) => p.icon?.alignment ?? 'viewport',\n iconOverlap: (p) => p.icon?.overlap ?? false,\n iconOptional: (p) => p.icon?.optional ?? false,\n iconTextFit: (p) => p.icon?.fit ?? 'none',\n iconTextFitPadding: (p) => p.icon?.padding ?? [0, 0, 0, 0],\n iconColor: (p) => p.icon?.color ?? '#000',\n iconOpacity: (p) => p.icon?.opacity ?? 1,\n });\n\n this.map.keepOnTop(symbol);\n this.layers.push(symbol);\n\n const renderer = this.ready.then(async ({ style }) => {\n // The style's fonts from its own glyphs\n if (style.glyphs) this.map.glyphs.register(style.glyphs, VectorTiles.fonts(style));\n\n // Its icons from its sprites, before the first labels\n const icons = style.layers.some((l) => l.type === 'symbol' && l.layout?.['icon-image'] !== undefined);\n\n if (icons && style.sprite) {\n (await this.loadSprites(style.sprite)).forEach((sprite) => {\n if (!this.destroyed) this.map.icons.addSprite(this.iconPrefix, sprite.icons, () => readPixels(sprite.image));\n });\n }\n\n return this.renderer((l) => l.type === 'symbol' && layers(l), []);\n });\n\n renderer.catch(() => undefined);\n\n /** The labels of the tiles, as features by style layer, the higher layers first: each list is given to the symbol\n * layer as a group, shaped once while the tile is kept */\n const tiles = new Lru<string, Promise<TileLabels>>(256);\n let generation = 0;\n /** The tiles whose labels are shown */\n let shown = '';\n /** The update asked again after tiles failed */\n let retry = 0;\n const update = async () => {\n if (this.destroyed) return;\n\n const { key, maxzoom } = await renderer;\n const run = ++generation;\n const camera = this.map.getCamera();\n const zoom = Math.max(0, Math.min(Math.floor(camera.zoom), 24));\n const ground = this.ground && this.map.hasLayer(this.ground) ? this.map.engine.wantedTiles(this.ground.id) : [];\n const keys: string[] = [];\n\n if (ground.length > 0) {\n // The ground's tiles, the nearest first: a tile so many levels coarser than the finest in view has its\n // labels of a zoom as many under the view's, past the source's deepest level those of that level at the zoom\n const groundTiles = Array.from({ length: Math.ceil(ground.length / 3) }, (_, k): [number, number, number] => [\n ground[3 * k] ?? 0,\n ground[3 * k + 1] ?? 0,\n ground[3 * k + 2] ?? 0,\n ]);\n const top = groundTiles.reduce((t, [z]) => Math.max(t, z), 0);\n\n groundTiles.forEach(([z, x, y]) => {\n if (keys.length >= maxTiles) return;\n\n const at = Math.max(0, zoom - (top - z));\n const tz = Math.min(at, maxzoom, z);\n const shift = 2 ** (z - tz);\n const key = `${tz}/${Math.floor(x / shift)}/${Math.floor(y / shift)}${at > tz ? `@${at}` : ''}`;\n\n if (!keys.includes(key)) keys.push(key);\n });\n } else {\n const z = Math.min(zoom, maxzoom);\n const wanted = tilesAround(this.map, camera, z, maxTiles);\n\n // Past the source's deepest level, its tiles' labels at the zoom of the view (the layers of the deeper zooms)\n keys.push(...wanted.map(([x, y]) => `${z}/${x}/${y}${zoom > z ? `@${zoom}` : ''}`));\n }\n\n // The same tiles as the labels shown: nothing to do\n const set = keys.join(' ');\n\n if (set === shown) return;\n\n const lists = await Promise.all(\n keys.map((k, index) => {\n const cached = tiles.get(k);\n\n if (cached) return cached;\n\n const [tile, deeper] = k.split('@');\n const [tz = 0, x = 0, y = 0] = (tile ?? '').split('/').map(Number);\n // The nearest tiles first: the others wait for the raster tiles\n const priority: Priority = index < 4 ? 'auto' : 'low';\n const work: BasemapWork = {\n type: 'labels',\n key,\n z: tz,\n x,\n y,\n priority,\n ...(deeper === undefined ? {} : { zoom: Number(deeper) }),\n };\n const p = this.request(tz, x, y, work).then(\n (r) => tileLabels('labels' in r ? r.labels : []),\n () => {\n // A network error is not kept: the tile is asked for again on the next update\n tiles.delete(k);\n\n return [];\n },\n );\n\n // A bounded cache of tiles' labels, the least recently used dropped\n tiles.set(k, p);\n\n return p;\n }),\n );\n\n if (run !== generation || this.destroyed) return;\n // A tile that failed is missing: the next update asks for it again, after a pause if no move brings one\n shown = keys.every((k) => tiles.has(k)) ? set : '';\n if (shown === '' && !retry) {\n retry = window.setTimeout(() => {\n retry = 0;\n refresh();\n }, RETRY_LABELS_MS);\n }\n\n // The labels of the higher style layers first: they win the collisions; for each style layer, the tiles nearest\n // to the center first\n const layerIds = [...new Set(lists.flatMap((list) => list.map(([layer]) => layer)))].sort((a, b) => b - a);\n const groups = layerIds.flatMap((layer) =>\n lists.map((list) => list.find(([l]) => l === layer)?.[1]).filter((group) => group !== undefined),\n );\n\n symbol.setGroups(groups);\n };\n // The style failed to load: reported by `ready`\n const refresh = () => {\n update().catch(() => undefined);\n };\n let timer = 0;\n const schedule = () => {\n if (timer) return;\n timer = window.setTimeout(() => {\n timer = 0;\n refresh();\n }, 250);\n };\n\n this.cleanup.push(this.map.on('move', schedule), this.map.on('moveend', refresh), () => {\n clearTimeout(timer);\n clearTimeout(retry);\n });\n refresh();\n\n return symbol;\n }\n\n /**\n * Makes a layer's tiles follow the view: `update` now and where the camera stops (`moveend`), `moving` every\n * `VECTOR_MOVE_REFRESH_MS` while it moves; the requests `held` aborted when destroyed\n */\n private followView(update: () => Promise<unknown>, held: Map<string, AbortController>, moving: () => unknown): void {\n const refresh = () => {\n update().catch(() => undefined);\n };\n const pace = { timer: 0 };\n const follow = () => {\n if (pace.timer) return;\n pace.timer = window.setTimeout(() => {\n pace.timer = 0;\n Promise.resolve(moving()).catch(() => undefined);\n }, VECTOR_MOVE_REFRESH_MS);\n };\n\n this.cleanup.push(this.map.on('move', follow), this.map.on('moveend', refresh), () => {\n clearTimeout(pace.timer);\n held.forEach((controller) => {\n controller.abort();\n });\n held.clear();\n });\n refresh();\n }\n\n /** Stops its workers' work and removes its raster and label layers from the map (those still there) */\n destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.cleanup.forEach((off) => {\n off();\n });\n this.cleanup.length = 0;\n this.layers.forEach((layer) => {\n if (this.map.hasLayer(layer)) layer.remove();\n });\n this.layers.length = 0;\n this.map.dropVectorTiles(this);\n // The page's copy of the sprites (the workers have theirs), and their icons\n this.sprites\n ?.then((sprites) => {\n sprites.forEach((sprite) => {\n sprite.image.close();\n });\n this.map.icons.remove(this.iconPrefix, true);\n })\n .catch(() => undefined);\n if (this.ownPool) {\n this.pool.terminate();\n } else {\n // Shared workers: only its requests stop and its renderers go\n this.pool.cancel(this);\n this.renderers.forEach((key) => {\n this.pool.broadcast({ type: 'drop', key });\n });\n }\n this.renderers.length = 0;\n }\n}\n\n/**\n * A `line-dasharray` as the engine takes it: two dashes and gaps in line widths (an odd count repeated, as the\n * canvas's `setLineDash`; past four, the first four), zeros for a solid line\n */\nexport const dashes = (value: Json | undefined, zoom: number): [number, number, number, number] => {\n const v = isExpression(value) ? evaluate(value, { zoom, properties: {}, type: 'Unknown' }) : value;\n const list = Array.isArray(v) ? v.map(Number).filter((d) => Number.isFinite(d) && d >= 0) : [];\n const even = list.length % 2 === 1 ? [...list, ...list] : list;\n const [a = 0, b = 0, c = 0, d = 0] = even.length >= 2 && even.some((x) => x > 0) ? even : [];\n\n return [a, b, c, d];\n};\n\n/** Metres around the view's center where every tree is drawn at zoom 16 (twice as far a zoom level out) */\nconst TREES_NEAR_METRES = 350;\n\n/** Whether a style layer draws streets, which glow at night: its id names a road (OpenMapTiles' styles, PLAN IGN's),\n * not its casing, a railway, a path or a tunnel */\nconst isStreet = (layer: StyleLayer): boolean =>\n /road|highway|street|motorway|trunk|primary|secondary|tertiary|minor|routier/i.test(layer.id) &&\n !/casing|outline|rail|path|track|ferry|tunnel|pier|area|pattern|label/i.test(layer.id);\n\n/** A `line-cap` as the engine draws it, at the camera's zoom (MapLibre's default: butt) */\nconst lineCap = (value: Json | undefined, zoom: number): 'butt' | 'round' | 'square' => {\n const v = isExpression(value) ? evaluate(value, { zoom, properties: {}, type: 'Unknown' }) : value;\n\n return v === 'round' || v === 'square' ? v : 'butt';\n};\n\n/** The deepest level `vectors()` cuts its tiles at: past the source's deepest level, its tiles cut again into deeper\n * ones (overzoom, as MapLibre does) down to level 18, their filters and styles those of their level, smaller tiles\n * drawn in a closer view; past it, the tiles of that level stretched */\nconst OVERZOOM_LEVEL = 18;\n\n/** The deepest level of the tiles of `vectors()` over a source whose deepest is `maxzoom` */\nconst deepestLevel = (maxzoom: number): number => Math.max(maxzoom, OVERZOOM_LEVEL);\n\n/** Milliseconds between two updates of the tiles of `vectors()` while the camera moves */\nconst VECTOR_MOVE_REFRESH_MS = 250;\n"]}
@@ -3,12 +3,12 @@ import type { TileGrid } from './grid.ts';
3
3
  * The tile grid of `layer` in the capabilities document `xml`: its tile matrix set `matrixSet` (default the layer's
4
4
  * first), with the layer's tile limits and longitude-latitude extent. Throws if the layer or the set is missing
5
5
  */
6
- export declare function parseWmtsGrid(xml: string, layer: string, matrixSet?: string): TileGrid;
6
+ export declare const parseWmtsGrid: (xml: string, layer: string, matrixSet?: string) => TileGrid;
7
7
  /**
8
8
  * The tile grid of a WMTS layer, from the service's capabilities at `capabilities` (fetched with CORS), for
9
9
  * `addRaster`: `await wmtsGrid('https://…/wmts?SERVICE=WMTS&REQUEST=GetCapabilities', 'LAYER', 'MATRIXSET')`. The
10
10
  * raster's URL writes the matrix set, {z} for the matrix, {x} and {y} for the column and the row
11
11
  */
12
- export declare function wmtsGrid(capabilities: string | URL, layer: string, matrixSet?: string, options?: {
12
+ export declare const wmtsGrid: (capabilities: string | URL, layer: string, matrixSet?: string, options?: {
13
13
  signal?: AbortSignal;
14
- }): Promise<TileGrid>;
14
+ }) => Promise<TileGrid>;
@@ -14,7 +14,7 @@ const numbers = (text) => (text ?? '').trim().split(/\s+/).map(Number);
14
14
  * The tile grid of `layer` in the capabilities document `xml`: its tile matrix set `matrixSet` (default the layer's
15
15
  * first), with the layer's tile limits and longitude-latitude extent. Throws if the layer or the set is missing
16
16
  */
17
- export function parseWmtsGrid(xml, layer, matrixSet) {
17
+ export const parseWmtsGrid = (xml, layer, matrixSet) => {
18
18
  const contents = child(parseXml(xml), 'Contents');
19
19
  const entry = children(contents, 'Layer').find((l) => childText(l, 'Identifier') === layer);
20
20
  if (!entry)
@@ -31,10 +31,15 @@ export function parseWmtsGrid(xml, layer, matrixSet) {
31
31
  const latFirst = geographic && epsgCode(crs) === 4326 && /EPSG/i.test(crs);
32
32
  const unit = geographic ? METRES_PER_DEGREE : 1;
33
33
  const limits = new Map();
34
- for (const l of children(child(link, 'TileMatrixSetLimits'), 'TileMatrixLimits')) {
35
- const [minRow, maxRow, minCol, maxCol] = ['MinTileRow', 'MaxTileRow', 'MinTileCol', 'MaxTileCol'].map((k) => Number(childText(l, k)));
36
- limits.set(childText(l, 'TileMatrix') ?? '', [minCol, minRow, maxCol, maxRow]);
37
- }
34
+ children(child(link, 'TileMatrixSetLimits'), 'TileMatrixLimits').forEach((l) => {
35
+ const limit = (k) => Number(childText(l, k));
36
+ limits.set(childText(l, 'TileMatrix') ?? '', [
37
+ limit('MinTileCol'),
38
+ limit('MinTileRow'),
39
+ limit('MaxTileCol'),
40
+ limit('MaxTileRow'),
41
+ ]);
42
+ });
38
43
  const matrices = children(set, 'TileMatrix').map((m) => {
39
44
  const id = childText(m, 'Identifier') ?? '';
40
45
  const [a = 0, b = 0] = numbers(childText(m, 'TopLeftCorner'));
@@ -53,25 +58,25 @@ export function parseWmtsGrid(xml, layer, matrixSet) {
53
58
  // A layer's limits leave out the matrices it does not have
54
59
  const served = limits.size > 0 ? matrices.filter((m) => limits.has(String(m.id))) : matrices;
55
60
  const box = child(entry, 'WGS84BoundingBox');
56
- const [west, south] = numbers(childText(box, 'LowerCorner'));
57
- const [east, north] = numbers(childText(box, 'UpperCorner'));
61
+ const [west = Number.NaN, south = Number.NaN] = numbers(childText(box, 'LowerCorner'));
62
+ const [east = Number.NaN, north = Number.NaN] = numbers(childText(box, 'UpperCorner'));
58
63
  const bounds = [west, south, east, north];
59
64
  return {
60
65
  crs,
61
66
  matrices: served,
62
67
  name,
63
- ...(bounds.every(Number.isFinite) ? { bounds: bounds } : {}),
68
+ ...(bounds.every(Number.isFinite) ? { bounds } : {}),
64
69
  };
65
- }
70
+ };
66
71
  /**
67
72
  * The tile grid of a WMTS layer, from the service's capabilities at `capabilities` (fetched with CORS), for
68
73
  * `addRaster`: `await wmtsGrid('https://…/wmts?SERVICE=WMTS&REQUEST=GetCapabilities', 'LAYER', 'MATRIXSET')`. The
69
74
  * raster's URL writes the matrix set, {z} for the matrix, {x} and {y} for the column and the row
70
75
  */
71
- export async function wmtsGrid(capabilities, layer, matrixSet, options = {}) {
76
+ export const wmtsGrid = async (capabilities, layer, matrixSet, options = {}) => {
72
77
  const response = await fetch(capabilities, withHeaders(capabilities, options.signal ? { signal: options.signal } : {}));
73
78
  if (!response.ok)
74
79
  throw new Error(`isard: ${response.status} for the WMTS capabilities`);
75
80
  return parseWmtsGrid(await response.text(), layer, matrixSet);
76
- }
81
+ };
77
82
  //# sourceMappingURL=wmts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wmts.js","sourceRoot":"","sources":["../../src/basemap/wmts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,2FAA2F;AAC3F,MAAM,iBAAiB,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC;AACxD,0FAA0F;AAC1F,MAAM,KAAK,GAAG,OAAO,CAAC;AAEtB,MAAM,OAAO,GAAG,CAAC,IAAwB,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAE3F;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,KAAa,EAAE,SAAkB;IAC1E,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,KAAK,KAAK,CAAC,CAAC;IAC5F,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EAC1B,KAAa,EACb,SAAkB,EAClB,UAAoC,EAAE;IAEtC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,YAAY,EACZ,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC5E,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,QAAQ,CAAC,MAAM,4BAA4B,CAAC,CAAC;IACzF,OAAO,aAAa,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAChE,CAAC","sourcesContent":["/**\n * The tile grid of a WMTS layer, read from the service's capabilities: its tile matrix set (CRS, levels, origin, tile\n * sizes), the layer's limits in it and its extent, for `addRaster({ url, grid })`.\n */\nimport { epsgCode, isGeographic } from '../data/crs.ts';\nimport { child, children, childText, parseXml } from '../data/xml.ts';\nimport { withHeaders } from '../engine/requests.ts';\nimport type { TileGrid, TileMatrix } from './grid.ts';\n\n/** Metres per degree, as WMTS counts the scale of a grid in degrees (OGC 07-057r7, 6.1) */\nconst METRES_PER_DEGREE = (2 * Math.PI * 6378137) / 360;\n/** The size of a pixel by which WMTS turns scale denominators into resolutions, metres */\nconst PIXEL = 0.00028;\n\nconst numbers = (text: string | undefined) => (text ?? '').trim().split(/\\s+/).map(Number);\n\n/**\n * The tile grid of `layer` in the capabilities document `xml`: its tile matrix set `matrixSet` (default the layer's\n * first), with the layer's tile limits and longitude-latitude extent. Throws if the layer or the set is missing\n */\nexport function parseWmtsGrid(xml: string, layer: string, matrixSet?: string): TileGrid {\n const contents = child(parseXml(xml), 'Contents');\n const entry = children(contents, 'Layer').find((l) => childText(l, 'Identifier') === layer);\n if (!entry) throw new Error(`isard: no WMTS layer ${layer}`);\n const links = children(entry, 'TileMatrixSetLink');\n const link = matrixSet === undefined ? links[0] : links.find((l) => childText(l, 'TileMatrixSet') === matrixSet);\n const name = childText(link, 'TileMatrixSet');\n const set = children(contents, 'TileMatrixSet').find((s) => childText(s, 'Identifier') === name);\n if (!name || !set) throw new Error(`isard: no tile matrix set ${matrixSet ?? ''} for the WMTS layer ${layer}`);\n const crs = childText(set, 'SupportedCRS') ?? '';\n const geographic = isGeographic(crs);\n // EPSG's geographic CRSs have their latitude first (CRS:84 and the IGN's WGS84G do not)\n const latFirst = geographic && epsgCode(crs) === 4326 && /EPSG/i.test(crs);\n const unit = geographic ? METRES_PER_DEGREE : 1;\n const limits = new Map<string, TileMatrix['limits']>();\n for (const l of children(child(link, 'TileMatrixSetLimits'), 'TileMatrixLimits')) {\n const [minRow, maxRow, minCol, maxCol] = ['MinTileRow', 'MaxTileRow', 'MinTileCol', 'MaxTileCol'].map((k) =>\n Number(childText(l, k)),\n ) as [number, number, number, number];\n limits.set(childText(l, 'TileMatrix') ?? '', [minCol, minRow, maxCol, maxRow]);\n }\n const matrices = children(set, 'TileMatrix').map((m): TileMatrix => {\n const id = childText(m, 'Identifier') ?? '';\n const [a = 0, b = 0] = numbers(childText(m, 'TopLeftCorner'));\n const limit = limits.get(id);\n return {\n id,\n resolution: (Number(childText(m, 'ScaleDenominator')) * PIXEL) / unit,\n origin: latFirst ? [b, a] : [a, b],\n tileWidth: Number(childText(m, 'TileWidth') ?? 256),\n tileHeight: Number(childText(m, 'TileHeight') ?? 256),\n matrixWidth: Number(childText(m, 'MatrixWidth') ?? Infinity),\n matrixHeight: Number(childText(m, 'MatrixHeight') ?? Infinity),\n ...(limit ? { limits: limit } : {}),\n };\n });\n // A layer's limits leave out the matrices it does not have\n const served = limits.size > 0 ? matrices.filter((m) => limits.has(String(m.id))) : matrices;\n const box = child(entry, 'WGS84BoundingBox');\n const [west, south] = numbers(childText(box, 'LowerCorner'));\n const [east, north] = numbers(childText(box, 'UpperCorner'));\n const bounds = [west, south, east, north];\n return {\n crs,\n matrices: served,\n name,\n ...(bounds.every(Number.isFinite) ? { bounds: bounds as [number, number, number, number] } : {}),\n };\n}\n\n/**\n * The tile grid of a WMTS layer, from the service's capabilities at `capabilities` (fetched with CORS), for\n * `addRaster`: `await wmtsGrid('https://…/wmts?SERVICE=WMTS&REQUEST=GetCapabilities', 'LAYER', 'MATRIXSET')`. The\n * raster's URL writes the matrix set, {z} for the matrix, {x} and {y} for the column and the row\n */\nexport async function wmtsGrid(\n capabilities: string | URL,\n layer: string,\n matrixSet?: string,\n options: { signal?: AbortSignal } = {},\n): Promise<TileGrid> {\n const response = await fetch(\n capabilities,\n withHeaders(capabilities, options.signal ? { signal: options.signal } : {}),\n );\n if (!response.ok) throw new Error(`isard: ${response.status} for the WMTS capabilities`);\n return parseWmtsGrid(await response.text(), layer, matrixSet);\n}\n"]}
1
+ {"version":3,"file":"wmts.js","sourceRoot":"","sources":["../../src/basemap/wmts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,2FAA2F;AAC3F,MAAM,iBAAiB,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC;AACxD,0FAA0F;AAC1F,MAAM,KAAK,GAAG,OAAO,CAAC;AAEtB,MAAM,OAAO,GAAG,CAAC,IAAwB,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAE3F;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,SAAkB,EAAY,EAAE;IACxF,MAA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AAE,KAAK,CAAC,CAAC;IAE5E,OAAO;QACL,GAAG;QACH,QAAQ,EAAE,MAAM;QAChB,IAAI;QACJ,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrD,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,YAA0B,EAC1B,KAAa,EACb,SAAkB,EAClB,UAAoC,EAAE,EACnB,EAAE;IACrB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,YAAY,EACZ,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC5E,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,QAAQ,CAAC,MAAM,4BAA4B,CAAC,CAAC;IAEzF,OAAO,aAAa,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAChE,CAAC,CAAC","sourcesContent":["/**\n * The tile grid of a WMTS layer, read from the service's capabilities: its tile matrix set (CRS, levels, origin, tile\n * sizes), the layer's limits in it and its extent, for `addRaster({ url, grid })`.\n */\nimport { epsgCode, isGeographic } from '../data/crs.ts';\nimport { child, children, childText, parseXml } from '../data/xml.ts';\nimport { withHeaders } from '../engine/requests.ts';\nimport type { TileGrid, TileMatrix } from './grid.ts';\n\n/** Metres per degree, as WMTS counts the scale of a grid in degrees (OGC 07-057r7, 6.1) */\nconst METRES_PER_DEGREE = (2 * Math.PI * 6378137) / 360;\n/** The size of a pixel by which WMTS turns scale denominators into resolutions, metres */\nconst PIXEL = 0.00028;\n\nconst numbers = (text: string | undefined) => (text ?? '').trim().split(/\\s+/).map(Number);\n\n/**\n * The tile grid of `layer` in the capabilities document `xml`: its tile matrix set `matrixSet` (default the layer's\n * first), with the layer's tile limits and longitude-latitude extent. Throws if the layer or the set is missing\n */\nexport const parseWmtsGrid = (xml: string, layer: string, matrixSet?: string): TileGrid => {\n const contents = child(parseXml(xml), 'Contents');\n const entry = children(contents, 'Layer').find((l) => childText(l, 'Identifier') === layer);\n\n if (!entry) throw new Error(`isard: no WMTS layer ${layer}`);\n\n const links = children(entry, 'TileMatrixSetLink');\n const link = matrixSet === undefined ? links[0] : links.find((l) => childText(l, 'TileMatrixSet') === matrixSet);\n const name = childText(link, 'TileMatrixSet');\n const set = children(contents, 'TileMatrixSet').find((s) => childText(s, 'Identifier') === name);\n\n if (!name || !set) throw new Error(`isard: no tile matrix set ${matrixSet ?? ''} for the WMTS layer ${layer}`);\n\n const crs = childText(set, 'SupportedCRS') ?? '';\n const geographic = isGeographic(crs);\n // EPSG's geographic CRSs have their latitude first (CRS:84 and the IGN's WGS84G do not)\n const latFirst = geographic && epsgCode(crs) === 4326 && /EPSG/i.test(crs);\n const unit = geographic ? METRES_PER_DEGREE : 1;\n const limits = new Map<string, TileMatrix['limits']>();\n\n children(child(link, 'TileMatrixSetLimits'), 'TileMatrixLimits').forEach((l) => {\n const limit = (k: string) => Number(childText(l, k));\n\n limits.set(childText(l, 'TileMatrix') ?? '', [\n limit('MinTileCol'),\n limit('MinTileRow'),\n limit('MaxTileCol'),\n limit('MaxTileRow'),\n ]);\n });\n\n const matrices = children(set, 'TileMatrix').map((m): TileMatrix => {\n const id = childText(m, 'Identifier') ?? '';\n const [a = 0, b = 0] = numbers(childText(m, 'TopLeftCorner'));\n const limit = limits.get(id);\n\n return {\n id,\n resolution: (Number(childText(m, 'ScaleDenominator')) * PIXEL) / unit,\n origin: latFirst ? [b, a] : [a, b],\n tileWidth: Number(childText(m, 'TileWidth') ?? 256),\n tileHeight: Number(childText(m, 'TileHeight') ?? 256),\n matrixWidth: Number(childText(m, 'MatrixWidth') ?? Infinity),\n matrixHeight: Number(childText(m, 'MatrixHeight') ?? Infinity),\n ...(limit ? { limits: limit } : {}),\n };\n });\n // A layer's limits leave out the matrices it does not have\n const served = limits.size > 0 ? matrices.filter((m) => limits.has(String(m.id))) : matrices;\n const box = child(entry, 'WGS84BoundingBox');\n const [west = Number.NaN, south = Number.NaN] = numbers(childText(box, 'LowerCorner'));\n const [east = Number.NaN, north = Number.NaN] = numbers(childText(box, 'UpperCorner'));\n const bounds: [number, number, number, number] = [west, south, east, north];\n\n return {\n crs,\n matrices: served,\n name,\n ...(bounds.every(Number.isFinite) ? { bounds } : {}),\n };\n};\n\n/**\n * The tile grid of a WMTS layer, from the service's capabilities at `capabilities` (fetched with CORS), for\n * `addRaster`: `await wmtsGrid('https://…/wmts?SERVICE=WMTS&REQUEST=GetCapabilities', 'LAYER', 'MATRIXSET')`. The\n * raster's URL writes the matrix set, {z} for the matrix, {x} and {y} for the column and the row\n */\nexport const wmtsGrid = async (\n capabilities: string | URL,\n layer: string,\n matrixSet?: string,\n options: { signal?: AbortSignal } = {},\n): Promise<TileGrid> => {\n const response = await fetch(\n capabilities,\n withHeaders(capabilities, options.signal ? { signal: options.signal } : {}),\n );\n\n if (!response.ok) throw new Error(`isard: ${response.status} for the WMTS capabilities`);\n\n return parseWmtsGrid(await response.text(), layer, matrixSet);\n};\n"]}
@@ -0,0 +1,17 @@
1
+ /** The pool of basemap workers the vector tiles share: a vector tile always goes to the same worker (its decoded copy
2
+ * kept there), the requests of an owner cancelled together, the renderers broadcast to every worker */
3
+ import type { Camera } from '../wasm/isard.js';
4
+ import type { Priority } from '../workers/basemap.worker.ts';
5
+ /** Default size of a basemap worker pool: cores - 1, 1 to 4 */
6
+ export declare const defaultWorkerCount: () => number;
7
+ /** Default URL of the basemap worker: in the page's assets folder (`isard/vite`), else next to the module */
8
+ export declare const defaultWorkerUrl: (assetsUrl?: string | URL) => string | URL;
9
+ /** Fetch priority of a raster tile drawn by the workers: 'high' near the center of the view, at the current zoom or
10
+ * coarser; 'low' far from it or finer (prefetch); 'auto' between */
11
+ export declare const tilePriority: (z: number, x: number, y: number, camera: Pick<Camera, "center" | "zoom">) => Priority;
12
+ /** The worker of a vector tile among `count`: always the same one */
13
+ export declare const workerIndex: (vz: number, vx: number, vy: number, count: number) => number;
14
+ /** The worker-side key of a renderer: unique across the `VectorTiles` sharing a pool */
15
+ export declare const rendererKey: (namespace: string, n: number) => string;
16
+ /** What the pool needs of a worker (a `Worker`, or a stand-in in tests) */
17
+ export type PoolWorker = Pick<Worker, 'postMessage' | 'terminate' | 'onmessage' | 'onerror' | 'onmessageerror'>;