@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.
Files changed (139) hide show
  1. package/README.md +12 -7
  2. package/THIRD-PARTY-NOTICES.md +7 -5
  3. package/dist/geojson-task-worker.js +3166 -0
  4. package/dist/geojson-task-worker.js.map +6 -0
  5. package/dist/geojson-worker.js +1089 -7
  6. package/dist/geojson-worker.js.map +3 -3
  7. package/dist/index.cjs +9588 -2093
  8. package/dist/index.cjs.map +3 -3
  9. package/dist/index.js +9599 -2090
  10. package/dist/index.js.map +3 -3
  11. package/dist/map-style.cjs +456 -20
  12. package/dist/map-style.cjs.map +3 -3
  13. package/dist/map-style.js +456 -19
  14. package/dist/map-style.js.map +2 -2
  15. package/dist/types/basemap-error.d.ts +52 -0
  16. package/dist/types/basemap-layer.d.ts +378 -25
  17. package/dist/types/basemap-protocol.d.ts +91 -0
  18. package/dist/types/basemap-request.d.ts +73 -0
  19. package/dist/types/circle-layer.d.ts +65 -8
  20. package/dist/types/color-relief-layer.d.ts +184 -0
  21. package/dist/types/dem-pixels.d.ts +40 -0
  22. package/dist/types/feature-state.d.ts +55 -0
  23. package/dist/types/fill-extrusion-lighting-extension.d.ts +1 -2
  24. package/dist/types/fill-outline-extension.d.ts +2 -3
  25. package/dist/types/fill-pattern.d.ts +35 -3
  26. package/dist/types/fill-style-extensions.d.ts +11 -59
  27. package/dist/types/geojson-resource.d.ts +18 -0
  28. package/dist/types/geojson-source.d.ts +13 -2
  29. package/dist/types/geojson-task-handler.d.ts +2 -0
  30. package/dist/types/geojson-task.d.ts +26 -0
  31. package/dist/types/geojson-tiler.d.ts +29 -2
  32. package/dist/types/geojson-worker.d.ts +5 -1
  33. package/dist/types/globe-horizon-extension.d.ts +2 -45
  34. package/dist/types/globe-layers.d.ts +141 -45
  35. package/dist/types/globe-line-angle-extension.d.ts +20 -17
  36. package/dist/types/glyph-store.d.ts +10 -1
  37. package/dist/types/heatmap-layer.d.ts +99 -0
  38. package/dist/types/hillshade-layer.d.ts +159 -27
  39. package/dist/types/icon-text-fit.d.ts +92 -0
  40. package/dist/types/image-source-layer.d.ts +142 -0
  41. package/dist/types/index.d.ts +25 -1
  42. package/dist/types/line-blur-extension.d.ts +3 -11
  43. package/dist/types/line-dash-extension.d.ts +53 -0
  44. package/dist/types/line-gradient-extension.d.ts +69 -0
  45. package/dist/types/line-metrics.d.ts +24 -0
  46. package/dist/types/line-pattern-extension.d.ts +50 -0
  47. package/dist/types/line-shape-extension.d.ts +76 -0
  48. package/dist/types/map-style-loader.d.ts +1 -1
  49. package/dist/types/map-style.d.ts +2 -2
  50. package/dist/types/mvt-label-layer.d.ts +111 -20
  51. package/dist/types/pmtiles-source.d.ts +38 -0
  52. package/dist/types/projected-background-layer.d.ts +63 -0
  53. package/dist/types/projected-bitmap-layer.d.ts +58 -0
  54. package/dist/types/projected-tile-data.d.ts +16 -0
  55. package/dist/types/projected-tile-selection.d.ts +72 -0
  56. package/dist/types/projected-tileset.d.ts +92 -0
  57. package/dist/types/projected-viewport.d.ts +76 -0
  58. package/dist/types/raster-color-extension.d.ts +4 -7
  59. package/dist/types/raster-fade.d.ts +155 -0
  60. package/dist/types/raster-tile-fingerprint.d.ts +11 -0
  61. package/dist/types/raster-tile-loader.d.ts +80 -0
  62. package/dist/types/shader-injection-plugin.d.ts +8 -0
  63. package/dist/types/source-features.d.ts +58 -0
  64. package/dist/types/source-tiles.d.ts +32 -0
  65. package/dist/types/sprite.d.ts +37 -3
  66. package/dist/types/stretch-icon-layer.d.ts +28 -0
  67. package/dist/types/style-accessor.d.ts +50 -12
  68. package/dist/types/style-expression.d.ts +22 -2
  69. package/dist/types/style-resolver.d.ts +47 -2
  70. package/dist/types/terrain-query.d.ts +39 -0
  71. package/dist/types/zoom-load-gate.d.ts +22 -0
  72. package/dist/types/zoom-paint-extension.d.ts +80 -11
  73. package/package.json +24 -21
  74. package/src/basemap-error.ts +82 -0
  75. package/src/basemap-layer.ts +1289 -101
  76. package/src/basemap-protocol.ts +353 -0
  77. package/src/basemap-request.ts +212 -0
  78. package/src/circle-layer.ts +430 -54
  79. package/src/color-relief-layer.ts +572 -0
  80. package/src/dem-pixels.ts +174 -0
  81. package/src/feature-state.ts +164 -0
  82. package/src/fill-extrusion-lighting-extension.ts +126 -9
  83. package/src/fill-outline-extension.ts +4 -4
  84. package/src/fill-pattern.ts +87 -9
  85. package/src/fill-style-extensions.ts +114 -44
  86. package/src/geojson-resource.ts +58 -0
  87. package/src/geojson-source.ts +106 -85
  88. package/src/geojson-task-handler.ts +11 -0
  89. package/src/geojson-task-worker.ts +8 -0
  90. package/src/geojson-task.ts +34 -0
  91. package/src/geojson-tiler.ts +270 -4
  92. package/src/geojson-worker.ts +36 -6
  93. package/src/globe-horizon-extension.ts +14 -4
  94. package/src/globe-layers.ts +1905 -406
  95. package/src/globe-line-angle-extension.ts +183 -23
  96. package/src/glyph-store.ts +28 -6
  97. package/src/heatmap-layer.ts +591 -0
  98. package/src/hillshade-layer.ts +309 -88
  99. package/src/icon-text-fit.ts +358 -0
  100. package/src/image-source-layer.ts +380 -0
  101. package/src/index.ts +58 -1
  102. package/src/line-blur-extension.ts +14 -12
  103. package/src/line-dash-extension.ts +303 -0
  104. package/src/line-gradient-extension.ts +191 -0
  105. package/src/line-metrics.ts +90 -0
  106. package/src/line-pattern-extension.ts +173 -0
  107. package/src/line-shape-extension.ts +272 -0
  108. package/src/map-style-loader.ts +5 -4
  109. package/src/map-style.ts +2 -1
  110. package/src/mvt-label-layer.ts +568 -144
  111. package/src/pmtiles-source.ts +276 -0
  112. package/src/projected-background-layer.ts +202 -0
  113. package/src/projected-bitmap-layer.ts +262 -0
  114. package/src/projected-tile-data.ts +132 -0
  115. package/src/projected-tile-selection.ts +605 -0
  116. package/src/projected-tileset.ts +183 -0
  117. package/src/projected-viewport.ts +254 -0
  118. package/src/raster-color-extension.ts +43 -18
  119. package/src/raster-fade.ts +319 -0
  120. package/src/raster-tile-fingerprint.ts +31 -0
  121. package/src/raster-tile-loader.ts +211 -0
  122. package/src/shader-injection-plugin.ts +25 -0
  123. package/src/source-features.ts +170 -0
  124. package/src/source-tiles.ts +102 -0
  125. package/src/sprite.ts +122 -15
  126. package/src/stretch-icon-layer.ts +87 -0
  127. package/src/style-accessor.ts +105 -17
  128. package/src/style-expression.ts +80 -3
  129. package/src/style-resolver.ts +200 -22
  130. package/src/terrain-query.ts +86 -0
  131. package/src/text-layout.ts +2 -3
  132. package/src/zoom-load-gate.ts +57 -0
  133. package/src/zoom-paint-extension.ts +245 -47
  134. package/dist/types/arabic-shaping.d.ts +0 -7
  135. package/dist/types/bidi.d.ts +0 -8
  136. package/dist/types/polylabel.d.ts +0 -17
  137. package/src/arabic-shaping.ts +0 -366
  138. package/src/bidi.ts +0 -199
  139. package/src/polylabel.ts +0 -312
