@tangram.gl/basemap-layers 0.0.0 → 10.0.0-alpha.3
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/README.md +12 -7
- package/THIRD-PARTY-NOTICES.md +7 -5
- package/dist/geojson-task-worker.js +3166 -0
- package/dist/geojson-task-worker.js.map +6 -0
- package/dist/geojson-worker.js +1089 -7
- package/dist/geojson-worker.js.map +3 -3
- package/dist/index.cjs +9588 -2093
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +9599 -2090
- package/dist/index.js.map +3 -3
- package/dist/map-style.cjs +456 -20
- package/dist/map-style.cjs.map +3 -3
- package/dist/map-style.js +456 -19
- package/dist/map-style.js.map +2 -2
- package/dist/types/basemap-error.d.ts +52 -0
- package/dist/types/basemap-layer.d.ts +378 -25
- package/dist/types/basemap-protocol.d.ts +91 -0
- package/dist/types/basemap-request.d.ts +73 -0
- package/dist/types/circle-layer.d.ts +65 -8
- package/dist/types/color-relief-layer.d.ts +184 -0
- package/dist/types/dem-pixels.d.ts +40 -0
- package/dist/types/feature-state.d.ts +55 -0
- package/dist/types/fill-extrusion-lighting-extension.d.ts +1 -2
- package/dist/types/fill-outline-extension.d.ts +2 -3
- package/dist/types/fill-pattern.d.ts +35 -3
- package/dist/types/fill-style-extensions.d.ts +11 -59
- package/dist/types/geojson-resource.d.ts +18 -0
- package/dist/types/geojson-source.d.ts +13 -2
- package/dist/types/geojson-task-handler.d.ts +2 -0
- package/dist/types/geojson-task.d.ts +26 -0
- package/dist/types/geojson-tiler.d.ts +29 -2
- package/dist/types/geojson-worker.d.ts +5 -1
- package/dist/types/globe-horizon-extension.d.ts +2 -45
- package/dist/types/globe-layers.d.ts +141 -45
- package/dist/types/globe-line-angle-extension.d.ts +20 -17
- package/dist/types/glyph-store.d.ts +10 -1
- package/dist/types/heatmap-layer.d.ts +99 -0
- package/dist/types/hillshade-layer.d.ts +159 -27
- package/dist/types/icon-text-fit.d.ts +92 -0
- package/dist/types/image-source-layer.d.ts +142 -0
- package/dist/types/index.d.ts +25 -1
- package/dist/types/line-blur-extension.d.ts +3 -11
- package/dist/types/line-dash-extension.d.ts +53 -0
- package/dist/types/line-gradient-extension.d.ts +69 -0
- package/dist/types/line-metrics.d.ts +24 -0
- package/dist/types/line-pattern-extension.d.ts +50 -0
- package/dist/types/line-shape-extension.d.ts +76 -0
- package/dist/types/map-style-loader.d.ts +1 -1
- package/dist/types/map-style.d.ts +2 -2
- package/dist/types/mvt-label-layer.d.ts +111 -20
- package/dist/types/pmtiles-source.d.ts +38 -0
- package/dist/types/projected-background-layer.d.ts +63 -0
- package/dist/types/projected-bitmap-layer.d.ts +58 -0
- package/dist/types/projected-tile-data.d.ts +16 -0
- package/dist/types/projected-tile-selection.d.ts +72 -0
- package/dist/types/projected-tileset.d.ts +92 -0
- package/dist/types/projected-viewport.d.ts +76 -0
- package/dist/types/raster-color-extension.d.ts +4 -7
- package/dist/types/raster-fade.d.ts +155 -0
- package/dist/types/raster-tile-fingerprint.d.ts +11 -0
- package/dist/types/raster-tile-loader.d.ts +80 -0
- package/dist/types/shader-injection-plugin.d.ts +8 -0
- package/dist/types/source-features.d.ts +58 -0
- package/dist/types/source-tiles.d.ts +32 -0
- package/dist/types/sprite.d.ts +37 -3
- package/dist/types/stretch-icon-layer.d.ts +28 -0
- package/dist/types/style-accessor.d.ts +50 -12
- package/dist/types/style-expression.d.ts +22 -2
- package/dist/types/style-resolver.d.ts +47 -2
- package/dist/types/terrain-query.d.ts +39 -0
- package/dist/types/zoom-load-gate.d.ts +22 -0
- package/dist/types/zoom-paint-extension.d.ts +80 -11
- package/package.json +24 -21
- package/src/basemap-error.ts +82 -0
- package/src/basemap-layer.ts +1289 -101
- package/src/basemap-protocol.ts +353 -0
- package/src/basemap-request.ts +212 -0
- package/src/circle-layer.ts +430 -54
- package/src/color-relief-layer.ts +572 -0
- package/src/dem-pixels.ts +174 -0
- package/src/feature-state.ts +164 -0
- package/src/fill-extrusion-lighting-extension.ts +126 -9
- package/src/fill-outline-extension.ts +4 -4
- package/src/fill-pattern.ts +87 -9
- package/src/fill-style-extensions.ts +114 -44
- package/src/geojson-resource.ts +58 -0
- package/src/geojson-source.ts +106 -85
- package/src/geojson-task-handler.ts +11 -0
- package/src/geojson-task-worker.ts +8 -0
- package/src/geojson-task.ts +34 -0
- package/src/geojson-tiler.ts +270 -4
- package/src/geojson-worker.ts +36 -6
- package/src/globe-horizon-extension.ts +14 -4
- package/src/globe-layers.ts +1905 -406
- package/src/globe-line-angle-extension.ts +183 -23
- package/src/glyph-store.ts +28 -6
- package/src/heatmap-layer.ts +591 -0
- package/src/hillshade-layer.ts +309 -88
- package/src/icon-text-fit.ts +358 -0
- package/src/image-source-layer.ts +380 -0
- package/src/index.ts +58 -1
- package/src/line-blur-extension.ts +14 -12
- package/src/line-dash-extension.ts +303 -0
- package/src/line-gradient-extension.ts +191 -0
- package/src/line-metrics.ts +90 -0
- package/src/line-pattern-extension.ts +173 -0
- package/src/line-shape-extension.ts +272 -0
- package/src/map-style-loader.ts +5 -4
- package/src/map-style.ts +2 -1
- package/src/mvt-label-layer.ts +568 -144
- package/src/pmtiles-source.ts +276 -0
- package/src/projected-background-layer.ts +202 -0
- package/src/projected-bitmap-layer.ts +262 -0
- package/src/projected-tile-data.ts +132 -0
- package/src/projected-tile-selection.ts +605 -0
- package/src/projected-tileset.ts +183 -0
- package/src/projected-viewport.ts +254 -0
- package/src/raster-color-extension.ts +43 -18
- package/src/raster-fade.ts +319 -0
- package/src/raster-tile-fingerprint.ts +31 -0
- package/src/raster-tile-loader.ts +211 -0
- package/src/shader-injection-plugin.ts +25 -0
- package/src/source-features.ts +170 -0
- package/src/source-tiles.ts +102 -0
- package/src/sprite.ts +122 -15
- package/src/stretch-icon-layer.ts +87 -0
- package/src/style-accessor.ts +105 -17
- package/src/style-expression.ts +80 -3
- package/src/style-resolver.ts +200 -22
- package/src/terrain-query.ts +86 -0
- package/src/text-layout.ts +2 -3
- package/src/zoom-load-gate.ts +57 -0
- package/src/zoom-paint-extension.ts +245 -47
- package/dist/types/arabic-shaping.d.ts +0 -7
- package/dist/types/bidi.d.ts +0 -8
- package/dist/types/polylabel.d.ts +0 -17
- package/src/arabic-shaping.ts +0 -366
- package/src/bidi.ts +0 -199
- package/src/polylabel.ts +0 -312
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** The size of the Web Mercator world, in deck.gl common units. */
|
|
2
|
+
export declare const MERCATOR_WORLD_SIZE = 512;
|
|
3
|
+
/** The latitude of the top edge of the Web Mercator tile pyramid. */
|
|
4
|
+
export declare const MAX_MERCATOR_LATITUDE = 85.051129;
|
|
5
|
+
/**
|
|
6
|
+
* What the projected draw mode reads of a deck.gl viewport. `project` and `unproject` convert
|
|
7
|
+
* between longitude/latitude and top-left pixels, through the view's projection. `project` also
|
|
8
|
+
* returns the depth of a position given with an elevation: 0 to 1 in front of the camera.
|
|
9
|
+
*/
|
|
10
|
+
export type ProjectedViewportLike = {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
zoom: number;
|
|
14
|
+
project: (lngLat: number[]) => number[];
|
|
15
|
+
unproject: (pixel: number[]) => number[];
|
|
16
|
+
/**
|
|
17
|
+
* Converts longitude/latitude to the view's map plane, before the camera. With it, the tile
|
|
18
|
+
* selection finds the tiles that the projection stretches (see `getProjectedTileIndices`).
|
|
19
|
+
*/
|
|
20
|
+
projectPosition?: (lngLat: number[]) => number[];
|
|
21
|
+
/**
|
|
22
|
+
* The projection of the view: deck.gl's descriptor of its coordinate reference system. Views of
|
|
23
|
+
* one projection have the same object, so what the tile selection measures of the projection,
|
|
24
|
+
* and not of the camera, is kept by it.
|
|
25
|
+
*/
|
|
26
|
+
crs?: object;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Whether a viewport draws longitude/latitude positions through a projected coordinate reference
|
|
30
|
+
* system (deck.gl's `_CustomProjectionView`), including across copies of deck.gl.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isProjectedViewport(viewport: unknown): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether tile geometry is drawn from longitude/latitude positions in a viewport, and not from
|
|
35
|
+
* tile-local positions: on a globe and in a projected view. Web Mercator tiles are squares only
|
|
36
|
+
* in a Web Mercator view.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isGeographicViewport(viewport: unknown): boolean;
|
|
39
|
+
/** Converts longitude/latitude to the Web Mercator world, `MERCATOR_WORLD_SIZE` wide, y up. */
|
|
40
|
+
export declare function lngLatToMercatorWorld(lngLat: ArrayLike<number>): [number, number];
|
|
41
|
+
/** Converts a Web Mercator world position, y up, to longitude/latitude. */
|
|
42
|
+
export declare function mercatorWorldToLngLat(world: ArrayLike<number>): [number, number];
|
|
43
|
+
/**
|
|
44
|
+
* The zoom at which a Web Mercator map has the scale of a projected view at its center: the zoom
|
|
45
|
+
* styles are evaluated at and tiles are selected for. A projected view's own zoom counts pixels
|
|
46
|
+
* per unit of its coordinate reference system, and a Web Mercator zoom pixels per unit of a
|
|
47
|
+
* projection that stretches with the latitude: the two differ by about log2(cos(latitude)).
|
|
48
|
+
* Measured from two screen steps at the view center, so it holds for any projection. Returns the
|
|
49
|
+
* view's own zoom where the center has no longitude/latitude.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getMercatorZoom(viewport: ProjectedViewportLike): number;
|
|
52
|
+
/**
|
|
53
|
+
* The zoom styles are evaluated at in a viewport: its own zoom, or in a projected view the zoom of
|
|
54
|
+
* the Web Mercator map of the same scale (see `getMercatorZoom`).
|
|
55
|
+
*/
|
|
56
|
+
export declare function getStyleZoom(viewport: unknown): number;
|
|
57
|
+
/**
|
|
58
|
+
* The direction a projected view draws a Web Mercator direction in, in its map plane, at
|
|
59
|
+
* `lngLat`: `degrees` counter-clockwise from east in Web Mercator space, to degrees
|
|
60
|
+
* counter-clockwise from the x axis of the view's coordinate reference system. The two differ by
|
|
61
|
+
* the projection's convergence, and in a projection that is not conformal also with the
|
|
62
|
+
* direction. Returns `degrees` where the view does not project the position.
|
|
63
|
+
*/
|
|
64
|
+
export declare function getProjectedPlaneAngle(viewport: {
|
|
65
|
+
projectPosition: (position: number[]) => number[];
|
|
66
|
+
}, lngLat: ArrayLike<number>, degrees: number): number;
|
|
67
|
+
/**
|
|
68
|
+
* Whether a projected view draws a longitude/latitude at its own place: the position, projected
|
|
69
|
+
* to the map plane and back, is the same position. A projection moves a position outside its area
|
|
70
|
+
* of use to the edge of that area, or has no position for it. A label there is not drawn: it
|
|
71
|
+
* shows on the edge, far from its place. The check does not depend on the camera.
|
|
72
|
+
*/
|
|
73
|
+
export declare function isPositionDrawn(viewport: {
|
|
74
|
+
projectPosition: (position: number[]) => number[];
|
|
75
|
+
unprojectPosition: (position: number[]) => number[];
|
|
76
|
+
}, lngLat: ArrayLike<number>): boolean;
|
|
@@ -105,12 +105,11 @@ type RasterColorExtensionProps = {
|
|
|
105
105
|
/**
|
|
106
106
|
* Applies a raster style layer's `raster-brightness-min`, `raster-brightness-max`,
|
|
107
107
|
* `raster-saturation`, `raster-contrast` and `raster-hue-rotate` to a `BitmapLayer`, with the
|
|
108
|
-
* formulas of MapLibre GL JS's raster shader
|
|
108
|
+
* formulas of MapLibre GL JS's raster shader, on WebGL and WebGPU.
|
|
109
109
|
*
|
|
110
110
|
* The adjusted colors are premultiplied, so the layer must blend with
|
|
111
|
-
* `RASTER_COLOR_BLEND_PARAMETERS
|
|
112
|
-
*
|
|
113
|
-
* device check as the shader; on WebGPU they are `null` and the sublayers keep their blending.
|
|
111
|
+
* `RASTER_COLOR_BLEND_PARAMETERS`. Added to a composite layer, the extension passes them to its
|
|
112
|
+
* sublayers as `rasterColorBlendParameters`. On WebGPU they are deck.gl's default blending.
|
|
114
113
|
*/
|
|
115
114
|
export declare class RasterColorExtension extends LayerExtension {
|
|
116
115
|
static extensionName: string;
|
|
@@ -122,12 +121,10 @@ export declare class RasterColorExtension extends LayerExtension {
|
|
|
122
121
|
};
|
|
123
122
|
};
|
|
124
123
|
getShaders(this: Layer<RasterColorExtensionProps>): {
|
|
125
|
-
modules?: undefined;
|
|
126
|
-
inject?: undefined;
|
|
127
|
-
} | {
|
|
128
124
|
modules: {
|
|
129
125
|
readonly name: "rasterColor";
|
|
130
126
|
readonly fs: "layout(std140) uniform rasterColorUniforms {\n float brightnessLow;\n float brightnessHigh;\n float saturationFactor;\n float contrastFactor;\n vec3 spinWeights;\n} rasterColor;\n\n// MapLibre GL JS's raster fragment shader, applied to an unpremultiplied color.\nvec3 rasterColor_adjust(vec3 color) {\n vec3 rgb = vec3(\n dot(color, rasterColor.spinWeights.xyz),\n dot(color, rasterColor.spinWeights.zxy),\n dot(color, rasterColor.spinWeights.yzx)\n );\n float average = (color.r + color.g + color.b) / 3.0;\n rgb += (average - rgb) * rasterColor.saturationFactor;\n rgb = (rgb - 0.5) * rasterColor.contrastFactor + 0.5;\n return mix(vec3(rasterColor.brightnessLow), vec3(rasterColor.brightnessHigh), rgb);\n}\n";
|
|
127
|
+
readonly source: "struct RasterColorUniforms {\n brightnessLow: f32,\n brightnessHigh: f32,\n saturationFactor: f32,\n contrastFactor: f32,\n spinWeights: vec3<f32>,\n};\n\n@group(0) @binding(auto) var<uniform> rasterColor: RasterColorUniforms;\n\n// The GLSL function above, in WGSL.\nfn rasterColor_adjust(color: vec3<f32>) -> vec3<f32> {\n var rgb = vec3<f32>(\n dot(color, rasterColor.spinWeights.xyz),\n dot(color, rasterColor.spinWeights.zxy),\n dot(color, rasterColor.spinWeights.yzx)\n );\n let average = (color.r + color.g + color.b) / 3.0;\n rgb += (average - rgb) * rasterColor.saturationFactor;\n rgb = (rgb - 0.5) * rasterColor.contrastFactor + 0.5;\n return mix(vec3<f32>(rasterColor.brightnessLow), vec3<f32>(rasterColor.brightnessHigh), rgb);\n}\n";
|
|
131
128
|
readonly uniformTypes: {
|
|
132
129
|
readonly brightnessLow: "f32";
|
|
133
130
|
readonly brightnessHigh: "f32";
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { LayerExtension } from '@deck.gl/core';
|
|
2
|
+
import type { Layer, LayerProps } from '@deck.gl/core';
|
|
3
|
+
import type { _Tile2DHeader as Tile2DHeader } from '@deck.gl/geo-layers';
|
|
4
|
+
import type { Texture } from '@luma.gl/core';
|
|
5
|
+
import { ProjectedTileLayer } from "./projected-tileset.js";
|
|
6
|
+
/** Returns the current time in milliseconds. `raster-fade-duration` is measured on this clock. */
|
|
7
|
+
export type RasterFadeClock = () => number;
|
|
8
|
+
/** The default clock: `performance.now`. */
|
|
9
|
+
export declare const defaultRasterFadeClock: RasterFadeClock;
|
|
10
|
+
/**
|
|
11
|
+
* The most zoom levels above a tile that its fading ancestor can be, as in MapLibre GL JS
|
|
12
|
+
* (`TileManager._maxFadingAncestorLevels`).
|
|
13
|
+
*/
|
|
14
|
+
export declare const MAX_FADING_ANCESTOR_LEVELS = 5;
|
|
15
|
+
/** How a tile is drawn at one moment of its fade. */
|
|
16
|
+
export type RasterFadeValues = {
|
|
17
|
+
/** The factor of the tile's alpha. */
|
|
18
|
+
opacity: number;
|
|
19
|
+
/** The share of the ancestor's color in the tile's color, 0 to 1. */
|
|
20
|
+
mix: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The fade of a tile `elapsed` milliseconds after it loaded, as MapLibre GL JS computes the fade
|
|
24
|
+
* of an incoming tile in `draw_raster`. A tile with a loaded ancestor cross-fades from the
|
|
25
|
+
* ancestor's image (`getCrossFadeValues`): the share of the ancestor goes from 1 to 0, and the
|
|
26
|
+
* tile stays opaque. A tile without one fades in from transparent (`getSelfFadeValues`). With a
|
|
27
|
+
* `duration` of 0, the tile is drawn at once.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getRasterFadeValues(elapsed: number, duration: number, crossFade: boolean): RasterFadeValues;
|
|
30
|
+
/** The part of an ancestor tile's image that covers a tile. */
|
|
31
|
+
export type RasterFadeParent = {
|
|
32
|
+
/** The texture coordinates of the tile's top-left corner in the ancestor's image. */
|
|
33
|
+
topLeft: [number, number];
|
|
34
|
+
/** The size of the tile in the ancestor's texture coordinates: `2 ** -levels`. */
|
|
35
|
+
scale: number;
|
|
36
|
+
};
|
|
37
|
+
/** The fade of one tile, fixed when the tile is first drawn. */
|
|
38
|
+
export type RasterFade = {
|
|
39
|
+
/** The time the tile was first drawn, on the layer's clock. */
|
|
40
|
+
start: number;
|
|
41
|
+
/** The ancestor that the tile cross-fades from, or `null` when it fades in alone. */
|
|
42
|
+
parent: RasterFadeParent | null;
|
|
43
|
+
};
|
|
44
|
+
/** A tile's position in its pyramid. */
|
|
45
|
+
type TileIndex = {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
z: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The part of the image of `ancestor` that covers `index`, as MapLibre GL JS's `parentTopLeft` and
|
|
52
|
+
* `parentScaleBy`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getRasterFadeParent(index: TileIndex, ancestor: TileIndex): RasterFadeParent;
|
|
55
|
+
/**
|
|
56
|
+
* The nearest ancestor of a tile that has an image to fade from, at most
|
|
57
|
+
* `MAX_FADING_ANCESTOR_LEVELS` zoom levels above it.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getFadingAncestor(tile: Tile2DHeader): Tile2DHeader | null;
|
|
60
|
+
/** The props that `RasterFadeExtension` adds to a `BitmapLayer`. */
|
|
61
|
+
export type RasterFadeExtensionProps = {
|
|
62
|
+
/** `raster-fade-duration`, in milliseconds. */
|
|
63
|
+
rasterFadeDuration?: number;
|
|
64
|
+
/** The clock the fade is measured on. */
|
|
65
|
+
rasterFadeClock?: RasterFadeClock;
|
|
66
|
+
/** The fade of the tile; `null` draws the tile faded in. */
|
|
67
|
+
rasterFade?: RasterFade | null;
|
|
68
|
+
/** The image of the ancestor the tile cross-fades from. */
|
|
69
|
+
rasterFadeParentImage?: unknown;
|
|
70
|
+
};
|
|
71
|
+
/** Whether the extension's shader runs on a layer's device. It is written in GLSL only. */
|
|
72
|
+
export declare function isRasterFadeSupported(layer: Layer): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Fades a raster tile's `BitmapLayer` in over `raster-fade-duration`, as MapLibre GL JS does:
|
|
75
|
+
* from its ancestor's image (`rasterFadeParentImage`, enlarged) where one was loaded, else from
|
|
76
|
+
* transparent. The fade is read from the clock at each draw, and the layer redraws until it
|
|
77
|
+
* ends. WebGL only; on WebGPU tiles are drawn at once.
|
|
78
|
+
*/
|
|
79
|
+
export declare class RasterFadeExtension extends LayerExtension {
|
|
80
|
+
static extensionName: string;
|
|
81
|
+
static defaultProps: {
|
|
82
|
+
rasterFadeDuration: number;
|
|
83
|
+
rasterFadeClock: {
|
|
84
|
+
type: string;
|
|
85
|
+
value: RasterFadeClock;
|
|
86
|
+
};
|
|
87
|
+
rasterFade: {
|
|
88
|
+
type: string;
|
|
89
|
+
value: null;
|
|
90
|
+
};
|
|
91
|
+
rasterFadeParentImage: {
|
|
92
|
+
type: string;
|
|
93
|
+
value: null;
|
|
94
|
+
async: boolean;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
getShaders(this: Layer<RasterFadeExtensionProps>): {
|
|
98
|
+
plugins: import("@luma.gl/shaders").ShaderPlugin[];
|
|
99
|
+
} | {
|
|
100
|
+
plugins?: undefined;
|
|
101
|
+
};
|
|
102
|
+
draw(this: Layer<RasterFadeExtensionProps & {
|
|
103
|
+
image?: unknown;
|
|
104
|
+
}>): void;
|
|
105
|
+
}
|
|
106
|
+
/** The props of a `RasterFadeTileLayer`. */
|
|
107
|
+
export type RasterFadeTileLayerProps = {
|
|
108
|
+
/** `raster-fade-duration`, in milliseconds. 0 draws tiles at once. */
|
|
109
|
+
rasterFadeDuration?: number;
|
|
110
|
+
/** The clock the fade is measured on. Default: `performance.now`. */
|
|
111
|
+
rasterFadeClock?: RasterFadeClock;
|
|
112
|
+
};
|
|
113
|
+
/** The sublayer props of one tile's fade. */
|
|
114
|
+
type TileFadeProps = {
|
|
115
|
+
rasterFade: RasterFade;
|
|
116
|
+
rasterFadeParentImage: unknown;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* A `ProjectedTileLayer` of raster tiles that fade in over `rasterFadeDuration` (see
|
|
120
|
+
* `RasterFadeExtension`, which `renderSubLayers` adds to the tiles' layers). A tile's fade starts
|
|
121
|
+
* when it is first drawn, from the nearest ancestor that was loaded then. When the fade ends, the
|
|
122
|
+
* tile lets go of the ancestor's image. The layer is loaded once its selected tiles have been
|
|
123
|
+
* drawn faded in, as MapLibre GL JS is idle only once its raster tiles have.
|
|
124
|
+
*/
|
|
125
|
+
export declare class RasterFadeTileLayer<DataT = any, ExtraPropsT extends {} = {}> extends ProjectedTileLayer<DataT, ExtraPropsT & RasterFadeTileLayerProps> {
|
|
126
|
+
static layerName: string;
|
|
127
|
+
static defaultProps: {
|
|
128
|
+
rasterFadeDuration: number;
|
|
129
|
+
rasterFadeClock: {
|
|
130
|
+
type: string;
|
|
131
|
+
value: RasterFadeClock;
|
|
132
|
+
};
|
|
133
|
+
TilesetClass: typeof import("./projected-tileset.js").ProjectedTileset2D;
|
|
134
|
+
maxStretch: number;
|
|
135
|
+
tileBounds: null;
|
|
136
|
+
};
|
|
137
|
+
state: ProjectedTileLayer<DataT, ExtraPropsT & RasterFadeTileLayerProps>['state'] & {
|
|
138
|
+
tileFades?: WeakMap<Tile2DHeader, TileFadeProps>;
|
|
139
|
+
releasedParentImage?: Texture;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* The image that a tile's layer takes in place of its ancestor's image when the fade ends. The
|
|
143
|
+
* layer then releases the texture it made from the ancestor's image. It cannot take `null`:
|
|
144
|
+
* deck.gl's `image` prop type makes a texture of each new value, and fails on `null`. deck.gl
|
|
145
|
+
* does not delete a texture that a layer receives, so the tile layer owns this one.
|
|
146
|
+
*/
|
|
147
|
+
private getReleasedParentImage;
|
|
148
|
+
finalizeState(): void;
|
|
149
|
+
/** Whether tiles fade: a positive duration, on a device that runs the fade's shader. */
|
|
150
|
+
private fades;
|
|
151
|
+
getSubLayerPropsByTile(tile: Tile2DHeader): Partial<LayerProps> | null;
|
|
152
|
+
/** Whether the selected tiles are loaded and their fades have been drawn to completion. */
|
|
153
|
+
get isLoaded(): boolean;
|
|
154
|
+
}
|
|
155
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RejectRasterTile } from "./raster-tile-loader.js";
|
|
2
|
+
/** The SHA-256 digest of the bytes of a raster tile, in hexadecimal. */
|
|
3
|
+
export declare function getRasterTileFingerprint(arrayBuffer: ArrayBuffer): Promise<string>;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a `rejectRasterTile` function that matches the tiles whose bytes have one of
|
|
6
|
+
* `fingerprints` (see {@link getRasterTileFingerprint}): the placeholder images of a tile service,
|
|
7
|
+
* which are the same bytes for every tile without data. `fingerprints` can be a promise, for
|
|
8
|
+
* fingerprints that are measured at run time from a tile that is known to have no data. A promise
|
|
9
|
+
* that rejects matches no tile.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createRasterTileFingerprintFilter(fingerprints: Iterable<string> | Promise<Iterable<string>>): RejectRasterTile;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { _TileLoadProps as TileLoadProps } from '@deck.gl/geo-layers';
|
|
2
|
+
import type { BasemapLoadOptions, BasemapSource } from "./style-resolver.js";
|
|
3
|
+
/** The position of a tile in the tile pyramid. */
|
|
4
|
+
export type RasterTileIndex = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
z: number;
|
|
8
|
+
};
|
|
9
|
+
/** A raster tile as the tile service returned it, before it is decoded. */
|
|
10
|
+
export type RasterTileResponse = {
|
|
11
|
+
/** The URL the tile was requested from. */
|
|
12
|
+
url: string;
|
|
13
|
+
/** The id of the style source of the tile. */
|
|
14
|
+
sourceId: string;
|
|
15
|
+
/** The position of the tile in the tile pyramid. */
|
|
16
|
+
index: RasterTileIndex;
|
|
17
|
+
/** The bytes of the response body. */
|
|
18
|
+
arrayBuffer: ArrayBuffer;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Returns `true` for a raster tile that has no map data, such as the placeholder image that some
|
|
22
|
+
* tile services return with status 200 where they have no coverage.
|
|
23
|
+
*/
|
|
24
|
+
export type RejectRasterTile = (tile: RasterTileResponse) => boolean | Promise<boolean>;
|
|
25
|
+
/** A decoded tile image, as deck.gl draws it. */
|
|
26
|
+
type TileImage = ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas;
|
|
27
|
+
/** The part of an image to draw, in pixels. */
|
|
28
|
+
export type ImageCrop = {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
};
|
|
34
|
+
/** Options of a {@link RasterTileLoader}. */
|
|
35
|
+
export type RasterTileLoaderOptions = {
|
|
36
|
+
/** The tile URL templates of the source. */
|
|
37
|
+
tiles: string[];
|
|
38
|
+
/** The id of the style source. */
|
|
39
|
+
sourceId: string;
|
|
40
|
+
/** The lowest zoom the source has tiles at. */
|
|
41
|
+
minZoom?: number;
|
|
42
|
+
/** Tiles for which this returns `true` have no data. */
|
|
43
|
+
rejectTile: RejectRasterTile;
|
|
44
|
+
/** The `fetch`, `fetchOptions` and `transformRequest` that tiles are requested with. */
|
|
45
|
+
loadOptions?: BasemapLoadOptions;
|
|
46
|
+
/** Decodes the bytes of a tile. Default: the image loader that deck.gl registers. */
|
|
47
|
+
decodeImage?: (arrayBuffer: ArrayBuffer) => Promise<TileImage>;
|
|
48
|
+
/** Cuts a part out of a decoded tile. Default: `createImageBitmap`. */
|
|
49
|
+
cropImage?: (image: TileImage, crop: ImageCrop) => Promise<TileImage>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The part of an ancestor tile's image that covers the tile `index`, `levels` zooms below it. The
|
|
53
|
+
* part is one pixel at least: a tile far below its ancestor is drawn in the color of that pixel.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getAncestorCrop(index: RasterTileIndex, levels: number, width: number, height: number): ImageCrop;
|
|
56
|
+
/** The ancestor of the tile `index`, `levels` zooms above it. */
|
|
57
|
+
export declare function getAncestorIndex(index: RasterTileIndex, levels: number): RasterTileIndex;
|
|
58
|
+
/**
|
|
59
|
+
* Loads the tiles of a raster source that returns an image where it has no data. A tile that
|
|
60
|
+
* `rejectTile` matches is drawn from the nearest ancestor tile that has data, enlarged, as
|
|
61
|
+
* MapLibre GL JS draws a tile that failed to load.
|
|
62
|
+
*/
|
|
63
|
+
export declare class RasterTileLoader {
|
|
64
|
+
readonly options: RasterTileLoaderOptions;
|
|
65
|
+
/** Decoded ancestor tiles, or `null` for those without data, most recently used last. */
|
|
66
|
+
private ancestors;
|
|
67
|
+
constructor(options: RasterTileLoaderOptions);
|
|
68
|
+
/** The `getTileData` of the source's `TileLayer`. */
|
|
69
|
+
getTileData: (tile: TileLoadProps) => Promise<TileImage | null>;
|
|
70
|
+
/** The decoded tile, or `null` when it has no data. */
|
|
71
|
+
private loadTile;
|
|
72
|
+
/** The decoded ancestor tile, loaded once for all of the tiles that draw a part of it. */
|
|
73
|
+
private loadAncestor;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The loader of a raster source's tiles. It is kept while the source's `tiles` and the options stay
|
|
77
|
+
* the same, so that the ancestor tiles it decoded are shared by every render.
|
|
78
|
+
*/
|
|
79
|
+
export declare function getRasterTileLoader(source: BasemapSource, options: Omit<RasterTileLoaderOptions, 'tiles'>): RasterTileLoader;
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ShaderModule, ShaderPlugin } from '@luma.gl/shaders';
|
|
2
|
+
/** Separates a GLSL extension's ordered hook contributions from its uniform module. */
|
|
3
|
+
export declare function createShaderInjectionPlugin(definition: ShaderModule & {
|
|
4
|
+
inject: Record<string, string | {
|
|
5
|
+
injection: string;
|
|
6
|
+
order?: number;
|
|
7
|
+
}>;
|
|
8
|
+
}): ShaderPlugin;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { BasemapSource } from "./style-resolver.js";
|
|
2
|
+
/** The parameters of {@link BasemapLayer.querySourceFeatures}, as MapLibre GL JS's. */
|
|
3
|
+
export type QuerySourceFeaturesOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* The source layer to read. Required for a `vector` source, where no features are returned
|
|
6
|
+
* without it, and ignored for a `geojson` source.
|
|
7
|
+
*/
|
|
8
|
+
sourceLayer?: string;
|
|
9
|
+
/** A style-spec filter expression that the features must match. */
|
|
10
|
+
filter?: unknown[] | null;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A feature returned by {@link BasemapLayer.querySourceFeatures}: a GeoJSON feature in longitude
|
|
14
|
+
* and latitude, as MapLibre GL JS returns one, with the source it was read from and the tile it was
|
|
15
|
+
* read in.
|
|
16
|
+
*/
|
|
17
|
+
export type BasemapSourceFeature = {
|
|
18
|
+
type: 'Feature';
|
|
19
|
+
/** The feature id: the tile feature's id, or the property that the source's `promoteId` names. */
|
|
20
|
+
id?: string | number;
|
|
21
|
+
/** The feature's geometry in the tile, in longitude and latitude. */
|
|
22
|
+
geometry: {
|
|
23
|
+
type: string;
|
|
24
|
+
coordinates: unknown;
|
|
25
|
+
};
|
|
26
|
+
/** The feature's properties. */
|
|
27
|
+
properties: Record<string, unknown>;
|
|
28
|
+
/** The id of the style source the feature was read from. */
|
|
29
|
+
source: string;
|
|
30
|
+
/** The source layer the feature was read from, for a `vector` source. */
|
|
31
|
+
sourceLayer?: string;
|
|
32
|
+
/** The index of the tile the feature was read from. */
|
|
33
|
+
tile: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
z: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/** The part of a loaded tile that the query reads. */
|
|
40
|
+
export type QueriedTile = {
|
|
41
|
+
index: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
z: number;
|
|
45
|
+
};
|
|
46
|
+
isLoaded: boolean;
|
|
47
|
+
content: unknown;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The features of a vector or GeoJSON source in `tiles`, as MapLibre GL JS's
|
|
51
|
+
* `Map#querySourceFeatures` reads them from the tiles it renders: every feature of the source
|
|
52
|
+
* layer that matches the filter, whether a style layer draws it or not. A tile that is in `tiles`
|
|
53
|
+
* more than once, as for the copies of the world, is read once. A feature that crosses a tile edge,
|
|
54
|
+
* or a point in the buffer of two tiles, is returned once per tile, as in MapLibre.
|
|
55
|
+
*
|
|
56
|
+
* `["zoom"]` in the filter is the zoom of the tile.
|
|
57
|
+
*/
|
|
58
|
+
export declare function querySourceFeaturesInTiles(tiles: readonly QueriedTile[], sourceId: string, source: BasemapSource, options?: QuerySourceFeaturesOptions): BasemapSourceFeature[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BasemapSource } from "./style-resolver.js";
|
|
2
|
+
/** A tile index of the Web Mercator tile pyramid. */
|
|
3
|
+
export type SourceTileIndex = {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
z: number;
|
|
7
|
+
};
|
|
8
|
+
/** The `bounds` of a source, `[west, south, east, north]` in degrees. */
|
|
9
|
+
export type SourceTileBounds = [number, number, number, number];
|
|
10
|
+
/**
|
|
11
|
+
* The tile URL templates that a source's tiles load from. For `scheme: "tms"`, every `{y}` is
|
|
12
|
+
* replaced by `{-y}`, which deck.gl expands to the row counted from the south, `2^z - y - 1`, as
|
|
13
|
+
* MapLibre GL JS writes `{y}` for a TMS source. For any other scheme, the source's own `tiles`.
|
|
14
|
+
* The same source gives the same array while its `tiles` stay the same, so the tiles are not
|
|
15
|
+
* reloaded on each render.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getSourceTileTemplates(source: BasemapSource): string[] | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* A source's `bounds`, clamped to longitudes -180 to 180 and latitudes -90 to 90 as MapLibre GL JS
|
|
20
|
+
* clamps them, or null if the source has no bounds of four numbers. Bounds whose west is east of
|
|
21
|
+
* their east, across the antimeridian, contain no tiles past zoom 0, as in MapLibre GL JS. The
|
|
22
|
+
* same source gives the same array while its `bounds` stay the same.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSourceTileBounds(source: BasemapSource): SourceTileBounds | null;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a tile overlaps `bounds` (see `getSourceTileBounds`), as MapLibre GL JS's
|
|
27
|
+
* `TileBounds.contains` tests it: a tile that only touches the bounds at an edge is outside. The
|
|
28
|
+
* bounds hold in every copy of the world.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isTileInBounds({ x, y, z }: SourceTileIndex, bounds: SourceTileBounds): boolean;
|
|
31
|
+
/** The tile indices that overlap `bounds`, or all of them if there are no bounds. */
|
|
32
|
+
export declare function filterTileIndicesByBounds<IndexT extends SourceTileIndex>(indices: IndexT[], bounds: SourceTileBounds | null | undefined): IndexT[];
|
package/dist/types/sprite.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { ImageTextFit } from "./icon-text-fit.js";
|
|
1
2
|
import type { BasemapLoadOptions } from "./style-resolver.js";
|
|
3
|
+
import { type BasemapLoadErrorHandler } from "./basemap-error.js";
|
|
2
4
|
/** One image in a style sprite, as listed in the sprite's JSON index. */
|
|
3
5
|
export type SpriteImage = {
|
|
4
6
|
x: number;
|
|
@@ -9,6 +11,22 @@ export type SpriteImage = {
|
|
|
9
11
|
pixelRatio?: number;
|
|
10
12
|
/** `true` for signed-distance-field images, which are tinted with `icon-color`. */
|
|
11
13
|
sdf?: boolean;
|
|
14
|
+
} & SpriteStretchMetadata;
|
|
15
|
+
/**
|
|
16
|
+
* How `icon-text-fit` stretches an image, in image pixels, as MapLibre GL JS reads it from the
|
|
17
|
+
* sprite's JSON index (see `icon-text-fit.ts`).
|
|
18
|
+
*/
|
|
19
|
+
export type SpriteStretchMetadata = {
|
|
20
|
+
/** Ranges `[x1, x2]` of image columns that stretch. */
|
|
21
|
+
stretchX?: [number, number][];
|
|
22
|
+
/** Ranges `[y1, y2]` of image rows that stretch. */
|
|
23
|
+
stretchY?: [number, number][];
|
|
24
|
+
/** `[x1, y1, x2, y2]`: the part of the image that the label covers. */
|
|
25
|
+
content?: [number, number, number, number];
|
|
26
|
+
/** How the width may change to keep the aspect ratio of `content`. */
|
|
27
|
+
textFitWidth?: ImageTextFit;
|
|
28
|
+
/** How the height may change to keep the aspect ratio of `content`. */
|
|
29
|
+
textFitHeight?: ImageTextFit;
|
|
12
30
|
};
|
|
13
31
|
/** A deck.gl `IconLayer` mapping entry for one sprite image. */
|
|
14
32
|
export type SpriteIconMappingEntry = {
|
|
@@ -20,7 +38,7 @@ export type SpriteIconMappingEntry = {
|
|
|
20
38
|
mask: boolean;
|
|
21
39
|
/** Device pixels per CSS pixel; `icon-size` scales `height / pixelRatio`. */
|
|
22
40
|
pixelRatio: number;
|
|
23
|
-
};
|
|
41
|
+
} & SpriteStretchMetadata;
|
|
24
42
|
/** A loaded sprite: the atlas image and its deck.gl icon mapping. */
|
|
25
43
|
export type SpriteAtlas = {
|
|
26
44
|
/**
|
|
@@ -52,10 +70,16 @@ export type SpriteLoadOptions = {
|
|
|
52
70
|
baseUrl?: string;
|
|
53
71
|
/** Device pixel ratio. At 2 or more, the `@2x` sprite is requested first. Default 1. */
|
|
54
72
|
pixelRatio?: number;
|
|
55
|
-
|
|
73
|
+
/** Called for each sprite that fails to load, in place of the warning logged without it. */
|
|
74
|
+
onError?: BasemapLoadErrorHandler;
|
|
75
|
+
} & Pick<NonNullable<BasemapLoadOptions>, 'fetch' | 'fetchOptions' | 'transformRequest'>;
|
|
56
76
|
/** Resolves a style's `sprite` value into sprite sources with absolute URLs. */
|
|
57
77
|
export declare function getSpriteSources(sprite: unknown, baseUrl?: string): SpriteSource[];
|
|
58
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Converts a sprite JSON index into a deck.gl `IconLayer` mapping. An image's stretch metadata is
|
|
80
|
+
* kept for `icon-text-fit`. As in MapLibre, an image whose stretch zones or content do not lie in
|
|
81
|
+
* order inside it is left out, with a warning.
|
|
82
|
+
*/
|
|
59
83
|
export declare function getSpriteIconMapping(index: Record<string, SpriteImage>): Record<string, SpriteIconMappingEntry>;
|
|
60
84
|
/**
|
|
61
85
|
* Loads every sprite a style references. A sprite that fails to load is skipped with a warning,
|
|
@@ -78,5 +102,15 @@ export type ResolvedSpriteIcon = {
|
|
|
78
102
|
* are unprefixed; names from other sprites are written `id:name`, as in MapLibre.
|
|
79
103
|
*/
|
|
80
104
|
export declare function resolveSpriteIcon(atlases: readonly SpriteAtlas[] | undefined, iconImage: string): ResolvedSpriteIcon | null;
|
|
105
|
+
/** Whether `icon-text-fit` cuts an image into parts: it has `stretchX` or `stretchY` zones. */
|
|
106
|
+
export declare function isStretchableIcon(entry: SpriteIconMappingEntry): boolean;
|
|
107
|
+
/** The mapping name of part `index` of a stretchable image (see `getStretchIconMapping`). */
|
|
108
|
+
export declare function getIconPartName(name: string, index: number): string;
|
|
109
|
+
/**
|
|
110
|
+
* A sprite's mapping with an entry for each part that `icon-text-fit` cuts a stretchable image
|
|
111
|
+
* into (`getIconPartName`), besides each image's own. The parts are the same whatever the icon is
|
|
112
|
+
* fitted to: only their sizes on screen change.
|
|
113
|
+
*/
|
|
114
|
+
export declare function getStretchIconMapping(atlas: SpriteAtlas): Record<string, SpriteIconMappingEntry>;
|
|
81
115
|
/** Warns once per icon name that a style references an image no loaded sprite contains. */
|
|
82
116
|
export declare function warnMissingIcon(iconImage: string): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IconLayer } from '@deck.gl/layers';
|
|
2
|
+
import type { IconLayerProps } from '@deck.gl/layers';
|
|
3
|
+
import type { Accessor, DefaultProps } from '@deck.gl/core';
|
|
4
|
+
/** Props of {@link StretchIconLayer}. */
|
|
5
|
+
export type StretchIconLayerProps<DataT = unknown> = IconLayerProps<DataT> & {
|
|
6
|
+
/**
|
|
7
|
+
* How much wider (x) and taller (y) each icon is drawn than its mapping's aspect ratio at
|
|
8
|
+
* `getSize`, before it is turned by `getAngle`. Default `[1, 1]`.
|
|
9
|
+
*/
|
|
10
|
+
getIconStretch?: Accessor<DataT, [number, number]>;
|
|
11
|
+
};
|
|
12
|
+
/** Applies `patches` to a shader source, throwing if one does not match: deck.gl changed it. */
|
|
13
|
+
export declare function patchIconShader(source: string, patches: [RegExp, string][]): string;
|
|
14
|
+
/** The shader patches of {@link StretchIconLayer}, for tests. */
|
|
15
|
+
export declare const STRETCH_ICON_SHADER_PATCHES: {
|
|
16
|
+
glsl: [RegExp, string][];
|
|
17
|
+
wgsl: [RegExp, string][];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* An `IconLayer` whose icons can be drawn at another aspect ratio than their image's
|
|
21
|
+
* (`getIconStretch`), as the parts of a stretched `icon-text-fit` icon are. WebGL and WebGPU.
|
|
22
|
+
*/
|
|
23
|
+
export declare class StretchIconLayer<DataT = unknown, ExtraProps extends {} = {}> extends IconLayer<DataT, Required<Pick<StretchIconLayerProps<DataT>, 'getIconStretch'>> & ExtraProps> {
|
|
24
|
+
static layerName: string;
|
|
25
|
+
static defaultProps: DefaultProps<StretchIconLayerProps<unknown>>;
|
|
26
|
+
getShaders(): any;
|
|
27
|
+
initializeState(): void;
|
|
28
|
+
}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FeatureStateLookup } from "./feature-state.js";
|
|
2
|
+
import { type CompiledStyleProperty, type StyleFeature } from "./style-expression.js";
|
|
2
3
|
type StyleLayerLike = {
|
|
3
4
|
paint?: Record<string, unknown>;
|
|
4
5
|
layout?: Record<string, unknown>;
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
|
-
* Zoom step at which style values are evaluated.
|
|
8
|
-
*
|
|
8
|
+
* Zoom step at which style values are evaluated. Layout, stepped paint and the endpoints of
|
|
9
|
+
* composite paint attributes step every `STYLE_ZOOM_STEP` zoom levels.
|
|
9
10
|
*/
|
|
10
11
|
export declare const STYLE_ZOOM_STEP = 0.25;
|
|
11
12
|
/**
|
|
12
|
-
* Zoom at which paint and layout values are evaluated: the zoom rounded down to a
|
|
13
|
+
* Zoom at which stepped paint and layout values are evaluated: the zoom rounded down to a
|
|
13
14
|
* `STYLE_ZOOM_STEP`.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* evaluation zoom, so neighbouring tiles agree at their seams.
|
|
16
|
+
* On WebGL, supported composite paint blends attributes evaluated at the enclosing style zoom
|
|
17
|
+
* steps on the GPU. Stepping keeps every tile on the same evaluation zoom, so neighbouring
|
|
18
|
+
* tiles agree at their seams.
|
|
19
19
|
*/
|
|
20
20
|
export declare function getZoomBucket(zoom: number): number;
|
|
21
|
+
/** Uses the viewport zoom while it is within the style step of the generated sublayer. */
|
|
22
|
+
export declare function getZoomPaintZoom(viewportZoom: number, generationZoom?: number): number;
|
|
21
23
|
/** Zoom at which filters are evaluated: the integer zoom, as the style spec specifies. */
|
|
22
24
|
export declare function getFilterZoom(zoom: number): number;
|
|
23
25
|
/**
|
|
@@ -27,19 +29,55 @@ export declare function getFilterZoom(zoom: number): number;
|
|
|
27
29
|
* MapLibre, so crossing a fractional limit must regenerate sublayers too.
|
|
28
30
|
*/
|
|
29
31
|
export declare function getStyleZoomKey(zoom: number, zoomLimits: readonly (number | undefined)[]): string;
|
|
32
|
+
/** The style inputs and conversion for one paint value. */
|
|
33
|
+
export type PaintProperty<T> = {
|
|
34
|
+
/** The style properties passed to the conversion in order. */
|
|
35
|
+
names: string[];
|
|
36
|
+
/** Combines the evaluated style properties into a width or color. */
|
|
37
|
+
combine: (values: any[]) => T;
|
|
38
|
+
};
|
|
39
|
+
/** A paint property that supplies a layer-wide value or the curve for blending feature values. */
|
|
40
|
+
type ZoomPaintProperty<T> = {
|
|
41
|
+
/** Evaluates the layer-wide value, or returns undefined for per-feature paint. */
|
|
42
|
+
evaluate: (zoom: number) => T | undefined;
|
|
43
|
+
/** Whether any of the inputs reads zoom. */
|
|
44
|
+
isZoomDependent: boolean;
|
|
45
|
+
/** Whether any of the inputs reads the feature or its state. */
|
|
46
|
+
isFeatureDependent: boolean;
|
|
47
|
+
/** The curve used to blend the lower and upper per-feature samples. */
|
|
48
|
+
interpolation: CompiledStyleProperty['zoomInterpolation'];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Compiles the properties that supply a layer-wide value or a composite blend factor.
|
|
52
|
+
* Discrete inputs are held at the lower sample's zoom. When interpolating inputs use different
|
|
53
|
+
* zoom curves, the composite values blend linearly between their sampled zooms.
|
|
54
|
+
*/
|
|
55
|
+
export declare function compileZoomPaintProperty<T>(styleLayer: StyleLayerLike, definition: PaintProperty<T>): ZoomPaintProperty<T>;
|
|
30
56
|
/** A deck.gl accessor built from one or more style properties. */
|
|
31
57
|
export type StyleAccessor<T> = {
|
|
32
58
|
/** A constant when no property depends on feature data, otherwise a per-feature function. */
|
|
33
59
|
value: T | ((feature: StyleFeature) => T);
|
|
34
|
-
/**
|
|
35
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Set to the evaluation zoom (`getZoomBucket`) when a per-feature value also depends on zoom.
|
|
62
|
+
* A value that reads feature state takes a string instead, which also changes with the states.
|
|
63
|
+
*/
|
|
64
|
+
updateTrigger?: number | string;
|
|
36
65
|
};
|
|
37
66
|
/**
|
|
38
67
|
* Builds a deck.gl accessor from style properties, evaluated at the stepped zoom
|
|
39
68
|
* (`getZoomBucket`). Feature-independent values become constants. Data-driven values become
|
|
40
|
-
* per-feature functions, with an update trigger when they also depend on zoom.
|
|
69
|
+
* per-feature functions, with an update trigger when they also depend on zoom. With
|
|
70
|
+
* `featureState`, `["feature-state", ...]` reads each feature's state from it, and the update
|
|
71
|
+
* trigger of a value that reads it changes with the states: only that attribute is computed
|
|
72
|
+
* again, and the geometry is kept.
|
|
73
|
+
*
|
|
74
|
+
* With `exactZoom`, the accessor evaluates the properties at the supplied zoom. With `stepZoom`,
|
|
75
|
+
* discrete zoom-dependent properties are sampled at that zoom instead.
|
|
41
76
|
*/
|
|
42
|
-
export declare function getStyleAccessor<T>(styleLayer: StyleLayerLike, propertyNames: string[], zoom: number, combine: (values: any[]) => T
|
|
77
|
+
export declare function getStyleAccessor<T>(styleLayer: StyleLayerLike, propertyNames: string[], zoom: number, combine: (values: any[]) => T, featureState?: FeatureStateLookup, { exactZoom, stepZoom }?: {
|
|
78
|
+
exactZoom?: boolean;
|
|
79
|
+
stepZoom?: number;
|
|
80
|
+
}): StyleAccessor<T>;
|
|
43
81
|
/** Converts a style color (alpha 0-1 or 0-255) and opacity into a deck.gl RGBA color. */
|
|
44
82
|
export declare function withOpacity(color: number[] | null | undefined, opacity?: number): [number, number, number, number];
|
|
45
83
|
export {};
|