isard 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +46 -39
  3. package/dist/basemap/basemaps.js +1 -0
  4. package/dist/basemap/basemaps.js.map +1 -1
  5. package/dist/basemap/pmtileslayer.d.ts +33 -0
  6. package/dist/basemap/pmtileslayer.js +97 -0
  7. package/dist/basemap/pmtileslayer.js.map +1 -0
  8. package/dist/basemap/trees.d.ts +26 -0
  9. package/dist/basemap/trees.js +141 -0
  10. package/dist/basemap/trees.js.map +1 -0
  11. package/dist/basemap/vectorstyle.d.ts +10 -0
  12. package/dist/basemap/vectorstyle.js +35 -0
  13. package/dist/basemap/vectorstyle.js.map +1 -1
  14. package/dist/basemap/vectortiles.d.ts +93 -44
  15. package/dist/basemap/vectortiles.js +511 -303
  16. package/dist/basemap/vectortiles.js.map +1 -1
  17. package/dist/basemap/workerpool.d.ts +17 -0
  18. package/dist/basemap/workerpool.js +203 -0
  19. package/dist/basemap/workerpool.js.map +1 -0
  20. package/dist/basemap.worker.js +2 -2
  21. package/dist/basemap.worker.js.map +18 -8
  22. package/dist/bind/layers.js +10 -0
  23. package/dist/bind/layers.js.map +1 -1
  24. package/dist/decoder.worker.js +4 -4
  25. package/dist/decoder.worker.js.map +3 -3
  26. package/dist/engine-loader.d.ts +8 -1
  27. package/dist/engine-loader.js +20 -1
  28. package/dist/engine-loader.js.map +1 -1
  29. package/dist/geoplateforme.d.ts +16 -0
  30. package/dist/geoplateforme.js +23 -0
  31. package/dist/geoplateforme.js.map +1 -1
  32. package/dist/grid-module.d.ts +44 -0
  33. package/dist/grid-module.js +63 -0
  34. package/dist/grid-module.js.map +1 -0
  35. package/dist/grids.d.ts +51 -0
  36. package/dist/grids.js +88 -0
  37. package/dist/grids.js.map +1 -0
  38. package/dist/index.d.ts +14 -4
  39. package/dist/index.js +11 -2
  40. package/dist/index.js.map +1 -1
  41. package/dist/isard_bg.wasm +0 -0
  42. package/dist/isard_core_bg.wasm +0 -0
  43. package/dist/isard_grid_bg.wasm +0 -0
  44. package/dist/isard_tess_bg.wasm +0 -0
  45. package/dist/layers/flow.d.ts +111 -0
  46. package/dist/layers/flow.js +222 -0
  47. package/dist/layers/flow.js.map +1 -0
  48. package/dist/layers/layers.js +9 -0
  49. package/dist/layers/layers.js.map +1 -1
  50. package/dist/layers/symbols.d.ts +2 -0
  51. package/dist/layers/symbols.js +2 -1
  52. package/dist/layers/symbols.js.map +1 -1
  53. package/dist/layers/vectors.d.ts +60 -0
  54. package/dist/layers/vectors.js +130 -0
  55. package/dist/layers/vectors.js.map +1 -0
  56. package/dist/map/frame-loop.d.ts +3 -0
  57. package/dist/map/frame-loop.js +6 -0
  58. package/dist/map/frame-loop.js.map +1 -1
  59. package/dist/map/layer-spec.d.ts +4 -1
  60. package/dist/map/layer-spec.js +2 -0
  61. package/dist/map/layer-spec.js.map +1 -1
  62. package/dist/map/raster-source.js +1 -1
  63. package/dist/map/raster-source.js.map +1 -1
  64. package/dist/map/workers.d.ts +5 -1
  65. package/dist/map/workers.js +36 -1
  66. package/dist/map/workers.js.map +1 -1
  67. package/dist/map.d.ts +35 -6
  68. package/dist/map.js +83 -11
  69. package/dist/map.js.map +1 -1
  70. package/dist/react/IsardMap.js +1 -0
  71. package/dist/react/IsardMap.js.map +1 -1
  72. package/dist/react/Layer.d.ts +2 -0
  73. package/dist/react/Layer.js.map +1 -1
  74. package/dist/react/Swipe.d.ts +11 -4
  75. package/dist/react/Swipe.js +26 -15
  76. package/dist/react/Swipe.js.map +1 -1
  77. package/dist/react/VectorGeometry.d.ts +35 -0
  78. package/dist/react/VectorGeometry.js +82 -0
  79. package/dist/react/VectorGeometry.js.map +1 -0
  80. package/dist/react/context.d.ts +2 -1
  81. package/dist/react/context.js.map +1 -1
  82. package/dist/react/index.d.ts +2 -1
  83. package/dist/react/index.js +2 -1
  84. package/dist/react/index.js.map +1 -1
  85. package/dist/types.d.ts +30 -3
  86. package/dist/types.js.map +1 -1
  87. package/dist/ui/minimap.d.ts +25 -0
  88. package/dist/ui/minimap.js +90 -0
  89. package/dist/ui/minimap.js.map +1 -0
  90. package/dist/ui/scale.d.ts +19 -0
  91. package/dist/ui/scale.js +44 -0
  92. package/dist/ui/scale.js.map +1 -0
  93. package/dist/ui/search.d.ts +25 -0
  94. package/dist/ui/search.js +119 -0
  95. package/dist/ui/search.js.map +1 -0
  96. package/dist/ui/style.js +17 -0
  97. package/dist/ui/style.js.map +1 -1
  98. package/dist/util/sun.d.ts +11 -0
  99. package/dist/util/sun.js +26 -0
  100. package/dist/util/sun.js.map +1 -0
  101. package/dist/wasm/isard.d.ts +124 -7
  102. package/dist/wasm/isard.js +319 -8
  103. package/dist/wasm/isard_core.d.ts +124 -7
  104. package/dist/wasm/isard_core.js +319 -8
  105. package/dist/wasm/isard_grid.d.ts +101 -0
  106. package/dist/wasm/isard_grid.js +375 -0
  107. package/dist/wasm/isard_tess.d.ts +109 -0
  108. package/dist/wasm/isard_tess.js +398 -0
  109. package/dist/workers/basemap/geometry.d.ts +72 -0
  110. package/dist/workers/basemap/labels.d.ts +8 -0
  111. package/dist/workers/basemap/raster.d.ts +10 -0
  112. package/dist/workers/basemap/street.d.ts +19 -0
  113. package/dist/workers/basemap/tiles.d.ts +65 -0
  114. package/dist/workers/basemap/trees.d.ts +19 -0
  115. package/dist/workers/basemap.worker.d.ts +147 -22
  116. package/dist/workers/basemap.worker.js +93 -553
  117. package/dist/workers/basemap.worker.js.map +1 -1
  118. package/package.json +6 -4
  119. package/vite.js +11 -2
