isard 1.8.0 → 1.10.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 +82 -1
- package/README.md +9 -4
- package/dist/basemap/grid.js +2 -5
- package/dist/basemap/grid.js.map +1 -1
- package/dist/basemap/models/furniture.d.ts +12 -0
- package/dist/basemap/{furniture.js → models/furniture.js} +6 -8
- package/dist/basemap/models/furniture.js.map +1 -0
- package/dist/basemap/{meshes.js → models/meshes.js} +1 -1
- package/dist/basemap/models/meshes.js.map +1 -0
- package/dist/basemap/models/trees.d.ts +21 -0
- package/dist/basemap/{trees.js → models/trees.js} +4 -36
- package/dist/basemap/models/trees.js.map +1 -0
- package/dist/basemap/placed.d.ts +2 -0
- package/dist/basemap/placed.js +2 -0
- package/dist/basemap/placed.js.map +1 -1
- package/dist/basemap/pmtiles.js +4 -3
- package/dist/basemap/pmtiles.js.map +1 -1
- package/dist/basemap/pmtileslayer.d.ts +4 -4
- package/dist/basemap/pmtileslayer.js +2 -1
- package/dist/basemap/pmtileslayer.js.map +1 -1
- package/dist/basemap/resample.js +3 -2
- package/dist/basemap/resample.js.map +1 -1
- package/dist/basemap/terrain.d.ts +5 -0
- package/dist/basemap/terrain.js +6 -4
- package/dist/basemap/terrain.js.map +1 -1
- package/dist/basemap/vectortiles/context.d.ts +3 -2
- package/dist/basemap/vectortiles/context.js.map +1 -1
- package/dist/basemap/vectortiles/extrusions.js.map +1 -1
- package/dist/basemap/vectortiles/furniture.d.ts +3 -3
- package/dist/basemap/vectortiles/furniture.js +2 -1
- package/dist/basemap/vectortiles/furniture.js.map +1 -1
- package/dist/basemap/vectortiles/labels.js +2 -1
- package/dist/basemap/vectortiles/labels.js.map +1 -1
- package/dist/basemap/vectortiles/lamps.d.ts +3 -3
- package/dist/basemap/vectortiles/lamps.js +1 -1
- package/dist/basemap/vectortiles/lamps.js.map +1 -1
- package/dist/basemap/vectortiles/placed.d.ts +3 -2
- package/dist/basemap/vectortiles/placed.js +5 -10
- package/dist/basemap/vectortiles/placed.js.map +1 -1
- package/dist/basemap/vectortiles/requests.d.ts +8 -1
- package/dist/basemap/vectortiles/requests.js +32 -4
- package/dist/basemap/vectortiles/requests.js.map +1 -1
- package/dist/basemap/vectortiles/street-wind.js +2 -2
- package/dist/basemap/vectortiles/street-wind.js.map +1 -1
- package/dist/basemap/vectortiles/style.js +7 -8
- package/dist/basemap/vectortiles/style.js.map +1 -1
- package/dist/basemap/vectortiles/tiles.d.ts +1 -3
- package/dist/basemap/vectortiles/tiles.js +1 -1
- package/dist/basemap/vectortiles/tiles.js.map +1 -1
- package/dist/basemap/vectortiles/trees.d.ts +4 -4
- package/dist/basemap/vectortiles/trees.js +2 -1
- package/dist/basemap/vectortiles/trees.js.map +1 -1
- package/dist/basemap/vectortiles/vectors.d.ts +9 -3
- package/dist/basemap/vectortiles/vectors.js +26 -2
- package/dist/basemap/vectortiles/vectors.js.map +1 -1
- package/dist/basemap/vectortiles.d.ts +8 -6
- package/dist/basemap/vectortiles.js +7 -4
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap/wmts.js +3 -4
- package/dist/basemap/wmts.js.map +1 -1
- package/dist/basemap/{trees.d.ts → woods.d.ts} +2 -19
- package/dist/basemap/woods.js +38 -0
- package/dist/basemap/woods.js.map +1 -0
- package/dist/basemap/workerpool.d.ts +1 -1
- package/dist/basemap/workerpool.js +3 -3
- package/dist/basemap/workerpool.js.map +1 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +23 -22
- package/dist/bind/layers.js +3 -0
- package/dist/bind/layers.js.map +1 -1
- package/dist/data/collada.js +4 -4
- package/dist/data/collada.js.map +1 -1
- package/dist/data/ifc.js +6 -11
- package/dist/data/ifc.js.map +1 -1
- package/dist/data/tileset.d.ts +21 -0
- package/dist/data/tileset.js +101 -0
- package/dist/data/tileset.js.map +1 -0
- package/dist/decoder.worker.js +5 -5
- package/dist/decoder.worker.js.map +7 -6
- package/dist/decoding/decoders.js.map +1 -0
- package/dist/{engine → decoding}/loader.js +2 -2
- package/dist/decoding/loader.js.map +1 -0
- package/dist/{engine → decoding}/protocol.d.ts +1 -1
- package/dist/decoding/protocol.js.map +1 -0
- package/dist/engine-loader.d.ts +3 -3
- package/dist/engine-loader.js +12 -5
- package/dist/engine-loader.js.map +1 -1
- package/dist/geoplateforme.d.ts +2 -1
- package/dist/geoplateforme.js +6 -8
- package/dist/geoplateforme.js.map +1 -1
- package/dist/index.d.ts +15 -7
- package/dist/index.js +9 -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_tess_bg.wasm +0 -0
- package/dist/layers/custom.d.ts +56 -0
- package/dist/layers/custom.js +93 -0
- package/dist/layers/custom.js.map +1 -0
- package/dist/layers/extrusions.d.ts +4 -2
- package/dist/layers/extrusions.js +2 -1
- package/dist/layers/extrusions.js.map +1 -1
- package/dist/layers/features.d.ts +3 -14
- package/dist/layers/features.js +4 -25
- package/dist/layers/features.js.map +1 -1
- package/dist/layers/flow.d.ts +3 -3
- package/dist/layers/flow.js +3 -4
- package/dist/layers/flow.js.map +1 -1
- package/dist/layers/glyphs.js +5 -3
- package/dist/layers/glyphs.js.map +1 -1
- package/dist/layers/ground.d.ts +57 -0
- package/dist/layers/ground.js +78 -0
- package/dist/layers/ground.js.map +1 -0
- package/dist/layers/icons.js +8 -6
- package/dist/layers/icons.js.map +1 -1
- package/dist/layers/layers.d.ts +2 -199
- package/dist/layers/layers.js +2 -469
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/models.d.ts +48 -0
- package/dist/layers/models.js +111 -0
- package/dist/layers/models.js.map +1 -0
- package/dist/layers/network.d.ts +26 -0
- package/dist/layers/network.js +127 -0
- package/dist/layers/network.js.map +1 -0
- package/dist/layers/panoramas.d.ts +2 -11
- package/dist/layers/panoramas.js +19 -9
- package/dist/layers/panoramas.js.map +1 -1
- package/dist/layers/photos.d.ts +4 -7
- package/dist/layers/photos.js +3 -4
- package/dist/layers/photos.js.map +1 -1
- package/dist/layers/pointclouds.d.ts +3 -2
- package/dist/layers/pointclouds.js +3 -3
- package/dist/layers/pointclouds.js.map +1 -1
- package/dist/layers/raster.d.ts +9 -0
- package/dist/layers/raster.js +24 -0
- package/dist/layers/raster.js.map +1 -0
- package/dist/layers/symbols.d.ts +2 -2
- package/dist/layers/symbols.js +2 -1
- package/dist/layers/symbols.js.map +1 -1
- package/dist/layers/tiles3d.d.ts +20 -0
- package/dist/layers/tiles3d.js +69 -0
- package/dist/layers/tiles3d.js.map +1 -0
- package/dist/layers/trees.d.ts +5 -7
- package/dist/layers/trees.js +2 -1
- package/dist/layers/trees.js.map +1 -1
- package/dist/layers/vectors.d.ts +3 -0
- package/dist/layers/vectors.js +4 -0
- package/dist/layers/vectors.js.map +1 -1
- package/dist/map/basemap-layers.js +1 -1
- package/dist/map/basemap-layers.js.map +1 -1
- package/dist/map/engine-settings.d.ts +1 -1
- package/dist/map/engine-settings.js +1 -1
- package/dist/map/engine-settings.js.map +1 -1
- package/dist/map/engines.js.map +1 -1
- package/dist/map/layer-spec.d.ts +7 -13
- package/dist/map/layer-spec.js.map +1 -1
- package/dist/map/workers.js +3 -4
- package/dist/map/workers.js.map +1 -1
- package/dist/map.d.ts +25 -58
- package/dist/map.js +61 -53
- package/dist/map.js.map +1 -1
- package/dist/panoramax.js +6 -8
- package/dist/panoramax.js.map +1 -1
- package/dist/react/CustomLayer.d.ts +1 -1
- package/dist/react/CustomLayer.js.map +1 -1
- package/dist/react/Layer.d.ts +5 -1
- package/dist/react/Layer.js.map +1 -1
- package/dist/react/VectorGeometry.d.ts +4 -0
- package/dist/react/VectorGeometry.js +6 -3
- package/dist/react/VectorGeometry.js.map +1 -1
- package/dist/react/VectorTiles.d.ts +2 -2
- package/dist/react/VectorTiles.js +1 -1
- package/dist/react/VectorTiles.js.map +1 -1
- package/dist/types.d.ts +16 -4
- package/dist/types.js.map +1 -1
- package/dist/ui/controls.js +2 -1
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/interaction.d.ts +4 -0
- package/dist/ui/interaction.js +59 -7
- package/dist/ui/interaction.js.map +1 -1
- package/dist/ui/minimap.js +1 -1
- package/dist/ui/minimap.js.map +1 -1
- package/dist/ui/overlay.js +3 -3
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/search.js +1 -1
- package/dist/ui/search.js.map +1 -1
- package/dist/util/animation.js +3 -2
- package/dist/util/animation.js.map +1 -1
- package/dist/util/color.d.ts +10 -0
- package/dist/util/color.js +29 -9
- package/dist/util/color.js.map +1 -1
- package/dist/util/fetch.d.ts +5 -0
- package/dist/util/fetch.js +11 -0
- package/dist/util/fetch.js.map +1 -0
- package/dist/util/geo.d.ts +5 -0
- package/dist/util/geo.js +8 -2
- package/dist/util/geo.js.map +1 -1
- package/dist/util/math.d.ts +3 -0
- package/dist/util/math.js +4 -0
- package/dist/util/math.js.map +1 -0
- package/dist/util/requests.js.map +1 -0
- package/dist/util/roofs.d.ts +0 -2
- package/dist/util/roofs.js +0 -3
- package/dist/util/roofs.js.map +1 -1
- package/dist/wasm/isard.d.ts +18 -1
- package/dist/wasm/isard.js +28 -2
- package/dist/wasm/isard_core.d.ts +13 -1
- package/dist/wasm/isard_core.js +20 -2
- package/dist/workers/basemap/geometry.d.ts +9 -19
- package/dist/workers/{basemap.worker.d.ts → basemap/protocol.d.ts} +32 -23
- package/dist/workers/basemap/street.d.ts +4 -2
- package/dist/workers/basemap/tiles.d.ts +1 -3
- package/dist/workers/basemap/trees.d.ts +2 -2
- package/package.json +1 -1
- package/dist/basemap/furniture.d.ts +0 -26
- package/dist/basemap/furniture.js.map +0 -1
- package/dist/basemap/meshes.js.map +0 -1
- package/dist/basemap/trees.js.map +0 -1
- package/dist/engine/decoders.js.map +0 -1
- package/dist/engine/loader.js.map +0 -1
- package/dist/engine/protocol.js.map +0 -1
- package/dist/engine/requests.js.map +0 -1
- package/dist/workers/basemap/furniture.d.ts +0 -13
- package/dist/workers/basemap/labels.d.ts +0 -24
- package/dist/workers/basemap/lamps.d.ts +0 -10
- package/dist/workers/basemap/raster.d.ts +0 -10
- package/dist/workers/basemap.worker.js +0 -221
- package/dist/workers/basemap.worker.js.map +0 -1
- /package/dist/basemap/{meshes.d.ts → models/meshes.d.ts} +0 -0
- /package/dist/{engine → decoding}/decoders.d.ts +0 -0
- /package/dist/{engine → decoding}/decoders.js +0 -0
- /package/dist/{engine → decoding}/loader.d.ts +0 -0
- /package/dist/{engine → decoding}/protocol.js +0 -0
- /package/dist/{engine → util}/requests.d.ts +0 -0
- /package/dist/{engine → util}/requests.js +0 -0
package/dist/isard_bg.wasm
CHANGED
|
Binary file
|
package/dist/isard_core_bg.wasm
CHANGED
|
Binary file
|
package/dist/isard_tess_bg.wasm
CHANGED
|
Binary file
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** The page's own WebGL drawing as a layer, called in every frame with the map's matrices */
|
|
2
|
+
import type { GeoMap } from '../map.ts';
|
|
3
|
+
import type { LonLat } from '../types.ts';
|
|
4
|
+
import type { Camera } from '../wasm/isard.js';
|
|
5
|
+
import { Layer } from './layers.ts';
|
|
6
|
+
/** What a custom layer gets to draw a frame (`CustomLayerInterface.render`) */
|
|
7
|
+
export interface CustomFrame {
|
|
8
|
+
/**
|
|
9
|
+
* The model-view-projection matrix of a local frame at a position and altitude (metres above the ellipsoid, as the
|
|
10
|
+
* relief is drawn: times its exaggeration), column-major for `uniformMatrix4fv` or a three.js camera: x east, y
|
|
11
|
+
* north, z up, in metres. Made in double precision relative to the camera, so that what is drawn stays exact at
|
|
12
|
+
* any zoom; draw within a few kilometres of the position (or take one matrix per object far apart). Only during
|
|
13
|
+
* `render`.
|
|
14
|
+
*/
|
|
15
|
+
matrixAt(lonLat: LonLat, altitude?: number): Float32Array;
|
|
16
|
+
/** The camera of the frame */
|
|
17
|
+
readonly camera: Camera;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A layer drawn by the page with its own WebGL code, as MapLibre's `CustomLayerInterface`: `render` is called at the
|
|
21
|
+
* layer's place in every frame drawn. It starts with the canvas bound, its viewport set, blending on (`SRC_ALPHA`,
|
|
22
|
+
* `ONE_MINUS_SRC_ALPHA`), no culling, and in `'3d'` mode the depth test on (`LEQUAL`, depth written): the relief, the
|
|
23
|
+
* buildings and the 3D Tiles hide what it draws and what it draws hides them. Whatever WebGL state it changes is set
|
|
24
|
+
* back afterwards; a library that caches the WebGL state (three.js) must forget it first (`renderer.resetState()`).
|
|
25
|
+
*
|
|
26
|
+
* The map is busy drawing meanwhile: `render` reads the frame, not the map (`getCamera` excepted); it may call
|
|
27
|
+
* `requestRender` for an animation.
|
|
28
|
+
*/
|
|
29
|
+
export interface CustomLayerInterface {
|
|
30
|
+
/** A name for the application (the map numbers its layers) */
|
|
31
|
+
id?: string;
|
|
32
|
+
/** `'2d'` (the default): drawn over what is under it; `'3d'`: with the depth buffer of the 3D layers */
|
|
33
|
+
renderingMode?: '2d' | '3d';
|
|
34
|
+
/** Creates the WebGL objects: once added, and again after the WebGL context was lost and restored */
|
|
35
|
+
onAdd?(gl: WebGL2RenderingContext, map: GeoMap): void;
|
|
36
|
+
render(gl: WebGL2RenderingContext, frame: CustomFrame): void;
|
|
37
|
+
/** Frees the WebGL objects: the layer is removed, or the map destroyed */
|
|
38
|
+
onRemove?(gl: WebGL2RenderingContext, map: GeoMap): void;
|
|
39
|
+
}
|
|
40
|
+
/** A layer drawn by the page's WebGL code (see `CustomLayerInterface`) */
|
|
41
|
+
export declare class CustomLayer extends Layer {
|
|
42
|
+
/** The application's object */
|
|
43
|
+
readonly implementation: CustomLayerInterface;
|
|
44
|
+
private readonly canvas;
|
|
45
|
+
private readonly owner;
|
|
46
|
+
/** The map's WebGL context, and whether `onAdd` made the layer's objects there (until `onRemove`) */
|
|
47
|
+
private readonly gl;
|
|
48
|
+
private added;
|
|
49
|
+
/** The context was lost since `onAdd`: its objects are gone */
|
|
50
|
+
private stale;
|
|
51
|
+
private readonly lost;
|
|
52
|
+
private readonly frame;
|
|
53
|
+
/** Called by the engine at the layer's place in the frame; the page's errors are reported, the frame goes on */
|
|
54
|
+
private readonly draw;
|
|
55
|
+
remove(): void;
|
|
56
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** The page's own WebGL drawing as a layer, called in every frame with the map's matrices */
|
|
2
|
+
import { Layer } from "./layers.js";
|
|
3
|
+
// ── The page's own 3D content: custom layers, glTF models ──
|
|
4
|
+
/** Reports an error of the page without throwing it here: the console shows it, as an uncaught one */
|
|
5
|
+
const report = (error) => {
|
|
6
|
+
if (typeof reportError === 'function')
|
|
7
|
+
reportError(error);
|
|
8
|
+
else
|
|
9
|
+
queueMicrotask(() => {
|
|
10
|
+
throw error;
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
/** A layer drawn by the page's WebGL code (see `CustomLayerInterface`) */
|
|
14
|
+
export class CustomLayer extends Layer {
|
|
15
|
+
implementation;
|
|
16
|
+
canvas;
|
|
17
|
+
owner;
|
|
18
|
+
/** The map's WebGL context, and whether `onAdd` made the layer's objects there (until `onRemove`) */
|
|
19
|
+
gl;
|
|
20
|
+
added = false;
|
|
21
|
+
/** The context was lost since `onAdd`: its objects are gone */
|
|
22
|
+
stale = false;
|
|
23
|
+
lost = () => {
|
|
24
|
+
this.stale = true;
|
|
25
|
+
};
|
|
26
|
+
frame;
|
|
27
|
+
/** @internal */
|
|
28
|
+
constructor(map,
|
|
29
|
+
/** The application's object */
|
|
30
|
+
implementation, canvas, owner, matrix, camera) {
|
|
31
|
+
super(map);
|
|
32
|
+
this.implementation = implementation;
|
|
33
|
+
this.canvas = canvas;
|
|
34
|
+
this.owner = owner;
|
|
35
|
+
// The context the engine made on the canvas (none once it is lost)
|
|
36
|
+
const gl = canvas.getContext('webgl2');
|
|
37
|
+
if (!gl)
|
|
38
|
+
throw new Error('isard: a custom layer needs the WebGL2 context of the map');
|
|
39
|
+
this.gl = gl;
|
|
40
|
+
this.frame = {
|
|
41
|
+
matrixAt: ([lon, lat], altitude = 0) => {
|
|
42
|
+
const m = matrix(lon, lat, altitude);
|
|
43
|
+
if (!m)
|
|
44
|
+
throw new Error('isard: frame.matrixAt is only available during render');
|
|
45
|
+
return m;
|
|
46
|
+
},
|
|
47
|
+
get camera() {
|
|
48
|
+
return camera();
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** @internal */
|
|
53
|
+
create(engine) {
|
|
54
|
+
// Once, and again on a context restored (not when the map moves onto another engine: the same context)
|
|
55
|
+
if (!this.added || this.stale) {
|
|
56
|
+
if (!this.added)
|
|
57
|
+
this.canvas.addEventListener('webglcontextlost', this.lost);
|
|
58
|
+
this.added = true;
|
|
59
|
+
this.stale = false;
|
|
60
|
+
this.implementation.onAdd?.(this.gl, this.owner);
|
|
61
|
+
}
|
|
62
|
+
return engine.addCustomLayer(this.draw, this.implementation.renderingMode === '3d');
|
|
63
|
+
}
|
|
64
|
+
/** Called by the engine at the layer's place in the frame; the page's errors are reported, the frame goes on */
|
|
65
|
+
draw = () => {
|
|
66
|
+
try {
|
|
67
|
+
this.implementation.render(this.gl, this.frame);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
report(error);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
remove() {
|
|
74
|
+
super.remove();
|
|
75
|
+
this.dispose();
|
|
76
|
+
}
|
|
77
|
+
/** @internal The layer is removed or the map destroyed: `onRemove`, unless the context is lost */
|
|
78
|
+
dispose() {
|
|
79
|
+
if (!this.added)
|
|
80
|
+
return;
|
|
81
|
+
this.added = false;
|
|
82
|
+
this.canvas.removeEventListener('webglcontextlost', this.lost);
|
|
83
|
+
if (this.stale)
|
|
84
|
+
return;
|
|
85
|
+
try {
|
|
86
|
+
this.implementation.onRemove?.(this.gl, this.owner);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
report(error);
|
|
90
|
+
}
|
|
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CAAC,MAAM,EAAE,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,kGAAkG;IACzF,OAAO;QACd,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO;QACvB,IAAI,CAAC;YACH,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;CACF","sourcesContent":["/** The page's own WebGL drawing as a layer, called in every frame with the map's matrices */\n\nimport type { GeoMap } from '../map.ts';\nimport type { LayerHost, LonLat } from '../types.ts';\nimport type { Camera, Engine } from '../wasm/isard.js';\nimport { Layer } from './layers.ts';\n\n// ── The page's own 3D content: custom layers, glTF models ──\n\n/** Reports an error of the page without throwing it here: the console shows it, as an uncaught one */\nconst report = (error: unknown): void => {\n if (typeof reportError === 'function') reportError(error);\n else\n queueMicrotask(() => {\n throw error;\n });\n};\n\n/** What a custom layer gets to draw a frame (`CustomLayerInterface.render`) */\nexport interface CustomFrame {\n /**\n * The model-view-projection matrix of a local frame at a position and altitude (metres above the ellipsoid, as the\n * relief is drawn: times its exaggeration), column-major for `uniformMatrix4fv` or a three.js camera: x east, y\n * north, z up, in metres. Made in double precision relative to the camera, so that what is drawn stays exact at\n * any zoom; draw within a few kilometres of the position (or take one matrix per object far apart). Only during\n * `render`.\n */\n matrixAt(lonLat: LonLat, altitude?: number): Float32Array;\n /** The camera of the frame */\n readonly camera: Camera;\n}\n\n/**\n * A layer drawn by the page with its own WebGL code, as MapLibre's `CustomLayerInterface`: `render` is called at the\n * layer's place in every frame drawn. It starts with the canvas bound, its viewport set, blending on (`SRC_ALPHA`,\n * `ONE_MINUS_SRC_ALPHA`), no culling, and in `'3d'` mode the depth test on (`LEQUAL`, depth written): the relief, the\n * buildings and the 3D Tiles hide what it draws and what it draws hides them. Whatever WebGL state it changes is set\n * back afterwards; a library that caches the WebGL state (three.js) must forget it first (`renderer.resetState()`).\n *\n * The map is busy drawing meanwhile: `render` reads the frame, not the map (`getCamera` excepted); it may call\n * `requestRender` for an animation.\n */\nexport interface CustomLayerInterface {\n /** A name for the application (the map numbers its layers) */\n id?: string;\n /** `'2d'` (the default): drawn over what is under it; `'3d'`: with the depth buffer of the 3D layers */\n renderingMode?: '2d' | '3d';\n /** Creates the WebGL objects: once added, and again after the WebGL context was lost and restored */\n onAdd?(gl: WebGL2RenderingContext, map: GeoMap): void;\n render(gl: WebGL2RenderingContext, frame: CustomFrame): void;\n /** Frees the WebGL objects: the layer is removed, or the map destroyed */\n onRemove?(gl: WebGL2RenderingContext, map: GeoMap): void;\n}\n\n/** The model-view-projection of a local frame in the engine running the map (`Engine.customMatrix`) */\n/** @internal */\nexport type CustomMatrix = (lon: number, lat: number, altitude: number) => Float32Array | undefined;\n\n/** A layer drawn by the page's WebGL code (see `CustomLayerInterface`) */\nexport class CustomLayer extends Layer {\n /** The map's WebGL context, and whether `onAdd` made the layer's objects there (until `onRemove`) */\n private readonly gl: WebGL2RenderingContext;\n private added = false;\n /** The context was lost since `onAdd`: its objects are gone */\n private stale = false;\n private readonly lost = () => {\n this.stale = true;\n };\n private readonly frame: CustomFrame;\n\n /** @internal */\n constructor(\n map: LayerHost,\n /** The application's object */\n readonly implementation: CustomLayerInterface,\n private readonly canvas: HTMLCanvasElement,\n private readonly owner: GeoMap,\n matrix: CustomMatrix,\n camera: () => Camera,\n ) {\n super(map);\n // The context the engine made on the canvas (none once it is lost)\n const gl = canvas.getContext('webgl2');\n\n if (!gl) throw new Error('isard: a custom layer needs the WebGL2 context of the map');\n this.gl = gl;\n this.frame = {\n matrixAt: ([lon, lat], altitude = 0) => {\n const m = matrix(lon, lat, altitude);\n\n if (!m) throw new Error('isard: frame.matrixAt is only available during render');\n\n return m;\n },\n get camera() {\n return camera();\n },\n };\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n // Once, and again on a context restored (not when the map moves onto another engine: the same context)\n if (!this.added || this.stale) {\n if (!this.added) this.canvas.addEventListener('webglcontextlost', this.lost);\n this.added = true;\n this.stale = false;\n this.implementation.onAdd?.(this.gl, this.owner);\n }\n\n return engine.addCustomLayer(this.draw, this.implementation.renderingMode === '3d');\n }\n\n /** Called by the engine at the layer's place in the frame; the page's errors are reported, the frame goes on */\n private readonly draw = (): void => {\n try {\n this.implementation.render(this.gl, this.frame);\n } catch (error) {\n report(error);\n }\n };\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal The layer is removed or the map destroyed: `onRemove`, unless the context is lost */\n override dispose(): void {\n if (!this.added) return;\n this.added = false;\n this.canvas.removeEventListener('webglcontextlost', this.lost);\n if (this.stale) return;\n try {\n this.implementation.onRemove?.(this.gl, this.owner);\n } catch (error) {\n report(error);\n }\n }\n}\n"]}
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by
|
|
5
5
|
* the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
7
|
+
import type { Placement } from '../types.ts';
|
|
8
|
+
import { type Feature, type FeatureData, type FeatureLayerStyle, type Properties, type Styled } from './features.ts';
|
|
9
|
+
import { Layer } from './layers.ts';
|
|
10
|
+
import type { NetworkLayer } from './network.ts';
|
|
9
11
|
export interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {
|
|
10
12
|
/** CSS color (default `#e4e1dc`) */
|
|
11
13
|
color: Styled<string, P>;
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by
|
|
5
5
|
* the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).
|
|
6
6
|
*/
|
|
7
|
-
import { metresAt
|
|
7
|
+
import { metresAt } from "../util/geo.js";
|
|
8
|
+
import { roofNumber } from "../util/roofs.js";
|
|
8
9
|
import { FLOATS, STYLE } from "../util/style-floats.js";
|
|
9
10
|
import { evaluate, featuresOf, parseColor, polygonGeometry, rampTexels, stops, } from "./features.js";
|
|
10
11
|
import { Layer } from "./layers.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extrusions.js","sourceRoot":"","sources":["../../src/layers/extrusions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EACL,QAAQ,EAIR,UAAU,EAGV,UAAU,EACV,eAAe,EACf,UAAU,EAEV,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAqB,MAAM,aAAa,CAAC;AAkDvD,yCAAyC;AACzC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAE5B,MAAM,OAAO,cAA+B,SAAQ,KAAK;IAS7C;IARO,KAAK,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC3D,SAAS,GAAG,CAAC,CAAC;IACd,OAAO,CAAmD;IAElE,gBAAgB;IAChB,YACE,GAAc,EACd,IAAgC,EACxB,KAAwB;QAEhC,KAAK,CAAC,GAAG,CAAC,CAAC;QAFH,UAAK,GAAL,KAAK,CAAmB;QAGhC,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,E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,OAAO,EAAE,KAAK;QACd,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Extruded polygons (buildings), styled per feature like the other feature layers, coming in tiles (or one set): an\n * application loading a tiled source (BD TOPO vector tiles…) hands each tile's buildings to `setTile` and drops them\n * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by\n * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).\n */\n\nimport type { LayerHost } from '../types.ts';\nimport { metresAt, roofNumber } from '../util/roofs.ts';\nimport { FLOATS, STYLE } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport {\n evaluate,\n type Feature,\n type FeatureData,\n type FeatureLayerStyle,\n featuresOf,\n type Placement,\n type Properties,\n parseColor,\n polygonGeometry,\n rampTexels,\n type Styled,\n stops,\n} from './features.ts';\nimport { Layer, type NetworkLayer } from './layers.ts';\n\nexport interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color (default `#e4e1dc`) */\n color: Styled<string, P>;\n /** Height of the roof over the ground, metres (default 6) */\n height: Styled<number, P>;\n /** Height of the foot of the walls, metres (default 0) */\n base: Styled<number, P>;\n /** Its roof's shape (default `flat`): one of OpenStreetMap's `roof:shape` (hipped, gabled, pyramidal, mansard; the\n * others drawn as the nearest of them), or `generated` from its outline (hipped or gabled under 450 m², a mansard\n * under 3000 m², flat past that). Fitted into the building's height, at most half of it */\n roof: Styled<string, P>;\n /** Its roof's height over the walls' top, metres (default: as its slopes make it) */\n roofHeight: Styled<number, P>;\n /** The walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades: boolean;\n}\n\nexport interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {\n /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */\n data?: FeatureData<P>;\n}\n\n/** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */\nexport type TileKey = string | number;\n\n/**\n * Polygons as typed arrays, for tiles decoded in a worker (no GeoJSON in between): points in Mercator [0, 1] (x, y\n * interleaved, y towards the south), the first point of each ring and the first ring of each polygon (one more entry\n * than rings and polygons; the first ring of a polygon is its outline), the feature of each polygon\n */\nexport interface PolygonArrays {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n}\n\ninterface Tile<P> {\n /** Batch number in the engine: tiles are drawn, and their features numbered for picking, in this order */\n batch: number;\n /** The properties of the features, which the style reads */\n properties: P[];\n features: Feature<P>[] | undefined;\n arrays: PolygonArrays | undefined;\n values: Float32Array | undefined;\n anchors: Float32Array | undefined;\n}\n\n/** TileKey of the set given as `data` */\nconst DATA = Symbol('data');\n\nexport class ExtrusionLayer<P = Properties> extends Layer {\n private readonly tiles = new Map<TileKey | typeof DATA, Tile<P>>();\n private nextBatch = 1;\n private network: { layer: NetworkLayer; max: number } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P> | undefined,\n private style: ExtrusionStyle<P>,\n ) {\n super(map);\n if (data) {\n const features = featuresOf(data);\n const properties = features.map((f) => f.properties);\n\n this.tiles.set(DATA, {\n batch: 0,\n properties,\n features,\n arrays: undefined,\n values: undefined,\n anchors: undefined,\n });\n }\n }\n\n /** Replaces the set given as `data` */\n setData(data: FeatureData<P>): void {\n const features = featuresOf(data);\n\n this.put(\n DATA,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n\n /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */\n setTile(key: TileKey, data: FeatureData<P> | { arrays: PolygonArrays; properties: P[] }): void {\n if ('arrays' in data) this.put(key, data.properties, undefined, data.arrays);\n else {\n const features = featuresOf(data);\n\n this.put(\n key,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n }\n\n removeTile(key: TileKey): void {\n const tile = this.tiles.get(key);\n\n if (!tile) return;\n this.tiles.delete(key);\n this.map.engine.removeExtrusionBatch(this.id, tile.batch);\n this.map.requestRender();\n }\n\n /** Keys of the tiles held */\n get tileKeys(): TileKey[] {\n return [...this.tiles.keys()].filter((k): k is TileKey => k !== DATA);\n }\n\n /** The properties of the features of a tile (or of the data) */\n properties(key?: TileKey): readonly P[] {\n return this.tiles.get(key ?? DATA)?.properties ?? [];\n }\n\n /** The feature of a picked index (its geometry if given as GeoJSON): tiles are numbered one after the other, in the\n * order they were added */\n featureAt(index: number): Feature<P> | undefined {\n let rest = index;\n\n for (const tile of [...this.tiles.values()].sort((a, b) => a.batch - b.batch)) {\n const n = tile.properties.length;\n\n if (rest < n) {\n const properties = tile.properties[rest];\n\n if (properties === undefined) return undefined;\n\n return tile.features?.[rest] ?? { type: 'Feature', properties, geometry: null };\n }\n rest -= n;\n }\n\n return undefined;\n }\n\n /** The tile and the index in it of a picked index */\n tileAt(index: number): { key: TileKey | undefined; index: number } | undefined {\n let rest = index;\n\n for (const [key, tile] of [...this.tiles].sort((a, b) => a[1].batch - b[1].batch)) {\n if (rest < tile.properties.length) return { key: key === DATA ? undefined : key, index: rest };\n rest -= tile.properties.length;\n }\n\n return undefined;\n }\n\n setStyle(style: Partial<ExtrusionStyle<P>>): void {\n this.style = { ...this.style, ...style };\n\n const engine = this.map.engine;\n // The roofs are geometry: the blocks built again\n const reshaped = style.roof !== undefined || style.roofHeight !== undefined;\n\n this.tiles.forEach((tile) => {\n if (reshaped) this.sendTile(engine, this.id, tile);\n else this.sendStyle(engine, this.id, tile);\n });\n this.sendLayer(engine, this.id);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible });\n }\n\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.tiles.forEach((tile) => {\n this.map.engine.setFeatureMask(this.id, this.mask(tile), tile.batch);\n });\n this.map.requestRender();\n }\n\n /** One value per building of a tile (or of the data), colored through the ramp; NaN keeps a building's color */\n setValues(values: Float32Array | undefined, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.values = values;\n this.map.engine.setFeatureValues(\n this.id,\n values ?? new Float32Array(tile.properties.length).fill(Number.NaN),\n tile.batch,\n );\n this.map.requestRender();\n }\n\n /**\n * Colors the buildings by the node values of a network layer, recolored with it: each building takes min(value(A)\n * + cost from A, value(B) + cost from B) from its anchors (`setAnchors`), through the ramp, up to `max` (above, or\n * unreached: its own color). Undefined: back to the buildings' own values.\n */\n linkNetwork(network: NetworkLayer | undefined, max = Number.POSITIVE_INFINITY): void {\n this.network = network && { layer: network, max };\n this.sendLink(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Per building of a tile (or of the data): node A, node B, cost from A, cost from B (4 floats each) */\n setAnchors(anchors: Float32Array, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.anchors = anchors;\n this.map.engine.setExtrusionAnchors(this.id, tile.batch, anchors);\n this.map.requestRender();\n }\n\n private put(\n key: TileKey | typeof DATA,\n properties: P[],\n features: Feature<P>[] | undefined,\n arrays: PolygonArrays | undefined,\n ): void {\n const old = this.tiles.get(key);\n const tile: Tile<P> = {\n batch: old?.batch ?? (key === DATA ? 0 : this.nextBatch++),\n properties,\n features,\n arrays,\n values: undefined,\n anchors: undefined,\n };\n\n this.tiles.set(key, tile);\n this.sendTile(this.map.engine, this.id, tile);\n this.map.requestRender();\n }\n\n private mask(tile: Tile<P>): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(tile.properties.length).fill(255);\n\n if (filter)\n tile.properties.forEach((p, i) => {\n if (!filter(p, i)) mask[i] = 0;\n });\n\n return mask;\n }\n\n private sendTile(engine: Engine, id: number, tile: Tile<P>): void {\n const g = tile.arrays ?? polygonGeometry(tile.features ?? []);\n const n = tile.properties.length;\n const { roofs, heights } = this.roofs(tile, g.feature);\n // The metres per Mercator unit at the middle of the batch (a batch spanning a country errs by a few hundredths)\n const [north, south] = g.points.reduce(\n ([lo, hi], v, i) => (i % 2 === 1 ? [Math.min(lo, v), Math.max(hi, v)] : [lo, hi]),\n [1, 0],\n );\n const metres = north <= south ? metresAt((north + south) / 2) : 0;\n\n engine.setExtrusionBatch(\n id,\n tile.batch,\n g.points,\n g.ringStart,\n g.polygonStart,\n g.feature,\n n,\n roofs,\n heights,\n metres,\n );\n this.sendStyle(engine, id, tile);\n if (tile.values) engine.setFeatureValues(id, tile.values, tile.batch);\n if (tile.anchors) engine.setExtrusionAnchors(id, tile.batch, tile.anchors);\n }\n\n /** Each polygon's roof (`roofNumber`: none if all flat) and height, from its feature's style */\n private roofs(tile: Tile<P>, feature: Uint32Array): { roofs: Uint8Array; heights: Float32Array } {\n const { roof, roofHeight } = this.style;\n\n if (roof === 'flat') return { roofs: new Uint8Array(), heights: new Float32Array() };\n\n const shapes = tile.properties.map((p, i) => roofNumber(evaluate(roof, p, i)) ?? 0);\n const heights = tile.properties.map((p, i) => evaluate(roofHeight, p, i));\n\n return {\n roofs: Uint8Array.from(feature, (f) => shapes[f] ?? 0),\n heights: Float32Array.from(feature, (f) => heights[f] ?? Number.NaN),\n };\n }\n\n private sendStyle(engine: Engine, id: number, tile: Tile<P>): void {\n const { color, height, base } = this.style;\n const out = new Float32Array(tile.properties.length * FLOATS);\n // Constant colors parsed once: a tile has thousands of buildings\n const fixed = typeof color === 'string' ? parseColor(color) : undefined;\n\n tile.properties.forEach((p, i) => {\n const o = i * FLOATS;\n\n out.set(fixed ?? parseColor(evaluate(color, p, i)), o + STYLE.color);\n out.set(stops(evaluate(height, p, i)), o + STYLE.size);\n out.set(stops(evaluate(base, p, i)), o + STYLE.size2);\n });\n engine.setFeatureStyle(id, out, tile.batch);\n engine.setFeatureMask(id, this.mask(tile), tile.batch);\n }\n\n private sendLayer(engine: Engine, id: number): void {\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n engine.setFacades(id, this.style.facades);\n }\n\n private sendLink(engine: Engine, id: number): void {\n const n = this.network;\n // A network removed (or not created) links to nothing\n const network = n && n.layer.id >= 0 ? n.layer.id : undefined;\n\n engine.linkExtrusionNetwork(id, network, n ? Math.min(n.max, 1e29) : 0);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addExtrusions();\n\n this.sendLayer(engine, id);\n this.tiles.forEach((tile) => {\n this.sendTile(engine, id, tile);\n });\n // A network created before (on a new engine, the map relinks once every layer is there)\n if (!this.network || this.network.layer.id >= 0) this.sendLink(engine, id);\n\n return id;\n }\n\n /** @internal On a new engine, the network may come after the buildings: linked once both are there */\n override relink(engine: Engine): void {\n if (this.network) this.sendLink(engine, this.id);\n }\n}\n\nexport const extrusionStyle = <P>(options: ExtrusionOptions<P>): ExtrusionStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n color: '#e4e1dc',\n height: 6,\n base: 0,\n roof: 'flat',\n roofHeight: Number.NaN,\n facades: false,\n ...rest,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"extrusions.js","sourceRoot":"","sources":["../../src/layers/extrusions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EACL,QAAQ,EAIR,UAAU,EAEV,UAAU,EACV,eAAe,EACf,UAAU,EAEV,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAmDpC,yCAAyC;AACzC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAE5B,MAAM,OAAO,cAA+B,SAAQ,KAA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AAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,MAAM,CAAC,GAAG;QACtB,OAAO,EAAE,KAAK;QACd,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Extruded polygons (buildings), styled per feature like the other feature layers, coming in tiles (or one set): an\n * application loading a tiled source (BD TOPO vector tiles…) hands each tile's buildings to `setTile` and drops them\n * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by\n * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).\n */\n\nimport type { LayerHost, Placement } from '../types.ts';\nimport { metresAt } from '../util/geo.ts';\nimport { roofNumber } from '../util/roofs.ts';\nimport { FLOATS, STYLE } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport {\n evaluate,\n type Feature,\n type FeatureData,\n type FeatureLayerStyle,\n featuresOf,\n type Properties,\n parseColor,\n polygonGeometry,\n rampTexels,\n type Styled,\n stops,\n} from './features.ts';\nimport { Layer } from './layers.ts';\nimport type { NetworkLayer } from './network.ts';\n\nexport interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color (default `#e4e1dc`) */\n color: Styled<string, P>;\n /** Height of the roof over the ground, metres (default 6) */\n height: Styled<number, P>;\n /** Height of the foot of the walls, metres (default 0) */\n base: Styled<number, P>;\n /** Its roof's shape (default `flat`): one of OpenStreetMap's `roof:shape` (hipped, gabled, pyramidal, mansard; the\n * others drawn as the nearest of them), or `generated` from its outline (hipped or gabled under 450 m², a mansard\n * under 3000 m², flat past that). Fitted into the building's height, at most half of it */\n roof: Styled<string, P>;\n /** Its roof's height over the walls' top, metres (default: as its slopes make it) */\n roofHeight: Styled<number, P>;\n /** The walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades: boolean;\n}\n\nexport interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {\n /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */\n data?: FeatureData<P>;\n}\n\n/** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */\nexport type TileKey = string | number;\n\n/**\n * Polygons as typed arrays, for tiles decoded in a worker (no GeoJSON in between): points in Mercator [0, 1] (x, y\n * interleaved, y towards the south), the first point of each ring and the first ring of each polygon (one more entry\n * than rings and polygons; the first ring of a polygon is its outline), the feature of each polygon\n */\nexport interface PolygonArrays {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n}\n\ninterface Tile<P> {\n /** Batch number in the engine: tiles are drawn, and their features numbered for picking, in this order */\n batch: number;\n /** The properties of the features, which the style reads */\n properties: P[];\n features: Feature<P>[] | undefined;\n arrays: PolygonArrays | undefined;\n values: Float32Array | undefined;\n anchors: Float32Array | undefined;\n}\n\n/** TileKey of the set given as `data` */\nconst DATA = Symbol('data');\n\nexport class ExtrusionLayer<P = Properties> extends Layer {\n private readonly tiles = new Map<TileKey | typeof DATA, Tile<P>>();\n private nextBatch = 1;\n private network: { layer: NetworkLayer; max: number } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P> | undefined,\n private style: ExtrusionStyle<P>,\n ) {\n super(map);\n if (data) {\n const features = featuresOf(data);\n const properties = features.map((f) => f.properties);\n\n this.tiles.set(DATA, {\n batch: 0,\n properties,\n features,\n arrays: undefined,\n values: undefined,\n anchors: undefined,\n });\n }\n }\n\n /** Replaces the set given as `data` */\n setData(data: FeatureData<P>): void {\n const features = featuresOf(data);\n\n this.put(\n DATA,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n\n /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */\n setTile(key: TileKey, data: FeatureData<P> | { arrays: PolygonArrays; properties: P[] }): void {\n if ('arrays' in data) this.put(key, data.properties, undefined, data.arrays);\n else {\n const features = featuresOf(data);\n\n this.put(\n key,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n }\n\n removeTile(key: TileKey): void {\n const tile = this.tiles.get(key);\n\n if (!tile) return;\n this.tiles.delete(key);\n this.map.engine.removeExtrusionBatch(this.id, tile.batch);\n this.map.requestRender();\n }\n\n /** Keys of the tiles held */\n get tileKeys(): TileKey[] {\n return [...this.tiles.keys()].filter((k): k is TileKey => k !== DATA);\n }\n\n /** The properties of the features of a tile (or of the data) */\n properties(key?: TileKey): readonly P[] {\n return this.tiles.get(key ?? DATA)?.properties ?? [];\n }\n\n /** The feature of a picked index (its geometry if given as GeoJSON): tiles are numbered one after the other, in the\n * order they were added */\n featureAt(index: number): Feature<P> | undefined {\n let rest = index;\n\n for (const tile of [...this.tiles.values()].sort((a, b) => a.batch - b.batch)) {\n const n = tile.properties.length;\n\n if (rest < n) {\n const properties = tile.properties[rest];\n\n if (properties === undefined) return undefined;\n\n return tile.features?.[rest] ?? { type: 'Feature', properties, geometry: null };\n }\n rest -= n;\n }\n\n return undefined;\n }\n\n /** The tile and the index in it of a picked index */\n tileAt(index: number): { key: TileKey | undefined; index: number } | undefined {\n let rest = index;\n\n for (const [key, tile] of [...this.tiles].sort((a, b) => a[1].batch - b[1].batch)) {\n if (rest < tile.properties.length) return { key: key === DATA ? undefined : key, index: rest };\n rest -= tile.properties.length;\n }\n\n return undefined;\n }\n\n setStyle(style: Partial<ExtrusionStyle<P>>): void {\n this.style = { ...this.style, ...style };\n\n const engine = this.map.engine;\n // The roofs are geometry: the blocks built again\n const reshaped = style.roof !== undefined || style.roofHeight !== undefined;\n\n this.tiles.forEach((tile) => {\n if (reshaped) this.sendTile(engine, this.id, tile);\n else this.sendStyle(engine, this.id, tile);\n });\n this.sendLayer(engine, this.id);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible });\n }\n\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.tiles.forEach((tile) => {\n this.map.engine.setFeatureMask(this.id, this.mask(tile), tile.batch);\n });\n this.map.requestRender();\n }\n\n /** One value per building of a tile (or of the data), colored through the ramp; NaN keeps a building's color */\n setValues(values: Float32Array | undefined, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.values = values;\n this.map.engine.setFeatureValues(\n this.id,\n values ?? new Float32Array(tile.properties.length).fill(Number.NaN),\n tile.batch,\n );\n this.map.requestRender();\n }\n\n /**\n * Colors the buildings by the node values of a network layer, recolored with it: each building takes min(value(A)\n * + cost from A, value(B) + cost from B) from its anchors (`setAnchors`), through the ramp, up to `max` (above, or\n * unreached: its own color). Undefined: back to the buildings' own values.\n */\n linkNetwork(network: NetworkLayer | undefined, max = Number.POSITIVE_INFINITY): void {\n this.network = network && { layer: network, max };\n this.sendLink(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Per building of a tile (or of the data): node A, node B, cost from A, cost from B (4 floats each) */\n setAnchors(anchors: Float32Array, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.anchors = anchors;\n this.map.engine.setExtrusionAnchors(this.id, tile.batch, anchors);\n this.map.requestRender();\n }\n\n private put(\n key: TileKey | typeof DATA,\n properties: P[],\n features: Feature<P>[] | undefined,\n arrays: PolygonArrays | undefined,\n ): void {\n const old = this.tiles.get(key);\n const tile: Tile<P> = {\n batch: old?.batch ?? (key === DATA ? 0 : this.nextBatch++),\n properties,\n features,\n arrays,\n values: undefined,\n anchors: undefined,\n };\n\n this.tiles.set(key, tile);\n this.sendTile(this.map.engine, this.id, tile);\n this.map.requestRender();\n }\n\n private mask(tile: Tile<P>): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(tile.properties.length).fill(255);\n\n if (filter)\n tile.properties.forEach((p, i) => {\n if (!filter(p, i)) mask[i] = 0;\n });\n\n return mask;\n }\n\n private sendTile(engine: Engine, id: number, tile: Tile<P>): void {\n const g = tile.arrays ?? polygonGeometry(tile.features ?? []);\n const n = tile.properties.length;\n const { roofs, heights } = this.roofs(tile, g.feature);\n // The metres per Mercator unit at the middle of the batch (a batch spanning a country errs by a few hundredths)\n const [north, south] = g.points.reduce(\n ([lo, hi], v, i) => (i % 2 === 1 ? [Math.min(lo, v), Math.max(hi, v)] : [lo, hi]),\n [1, 0],\n );\n const metres = north <= south ? metresAt((north + south) / 2) : 0;\n\n engine.setExtrusionBatch(\n id,\n tile.batch,\n g.points,\n g.ringStart,\n g.polygonStart,\n g.feature,\n n,\n roofs,\n heights,\n metres,\n );\n this.sendStyle(engine, id, tile);\n if (tile.values) engine.setFeatureValues(id, tile.values, tile.batch);\n if (tile.anchors) engine.setExtrusionAnchors(id, tile.batch, tile.anchors);\n }\n\n /** Each polygon's roof (`roofNumber`: none if all flat) and height, from its feature's style */\n private roofs(tile: Tile<P>, feature: Uint32Array): { roofs: Uint8Array; heights: Float32Array } {\n const { roof, roofHeight } = this.style;\n\n if (roof === 'flat') return { roofs: new Uint8Array(), heights: new Float32Array() };\n\n const shapes = tile.properties.map((p, i) => roofNumber(evaluate(roof, p, i)) ?? 0);\n const heights = tile.properties.map((p, i) => evaluate(roofHeight, p, i));\n\n return {\n roofs: Uint8Array.from(feature, (f) => shapes[f] ?? 0),\n heights: Float32Array.from(feature, (f) => heights[f] ?? Number.NaN),\n };\n }\n\n private sendStyle(engine: Engine, id: number, tile: Tile<P>): void {\n const { color, height, base } = this.style;\n const out = new Float32Array(tile.properties.length * FLOATS);\n // Constant colors parsed once: a tile has thousands of buildings\n const fixed = typeof color === 'string' ? parseColor(color) : undefined;\n\n tile.properties.forEach((p, i) => {\n const o = i * FLOATS;\n\n out.set(fixed ?? parseColor(evaluate(color, p, i)), o + STYLE.color);\n out.set(stops(evaluate(height, p, i)), o + STYLE.size);\n out.set(stops(evaluate(base, p, i)), o + STYLE.size2);\n });\n engine.setFeatureStyle(id, out, tile.batch);\n engine.setFeatureMask(id, this.mask(tile), tile.batch);\n }\n\n private sendLayer(engine: Engine, id: number): void {\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n engine.setFacades(id, this.style.facades);\n }\n\n private sendLink(engine: Engine, id: number): void {\n const n = this.network;\n // A network removed (or not created) links to nothing\n const network = n && n.layer.id >= 0 ? n.layer.id : undefined;\n\n engine.linkExtrusionNetwork(id, network, n ? Math.min(n.max, 1e29) : 0);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addExtrusions();\n\n this.sendLayer(engine, id);\n this.tiles.forEach((tile) => {\n this.sendTile(engine, id, tile);\n });\n // A network created before (on a new engine, the map relinks once every layer is there)\n if (!this.network || this.network.layer.id >= 0) this.sendLink(engine, id);\n\n return id;\n }\n\n /** @internal On a new engine, the network may come after the buildings: linked once both are there */\n override relink(engine: Engine): void {\n if (this.network) this.sendLink(engine, this.id);\n }\n}\n\nexport const extrusionStyle = <P>(options: ExtrusionOptions<P>): ExtrusionStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n color: '#e4e1dc',\n height: 6,\n base: 0,\n roof: 'flat',\n roofHeight: Number.NaN,\n facades: false,\n ...rest,\n };\n};\n"]}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* returning either, evaluated once per feature when the data or the style change: the engine keeps the result in
|
|
5
5
|
* textures, and restyling, recoloring by values or filtering never touches the geometry.
|
|
6
6
|
*/
|
|
7
|
+
import type { Placement } from '../types.ts';
|
|
8
|
+
import { parseColor, type Ramp, rampTexels } from '../util/color.ts';
|
|
7
9
|
import { Layer } from './layers.ts';
|
|
8
10
|
export type Position = [lon: number, lat: number, ...rest: number[]];
|
|
9
11
|
export type Geometry = {
|
|
@@ -54,9 +56,8 @@ export type Stops = [zoom: number, value: number][];
|
|
|
54
56
|
/** A size: CSS pixels, or zoom stops */
|
|
55
57
|
export type Size = number | Stops;
|
|
56
58
|
/** A value for all features, or a function of each feature (its properties and its index in the data) */
|
|
59
|
+
export { parseColor, type Ramp, rampTexels };
|
|
57
60
|
export type Styled<T, P = Properties> = T | ((properties: P, index: number) => T);
|
|
58
|
-
/** Colors of values: `[[value, color], …]` in increasing values, linear in between */
|
|
59
|
-
export type Ramp = [value: number, color: string][];
|
|
60
61
|
export interface FeatureLayerStyle<P = Properties> {
|
|
61
62
|
/** Layer opacity, 0 to 1, or zoom stops (a layer fading in past a zoom) (default 1) */
|
|
62
63
|
opacity: Size;
|
|
@@ -91,10 +92,6 @@ export interface CircleStyle<P = Properties> extends FeatureLayerStyle<P> {
|
|
|
91
92
|
export interface FillStyle<P = Properties> extends FeatureLayerStyle<P> {
|
|
92
93
|
color: Styled<string, P>;
|
|
93
94
|
}
|
|
94
|
-
/** Where a new layer goes: under `before`, or on top of the others */
|
|
95
|
-
export interface Placement {
|
|
96
|
-
before?: Layer;
|
|
97
|
-
}
|
|
98
95
|
export interface LineOptions<P = Properties> extends Partial<LineStyle<P>>, Placement {
|
|
99
96
|
/** LineString and MultiLineString features; the rings of Polygon and MultiPolygon features are drawn as lines */
|
|
100
97
|
data: FeatureData<P>;
|
|
@@ -107,14 +104,6 @@ export interface FillOptions<P = Properties> extends Partial<FillStyle<P>>, Plac
|
|
|
107
104
|
/** Polygon and MultiPolygon features */
|
|
108
105
|
data: FeatureData<P>;
|
|
109
106
|
}
|
|
110
|
-
/** A CSS color to RGBA 0-1 (see `parseCssColor`); black if unknown or missing */
|
|
111
|
-
export declare const parseColor: (color: string) => [r: number, g: number, b: number, a: number];
|
|
112
|
-
/** 256 RGBA texels of a ramp over its value range, and that range */
|
|
113
|
-
export declare const rampTexels: (ramp: Ramp) => {
|
|
114
|
-
rgba: Uint8Array;
|
|
115
|
-
min: number;
|
|
116
|
-
max: number;
|
|
117
|
-
};
|
|
118
107
|
/** Up to four stops as zooms then values, constant if a number */
|
|
119
108
|
export declare const stops: (size: Size) => [number, number, number, number, number, number, number, number];
|
|
120
109
|
/** Value of zoom stops at a zoom */
|
package/dist/layers/features.js
CHANGED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
* textures, and restyling, recoloring by values or filtering never touches the geometry.
|
|
6
6
|
*/
|
|
7
7
|
import { crsOf, reproject } from "../data/crs.js";
|
|
8
|
-
import {
|
|
8
|
+
import { parseColor, rampTexels } from "../util/color.js";
|
|
9
9
|
import { mercatorX, mercatorY } from "../util/geo.js";
|
|
10
10
|
import { FLOATS, STYLE } from "../util/style-floats.js";
|
|
11
11
|
import { Layer } from "./layers.js";
|
|
12
|
+
/** A value for all features, or a function of each feature (its properties and its index in the data) */
|
|
13
|
+
// Where they were, for the layers and the API
|
|
14
|
+
export { parseColor, rampTexels };
|
|
12
15
|
const BASE = {
|
|
13
16
|
opacity: 1,
|
|
14
17
|
minZoom: 0,
|
|
@@ -17,30 +20,6 @@ const BASE = {
|
|
|
17
20
|
filter: undefined,
|
|
18
21
|
ramp: undefined,
|
|
19
22
|
};
|
|
20
|
-
// ── Colors ──
|
|
21
|
-
/** A CSS color to RGBA 0-1 (see `parseCssColor`); black if unknown or missing */
|
|
22
|
-
export const parseColor = (color) => {
|
|
23
|
-
return parseCssColor(color) ?? [0, 0, 0, 1];
|
|
24
|
-
};
|
|
25
|
-
/** 256 RGBA texels of a ramp over its value range, and that range */
|
|
26
|
-
export const rampTexels = (ramp) => {
|
|
27
|
-
const stops = ramp.map(([v, c]) => [v, parseColor(c)]).sort((a, b) => a[0] - b[0]);
|
|
28
|
-
const min = stops[0]?.[0] ?? 0;
|
|
29
|
-
const max = stops.at(-1)?.[0] ?? 1;
|
|
30
|
-
const rgba = new Uint8Array(256 * 4);
|
|
31
|
-
for (let i = 0; i < 256; i += 1) {
|
|
32
|
-
const v = min + ((max - min) * i) / 255;
|
|
33
|
-
let k = 0;
|
|
34
|
-
while (k + 1 < stops.length && (stops[k + 1]?.[0] ?? 0) < v)
|
|
35
|
-
k += 1;
|
|
36
|
-
const [v0, c0] = stops[k] ?? [min, [0, 0, 0, 1]];
|
|
37
|
-
const [v1, c1] = stops[k + 1] ?? [v0, c0];
|
|
38
|
-
const t = v1 > v0 ? Math.max(0, Math.min(1, (v - v0) / (v1 - v0))) : 0;
|
|
39
|
-
for (let j = 0; j < 4; j += 1)
|
|
40
|
-
rgba[i * 4 + j] = Math.round(((c0[j] ?? 0) + ((c1[j] ?? 0) - (c0[j] ?? 0)) * t) * 255);
|
|
41
|
-
}
|
|
42
|
-
return { rgba, min, max };
|
|
43
|
-
};
|
|
44
23
|
/** Up to four stops as zooms then values, constant if a number */
|
|
45
24
|
export const stops = (size) => {
|
|
46
25
|
if (!Array.isArray(size)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/layers/features.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAiGpC,MAAM,IAAI,GAAG;IACX,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,EAAE;IACX,OAAO,EA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CAAC;QACT,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,UAAU;QACrB,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,OAAuB,EAAgB,EAAE;IACpE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjD,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;AAC7C,CAAC,CAAC","sourcesContent":["/**\n * Feature layers: lines, circles and fills from GeoJSON, styled per feature. A style value is a constant, zoom stops\n * (`[[zoom, value], …]`, linear in between, as MapLibre's `interpolate linear zoom`), or a function of the feature\n * returning either, evaluated once per feature when the data or the style change: the engine keeps the result in\n * textures, and restyling, recoloring by values or filtering never touches the geometry.\n */\n\nimport { crsOf, reproject } from '../data/crs.ts';\nimport type { LayerHost } from '../types.ts';\nimport { parseCssColor } from '../util/color.ts';\nimport { mercatorX, mercatorY } from '../util/geo.ts';\nimport { FLOATS, STYLE } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport { Layer } from './layers.ts';\n\n// ── GeoJSON (the parts used here) ──\n\nexport type Position = [lon: number, lat: number, ...rest: number[]];\nexport type Geometry =\n | { type: 'Point'; coordinates: Position }\n | { type: 'MultiPoint'; coordinates: Position[] }\n | { type: 'LineString'; coordinates: Position[] }\n | { type: 'MultiLineString'; coordinates: Position[][] }\n | { type: 'Polygon'; coordinates: Position[][] }\n | { type: 'MultiPolygon'; coordinates: Position[][][] }\n | { type: 'GeometryCollection'; geometries: Geometry[] };\nexport type Properties = Record<string, unknown>;\nexport interface Feature<P = Properties> {\n type: 'Feature';\n geometry: Geometry | null;\n properties: P;\n id?: string | number;\n}\nexport interface FeatureCollection<P = Properties> {\n type: 'FeatureCollection';\n features: Feature<P>[];\n /** The CRS of the coordinates, a legacy member (GeoJSON of 2008, the output of a WFS in another CRS): the feature\n * layers reproject a collection that names one (see `reproject`) */\n crs?: { type: 'name'; properties: { name: string } };\n}\n/** What a feature layer takes: a collection, its features, or one feature */\nexport type FeatureData<P = Properties> = FeatureCollection<P> | Feature<P>[] | Feature<P>;\n\n// ── Style values ──\n\n/** Zoom stops: `[[zoom, value], …]` in increasing zooms, up to four, linear in between, constant outside */\nexport type Stops = [zoom: number, value: number][];\n/** A size: CSS pixels, or zoom stops */\nexport type Size = number | Stops;\n/** A value for all features, or a function of each feature (its properties and its index in the data) */\nexport type Styled<T, P = Properties> = T | ((properties: P, index: number) => T);\n/** Colors of values: `[[value, color], …]` in increasing values, linear in between */\nexport type Ramp = [value: number, color: string][];\n\nexport interface FeatureLayerStyle<P = Properties> {\n /** Layer opacity, 0 to 1, or zoom stops (a layer fading in past a zoom) (default 1) */\n opacity: Size;\n /** Zooms the layer shows in: from `minZoom` (included) to `maxZoom` (excluded) */\n minZoom: number;\n maxZoom: number;\n visible: boolean;\n /** Features drawn; the others hidden (default all) */\n filter: ((properties: P, index: number) => boolean) | undefined;\n /** Colors of the values given by `setValues`: a feature with a value takes its color here, the others keep theirs */\n ramp: Ramp | undefined;\n}\n\nexport interface LineStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color: `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()`, `rgba()` (default `#000`) */\n color: Styled<string, P>;\n /** CSS pixels (default 1) */\n width: Styled<Size, P>;\n /** Dash and gap, in line widths (MapLibre's `line-dasharray`); undefined: solid */\n dash: [dash: number, gap: number] | undefined;\n}\n\nexport interface CircleStyle<P = Properties> extends FeatureLayerStyle<P> {\n color: Styled<string, P>;\n /** CSS pixels (default 5) */\n radius: Styled<Size, P>;\n strokeColor: Styled<string, P>;\n /** CSS pixels (default 0) */\n strokeWidth: Styled<Size, P>;\n /** `'viewport'` (default): discs facing the screen; `'map'`: lying on the ground (MapLibre's\n * `circle-pitch-alignment`) */\n alignment: 'viewport' | 'map';\n}\n\nexport interface FillStyle<P = Properties> extends FeatureLayerStyle<P> {\n color: Styled<string, P>;\n}\n\n/** Where a new layer goes: under `before`, or on top of the others */\nexport interface Placement {\n before?: Layer;\n}\n\nexport interface LineOptions<P = Properties> extends Partial<LineStyle<P>>, Placement {\n /** LineString and MultiLineString features; the rings of Polygon and MultiPolygon features are drawn as lines */\n data: FeatureData<P>;\n}\nexport interface CircleOptions<P = Properties> extends Partial<CircleStyle<P>>, Placement {\n /** Point and MultiPoint features */\n data: FeatureData<P>;\n}\nexport interface FillOptions<P = Properties> extends Partial<FillStyle<P>>, Placement {\n /** Polygon and MultiPolygon features */\n data: FeatureData<P>;\n}\n\nconst BASE = {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n} satisfies FeatureLayerStyle;\n\n// ── Colors ──\n\n/** A CSS color to RGBA 0-1 (see `parseCssColor`); black if unknown or missing */\nexport const parseColor = (color: string): [r: number, g: number, b: number, a: number] => {\n return parseCssColor(color) ?? [0, 0, 0, 1];\n};\n\n/** 256 RGBA texels of a ramp over its value range, and that range */\nexport const rampTexels = (ramp: Ramp): { rgba: Uint8Array; min: number; max: number } => {\n const stops = ramp.map(([v, c]) => [v, parseColor(c)] as const).sort((a, b) => a[0] - b[0]);\n const min = stops[0]?.[0] ?? 0;\n const max = stops.at(-1)?.[0] ?? 1;\n const rgba = new Uint8Array(256 * 4);\n\n for (let i = 0; i < 256; i += 1) {\n const v = min + ((max - min) * i) / 255;\n let k = 0;\n\n while (k + 1 < stops.length && (stops[k + 1]?.[0] ?? 0) < v) k += 1;\n\n const [v0, c0] = stops[k] ?? [min, [0, 0, 0, 1]];\n const [v1, c1] = stops[k + 1] ?? [v0, c0];\n const t = v1 > v0 ? Math.max(0, Math.min(1, (v - v0) / (v1 - v0))) : 0;\n\n for (let j = 0; j < 4; j += 1)\n rgba[i * 4 + j] = Math.round(((c0[j] ?? 0) + ((c1[j] ?? 0) - (c0[j] ?? 0)) * t) * 255);\n }\n\n return { rgba, min, max };\n};\n\n/** Up to four stops as zooms then values, constant if a number */\nexport const stops = (size: Size): [number, number, number, number, number, number, number, number] => {\n if (!Array.isArray(size)) {\n // A style function may return nothing for a feature without the property: 0\n const v = Number.isFinite(size) ? size : 0;\n\n return [0, 0, 0, 0, v, v, v, v];\n }\n\n // More than four: resampled at four zooms over their range\n const resampled = (): [number, number][] => {\n const z0 = size[0]?.[0] ?? 0;\n const z1 = size.at(-1)?.[0] ?? 0;\n\n return [0, 1, 2, 3].map((k): [number, number] => {\n const z = z0 + ((z1 - z0) * k) / 3;\n\n return [z, interpolate(size, z)];\n });\n };\n const s = size.length > 4 ? resampled() : size;\n const at = (k: number) => s[Math.min(k, s.length - 1)] ?? [0, 0];\n\n return [at(0)[0], at(1)[0], at(2)[0], at(3)[0], at(0)[1], at(1)[1], at(2)[1], at(3)[1]];\n};\n\n/** Value of zoom stops at a zoom */\nexport const interpolate = (size: Size, zoom: number): number => {\n if (typeof size === 'number') return size;\n\n const first = size[0];\n\n if (!first) return 0;\n if (zoom <= first[0]) return first[1];\n\n const k = size.findIndex(([z], i) => i > 0 && zoom <= z);\n\n if (k < 0) return size.at(-1)?.[1] ?? 0;\n\n const [z0, v0] = size[k - 1] ?? first;\n const [z1, v1] = size[k] ?? first;\n\n return v0 + ((v1 - v0) * (zoom - z0)) / Math.max(z1 - z0, 1e-9);\n};\n\nexport const evaluate = <T, P>(value: Styled<T, P>, properties: P, index: number): T => {\n return typeof value === 'function' ? (value as (p: P, i: number) => T)(properties, index) : value;\n};\n\n// ── Geometry ──\n\n/** Collections in another CRS, reprojected once (the layers read their data again) */\nconst reprojected = new WeakMap<object, Feature<unknown>[]>();\n\nexport const featuresOf = <P>(data: FeatureData<P>): Feature<P>[] => {\n if (Array.isArray(data)) return data;\n if (data.type !== 'FeatureCollection') return [data];\n if (crsOf(data) === undefined) return data.features;\n\n const cached = reprojected.get(data) as Feature<P>[] | undefined;\n\n if (cached) return cached;\n\n const features = reproject(data).features;\n\n reprojected.set(data, features);\n\n return features;\n};\n\n/** Every geometry of a feature, collections flattened */\nfunction* geometries(geometry: Geometry | null): Generator<Geometry> {\n if (!geometry) return;\n if (geometry.type === 'GeometryCollection') for (const g of geometry.geometries) yield* geometries(g);\n else yield geometry;\n}\n\n/** A growable typed array */\nclass Grow<T extends Float64Array | Uint32Array> {\n length = 0;\n constructor(public data: T) {}\n push(...values: number[]): void {\n if (this.length + values.length > this.data.length) {\n const next = new (this.data.constructor as new (n: number) => T)(\n Math.max(16, this.data.length * 2, this.length + values.length),\n );\n\n next.set(this.data);\n this.data = next;\n }\n for (const v of values) this.data[this.length++] = v;\n }\n done(): T {\n return this.data.subarray(0, this.length) as T;\n }\n}\n\n/** Lines of the features: points (Mercator), first point of each line, feature of each line */\nconst lineGeometry = (features: Feature<unknown>[]) => {\n const points = new Grow(new Float64Array(1024));\n const start = new Grow(new Uint32Array(64));\n const feature = new Grow(new Uint32Array(64));\n const line = (coords: Position[], f: number) => {\n start.push(points.length / 2);\n feature.push(f);\n for (const [lon, lat] of coords) points.push(mercatorX(lon), mercatorY(lat));\n };\n\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'LineString') line(g.coordinates, i);\n else if (g.type === 'MultiLineString') for (const l of g.coordinates) line(l, i);\n else if (g.type === 'Polygon') for (const r of g.coordinates) line(r, i);\n else if (g.type === 'MultiPolygon') for (const p of g.coordinates) for (const r of p) line(r, i);\n }\n });\n start.push(points.length / 2);\n\n return { points: points.done(), start: start.done(), feature: feature.done() };\n};\n\nconst pointGeometry = (features: Feature<unknown>[]) => {\n const points = new Grow(new Float64Array(1024));\n const feature = new Grow(new Uint32Array(64));\n const point = ([lon, lat]: Position, f: number) => {\n points.push(mercatorX(lon), mercatorY(lat));\n feature.push(f);\n };\n\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'Point') point(g.coordinates, i);\n else if (g.type === 'MultiPoint') for (const p of g.coordinates) point(p, i);\n }\n });\n\n return { points: points.done(), feature: feature.done() };\n};\n\nexport const polygonGeometry = (features: Feature<unknown>[]) => {\n const points = new Grow(new Float64Array(1024));\n const ringStart = new Grow(new Uint32Array(64));\n const polygonStart = new Grow(new Uint32Array(64));\n const feature = new Grow(new Uint32Array(64));\n const polygon = (rings: Position[][], f: number) => {\n polygonStart.push(ringStart.length);\n feature.push(f);\n for (const ring of rings) {\n ringStart.push(points.length / 2);\n for (const [lon, lat] of ring) points.push(mercatorX(lon), mercatorY(lat));\n }\n };\n\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'Polygon') polygon(g.coordinates, i);\n else if (g.type === 'MultiPolygon') for (const p of g.coordinates) polygon(p, i);\n }\n });\n ringStart.push(points.length / 2);\n polygonStart.push(ringStart.length - 1);\n\n return {\n points: points.done(),\n ringStart: ringStart.done(),\n polygonStart: polygonStart.done(),\n feature: feature.done(),\n };\n};\n\n// ── Layers ──\n\n/** What every feature layer shares: its data, its style in the engine, values, filter */\nexport abstract class FeatureLayer<P, S extends FeatureLayerStyle<P>> extends Layer {\n protected list: Feature<P>[];\n protected values: Float32Array | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P>,\n protected style: S,\n ) {\n super(map);\n this.list = featuresOf(data);\n }\n\n /** The features, in the order of the data (their index is what `pick` returns) */\n get features(): readonly Feature<P>[] {\n return this.list;\n }\n\n /** The feature of a picked index */\n featureAt(index: number): Feature<P> | undefined {\n return this.list[index];\n }\n\n /** Replaces the features; the style is evaluated again for them */\n setData(data: FeatureData<P>): void {\n const before = this.list.length;\n\n this.list = featuresOf(data);\n if (this.list.length !== before) this.values = undefined;\n // A new feature count needs new textures: the layer is created again at its place\n if (this.list.length !== before) this.recreate();\n else {\n this.upload(this.map.engine, this.id);\n this.applyStyle(this.map.engine, this.id);\n }\n this.map.requestRender();\n }\n\n setStyle(style: Partial<S>): void {\n this.style = { ...this.style, ...style };\n this.applyStyle(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** One value per feature (in data order), colored through the style's `ramp`; NaN keeps a feature's color */\n setValues(values: Float32Array | undefined): void {\n this.values = values;\n this.map.engine.setFeatureValues(this.id, values ?? new Float32Array(this.list.length).fill(Number.NaN));\n this.map.requestRender();\n }\n\n /** Shows only the features the predicate keeps; undefined shows them all */\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.map.engine.setFeatureMask(this.id, this.mask());\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible } as Partial<S>);\n }\n\n private mask(): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(this.list.length).fill(255);\n\n if (filter)\n this.list.forEach((f, i) => {\n if (!filter(f.properties, i)) mask[i] = 0;\n });\n\n return mask;\n }\n\n /** Recreated in the engine at the same place (a new feature count) */\n private recreate(): void {\n const engine = this.map.engine;\n const old = this.id;\n\n this.attach(engine);\n this.map.replaceLayer(this, old);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = this.add(engine);\n\n this.applyStyle(engine, id);\n if (this.values) engine.setFeatureValues(id, this.values);\n\n return id;\n }\n\n /** @internal Adds the geometry to the engine, returns the layer id */\n protected abstract add(engine: Engine): number;\n /** @internal Sends the geometry again (same feature count) */\n protected abstract upload(engine: Engine, id: number): void;\n /** Two colors and two sizes of a feature */\n protected abstract featureStyle(\n properties: P,\n index: number,\n ): [color: string, second: string, size: Size, second: Size];\n /** @internal Layer-specific settings (dashes, alignment) */\n protected abstract applyExtra(engine: Engine, id: number): void;\n\n /** @internal */\n protected applyStyle(engine: Engine, id: number): void {\n const out = new Float32Array(this.list.length * FLOATS);\n\n this.list.forEach((f, i) => {\n const [color, second, size, size2] = this.featureStyle(f.properties, i);\n const o = i * FLOATS;\n\n out.set(parseColor(color), o + STYLE.color);\n out.set(parseColor(second), o + STYLE.second);\n out.set(stops(size), o + STYLE.size);\n out.set(stops(size2), o + STYLE.size2);\n });\n engine.setFeatureStyle(id, out);\n engine.setFeatureMask(id, this.mask());\n\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n this.applyExtra(engine, id);\n }\n}\n\nexport class LineLayer<P = Properties> extends FeatureLayer<P, LineStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = lineGeometry(this.list);\n\n return engine.addLines(g.points, g.start, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = lineGeometry(this.list);\n\n engine.setLines(id, g.points, g.start, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n const { color, width } = this.style;\n\n return [evaluate(color, properties, index), '#000', evaluate(width, properties, index), 0];\n }\n\n /** @internal */\n protected applyExtra(engine: Engine, id: number): void {\n const [dash, gap] = this.style.dash ?? [0, 0];\n\n engine.setLineDash(id, dash, gap);\n }\n}\n\nexport class CircleLayer<P = Properties> extends FeatureLayer<P, CircleStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = pointGeometry(this.list);\n\n return engine.addCircles(g.points, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = pointGeometry(this.list);\n\n engine.setCircles(id, g.points, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n const { color, strokeColor, radius, strokeWidth } = this.style;\n\n return [\n evaluate(color, properties, index),\n evaluate(strokeColor, properties, index),\n evaluate(radius, properties, index),\n evaluate(strokeWidth, properties, index),\n ];\n }\n\n /** @internal */\n protected applyExtra(engine: Engine, id: number): void {\n engine.setCircleAlignment(id, this.style.alignment === 'map');\n }\n}\n\nexport class FillLayer<P = Properties> extends FeatureLayer<P, FillStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = polygonGeometry(this.list);\n\n return engine.addFills(g.points, g.ringStart, g.polygonStart, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = polygonGeometry(this.list);\n\n engine.setFills(id, g.points, g.ringStart, g.polygonStart, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n return [evaluate(this.style.color, properties, index), '#000', 0, 0];\n }\n\n protected applyExtra(): void {}\n}\n\nexport const lineStyle = <P>(options: LineOptions<P>): LineStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return { ...BASE, color: '#000', width: 1, dash: undefined, ...rest };\n};\n\nexport const circleStyle = <P>(options: CircleOptions<P>): CircleStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return {\n ...BASE,\n color: '#000',\n radius: 5,\n strokeColor: '#fff',\n strokeWidth: 0,\n alignment: 'viewport',\n ...rest,\n };\n};\n\nexport const fillStyle = <P>(options: FillOptions<P>): FillStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return { ...BASE, color: '#000', ...rest };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/layers/features.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAa,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAoCpC,yGAAyG;AACzG,8CAA8C;AAC9C,OAAO,EAAE,UAAU,EAAa,UAAU,EAAE,CAAC;AAuD7C,MAAM,IAAI,GAAG;IACX,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV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MAAM,WAAW,GAAG,CAAI,OAAyB,EAAkB,EAAE;IAC1E,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjD,OAAO;QACL,GAAG,IAAI;QACP,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,CAAC;QACT,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,UAAU;QACrB,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,OAAuB,EAAgB,EAAE;IACpE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjD,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;AAC7C,CAAC,CAAC","sourcesContent":["/**\n * Feature layers: lines, circles and fills from GeoJSON, styled per feature. A style value is a constant, zoom stops\n * (`[[zoom, value], …]`, linear in between, as MapLibre's `interpolate linear zoom`), or a function of the feature\n * returning either, evaluated once per feature when the data or the style change: the engine keeps the result in\n * textures, and restyling, recoloring by values or filtering never touches the geometry.\n */\n\nimport { crsOf, reproject } from '../data/crs.ts';\nimport type { LayerHost, Placement } from '../types.ts';\nimport { parseColor, type Ramp, rampTexels } from '../util/color.ts';\nimport { mercatorX, mercatorY } from '../util/geo.ts';\nimport { FLOATS, STYLE } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard.js';\nimport { Layer } from './layers.ts';\n\n// ── GeoJSON (the parts used here) ──\n\nexport type Position = [lon: number, lat: number, ...rest: number[]];\nexport type Geometry =\n | { type: 'Point'; coordinates: Position }\n | { type: 'MultiPoint'; coordinates: Position[] }\n | { type: 'LineString'; coordinates: Position[] }\n | { type: 'MultiLineString'; coordinates: Position[][] }\n | { type: 'Polygon'; coordinates: Position[][] }\n | { type: 'MultiPolygon'; coordinates: Position[][][] }\n | { type: 'GeometryCollection'; geometries: Geometry[] };\nexport type Properties = Record<string, unknown>;\nexport interface Feature<P = Properties> {\n type: 'Feature';\n geometry: Geometry | null;\n properties: P;\n id?: string | number;\n}\nexport interface FeatureCollection<P = Properties> {\n type: 'FeatureCollection';\n features: Feature<P>[];\n /** The CRS of the coordinates, a legacy member (GeoJSON of 2008, the output of a WFS in another CRS): the feature\n * layers reproject a collection that names one (see `reproject`) */\n crs?: { type: 'name'; properties: { name: string } };\n}\n/** What a feature layer takes: a collection, its features, or one feature */\nexport type FeatureData<P = Properties> = FeatureCollection<P> | Feature<P>[] | Feature<P>;\n\n// ── Style values ──\n\n/** Zoom stops: `[[zoom, value], …]` in increasing zooms, up to four, linear in between, constant outside */\nexport type Stops = [zoom: number, value: number][];\n/** A size: CSS pixels, or zoom stops */\nexport type Size = number | Stops;\n/** A value for all features, or a function of each feature (its properties and its index in the data) */\n// Where they were, for the layers and the API\nexport { parseColor, type Ramp, rampTexels };\n\nexport type Styled<T, P = Properties> = T | ((properties: P, index: number) => T);\n\nexport interface FeatureLayerStyle<P = Properties> {\n /** Layer opacity, 0 to 1, or zoom stops (a layer fading in past a zoom) (default 1) */\n opacity: Size;\n /** Zooms the layer shows in: from `minZoom` (included) to `maxZoom` (excluded) */\n minZoom: number;\n maxZoom: number;\n visible: boolean;\n /** Features drawn; the others hidden (default all) */\n filter: ((properties: P, index: number) => boolean) | undefined;\n /** Colors of the values given by `setValues`: a feature with a value takes its color here, the others keep theirs */\n ramp: Ramp | undefined;\n}\n\nexport interface LineStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color: `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()`, `rgba()` (default `#000`) */\n color: Styled<string, P>;\n /** CSS pixels (default 1) */\n width: Styled<Size, P>;\n /** Dash and gap, in line widths (MapLibre's `line-dasharray`); undefined: solid */\n dash: [dash: number, gap: number] | undefined;\n}\n\nexport interface CircleStyle<P = Properties> extends FeatureLayerStyle<P> {\n color: Styled<string, P>;\n /** CSS pixels (default 5) */\n radius: Styled<Size, P>;\n strokeColor: Styled<string, P>;\n /** CSS pixels (default 0) */\n strokeWidth: Styled<Size, P>;\n /** `'viewport'` (default): discs facing the screen; `'map'`: lying on the ground (MapLibre's\n * `circle-pitch-alignment`) */\n alignment: 'viewport' | 'map';\n}\n\nexport interface FillStyle<P = Properties> extends FeatureLayerStyle<P> {\n color: Styled<string, P>;\n}\n\nexport interface LineOptions<P = Properties> extends Partial<LineStyle<P>>, Placement {\n /** LineString and MultiLineString features; the rings of Polygon and MultiPolygon features are drawn as lines */\n data: FeatureData<P>;\n}\nexport interface CircleOptions<P = Properties> extends Partial<CircleStyle<P>>, Placement {\n /** Point and MultiPoint features */\n data: FeatureData<P>;\n}\nexport interface FillOptions<P = Properties> extends Partial<FillStyle<P>>, Placement {\n /** Polygon and MultiPolygon features */\n data: FeatureData<P>;\n}\n\nconst BASE = {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n} satisfies FeatureLayerStyle;\n\n/** Up to four stops as zooms then values, constant if a number */\nexport const stops = (size: Size): [number, number, number, number, number, number, number, number] => {\n if (!Array.isArray(size)) {\n // A style function may return nothing for a feature without the property: 0\n const v = Number.isFinite(size) ? size : 0;\n\n return [0, 0, 0, 0, v, v, v, v];\n }\n\n // More than four: resampled at four zooms over their range\n const resampled = (): [number, number][] => {\n const z0 = size[0]?.[0] ?? 0;\n const z1 = size.at(-1)?.[0] ?? 0;\n\n return [0, 1, 2, 3].map((k): [number, number] => {\n const z = z0 + ((z1 - z0) * k) / 3;\n\n return [z, interpolate(size, z)];\n });\n };\n const s = size.length > 4 ? resampled() : size;\n const at = (k: number) => s[Math.min(k, s.length - 1)] ?? [0, 0];\n\n return [at(0)[0], at(1)[0], at(2)[0], at(3)[0], at(0)[1], at(1)[1], at(2)[1], at(3)[1]];\n};\n\n/** Value of zoom stops at a zoom */\nexport const interpolate = (size: Size, zoom: number): number => {\n if (typeof size === 'number') return size;\n\n const first = size[0];\n\n if (!first) return 0;\n if (zoom <= first[0]) return first[1];\n\n const k = size.findIndex(([z], i) => i > 0 && zoom <= z);\n\n if (k < 0) return size.at(-1)?.[1] ?? 0;\n\n const [z0, v0] = size[k - 1] ?? first;\n const [z1, v1] = size[k] ?? first;\n\n return v0 + ((v1 - v0) * (zoom - z0)) / Math.max(z1 - z0, 1e-9);\n};\n\nexport const evaluate = <T, P>(value: Styled<T, P>, properties: P, index: number): T => {\n return typeof value === 'function' ? (value as (p: P, i: number) => T)(properties, index) : value;\n};\n\n// ── Geometry ──\n\n/** Collections in another CRS, reprojected once (the layers read their data again) */\nconst reprojected = new WeakMap<object, Feature<unknown>[]>();\n\nexport const featuresOf = <P>(data: FeatureData<P>): Feature<P>[] => {\n if (Array.isArray(data)) return data;\n if (data.type !== 'FeatureCollection') return [data];\n if (crsOf(data) === undefined) return data.features;\n\n const cached = reprojected.get(data) as Feature<P>[] | undefined;\n\n if (cached) return cached;\n\n const features = reproject(data).features;\n\n reprojected.set(data, features);\n\n return features;\n};\n\n/** Every geometry of a feature, collections flattened */\nfunction* geometries(geometry: Geometry | null): Generator<Geometry> {\n if (!geometry) return;\n if (geometry.type === 'GeometryCollection') for (const g of geometry.geometries) yield* geometries(g);\n else yield geometry;\n}\n\n/** A growable typed array */\nclass Grow<T extends Float64Array | Uint32Array> {\n length = 0;\n constructor(public data: T) {}\n push(...values: number[]): void {\n if (this.length + values.length > this.data.length) {\n const next = new (this.data.constructor as new (n: number) => T)(\n Math.max(16, this.data.length * 2, this.length + values.length),\n );\n\n next.set(this.data);\n this.data = next;\n }\n for (const v of values) this.data[this.length++] = v;\n }\n done(): T {\n return this.data.subarray(0, this.length) as T;\n }\n}\n\n/** Lines of the features: points (Mercator), first point of each line, feature of each line */\nconst lineGeometry = (features: Feature<unknown>[]) => {\n const points = new Grow(new Float64Array(1024));\n const start = new Grow(new Uint32Array(64));\n const feature = new Grow(new Uint32Array(64));\n const line = (coords: Position[], f: number) => {\n start.push(points.length / 2);\n feature.push(f);\n for (const [lon, lat] of coords) points.push(mercatorX(lon), mercatorY(lat));\n };\n\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'LineString') line(g.coordinates, i);\n else if (g.type === 'MultiLineString') for (const l of g.coordinates) line(l, i);\n else if (g.type === 'Polygon') for (const r of g.coordinates) line(r, i);\n else if (g.type === 'MultiPolygon') for (const p of g.coordinates) for (const r of p) line(r, i);\n }\n });\n start.push(points.length / 2);\n\n return { points: points.done(), start: start.done(), feature: feature.done() };\n};\n\nconst pointGeometry = (features: Feature<unknown>[]) => {\n const points = new Grow(new Float64Array(1024));\n const feature = new Grow(new Uint32Array(64));\n const point = ([lon, lat]: Position, f: number) => {\n points.push(mercatorX(lon), mercatorY(lat));\n feature.push(f);\n };\n\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'Point') point(g.coordinates, i);\n else if (g.type === 'MultiPoint') for (const p of g.coordinates) point(p, i);\n }\n });\n\n return { points: points.done(), feature: feature.done() };\n};\n\nexport const polygonGeometry = (features: Feature<unknown>[]) => {\n const points = new Grow(new Float64Array(1024));\n const ringStart = new Grow(new Uint32Array(64));\n const polygonStart = new Grow(new Uint32Array(64));\n const feature = new Grow(new Uint32Array(64));\n const polygon = (rings: Position[][], f: number) => {\n polygonStart.push(ringStart.length);\n feature.push(f);\n for (const ring of rings) {\n ringStart.push(points.length / 2);\n for (const [lon, lat] of ring) points.push(mercatorX(lon), mercatorY(lat));\n }\n };\n\n features.forEach((f, i) => {\n for (const g of geometries(f.geometry)) {\n if (g.type === 'Polygon') polygon(g.coordinates, i);\n else if (g.type === 'MultiPolygon') for (const p of g.coordinates) polygon(p, i);\n }\n });\n ringStart.push(points.length / 2);\n polygonStart.push(ringStart.length - 1);\n\n return {\n points: points.done(),\n ringStart: ringStart.done(),\n polygonStart: polygonStart.done(),\n feature: feature.done(),\n };\n};\n\n// ── Layers ──\n\n/** What every feature layer shares: its data, its style in the engine, values, filter */\nexport abstract class FeatureLayer<P, S extends FeatureLayerStyle<P>> extends Layer {\n protected list: Feature<P>[];\n protected values: Float32Array | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P>,\n protected style: S,\n ) {\n super(map);\n this.list = featuresOf(data);\n }\n\n /** The features, in the order of the data (their index is what `pick` returns) */\n get features(): readonly Feature<P>[] {\n return this.list;\n }\n\n /** The feature of a picked index */\n featureAt(index: number): Feature<P> | undefined {\n return this.list[index];\n }\n\n /** Replaces the features; the style is evaluated again for them */\n setData(data: FeatureData<P>): void {\n const before = this.list.length;\n\n this.list = featuresOf(data);\n if (this.list.length !== before) this.values = undefined;\n // A new feature count needs new textures: the layer is created again at its place\n if (this.list.length !== before) this.recreate();\n else {\n this.upload(this.map.engine, this.id);\n this.applyStyle(this.map.engine, this.id);\n }\n this.map.requestRender();\n }\n\n setStyle(style: Partial<S>): void {\n this.style = { ...this.style, ...style };\n this.applyStyle(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** One value per feature (in data order), colored through the style's `ramp`; NaN keeps a feature's color */\n setValues(values: Float32Array | undefined): void {\n this.values = values;\n this.map.engine.setFeatureValues(this.id, values ?? new Float32Array(this.list.length).fill(Number.NaN));\n this.map.requestRender();\n }\n\n /** Shows only the features the predicate keeps; undefined shows them all */\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.map.engine.setFeatureMask(this.id, this.mask());\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible } as Partial<S>);\n }\n\n private mask(): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(this.list.length).fill(255);\n\n if (filter)\n this.list.forEach((f, i) => {\n if (!filter(f.properties, i)) mask[i] = 0;\n });\n\n return mask;\n }\n\n /** Recreated in the engine at the same place (a new feature count) */\n private recreate(): void {\n const engine = this.map.engine;\n const old = this.id;\n\n this.attach(engine);\n this.map.replaceLayer(this, old);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = this.add(engine);\n\n this.applyStyle(engine, id);\n if (this.values) engine.setFeatureValues(id, this.values);\n\n return id;\n }\n\n /** @internal Adds the geometry to the engine, returns the layer id */\n protected abstract add(engine: Engine): number;\n /** @internal Sends the geometry again (same feature count) */\n protected abstract upload(engine: Engine, id: number): void;\n /** Two colors and two sizes of a feature */\n protected abstract featureStyle(\n properties: P,\n index: number,\n ): [color: string, second: string, size: Size, second: Size];\n /** @internal Layer-specific settings (dashes, alignment) */\n protected abstract applyExtra(engine: Engine, id: number): void;\n\n /** @internal */\n protected applyStyle(engine: Engine, id: number): void {\n const out = new Float32Array(this.list.length * FLOATS);\n\n this.list.forEach((f, i) => {\n const [color, second, size, size2] = this.featureStyle(f.properties, i);\n const o = i * FLOATS;\n\n out.set(parseColor(color), o + STYLE.color);\n out.set(parseColor(second), o + STYLE.second);\n out.set(stops(size), o + STYLE.size);\n out.set(stops(size2), o + STYLE.size2);\n });\n engine.setFeatureStyle(id, out);\n engine.setFeatureMask(id, this.mask());\n\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n this.applyExtra(engine, id);\n }\n}\n\nexport class LineLayer<P = Properties> extends FeatureLayer<P, LineStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = lineGeometry(this.list);\n\n return engine.addLines(g.points, g.start, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = lineGeometry(this.list);\n\n engine.setLines(id, g.points, g.start, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n const { color, width } = this.style;\n\n return [evaluate(color, properties, index), '#000', evaluate(width, properties, index), 0];\n }\n\n /** @internal */\n protected applyExtra(engine: Engine, id: number): void {\n const [dash, gap] = this.style.dash ?? [0, 0];\n\n engine.setLineDash(id, dash, gap);\n }\n}\n\nexport class CircleLayer<P = Properties> extends FeatureLayer<P, CircleStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = pointGeometry(this.list);\n\n return engine.addCircles(g.points, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = pointGeometry(this.list);\n\n engine.setCircles(id, g.points, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n const { color, strokeColor, radius, strokeWidth } = this.style;\n\n return [\n evaluate(color, properties, index),\n evaluate(strokeColor, properties, index),\n evaluate(radius, properties, index),\n evaluate(strokeWidth, properties, index),\n ];\n }\n\n /** @internal */\n protected applyExtra(engine: Engine, id: number): void {\n engine.setCircleAlignment(id, this.style.alignment === 'map');\n }\n}\n\nexport class FillLayer<P = Properties> extends FeatureLayer<P, FillStyle<P>> {\n /** @internal */\n protected add(engine: Engine): number {\n const g = polygonGeometry(this.list);\n\n return engine.addFills(g.points, g.ringStart, g.polygonStart, g.feature, this.list.length);\n }\n\n /** @internal */\n protected upload(engine: Engine, id: number): void {\n const g = polygonGeometry(this.list);\n\n engine.setFills(id, g.points, g.ringStart, g.polygonStart, g.feature);\n }\n\n protected featureStyle(properties: P, index: number): [string, string, Size, Size] {\n return [evaluate(this.style.color, properties, index), '#000', 0, 0];\n }\n\n protected applyExtra(): void {}\n}\n\nexport const lineStyle = <P>(options: LineOptions<P>): LineStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return { ...BASE, color: '#000', width: 1, dash: undefined, ...rest };\n};\n\nexport const circleStyle = <P>(options: CircleOptions<P>): CircleStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return {\n ...BASE,\n color: '#000',\n radius: 5,\n strokeColor: '#fff',\n strokeWidth: 0,\n alignment: 'viewport',\n ...rest,\n };\n};\n\nexport const fillStyle = <P>(options: FillOptions<P>): FillStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return { ...BASE, color: '#000', ...rest };\n};\n"]}
|
package/dist/layers/flow.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* and latitudes, m/s), their trails drawn on the globe and the relief and animated, colored by speed: wind maps,
|
|
4
4
|
* currents. The engine moves them (`stepFlow`), one step per animation frame while the layer plays.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import type { Placement } from '../types.ts';
|
|
7
|
+
import { type Ramp } from '../util/color.ts';
|
|
7
8
|
import { Layer } from './layers.ts';
|
|
8
9
|
/**
|
|
9
10
|
* A field of velocities: `width` × `height` points, from west to east and from north to south (row after row), the
|
|
@@ -37,7 +38,7 @@ export interface TimedField {
|
|
|
37
38
|
time: Date | number;
|
|
38
39
|
field: FlowField;
|
|
39
40
|
}
|
|
40
|
-
export interface FlowOptions extends Partial<FlowStyle
|
|
41
|
+
export interface FlowOptions extends Partial<FlowStyle>, Placement {
|
|
41
42
|
/** The field; or `fields`, at their times, mixed at `time` */
|
|
42
43
|
field?: FlowField;
|
|
43
44
|
/** Fields at their times, on one grid (a model's hours): the layer's field at `time` the mix of the two around it */
|
|
@@ -50,7 +51,6 @@ export interface FlowOptions extends Partial<FlowStyle> {
|
|
|
50
51
|
trail?: number;
|
|
51
52
|
/** Moving from the start (default true); `play`, `pause` and `step` after */
|
|
52
53
|
playing?: boolean;
|
|
53
|
-
before?: Layer;
|
|
54
54
|
}
|
|
55
55
|
export declare class FlowLayer extends Layer {
|
|
56
56
|
#private;
|