@@ -0,0 +1,73 @@
1
+ import type { LayerProps } from '@deck.gl/core';
2
+ import { type BasemapRequestType } from "./basemap-protocol.js";
3
+ /**
4
+ * The kind of resource a request is for, with the names of MapLibre GL JS's `ResourceType`:
5
+ * `'Style'` for the style document, `'Source'` for a TileJSON and for the `data` URL of a GeoJSON
6
+ * source, `'Tile'` for a vector, raster or raster-dem tile, `'Glyphs'` for a glyph range,
7
+ * `'SpriteJSON'` and `'SpriteImage'` for the sprite index and image.
8
+ */
9
+ export type BasemapResourceType = 'Unknown' | 'Style' | 'Source' | 'Tile' | 'Glyphs' | 'SpriteImage' | 'SpriteJSON' | 'Image';
10
+ /**
11
+ * The request that a {@link BasemapTransformRequest} returns, as MapLibre GL JS's
12
+ * `RequestParameters`. Each field that is set replaces the field of the same name in the request;
13
+ * `headers` are merged into the request's headers by name.
14
+ */
15
+ export type BasemapTransformedRequest = {
16
+ /** The URL to request in place of the original URL. */
17
+ url: string;
18
+ /** Headers to add to the request, or to replace in it. */
19
+ headers?: HeadersInit;
20
+ /** The request method. */
21
+ method?: string;
22
+ /** The request body. */
23
+ body?: BodyInit | null;
24
+ /** The credentials mode of the request, such as `'include'` to send cookies to another origin. */
25
+ credentials?: RequestCredentials;
26
+ /** The cache mode of the request. */
27
+ cache?: RequestCache;
28
+ /** Accepted for MapLibre GL JS compatibility; not used. */
29
+ type?: string;
30
+ /** Accepted for MapLibre GL JS compatibility; not used. */
31
+ collectResourceTiming?: boolean;
32
+ };
33
+ /**
34
+ * Changes a request before it is sent, as MapLibre GL JS's `transformRequest` map option: receives
35
+ * the absolute URL and the kind of resource, and returns the URL and request fields to use, or
36
+ * nothing to send the request as it is.
37
+ */
38
+ export type BasemapTransformRequest = (url: string, resourceType: BasemapResourceType) => BasemapTransformedRequest | null | undefined | void;
39
+ /**
40
+ * Applies `transformRequest` to a request: the URL to send, and `init` with the fields of the
41
+ * transformed request. Without `transformRequest`, or when it returns nothing, the URL and `init`
42
+ * are returned as they are. The `signal` of `init` is always kept.
43
+ */
44
+ export declare function transformBasemapRequest(transformRequest: BasemapTransformRequest | null | undefined, url: string, resourceType: BasemapResourceType, init?: RequestInit): {
45
+ url: string;
46
+ init: RequestInit | undefined;
47
+ };
48
+ /**
49
+ * A `fetch` for one kind of resource: it applies `transformRequest` to each request, then sends
50
+ * it with `fetch`, or with the global `fetch` without one.
51
+ */
52
+ export declare function getBasemapRequestFetch(resourceType: BasemapResourceType, { fetch: fetchFn, transformRequest }?: {
53
+ fetch?: typeof fetch;
54
+ transformRequest?: BasemapTransformRequest | null;
55
+ }): typeof fetch;
56
+ /** A deck.gl layer `fetch` prop. */
57
+ type LayerFetch = NonNullable<LayerProps['fetch']>;
58
+ /**
59
+ * A deck.gl layer `fetch` prop for tiles that applies `transformRequest` to each tile URL, then
60
+ * loads the tile with `nextFetch`. The fields of the transformed request are added to each
61
+ * request that the loaders make, through the `fetch` of the loader options. Returns `nextFetch`
62
+ * without `transformRequest`, and the same function for the same arguments, so that the props of
63
+ * a tile layer stay equal.
64
+ */
65
+ export declare function getBasemapLayerFetch(nextFetch: LayerFetch, transformRequest: BasemapTransformRequest | null | undefined): LayerFetch;
66
+ /** Applies the request transformation before protocol dispatch for a resource. */
67
+ export declare function getBasemapResourceFetch(resourceType: BasemapResourceType, type: BasemapRequestType, options?: {
68
+ fetch?: typeof fetch;
69
+ transformRequest?: BasemapTransformRequest | null;
70
+ }): typeof fetch;
71
+ /** Applies the request transformation before protocol dispatch for a tile. */
72
+ export declare function getBasemapTileFetch(nextFetch: LayerFetch, type: BasemapRequestType, transformRequest: BasemapTransformRequest | null | undefined): LayerFetch;
73
+ export {};
@@ -1,11 +1,46 @@
1
1
  import { LayerExtension } from '@deck.gl/core';
