isard 2.0.0 → 2.1.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 (58) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +1 -1
  3. package/dist/basemap/vectortiles/vectors.d.ts +3 -1
  4. package/dist/basemap/vectortiles/vectors.js +2 -0
  5. package/dist/basemap/vectortiles/vectors.js.map +1 -1
  6. package/dist/basemap/vectortiles.d.ts +1 -3
  7. package/dist/basemap/vectortiles.js +1 -3
  8. package/dist/basemap/vectortiles.js.map +1 -1
  9. package/dist/bind/layers.js +2 -2
  10. package/dist/bind/layers.js.map +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/isard_webgl2_bg.wasm +0 -0
  14. package/dist/isard_webgpu_bg.wasm +0 -0
  15. package/dist/layers/extrusions.d.ts +6 -1
  16. package/dist/layers/extrusions.js +15 -4
  17. package/dist/layers/extrusions.js.map +1 -1
  18. package/dist/layers/ground.d.ts +1 -1
  19. package/dist/layers/ground.js +1 -1
  20. package/dist/layers/ground.js.map +1 -1
  21. package/dist/layers/layers.js +1 -1
  22. package/dist/layers/layers.js.map +1 -1
  23. package/dist/layers/models.d.ts +7 -1
  24. package/dist/layers/models.js +19 -1
  25. package/dist/layers/models.js.map +1 -1
  26. package/dist/layers/pointclouds.d.ts +2 -2
  27. package/dist/layers/pointclouds.js +3 -3
  28. package/dist/layers/pointclouds.js.map +1 -1
  29. package/dist/layers/raster.js +5 -0
  30. package/dist/layers/raster.js.map +1 -1
  31. package/dist/layers/tiles3d.d.ts +4 -6
  32. package/dist/layers/tiles3d.js +9 -14
  33. package/dist/layers/tiles3d.js.map +1 -1
  34. package/dist/layers/vectors.d.ts +6 -0
  35. package/dist/layers/vectors.js +18 -1
  36. package/dist/layers/vectors.js.map +1 -1
  37. package/dist/map/engine-settings.d.ts +4 -1
  38. package/dist/map/engine-settings.js +13 -2
  39. package/dist/map/engine-settings.js.map +1 -1
  40. package/dist/map/layer-stack.d.ts +5 -6
  41. package/dist/map/layer-stack.js +5 -6
  42. package/dist/map/layer-stack.js.map +1 -1
  43. package/dist/map.d.ts +22 -9
  44. package/dist/map.js +52 -16
  45. package/dist/map.js.map +1 -1
  46. package/dist/react/VectorGeometry.d.ts +4 -1
  47. package/dist/react/VectorGeometry.js +5 -1
  48. package/dist/react/VectorGeometry.js.map +1 -1
  49. package/dist/settings.d.ts +2 -0
  50. package/dist/settings.js +1 -1
  51. package/dist/settings.js.map +1 -1
  52. package/dist/types.d.ts +23 -4
  53. package/dist/types.js.map +1 -1
  54. package/dist/wasm/isard_webgl2.d.ts +21 -7
  55. package/dist/wasm/isard_webgl2.js +42 -21
  56. package/dist/wasm/isard_webgpu.d.ts +21 -7
  57. package/dist/wasm/isard_webgpu.js +42 -21
  58. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,38 @@ versions [Semantic Versioning](https://semver.org) (before 1.0.0, a minor versio
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [2.1.0] - 2026-10-31
9
+
10
+ With `isard-react-native` and `isard-map` (Python) 2.1.0.
11
+
12
+ ### Added
13
+
14
+ - Rasters draped on extrusions and on a vector basemap's buildings: `drape: { raster, faces, opacity }` in
15
+ `addExtrusions`, `vectorTiles().vectors()` and `vectorTiles().extrusions()` (or `setDrape`) lays a raster layer on
16
+ the roofs, or every face, as on 3D Tiles: an ortho on the city, a solar potential on the roofs. In React,
17
+ `<Geometry drape>` and `<Layer type="extrusions" drape>`. The An ortho on the city's roofs example (TypeScript,
18
+ React, Python, React Native).
19
+ - Rasters draped on glTF models: `drape` in `addModels` (or `setDrape`), on the faces looking up or every face, read
20
+ over the instances' footprint; in React, `<Layer type="models" drape>`. The A BIM building example drapes the
21
+ orthophotos on its building by buttons (TypeScript, React, Python, React Native).
22
+ - A GPU memory budget for the map: `memory` (megabytes; `'auto'`, the default, 256 on a touch screen and 1024
23
+ elsewhere) shared by the 3D Tiles' meshes, the point clouds' nodes and the rasters' pools; past it the tiles drawn
24
+ least recently are unloaded, whichever their layer. `map.memory()` says what each layer holds.
25
+ - `bun run port` loads isard from the local build where a page loads it from jsDelivr (the React Native examples), as
26
+ the visual tests do.
27
+
28
+ ### Changed
29
+
30
+ - `Tiles3dDrape` is `Drape`: the same raster draped on 3D Tiles, extrusions, a basemap's buildings and models.
31
+ - A 3D Tiles layer no longer keeps 512 MB of meshes of its own, nor a point cloud twice its point budget's vertices:
32
+ they share the map's `memory`, as the rasters' pools do.
33
+
34
+ ### Fixed
35
+
36
+ - The map is made again when its WebGPU device is lost (a phone taking its memory back, a driver reset, the GPU process
37
+ gone), as it was on a WebGL2 context lost: a new device asked for at once, its layers in their order with the same
38
+ handles, custom layers' `onAdd` again. A lost device left the map still.
39
+
8
40
  ## [2.0.0] - 2026-10-30
9
41
 
10
42
  With `isard-react-native` and `isard-map` (Python) 2.0.0: the three now share their version.
