isard 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/dist/basemap/furniture.d.ts +20 -2
- package/dist/basemap/furniture.js +72 -3
- package/dist/basemap/furniture.js.map +1 -1
- package/dist/basemap/meshes.d.ts +21 -0
- package/dist/basemap/meshes.js +159 -0
- package/dist/basemap/meshes.js.map +1 -0
- package/dist/basemap/placed.d.ts +13 -0
- package/dist/basemap/placed.js +14 -0
- package/dist/basemap/placed.js.map +1 -0
- package/dist/basemap/trees.d.ts +4 -14
- package/dist/basemap/trees.js +12 -93
- package/dist/basemap/trees.js.map +1 -1
- package/dist/basemap/vectortiles/context.d.ts +4 -2
- package/dist/basemap/vectortiles/context.js.map +1 -1
- package/dist/basemap/vectortiles/extrusions.d.ts +1 -1
- package/dist/basemap/vectortiles/extrusions.js +7 -16
- package/dist/basemap/vectortiles/extrusions.js.map +1 -1
- package/dist/basemap/vectortiles/furniture.d.ts +19 -0
- package/dist/basemap/vectortiles/furniture.js +29 -0
- package/dist/basemap/vectortiles/furniture.js.map +1 -0
- package/dist/basemap/vectortiles/labels.js +8 -1
- package/dist/basemap/vectortiles/labels.js.map +1 -1
- package/dist/basemap/vectortiles/lamps.js +11 -76
- package/dist/basemap/vectortiles/lamps.js.map +1 -1
- package/dist/basemap/vectortiles/placed.d.ts +38 -0
- package/dist/basemap/vectortiles/placed.js +143 -0
- package/dist/basemap/vectortiles/placed.js.map +1 -0
- package/dist/basemap/vectortiles/street-wind.js +4 -6
- package/dist/basemap/vectortiles/street-wind.js.map +1 -1
- package/dist/basemap/vectortiles/trees.d.ts +2 -9
- package/dist/basemap/vectortiles/trees.js +34 -165
- package/dist/basemap/vectortiles/trees.js.map +1 -1
- package/dist/basemap/vectortiles/vectors.d.ts +4 -5
- package/dist/basemap/vectortiles/vectors.js +17 -16
- package/dist/basemap/vectortiles/vectors.js.map +1 -1
- package/dist/basemap/vectortiles.d.ts +14 -4
- package/dist/basemap/vectortiles.js +40 -12
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap/wmts.js +2 -2
- package/dist/basemap/wmts.js.map +1 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +18 -14
- package/dist/bind/layers.d.ts +10 -3
- package/dist/bind/layers.js +11 -4
- package/dist/bind/layers.js.map +1 -1
- package/dist/data/collada.js +3 -17
- package/dist/data/collada.js.map +1 -1
- package/dist/data/crs.js +1 -1
- package/dist/data/crs.js.map +1 -1
- package/dist/data/ifc.js +21 -22
- package/dist/data/ifc.js.map +1 -1
- package/dist/geoplateforme.d.ts +16 -4
- package/dist/geoplateforme.js +26 -4
- package/dist/geoplateforme.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/isard_grid_bg.wasm +0 -0
- package/dist/isard_tess_bg.wasm +0 -0
- package/dist/layers/extrusions.js +5 -4
- package/dist/layers/extrusions.js.map +1 -1
- package/dist/layers/features.d.ts +0 -2
- package/dist/layers/features.js +5 -6
- package/dist/layers/features.js.map +1 -1
- package/dist/layers/layers.d.ts +2 -0
- package/dist/layers/layers.js +11 -0
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/panoramas.d.ts +32 -10
- package/dist/layers/panoramas.js +55 -28
- package/dist/layers/panoramas.js.map +1 -1
- package/dist/layers/photos.js +5 -6
- package/dist/layers/photos.js.map +1 -1
- package/dist/layers/trees.js +7 -7
- package/dist/layers/trees.js.map +1 -1
- package/dist/layers/vectors.d.ts +1 -0
- package/dist/layers/vectors.js +23 -8
- package/dist/layers/vectors.js.map +1 -1
- package/dist/map/frame-loop.d.ts +2 -0
- package/dist/map/frame-loop.js +3 -3
- package/dist/map/frame-loop.js.map +1 -1
- package/dist/map.js +17 -0
- package/dist/map.js.map +1 -1
- package/dist/panoramax.d.ts +19 -0
- package/dist/panoramax.js +48 -3
- package/dist/panoramax.js.map +1 -1
- package/dist/react/CustomLayer.js +5 -4
- package/dist/react/CustomLayer.js.map +1 -1
- package/dist/react/Layer.d.ts +1 -1
- package/dist/react/Layer.js +6 -5
- package/dist/react/Layer.js.map +1 -1
- package/dist/react/VectorGeometry.d.ts +18 -9
- package/dist/react/VectorGeometry.js +30 -15
- package/dist/react/VectorGeometry.js.map +1 -1
- package/dist/react/VectorTiles.d.ts +65 -0
- package/dist/react/VectorTiles.js +112 -0
- package/dist/react/VectorTiles.js.map +1 -0
- package/dist/react/context.d.ts +12 -0
- package/dist/react/context.js +40 -1
- package/dist/react/context.js.map +1 -1
- package/dist/react/index.d.ts +7 -1
- package/dist/react/index.js +7 -1
- package/dist/react/index.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.js.map +1 -1
- package/dist/util/geo.d.ts +8 -0
- package/dist/util/geo.js +8 -0
- package/dist/util/geo.js.map +1 -1
- package/dist/util/gltf.d.ts +18 -1
- package/dist/util/gltf.js +26 -1
- package/dist/util/gltf.js.map +1 -1
- package/dist/util/roofs.d.ts +8 -0
- package/dist/util/roofs.js +16 -2
- package/dist/util/roofs.js.map +1 -1
- package/dist/util/style-floats.d.ts +33 -0
- package/dist/util/style-floats.js +34 -0
- package/dist/util/style-floats.js.map +1 -0
- package/dist/util/sun.js +1 -1
- package/dist/util/sun.js.map +1 -1
- package/dist/workers/basemap/furniture.d.ts +13 -0
- package/dist/workers/basemap/geometry.d.ts +2 -5
- package/dist/workers/basemap/labels.d.ts +5 -2
- package/dist/workers/basemap/lamps.d.ts +3 -3
- package/dist/workers/basemap/tiles.d.ts +2 -0
- package/dist/workers/basemap/trees.d.ts +3 -0
- package/dist/workers/basemap.worker.d.ts +17 -1
- package/dist/workers/basemap.worker.js +12 -1
- package/dist/workers/basemap.worker.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { type Renderer } from './tiles.ts';
|
|
|
4
4
|
/**
|
|
5
5
|
* Lamps along the lines of the renderer's layers in a tile, `spacing` metres apart along each street, every other
|
|
6
6
|
* one on its other side, as far from its middle as its class says (`SIDE_METRES`): longitude, latitude, scale, heading
|
|
7
|
-
* (degrees, facing the street) and rank (in [0, 1): the page keeps the lowest far from the view) of each, as
|
|
8
|
-
*
|
|
7
|
+
* (degrees, facing the street) and rank (in [0, 1): the page keeps the lowest far from the view) of each, as things
|
|
8
|
+
* placed (`PLACED_NUMBERS`, the kind 0); past `maxLamps`, thinned evenly. A street in several layers has its lamps once
|
|
9
9
|
*/
|
|
10
|
-
export declare const lamps: (r: Renderer, z: number, x: number, y: number, id: number, spacing: number, maxLamps: number, priority?: Priority) => Promise<Float64Array<
|
|
10
|
+
export declare const lamps: (r: Renderer, z: number, x: number, y: number, id: number, spacing: number, maxLamps: number, priority?: Priority) => Promise<Float64Array<ArrayBufferLike> | undefined>;
|
|
@@ -47,6 +47,8 @@ export declare const aborted: Set<number>;
|
|
|
47
47
|
export declare const image: (url: string, priority?: Priority) => Promise<ImageBitmap | undefined>;
|
|
48
48
|
/** A vector tile, decoded (shared by every renderer of its URL); the first request's priority fetches it */
|
|
49
49
|
export declare const tile: (url: string, priority?: Priority) => Promise<Map<string, TileLayer> | undefined>;
|
|
50
|
+
/** A tile's URL from its source's template */
|
|
51
|
+
export declare const tileUrl: (template: string, z: number, x: number, y: number) => string;
|
|
50
52
|
/** The vector tile to draw a raster tile from, and where the raster tile lies in it (tile units) */
|
|
51
53
|
export declare const source: (r: Renderer, z: number, x: number, y: number) => {
|
|
52
54
|
url: string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/** The trees of a tile: points scattered over the woods of its polygons, the same each time the tile is cut */
|
|
2
2
|
import type { Priority } from '../basemap.worker.ts';
|
|
3
3
|
import { type Renderer } from './tiles.ts';
|
|
4
|
+
/** Things placed (`PLACED_NUMBERS` each), past `max` thinned evenly by their rank: one in so many kept, the
|
|
5
|
+
* same ones each time */
|
|
6
|
+
export declare const thinned: (found: readonly number[], max: number) => Float64Array;
|
|
4
7
|
/** A number in [0, 1) from four integers, the same for the same ones: where a tree stands in its cell, its size */
|
|
5
8
|
export declare const treeHash: (a: number, b: number, c: number, d: number) => number;
|
|
6
9
|
/** Whether a point lies in rings (interleaved points, unclosed or closed), even-odd: the holes cut out */
|
|
@@ -20,7 +20,7 @@ import { type PngEncoding } from '../basemap/terrain.ts';
|
|
|
20
20
|
import { type LabelCandidate, type RasterSource, type StyleLayer } from '../basemap/vectorstyle.ts';
|
|
21
21
|
import { type HeaderRules } from '../engine/requests.ts';
|
|
22
22
|
import { type GridDescription, type StreetFlows } from '../grid-module.ts';
|
|
23
|
-
import {
|
|
23
|
+
import type { RoofMode } from '../util/roofs.ts';
|
|
24
24
|
import { type StreetWork } from './basemap/street.ts';
|
|
25
25
|
import { type Sprite } from './basemap/tiles.ts';
|
|
26
26
|
export type { LabelCandidate, RasterSource, Sprite };
|
|
@@ -45,6 +45,8 @@ export type BasemapWork = {
|
|
|
45
45
|
x: number;
|
|
46
46
|
y: number;
|
|
47
47
|
zoom?: number;
|
|
48
|
+
/** The labels in a building given its height (they stand on its roof) */
|
|
49
|
+
roofs?: boolean;
|
|
48
50
|
priority?: Priority;
|
|
49
51
|
}
|
|
50
52
|
/** The polygons of the renderer's layers (buildings), for extrusions */
|
|
@@ -68,6 +70,17 @@ export type BasemapWork = {
|
|
|
68
70
|
maxTrees: number;
|
|
69
71
|
priority?: Priority;
|
|
70
72
|
}
|
|
73
|
+
/** The street furniture of the tile (OpenMapTiles' points of interest of the street, benches along the pedestrian
|
|
74
|
+
* streets and the parks' paths), at most `maxObjects` */
|
|
75
|
+
| {
|
|
76
|
+
type: 'furniture';
|
|
77
|
+
key: string;
|
|
78
|
+
z: number;
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
maxObjects: number;
|
|
82
|
+
priority?: Priority;
|
|
83
|
+
}
|
|
71
84
|
/** Street lamps along the lines of the renderer's layers, `spacing` metres apart along each street, at most
|
|
72
85
|
* `maxLamps` */
|
|
73
86
|
| {
|
|
@@ -174,6 +187,9 @@ export type BasemapResponse = {
|
|
|
174
187
|
} | {
|
|
175
188
|
id: number;
|
|
176
189
|
lamps: Float64Array;
|
|
190
|
+
} | {
|
|
191
|
+
id: number;
|
|
192
|
+
furniture: Float64Array;
|
|
177
193
|
} | {
|
|
178
194
|
id: number;
|
|
179
195
|
vectors: TileVectors;
|
|
@@ -19,6 +19,7 @@ import { fetchHeights } from "../basemap/terrain.js";
|
|
|
19
19
|
import { vectorKind } from "../basemap/vectorstyle.js";
|
|
20
20
|
import { setHeaderRules, withHeaders } from "../engine/requests.js";
|
|
21
21
|
import { decodeGrids } from "../grid-module.js";
|
|
22
|
+
import { furniture } from "./basemap/furniture.js";
|
|
22
23
|
import { polygons, tess, tessellate, tessellator, vectors } from "./basemap/geometry.js";
|
|
23
24
|
import { labels } from "./basemap/labels.js";
|
|
24
25
|
import { lamps } from "./basemap/lamps.js";
|
|
@@ -93,6 +94,13 @@ self.onmessage = async ({ data }) => {
|
|
|
93
94
|
else
|
|
94
95
|
post({ id: data.id, trees: out }, [out.buffer]);
|
|
95
96
|
}
|
|
97
|
+
else if (data.type === 'furniture') {
|
|
98
|
+
const out = await furniture(r, data.z, data.x, data.y, data.id, data.maxObjects, data.priority);
|
|
99
|
+
if (!out)
|
|
100
|
+
post({ id: data.id, missing: true });
|
|
101
|
+
else
|
|
102
|
+
post({ id: data.id, furniture: out }, [out.buffer]);
|
|
103
|
+
}
|
|
96
104
|
else if (data.type === 'lamps') {
|
|
97
105
|
const out = await lamps(r, data.z, data.x, data.y, data.id, data.spacing, data.maxLamps, data.priority);
|
|
98
106
|
if (!out)
|
|
@@ -155,7 +163,10 @@ self.onmessage = async ({ data }) => {
|
|
|
155
163
|
}
|
|
156
164
|
}
|
|
157
165
|
else {
|
|
158
|
-
post({
|
|
166
|
+
post({
|
|
167
|
+
id: data.id,
|
|
168
|
+
labels: await labels(r, data.z, data.x, data.y, data.id, data.priority, data.zoom, data.roofs),
|
|
169
|
+
});
|
|
159
170
|
}
|
|
160
171
|
}
|
|
161
172
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basemap.worker.js","sourceRoot":"","sources":["../../src/workers/basemap.worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAY,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAkC,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAA2D,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAChH,OAAO,EAAoB,cAAc,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,WAAW,EAA0C,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAiB,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAmB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAe,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAwL3C,yFAAyF;AACzF,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEvD,kEAAkE;AAClE,MAAM,cAAc,GAAY,EAAE,CAAC;AAEnC,uFAAuF;AACvF,MAAM,YAAY,GAAG,SAAS,EAAE,CAAC;AAEjC,MAAM,IAAI,GAAG,CAAC,OAAwB,EAAE,WAA2B,EAAE,EAAE,EAAE,CACtE,IAA0B,CA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,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;;gBAC5C,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAC;YAAS,CAAC;QACT,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC,CAAC","sourcesContent":["/**\n * Worker of the vector basemaps: fetches and decodes vector tiles (kept for the tiles that share them), draws their\n * fills, lines and circles with a MapLibre style into images (Canvas 2D, off the main thread) for the raster pool,\n * with the style's raster layers under them, and lists the label candidates of the style's symbol layers (their texts\n * and icons) for the page to shape and place. Extrusions are drawn flat, as fills. Or it cuts the fills, lines and\n * buildings of a tile into geometry for the engine to draw as such (`vectors`), with their style per feature (a\n * building's color, height and base height). It also decodes the\n * altitudes of PNG relief tiles and draws the rasters reprojected from other grids (planned by the page), for the\n * map's other layers.\n *\n * A raster tile of level z covers 256 CSS pixels at map zoom z - 1 (MapLibre's 512 px convention): it is drawn from\n * the vector tile of level z - 1 (or the deepest one the source has), with the style at that zoom.\n *\n * This module answers the page's messages; the jobs are in `./basemap/`: the state they share (`tiles.ts`), the\n * images (`raster.ts`), the labels (`labels.ts`), the geometry (`geometry.ts`), the trees (`trees.ts`).\n */\n\nimport type { Value } from '../basemap/mvt.ts';\nimport { type Job, resampler } from '../basemap/resample.ts';\nimport { fetchHeights, type PngEncoding, type Surface } from '../basemap/terrain.ts';\nimport { type LabelCandidate, type RasterSource, type StyleLayer, vectorKind } from '../basemap/vectorstyle.ts';\nimport { type HeaderRules, setHeaderRules, withHeaders } from '../engine/requests.ts';\nimport { decodeGrids, type GridDescription, type StreetFlows } from '../grid-module.ts';\nimport { polygons, type RoofMode, tess, tessellate, tessellator, vectors } from './basemap/geometry.ts';\nimport { labels } from './basemap/labels.ts';\nimport { lamps } from './basemap/lamps.ts';\nimport { render } from './basemap/raster.ts';\nimport { type StreetWork, streetFlowOf } from './basemap/street.ts';\nimport { aborted, active, cache, cacheShare, renderers, type Sprite } from './basemap/tiles.ts';\nimport { trees } from './basemap/trees.ts';\n\nexport type { LabelCandidate, RasterSource, Sprite };\n\n/** Fetch priority of a request (`fetch`'s `priority`, a hint to the browser) */\nexport type Priority = 'high' | 'low' | 'auto';\n\n/** A tile's image or labels, asked of a worker; or a tile of another layer decoded: the altitudes of a PNG relief\n * tile, a Mercator tile reprojected from the source images of its plan (keeping `cached` of them) */\nexport type BasemapWork =\n | { type: 'render'; key: string; z: number; x: number; y: number; size: number; priority?: Priority }\n /** `zoom`: the zoom the style is evaluated at, past the source's deepest level (`z` by default) */\n | { type: 'labels'; key: string; z: number; x: number; y: number; zoom?: number; priority?: Priority }\n /** The polygons of the renderer's layers (buildings), for extrusions */\n | { type: 'polygons'; key: string; z: number; x: number; y: number; priority?: Priority }\n /** Trees scattered over the polygons of the renderer's layers, `spacing[s]` metres apart in layer `s` (0: none), at\n * most `maxTrees` */\n | {\n type: 'trees';\n key: string;\n z: number;\n x: number;\n y: number;\n spacing: number[];\n maxTrees: number;\n priority?: Priority;\n }\n /** Street lamps along the lines of the renderer's layers, `spacing` metres apart along each street, at most\n * `maxLamps` */\n | {\n type: 'lamps';\n key: string;\n z: number;\n x: number;\n y: number;\n spacing: number;\n maxLamps: number;\n priority?: Priority;\n }\n /** The fills and lines of the renderer's layers cut to the tile, for the engine to draw as geometry; `styles`: their\n * style only, the layers' paint changed (the same features, in the same order). A tile past the source's deepest\n * level is cut from its tile of that level (overzoom); `deepest`, the deepest level asked for (default the\n * source's), is styled past itself, as the map stretches it */\n | {\n type: 'vectors';\n key: string;\n z: number;\n x: number;\n y: number;\n deepest?: number;\n /** How the buildings' roofs are made (`RoofMode`) */\n roofs?: RoofMode;\n styles?: boolean;\n /** With the prisms of the fills (a relief under them) */\n prism?: boolean;\n priority?: Priority;\n }\n | { type: 'heights'; url: string; encoding: PngEncoding; floor?: number }\n /** The wind of a city's streets round the buildings of the renderer's layers (see `StreetWork`) */\n | ({ type: 'street'; key: string } & StreetWork)\n /** A GRIB2 or NetCDF file (fetched from `url`, or its `bytes`) read into grids by the grid module (`module`) */\n | { type: 'grids'; module: string; url?: string; bytes?: ArrayBuffer }\n | { type: 'reproject'; job: Job; cached: number };\n\nexport type BasemapRequest =\n /** The page's request headers (`setRequestHeaders`) */\n | { type: 'headers'; rules: HeaderRules }\n /** Where the tessellation module is (`isard_tess_bg.wasm`), loaded with the first `vectors` job */\n | { type: 'tess'; url: string }\n | {\n type: 'init';\n /** Renderers by key: each draws its own layers of the same source */\n key: string;\n tiles: string;\n maxzoom: number;\n layers: StyleLayer[];\n /** The style's raster sources, by name, for its raster layers */\n rasters?: Record<string, RasterSource>;\n /** The style's sprites, for the fill patterns (loaded once by the page) */\n sprites?: Sprite[];\n /** Workers of the pool: each keeps its share of the decoded tiles */\n workers?: number;\n }\n | (BasemapWork & { id: number })\n | { type: 'abort'; id: number }\n /** A renderer no longer used: forgotten */\n | { type: 'drop'; key: string };\n\nexport type BasemapResponse =\n | { id: number; image: ImageBitmap }\n | { id: number; missing: true }\n | { id: number; error: string }\n | { id: number; labels: LabelCandidate[] }\n | { id: number; polygons: TilePolygons }\n | { id: number; trees: Float64Array }\n | { id: number; lamps: Float64Array }\n | { id: number; vectors: TileVectors }\n | ({ id: number } & TileStyles)\n | { id: number; heights: Float32Array }\n | { id: number; grids: GridDescription[]; values: Float32Array[] }\n | { id: number; street: StreetFlows };\n\n/** The polygons of a tile in Mercator [0, 1], as the extrusions take them (`PolygonArrays`), and their properties */\nexport interface TilePolygons {\n arrays: {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n };\n properties: Record<string, Value>[];\n}\n\n/**\n * The geometry of a vector tile for the engine (`setVectorTile`), in Mercator [0, 1], cut to the tile: a styled\n * feature is a feature of the tile in one of the renderer's layers (the sublayers, in their order), numbered layer\n * after layer. The polygons and lines of sublayer `s` are `fillStart[s] .. fillStart[s + 1]` and `lineStart[s] ..\n * lineStart[s + 1]` (one more entry than the renderer's layers)\n */\nexport interface TileVectors {\n fills: {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n fillStart: Uint32Array;\n /** Per polygon, its block's roof: its shape's number (`RoofShape::number`, 255 generated) and height (metres) */\n roofs?: Uint8Array;\n roofHeights?: Float32Array;\n /** The whole outlines of the buildings the tile cuts (Mercator, interleaved), where each polygon's starts (and the\n * end; an empty one: whole) */\n roofOutlines?: Float64Array;\n roofOutlineStart?: Uint32Array;\n /** Metres per Mercator unit at the tile */\n roofMetres?: number;\n };\n lines: { points: Float64Array; start: Uint32Array; feature: Uint32Array; lineStart: Uint32Array };\n /** The points of the circle sublayers (Mercator), each with its styled feature, and the first of each sublayer (and\n * the end) */\n circles?: { points: Float64Array; feature: Uint32Array; circleStart: Uint32Array };\n /** The style of each styled feature, `FLOATS` (32) each, as the engine's line layers take it */\n styles: Float32Array;\n /** The names of the fills' patterns its styles point at (`resolvePatterns`) */\n patterns?: string[];\n /** The tile's corners (west, north, east, south, Mercator): no wall of a building along its edges, where one cut\n * there goes on in the next tile */\n tile?: Float64Array;\n /** Its feature's properties (shared by the styled features of one feature) and its sublayer */\n properties: Record<string, Value>[];\n sublayer: Uint16Array;\n /** The geometry made ready for the GPU by the tessellation module (the engine's `setVectorTileMesh`); without it,\n * the engine does that on the main thread */\n mesh?: TileMesh;\n}\n\n/** The styles alone of a vector tile's features, restyled (as `TileVectors`'s) */\nexport interface TileStyles {\n styles: Float32Array;\n patterns: string[];\n}\n\n/** A vector tile ready for the GPU, as the tessellation module makes it (`TessellatedTile`) */\nexport interface TileMesh {\n /** Fill vertices, as bytes */\n vertices: Uint8Array;\n indices: Uint32Array;\n /** Per sublayer: its top cap and the rest of its prism, first and end of each */\n fillRanges: Uint32Array;\n prism: boolean;\n /** Line pieces, as bytes */\n pieces: Uint8Array;\n /** Feature and length of each line */\n lineTable: Float32Array;\n /** Per sublayer: its pieces, first and end */\n lineRanges: Uint32Array;\n /** Blocks of the extrusion sublayers (buildings), as bytes */\n blocks: Uint8Array;\n blockIndices: Uint32Array;\n /** Per sublayer: its blocks' triangles, first and end */\n blockRanges: Uint32Array;\n /** Min x, min y, max x, max y of the tile's points */\n bounds: Float64Array;\n}\n\n/** The signals of the relief and reprojection requests in progress, aborted with them */\nconst controllers = new Map<number, AbortController>();\n\n/** Where this worker reads the colors of the relief tiles back */\nconst heightsSurface: Surface = {};\n\n/** The reprojected rasters' source images this worker keeps, shared by every source */\nconst reprojection = resampler();\n\nconst post = (message: BasemapResponse, transfer: Transferable[] = []) =>\n (self as unknown as Worker).postMessage(message, transfer);\n\nself.onmessage = async ({ data }: MessageEvent<BasemapRequest>) => {\n if (data.type === 'headers') {\n setHeaderRules(data.rules);\n\n return;\n }\n if (data.type === 'tess') {\n tess.url = data.url;\n\n return;\n }\n if (data.type === 'init') {\n if (data.workers !== undefined) cache.capacity = cacheShare(data.workers);\n renderers.set(data.key, {\n tiles: data.tiles,\n maxzoom: data.maxzoom,\n layers: data.layers,\n rasters: data.rasters ?? {},\n sprites: data.sprites ?? [],\n patterns: new Map(),\n });\n\n return;\n }\n if (data.type === 'drop') {\n // Its copy of the sprites\n renderers.get(data.key)?.sprites.forEach((sprite) => {\n sprite.image.close();\n });\n renderers.delete(data.key);\n\n return;\n }\n if (data.type === 'abort') {\n // An abort that arrives after the answer is ignored\n if (active.has(data.id)) aborted.add(data.id);\n controllers.get(data.id)?.abort();\n\n return;\n }\n if (data.type === 'heights' || data.type === 'reproject' || data.type === 'grids') {\n await decodeTile(data);\n\n return;\n }\n active.add(data.id);\n\n const r = renderers.get(data.key);\n\n try {\n if (!r) throw new Error(`no renderer ${data.key}`);\n if (data.type === 'render') {\n const image = await render(r, data.z, data.x, data.y, data.size, data.id, data.priority);\n\n if (image) post({ id: data.id, image }, [image]);\n else post({ id: data.id, missing: true });\n } else if (data.type === 'trees') {\n const out = await trees(r, data.z, data.x, data.y, data.id, data.spacing, data.maxTrees, data.priority);\n\n if (!out) post({ id: data.id, missing: true });\n else post({ id: data.id, trees: out }, [out.buffer]);\n } else if (data.type === 'lamps') {\n const out = await lamps(r, data.z, data.x, data.y, data.id, data.spacing, data.maxLamps, data.priority);\n\n if (!out) post({ id: data.id, missing: true });\n else post({ id: data.id, lamps: out }, [out.buffer]);\n } else if (data.type === 'street') {\n const street = await streetFlowOf(r, data, data.id);\n\n post(\n { id: data.id, street },\n [street.eastU, street.eastV, street.northU, street.northV].map((a) => a.buffer),\n );\n } else if (data.type === 'polygons') {\n const tilePolygons = await polygons(r, data.z, data.x, data.y, data.id, data.priority);\n\n if (!tilePolygons) post({ id: data.id, missing: true });\n else {\n const { points, ringStart, polygonStart, feature } = tilePolygons.arrays;\n\n post({ id: data.id, polygons: tilePolygons }, [\n points.buffer,\n ringStart.buffer,\n polygonStart.buffer,\n feature.buffer,\n ]);\n }\n } else if (data.type === 'vectors') {\n const out = await vectors(r, data, data.id, data.styles === true, data.priority);\n\n if (!out) post({ id: data.id, missing: true });\n else if (!('fills' in out)) post({ id: data.id, ...out }, [out.styles.buffer]);\n else {\n const raised = Uint8Array.from(r.layers, (l) => (vectorKind(l) === 'extrusion' ? 1 : 0));\n const mesh = (await tessellator()) ? tessellate(out, raised, data.prism === true) : undefined;\n const { fills, lines } = out;\n\n post({ id: data.id, vectors: mesh ? { ...out, mesh } : out }, [\n ...[fills.points, fills.ringStart, fills.polygonStart, fills.feature, fills.fillStart].map((a) => a.buffer),\n ...[fills.roofs, fills.roofHeights, fills.roofOutlines, fills.roofOutlineStart].flatMap((a) =>\n a ? [a.buffer] : [],\n ),\n ...[lines.points, lines.start, lines.feature, lines.lineStart].map((a) => a.buffer),\n ...(out.circles\n ? [out.circles.points, out.circles.feature, out.circles.circleStart].map((a) => a.buffer)\n : []),\n out.styles.buffer,\n out.sublayer.buffer,\n ...(mesh\n ? [\n mesh.vertices,\n mesh.indices,\n mesh.fillRanges,\n mesh.pieces,\n mesh.lineTable,\n mesh.lineRanges,\n mesh.blocks,\n mesh.blockIndices,\n mesh.blockRanges,\n mesh.bounds,\n ]\n : []\n ).map((a) => a.buffer),\n ]);\n }\n } else {\n post({ id: data.id, labels: await labels(r, data.z, data.x, data.y, data.id, data.priority, data.zoom) });\n }\n } catch (error) {\n post({ id: data.id, error: String(error) });\n } finally {\n active.delete(data.id);\n aborted.delete(data.id);\n }\n};\n\n/** A file's bytes, with the page's request headers */\nconst fetchBytes = async (url: string, signal: AbortSignal): Promise<ArrayBuffer> => {\n const response = await fetch(url, withHeaders(url, { signal }));\n\n if (!response.ok) throw new Error(`${url}: ${response.status}`);\n\n return response.arrayBuffer();\n};\n\n/** A tile of another layer: the altitudes of a relief tile, or a reprojected raster tile; or a file's grids */\nconst decodeTile = async (data: Extract<BasemapWork, { type: 'heights' | 'reproject' | 'grids' }> & { id: number }) => {\n const controller = new AbortController();\n\n controllers.set(data.id, controller);\n try {\n if (data.type === 'grids') {\n const { module, url, bytes } = data;\n const file = bytes ?? (url ? await fetchBytes(url, controller.signal) : new ArrayBuffer(0));\n const { grids, values } = await decodeGrids(new Uint8Array(file), module);\n\n post(\n { id: data.id, grids, values },\n values.map((v) => v.buffer),\n );\n } else if (data.type === 'heights') {\n const heights = await fetchHeights(data.url, data.encoding, data.floor, controller.signal, heightsSurface);\n\n if (heights) post({ id: data.id, heights }, [heights.buffer]);\n else post({ id: data.id, missing: true });\n } else {\n reprojection.cache.capacity = data.cached;\n\n const image = await reprojection.draw(data.job, controller.signal);\n\n if (image) post({ id: data.id, image }, [image]);\n else post({ id: data.id, missing: true });\n }\n } catch (error) {\n post({ id: data.id, error: String(error) });\n } finally {\n controllers.delete(data.id);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;gBAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;;gBACzD,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;YAE1C,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YAEnE,IAAI,KAAK;gBAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;;gBAC5C,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAC;YAAS,CAAC;QACT,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC,CAAC","sourcesContent":["/**\n * Worker of the vector basemaps: fetches and decodes vector tiles (kept for the tiles that share them), draws their\n * fills, lines and circles with a MapLibre style into images (Canvas 2D, off the main thread) for the raster pool,\n * with the style's raster layers under them, and lists the label candidates of the style's symbol layers (their texts\n * and icons) for the page to shape and place. Extrusions are drawn flat, as fills. Or it cuts the fills, lines and\n * buildings of a tile into geometry for the engine to draw as such (`vectors`), with their style per feature (a\n * building's color, height and base height). It also decodes the\n * altitudes of PNG relief tiles and draws the rasters reprojected from other grids (planned by the page), for the\n * map's other layers.\n *\n * A raster tile of level z covers 256 CSS pixels at map zoom z - 1 (MapLibre's 512 px convention): it is drawn from\n * the vector tile of level z - 1 (or the deepest one the source has), with the style at that zoom.\n *\n * This module answers the page's messages; the jobs are in `./basemap/`: the state they share (`tiles.ts`), the\n * images (`raster.ts`), the labels (`labels.ts`), the geometry (`geometry.ts`), the trees (`trees.ts`).\n */\n\nimport type { Value } from '../basemap/mvt.ts';\nimport { type Job, resampler } from '../basemap/resample.ts';\nimport { fetchHeights, type PngEncoding, type Surface } from '../basemap/terrain.ts';\nimport { type LabelCandidate, type RasterSource, type StyleLayer, vectorKind } from '../basemap/vectorstyle.ts';\nimport { type HeaderRules, setHeaderRules, withHeaders } from '../engine/requests.ts';\nimport { decodeGrids, type GridDescription, type StreetFlows } from '../grid-module.ts';\nimport type { RoofMode } from '../util/roofs.ts';\nimport { furniture } from './basemap/furniture.ts';\nimport { polygons, tess, tessellate, tessellator, vectors } from './basemap/geometry.ts';\nimport { labels } from './basemap/labels.ts';\nimport { lamps } from './basemap/lamps.ts';\nimport { render } from './basemap/raster.ts';\nimport { type StreetWork, streetFlowOf } from './basemap/street.ts';\nimport { aborted, active, cache, cacheShare, renderers, type Sprite } from './basemap/tiles.ts';\nimport { trees } from './basemap/trees.ts';\n\nexport type { LabelCandidate, RasterSource, Sprite };\n\n/** Fetch priority of a request (`fetch`'s `priority`, a hint to the browser) */\nexport type Priority = 'high' | 'low' | 'auto';\n\n/** A tile's image or labels, asked of a worker; or a tile of another layer decoded: the altitudes of a PNG relief\n * tile, a Mercator tile reprojected from the source images of its plan (keeping `cached` of them) */\nexport type BasemapWork =\n | { type: 'render'; key: string; z: number; x: number; y: number; size: number; priority?: Priority }\n /** `zoom`: the zoom the style is evaluated at, past the source's deepest level (`z` by default) */\n | {\n type: 'labels';\n key: string;\n z: number;\n x: number;\n y: number;\n zoom?: number;\n /** The labels in a building given its height (they stand on its roof) */\n roofs?: boolean;\n priority?: Priority;\n }\n /** The polygons of the renderer's layers (buildings), for extrusions */\n | { type: 'polygons'; key: string; z: number; x: number; y: number; priority?: Priority }\n /** Trees scattered over the polygons of the renderer's layers, `spacing[s]` metres apart in layer `s` (0: none), at\n * most `maxTrees` */\n | {\n type: 'trees';\n key: string;\n z: number;\n x: number;\n y: number;\n spacing: number[];\n maxTrees: number;\n priority?: Priority;\n }\n /** The street furniture of the tile (OpenMapTiles' points of interest of the street, benches along the pedestrian\n * streets and the parks' paths), at most `maxObjects` */\n | {\n type: 'furniture';\n key: string;\n z: number;\n x: number;\n y: number;\n maxObjects: number;\n priority?: Priority;\n }\n /** Street lamps along the lines of the renderer's layers, `spacing` metres apart along each street, at most\n * `maxLamps` */\n | {\n type: 'lamps';\n key: string;\n z: number;\n x: number;\n y: number;\n spacing: number;\n maxLamps: number;\n priority?: Priority;\n }\n /** The fills and lines of the renderer's layers cut to the tile, for the engine to draw as geometry; `styles`: their\n * style only, the layers' paint changed (the same features, in the same order). A tile past the source's deepest\n * level is cut from its tile of that level (overzoom); `deepest`, the deepest level asked for (default the\n * source's), is styled past itself, as the map stretches it */\n | {\n type: 'vectors';\n key: string;\n z: number;\n x: number;\n y: number;\n deepest?: number;\n /** How the buildings' roofs are made (`RoofMode`) */\n roofs?: RoofMode;\n styles?: boolean;\n /** With the prisms of the fills (a relief under them) */\n prism?: boolean;\n priority?: Priority;\n }\n | { type: 'heights'; url: string; encoding: PngEncoding; floor?: number }\n /** The wind of a city's streets round the buildings of the renderer's layers (see `StreetWork`) */\n | ({ type: 'street'; key: string } & StreetWork)\n /** A GRIB2 or NetCDF file (fetched from `url`, or its `bytes`) read into grids by the grid module (`module`) */\n | { type: 'grids'; module: string; url?: string; bytes?: ArrayBuffer }\n | { type: 'reproject'; job: Job; cached: number };\n\nexport type BasemapRequest =\n /** The page's request headers (`setRequestHeaders`) */\n | { type: 'headers'; rules: HeaderRules }\n /** Where the tessellation module is (`isard_tess_bg.wasm`), loaded with the first `vectors` job */\n | { type: 'tess'; url: string }\n | {\n type: 'init';\n /** Renderers by key: each draws its own layers of the same source */\n key: string;\n tiles: string;\n maxzoom: number;\n layers: StyleLayer[];\n /** The style's raster sources, by name, for its raster layers */\n rasters?: Record<string, RasterSource>;\n /** The style's sprites, for the fill patterns (loaded once by the page) */\n sprites?: Sprite[];\n /** Workers of the pool: each keeps its share of the decoded tiles */\n workers?: number;\n }\n | (BasemapWork & { id: number })\n | { type: 'abort'; id: number }\n /** A renderer no longer used: forgotten */\n | { type: 'drop'; key: string };\n\nexport type BasemapResponse =\n | { id: number; image: ImageBitmap }\n | { id: number; missing: true }\n | { id: number; error: string }\n | { id: number; labels: LabelCandidate[] }\n | { id: number; polygons: TilePolygons }\n | { id: number; trees: Float64Array }\n | { id: number; lamps: Float64Array }\n | { id: number; furniture: Float64Array }\n | { id: number; vectors: TileVectors }\n | ({ id: number } & TileStyles)\n | { id: number; heights: Float32Array }\n | { id: number; grids: GridDescription[]; values: Float32Array[] }\n | { id: number; street: StreetFlows };\n\n/** The polygons of a tile in Mercator [0, 1], as the extrusions take them (`PolygonArrays`), and their properties */\nexport interface TilePolygons {\n arrays: {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n };\n properties: Record<string, Value>[];\n}\n\n/**\n * The geometry of a vector tile for the engine (`setVectorTile`), in Mercator [0, 1], cut to the tile: a styled\n * feature is a feature of the tile in one of the renderer's layers (the sublayers, in their order), numbered layer\n * after layer. The polygons and lines of sublayer `s` are `fillStart[s] .. fillStart[s + 1]` and `lineStart[s] ..\n * lineStart[s + 1]` (one more entry than the renderer's layers)\n */\nexport interface TileVectors {\n fills: {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n fillStart: Uint32Array;\n /** Per polygon, its block's roof: its shape's number (`RoofShape::number`, 255 generated) and height (metres) */\n roofs?: Uint8Array;\n roofHeights?: Float32Array;\n /** The whole outlines of the buildings the tile cuts (Mercator, interleaved), where each polygon's starts (and the\n * end; an empty one: whole) */\n roofOutlines?: Float64Array;\n roofOutlineStart?: Uint32Array;\n /** Metres per Mercator unit at the tile */\n roofMetres?: number;\n };\n lines: { points: Float64Array; start: Uint32Array; feature: Uint32Array; lineStart: Uint32Array };\n /** The points of the circle sublayers (Mercator), each with its styled feature, and the first of each sublayer (and\n * the end) */\n circles?: { points: Float64Array; feature: Uint32Array; circleStart: Uint32Array };\n /** The style of each styled feature, `FLOATS` (32) each, as the engine's line layers take it */\n styles: Float32Array;\n /** The names of the fills' patterns its styles point at (`resolvePatterns`) */\n patterns?: string[];\n /** The tile's corners (west, north, east, south, Mercator): no wall of a building along its edges, where one cut\n * there goes on in the next tile */\n tile?: Float64Array;\n /** Its feature's properties (shared by the styled features of one feature) and its sublayer */\n properties: Record<string, Value>[];\n sublayer: Uint16Array;\n /** The geometry made ready for the GPU by the tessellation module (the engine's `setVectorTileMesh`); without it,\n * the engine does that on the main thread */\n mesh?: TileMesh;\n}\n\n/** The styles alone of a vector tile's features, restyled (as `TileVectors`'s) */\nexport interface TileStyles {\n styles: Float32Array;\n patterns: string[];\n}\n\n/** A vector tile ready for the GPU, as the tessellation module makes it (`TessellatedTile`) */\nexport interface TileMesh {\n /** Fill vertices, as bytes */\n vertices: Uint8Array;\n indices: Uint32Array;\n /** Per sublayer: its top cap and the rest of its prism, first and end of each */\n fillRanges: Uint32Array;\n prism: boolean;\n /** Line pieces, as bytes */\n pieces: Uint8Array;\n /** Feature and length of each line */\n lineTable: Float32Array;\n /** Per sublayer: its pieces, first and end */\n lineRanges: Uint32Array;\n /** Blocks of the extrusion sublayers (buildings), as bytes */\n blocks: Uint8Array;\n blockIndices: Uint32Array;\n /** Per sublayer: its blocks' triangles, first and end */\n blockRanges: Uint32Array;\n /** Min x, min y, max x, max y of the tile's points */\n bounds: Float64Array;\n}\n\n/** The signals of the relief and reprojection requests in progress, aborted with them */\nconst controllers = new Map<number, AbortController>();\n\n/** Where this worker reads the colors of the relief tiles back */\nconst heightsSurface: Surface = {};\n\n/** The reprojected rasters' source images this worker keeps, shared by every source */\nconst reprojection = resampler();\n\nconst post = (message: BasemapResponse, transfer: Transferable[] = []) =>\n (self as unknown as Worker).postMessage(message, transfer);\n\nself.onmessage = async ({ data }: MessageEvent<BasemapRequest>) => {\n if (data.type === 'headers') {\n setHeaderRules(data.rules);\n\n return;\n }\n if (data.type === 'tess') {\n tess.url = data.url;\n\n return;\n }\n if (data.type === 'init') {\n if (data.workers !== undefined) cache.capacity = cacheShare(data.workers);\n renderers.set(data.key, {\n tiles: data.tiles,\n maxzoom: data.maxzoom,\n layers: data.layers,\n rasters: data.rasters ?? {},\n sprites: data.sprites ?? [],\n patterns: new Map(),\n });\n\n return;\n }\n if (data.type === 'drop') {\n // Its copy of the sprites\n renderers.get(data.key)?.sprites.forEach((sprite) => {\n sprite.image.close();\n });\n renderers.delete(data.key);\n\n return;\n }\n if (data.type === 'abort') {\n // An abort that arrives after the answer is ignored\n if (active.has(data.id)) aborted.add(data.id);\n controllers.get(data.id)?.abort();\n\n return;\n }\n if (data.type === 'heights' || data.type === 'reproject' || data.type === 'grids') {\n await decodeTile(data);\n\n return;\n }\n active.add(data.id);\n\n const r = renderers.get(data.key);\n\n try {\n if (!r) throw new Error(`no renderer ${data.key}`);\n if (data.type === 'render') {\n const image = await render(r, data.z, data.x, data.y, data.size, data.id, data.priority);\n\n if (image) post({ id: data.id, image }, [image]);\n else post({ id: data.id, missing: true });\n } else if (data.type === 'trees') {\n const out = await trees(r, data.z, data.x, data.y, data.id, data.spacing, data.maxTrees, data.priority);\n\n if (!out) post({ id: data.id, missing: true });\n else post({ id: data.id, trees: out }, [out.buffer]);\n } else if (data.type === 'furniture') {\n const out = await furniture(r, data.z, data.x, data.y, data.id, data.maxObjects, data.priority);\n\n if (!out) post({ id: data.id, missing: true });\n else post({ id: data.id, furniture: out }, [out.buffer]);\n } else if (data.type === 'lamps') {\n const out = await lamps(r, data.z, data.x, data.y, data.id, data.spacing, data.maxLamps, data.priority);\n\n if (!out) post({ id: data.id, missing: true });\n else post({ id: data.id, lamps: out }, [out.buffer]);\n } else if (data.type === 'street') {\n const street = await streetFlowOf(r, data, data.id);\n\n post(\n { id: data.id, street },\n [street.eastU, street.eastV, street.northU, street.northV].map((a) => a.buffer),\n );\n } else if (data.type === 'polygons') {\n const tilePolygons = await polygons(r, data.z, data.x, data.y, data.id, data.priority);\n\n if (!tilePolygons) post({ id: data.id, missing: true });\n else {\n const { points, ringStart, polygonStart, feature } = tilePolygons.arrays;\n\n post({ id: data.id, polygons: tilePolygons }, [\n points.buffer,\n ringStart.buffer,\n polygonStart.buffer,\n feature.buffer,\n ]);\n }\n } else if (data.type === 'vectors') {\n const out = await vectors(r, data, data.id, data.styles === true, data.priority);\n\n if (!out) post({ id: data.id, missing: true });\n else if (!('fills' in out)) post({ id: data.id, ...out }, [out.styles.buffer]);\n else {\n const raised = Uint8Array.from(r.layers, (l) => (vectorKind(l) === 'extrusion' ? 1 : 0));\n const mesh = (await tessellator()) ? tessellate(out, raised, data.prism === true) : undefined;\n const { fills, lines } = out;\n\n post({ id: data.id, vectors: mesh ? { ...out, mesh } : out }, [\n ...[fills.points, fills.ringStart, fills.polygonStart, fills.feature, fills.fillStart].map((a) => a.buffer),\n ...[fills.roofs, fills.roofHeights, fills.roofOutlines, fills.roofOutlineStart].flatMap((a) =>\n a ? [a.buffer] : [],\n ),\n ...[lines.points, lines.start, lines.feature, lines.lineStart].map((a) => a.buffer),\n ...(out.circles\n ? [out.circles.points, out.circles.feature, out.circles.circleStart].map((a) => a.buffer)\n : []),\n out.styles.buffer,\n out.sublayer.buffer,\n ...(mesh\n ? [\n mesh.vertices,\n mesh.indices,\n mesh.fillRanges,\n mesh.pieces,\n mesh.lineTable,\n mesh.lineRanges,\n mesh.blocks,\n mesh.blockIndices,\n mesh.blockRanges,\n mesh.bounds,\n ]\n : []\n ).map((a) => a.buffer),\n ]);\n }\n } else {\n post({\n id: data.id,\n labels: await labels(r, data.z, data.x, data.y, data.id, data.priority, data.zoom, data.roofs),\n });\n }\n } catch (error) {\n post({ id: data.id, error: String(error) });\n } finally {\n active.delete(data.id);\n aborted.delete(data.id);\n }\n};\n\n/** A file's bytes, with the page's request headers */\nconst fetchBytes = async (url: string, signal: AbortSignal): Promise<ArrayBuffer> => {\n const response = await fetch(url, withHeaders(url, { signal }));\n\n if (!response.ok) throw new Error(`${url}: ${response.status}`);\n\n return response.arrayBuffer();\n};\n\n/** A tile of another layer: the altitudes of a relief tile, or a reprojected raster tile; or a file's grids */\nconst decodeTile = async (data: Extract<BasemapWork, { type: 'heights' | 'reproject' | 'grids' }> & { id: number }) => {\n const controller = new AbortController();\n\n controllers.set(data.id, controller);\n try {\n if (data.type === 'grids') {\n const { module, url, bytes } = data;\n const file = bytes ?? (url ? await fetchBytes(url, controller.signal) : new ArrayBuffer(0));\n const { grids, values } = await decodeGrids(new Uint8Array(file), module);\n\n post(\n { id: data.id, grids, values },\n values.map((v) => v.buffer),\n );\n } else if (data.type === 'heights') {\n const heights = await fetchHeights(data.url, data.encoding, data.floor, controller.signal, heightsSurface);\n\n if (heights) post({ id: data.id, heights }, [heights.buffer]);\n else post({ id: data.id, missing: true });\n } else {\n reprojection.cache.capacity = data.cached;\n\n const image = await reprojection.draw(data.job, controller.signal);\n\n if (image) post({ id: data.id, image }, [image]);\n else post({ id: data.id, missing: true });\n }\n } catch (error) {\n post({ id: data.id, error: String(error) });\n } finally {\n controllers.delete(data.id);\n }\n};\n"]}
|
package/package.json
CHANGED