2
- import type { Layer } from '@deck.gl/core';
3
- import { ScatterplotLayer } from '@deck.gl/layers';
2
+ import type { Accessor, DefaultProps, Layer, UpdateParameters } from '@deck.gl/core';
3
+ import { ScatterplotLayer, type ScatterplotLayerProps } from '@deck.gl/layers';
4
+ import type { ShaderPlugin } from '@luma.gl/shaders';
5
+ import { FillTranslateExtension, type FillTranslateExtensionProps } from "./fill-style-extensions.js";
6
+ import type { FeatureStateLookup } from "./feature-state.js";
4
7
  import type { ResolvedBasemapStyleLayer as BasemapStyleLayer } from "./style-resolver.js";
8
+ /** Uniforms of the circle paint at the viewport zoom. */
9
+ type CircleZoomPaint = {
10
+ /** Inner radius and stroke width, each negative when it comes from an attribute. */
11
+ size: number[];
12
+ /** RGBA fill, with a negative alpha when it comes from an attribute. */
13
+ fillColor: number[];
14
+ /** RGBA stroke, with a negative alpha when it comes from an attribute. */
15
+ lineColor: number[];
16
+ /** Blend factors for the radius, stroke width, fill and stroke color, in that order. */
17
+ blend: number[];
18
+ };
19
+ /** Circle paint supplied to the WebGL shader. */
20
+ type CircleZoomPaintProps = {
21
+ /** The uniform values at the current zoom, or null for ordinary stepped attributes. */
22
+ circleZoomPaint?: ((zoom: number) => CircleZoomPaint) | null;
23
+ /** Inner radius and stroke width at the next style zoom step. */
24
+ getNextCircleSize?: Accessor<any, [number, number]>;
25
+ /** Fill RGBA at the next style zoom step. */
26
+ getNextCircleFillColor?: Accessor<any, number[]>;
27
+ /** Stroke RGBA at the next style zoom step. */
28
+ getNextCircleLineColor?: Accessor<any, number[]>;
29
+ };
30
+ /** Draws the installed scatterplot shader with continuous paint when the style needs it. */
31
+ declare class ZoomPaintScatterplotLayer extends ScatterplotLayer<any, CircleZoomPaintProps> {
32
+ static layerName: string;
33
+ static defaultProps: DefaultProps<ScatterplotLayerProps & CircleZoomPaintProps>;
34
+ /** Adds the paint plugin alongside all of the inherited extension shaders. */
35
+ getShaders(): any;
36
+ /** Updates the attribute layout before a style edit switches the model's shader. */
37
+ updateState(params: UpdateParameters<this>): void;
38
+ /** Evaluates layer-wide paint and composite factors for the viewport being drawn. */
39
+ draw(options: Parameters<ScatterplotLayer['draw']>[0]): void;
40
+ }
5
41
  /**
6
42
  * Adds `getBlur` to a `ScatterplotLayer`: per circle, the outer fraction of the circle (stroke
7
- * included) that fades out, as MapLibre GL JS draws `circle-blur`. WebGL only; on WebGPU circles
8
- * draw without blur.
43
+ * included) that fades out, as MapLibre GL JS draws `circle-blur`, on WebGL and WebGPU.
9
44
  */