package/README.md CHANGED
@@ -186,7 +186,7 @@ More in [Develop and release](https://ideal-adventure-zqn6y6p.pages.github.io/gu
186
186
 
187
187
  By priority:
188
188
 
189
- - **P1**, next: rasters draped on the buildings.
189
+ - **P1**, next: the memory budget measured on a phone (a phone closes a page past about a gigabyte).
190
190
  - **P2**, then: rasters draped within an area; a clipping volume; a performance report.
191
191
  - **P3**, later: objects moving along paths; video in the scene.
192
192
  - **P4**, when time allows: the whole MapLibre style drawn as vectors, a 3D vector map to walk through, Panoramax's
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { Icons } from '../../layers/icons.ts';
6
6
  import type { VectorLayer } from '../../layers/vectors.ts';
7
- import type { Placement, Tiles3dOptions } from '../../types.ts';
7
+ import type { Drape, Placement, Tiles3dOptions } from '../../types.ts';
8
8
  import type { RoofMode } from '../../util/roofs.ts';
9
9
  import { type Json, type StyleLayer } from '../vectorstyle.ts';
10
10
  import type { VectorTilesContext } from './context.ts';
@@ -31,6 +31,8 @@ export interface VectorsOptions extends Placement {
31
31
  roofs?: RoofMode;
32
32
  /** The buildings' walls show their windows: glass by day, some lit at night (default false: only the lit ones) */
33
33
  facades?: boolean;
34
+ /** A raster layer draped on the buildings' roofs (`setDrape`): an ortho on the city; on the 3D buildings too */
35
+ drape?: Drape | undefined;
34
36
  /**
35
37
  * 3D buildings in place of the style's raised ones where they have some: a 3D Tiles tileset (`batiments3d()`: the
36
38
  * IGN's Bâtiments 3D over France) drawn with the layer, removed and moved with it (its `companions`); the style's
@@ -91,6 +91,8 @@ export const vectors = (context, options = {}) => {
91
91
  vector.companions.push(buildings);
92
92
  vector.buildings3d = buildings;
93
93
  vector.setFacades(facades);
94
+ if (options.drape)
95
+ vector.setDrape(options.drape);
94
96
  const state = { renderer: context.renderer((l) => vectorKind(l) !== undefined && layers(l), []), update: 0, style: 0 };
95
97
  state.renderer.catch(() => undefined);
96
98
  /** The style's sprites among the map's icons, if a layer drawn has a pattern: waited for before the first tiles */
@@ -1 +1 @@
1
- {"version":3,"file":"vectors.js","sourceRoot":"","sources":["../../../src/basemap/vectortiles/vectors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAA8B,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAmB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE/F;;wEAEwE;AACxE,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,6FAA6F;AAC7F,MAAM,YAAY,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC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CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC,CAAC;IACF,MAAM,CAAC,KAAK,GAAG,GAAG,EAAE;QAClB,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IACF,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;QACvD,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YAAE,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IACH,kCAAkC;IAClC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAErC,kHAAkH;IAClH,mBAAmB;IACnB,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * The vector layer of a vector basemap (`VectorTiles.vectors`): its fills, lines and buildings cut by the workers\n * into geometry the engine draws, the tiles following the view, and how its style layers are read for the engine.\n */\n\nimport { tilesetCoverage } from '../../data/tileset.ts';\nimport type { Icons } from '../../layers/icons.ts';\nimport type { VectorLayer, VectorSublayer } from '../../layers/vectors.ts';\nimport type { Placement, Tiles3dOptions } from '../../types.ts';\nimport { latitude, longitude } from '../../util/geo.ts';\nimport type { RoofMode } from '../../util/roofs.ts';\nimport { FLOATS, STYLE } from '../../util/style-floats.ts';\nimport type { BasemapWork, Priority } from '../../workers/basemap/protocol.ts';\nimport { evaluate, isExpression, type Json, type StyleLayer, vectorKind, zoomOnly } from '../vectorstyle.ts';\nimport type { Renderer, VectorTilesContext } from './context.ts';\nimport { TileRequests } from './requests.ts';\nimport { nearPriority, parseTileKey, type TileTriple, tileKey, tileTriples } from './tiles.ts';\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 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/** A layout or paint value at a zoom, whatever the feature (an expression evaluated) */\nconst atZoom = (value: Json | undefined, zoom: number): unknown =>\n isExpression(value) ? evaluate(value, { zoom, properties: {}, type: 'Unknown' }) : value;\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 = atZoom(value, zoom);\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/** 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 */\nexport const 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 = atZoom(value, zoom);\n\n return v === 'round' || v === 'square' ? v : 'butt';\n};\n\n/** A `line-join` as the engine draws it, at the camera's zoom (MapLibre's default: miter) */\nconst lineJoin = (value: Json | undefined, zoom: number): 'miter' | 'bevel' | 'round' => {\n const v = atZoom(value, zoom);\n\n return v === 'round' || v === 'bevel' ? v : 'miter';\n};\n\n/** A `line-miter-limit` at the camera's zoom (MapLibre's default: 2) */\nconst miterLimit = (value: Json | undefined, zoom: number): number => {\n const v = Number(atZoom(value, zoom) ?? 2);\n\n return Number.isFinite(v) ? v : 2;\n};\n\n/** A tile's styles with their patterns placed: each feature's pattern, as its index past one into `names`\n * (`STYLE.fillPattern`, `STYLE.linePattern`), replaced by its image's place in the icon atlas (texels) and pixel\n * ratio; none if the atlas has no such image; the atlas uploaded */\nexport const placePatterns = (\n styles: Float32Array,\n names: readonly string[] | undefined,\n icons: Icons,\n prefix: string,\n): Float32Array => {\n if (!names?.length) return styles;\n // Thousands of features a tile: a loop\n for (let f = 0; f + FLOATS <= styles.length; f += FLOATS) {\n const fill = styles[f + STYLE.fillPattern] ?? 0;\n const line = styles[f + STYLE.linePattern] ?? 0;\n const index = fill > 0 ? fill : line;\n\n if (index <= 0) continue;\n\n const icon = icons.get(prefix + (names[index - 1] ?? ''));\n const place = icon ? [icon.x, icon.y, icon.width, icon.height] : [0, 0, 0, 0];\n const ratio = icon?.pixelRatio ?? 0;\n\n if (fill > 0) styles.set([...place, ratio], f + STYLE.size + 4);\n else {\n styles.set(place, f + STYLE.second);\n styles[f + STYLE.patternRatio] = ratio;\n }\n }\n icons.flush();\n\n return styles;\n};\n\n/** The paint properties of the patterns `vectors()` draws, whose images come from the style's sprite */\nconst PATTERNS = ['fill-pattern', 'background-pattern', 'line-pattern', 'fill-extrusion-pattern'];\n\n/** A `fill-translate` or `line-translate` at the camera's zoom (CSS pixels; none if it is not two numbers) */\nexport const translation = (value: Json | undefined, zoom: number): [number, number] => {\n const v = atZoom(value, zoom);\n const [x, y] = Array.isArray(v) ? v.map(Number) : [];\n\n return Number.isFinite(x) && Number.isFinite(y) ? [x ?? 0, y ?? 0] : [0, 0];\n};\n\n/** The options of `VectorTiles.vectors` */\nexport interface VectorsOptions extends Placement {\n layers?: (layer: StyleLayer) => boolean;\n streets?: (layer: StyleLayer) => boolean;\n /** The buildings' roofs: from their data (`roof:shape`, `roof:height`; flat without, the default), generated from\n * their outline where they have none (hipped, gabled or mansard by size and shape), or all flat */\n roofs?: RoofMode;\n /** The buildings' walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades?: boolean;\n /**\n * 3D buildings in place of the style's raised ones where they have some: a 3D Tiles tileset (`batiments3d()`: the\n * IGN's Bâtiments 3D over France) drawn with the layer, removed and moved with it (its `companions`); the style's\n * buildings left out where the tileset's children cover (their boxes, read from its `tileset.json`, a child that is\n * a tileset of its own read when a tile meets it), kept elsewhere; their walls' windows with `facades`\n */\n buildings3d?: Tiles3dOptions;\n}\n\nexport const vectors = (context: VectorTilesContext, options: VectorsOptions = {}): VectorLayer => {\n const { map } = context;\n const { layers = () => true, streets = isStreet, before, roofs = 'data', facades = false } = options;\n const vector = map.addVectorLayer(before);\n // The 3D buildings over the layer's ground, and where they stand\n const buildings = options.buildings3d && map.addTiles3d({ ...options.buildings3d, ...(before && { before }) });\n const coverage = options.buildings3d && tilesetCoverage(options.buildings3d.url);\n\n if (buildings) vector.companions.push(buildings);\n vector.buildings3d = buildings;\n vector.setFacades(facades);\n const state: {\n renderer: Promise<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: context.renderer((l) => vectorKind(l) !== undefined && layers(l), []), update: 0, style: 0 };\n\n state.renderer.catch(() => undefined);\n\n /** The style's sprites among the map's icons, if a layer drawn has a pattern: waited for before the first tiles */\n const sprites = context.ready\n .then(({ style }) =>\n style.layers.some((l) => layers(l) && PATTERNS.some((k) => l.paint?.[k] !== undefined))\n ? context.addSprites()\n : undefined,\n )\n .catch(() => undefined);\n const placed = (styles: Float32Array, names: readonly string[] | undefined) =>\n placePatterns(styles, names, map.icons, context.iconPrefix);\n context.layers.push(vector);\n\n const sublayers = (list: StyleLayer[]): VectorSublayer[] => {\n const zoom = 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 join: lineJoin(l.layout?.['line-join'], zoom),\n miterLimit: miterLimit(l.layout?.['line-miter-limit'], zoom),\n translate: translation(l.paint?.[`${l.type}-translate`], zoom),\n translateAnchor: l.paint?.[`${l.type}-translate-anchor`] === 'viewport' ? 'viewport' : 'map',\n patterned: l.paint?.['fill-pattern'] !== undefined || l.paint?.['background-pattern'] !== undefined,\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 requests = new TileRequests();\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 = async (\n { key, maxzoom }: { key: string; maxzoom: number },\n [z, x, y]: TileTriple,\n styles: boolean,\n priority: Priority,\n signal?: AbortSignal,\n ) => {\n const d = Math.max(0, z - maxzoom);\n // Where the 3D buildings stand over the source's tile the worker cuts (none known: the style's buildings kept)\n const n = 2 ** (z - d);\n const [tx, ty] = [Math.floor(x / 2 ** d), Math.floor(y / 2 ** d)];\n const covered = await coverage\n ?.within([longitude(tx / n), latitude((ty + 1) / n), longitude((tx + 1) / n), latitude(ty / n)])\n .catch(() => undefined);\n const work: BasemapWork = {\n type: 'vectors',\n key,\n z,\n x,\n y,\n deepest: deepestLevel(maxzoom),\n roofs,\n ...(covered?.length ? { covered } : {}),\n priority,\n };\n\n // The geometry made ready for the GPU in the workers, with the prisms the relief needs\n return context.request(\n z - d,\n Math.floor(x / 2 ** d),\n Math.floor(y / 2 ** d),\n styles ? { ...work, styles } : { ...work, prism: 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 context.broadcast({ type: 'tess', url: map.tessUrl });\n /** Asks the workers again for the styles of a tile held, under the current style; the tile's geometry stays as it\n * is */\n const restyleTile = async (renderer: { key: string; maxzoom: number }, k: string) => {\n const r = await ask(renderer, parseTileKey(k), true, 'auto').catch(() => undefined);\n\n if (r && 'styles' in r) vector.setTileStyles(k, placed(r.styles, r.patterns));\n };\n const update = async () => {\n if (context.destroyed()) return;\n\n const generation = ++state.update;\n // The style the tiles are cut under: that of the renderer awaited, a restyle meanwhile (a paint property set as the\n // style loads) asking their styles again once they are there\n const style = state.style;\n const { key, maxzoom, layers: list } = await state.renderer;\n\n await sprites;\n\n vector.setSublayers(sublayers(state.own ?? list));\n\n const wanted = tileTriples(map.engine.vectorTilesInView(0, deepestLevel(maxzoom), map.quality.reach));\n const keys = new Set(wanted.map((t) => tileKey(...t)));\n const loads = wanted.flatMap((t, index) => {\n const k = tileKey(...t);\n\n if (requests.has(k)) return [];\n\n return [\n requests.ask(\n k,\n (signal) => ask({ key, maxzoom }, t, false, nearPriority(index, 'high', 'auto'), signal),\n async (r) => {\n if (!('vectors' in r)) return;\n await vector.setTile(k, { ...r.vectors, styles: placed(r.vectors.styles, r.vectors.patterns) });\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 ];\n });\n // Out of view: those still asked for go at once, those drawn once their replacements are there (no hole). The\n // drawn ones are those the engine shows, held or not (a recut forgets what it held, not what is drawn)\n const drop = (drawn: boolean) => {\n const shown = new Set(vector.tileKeys);\n const known = new Set([...requests.keys(), ...(drawn ? shown : [])]);\n\n known.forEach((k) => {\n if (keys.has(k) || shown.has(k) !== drawn) return;\n requests.drop(k);\n vector.removeTile(k);\n });\n };\n\n drop(false);\n // Every tile of the view, those an earlier update asked for too: a tile out of view stays drawn until all of them\n // are there\n await Promise.all([...loads, requests.answered(keys)]);\n // A later update (the view moved again meanwhile) drops for its own view: these keys are no longer the view\n if (!context.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 }) => context.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 }) => context.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 requests.abortAll();\n refresh();\n };\n vector.refresh = refresh;\n vector.styled = state.renderer.then(({ layers: list }) => {\n if (!context.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 context.followView(vector, update, requests, update);\n\n return vector;\n};\n"]}
1
+ {"version":3,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,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IACH,kCAAkC;IAClC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAErC,kHAAkH;IAClH,mBAAmB;IACnB,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * The vector layer of a vector basemap (`VectorTiles.vectors`): its fills, lines and buildings cut by the workers\n * into geometry the engine draws, the tiles following the view, and how its style layers are read for the engine.\n */\n\nimport { tilesetCoverage } from '../../data/tileset.ts';\nimport type { Icons } from '../../layers/icons.ts';\nimport type { VectorLayer, VectorSublayer } from '../../layers/vectors.ts';\nimport type { Drape, Placement, Tiles3dOptions } from '../../types.ts';\nimport { latitude, longitude } from '../../util/geo.ts';\nimport type { RoofMode } from '../../util/roofs.ts';\nimport { FLOATS, STYLE } from '../../util/style-floats.ts';\nimport type { BasemapWork, Priority } from '../../workers/basemap/protocol.ts';\nimport { evaluate, isExpression, type Json, type StyleLayer, vectorKind, zoomOnly } from '../vectorstyle.ts';\nimport type { Renderer, VectorTilesContext } from './context.ts';\nimport { TileRequests } from './requests.ts';\nimport { nearPriority, parseTileKey, type TileTriple, tileKey, tileTriples } from './tiles.ts';\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 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/** A layout or paint value at a zoom, whatever the feature (an expression evaluated) */\nconst atZoom = (value: Json | undefined, zoom: number): unknown =>\n isExpression(value) ? evaluate(value, { zoom, properties: {}, type: 'Unknown' }) : value;\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 = atZoom(value, zoom);\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/** 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 */\nexport const 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 = atZoom(value, zoom);\n\n return v === 'round' || v === 'square' ? v : 'butt';\n};\n\n/** A `line-join` as the engine draws it, at the camera's zoom (MapLibre's default: miter) */\nconst lineJoin = (value: Json | undefined, zoom: number): 'miter' | 'bevel' | 'round' => {\n const v = atZoom(value, zoom);\n\n return v === 'round' || v === 'bevel' ? v : 'miter';\n};\n\n/** A `line-miter-limit` at the camera's zoom (MapLibre's default: 2) */\nconst miterLimit = (value: Json | undefined, zoom: number): number => {\n const v = Number(atZoom(value, zoom) ?? 2);\n\n return Number.isFinite(v) ? v : 2;\n};\n\n/** A tile's styles with their patterns placed: each feature's pattern, as its index past one into `names`\n * (`STYLE.fillPattern`, `STYLE.linePattern`), replaced by its image's place in the icon atlas (texels) and pixel\n * ratio; none if the atlas has no such image; the atlas uploaded */\nexport const placePatterns = (\n styles: Float32Array,\n names: readonly string[] | undefined,\n icons: Icons,\n prefix: string,\n): Float32Array => {\n if (!names?.length) return styles;\n // Thousands of features a tile: a loop\n for (let f = 0; f + FLOATS <= styles.length; f += FLOATS) {\n const fill = styles[f + STYLE.fillPattern] ?? 0;\n const line = styles[f + STYLE.linePattern] ?? 0;\n const index = fill > 0 ? fill : line;\n\n if (index <= 0) continue;\n\n const icon = icons.get(prefix + (names[index - 1] ?? ''));\n const place = icon ? [icon.x, icon.y, icon.width, icon.height] : [0, 0, 0, 0];\n const ratio = icon?.pixelRatio ?? 0;\n\n if (fill > 0) styles.set([...place, ratio], f + STYLE.size + 4);\n else {\n styles.set(place, f + STYLE.second);\n styles[f + STYLE.patternRatio] = ratio;\n }\n }\n icons.flush();\n\n return styles;\n};\n\n/** The paint properties of the patterns `vectors()` draws, whose images come from the style's sprite */\nconst PATTERNS = ['fill-pattern', 'background-pattern', 'line-pattern', 'fill-extrusion-pattern'];\n\n/** A `fill-translate` or `line-translate` at the camera's zoom (CSS pixels; none if it is not two numbers) */\nexport const translation = (value: Json | undefined, zoom: number): [number, number] => {\n const v = atZoom(value, zoom);\n const [x, y] = Array.isArray(v) ? v.map(Number) : [];\n\n return Number.isFinite(x) && Number.isFinite(y) ? [x ?? 0, y ?? 0] : [0, 0];\n};\n\n/** The options of `VectorTiles.vectors` */\nexport interface VectorsOptions extends Placement {\n layers?: (layer: StyleLayer) => boolean;\n streets?: (layer: StyleLayer) => boolean;\n /** The buildings' roofs: from their data (`roof:shape`, `roof:height`; flat without, the default), generated from\n * their outline where they have none (hipped, gabled or mansard by size and shape), or all flat */\n roofs?: RoofMode;\n /** The buildings' walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades?: boolean;\n /** A raster layer draped on the buildings' roofs (`setDrape`): an ortho on the city; on the 3D buildings too */\n drape?: Drape | undefined;\n /**\n * 3D buildings in place of the style's raised ones where they have some: a 3D Tiles tileset (`batiments3d()`: the\n * IGN's Bâtiments 3D over France) drawn with the layer, removed and moved with it (its `companions`); the style's\n * buildings left out where the tileset's children cover (their boxes, read from its `tileset.json`, a child that is\n * a tileset of its own read when a tile meets it), kept elsewhere; their walls' windows with `facades`\n */\n buildings3d?: Tiles3dOptions;\n}\n\nexport const vectors = (context: VectorTilesContext, options: VectorsOptions = {}): VectorLayer => {\n const { map } = context;\n const { layers = () => true, streets = isStreet, before, roofs = 'data', facades = false } = options;\n const vector = map.addVectorLayer(before);\n // The 3D buildings over the layer's ground, and where they stand\n const buildings = options.buildings3d && map.addTiles3d({ ...options.buildings3d, ...(before && { before }) });\n const coverage = options.buildings3d && tilesetCoverage(options.buildings3d.url);\n\n if (buildings) vector.companions.push(buildings);\n vector.buildings3d = buildings;\n vector.setFacades(facades);\n if (options.drape) vector.setDrape(options.drape);\n const state: {\n renderer: Promise<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: context.renderer((l) => vectorKind(l) !== undefined && layers(l), []), update: 0, style: 0 };\n\n state.renderer.catch(() => undefined);\n\n /** The style's sprites among the map's icons, if a layer drawn has a pattern: waited for before the first tiles */\n const sprites = context.ready\n .then(({ style }) =>\n style.layers.some((l) => layers(l) && PATTERNS.some((k) => l.paint?.[k] !== undefined))\n ? context.addSprites()\n : undefined,\n )\n .catch(() => undefined);\n const placed = (styles: Float32Array, names: readonly string[] | undefined) =>\n placePatterns(styles, names, map.icons, context.iconPrefix);\n context.layers.push(vector);\n\n const sublayers = (list: StyleLayer[]): VectorSublayer[] => {\n const zoom = 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 join: lineJoin(l.layout?.['line-join'], zoom),\n miterLimit: miterLimit(l.layout?.['line-miter-limit'], zoom),\n translate: translation(l.paint?.[`${l.type}-translate`], zoom),\n translateAnchor: l.paint?.[`${l.type}-translate-anchor`] === 'viewport' ? 'viewport' : 'map',\n patterned: l.paint?.['fill-pattern'] !== undefined || l.paint?.['background-pattern'] !== undefined,\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 requests = new TileRequests();\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 = async (\n { key, maxzoom }: { key: string; maxzoom: number },\n [z, x, y]: TileTriple,\n styles: boolean,\n priority: Priority,\n signal?: AbortSignal,\n ) => {\n const d = Math.max(0, z - maxzoom);\n // Where the 3D buildings stand over the source's tile the worker cuts (none known: the style's buildings kept)\n const n = 2 ** (z - d);\n const [tx, ty] = [Math.floor(x / 2 ** d), Math.floor(y / 2 ** d)];\n const covered = await coverage\n ?.within([longitude(tx / n), latitude((ty + 1) / n), longitude((tx + 1) / n), latitude(ty / n)])\n .catch(() => undefined);\n const work: BasemapWork = {\n type: 'vectors',\n key,\n z,\n x,\n y,\n deepest: deepestLevel(maxzoom),\n roofs,\n ...(covered?.length ? { covered } : {}),\n priority,\n };\n\n // The geometry made ready for the GPU in the workers, with the prisms the relief needs\n return context.request(\n z - d,\n Math.floor(x / 2 ** d),\n Math.floor(y / 2 ** d),\n styles ? { ...work, styles } : { ...work, prism: 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 context.broadcast({ type: 'tess', url: map.tessUrl });\n /** Asks the workers again for the styles of a tile held, under the current style; the tile's geometry stays as it\n * is */\n const restyleTile = async (renderer: { key: string; maxzoom: number }, k: string) => {\n const r = await ask(renderer, parseTileKey(k), true, 'auto').catch(() => undefined);\n\n if (r && 'styles' in r) vector.setTileStyles(k, placed(r.styles, r.patterns));\n };\n const update = async () => {\n if (context.destroyed()) return;\n\n const generation = ++state.update;\n // The style the tiles are cut under: that of the renderer awaited, a restyle meanwhile (a paint property set as the\n // style loads) asking their styles again once they are there\n const style = state.style;\n const { key, maxzoom, layers: list } = await state.renderer;\n\n await sprites;\n\n vector.setSublayers(sublayers(state.own ?? list));\n\n const wanted = tileTriples(map.engine.vectorTilesInView(0, deepestLevel(maxzoom), map.quality.reach));\n const keys = new Set(wanted.map((t) => tileKey(...t)));\n const loads = wanted.flatMap((t, index) => {\n const k = tileKey(...t);\n\n if (requests.has(k)) return [];\n\n return [\n requests.ask(\n k,\n (signal) => ask({ key, maxzoom }, t, false, nearPriority(index, 'high', 'auto'), signal),\n async (r) => {\n if (!('vectors' in r)) return;\n await vector.setTile(k, { ...r.vectors, styles: placed(r.vectors.styles, r.vectors.patterns) });\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 ];\n });\n // Out of view: those still asked for go at once, those drawn once their replacements are there (no hole). The\n // drawn ones are those the engine shows, held or not (a recut forgets what it held, not what is drawn)\n const drop = (drawn: boolean) => {\n const shown = new Set(vector.tileKeys);\n const known = new Set([...requests.keys(), ...(drawn ? shown : [])]);\n\n known.forEach((k) => {\n if (keys.has(k) || shown.has(k) !== drawn) return;\n requests.drop(k);\n vector.removeTile(k);\n });\n };\n\n drop(false);\n // Every tile of the view, those an earlier update asked for too: a tile out of view stays drawn until all of them\n // are there\n await Promise.all([...loads, requests.answered(keys)]);\n // A later update (the view moved again meanwhile) drops for its own view: these keys are no longer the view\n if (!context.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 }) => context.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 }) => context.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 requests.abortAll();\n refresh();\n };\n vector.refresh = refresh;\n vector.styled = state.renderer.then(({ layers: list }) => {\n if (!context.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 context.followView(vector, update, requests, update);\n\n return vector;\n};\n"]}
@@ -127,8 +127,7 @@ export declare class VectorTiles {
127
127
  * tile comes back; the engine draws them all in one instanced draw, on the relief. A low-poly tree by default (its
128
128
  * `colors`), or your own glTF (`url`, `data`, about 10 metres high, standing on its origin). Dense around the
129
129
  * view's center, fewer and fewer away from it (as the camera moves too), at most `maxInstances` drawn (default
130
- * 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000). The models load the
131
- * engine with 3D Tiles.
130
+ * 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000).
132
131
  */
133
132
  trees(options?: TreesOptions): ModelLayer;
134
133
  /**
@@ -136,7 +135,6 @@ export declare class VectorTiles {
136
135
  * level (`minZoom`, default 16): the workers place them `spacing` metres apart (default 30) along each street, every
137
136
  * other one on its other side, as far from its middle as its class says; their heads lit at night (`light`). All of
138
137
  * them near the ground under the camera, fewer and fewer away from it, at most `maxInstances` drawn (default 15000).
139
- * The models load the engine with 3D Tiles.
140
138
  */
141
139
  lamps(options?: LampsOptions): ModelLayer;
142
140
  /**
@@ -220,8 +220,7 @@ export class VectorTiles {
220
220
  * tile comes back; the engine draws them all in one instanced draw, on the relief. A low-poly tree by default (its
221
221
  * `colors`), or your own glTF (`url`, `data`, about 10 metres high, standing on its origin). Dense around the
222
222
  * view's center, fewer and fewer away from it (as the camera moves too), at most `maxInstances` drawn (default
223
- * 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000). The models load the
224
- * engine with 3D Tiles.
223
+ * 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000).
225
224
  */
226
225
  trees(options = {}) {
227
226
  return trees(this.context, options);
@@ -231,7 +230,6 @@ export class VectorTiles {
231
230
  * level (`minZoom`, default 16): the workers place them `spacing` metres apart (default 30) along each street, every
232
231
  * other one on its other side, as far from its middle as its class says; their heads lit at night (`light`). All of
233
232
  * them near the ground under the camera, fewer and fewer away from it, at most `maxInstances` drawn (default 15000).
234
- * The models load the engine with 3D Tiles.
235
233
  */
236
234
  lamps(options = {}) {
237
235
  return lamps(this.context, options);
@@ -1 +1 @@
1
- {"version":3,"file":"vectortiles.js","sourceRoot":"","sources":["../../src/basemap/vectortiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAqB,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQ/F,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAIxC,OAAO,EAAE,UAAU,EAA+B,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAyB,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAsB,MAAM,E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MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC/B,4EAA4E;QAC5E,IAAI,CAAC,OAAO;YACV,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YACjB,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBACzB,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,8DAA8D;YAC9D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF","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 * The layers other than the raster ones are made in `vectortiles/` (one module each), from what they use of the\n * instance (`VectorTilesContext`); the style's loading is in `vectortiles/style.ts`.\n */\n\nimport type { ExtrusionLayer } from '../layers/extrusions.ts';\nimport { type LoadedSprite, loadSprites, readPixels, spriteSources } from '../layers/icons.ts';\nimport type { Layer } from '../layers/layers.ts';\nimport type { ModelLayer } from '../layers/models.ts';\nimport type { RasterLayer } from '../layers/raster.ts';\nimport type { SymbolLayer } from '../layers/symbols.ts';\nimport type { VectorLayer } from '../layers/vectors.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { Placement } from '../types.ts';\nimport { clamp } from '../util/math.ts';\nimport type { BasemapWork, Sprite } from '../workers/basemap/protocol.ts';\nimport type { LabelCandidate, Style, StyleLayer } from './vectorstyle.ts';\nimport type { Renderer, VectorTilesContext } from './vectortiles/context.ts';\nimport { extrusions, type VectorExtrusionOptions } from './vectortiles/extrusions.ts';\nimport { type FurnitureOptions, furniture } from './vectortiles/furniture.ts';\nimport { type LabelsOptions, labels, size, tileLabels } from './vectortiles/labels.ts';\nimport { type LampsOptions, lamps } from './vectortiles/lamps.ts';\nimport type { TileRequests } from './vectortiles/requests.ts';\nimport { type StreetWindLayer, type StreetWindOptions, streetWind } from './vectortiles/street-wind.ts';\nimport {\n type LoadedStyle,\n loadStyle,\n OPENFREEMAP_STYLES,\n PLAN_STYLES,\n styleAttribution,\n VECTOR_BASEMAPS,\n} from './vectortiles/style.ts';\nimport { VECTOR_MOVE_REFRESH_MS } from './vectortiles/tiles.ts';\nimport { type TreesOptions, trees } from './vectortiles/trees.ts';\nimport { dashes, type VectorsOptions, vectors } from './vectortiles/vectors.ts';\nimport { type BasemapWorkers, rendererKey, tilePriority } from './workerpool.ts';\n\n// The names the package and its tests import from here, now made in `vectortiles/`\nexport { dashes, OPENFREEMAP_STYLES, PLAN_STYLES, size, styleAttribution, tileLabels, VECTOR_BASEMAPS };\n\n/** The options of `VectorTiles.raster` */\nexport interface VectorRasterOptions extends Placement {\n /** The style layers drawn (default all but the symbols) */\n layers?: (layer: StyleLayer) => boolean;\n /** Style layers of the same source drawn after them */\n extraLayers?: StyleLayer[];\n /** Texture size of its tiles (512 by default: sharp lines) */\n size?: number;\n opacity?: number;\n minZoom?: number;\n maxZoom?: number;\n}\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\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 /** What its layers made in `vectortiles/` use of it */\n private readonly context: VectorTilesContext;\n /** The style once loaded, with its source resolved */\n readonly ready: Promise<LoadedStyle>;\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 = loadStyle(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 this.context = {\n map,\n ready: this.ready,\n layers: this.layers,\n cleanup: this.cleanup,\n iconPrefix: this.iconPrefix,\n destroyed: () => this.destroyed,\n ground: () => this.ground,\n broadcast: (message) => {\n this.pool.broadcast(message);\n },\n request: (vz, vx, vy, work, signal) => this.request(vz, vx, vy, work, signal),\n renderer: (select, extra, again) => this.renderer(select, extra, { again }),\n loadSprites: (sprite) => this.loadSprites(sprite),\n addSprites: () => this.addSprites(),\n followView: (layer, update, requests, moving) => {\n this.followView(layer, update, requests, moving);\n },\n stopWith: (layer, stop) => {\n this.stopWith(layer, stop);\n },\n };\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 /** The style's sprites, kept once all of them came: one that failed is asked for again by the next layer */\n private loadSprites(sprite: Style['sprite']): Promise<LoadedSprite[]> {\n if (this.sprites) return this.sprites;\n\n const wanted = spriteSources(sprite).length;\n const loading: Promise<LoadedSprite[]> = loadSprites(sprite)\n .catch(() => [])\n .then((loaded) => {\n if (loaded.length < wanted && this.sprites === loading) {\n console.warn(\n `isard: ${wanted - loaded.length} of the style's sprites not loaded, its icons and patterns missing`,\n );\n this.sprites = undefined;\n }\n\n return loaded;\n });\n\n this.sprites = loading;\n\n return loading;\n }\n\n /** The style's sprites added to the map's icons, once */\n private spritesAdded: Promise<void> | undefined;\n\n /** The style's sprites among the map's icons (under `iconPrefix`), added once: the labels' icons, the fills'\n * patterns */\n private addSprites(): Promise<void> {\n this.spritesAdded ??= this.ready.then(async ({ style }) => {\n if (!style.sprite) return;\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.spritesAdded;\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.map.track(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 that key, restyled), with the style's sprites if\n * it `draws` the tiles into images with patterns (the raster path: the others take their images in the page) */\n private async renderer(\n select: (layer: StyleLayer) => boolean,\n extra: StyleLayer[],\n { again, draws = false }: { again?: string | undefined; draws?: boolean } = {},\n ): Promise<Renderer> {\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 = draws && 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({\n type: 'init',\n key,\n tiles,\n maxzoom,\n layers,\n rasters,\n cached: this.map.quality.cachedTiles,\n ...(sprites.length ? { sprites } : {}),\n });\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(options: VectorRasterOptions = {}): 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, { draws: true });\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 = clamp(z - 1, 0, 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>>(options: VectorExtrusionOptions<P> = {}): ExtrusionLayer<P> {\n return extrusions<P>(this.context, options);\n }\n\n /**\n * The wind through the streets around the view, as particles at street level (`height`, default 3 metres) between\n * the style's buildings (`layers`, default its `building` and `bati_surf` layers): their footprints laid on a grid of\n * `cell` metres (default 4) over a square of `size` metres (default 1200) around the view's center, the flow of the\n * air round them a potential flow (it goes round the blocks and faster through the narrow streets; no wake behind\n * them), computed in a worker by the grid module from street level (`minZoom`, default 15) and again when the view\n * leaves the square's middle. `wind` is the wind far away (east and north, m/s, default a light breeze from the\n * south-west); `setWind` changes it at once (the flow is linear in it: nothing computed again), from a model's hour\n * (`windAt`) for instance; `computed` resolves once the first square's flow is there. The other options are the flow\n * layer's (`addFlow`)\n */\n streetWind(options: StreetWindOptions = {}): StreetWindLayer {\n return streetWind(this.context, options);\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(options: TreesOptions = {}): ModelLayer {\n return trees(this.context, options);\n }\n\n /**\n * Street lamps along the style's streets (the road line layers, or those `layers` keeps) as 3D models, from street\n * level (`minZoom`, default 16): the workers place them `spacing` metres apart (default 30) along each street, every\n * other one on its other side, as far from its middle as its class says; their heads lit at night (`light`). All of\n * them near the ground under the camera, fewer and fewer away from it, at most `maxInstances` drawn (default 15000).\n * The models load the engine with 3D Tiles.\n */\n lamps(options: LampsOptions = {}): ModelLayer {\n return lamps(this.context, options);\n }\n\n /**\n * The street furniture as 3D models, from OpenMapTiles' points of interest of the street: bus shelters at the bus\n * stops, waste baskets, post boxes, drinking fountains (Wallace's in Paris), bicycle racks, each facing its street;\n * benches along the pedestrian streets and the paths of the parks and gardens. Placed by the workers, one instanced\n * draw a kind, all of them near the camera and fewer away from it. The layer returned holds the other kinds' (its\n * `companions`); removed with it\n */\n furniture(options: FurnitureOptions = {}): ModelLayer {\n return furniture(this.context, options);\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 styles those of their level; a filter reading the zoom\n * holds at the whole zoom under the camera's, as MapLibre evaluates it). The fills' outlines are drawn one\n * pixel wide, the lines' ends as their `line-cap` says, their joins as their `line-join` says (and `line-miter-limit`),\n * offset by `line-offset`; the colors follow the camera's zoom; the fills', lines' and buildings' patterns from the\n * style's sprite (the fills' over the relief too; on the globe, their average color there), the circle layers' points\n * as circles facing the screen, the lines' blur, the fills' and lines' translations. The buildings' roofs (`roofs`)\n * as their data says (`roof:shape`, `roof:height`; flat without, the default), generated from their outline where\n * they have none (`'generated'`), or all flat. `raster` stays the lighter path for heavy styles and small devices.\n * 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(options: VectorsOptions = {}): VectorLayer {\n return vectors(this.context, options);\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: LabelsOptions = {}): SymbolLayer<LabelCandidate> {\n return labels(this.context, options);\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, and again after a pause when tiles failed; the `requests` aborted when\n * destroyed or the layer removed\n */\n private followView(\n layer: Layer,\n update: () => Promise<unknown>,\n requests: TileRequests,\n moving: () => unknown,\n ): 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 const [offMove, offEnd] = [this.map.on('move', follow), this.map.on('moveend', refresh)];\n\n requests.retryWith(refresh);\n\n this.stopWith(layer, () => {\n offMove();\n offEnd();\n clearTimeout(pace.timer);\n requests.abortAll();\n });\n refresh();\n }\n\n /** Calls `stop` when destroyed or once `layer` is removed, whichever comes first */\n private stopWith(layer: Layer, stop: () => void): void {\n const once = { done: false };\n const run = () => {\n if (once.done) return;\n once.done = true;\n stop();\n };\n\n this.cleanup.push(run);\n layer.whenRemoved.push(run);\n }\n\n /** Removes its layers from the map (those still there) and stops its workers' work */\n remove(): 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"]}
1
+ {"version":3,"file":"vectortiles.js","sourceRoot":"","sources":["../../src/basemap/vectortiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAqB,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQ/F,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAIxC,OAAO,EAAE,UAAU,EAA+B,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAyB,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAsB,MAAM,EAAE,IAAI,EAA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M,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC/B,4EAA4E;QAC5E,IAAI,CAAC,OAAO;YACV,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YACjB,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBACzB,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,8DAA8D;YAC9D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF","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 * The layers other than the raster ones are made in `vectortiles/` (one module each), from what they use of the\n * instance (`VectorTilesContext`); the style's loading is in `vectortiles/style.ts`.\n */\n\nimport type { ExtrusionLayer } from '../layers/extrusions.ts';\nimport { type LoadedSprite, loadSprites, readPixels, spriteSources } from '../layers/icons.ts';\nimport type { Layer } from '../layers/layers.ts';\nimport type { ModelLayer } from '../layers/models.ts';\nimport type { RasterLayer } from '../layers/raster.ts';\nimport type { SymbolLayer } from '../layers/symbols.ts';\nimport type { VectorLayer } from '../layers/vectors.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { Placement } from '../types.ts';\nimport { clamp } from '../util/math.ts';\nimport type { BasemapWork, Sprite } from '../workers/basemap/protocol.ts';\nimport type { LabelCandidate, Style, StyleLayer } from './vectorstyle.ts';\nimport type { Renderer, VectorTilesContext } from './vectortiles/context.ts';\nimport { extrusions, type VectorExtrusionOptions } from './vectortiles/extrusions.ts';\nimport { type FurnitureOptions, furniture } from './vectortiles/furniture.ts';\nimport { type LabelsOptions, labels, size, tileLabels } from './vectortiles/labels.ts';\nimport { type LampsOptions, lamps } from './vectortiles/lamps.ts';\nimport type { TileRequests } from './vectortiles/requests.ts';\nimport { type StreetWindLayer, type StreetWindOptions, streetWind } from './vectortiles/street-wind.ts';\nimport {\n type LoadedStyle,\n loadStyle,\n OPENFREEMAP_STYLES,\n PLAN_STYLES,\n styleAttribution,\n VECTOR_BASEMAPS,\n} from './vectortiles/style.ts';\nimport { VECTOR_MOVE_REFRESH_MS } from './vectortiles/tiles.ts';\nimport { type TreesOptions, trees } from './vectortiles/trees.ts';\nimport { dashes, type VectorsOptions, vectors } from './vectortiles/vectors.ts';\nimport { type BasemapWorkers, rendererKey, tilePriority } from './workerpool.ts';\n\n// The names the package and its tests import from here, now made in `vectortiles/`\nexport { dashes, OPENFREEMAP_STYLES, PLAN_STYLES, size, styleAttribution, tileLabels, VECTOR_BASEMAPS };\n\n/** The options of `VectorTiles.raster` */\nexport interface VectorRasterOptions extends Placement {\n /** The style layers drawn (default all but the symbols) */\n layers?: (layer: StyleLayer) => boolean;\n /** Style layers of the same source drawn after them */\n extraLayers?: StyleLayer[];\n /** Texture size of its tiles (512 by default: sharp lines) */\n size?: number;\n opacity?: number;\n minZoom?: number;\n maxZoom?: number;\n}\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\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 /** What its layers made in `vectortiles/` use of it */\n private readonly context: VectorTilesContext;\n /** The style once loaded, with its source resolved */\n readonly ready: Promise<LoadedStyle>;\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 = loadStyle(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 this.context = {\n map,\n ready: this.ready,\n layers: this.layers,\n cleanup: this.cleanup,\n iconPrefix: this.iconPrefix,\n destroyed: () => this.destroyed,\n ground: () => this.ground,\n broadcast: (message) => {\n this.pool.broadcast(message);\n },\n request: (vz, vx, vy, work, signal) => this.request(vz, vx, vy, work, signal),\n renderer: (select, extra, again) => this.renderer(select, extra, { again }),\n loadSprites: (sprite) => this.loadSprites(sprite),\n addSprites: () => this.addSprites(),\n followView: (layer, update, requests, moving) => {\n this.followView(layer, update, requests, moving);\n },\n stopWith: (layer, stop) => {\n this.stopWith(layer, stop);\n },\n };\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 /** The style's sprites, kept once all of them came: one that failed is asked for again by the next layer */\n private loadSprites(sprite: Style['sprite']): Promise<LoadedSprite[]> {\n if (this.sprites) return this.sprites;\n\n const wanted = spriteSources(sprite).length;\n const loading: Promise<LoadedSprite[]> = loadSprites(sprite)\n .catch(() => [])\n .then((loaded) => {\n if (loaded.length < wanted && this.sprites === loading) {\n console.warn(\n `isard: ${wanted - loaded.length} of the style's sprites not loaded, its icons and patterns missing`,\n );\n this.sprites = undefined;\n }\n\n return loaded;\n });\n\n this.sprites = loading;\n\n return loading;\n }\n\n /** The style's sprites added to the map's icons, once */\n private spritesAdded: Promise<void> | undefined;\n\n /** The style's sprites among the map's icons (under `iconPrefix`), added once: the labels' icons, the fills'\n * patterns */\n private addSprites(): Promise<void> {\n this.spritesAdded ??= this.ready.then(async ({ style }) => {\n if (!style.sprite) return;\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.spritesAdded;\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.map.track(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 that key, restyled), with the style's sprites if\n * it `draws` the tiles into images with patterns (the raster path: the others take their images in the page) */\n private async renderer(\n select: (layer: StyleLayer) => boolean,\n extra: StyleLayer[],\n { again, draws = false }: { again?: string | undefined; draws?: boolean } = {},\n ): Promise<Renderer> {\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 = draws && 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({\n type: 'init',\n key,\n tiles,\n maxzoom,\n layers,\n rasters,\n cached: this.map.quality.cachedTiles,\n ...(sprites.length ? { sprites } : {}),\n });\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(options: VectorRasterOptions = {}): 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, { draws: true });\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 = clamp(z - 1, 0, 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>>(options: VectorExtrusionOptions<P> = {}): ExtrusionLayer<P> {\n return extrusions<P>(this.context, options);\n }\n\n /**\n * The wind through the streets around the view, as particles at street level (`height`, default 3 metres) between\n * the style's buildings (`layers`, default its `building` and `bati_surf` layers): their footprints laid on a grid of\n * `cell` metres (default 4) over a square of `size` metres (default 1200) around the view's center, the flow of the\n * air round them a potential flow (it goes round the blocks and faster through the narrow streets; no wake behind\n * them), computed in a worker by the grid module from street level (`minZoom`, default 15) and again when the view\n * leaves the square's middle. `wind` is the wind far away (east and north, m/s, default a light breeze from the\n * south-west); `setWind` changes it at once (the flow is linear in it: nothing computed again), from a model's hour\n * (`windAt`) for instance; `computed` resolves once the first square's flow is there. The other options are the flow\n * layer's (`addFlow`)\n */\n streetWind(options: StreetWindOptions = {}): StreetWindLayer {\n return streetWind(this.context, options);\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).\n */\n trees(options: TreesOptions = {}): ModelLayer {\n return trees(this.context, options);\n }\n\n /**\n * Street lamps along the style's streets (the road line layers, or those `layers` keeps) as 3D models, from street\n * level (`minZoom`, default 16): the workers place them `spacing` metres apart (default 30) along each street, every\n * other one on its other side, as far from its middle as its class says; their heads lit at night (`light`). All of\n * them near the ground under the camera, fewer and fewer away from it, at most `maxInstances` drawn (default 15000).\n */\n lamps(options: LampsOptions = {}): ModelLayer {\n return lamps(this.context, options);\n }\n\n /**\n * The street furniture as 3D models, from OpenMapTiles' points of interest of the street: bus shelters at the bus\n * stops, waste baskets, post boxes, drinking fountains (Wallace's in Paris), bicycle racks, each facing its street;\n * benches along the pedestrian streets and the paths of the parks and gardens. Placed by the workers, one instanced\n * draw a kind, all of them near the camera and fewer away from it. The layer returned holds the other kinds' (its\n * `companions`); removed with it\n */\n furniture(options: FurnitureOptions = {}): ModelLayer {\n return furniture(this.context, options);\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 styles those of their level; a filter reading the zoom\n * holds at the whole zoom under the camera's, as MapLibre evaluates it). The fills' outlines are drawn one\n * pixel wide, the lines' ends as their `line-cap` says, their joins as their `line-join` says (and `line-miter-limit`),\n * offset by `line-offset`; the colors follow the camera's zoom; the fills', lines' and buildings' patterns from the\n * style's sprite (the fills' over the relief too; on the globe, their average color there), the circle layers' points\n * as circles facing the screen, the lines' blur, the fills' and lines' translations. The buildings' roofs (`roofs`)\n * as their data says (`roof:shape`, `roof:height`; flat without, the default), generated from their outline where\n * they have none (`'generated'`), or all flat. `raster` stays the lighter path for heavy styles and small devices.\n * 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(options: VectorsOptions = {}): VectorLayer {\n return vectors(this.context, options);\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: LabelsOptions = {}): SymbolLayer<LabelCandidate> {\n return labels(this.context, options);\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, and again after a pause when tiles failed; the `requests` aborted when\n * destroyed or the layer removed\n */\n private followView(\n layer: Layer,\n update: () => Promise<unknown>,\n requests: TileRequests,\n moving: () => unknown,\n ): 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 const [offMove, offEnd] = [this.map.on('move', follow), this.map.on('moveend', refresh)];\n\n requests.retryWith(refresh);\n\n this.stopWith(layer, () => {\n offMove();\n offEnd();\n clearTimeout(pace.timer);\n requests.abortAll();\n });\n refresh();\n }\n\n /** Calls `stop` when destroyed or once `layer` is removed, whichever comes first */\n private stopWith(layer: Layer, stop: () => void): void {\n const once = { done: false };\n const run = () => {\n if (once.done) return;\n once.done = true;\n stop();\n };\n\n this.cleanup.push(run);\n layer.whenRemoved.push(run);\n }\n\n /** Removes its layers from the map (those still there) and stops its workers' work */\n remove(): 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"]}
@@ -42,10 +42,10 @@ const OWN_SETTERS = {
42
42
  circles: new Set(['data', 'filter', 'values']),
43
43
  fills: new Set(['data', 'filter', 'values']),
44
44
  symbols: new Set(['data', 'filter']),
45
- extrusions: new Set(['data', 'filter', 'values']),
45
+ extrusions: new Set(['data', 'filter', 'values', 'drape']),
46
46
  network: new Set(['costs', 'edgeWidths', 'values']),
47
47
  tiles3d: new Set(['facades', 'drape']),
48
- models: new Set(['instances', 'altitudeReference']),
48
+ models: new Set(['instances', 'altitudeReference', 'drape']),
49
49
  ground: new Set(['uniforms', 'textures']),
50
50
  flow: new Set(['field', 'fields', 'time', 'playing']),
51
51
  };
@@ -1 +1 @@
1
- {"version":3,"file":"layers.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KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,8BAA8B;IAC9B,MAAM,CAAC,KAAY;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAE/D,IAAI,KAAK,IAAI,CAAC;YAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACF","sourcesContent":["/**\n * What a framework's binding (isard/react, isard/vue) does when the description of a layer changes: the least the\n * layer needs (its data, its style, its instances), or a new layer in its place when what changed is set at creation\n * (its URL, its grid, its nodes). Free of any framework.\n */\n\nimport type { Layer } from '../layers/layers.ts';\nimport type { GeoMap, LayerSpec } from '../map.ts';\n\n/** A layer as a binding describes it: the options of `map.add`, and the values of its features or nodes\n * (`setValues`: what colors them by a ramp) */\nexport type BoundLayerSpec<P = Record<string, unknown>> = LayerSpec<P> & { values?: Float32Array };\n\n/** The keys `setStyle` takes, by layer type; `'all'`: every key but the data (the feature layers) */\nconst STYLE_KEYS: Record<LayerSpec['type'], 'all' | ReadonlySet<string>> = {\n lines: 'all',\n circles: 'all',\n fills: 'all',\n symbols: 'all',\n extrusions: 'all',\n raster: new Set(['opacity', 'saturation']),\n network: new Set(['width', 'max', 'contour', 'opacity', 'halo', 'haloOpacity', 'ramp', 'unreachedColor', 'fade']),\n tiles3d: new Set(['maxScreenSpaceError', 'opacity', 'pointSize', 'color', 'featureColor']),\n pointcloud: new Set([\n 'colorBy',\n 'pointSize',\n 'maxPointSize',\n 'sizeMode',\n 'shape',\n 'edl',\n 'classifications',\n 'elevationRange',\n 'elevationRamp',\n 'intensityRange',\n 'maxScreenSpaceError',\n 'pointBudget',\n ]),\n models: new Set(),\n trees: new Set(),\n ground: new Set(),\n flow: new Set(['colors', 'width', 'opacity', 'height', 'speed', 'density']),\n};\n\n/** Keys a layer takes at its creation only, by layer type: a change makes it anew (whatever its style keys say) */\nconst CREATION_KEYS: Partial<Record<LayerSpec['type'], ReadonlySet<string>>> = {\n lines: new Set(['altitudeReference']),\n};\n\n/** Keys a layer takes by a method of its own, by layer type */\nconst OWN_SETTERS: Partial<Record<LayerSpec['type'], ReadonlySet<string>>> = {\n lines: new Set(['data', 'filter', 'values']),\n circles: new Set(['data', 'filter', 'values']),\n fills: new Set(['data', 'filter', 'values']),\n symbols: new Set(['data', 'filter']),\n extrusions: new Set(['data', 'filter', 'values']),\n network: new Set(['costs', 'edgeWidths', 'values']),\n tiles3d: new Set(['facades', 'drape']),\n models: new Set(['instances', 'altitudeReference']),\n ground: new Set(['uniforms', 'textures']),\n flow: new Set(['field', 'fields', 'time', 'playing']),\n};\n\n/** The keys of a description and their values */\nconst fields = (spec: BoundLayerSpec): Map<string, unknown> => new Map(Object.entries(spec));\n\n/** What to do with a layer whose description went from `prev` to `next` */\nexport type LayerChange =\n | { rebuild: true }\n | {\n rebuild: false;\n /** The keys changed, with their new values */\n style: Record<string, unknown>;\n own: Record<string, unknown>;\n };\n\n/**\n * The change from one description to the next, or `undefined` when nothing changed. Values are compared by identity:\n * data, functions and arrays given anew at each render are changes (keep them in a memo)\n */\nexport const layerChange = (prev: BoundLayerSpec, next: BoundLayerSpec): LayerChange | undefined => {\n if (prev.type !== next.type) return { rebuild: true };\n\n const before = fields(prev);\n const after = fields(next);\n const styleKeys = STYLE_KEYS[next.type];\n const own = OWN_SETTERS[next.type];\n const change: Extract<LayerChange, { rebuild: false }> = { rebuild: false, style: {}, own: {} };\n const keys = [...new Set([...before.keys(), ...after.keys()])].filter(\n (key) => key !== 'type' && !Object.is(before.get(key), after.get(key)),\n );\n\n if (keys.length === 0) return undefined;\n\n const creation = CREATION_KEYS[next.type];\n const isStyle = (key: string) =>\n key !== 'before' && !creation?.has(key) && (styleKeys === 'all' || styleKeys.has(key));\n\n // A style or setting taken away: the layer goes back to its defaults, as made anew\n if (keys.some((key) => !after.has(key) || !(own?.has(key) || isStyle(key)))) return { rebuild: true };\n keys.forEach((key) => {\n if (own?.has(key)) change.own[key] = after.get(key);\n else change.style[key] = after.get(key);\n });\n\n return change;\n};\n\n/** The methods a change calls on a layer, those of its type */\ntype Setter =\n | 'setStyle'\n | 'setFacades'\n | 'setDrape'\n | 'setData'\n | 'setFilter'\n | 'setValues'\n | 'setCosts'\n | 'setEdgeWidths'\n | 'setInstances'\n | 'setUniform'\n | 'setTexture'\n | 'setField'\n | 'setFields'\n | 'setTime'\n | 'setPlaying';\n\n/** Calls a setter of the layer, if its type has it */\nconst set = (layer: Layer, setter: Setter, ...args: unknown[]): void => {\n const method: unknown = Reflect.get(layer, setter);\n\n if (typeof method === 'function') method.apply(layer, args);\n};\n\n/** Applies a change that keeps the layer (`rebuild: false`) */\nexport const applyLayerChange = (\n layer: Layer,\n next: BoundLayerSpec,\n change: Extract<LayerChange, { rebuild: false }>,\n): void => {\n const spec = fields(next);\n const own = change.own;\n\n if ('data' in own) set(layer, 'setData', own.data);\n if ('filter' in own) set(layer, 'setFilter', own.filter);\n if ('values' in own) set(layer, 'setValues', own.values);\n if ('field' in own) set(layer, 'setField', own.field);\n if ('fields' in own) set(layer, 'setFields', own.fields, spec.get('time'));\n else if ('time' in own) set(layer, 'setTime', own.time);\n if ('playing' in own) set(layer, 'setPlaying', own.playing ?? true);\n if ('costs' in own) set(layer, 'setCosts', own.costs);\n if ('edgeWidths' in own) set(layer, 'setEdgeWidths', own.edgeWidths);\n if ('instances' in own || 'altitudeReference' in own) {\n set(layer, 'setInstances', spec.get('instances'), spec.get('altitudeReference'));\n }\n if ('uniforms' in own) {\n Object.entries(own.uniforms ?? {}).forEach(([name, value]) => {\n set(layer, 'setUniform', name, value);\n });\n }\n if ('textures' in own) {\n Object.entries(own.textures ?? {}).forEach(([name, texture]) => {\n set(layer, 'setTexture', name, texture);\n });\n }\n if ('facades' in own) set(layer, 'setFacades', own.facades ?? false);\n if ('drape' in own) set(layer, 'setDrape', own.drape);\n if (Object.keys(change.style).length > 0) set(layer, 'setStyle', change.style);\n};\n\n/** Adds a layer from its description, its values set */\nexport const addBoundLayer = (map: GeoMap, { values, ...spec }: BoundLayerSpec): Layer => {\n const layer = map.add(spec as LayerSpec);\n\n if (values) set(layer, 'setValues', values);\n\n return layer;\n};\n\n/** A layer made anew from its description in the place of `old`, its values set */\nexport const rebuildBoundLayer = (map: GeoMap, old: Layer, { values, ...spec }: BoundLayerSpec): Layer => {\n const layer = map.rebuildLayer(old, spec as LayerSpec);\n\n if (values) set(layer, 'setValues', values);\n\n return layer;\n};\n\n/**\n * The layers of a binding in their declared order: `order` (default 0) from the bottom up, layers of the same order by\n * their `rank` (where they were declared: a component's taken when it first renders, before its layer may wait for\n * something, its tiles or its data), else by the time they came. A layer added or made anew is moved under the first\n * layer above it\n */\nexport class LayerOrder {\n private readonly entries: { layer: Layer; order: number; seq: number }[] = [];\n private seq = 0;\n\n /** The next rank: a component's place among the others, taken as React renders them in their declared order */\n rank(): number {\n this.seq += 1;\n\n return this.seq;\n }\n\n /** Places a new layer (at its `rank`, else after every other), or a layer made anew in place of `old` */\n place(layer: Layer, order: number, { old, rank }: { old?: Layer | undefined; rank?: number | undefined } = {}): void {\n const index = old ? this.entries.findIndex((e) => e.layer === old) : -1;\n const entry = index >= 0 ? this.entries[index] : undefined;\n\n if (entry) {\n entry.layer = layer;\n entry.order = order;\n } else {\n this.entries.push({ layer, order, seq: rank ?? this.rank() });\n }\n this.entries.sort((a, b) => a.order - b.order || a.seq - b.seq);\n\n const at = this.entries.findIndex((e) => e.layer === layer);\n const above = this.entries[at + 1]?.layer;\n\n if (above) layer.moveBefore(above);\n }\n\n /** Forgets a layer removed */\n remove(layer: Layer): void {\n const index = this.entries.findIndex((e) => e.layer === layer);\n\n if (index >= 0) this.entries.splice(index, 1);\n }\n}\n"]}
1
+ {"version":3,"file":"layers.js","sourceRoot":"","sources":["../../src/bind/layers.ts"],"names":[],"mappings":"AAAA;;;;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AAC,CAAC;IACrC,CAAC;IAED,8BAA8B;IAC9B,MAAM,CAAC,KAAY;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAE/D,IAAI,KAAK,IAAI,CAAC;YAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACF","sourcesContent":["/**\n * What a framework's binding (isard/react, isard/vue) does when the description of a layer changes: the least the\n * layer needs (its data, its style, its instances), or a new layer in its place when what changed is set at creation\n * (its URL, its grid, its nodes). Free of any framework.\n */\n\nimport type { Layer } from '../layers/layers.ts';\nimport type { GeoMap, LayerSpec } from '../map.ts';\n\n/** A layer as a binding describes it: the options of `map.add`, and the values of its features or nodes\n * (`setValues`: what colors them by a ramp) */\nexport type BoundLayerSpec<P = Record<string, unknown>> = LayerSpec<P> & { values?: Float32Array };\n\n/** The keys `setStyle` takes, by layer type; `'all'`: every key but the data (the feature layers) */\nconst STYLE_KEYS: Record<LayerSpec['type'], 'all' | ReadonlySet<string>> = {\n lines: 'all',\n circles: 'all',\n fills: 'all',\n symbols: 'all',\n extrusions: 'all',\n raster: new Set(['opacity', 'saturation']),\n network: new Set(['width', 'max', 'contour', 'opacity', 'halo', 'haloOpacity', 'ramp', 'unreachedColor', 'fade']),\n tiles3d: new Set(['maxScreenSpaceError', 'opacity', 'pointSize', 'color', 'featureColor']),\n pointcloud: new Set([\n 'colorBy',\n 'pointSize',\n 'maxPointSize',\n 'sizeMode',\n 'shape',\n 'edl',\n 'classifications',\n 'elevationRange',\n 'elevationRamp',\n 'intensityRange',\n 'maxScreenSpaceError',\n 'pointBudget',\n ]),\n models: new Set(),\n trees: new Set(),\n ground: new Set(),\n flow: new Set(['colors', 'width', 'opacity', 'height', 'speed', 'density']),\n};\n\n/** Keys a layer takes at its creation only, by layer type: a change makes it anew (whatever its style keys say) */\nconst CREATION_KEYS: Partial<Record<LayerSpec['type'], ReadonlySet<string>>> = {\n lines: new Set(['altitudeReference']),\n};\n\n/** Keys a layer takes by a method of its own, by layer type */\nconst OWN_SETTERS: Partial<Record<LayerSpec['type'], ReadonlySet<string>>> = {\n lines: new Set(['data', 'filter', 'values']),\n circles: new Set(['data', 'filter', 'values']),\n fills: new Set(['data', 'filter', 'values']),\n symbols: new Set(['data', 'filter']),\n extrusions: new Set(['data', 'filter', 'values', 'drape']),\n network: new Set(['costs', 'edgeWidths', 'values']),\n tiles3d: new Set(['facades', 'drape']),\n models: new Set(['instances', 'altitudeReference', 'drape']),\n ground: new Set(['uniforms', 'textures']),\n flow: new Set(['field', 'fields', 'time', 'playing']),\n};\n\n/** The keys of a description and their values */\nconst fields = (spec: BoundLayerSpec): Map<string, unknown> => new Map(Object.entries(spec));\n\n/** What to do with a layer whose description went from `prev` to `next` */\nexport type LayerChange =\n | { rebuild: true }\n | {\n rebuild: false;\n /** The keys changed, with their new values */\n style: Record<string, unknown>;\n own: Record<string, unknown>;\n };\n\n/**\n * The change from one description to the next, or `undefined` when nothing changed. Values are compared by identity:\n * data, functions and arrays given anew at each render are changes (keep them in a memo)\n */\nexport const layerChange = (prev: BoundLayerSpec, next: BoundLayerSpec): LayerChange | undefined => {\n if (prev.type !== next.type) return { rebuild: true };\n\n const before = fields(prev);\n const after = fields(next);\n const styleKeys = STYLE_KEYS[next.type];\n const own = OWN_SETTERS[next.type];\n const change: Extract<LayerChange, { rebuild: false }> = { rebuild: false, style: {}, own: {} };\n const keys = [...new Set([...before.keys(), ...after.keys()])].filter(\n (key) => key !== 'type' && !Object.is(before.get(key), after.get(key)),\n );\n\n if (keys.length === 0) return undefined;\n\n const creation = CREATION_KEYS[next.type];\n const isStyle = (key: string) =>\n key !== 'before' && !creation?.has(key) && (styleKeys === 'all' || styleKeys.has(key));\n\n // A style or setting taken away: the layer goes back to its defaults, as made anew\n if (keys.some((key) => !after.has(key) || !(own?.has(key) || isStyle(key)))) return { rebuild: true };\n keys.forEach((key) => {\n if (own?.has(key)) change.own[key] = after.get(key);\n else change.style[key] = after.get(key);\n });\n\n return change;\n};\n\n/** The methods a change calls on a layer, those of its type */\ntype Setter =\n | 'setStyle'\n | 'setFacades'\n | 'setDrape'\n | 'setData'\n | 'setFilter'\n | 'setValues'\n | 'setCosts'\n | 'setEdgeWidths'\n | 'setInstances'\n | 'setUniform'\n | 'setTexture'\n | 'setField'\n | 'setFields'\n | 'setTime'\n | 'setPlaying';\n\n/** Calls a setter of the layer, if its type has it */\nconst set = (layer: Layer, setter: Setter, ...args: unknown[]): void => {\n const method: unknown = Reflect.get(layer, setter);\n\n if (typeof method === 'function') method.apply(layer, args);\n};\n\n/** Applies a change that keeps the layer (`rebuild: false`) */\nexport const applyLayerChange = (\n layer: Layer,\n next: BoundLayerSpec,\n change: Extract<LayerChange, { rebuild: false }>,\n): void => {\n const spec = fields(next);\n const own = change.own;\n\n if ('data' in own) set(layer, 'setData', own.data);\n if ('filter' in own) set(layer, 'setFilter', own.filter);\n if ('values' in own) set(layer, 'setValues', own.values);\n if ('field' in own) set(layer, 'setField', own.field);\n if ('fields' in own) set(layer, 'setFields', own.fields, spec.get('time'));\n else if ('time' in own) set(layer, 'setTime', own.time);\n if ('playing' in own) set(layer, 'setPlaying', own.playing ?? true);\n if ('costs' in own) set(layer, 'setCosts', own.costs);\n if ('edgeWidths' in own) set(layer, 'setEdgeWidths', own.edgeWidths);\n if ('instances' in own || 'altitudeReference' in own) {\n set(layer, 'setInstances', spec.get('instances'), spec.get('altitudeReference'));\n }\n if ('uniforms' in own) {\n Object.entries(own.uniforms ?? {}).forEach(([name, value]) => {\n set(layer, 'setUniform', name, value);\n });\n }\n if ('textures' in own) {\n Object.entries(own.textures ?? {}).forEach(([name, texture]) => {\n set(layer, 'setTexture', name, texture);\n });\n }\n if ('facades' in own) set(layer, 'setFacades', own.facades ?? false);\n if ('drape' in own) set(layer, 'setDrape', own.drape);\n if (Object.keys(change.style).length > 0) set(layer, 'setStyle', change.style);\n};\n\n/** Adds a layer from its description, its values set */\nexport const addBoundLayer = (map: GeoMap, { values, ...spec }: BoundLayerSpec): Layer => {\n const layer = map.add(spec as LayerSpec);\n\n if (values) set(layer, 'setValues', values);\n\n return layer;\n};\n\n/** A layer made anew from its description in the place of `old`, its values set */\nexport const rebuildBoundLayer = (map: GeoMap, old: Layer, { values, ...spec }: BoundLayerSpec): Layer => {\n const layer = map.rebuildLayer(old, spec as LayerSpec);\n\n if (values) set(layer, 'setValues', values);\n\n return layer;\n};\n\n/**\n * The layers of a binding in their declared order: `order` (default 0) from the bottom up, layers of the same order by\n * their `rank` (where they were declared: a component's taken when it first renders, before its layer may wait for\n * something, its tiles or its data), else by the time they came. A layer added or made anew is moved under the first\n * layer above it\n */\nexport class LayerOrder {\n private readonly entries: { layer: Layer; order: number; seq: number }[] = [];\n private seq = 0;\n\n /** The next rank: a component's place among the others, taken as React renders them in their declared order */\n rank(): number {\n this.seq += 1;\n\n return this.seq;\n }\n\n /** Places a new layer (at its `rank`, else after every other), or a layer made anew in place of `old` */\n place(layer: Layer, order: number, { old, rank }: { old?: Layer | undefined; rank?: number | undefined } = {}): void {\n const index = old ? this.entries.findIndex((e) => e.layer === old) : -1;\n const entry = index >= 0 ? this.entries[index] : undefined;\n\n if (entry) {\n entry.layer = layer;\n entry.order = order;\n } else {\n this.entries.push({ layer, order, seq: rank ?? this.rank() });\n }\n this.entries.sort((a, b) => a.order - b.order || a.seq - b.seq);\n\n const at = this.entries.findIndex((e) => e.layer === layer);\n const above = this.entries[at + 1]?.layer;\n\n if (above) layer.moveBefore(above);\n }\n\n /** Forgets a layer removed */\n remove(layer: Layer): void {\n const index = this.entries.findIndex((e) => e.layer === layer);\n\n if (index >= 0) this.entries.splice(index, 1);\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -67,7 +67,7 @@ export { type VectorFeature, VectorLayer, type VectorSublayer } from './layers/v
67
67
  export type { HoverPicking } from './map/hover-pick.ts';
68
68
  export { GeoMap, type LayerSpec } from './map.ts';
69
69
  export { PANORAMAX_API, type PanoramaxPicture, type PanoramaxSequenceOptions, panoramaxPanoramas, panoramaxPhoto, panoramaxPicture, panoramaxSequence, panoramaxStyle, } from './panoramax.ts';
70
- export type { AnimationOptions, AtmosphereOptions, Basemap, BasemapName, BodyOptions, CelestialBody, FeatureColor, FeatureHit, FirstPersonView, FlyToOptions, GeoMapOptions, LoadingMode, LonLat, MapEvents, MapGpuTimings, MapHoverFeatureEvent, MapPointerEvent, NetworkOptions, NetworkStyle, PickOptions, Placement, Point, Projection, Quality, RasterGrid, RasterOptions, RasterStyle, SunOptions, SwipeOptions, TerrainEncoding, TerrainModel, TerrainOptions, Tiles3dDrape, Tiles3dOptions, Tiles3dStyle, ViewshedOptions, } from './types.ts';
70
+ export type { AnimationOptions, AtmosphereOptions, Basemap, BasemapName, BodyOptions, CelestialBody, Drape, FeatureColor, FeatureHit, FirstPersonView, FlyToOptions, GeoMapOptions, LoadingMode, LonLat, MapEvents, MapGpuTimings, MapHoverFeatureEvent, MapMemory, MapPointerEvent, NetworkOptions, NetworkStyle, PickOptions, Placement, Point, Projection, Quality, RasterGrid, RasterOptions, RasterStyle, SunOptions, SwipeOptions, TerrainEncoding, TerrainModel, TerrainOptions, Tiles3dOptions, Tiles3dStyle, ViewshedOptions, } from './types.ts';
71
71
  export { AttributionControl, type AttributionOptions, type Control, type ControlPosition, NavigationControl, type NavigationOptions, } from './ui/controls.ts';
72
72
  export { MinimapControl, type MinimapOptions } from './ui/minimap.ts';
73
73
  export { type Anchor, Marker, type MarkerEvent, type MarkerEvents, type MarkerOptions, Panel, type PanelOptions, Popup, type PopupEvents, type PopupOptions, } from './ui/overlay.ts';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,uBAAuB,EAAE,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AqB,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAsB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/**\n * isard: a WebGL2 map engine for large, interactive data layers, labels and 3D Tiles.\n *\n * ```ts\n * import { GeoMap } from 'isard';\n * const map = await GeoMap.create(container, { center: [2.4246, 48.8457], zoom: 13 });\n * const network = map.addNetwork({ nodes, edges, max: 1800, contour: 300 });\n * map.on('hover', ({ lonLat }) => lonLat && network.setValues(travelTimes(lonLat)));\n * map.addTiles3d({ url: 'https://…/tileset.json' });\n * map.addControl(new NavigationControl());\n * new Marker().setLonLat([2.4246, 48.8457]).setPopup(new Popup({ offset: [0, -34] }).setText('Here')).addTo(map);\n * ```\n */\nexport { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from './basemap/basemaps.ts';\nexport type { TileGrid, TileMatrix } from './basemap/grid.ts';\nexport { coniferModel, type TreeColors, treeModel } from './basemap/models/trees.ts';\nexport {\n PMTiles,\n type PmtilesEntry,\n type PmtilesHeader,\n type PmtilesTileType,\n tileIdToZxy,\n zxyToTileId,\n} from './basemap/pmtiles.ts';\nexport { basicStyle, type PmtilesOptions } from './basemap/pmtileslayer.ts';\nexport type {\n CandidateIcon,\n CandidateOverlap,\n Json,\n LabelCandidate,\n RasterSource,\n Style,\n StyleLayer,\n} from './basemap/vectorstyle.ts';\nexport type { VectorExtrusionOptions } from './basemap/vectortiles/extrusions.ts';\nexport type { FurnitureOptions } from './basemap/vectortiles/furniture.ts';\nexport type { LabelsOptions } from './basemap/vectortiles/labels.ts';\nexport type { LampsOptions } from './basemap/vectortiles/lamps.ts';\nexport type { StreetWindLayer, StreetWindOptions } from './basemap/vectortiles/street-wind.ts';\nexport type { LoadedStyle } from './basemap/vectortiles/style.ts';\nexport type { TreesOptions } from './basemap/vectortiles/trees.ts';\nexport { isStreet, type VectorsOptions } from './basemap/vectortiles/vectors.ts';\nexport type { VectorRasterOptions, VectorTilesOptions } from './basemap/vectortiles.ts';\nexport { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from './basemap/vectortiles.ts';\nexport { parseWmtsGrid, wmtsGrid } from './basemap/wmts.ts';\nexport { type ColladaImages, colladaImages, loadCollada, parseCollada } from './data/collada.ts';\nexport {\n type Crs,\n type CrsLike,\n getCrs,\n lambertConformalConic,\n registerCrs,\n reproject,\n transverseMercator,\n} from './data/crs.ts';\nexport { parseGpx } from './data/gpx.ts';\nexport {\n type IfcElement,\n type IfcModel,\n type IfcOptions,\n type IfcPlace,\n type IfcProperties,\n type IfcStorey,\n loadIfc,\n WEB_IFC,\n} from './data/ifc.ts';\nexport { parseKml } from './data/kml.ts';\nexport { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';\nexport type { DecoderUrls } from './decoding/decoders.ts';\nexport {\n BATIMENTS_3D_URL,\n type BdTopoBuilding,\n batiments3d,\n bdtopoBuildings,\n bdtopoRoofs,\n type GeocodedPlace,\n geoplateformeGeocode,\n geoplateformeWfs,\n geoplateformeWms,\n geoplateformeWmts,\n IGN_ATTRIBUTION,\n IGN_PRESETS,\n type IgnPreset,\n lambert93Grid,\n} from './geoplateforme.ts';\nexport { type Grid, windAt, windFields } from './grids.ts';\nexport type { CustomFrame, CustomLayerInterface } from './layers/custom.ts';\nexport { CustomLayer } from './layers/custom.ts';\nexport type { ExtrusionOptions, ExtrusionStyle, PolygonArrays, TileKey } from './layers/extrusions.ts';\nexport { ExtrusionLayer } from './layers/extrusions.ts';\nexport type {\n CircleOptions,\n CircleStyle,\n Feature,\n FeatureCollection,\n FeatureData,\n FeatureLayerStyle,\n FillOptions,\n FillStyle,\n Geometry,\n LineOptions,\n LineStyle,\n Position,\n Properties,\n Ramp,\n Size,\n Stops,\n Styled,\n} from './layers/features.ts';\nexport { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColor } from './layers/features.ts';\nexport type { FlowField, FlowOptions, FlowStyle, TimedField } from './layers/flow.ts';\nexport { FlowLayer, flowFieldFromImage, flowFieldsFromImage } from './layers/flow.ts';\nexport type { TextPart } from './layers/glyphs.ts';\nexport { DEFAULT_FONT, GLYPHS_URL } from './layers/glyphs.ts';\nexport type { GroundOptions, GroundTexture, GroundUniform } from './layers/ground.ts';\nexport { GroundLayer } from './layers/ground.ts';\nexport type { ImageOptions, Pixels, SpriteIcon } from './layers/icons.ts';\nexport { Layer } from './layers/layers.ts';\nexport type { ModelInstance, ModelOptions } from './layers/models.ts';\nexport { ModelLayer } from './layers/models.ts';\nexport { NetworkLayer } from './layers/network.ts';\nexport {\n type CalibratedPanoramaOptions,\n type Panorama,\n type PanoramaOptions,\n type PanoramaPhoto,\n Panoramas,\n type PhotoPanoramaOptions,\n} from './layers/panoramas.ts';\nexport { type PhotoOptions, photoModel } from './layers/photos.ts';\nexport type { ClassStyle, PointCloudOptions, PointCloudStyle, PointColor } from './layers/pointclouds.ts';\nexport { CLASSIFICATIONS, ELEVATION_RAMP, PointCloudLayer } from './layers/pointclouds.ts';\nexport { RasterLayer } from './layers/raster.ts';\nexport type { Overlap, SymbolOptions, SymbolStyle } from './layers/symbols.ts';\nexport { SymbolLayer } from './layers/symbols.ts';\nexport { Tiles3dLayer } from './layers/tiles3d.ts';\nexport { type TreeKind, type TreeOptions, treeKind } from './layers/trees.ts';\nexport { type VectorFeature, VectorLayer, type VectorSublayer } from './layers/vectors.ts';\nexport type { HoverPicking } from './map/hover-pick.ts';\nexport { GeoMap, type LayerSpec } from './map.ts';\nexport {\n PANORAMAX_API,\n type PanoramaxPicture,\n type PanoramaxSequenceOptions,\n panoramaxPanoramas,\n panoramaxPhoto,\n panoramaxPicture,\n panoramaxSequence,\n panoramaxStyle,\n} from './panoramax.ts';\nexport type {\n AnimationOptions,\n AtmosphereOptions,\n Basemap,\n BasemapName,\n BodyOptions,\n CelestialBody,\n FeatureColor,\n FeatureHit,\n FirstPersonView,\n FlyToOptions,\n GeoMapOptions,\n LoadingMode,\n LonLat,\n MapEvents,\n MapGpuTimings,\n MapHoverFeatureEvent,\n MapPointerEvent,\n NetworkOptions,\n NetworkStyle,\n PickOptions,\n Placement,\n Point,\n Projection,\n Quality,\n RasterGrid,\n RasterOptions,\n RasterStyle,\n SunOptions,\n SwipeOptions,\n TerrainEncoding,\n TerrainModel,\n TerrainOptions,\n Tiles3dDrape,\n Tiles3dOptions,\n Tiles3dStyle,\n ViewshedOptions,\n} from './types.ts';\nexport {\n AttributionControl,\n type AttributionOptions,\n type Control,\n type ControlPosition,\n NavigationControl,\n type NavigationOptions,\n} from './ui/controls.ts';\nexport { MinimapControl, type MinimapOptions } from './ui/minimap.ts';\nexport {\n type Anchor,\n Marker,\n type MarkerEvent,\n type MarkerEvents,\n type MarkerOptions,\n Panel,\n type PanelOptions,\n Popup,\n type PopupEvents,\n type PopupOptions,\n} from './ui/overlay.ts';\nexport { lengthLabel, roundLength, ScaleControl, type ScaleOptions } from './ui/scale.ts';\nexport { SearchControl, type SearchOptions } from './ui/search.ts';\nexport { setRequestHeaders } from './util/requests.ts';\nexport type { RoofMode } from './util/roofs.ts';\nexport { sunPosition } from './util/sun.ts';\nexport type {\n Camera,\n NetworkStats,\n PickHit,\n PickResult,\n PointCloudInfo,\n PointCloudPoint,\n PointCloudStats,\n RasterLayerStats,\n Tiles3dStats,\n} from './wasm/isard_webgpu.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EACL,OAAO,EAIP,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAuB,M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map engine for large, interactive data layers, labels and 3D Tiles.\n *\n * ```ts\n * import { GeoMap } from 'isard';\n * const map = await GeoMap.create(container, { center: [2.4246, 48.8457], zoom: 13 });\n * const network = map.addNetwork({ nodes, edges, max: 1800, contour: 300 });\n * map.on('hover', ({ lonLat }) => lonLat && network.setValues(travelTimes(lonLat)));\n * map.addTiles3d({ url: 'https://…/tileset.json' });\n * map.addControl(new NavigationControl());\n * new Marker().setLonLat([2.4246, 48.8457]).setPopup(new Popup({ offset: [0, -34] }).setText('Here')).addTo(map);\n * ```\n */\nexport { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from './basemap/basemaps.ts';\nexport type { TileGrid, TileMatrix } from './basemap/grid.ts';\nexport { coniferModel, type TreeColors, treeModel } from './basemap/models/trees.ts';\nexport {\n PMTiles,\n type PmtilesEntry,\n type PmtilesHeader,\n type PmtilesTileType,\n tileIdToZxy,\n zxyToTileId,\n} from './basemap/pmtiles.ts';\nexport { basicStyle, type PmtilesOptions } from './basemap/pmtileslayer.ts';\nexport type {\n CandidateIcon,\n CandidateOverlap,\n Json,\n LabelCandidate,\n RasterSource,\n Style,\n StyleLayer,\n} from './basemap/vectorstyle.ts';\nexport type { VectorExtrusionOptions } from './basemap/vectortiles/extrusions.ts';\nexport type { FurnitureOptions } from './basemap/vectortiles/furniture.ts';\nexport type { LabelsOptions } from './basemap/vectortiles/labels.ts';\nexport type { LampsOptions } from './basemap/vectortiles/lamps.ts';\nexport type { StreetWindLayer, StreetWindOptions } from './basemap/vectortiles/street-wind.ts';\nexport type { LoadedStyle } from './basemap/vectortiles/style.ts';\nexport type { TreesOptions } from './basemap/vectortiles/trees.ts';\nexport { isStreet, type VectorsOptions } from './basemap/vectortiles/vectors.ts';\nexport type { VectorRasterOptions, VectorTilesOptions } from './basemap/vectortiles.ts';\nexport { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from './basemap/vectortiles.ts';\nexport { parseWmtsGrid, wmtsGrid } from './basemap/wmts.ts';\nexport { type ColladaImages, colladaImages, loadCollada, parseCollada } from './data/collada.ts';\nexport {\n type Crs,\n type CrsLike,\n getCrs,\n lambertConformalConic,\n registerCrs,\n reproject,\n transverseMercator,\n} from './data/crs.ts';\nexport { parseGpx } from './data/gpx.ts';\nexport {\n type IfcElement,\n type IfcModel,\n type IfcOptions,\n type IfcPlace,\n type IfcProperties,\n type IfcStorey,\n loadIfc,\n WEB_IFC,\n} from './data/ifc.ts';\nexport { parseKml } from './data/kml.ts';\nexport { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';\nexport type { DecoderUrls } from './decoding/decoders.ts';\nexport {\n BATIMENTS_3D_URL,\n type BdTopoBuilding,\n batiments3d,\n bdtopoBuildings,\n bdtopoRoofs,\n type GeocodedPlace,\n geoplateformeGeocode,\n geoplateformeWfs,\n geoplateformeWms,\n geoplateformeWmts,\n IGN_ATTRIBUTION,\n IGN_PRESETS,\n type IgnPreset,\n lambert93Grid,\n} from './geoplateforme.ts';\nexport { type Grid, windAt, windFields } from './grids.ts';\nexport type { CustomFrame, CustomLayerInterface } from './layers/custom.ts';\nexport { CustomLayer } from './layers/custom.ts';\nexport type { ExtrusionOptions, ExtrusionStyle, PolygonArrays, TileKey } from './layers/extrusions.ts';\nexport { ExtrusionLayer } from './layers/extrusions.ts';\nexport type {\n CircleOptions,\n CircleStyle,\n Feature,\n FeatureCollection,\n FeatureData,\n FeatureLayerStyle,\n FillOptions,\n FillStyle,\n Geometry,\n LineOptions,\n LineStyle,\n Position,\n Properties,\n Ramp,\n Size,\n Stops,\n Styled,\n} from './layers/features.ts';\nexport { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColor } from './layers/features.ts';\nexport type { FlowField, FlowOptions, FlowStyle, TimedField } from './layers/flow.ts';\nexport { FlowLayer, flowFieldFromImage, flowFieldsFromImage } from './layers/flow.ts';\nexport type { TextPart } from './layers/glyphs.ts';\nexport { DEFAULT_FONT, GLYPHS_URL } from './layers/glyphs.ts';\nexport type { GroundOptions, GroundTexture, GroundUniform } from './layers/ground.ts';\nexport { GroundLayer } from './layers/ground.ts';\nexport type { ImageOptions, Pixels, SpriteIcon } from './layers/icons.ts';\nexport { Layer } from './layers/layers.ts';\nexport type { ModelInstance, ModelOptions } from './layers/models.ts';\nexport { ModelLayer } from './layers/models.ts';\nexport { NetworkLayer } from './layers/network.ts';\nexport {\n type CalibratedPanoramaOptions,\n type Panorama,\n type PanoramaOptions,\n type PanoramaPhoto,\n Panoramas,\n type PhotoPanoramaOptions,\n} from './layers/panoramas.ts';\nexport { type PhotoOptions, photoModel } from './layers/photos.ts';\nexport type { ClassStyle, PointCloudOptions, PointCloudStyle, PointColor } from './layers/pointclouds.ts';\nexport { CLASSIFICATIONS, ELEVATION_RAMP, PointCloudLayer } from './layers/pointclouds.ts';\nexport { RasterLayer } from './layers/raster.ts';\nexport type { Overlap, SymbolOptions, SymbolStyle } from './layers/symbols.ts';\nexport { SymbolLayer } from './layers/symbols.ts';\nexport { Tiles3dLayer } from './layers/tiles3d.ts';\nexport { type TreeKind, type TreeOptions, treeKind } from './layers/trees.ts';\nexport { type VectorFeature, VectorLayer, type VectorSublayer } from './layers/vectors.ts';\nexport type { HoverPicking } from './map/hover-pick.ts';\nexport { GeoMap, type LayerSpec } from './map.ts';\nexport {\n PANORAMAX_API,\n type PanoramaxPicture,\n type PanoramaxSequenceOptions,\n panoramaxPanoramas,\n panoramaxPhoto,\n panoramaxPicture,\n panoramaxSequence,\n panoramaxStyle,\n} from './panoramax.ts';\nexport type {\n AnimationOptions,\n AtmosphereOptions,\n Basemap,\n BasemapName,\n BodyOptions,\n CelestialBody,\n Drape,\n FeatureColor,\n FeatureHit,\n FirstPersonView,\n FlyToOptions,\n GeoMapOptions,\n LoadingMode,\n LonLat,\n MapEvents,\n MapGpuTimings,\n MapHoverFeatureEvent,\n MapMemory,\n MapPointerEvent,\n NetworkOptions,\n NetworkStyle,\n PickOptions,\n Placement,\n Point,\n Projection,\n Quality,\n RasterGrid,\n RasterOptions,\n RasterStyle,\n SunOptions,\n SwipeOptions,\n TerrainEncoding,\n TerrainModel,\n TerrainOptions,\n Tiles3dOptions,\n Tiles3dStyle,\n ViewshedOptions,\n} from './types.ts';\nexport {\n AttributionControl,\n type AttributionOptions,\n type Control,\n type ControlPosition,\n NavigationControl,\n type NavigationOptions,\n} from './ui/controls.ts';\nexport { MinimapControl, type MinimapOptions } from './ui/minimap.ts';\nexport {\n type Anchor,\n Marker,\n type MarkerEvent,\n type MarkerEvents,\n type MarkerOptions,\n Panel,\n type PanelOptions,\n Popup,\n type PopupEvents,\n type PopupOptions,\n} from './ui/overlay.ts';\nexport { lengthLabel, roundLength, ScaleControl, type ScaleOptions } from './ui/scale.ts';\nexport { SearchControl, type SearchOptions } from './ui/search.ts';\nexport { setRequestHeaders } from './util/requests.ts';\nexport type { RoofMode } from './util/roofs.ts';\nexport { sunPosition } from './util/sun.ts';\nexport type {\n Camera,\n NetworkStats,\n PickHit,\n PickResult,\n PointCloudInfo,\n PointCloudPoint,\n PointCloudStats,\n RasterLayerStats,\n Tiles3dStats,\n} from './wasm/isard_webgpu.js';\n"]}
Binary file
Binary file