@@ -2,17 +2,27 @@
2
2
  * Worker of the vector basemaps: fetches and decodes vector tiles (kept for the tiles that share them), draws their
3
3
  * fills, lines and circles with a MapLibre style into images (Canvas 2D, off the main thread) for the raster pool,
4
4
  * with the style's raster layers under them, and lists the label candidates of the style's symbol layers (their texts
5
- * and icons) for the page to shape and place. Extrusions are drawn flat, as fills. It also decodes the altitudes of PNG relief tiles and
6
- * draws the rasters reprojected from other grids (planned by the page), for the map's other layers.
5
+ * and icons) for the page to shape and place. Extrusions are drawn flat, as fills. Or it cuts the fills, lines and
6
+ * buildings of a tile into geometry for the engine to draw as such (`vectors`), with their style per feature (a
7
+ * building's color, height and base height). It also decodes the
8
+ * altitudes of PNG relief tiles and draws the rasters reprojected from other grids (planned by the page), for the
9
+ * map's other layers.
7
10
  *
8
11
  * A raster tile of level z covers 256 CSS pixels at map zoom z - 1 (MapLibre's 512 px convention): it is drawn from
9
12
  * the vector tile of level z - 1 (or the deepest one the source has), with the style at that zoom.
13
+ *
14
+ * This module answers the page's messages; the jobs are in `./basemap/`: the state they share (`tiles.ts`), the
15
+ * images (`raster.ts`), the labels (`labels.ts`), the geometry (`geometry.ts`), the trees (`trees.ts`).
10
16
  */
17
+ import type { Value } from '../basemap/mvt.ts';
11
18
  import { type Job } from '../basemap/resample.ts';
12
19
  import { type PngEncoding } from '../basemap/terrain.ts';
13
20
  import { type LabelCandidate, type RasterSource, type StyleLayer } from '../basemap/vectorstyle.ts';
14
21
  import { type HeaderRules } from '../engine/requests.ts';
15
- export type { LabelCandidate, RasterSource };
22
+ import { type GridDescription, type StreetFlows } from '../grid-module.ts';
23
+ import { type StreetWork } from './basemap/street.ts';
24
+ import { type Sprite } from './basemap/tiles.ts';
25
+ export type { LabelCandidate, RasterSource, Sprite };
16
26
  /** Fetch priority of a request (`fetch`'s `priority`, a hint to the browser) */
17
27
  export type Priority = 'high' | 'low' | 'auto';
18
28
  /** A tile's image or labels, asked of a worker; or a tile of another layer decoded: the altitudes of a PNG relief
@@ -35,11 +45,60 @@ export type BasemapWork = {
35
45
  y: number;
36
46
  zoom?: number;
37
47
  priority?: Priority;
48
+ }
49
+ /** The polygons of the renderer's layers (buildings), for extrusions */
50
+ | {
51
+ type: 'polygons';
52
+ key: string;
53
+ z: number;
54
+ x: number;
55
+ y: number;
56
+ priority?: Priority;
57
+ }
58
+ /** Trees scattered over the polygons of the renderer's layers, `spacing[s]` metres apart in layer `s` (0: none), at
59
+ * most `maxTrees` */
60
+ | {
61
+ type: 'trees';
62
+ key: string;
63
+ z: number;
64
+ x: number;
65
+ y: number;
66
+ spacing: number[];
67
+ maxTrees: number;
68
+ priority?: Priority;
69
+ }
70
+ /** The fills and lines of the renderer's layers cut to the tile, for the engine to draw as geometry; `styles`: their
71
+ * style only, the layers' paint changed (the same features, in the same order). A tile past the source's deepest
72
+ * level is cut from its tile of that level (overzoom); `deepest`, the deepest level asked for (default the
73
+ * source's), is styled past itself, as the map stretches it */
74
+ | {
75
+ type: 'vectors';
76
+ key: string;
77
+ z: number;
78
+ x: number;
79
+ y: number;
80
+ deepest?: number;
81
+ styles?: boolean;
82
+ /** With the prisms of the fills (a relief under them) */
83
+ prism?: boolean;
84
+ priority?: Priority;
38
85
  } | {
39
86
  type: 'heights';
40
87
  url: string;
41
88
  encoding: PngEncoding;
42
89
  floor?: number;
90
+ }
91
+ /** The wind of a city's streets round the buildings of the renderer's layers (see `StreetWork`) */
92
+ | ({
93
+ type: 'street';
94
+ key: string;
95
+ } & StreetWork)
96
+ /** A GRIB2 or NetCDF file (fetched from `url`, or its `bytes`) read into grids by the grid module (`module`) */
97
+ | {
98
+ type: 'grids';
99
+ module: string;
100
+ url?: string;
101
+ bytes?: ArrayBuffer;
43
102
  } | {
44
103
  type: 'reproject';
45
104
  job: Job;
@@ -50,6 +109,11 @@ export type BasemapRequest =
50
109
  {
51
110
  type: 'headers';
52
111
  rules: HeaderRules;
112
+ }
113
+ /** Where the tessellation module is (`isard_tess_bg.wasm`), loaded with the first `vectors` job */
114
+ | {
115
+ type: 'tess';
116
+ url: string;
53
117
  } | {
54
118
  type: 'init';
55
119
  /** Renderers by key: each draws its own layers of the same source */
@@ -86,29 +150,90 @@ export type BasemapResponse = {
86
150
  } | {
87
151
  id: number;
88
152
  labels: LabelCandidate[];
153
+ } | {
154
+ id: number;
155
+ polygons: TilePolygons;
156
+ } | {
157
+ id: number;
158
+ trees: Float64Array;
159
+ } | {
160
+ id: number;
161
+ vectors: TileVectors;
162
+ } | {
163
+ id: number;
164
+ styles: Float32Array;
89
165
  } | {
90
166
  id: number;
91
167
  heights: Float32Array;
168
+ } | {
169
+ id: number;
170
+ grids: GridDescription[];
171
+ values: Float32Array[];
172
+ } | {
173
+ id: number;
174
+ street: StreetFlows;
92
175
  };
93
- /** A sprite of the style: its images by name (`id:name` but in the default sprite) and its sheet */
94
- export interface Sprite {
95
- image: ImageBitmap;
96
- icons: Record<string, {
97
- x: number;
98
- y: number;
99
- width: number;
100
- height: number;
101
- pixelRatio?: number;
102
- }>;
176
+ /** The polygons of a tile in Mercator [0, 1], as the extrusions take them (`PolygonArrays`), and their properties */
177
+ export interface TilePolygons {
178
+ arrays: {
179
+ points: Float64Array;
180
+ ringStart: Uint32Array;
181
+ polygonStart: Uint32Array;
182
+ feature: Uint32Array;
183
+ };
184
+ properties: Record<string, Value>[];
103
185
  }
104
- /** The decoded tiles one worker of `workers` keeps */
105
- export declare const cacheShare: (workers: number) => number;
106
186
  /**
107
- * The image of a drawn canvas, its alpha straight (the engine blends straight alpha). An opaque tile (a background
108
- * of full opacity, as a basemap's) is moved out of the canvas as it is, premultiplied and straight being the same
109
- * there; another one is read back unpremultiplied, copied
187
+ * The geometry of a vector tile for the engine (`setVectorTile`), in Mercator [0, 1], cut to the tile: a styled
188
+ * feature is a feature of the tile in one of the renderer's layers (the sublayers, in their order), numbered layer
189
+ * after layer. The polygons and lines of sublayer `s` are `fillStart[s] .. fillStart[s + 1]` and `lineStart[s] ..
190
+ * lineStart[s + 1]` (one more entry than the renderer's layers)
110
191
  */
111
- export declare const tileImage: (canvas: OffscreenCanvas, g: OffscreenCanvasRenderingContext2D, opaque: boolean) => Promise<ImageBitmap>;
112
- /** Points every `spacing` along a line (tile units, x and y interleaved), the first half a spacing in (the middle of a
113
- * shorter line): each point and the segment it lies on (x, y, x0, y0, x1, y1) */
114
- export declare const lineAnchors: (line: readonly number[], spacing: number) => number[][];
192
+ export interface TileVectors {
193
+ fills: {
194
+ points: Float64Array;
195
+ ringStart: Uint32Array;
196
+ polygonStart: Uint32Array;
197
+ feature: Uint32Array;
198
+ fillStart: Uint32Array;
199
+ };
200
+ lines: {
201
+ points: Float64Array;
202
+ start: Uint32Array;
203
+ feature: Uint32Array;
204
+ lineStart: Uint32Array;
205
+ };
206
+ /** The style of each styled feature, `FLOATS` (32) each, as the engine's line layers take it */
207
+ styles: Float32Array;
208
+ /** The tile's corners (west, north, east, south, Mercator): no wall of a building along its edges, where one cut
209
+ * there goes on in the next tile */
210
+ tile?: Float64Array;
211
+ /** Its feature's properties (shared by the styled features of one feature) and its sublayer */
212
+ properties: Record<string, Value>[];
213
+ sublayer: Uint16Array;
214
+ /** The geometry made ready for the GPU by the tessellation module (the engine's `setVectorTileMesh`); without it,
215
+ * the engine does that on the main thread */
216
+ mesh?: TileMesh;
217
+ }
218
+ /** A vector tile ready for the GPU, as the tessellation module makes it (`TessellatedTile`) */
219
+ export interface TileMesh {
220
+ /** Fill vertices, as bytes */
221
+ vertices: Uint8Array;
222
+ indices: Uint32Array;
223
+ /** Per sublayer: its top cap and the rest of its prism, first and end of each */
224
+ fillRanges: Uint32Array;
225
+ prism: boolean;
226
+ /** Line pieces, as bytes */
227
+ pieces: Uint8Array;
228
+ /** Feature and length of each line */
229
+ lineTable: Float32Array;
230
+ /** Per sublayer: its pieces, first and end */
231
+ lineRanges: Uint32Array;
232
+ /** Blocks of the extrusion sublayers (buildings), as bytes */
233
+ blocks: Uint8Array;
234
+ blockIndices: Uint32Array;
235
+ /** Per sublayer: its blocks' triangles, first and end */
236
+ blockRanges: Uint32Array;
237
+ /** Min x, min y, max x, max y of the tile's points */
238
+ bounds: Float64Array;
239
+ }