10
45
  export declare class CircleBlurExtension extends LayerExtension {
11
46
  static extensionName: string;
@@ -17,6 +52,7 @@ export declare class CircleBlurExtension extends LayerExtension {
17
52
  };
18
53
  initializeState(this: Layer): void;
19
54
  getShaders(this: Layer): {
55
+ plugins: ShaderPlugin[];
20
56
  inject?: undefined;
21
57
  } | {
22
58
  inject: {
@@ -25,25 +61,46 @@ export declare class CircleBlurExtension extends LayerExtension {
25
61
  'fs:#decl': string;
26
62
  'fs:DECKGL_FILTER_COLOR': string;
27
63
  };
64
+ plugins?: undefined;
65
+ };
66
+ }
67
+ /**
68
+ * `circle-translate` and `circle-translate-anchor` for a `ScatterplotLayer`: the offset of
69
+ * `FillTranslateExtension`, which moves a circle's center on the ground, turned with the map or
70
+ * with the viewport, as MapLibre GL JS moves it in tile units, on WebGL and WebGPU.
71
+ */
72
+ export declare class CircleTranslateExtension extends FillTranslateExtension {
73
+ static extensionName: string;
74
+ getShaders(this: Layer): {
75
+ plugins: ShaderPlugin[];
28
76
  };
29
77
  }
30
78
  /**
31
79
  * Draws a `circle` style layer's points (and each point of a multipoint) with MapLibre's circle
32
80
  * paint: the stroke is drawn outside `circle-radius`. Under pitch, circles shrink with distance,
33
81
  * as with the default `circle-pitch-scale` of `map`; `viewport` is not applied.
34
- * `circle-translate-anchor` follows `circle-pitch-alignment`: the offset is screen-aligned when
35
- * circles face the viewer and map-aligned when they lie on the map.
82
+ * `circle-translate` moves the circles on the ground, as in MapLibre, turned with the map, or with
83
+ * the viewport for a `circle-translate-anchor` of `viewport`.
36
84
  */
37
- export declare function createCircleSubLayer({ baseProps, id, styleLayer, features, zoom, globe, parameters }: {
85
+ export declare function createCircleSubLayer({ baseProps, id, styleLayer, features, zoom, featureState, globe, webgpu, styleProps, translate, parameters }: {
38
86
  baseProps: any;
39
87
  id: string;
40
88
  styleLayer: BasemapStyleLayer;
41
89
  features: any[];
42
90
  zoom: number;
91
+ /** The feature states the style layer's paint reads, if it reads any. */
92
+ featureState?: FeatureStateLookup;
43
93
  /**
44
94
  * On a globe, circles always face the viewer: `circle-pitch-alignment: map` is not verified
45
95
  * there.
46
96
  */
47
97
  globe: boolean;
98
+ /** Whether the circles draw on WebGPU, where zoom-dependent paint is not interpolated on the GPU. */
99
+ webgpu?: boolean;
100
+ /** Extra sublayer props that may supply their own paint accessors or columns. */
101
+ styleProps?: Record<string, unknown>;
102
+ /** `circle-translate` and its anchor, when the layer sets them, as `FillTranslateExtension` takes them. */
103
+ translate?: FillTranslateExtensionProps | null;
48
104
  parameters: any;
49
- }): ScatterplotLayer<any, {}> | null;
105
+ }): ZoomPaintScatterplotLayer | null;
106
+ export {};
@@ -0,0 +1,184 @@
1
+ /**
2
+ * @license
3
+ * Portions of this file are adapted from MapLibre GL JS v6.13.0,
4
+ * src/shaders/glsl/color_relief.fragment.glsl and
5
+ * src/style/style_layer/color_relief_style_layer.ts,
6
+ * under these licenses (see also THIRD-PARTY-NOTICES.md):
7
+ *
8
+ * Copyright (c) 2023, MapLibre contributors
9
+ *
10
+ * All rights reserved.
11
+ *
12
+ * Redistribution and use in source and binary forms, with or without modification,
13
+ * are permitted provided that the following conditions are met:
14
+ *
15
+ * * Redistributions of source code must retain the above copyright notice,
16
+ * this list of conditions and the following disclaimer.
17
+ * * Redistributions in binary form must reproduce the above copyright notice,
18
+ * this list of conditions and the following disclaimer in the documentation
19
+ * and/or other materials provided with the distribution.
20
+ * * Neither the name of MapLibre GL JS nor the names of its contributors
21
+ * may be used to endorse or promote products derived from this software
22
+ * without specific prior written permission.
23
+ *
24
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+ *
36
+ * MapLibre GL JS contains code from mapbox-gl-js v1.13 and earlier, licensed under a
37
+ * BSD-3-Clause license:
38
+ *
39
+ * Copyright (c) 2020, Mapbox
40
+ * Redistribution and use in source and binary forms, with or without modification,
41
+ * are permitted provided that the following conditions are met:
42
+ *
43
+ * * Redistributions of source code must retain the above copyright notice,
44
+ * this list of conditions and the following disclaimer.
45
+ * * Redistributions in binary form must reproduce the above copyright notice,
46
+ * this list of conditions and the following disclaimer in the documentation
47
+ * and/or other materials provided with the distribution.
48
+ * * Neither the name of Mapbox GL JS nor the names of its contributors
49
+ * may be used to endorse or promote products derived from this software
50
+ * without specific prior written permission.
51
+ *
52
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
56
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
57
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
58
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
59
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
60
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
61
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
62
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63
+ */
64
+ import type { Layer, LayersList, UpdateParameters } from '@deck.gl/core';
65
+ import type { Device, Texture } from '@luma.gl/core';
66
+ import { type DemNeighbors, type DemTile, DemTileLayer, type DemTileLayerProps, type DemUnpackVector } from "./hillshade-layer.js";
67
+ /**
68
+ * `color-relief` style layers over `raster-dem` sources, drawn as MapLibre GL JS draws them.
69
+ *
70
+ * MapLibre reads the stops of the `color-relief-color` ramp, an `interpolate` expression over
71
+ * `["elevation"]`, into two textures: the stops' elevations, packed with the DEM's encoding, and
72
+ * their colors. Its fragment shader finds a pixel's elevation between two stops with a binary
73
+ * search and blends their colors linearly, whatever the interpolation type. Here the ramp is one
74
+ * float texture of the same values, and the DEM tile a texture of its elevations, with a
75
+ * one-pixel border from its neighbors, as the hillshade layers prepare theirs.
76
+ */
77
+ /** A color ramp, as MapLibre GL JS's `ColorReliefStyleLayer` makes it. */
78
+ export type ColorRamp = {
79
+ /** Elevations in meters, ascending. */
80
+ elevationStops: number[];
81
+ /** Premultiplied RGBA in 0-1, one per elevation stop. */
82
+ colorStops: [number, number, number, number][];
83
+ };
84
+ /**
85
+ * The color ramp of a `color-relief-color` value, at most `maxLength` stops long, as MapLibre GL JS
86
+ * creates it: the stops of an `interpolate` expression, or one transparent stop for any other
87
+ * value. A single stop is repeated one meter higher. A longer ramp is resampled to `maxLength`
88
+ * stops, which MapLibre warns may not render properly.
89
+ */
90
+ export declare function createColorRamp(value: unknown, maxLength: number): ColorRamp;
91
+ /** Whether a ramp draws anything: whether any of its colors is not transparent. */
92
+ export declare function isColorRampVisible(ramp: ColorRamp): boolean;
93
+ /**
94
+ * An elevation as the shader reads a DEM pixel of it: rounded to the steps of the encoding
95
+ * `unpack`, `min(factors)` meters, within what its 8-bit red, green and blue hold, as MapLibre GL
96
+ * JS's `packDEMData` rounds it; then to the steps of the elevation texture (see
97
+ * `prepareColorReliefTexture`). Unlike `packDEMData`, it counts the elevation once where factors
98
+ * overlap, as in the default custom factors `[1, 1, 1, 0]`, whose pixel `[100, 0, 0]` is 100 m.
99
+ */
100
+ export declare function quantizeElevation(elevation: number, [redFactor, greenFactor, blueFactor, baseShift]: DemUnpackVector): number;
101
+ /**
102
+ * The texels of a ramp's texture, `colorStops.length` wide and 2 high, RGBA in 8 bits: the first
103
+ * row holds the colors, premultiplied and rounded to 8 bits as MapLibre GL JS uploads them, and the
104
+ * second the elevations, as the shader reads them back from the DEM encoding `unpack`, encoded as
105
+ * the elevation texture encodes them (see `prepareColorReliefTexture`). WebGPU can bind an 8-bit
106
+ * texture as a float texture without the `float32-filterable` feature; a 32-bit float one, not.
107
+ */
108
+ export declare function getColorRampTexels(ramp: ColorRamp, unpack: DemUnpackVector): Uint8Array;
109
+ /**
110
+ * The elevation texture of a DEM tile, `dim + 2` pixels square: the tile and a one-pixel border
111
+ * from its loaded neighbors (see `getBorderedElevations`), RGBA. Elevations are encoded as
112
+ * terrarium: `R * 256 + G + B / 256 - 32768`, whatever the source's encoding, which keeps their
113
+ * linear filtering, and are clamped to that encoding's range.
114
+ */
115
+ export declare function prepareColorReliefTexture(dem: DemTile, getNeighbor?: DemNeighbors): Uint8ClampedArray<ArrayBuffer>;
116
+ /** The `colorRelief` shader module's uniforms and bindings. */
117
+ export type ColorReliefUniforms = {
118
+ /** `color-relief-opacity`. */
119
+ opacity: number;
120
+ /** The number of stops in the ramp. */
121
+ rampSize: number;
122
+ colorReliefRamp?: Texture;
123
+ };
124
+ /** A ramp's texture, created by the `ColorReliefTileLayer` that owns it. */
125
+ export type ColorRampTexture = {
126
+ texture: Texture;
127
+ size: number;
128
+ };
129
+ /** Props of a `ColorReliefTileLayer`. */
130
+ export type ColorReliefTileLayerProps = DemTileLayerProps & {
131
+ /** `color-relief-color`, as the style sets it. */
132
+ colorReliefColor: unknown;
133
+ /** `color-relief-opacity`, evaluated. */
134
+ colorReliefOpacity: number;
135
+ /** The unpack vector of the source, to which MapLibre rounds the ramp's elevations. */
136
+ colorReliefUnpack: DemUnpackVector;
137
+ /** Extra props of every tile's bitmap layer, such as `parameters`. */
138
+ colorReliefSubLayerProps?: Record<string, unknown>;
139
+ };
140
+ /**
141
+ * The tiles of a `raster-dem` source, colored by elevation by one `color-relief` style layer (see
142
+ * `DemTileLayer`). The layer owns the texture of its ramp, which its tiles share.
143
+ */
144
+ export declare class ColorReliefTileLayer extends DemTileLayer<ColorReliefTileLayerProps> {
145
+ static layerName: string;
146
+ static defaultProps: {
147
+ colorReliefColor: {
148
+ type: string;
149
+ value: null;
150
+ compare: boolean;
151
+ };
152
+ colorReliefOpacity: {
153
+ type: string;
154
+ value: number;
155
+ };
156
+ colorReliefUnpack: {
157
+ type: string;
158
+ value: number[];
159
+ compare: boolean;
160
+ };
161
+ colorReliefSubLayerProps: {
162
+ type: string;
163
+ value: null;
164
+ compare: boolean;
165
+ };
166
+ demTilesetOwner: {
167
+ type: string;
168
+ value: null;
169
+ compare: boolean;
170
+ };
171
+ };
172
+ state: DemTileLayer<ColorReliefTileLayerProps>['state'] & {
173
+ colorRamp?: ColorRampTexture & {
174
+ key: string;
175
+ device: Device;
176
+ };
177
+ };
178
+ updateState(params: UpdateParameters<this>): void;
179
+ finalizeState(): void;
180
+ private getColorRampKey;
181
+ /** The texture of the ramp, created again when the ramp or its encoding changes. */
182
+ private getColorRampTexture;
183
+ renderSubLayers(props: any): Layer | null | LayersList;
184
+ }
@@ -0,0 +1,40 @@
1
+ /** An image whose pixels can be read: a decoded tile, or a canvas. */
2
+ export type DemPixelSource = ImageBitmap | HTMLCanvasElement | OffscreenCanvas;
3
+ /** Reads the exact RGBA bytes of an image, row by row from the top-left pixel. */
4
+ export type DemPixelReader = (image: DemPixelSource) => Promise<Uint8ClampedArray>;
5
+ /** How the pixels of a DEM tile are read exactly. */
6
+ export type DemPixelReadMethod = 'canvas' | 'video-frame';
7
+ /**
8
+ * Thrown when this browser gives no exact pixels of an image. Some browsers add noise to canvas
9
+ * reads to resist fingerprinting (Firefox `privacy.resistFingerprinting`, Brave, Safari), and
10
+ * some of them also turn `VideoFrame` off. One changed byte moves a Terrarium elevation by up to
11
+ * 256 m, so the tile fails instead of drawing wrong heights.
12
+ */
13
+ export declare class DemPixelReadError extends Error {
14
+ constructor(reason: string, options?: {
15
+ cause?: unknown;
16
+ });
17
+ }
18
+ /** Creates a DEM bitmap with its color and alpha bytes preserved. */
19
+ export declare function createDemImageBitmap(image: Blob | ImageData): Promise<ImageBitmap>;
20
+ /** Reads the pixels of an image through a 2D canvas. */
21
+ export declare function readPixelsWithCanvas(image: DemPixelSource): Promise<Uint8ClampedArray>;
22
+ /**
23
+ * Reads the pixels of an image through WebCodecs, which canvas noise does not reach. The frame
24
+ * is copied in its own pixel format, so no color conversion runs; blue-first formats are
25
+ * reordered to RGBA, and formats without alpha (`RGBX`, `BGRX`) get opaque pixels.
26
+ */
27
+ export declare function readPixelsWithVideoFrame(image: DemPixelSource): Promise<Uint8ClampedArray>;
28
+ /**
29
+ * Chooses how to read DEM pixels exactly: through a canvas, which is what MapLibre GL JS and most
30
+ * browsers use; through `VideoFrame` where canvas reads are changed; or neither, which rejects
31
+ * with a {@link DemPixelReadError}. Each method is tested on a known image before it is chosen.
32
+ */
33
+ export declare function chooseDemPixelReadMethod(): Promise<DemPixelReadMethod>;
34
+ /**
35
+ * A reader of exact DEM pixels. Later reads reuse the chosen method or a definitive exactness
36
+ * failure. An interrupted probe can be retried by the next read.
37
+ */
38
+ export declare function createDemPixelReader(): DemPixelReader;
39
+ /** Reads exact DEM tile pixels and shares the method selection across the page. */
40
+ export declare const readDemPixels: DemPixelReader;
@@ -0,0 +1,55 @@
1
+ import { type StyleFeature } from "./style-expression.js";
2
+ import type { BasemapSource, ResolvedBasemapStyleLayer } from "./style-resolver.js";
3
+ /** The state of one feature, which `["feature-state", key]` reads. */
4
+ export type FeatureState = Readonly<Record<string, unknown>>;
5
+ /** The states of features, by feature id. */
6
+ export type FeatureStates = Readonly<Record<string, FeatureState>>;
7
+ /**
8
+ * The states of a style's features, by source id. A `vector` source's states are by source layer
9
+ * and then by feature id; a `geojson` source's are by feature id, as MapLibre GL JS's
10
+ * `setFeatureState` addresses them. Pass a new object to change a state: objects are compared by
11
+ * identity.
12
+ */
13
+ export type BasemapFeatureState = Readonly<Record<string, FeatureStates | Readonly<Record<string, FeatureStates>>>>;
14
+ /** The state of a feature of one style layer, for its paint accessors. */
15
+ export type FeatureStateLookup = {
16
+ /** The feature's state, or undefined for a feature without one. */
17
+ get: (feature: StyleFeature) => FeatureState | undefined;
18
+ /** Changes when the states of the style layer's features change. */
19
+ token: number;
20
+ };
21
+ /**
22
+ * The id a feature's state is kept under, as MapLibre GL JS reads it: the `promoteId` property of a
23
+ * vector source (none for a source layer that an object `promoteId` does not name), or the
24
+ * feature's id. A GeoJSON source's `promoteId` is already the id of its tile features.
25
+ */
26
+ export declare function getFeatureStateId(feature: StyleFeature, source: BasemapSource | undefined, sourceLayer: string | undefined): string | number | undefined;
27
+ /** The states of the features of a style layer's source and source layer. */
28
+ export declare function getStyleLayerFeatureStates(featureState: BasemapFeatureState | null | undefined, sourceId: string, source: BasemapSource | undefined, styleLayer: ResolvedBasemapStyleLayer): FeatureStates | undefined;
29
+ /** Whether a style layer's paint reads `["feature-state", ...]`. */
30
+ export declare function isStyleLayerStateDependent(styleLayer: ResolvedBasemapStyleLayer): boolean;
31
+ /** A number per states object, 0 for none: a new object, a new number. */
32
+ export declare function getFeatureStatesToken(states: FeatureStates | undefined): number;
33
+ /**
34
+ * The feature states of a style layer whose paint reads them, or undefined for a style layer whose
35
+ * paint does not: its accessors and update triggers then stay as they are.
36
+ */
37
+ export declare function getFeatureStateLookup(featureState: BasemapFeatureState | null | undefined, sourceId: string, source: BasemapSource | undefined, styleLayer: ResolvedBasemapStyleLayer): FeatureStateLookup | undefined;
38
+ /**
39
+ * A picked feature of a vector or GeoJSON source, named as MapLibre GL JS's `queryRenderedFeatures`
40
+ * names it. `BasemapLayer` adds it to deck.gl's picking info as `basemapFeature`.
41
+ */
42
+ export type BasemapPickedFeature = {
43
+ /** The feature's id (a vector source's `promoteId` property), or undefined without one. */
44
+ id: string | number | undefined;
45
+ /** The id of the feature's source in the style. */
46
+ source: string;
47
+ /** The feature's source layer, for a vector source. */
48
+ sourceLayer: string | undefined;
49
+ /** The id of the style layer that drew the feature. */
50
+ styleLayerId: string;
51
+ /** The feature's properties. */
52
+ properties: Record<string, unknown>;
53
+ };
54
+ /** The picked feature of a style layer, for a feature of `source`. */
55
+ export declare function getPickedFeature(feature: StyleFeature, sourceId: string, source: BasemapSource | undefined, styleLayerId: string): BasemapPickedFeature;
@@ -31,8 +31,7 @@ export declare function getFillExtrusionLightDirection(light: FillExtrusionLight
31
31
  * layer at every draw. A light anchored to the viewport turns with the viewport's bearing, which is
32
32
  * read at every draw. On a globe, the light is placed relative to
33
33
  * the ground under each building. Polygons must lie at `fill-extrusion-base` and be extruded by
34
- * the rest of the height. WebGL only: on WebGPU the extension adds no shader code, and buildings
35
- * keep deck.gl's lights.
34
+ * the rest of the height. On WebGL and WebGPU.
36
35
  */
37
36
  export declare class FillExtrusionLightingExtension extends LayerExtension {
38
37
  static extensionName: string;
@@ -1,6 +1,5 @@
1
1
  import { LayerExtension } from '@deck.gl/core';
2
2
  import type { Layer } from '@deck.gl/core';
3
- import type { ShaderModule } from '@luma.gl/shadertools';
4
3
  /**
5
4
  * Draws the `PathLayer`s of a fill's outline (`fill-outline-color`) as MapLibre GL JS draws it: as
6
5
  * `gl.LINES`, which draw each segment on its own, one pixel across the axis it crosses most
@@ -15,8 +14,8 @@ import type { ShaderModule } from '@luma.gl/shadertools';
15
14
  export declare class FillOutlineExtension extends LayerExtension {
16
15
  static extensionName: string;
17
16
  getShaders(this: Layer): {
18
- modules?: undefined;
17
+ plugins?: undefined;
19
18
  } | {
20
- modules: ShaderModule[];
19
+ plugins: import("@luma.gl/shaders").ShaderPlugin[];
21
20
  };
22
21
  }
@@ -27,9 +27,11 @@ export type FillPatternGroup = {
27
27
  * Returns no groups while the sprites load (`null`) or when the layer has no `fill-pattern`. A
28
28
  * pattern that does not depend on feature data keeps the tile's feature array, so deck.gl does not
29
29
  * re-tessellate the features at a new zoom step; per-feature groups are cached per tile, style
30
- * layer, sprite list and zoom.
30
+ * layer, sprite list and zoom. `propertyName` is `line-pattern` for a patterned line, which is
31
+ * grouped the same way, and `background-pattern` for a patterned background, whose features are the
32
+ * polygons that cover the map.
31
33
  */
32
- export declare function getFillPatternGroups(features: any[], styleLayer: StyleLayerLike, zoom: number, spriteAtlases: SpriteAtlas[] | null | undefined): FillPatternGroup[];
34
+ export declare function getFillPatternGroups(features: any[], styleLayer: StyleLayerLike, zoom: number, spriteAtlases: SpriteAtlas[] | null | undefined, propertyName?: 'fill-pattern' | 'line-pattern' | 'background-pattern'): FillPatternGroup[];
33
35
  type PatternAtlas = {
34
36
  image: SpriteAtlas['image'] | OffscreenCanvas | HTMLCanvasElement | ImageData;
35
37
  mapping: Record<string, SpriteIconMappingEntry>;
@@ -73,6 +75,20 @@ export declare function packPatternImages(sizes: {
73
75
  * every neighbor's color, stays 0, so no pixel's new color depends on another's.
74
76
  */
75
77
  export declare function bleedIntoTransparentPixels({ data, width, height }: ImageData, [left, top, right, bottom]?: number[]): void;
78
+ /** Consecutive features, in draw order, whose images are in one group's atlas. */
79
+ export type PatternRun = {
80
+ group: FillPatternGroup;
81
+ features: any[];
82
+ /** Unique among the runs of one list of groups, and the same while the groups are reused. */
83
+ key: string;
84
+ };
85
+ /**
86
+ * Splits groups into runs of consecutive `features` with the same atlas, so that sublayers drawn
87
+ * run after run keep the features' draw order, such as `line-sort-key`'s, across atlases. A group
88
+ * whose features are consecutive stays one run. The runs of a group share its pattern atlas.
89
+ * Cached per list of groups, which `getFillPatternGroups` reuses while its inputs are unchanged.
90
+ */
91
+ export declare function getPatternRuns(features: any[], groups: FillPatternGroup[]): PatternRun[];
76
92
  /**
77
93
  * The features of a patterned fill that no group draws, because no loaded sprite has their image.
78
94
  * MapLibre GL JS draws no fill for them, but still draws their `fill-outline-color` outline.
@@ -86,14 +102,30 @@ export declare function getFeaturesWithoutPattern(features: any[], groups: FillP
86
102
  * supplies the colors, so the fill color is only the opacity.
87
103
  */
88
104
  export declare function getFillPatternProps(group: FillPatternGroup, zoom: number): {
89
- fillPatternAtlas: string | OffscreenCanvas | ImageBitmap | HTMLCanvasElement | ImageData;
105
+ fillPatternAtlas: string | ImageData | HTMLCanvasElement | ImageBitmap | OffscreenCanvas;
90
106
  fillPatternMapping: Record<string, SpriteIconMappingEntry>;
91
107
  fillPatternMask: boolean;
92
108
  textureParameters: {
93
109
  readonly mipmapFilter: "none";
110
+ readonly lodMaxClamp: 0;
94
111
  };
95
112
  fillPatternSizeUnits: "common";
96
113
  getFillPattern: string | ((feature: StyleFeature) => string);
97
114
  getFillPatternScale: number | ((feature: StyleFeature) => number);
98
115
  };
116
+ /**
117
+ * `LinePatternExtension` props for a group of patterned lines: the pattern atlas, which its
118
+ * shader reads as MapLibre GL JS's does, and pixels per common unit at the integer zoom, which
119
+ * the pattern's repeats are measured in.
120
+ */
121
+ export declare function getLinePatternProps(group: FillPatternGroup, zoom: number): {
122
+ linePatternAtlas: string | ImageData | HTMLCanvasElement | ImageBitmap | OffscreenCanvas;
123
+ linePatternMapping: Record<string, SpriteIconMappingEntry>;
124
+ linePatternPixelsPerUnit: number;
125
+ textureParameters: {
126
+ readonly mipmapFilter: "none";
127
+ readonly lodMaxClamp: 0;
128
+ };
129
+ getLinePattern: string | ((feature: StyleFeature) => string);
130
+ };
99
131
  export {};