@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
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { LayerExtension } from '@deck.gl/core';
|
|
2
|
-
import type { Layer } from '@deck.gl/core';
|
|
2
|
+
import type { FirstPersonViewport, Layer } from '@deck.gl/core';
|
|
3
|
+
import type { ShaderPlugin } from '@luma.gl/shaders';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* north up, and the shader turns them as the view draws the line, upright with `keepUpright`. In
|
|
7
|
-
* other views it does nothing. Add it only to billboards (the shader would also turn the offset of
|
|
8
|
-
* a layer drawn in the map plane) whose angle is a direction on the map. WebGL only: on WebGPU the
|
|
9
|
-
* extension adds no shader code, and they stay as they are drawn from north up.
|
|
5
|
+
* Turns camera-facing labels along the projected line, upright with `keepUpright`. The globe
|
|
6
|
+
* uses this on WebGL. With `mercator`, viewport-pitched road text uses it on both backends.
|
|
10
7
|
*
|
|
11
8
|
* Added to a composite layer such as `TextLayer`, it reaches the character and background
|
|
12
9
|
* sublayers. With `keepOffsetSide`, text kept upright is turned around without its pixel offset,
|
|
@@ -15,23 +12,29 @@ import type { Layer } from '@deck.gl/core';
|
|
|
15
12
|
export declare class GlobeLineAngleExtension extends LayerExtension<{
|
|
16
13
|
keepUpright: boolean;
|
|
17
14
|
keepOffsetSide?: boolean;
|
|
15
|
+
mercator?: boolean;
|
|
18
16
|
}> {
|
|
19
17
|
static extensionName: string;
|
|
20
18
|
constructor(opts: {
|
|
21
19
|
keepUpright: boolean;
|
|
22
20
|
keepOffsetSide?: boolean;
|
|
21
|
+
mercator?: boolean;
|
|
23
22
|
});
|
|
24
23
|
getShaders(this: Layer, extension: GlobeLineAngleExtension): {
|
|
25
|
-
|
|
24
|
+
plugins: ShaderPlugin[];
|
|
26
25
|
} | {
|
|
27
|
-
|
|
28
|
-
name: string;
|
|
29
|
-
dependencies: import("@luma.gl/shadertools").ShaderModule[];
|
|
30
|
-
inject: {
|
|
31
|
-
'vs:#decl': string;
|
|
32
|
-
'vs:#main-start': string;
|
|
33
|
-
'vs:DECKGL_FILTER_SIZE': string;
|
|
34
|
-
};
|
|
35
|
-
}[];
|
|
26
|
+
plugins?: undefined;
|
|
36
27
|
};
|
|
37
28
|
}
|
|
29
|
+
/** Forward distance to the ground at the view center, limited to the far plane at the horizon. */
|
|
30
|
+
export declare function getFirstPersonLabelReferenceDepth(viewport: FirstPersonViewport): number;
|
|
31
|
+
/** MapLibre's viewport-pitched symbol size, shared with placement. */
|
|
32
|
+
export declare function getFirstPersonLabelPerspective(referenceDepth: number, anchorDepth: number): number;
|
|
33
|
+
/** Size first-person billboard symbols in screen pixels with MapLibre's distance falloff. */
|
|
34
|
+
export declare class FirstPersonLabelSizeExtension extends LayerExtension {
|
|
35
|
+
static extensionName: string;
|
|
36
|
+
getShaders(this: Layer): {
|
|
37
|
+
plugins: ShaderPlugin[];
|
|
38
|
+
};
|
|
39
|
+
draw(this: Layer): void;
|
|
40
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type BasemapTransformRequest } from "./basemap-request.js";
|
|
1
2
|
import type { Glyph } from "./glyph-pbf.js";
|
|
3
|
+
import { type BasemapLoadErrorHandler } from "./basemap-error.js";
|
|
2
4
|
/** Options for a {@link GlyphStore}. */
|
|
3
5
|
export type GlyphStoreOptions = {
|
|
4
6
|
/** The style's `glyphs` URL, with `{fontstack}` and `{range}`. */
|
|
@@ -7,6 +9,10 @@ export type GlyphStoreOptions = {
|
|
|
7
9
|
baseUrl?: string;
|
|
8
10
|
fetch?: typeof fetch;
|
|
9
11
|
fetchOptions?: RequestInit;
|
|
12
|
+
/** Called for each range that fails to load, in place of the warning logged without it. */
|
|
13
|
+
onError?: BasemapLoadErrorHandler;
|
|
14
|
+
/** Changes each glyph range request before it is sent (see `BasemapTransformRequest`). */
|
|
15
|
+
transformRequest?: BasemapTransformRequest | null;
|
|
10
16
|
};
|
|
11
17
|
/**
|
|
12
18
|
* Bound on the font stacks a store keeps glyphs for: stacks come from untrusted style and tile
|
|
@@ -33,8 +39,11 @@ export declare class GlyphStore {
|
|
|
33
39
|
*/
|
|
34
40
|
readonly id: number;
|
|
35
41
|
readonly url: string;
|
|
42
|
+
/** Whether a glyph range failed to load. Such a range holds no glyphs, and is not loaded again. */
|
|
43
|
+
failed: boolean;
|
|
36
44
|
private readonly fetch;
|
|
37
45
|
private readonly fetchOptions?;
|
|
46
|
+
private readonly onError?;
|
|
38
47
|
private readonly stacks;
|
|
39
48
|
/** The font stacks each consumer retains (see `retain`). */
|
|
40
49
|
private readonly retained;
|
|
@@ -42,7 +51,7 @@ export declare class GlyphStore {
|
|
|
42
51
|
private readonly retainCounts;
|
|
43
52
|
/** Called once when a consumer next gives back a font stack (see `onRetainedFreed`). */
|
|
44
53
|
private readonly freedListeners;
|
|
45
|
-
constructor({ url, baseUrl, fetch: fetchFn, fetchOptions }: GlyphStoreOptions);
|
|
54
|
+
constructor({ url, baseUrl, fetch: fetchFn, fetchOptions, transformRequest, onError }: GlyphStoreOptions);
|
|
46
55
|
/**
|
|
47
56
|
* The glyph of a code point: `undefined` while its range is not loaded, `null` when the range
|
|
48
57
|
* has no glyph for it.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Layer, type Accessor, type DefaultProps, type LayerProps, type UpdateParameters } from '@deck.gl/core';
|
|
2
|
+
import type { Framebuffer, Texture } from '@luma.gl/core';
|
|
3
|
+
import { Model } from '@luma.gl/engine';
|
|
4
|
+
import { type StyleFeature } from "./style-expression.js";
|
|
5
|
+
import type { ResolvedBasemapStyleLayer as BasemapStyleLayer } from "./style-resolver.js";
|
|
6
|
+
/** The texels of a color ramp, as MapLibre GL JS renders `heatmap-color`. */
|
|
7
|
+
export declare const COLOR_RAMP_SIZE = 256;
|
|
8
|
+
/** A point of a heatmap: its longitude/latitude position and the feature it comes from. */
|
|
9
|
+
export type HeatmapPoint = {
|
|
10
|
+
position: [number, number];
|
|
11
|
+
feature: StyleFeature;
|
|
12
|
+
};
|
|
13
|
+
/** Props of {@link BasemapHeatmapLayer}. */
|
|
14
|
+
export type BasemapHeatmapLayerProps<DataT = HeatmapPoint> = {
|
|
15
|
+
data: DataT[];
|
|
16
|
+
/** The longitude/latitude of a point. */
|
|
17
|
+
getPosition?: Accessor<DataT, [number, number]>;
|
|
18
|
+
/** `heatmap-weight`: a point's share of the density. */
|
|
19
|
+
getWeight?: Accessor<DataT, number>;
|
|
20
|
+
/** `heatmap-radius`, in pixels. */
|
|
21
|
+
getRadius?: Accessor<DataT, number>;
|
|
22
|
+
/** `heatmap-intensity`: multiplies the density of every point. */
|
|
23
|
+
intensity?: number;
|
|
24
|
+
/**
|
|
25
|
+
* `heatmap-color`, as `COLOR_RAMP_SIZE` premultiplied RGBA texels, from density 0 to 1 (see
|
|
26
|
+
* `getHeatmapColorRamp`). The layer's `opacity` is `heatmap-opacity`.
|
|
27
|
+
*/
|
|
28
|
+
colorRamp: Uint8Array;
|
|
29
|
+
};
|
|
30
|
+
type DensityTarget = {
|
|
31
|
+
framebuffer: Framebuffer;
|
|
32
|
+
texture: Texture;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Draws a `heatmap` style layer as MapLibre GL JS does: each point adds a Gaussian kernel to a
|
|
36
|
+
* density texture a quarter of the drawing buffer's size, with additive blending, and the density
|
|
37
|
+
* is then colored by `heatmap-color` over the whole view. Kernels are on the map plane: on a globe
|
|
38
|
+
* they lie on the sphere, and in a projected view on the plane of the view's projection. WebGL
|
|
39
|
+
* only; on WebGPU the layer draws nothing.
|
|
40
|
+
*/
|
|
41
|
+
export declare class BasemapHeatmapLayer<DataT = HeatmapPoint> extends Layer<Required<BasemapHeatmapLayerProps<DataT>> & LayerProps> {
|
|
42
|
+
static layerName: string;
|
|
43
|
+
static defaultProps: DefaultProps<BasemapHeatmapLayerProps<any>>;
|
|
44
|
+
state: {
|
|
45
|
+
model?: Model;
|
|
46
|
+
compositeModel?: Model;
|
|
47
|
+
colorRampTexture?: Texture;
|
|
48
|
+
/** The density texture of each view, by viewport id. */
|
|
49
|
+
densityTargets: Map<string, DensityTarget>;
|
|
50
|
+
densityFormat: 'rgba16float' | 'rgba8unorm';
|
|
51
|
+
};
|
|
52
|
+
getShaders(): any;
|
|
53
|
+
initializeState(): void;
|
|
54
|
+
private getKernelModel;
|
|
55
|
+
updateState(params: UpdateParameters<this>): void;
|
|
56
|
+
finalizeState(context: any): void;
|
|
57
|
+
/** The density texture of the current view, a quarter of its size in device pixels. */
|
|
58
|
+
private getDensityTarget;
|
|
59
|
+
draw({ shaderModuleProps }: any): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `heatmap-color` as `COLOR_RAMP_SIZE` premultiplied RGBA texels, as MapLibre GL JS renders the
|
|
63
|
+
* ramp (`renderColorRamp`): the color at density `i / 255`, rounded to 8 bits unpremultiplied and
|
|
64
|
+
* then premultiplied, as WebGL premultiplies the ramp it uploads. The same array is returned while
|
|
65
|
+
* the property is unchanged.
|
|
66
|
+
*/
|
|
67
|
+
export declare function getHeatmapColorRamp(styleLayer: BasemapStyleLayer): Uint8Array;
|
|
68
|
+
type TileIndex = {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
z: number;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The points of a tile's features (each point of a multipoint) that lie in the tile, with their
|
|
75
|
+
* longitude/latitude. A tile's features include a buffer around it, which its neighbors also hold;
|
|
76
|
+
* MapLibre GL JS leaves out the points outside a tile, so that each point adds to the density once.
|
|
77
|
+
* `features` are tile-local, from 0 to 1 across the tile, or in longitude/latitude with `lngLat`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function getHeatmapPoints(features: any[], index: TileIndex, lngLat: boolean): HeatmapPoint[];
|
|
80
|
+
/**
|
|
81
|
+
* The tiles of `tiles` that no other tile of `tiles` covers. Where a tile and its ancestor are both
|
|
82
|
+
* drawn, as while the tile's siblings load, MapLibre GL JS draws the heatmap of the ancestor only.
|
|
83
|
+
*/
|
|
84
|
+
export declare function getTilesWithoutDrawnAncestor<T extends {
|
|
85
|
+
index: TileIndex;
|
|
86
|
+
}>(tiles: T[]): T[];
|
|
87
|
+
/**
|
|
88
|
+
* The layer of a `heatmap` style layer, drawing the points of all of its run's drawn tiles (see
|
|
89
|
+
* `getHeatmapPoints`). `heatmap-radius` and `heatmap-weight` are evaluated per feature;
|
|
90
|
+
* `heatmap-intensity` and `heatmap-opacity` at the style zoom. Nothing is drawn at
|
|
91
|
+
* `heatmap-opacity: 0`, as in MapLibre GL JS.
|
|
92
|
+
*/
|
|
93
|
+
export declare function createHeatmapSubLayer({ props, styleLayer, points, zoom }: {
|
|
94
|
+
props: Record<string, any>;
|
|
95
|
+
styleLayer: BasemapStyleLayer;
|
|
96
|
+
points: HeatmapPoint[];
|
|
97
|
+
zoom: number;
|
|
98
|
+
}): BasemapHeatmapLayer | null;
|
|
99
|
+
export {};
|
|
@@ -1,6 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Portions of this file are adapted from MapLibre GL JS v6.13.0,
|
|
4
|
+
* src/shaders/glsl/hillshade.fragment.glsl and hillshade_prepare.fragment.glsl,
|
|
5
|
+
* under these licenses (see also THIRD-PARTY-NOTICES.md):
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2023, MapLibre contributors
|
|
8
|
+
*
|
|
9
|
+
* All rights reserved.
|
|
10
|
+
*
|
|
11
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
|
12
|
+
* are permitted provided that the following conditions are met:
|
|
13
|
+
*
|
|
14
|
+
* * Redistributions of source code must retain the above copyright notice,
|
|
15
|
+
* this list of conditions and the following disclaimer.
|
|
16
|
+
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
17
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
18
|
+
* and/or other materials provided with the distribution.
|
|
19
|
+
* * Neither the name of MapLibre GL JS nor the names of its contributors
|
|
20
|
+
* may be used to endorse or promote products derived from this software
|
|
21
|
+
* without specific prior written permission.
|
|
22
|
+
*
|
|
23
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
24
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
25
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
26
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
27
|
+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
28
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
29
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
30
|
+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
31
|
+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
32
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
33
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
+
*
|
|
35
|
+
* MapLibre GL JS contains code from mapbox-gl-js v1.13 and earlier, licensed under a
|
|
36
|
+
* BSD-3-Clause license:
|
|
37
|
+
*
|
|
38
|
+
* Copyright (c) 2020, Mapbox
|
|
39
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
|
40
|
+
* are permitted provided that the following conditions are met:
|
|
41
|
+
*
|
|
42
|
+
* * Redistributions of source code must retain the above copyright notice,
|
|
43
|
+
* this list of conditions and the following disclaimer.
|
|
44
|
+
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
45
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
46
|
+
* and/or other materials provided with the distribution.
|
|
47
|
+
* * Neither the name of Mapbox GL JS nor the names of its contributors
|
|
48
|
+
* may be used to endorse or promote products derived from this software
|
|
49
|
+
* without specific prior written permission.
|
|
50
|
+
*
|
|
51
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
52
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
53
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
54
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
55
|
+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
56
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
57
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
58
|
+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
59
|
+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
60
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
61
|
+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
62
|
+
*/
|
|
1
63
|
import type { Layer, LayersList, UpdateParameters } from '@deck.gl/core';
|
|
2
|
-
import { SharedTile2DLayer, SharedTileset2D } from '@deck.gl-community/geo-layers';
|
|
3
|
-
import type { SharedTile2DLayerProps, SharedTileset2DProps } from '@deck.gl-community/geo-layers';
|
|
64
|
+
import { SharedTile2DLayer, SharedTileset2D } from '@deck.gl-community/layers/geo-layers';
|
|
65
|
+
import type { SharedTile2DLayerProps, SharedTileset2DProps } from '@deck.gl-community/layers/geo-layers';
|
|
4
66
|
import type { BasemapLoadOptions, BasemapSource } from "./style-resolver.js";
|
|
5
67
|
/**
|
|
6
68
|
* `hillshade` style layers over `raster-dem` sources, drawn as MapLibre GL JS draws them.
|
|
@@ -30,6 +92,12 @@ export declare function decodeDemTile(pixels: ArrayLike<number>, width: number,
|
|
|
30
92
|
* where it is not loaded.
|
|
31
93
|
*/
|
|
32
94
|
export type DemNeighbors = (dx: number, dy: number) => DemTile | null;
|
|
95
|
+
/**
|
|
96
|
+
* The elevation at a pixel `(x, y)` of a DEM tile or of a border around it, up to one tile wide.
|
|
97
|
+
* Pixels past the tile's edges come from its loaded neighbors (of the same size), and where a
|
|
98
|
+
* neighbor is missing, from the tile's nearest edge pixel, as MapLibre GL JS backfills them.
|
|
99
|
+
*/
|
|
100
|
+
export declare function getBorderedElevations(dem: DemTile, getNeighbor: DemNeighbors): (x: number, y: number) => number;
|
|
33
101
|
/**
|
|
34
102
|
* The slope texture of MapLibre GL JS's hillshade "prepare" pass, `dim + 2` pixels square: the
|
|
35
103
|
* tile and a one-pixel border, RGBA, with the scaled east-west and north-south slopes in red and
|
|
@@ -37,9 +105,16 @@ export type DemNeighbors = (dx: number, dy: number) => DemTile | null;
|
|
|
37
105
|
* neighbor is missing, from the tile's nearest edge pixel, as MapLibre fills them.
|
|
38
106
|
*
|
|
39
107
|
* `zoom` is the tile's zoom, also where it is scaled up past its source's `maxzoom`. MapLibre
|
|
40
|
-
* scales the slopes by it, and exaggerates them below zoom 15.
|
|
108
|
+
* scales the slopes by it, and exaggerates them below zoom 15. `bodyRadius` is the radius, in
|
|
109
|
+
* meters, of the body the tile covers (see `getBodyRadius`): a tile pixel spans less ground on a
|
|
110
|
+
* smaller body, so the same elevations make steeper slopes. The default is the Earth's, as MapLibre.
|
|
111
|
+
*/
|
|
112
|
+
export declare function prepareHillshadeTexture(dem: DemTile, zoom: number, getNeighbor?: DemNeighbors, bodyRadius?: number): Uint8ClampedArray<ArrayBuffer>;
|
|
113
|
+
/**
|
|
114
|
+
* The radius, in meters, of the body a viewport draws: in a projected view the semi-major axis of
|
|
115
|
+
* its CRS, which can be the Moon or Mars, and otherwise the Earth's.
|
|
41
116
|
*/
|
|
42
|
-
export declare function
|
|
117
|
+
export declare function getBodyRadius(viewport: unknown): number;
|
|
43
118
|
/** The most light sources the shader takes. MapLibre takes any number. */
|
|
44
119
|
export declare const MAX_HILLSHADE_LIGHTS = 4;
|
|
45
120
|
/** A hillshade layer's paint, evaluated and ready for the shader (but for the map's bearing). */
|
|
@@ -83,45 +158,111 @@ export type HillshadeUniforms = {
|
|
|
83
158
|
* anchored to the viewport, and the tile's latitude range `[north, south]`.
|
|
84
159
|
*/
|
|
85
160
|
export declare function getHillshadeUniforms(parameters: HillshadeParameters, bearing: number, latRange: [number, number]): HillshadeUniforms;
|
|
161
|
+
/**
|
|
162
|
+
* The blending of the hillshade's premultiplied colors, as MapLibre blends them (and as
|
|
163
|
+
* `RASTER_COLOR_BLEND_PARAMETERS`).
|
|
164
|
+
*/
|
|
165
|
+
export declare const PREMULTIPLIED_BLEND_PARAMETERS: {
|
|
166
|
+
readonly blendColorOperation: "add";
|
|
167
|
+
readonly blendColorSrcFactor: "one";
|
|
168
|
+
readonly blendColorDstFactor: "one-minus-src-alpha";
|
|
169
|
+
readonly blendAlphaOperation: "add";
|
|
170
|
+
readonly blendAlphaSrcFactor: "one";
|
|
171
|
+
readonly blendAlphaDstFactor: "one-minus-src-alpha";
|
|
172
|
+
};
|
|
86
173
|
/**
|
|
87
174
|
* Fetches and decodes a DEM tile. Colors are read as stored, without color space conversion or
|
|
88
|
-
* premultiplication, which would change the elevations
|
|
175
|
+
* premultiplication, which would change the elevations, and without the noise that some browsers
|
|
176
|
+
* add to canvas reads (see `readDemPixels`). An empty response is a tile without data.
|
|
89
177
|
*/
|
|
90
178
|
export declare function loadDemTile(url: string, unpack: DemUnpackVector, { signal, loadOptions }?: {
|
|
91
179
|
signal?: AbortSignal;
|
|
92
180
|
loadOptions?: BasemapLoadOptions;
|
|
93
181
|
}): Promise<DemTile | null>;
|
|
182
|
+
type TileIndex = {
|
|
183
|
+
x: number;
|
|
184
|
+
y: number;
|
|
185
|
+
z: number;
|
|
186
|
+
};
|
|
187
|
+
/** A tile of a `raster-dem` source's tileset. */
|
|
188
|
+
export type DemTileHeader = {
|
|
189
|
+
id: string;
|
|
190
|
+
index: TileIndex;
|
|
191
|
+
bbox: unknown;
|
|
192
|
+
content: DemTile | null;
|
|
193
|
+
isLoaded: boolean;
|
|
194
|
+
};
|
|
94
195
|
/**
|
|
95
196
|
* Creates the tileset of a `raster-dem` source: each tile is fetched and decoded once, and shared
|
|
96
|
-
* by every `
|
|
197
|
+
* by every `DemTileLayer` drawn from it, as the tiles of a vector source are shared by its
|
|
97
198
|
* style runs. `tilesetProps` are the source's tile pyramid (see `getTilePyramidProps`).
|
|
98
199
|
*/
|
|
99
200
|
export declare function createSharedDemTileset(source: BasemapSource, loadOptions: BasemapLoadOptions | undefined, tilesetProps?: Partial<SharedTileset2DProps<DemTile | null>>): SharedTileset2D<DemTile | null>;
|
|
100
201
|
/**
|
|
101
|
-
* A tileset shared by the `
|
|
102
|
-
*
|
|
202
|
+
* A tileset shared by the `DemTileLayer`s of one `raster-dem` source, finalized when the last of
|
|
203
|
+
* them is. `BasemapLayer` owns its sources' tilesets itself; this is for the layers that
|
|
103
204
|
* `getBasemapLayers` creates without it.
|
|
104
205
|
*/
|
|
105
206
|
export type DemTilesetOwner = {
|
|
106
207
|
tileset: SharedTileset2D;
|
|
107
208
|
consumers: Set<object>;
|
|
108
209
|
};
|
|
210
|
+
/** Props of a `DemTileLayer`. */
|
|
211
|
+
export type DemTileLayerProps = SharedTile2DLayerProps<DemTile | null> & {
|
|
212
|
+
/** The owner of a shared `data` tileset that the layer releases when finalized. */
|
|
213
|
+
demTilesetOwner?: DemTilesetOwner | null;
|
|
214
|
+
};
|
|
215
|
+
/** The loaded neighbors of a DEM tile, and a key that changes when a neighbor loads. */
|
|
216
|
+
export type DemTileNeighbors = {
|
|
217
|
+
getNeighbor: DemNeighbors;
|
|
218
|
+
key: string;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* The tiles of a `raster-dem` source, drawn by one style layer (`hillshade` or `color-relief`).
|
|
222
|
+
* The decoded tiles come from the source's tileset, shared with the source's other such layers
|
|
223
|
+
* (see `createSharedDemTileset`). A tile is drawn from its elevations and the edge pixels of its
|
|
224
|
+
* loaded neighbors, so that tiles join without seams: when a tile loads, its neighbors are drawn
|
|
225
|
+
* again.
|
|
226
|
+
*/
|
|
227
|
+
export declare abstract class DemTileLayer<PropsT extends DemTileLayerProps = DemTileLayerProps> extends SharedTile2DLayer<DemTile | null, PropsT> {
|
|
228
|
+
static layerName: string;
|
|
229
|
+
static defaultProps: {
|
|
230
|
+
demTilesetOwner: {
|
|
231
|
+
type: string;
|
|
232
|
+
value: null;
|
|
233
|
+
compare: boolean;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
state: SharedTile2DLayer<DemTile | null>['state'] & {
|
|
237
|
+
demTilesetOwner?: DemTilesetOwner;
|
|
238
|
+
/** Stands for this layer among an owner's consumers. */
|
|
239
|
+
demTilesetConsumer?: object;
|
|
240
|
+
};
|
|
241
|
+
updateState(params: UpdateParameters<this>): void;
|
|
242
|
+
finalizeState(): void;
|
|
243
|
+
private releaseDemTileset;
|
|
244
|
+
/** Tile traversal that also selects tiles in a projected view (see `basemapTilesetAdapter`). */
|
|
245
|
+
_getTilesetOptions(): SharedTileset2DProps<DemTile | null>;
|
|
246
|
+
/**
|
|
247
|
+
* In a projected view, tiles are not culled by the longitude/latitude box of the screen corners:
|
|
248
|
+
* a corner can lie outside the projection, and the tile selection has tested each tile already.
|
|
249
|
+
*/
|
|
250
|
+
filterSubLayer(context: any): boolean;
|
|
251
|
+
_onTileLoad(tile: any): void;
|
|
252
|
+
/** The loaded neighbors of a tile, which wrap around the antimeridian. */
|
|
253
|
+
protected getDemNeighbors(tile: DemTileHeader): DemTileNeighbors;
|
|
254
|
+
}
|
|
109
255
|
/** Props of a `HillshadeTileLayer`. */
|
|
110
|
-
export type HillshadeTileLayerProps =
|
|
256
|
+
export type HillshadeTileLayerProps = DemTileLayerProps & {
|
|
111
257
|
hillshadeParameters: HillshadeParameters;
|
|
112
258
|
/** Extra props of every tile's bitmap layer, such as `parameters`. */
|
|
113
259
|
hillshadeSubLayerProps?: Record<string, unknown>;
|
|
114
|
-
/** The owner of a shared `data` tileset that the layer releases when finalized. */
|
|
115
|
-
demTilesetOwner?: DemTilesetOwner | null;
|
|
116
260
|
};
|
|
117
261
|
/**
|
|
118
|
-
* The tiles of a `raster-dem` source, shaded by one `hillshade` style layer
|
|
119
|
-
*
|
|
120
|
-
* `createSharedDemTileset`); the slopes and the shading are the layer's own. Each tile's slopes are
|
|
121
|
-
* prepared from its elevations and those of its loaded neighbors, so that tiles join without
|
|
122
|
-
* seams. Draws nothing on WebGPU: the shader is GLSL.
|
|
262
|
+
* The tiles of a `raster-dem` source, shaded by one `hillshade` style layer (see `DemTileLayer`).
|
|
263
|
+
* Each tile's slopes are prepared from its elevations and those of its loaded neighbors.
|
|
123
264
|
*/
|
|
124
|
-
export declare class HillshadeTileLayer extends
|
|
265
|
+
export declare class HillshadeTileLayer extends DemTileLayer<HillshadeTileLayerProps> {
|
|
125
266
|
static layerName: string;
|
|
126
267
|
static defaultProps: {
|
|
127
268
|
hillshadeParameters: {
|
|
@@ -140,15 +281,6 @@ export declare class HillshadeTileLayer extends SharedTile2DLayer<DemTile | null
|
|
|
140
281
|
compare: boolean;
|
|
141
282
|
};
|
|
142
283
|
};
|
|
143
|
-
state: SharedTile2DLayer<DemTile | null>['state'] & {
|
|
144
|
-
demTilesetOwner?: DemTilesetOwner;
|
|
145
|
-
/** Stands for this layer among an owner's consumers. */
|
|
146
|
-
demTilesetConsumer?: object;
|
|
147
|
-
};
|
|
148
|
-
updateState(params: UpdateParameters<this>): void;
|
|
149
|
-
finalizeState(): void;
|
|
150
|
-
private releaseDemTileset;
|
|
151
|
-
_onTileLoad(tile: any): void;
|
|
152
|
-
renderLayers(): Layer | null | LayersList;
|
|
153
284
|
renderSubLayers(props: any): Layer | null | LayersList;
|
|
154
285
|
}
|
|
286
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `icon-text-fit`: an icon stretched to cover its label, and the stretchable images that sprites
|
|
3
|
+
* describe with `stretchX`, `stretchY` and `content`, laid out as MapLibre GL JS lays them out
|
|
4
|
+
* (`fitIconToText` and `applyTextFit` in its `symbol/shaping.ts`, `getIconQuads` in
|
|
5
|
+
* `symbol/quads.ts`). Boxes are in CSS pixels from the symbol's anchor, y down.
|
|
6
|
+
*/
|
|
7
|
+
/** `icon-text-fit`: which sides of the label the icon is stretched to. */
|
|
8
|
+
export type IconTextFit = 'none' | 'width' | 'height' | 'both';
|
|
9
|
+
/** `textFitWidth` / `textFitHeight` of a sprite image. */
|
|
10
|
+
export type ImageTextFit = 'stretchOrShrink' | 'stretchOnly' | 'proportional';
|
|
11
|
+
/** A box in pixels from the symbol's anchor, y down. */
|
|
12
|
+
export type SymbolBox = {
|
|
13
|
+
left: number;
|
|
14
|
+
top: number;
|
|
15
|
+
right: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The size and stretch metadata of a sprite image, as its JSON index gives them: sizes and zones
|
|
20
|
+
* in image pixels, which are `pixelRatio` per CSS pixel.
|
|
21
|
+
*/
|
|
22
|
+
export type StretchableImage = {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
pixelRatio: number;
|
|
26
|
+
/** Ranges `[x1, x2]` of image columns that stretch. */
|
|
27
|
+
stretchX?: [number, number][];
|
|
28
|
+
/** Ranges `[y1, y2]` of image rows that stretch. */
|
|
29
|
+
stretchY?: [number, number][];
|
|
30
|
+
/** `[x1, y1, x2, y2]`: the part of the image that the label covers. */
|
|
31
|
+
content?: [number, number, number, number];
|
|
32
|
+
textFitWidth?: ImageTextFit;
|
|
33
|
+
textFitHeight?: ImageTextFit;
|
|
34
|
+
};
|
|
35
|
+
/** An icon box fitted to its label, and how much of the image lies outside it (see `content`). */
|
|
36
|
+
export type FittedIcon = SymbolBox & {
|
|
37
|
+
/** CSS pixels of the image outside `content`: left, top, right, bottom. */
|
|
38
|
+
collisionPadding?: [number, number, number, number];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* One rectangle of a stretched icon, drawn from one part of its image. Its corners are
|
|
42
|
+
* `em * max(minScale, iconSize) + px` (see {@link getIconQuadBox}): the `em` part stretches with
|
|
43
|
+
* the label and scales with `icon-size`, the `px` part keeps the fixed zones at their size.
|
|
44
|
+
*/
|
|
45
|
+
export type IconQuad = {
|
|
46
|
+
/** The part of the image, in image pixels from its top left corner. */
|
|
47
|
+
image: {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
};
|
|
53
|
+
em: SymbolBox;
|
|
54
|
+
px: SymbolBox;
|
|
55
|
+
/** The least scale of `em` on each axis, so that the stretched zones never shrink below zero. */
|
|
56
|
+
minScale: [number, number];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* MapLibre's `fitIconToText`: the box of an icon stretched to the box of its label, padded by
|
|
60
|
+
* `icon-text-fit-padding` (`[top, right, bottom, left]`), and moved by `icon-offset`. On an axis it
|
|
61
|
+
* is not stretched along, the icon keeps its size, centered on the label. `icon-anchor` is not
|
|
62
|
+
* read. The box is at `icon-size` 1; {@link getIconQuads} and {@link getFittedIconCollisionBox}
|
|
63
|
+
* scale it.
|
|
64
|
+
*/
|
|
65
|
+
export declare function fitIconToText(image: StretchableImage, text: SymbolBox, textFit: IconTextFit, padding: readonly number[], iconOffset: readonly number[]): FittedIcon;
|
|
66
|
+
/**
|
|
67
|
+
* MapLibre's `applyTextFit`: a fitted icon box widened or heightened to keep the aspect ratio of
|
|
68
|
+
* its image's `content`, as the image's `textFitWidth` / `textFitHeight` ask. Only for images with
|
|
69
|
+
* `content` and one of them.
|
|
70
|
+
*/
|
|
71
|
+
export declare function applyTextFit(image: StretchableImage, icon: SymbolBox): SymbolBox;
|
|
72
|
+
/**
|
|
73
|
+
* MapLibre's `getIconQuads` for an icon fitted with {@link fitIconToText}: the rectangles that draw
|
|
74
|
+
* it. An image without stretch zones is one rectangle, its `content` (or all of it) stretched over
|
|
75
|
+
* the box. An image with `stretchX` / `stretchY` is cut at the zones' edges: the stretched zones
|
|
76
|
+
* share what the box adds, and the fixed zones keep their size. Empty rectangles are left out.
|
|
77
|
+
*/
|
|
78
|
+
export declare function getIconQuads(image: StretchableImage, fitted: FittedIcon): IconQuad[];
|
|
79
|
+
/** Where a quad is drawn at `icon-size`, as MapLibre's icon shader places its corners. */
|
|
80
|
+
export declare function getIconQuadBox(quad: IconQuad, iconSize: number): SymbolBox;
|
|
81
|
+
/**
|
|
82
|
+
* The collision box of a fitted icon, `[x1, y1, x2, y2]`, as MapLibre's `CollisionFeature` makes
|
|
83
|
+
* it: the fitted box at `icon-size`, padded by `icon-padding` (`[top, right, bottom, left]`), and
|
|
84
|
+
* widened by the image outside its `content`.
|
|
85
|
+
*/
|
|
86
|
+
export declare function getFittedIconCollisionBox(image: StretchableImage, fitted: FittedIcon, iconSize: number, padding: readonly number[]): [number, number, number, number];
|
|
87
|
+
/**
|
|
88
|
+
* Whether a sprite image's stretch metadata is valid, as MapLibre's image manager checks it: zones
|
|
89
|
+
* in order, each inside the image, and `content` inside the image with its corners in order.
|
|
90
|
+
* MapLibre does not draw an image that fails.
|
|
91
|
+
*/
|
|
92
|
+
export declare function isValidStretchMetadata(image: StretchableImage): boolean;
|