@tangram.gl/basemap-layers 0.0.0-stage → 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -2
- package/THIRD-PARTY-NOTICES.md +205 -0
- package/dist/geojson-worker.js +2160 -0
- package/dist/geojson-worker.js.map +6 -0
- package/dist/index.cjs +11388 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.js +11369 -0
- package/dist/index.js.map +6 -0
- package/dist/map-style.cjs +445 -0
- package/dist/map-style.cjs.map +6 -0
- package/dist/map-style.js +431 -0
- package/dist/map-style.js.map +6 -0
- package/dist/types/arabic-shaping.d.ts +7 -0
- package/dist/types/atmosphere-layer.d.ts +10 -0
- package/dist/types/basemap-layer.d.ts +150 -0
- package/dist/types/bidi.d.ts +8 -0
- package/dist/types/circle-layer.d.ts +49 -0
- package/dist/types/fill-extrusion-lighting-extension.d.ts +49 -0
- package/dist/types/fill-outline-extension.d.ts +22 -0
- package/dist/types/fill-pattern.d.ts +99 -0
- package/dist/types/fill-style-extensions.d.ts +100 -0
- package/dist/types/geojson-source.d.ts +29 -0
- package/dist/types/geojson-tiler.d.ts +48 -0
- package/dist/types/geojson-worker.d.ts +40 -0
- package/dist/types/globe-horizon-extension.d.ts +61 -0
- package/dist/types/globe-layers.d.ts +239 -0
- package/dist/types/globe-line-angle-extension.d.ts +37 -0
- package/dist/types/glyph-font-renderer.d.ts +37 -0
- package/dist/types/glyph-pbf.d.ts +37 -0
- package/dist/types/glyph-store.d.ts +103 -0
- package/dist/types/grid-index.d.ts +47 -0
- package/dist/types/hillshade-layer.d.ts +154 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/is-globe-viewport.d.ts +2 -0
- package/dist/types/label-font-renderer.d.ts +18 -0
- package/dist/types/label-placement.d.ts +247 -0
- package/dist/types/label-text-layer.d.ts +231 -0
- package/dist/types/line-blur-extension.d.ts +73 -0
- package/dist/types/line-glyphs.d.ts +60 -0
- package/dist/types/line-placement.d.ts +93 -0
- package/dist/types/map-style-loader.d.ts +48 -0
- package/dist/types/map-style-schema.d.ts +72 -0
- package/dist/types/map-style.d.ts +6 -0
- package/dist/types/mapbox-style.d.ts +40 -0
- package/dist/types/mvt-label-layer.d.ts +923 -0
- package/dist/types/polylabel.d.ts +17 -0
- package/dist/types/raster-color-extension.d.ts +146 -0
- package/dist/types/shared-texture.d.ts +34 -0
- package/dist/types/sort-key.d.ts +10 -0
- package/dist/types/sprite.d.ts +82 -0
- package/dist/types/style-accessor.d.ts +45 -0
- package/dist/types/style-expression.d.ts +83 -0
- package/dist/types/style-resolver.d.ts +94 -0
- package/dist/types/text-font.d.ts +36 -0
- package/dist/types/text-halo-blur-extension.d.ts +55 -0
- package/dist/types/text-layout.d.ts +71 -0
- package/dist/types/util.d.ts +22 -0
- package/dist/types/zoom-paint-extension.d.ts +72 -0
- package/package.json +80 -3
- package/src/arabic-shaping.ts +366 -0
- package/src/atmosphere-layer.ts +19 -0
- package/src/basemap-layer.ts +533 -0
- package/src/bidi.ts +199 -0
- package/src/circle-layer.ts +191 -0
- package/src/fill-extrusion-lighting-extension.ts +206 -0
- package/src/fill-outline-extension.ts +70 -0
- package/src/fill-pattern.ts +400 -0
- package/src/fill-style-extensions.ts +177 -0
- package/src/geojson-source.ts +318 -0
- package/src/geojson-tiler.ts +185 -0
- package/src/geojson-worker.ts +98 -0
- package/src/globe-horizon-extension.ts +64 -0
- package/src/globe-layers.ts +3487 -0
- package/src/globe-line-angle-extension.ts +131 -0
- package/src/glyph-font-renderer.ts +173 -0
- package/src/glyph-pbf.ts +164 -0
- package/src/glyph-store.ts +326 -0
- package/src/grid-index.ts +177 -0
- package/src/hillshade-layer.ts +775 -0
- package/src/index.ts +18 -0
- package/src/is-globe-viewport.ts +24 -0
- package/src/label-font-renderer.ts +159 -0
- package/src/label-placement.ts +727 -0
- package/src/label-text-layer.ts +913 -0
- package/src/line-blur-extension.ts +237 -0
- package/src/line-glyphs.ts +364 -0
- package/src/line-placement.ts +446 -0
- package/src/map-style-loader.ts +56 -0
- package/src/map-style-schema.ts +83 -0
- package/src/map-style.ts +23 -0
- package/src/mapbox-style.ts +168 -0
- package/src/mvt-label-layer.ts +3744 -0
- package/src/polylabel.ts +312 -0
- package/src/raster-color-extension.ts +245 -0
- package/src/shared-texture.ts +153 -0
- package/src/sort-key.ts +63 -0
- package/src/sprite.ts +244 -0
- package/src/style-accessor.ts +95 -0
- package/src/style-expression.ts +327 -0
- package/src/style-resolver.ts +301 -0
- package/src/text-font.ts +150 -0
- package/src/text-halo-blur-extension.ts +115 -0
- package/src/text-layout.ts +441 -0
- package/src/util.ts +47 -0
- package/src/zoom-paint-extension.ts +207 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LayerExtension } from '@deck.gl/core';
|
|
2
|
+
import type { Layer } from '@deck.gl/core';
|
|
3
|
+
/** A style's `light`, evaluated at one zoom. */
|
|
4
|
+
export type FillExtrusionLight = {
|
|
5
|
+
/** Whether the light turns with the map (`map`) or stays fixed on the screen (`viewport`). */
|
|
6
|
+
anchor: 'map' | 'viewport';
|
|
7
|
+
/** Radial coordinate, azimuthal angle and polar angle, in degrees, as in the style spec. */
|
|
8
|
+
position: [number, number, number];
|
|
9
|
+
/** RGB in 0-1. */
|
|
10
|
+
color: [number, number, number];
|
|
11
|
+
/** 0-1. */
|
|
12
|
+
intensity: number;
|
|
13
|
+
};
|
|
14
|
+
/** The style spec's default `light`. */
|
|
15
|
+
export declare const DEFAULT_FILL_EXTRUSION_LIGHT: FillExtrusionLight;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the light vector that deck.gl's normals, in common space (x east, y north, z up), are
|
|
18
|
+
* shaded against, as MapLibre GL JS shades its own. MapLibre takes the light's spherical position
|
|
19
|
+
* in tile coordinates (y south) and turns it by the map's bearing when the light is anchored to
|
|
20
|
+
* the viewport. It keeps the light's radial length, which it does not normalize. Its wall normals
|
|
21
|
+
* point into the buildings: `_generateSideFaces` takes the perpendicular `(-y, x)` of each edge
|
|
22
|
+
* of a ring that is clockwise in tile coordinates. deck.gl's point out, so the horizontal part of
|
|
23
|
+
* the light is reversed for them: x is negated, and y, negated from tile to common space, is
|
|
24
|
+
* negated back.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getFillExtrusionLightDirection(light: FillExtrusionLight, bearing: number): [number, number, number];
|
|
27
|
+
/**
|
|
28
|
+
* Shades the extruded `SolidPolygonLayer`s of a layer as MapLibre GL JS shades `fill-extrusion`,
|
|
29
|
+
* from the style's `light` (`fillExtrusionLight`) and `fill-extrusion-vertical-gradient`
|
|
30
|
+
* (`fillExtrusionVerticalGradient`), instead of with deck.gl's lights, which it turns off for the
|
|
31
|
+
* layer at every draw. A light anchored to the viewport turns with the viewport's bearing, which is
|
|
32
|
+
* read at every draw. On a globe, the light is placed relative to
|
|
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.
|
|
36
|
+
*/
|
|
37
|
+
export declare class FillExtrusionLightingExtension extends LayerExtension {
|
|
38
|
+
static extensionName: string;
|
|
39
|
+
static defaultProps: {
|
|
40
|
+
fillExtrusionLight: {
|
|
41
|
+
type: string;
|
|
42
|
+
value: FillExtrusionLight;
|
|
43
|
+
};
|
|
44
|
+
fillExtrusionVerticalGradient: boolean;
|
|
45
|
+
};
|
|
46
|
+
isEnabled(layer: Layer): boolean;
|
|
47
|
+
getShaders(this: Layer, extension: this): any;
|
|
48
|
+
draw(this: Layer<any>, params: any, extension: this): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { LayerExtension } from '@deck.gl/core';
|
|
2
|
+
import type { Layer } from '@deck.gl/core';
|
|
3
|
+
import type { ShaderModule } from '@luma.gl/shadertools';
|
|
4
|
+
/**
|
|
5
|
+
* Draws the `PathLayer`s of a fill's outline (`fill-outline-color`) as MapLibre GL JS draws it: as
|
|
6
|
+
* `gl.LINES`, which draw each segment on its own, one pixel across the axis it crosses most
|
|
7
|
+
* steeply. deck.gl's 1 pixel stroke covers more pixels than that on diagonals, and its joins draw
|
|
8
|
+
* past the corners of short segments, so outlines came out darker and wider than MapLibre's. The
|
|
9
|
+
* stroke, drawn without antialiasing, is cut to the pixels a line draws: those within half a pixel
|
|
10
|
+
* of the segment along that axis, and not in the joins. MapLibre's shader also fades each pixel
|
|
11
|
+
* with its distance from the line (`fill_outline.fragment.glsl`); its outlines in Chrome have the
|
|
12
|
+
* colors of unfaded pixels, and so do these. Other sublayers are left unchanged. WebGL only; on
|
|
13
|
+
* WebGPU the outline draws as a stroke.
|
|
14
|
+
*/
|
|
15
|
+
export declare class FillOutlineExtension extends LayerExtension {
|
|
16
|
+
static extensionName: string;
|
|
17
|
+
getShaders(this: Layer): {
|
|
18
|
+
modules?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
modules: ShaderModule[];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type StyleFeature } from "./style-expression.js";
|
|
2
|
+
import { type SpriteAtlas, type SpriteIconMappingEntry } from "./sprite.js";
|
|
3
|
+
type StyleLayerLike = {
|
|
4
|
+
paint?: Record<string, unknown>;
|
|
5
|
+
layout?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
/** The features of a patterned fill whose images come from one sprite. */
|
|
8
|
+
export type FillPatternGroup = {
|
|
9
|
+
atlas: SpriteAtlas;
|
|
10
|
+
/** The atlas's index in the style's sprite list, unique per group. */
|
|
11
|
+
atlasIndex: number;
|
|
12
|
+
features: any[];
|
|
13
|
+
/** The image name in the atlas's mapping, for every feature or per feature. */
|
|
14
|
+
getFillPattern: string | ((feature: StyleFeature) => string);
|
|
15
|
+
/** The image's pixel ratio, device pixels per CSS pixel, for every feature or per feature. */
|
|
16
|
+
getPixelRatio: number | ((feature: StyleFeature) => number);
|
|
17
|
+
/** The names of the group's images, sorted. */
|
|
18
|
+
names: string[];
|
|
19
|
+
/** The group's pattern atlas, made on first use and released with the group. */
|
|
20
|
+
patternAtlas?: PatternAtlas;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Splits a patterned fill's features by the sprite their `fill-pattern` image is in. Features
|
|
24
|
+
* whose image is in no loaded sprite draw nothing, as in MapLibre GL JS. `fill-pattern` is
|
|
25
|
+
* evaluated at the integer zoom, as the style spec does for cross-faded properties.
|
|
26
|
+
*
|
|
27
|
+
* Returns no groups while the sprites load (`null`) or when the layer has no `fill-pattern`. A
|
|
28
|
+
* pattern that does not depend on feature data keeps the tile's feature array, so deck.gl does not
|
|
29
|
+
* re-tessellate the features at a new zoom step; per-feature groups are cached per tile, style
|
|
30
|
+
* layer, sprite list and zoom.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getFillPatternGroups(features: any[], styleLayer: StyleLayerLike, zoom: number, spriteAtlases: SpriteAtlas[] | null | undefined): FillPatternGroup[];
|
|
33
|
+
type PatternAtlas = {
|
|
34
|
+
image: SpriteAtlas['image'] | OffscreenCanvas | HTMLCanvasElement | ImageData;
|
|
35
|
+
mapping: Record<string, SpriteIconMappingEntry>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* An atlas of the named sprite images for a pattern, each with a 1 pixel border copied from its
|
|
39
|
+
* opposite edge, as MapLibre GL JS pads its pattern atlas. A sprite packs its images edge to edge,
|
|
40
|
+
* so a linear filter at an image's edge would blend in the next image and draw a seam between the
|
|
41
|
+
* repeats; with the border, it blends in the image's own wrapped pixels. The atlas holds only
|
|
42
|
+
* these images, so each fill uploads a small texture instead of the whole sprite. Where the
|
|
43
|
+
* sprite image is a URL, or no canvas is available, it returns the sprite itself.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getPatternAtlas(atlas: SpriteAtlas, names: string[]): PatternAtlas;
|
|
46
|
+
/**
|
|
47
|
+
* The largest width and height of a pattern atlas. WebGL 2 guarantees textures of 2048 pixels; in
|
|
48
|
+
* practice every device that runs it supports 4096, as MapLibre GL JS also assumes for its atlases.
|
|
49
|
+
*/
|
|
50
|
+
export declare const MAX_PATTERN_ATLAS_SIZE = 4096;
|
|
51
|
+
/**
|
|
52
|
+
* Places images with a 1 pixel border on each side in rows no wider than `maxSize`: shelf packing,
|
|
53
|
+
* tallest images first. Returns each image's top left corner, inside its border, and the atlas
|
|
54
|
+
* size, or `null` when the images do not fit in `maxSize` by `maxSize`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function packPatternImages(sizes: {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
}[], maxSize?: number): {
|
|
60
|
+
positions: [number, number][];
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
} | null;
|
|
64
|
+
/**
|
|
65
|
+
* Gives each fully transparent pixel of the rectangle `[left, top, right, bottom)` (the whole
|
|
66
|
+
* image by default) next to a visible one the alpha-weighted average color of its neighbors in
|
|
67
|
+
* the rectangle, keeping it transparent. MapLibre GL JS samples its pattern atlas, which is
|
|
68
|
+
* premultiplied, with a linear filter, so a pattern's edges blend toward transparent in its own
|
|
69
|
+
* color. A canvas uploads unpremultiplied, with transparent pixels black: the filter would blend
|
|
70
|
+
* the edges toward black, and draw light patterns with dark outlines. The image is read back from
|
|
71
|
+
* the canvas so that these colors survive (a canvas keeps none for transparent pixels). It is
|
|
72
|
+
* changed in place, with no copy: only transparent pixels change, and their alpha, which weighs
|
|
73
|
+
* every neighbor's color, stays 0, so no pixel's new color depends on another's.
|
|
74
|
+
*/
|
|
75
|
+
export declare function bleedIntoTransparentPixels({ data, width, height }: ImageData, [left, top, right, bottom]?: number[]): void;
|
|
76
|
+
/**
|
|
77
|
+
* The features of a patterned fill that no group draws, because no loaded sprite has their image.
|
|
78
|
+
* MapLibre GL JS draws no fill for them, but still draws their `fill-outline-color` outline.
|
|
79
|
+
* Cached per list of groups, which `getFillPatternGroups` reuses while its inputs are unchanged.
|
|
80
|
+
*/
|
|
81
|
+
export declare function getFeaturesWithoutPattern(features: any[], groups: FillPatternGroup[]): any[];
|
|
82
|
+
/**
|
|
83
|
+
* `FillPatternExtension` props for a group: the sprite atlas and mapping, and each image repeated
|
|
84
|
+
* at its CSS-pixel size at the integer zoom, as MapLibre GL JS sizes patterns. Between integer
|
|
85
|
+
* zooms the pattern scales with the map, and it steps back at the next integer zoom. The image
|
|
86
|
+
* supplies the colors, so the fill color is only the opacity.
|
|
87
|
+
*/
|
|
88
|
+
export declare function getFillPatternProps(group: FillPatternGroup, zoom: number): {
|
|
89
|
+
fillPatternAtlas: string | OffscreenCanvas | ImageBitmap | HTMLCanvasElement | ImageData;
|
|
90
|
+
fillPatternMapping: Record<string, SpriteIconMappingEntry>;
|
|
91
|
+
fillPatternMask: boolean;
|
|
92
|
+
textureParameters: {
|
|
93
|
+
readonly mipmapFilter: "none";
|
|
94
|
+
};
|
|
95
|
+
fillPatternSizeUnits: "common";
|
|
96
|
+
getFillPattern: string | ((feature: StyleFeature) => string);
|
|
97
|
+
getFillPatternScale: number | ((feature: StyleFeature) => number);
|
|
98
|
+
};
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { LayerExtension } from '@deck.gl/core';
|
|
2
|
+
import type { CompositeLayer, Layer } from '@deck.gl/core';
|
|
3
|
+
import { FillStyleExtension } from '@deck.gl/extensions';
|
|
4
|
+
/** The anchor of `fill-translate`. */
|
|
5
|
+
export type FillTranslateAnchor = 'map' | 'viewport';
|
|
6
|
+
type FillTranslateExtensionProps = {
|
|
7
|
+
/** `fill-translate`: the offset in pixels, x right and y down. */
|
|
8
|
+
fillTranslate?: [number, number];
|
|
9
|
+
/** `fill-translate-anchor`: `'map'` turns the offset with the map, `'viewport'` keeps it on screen. */
|
|
10
|
+
fillTranslateAnchor?: FillTranslateAnchor;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Returns the ground offset of `fill-translate` in pixels, x east and y south, at a map bearing in
|
|
14
|
+
* degrees. A `'viewport'` offset is turned by the bearing, so it keeps its direction on screen,
|
|
15
|
+
* as in MapLibre GL JS.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getFillTranslateOffset(translate: readonly [number, number], anchor: FillTranslateAnchor, bearing: number): [number, number];
|
|
18
|
+
/**
|
|
19
|
+
* Offsets a fill and its outline by `fill-translate` pixels, anchored to the map or to the
|
|
20
|
+
* viewport by `fill-translate-anchor`. WebGL only; on WebGPU fills draw untranslated.
|
|
21
|
+
*
|
|
22
|
+
* Added to a `GeoJsonLayer`, it reaches the polygon fill and outline sublayers.
|
|
23
|
+
*/
|
|
24
|
+
export declare class FillTranslateExtension extends LayerExtension {
|
|
25
|
+
static extensionName: string;
|
|
26
|
+
static defaultProps: {
|
|
27
|
+
fillTranslate: {
|
|
28
|
+
type: string;
|
|
29
|
+
value: number[];
|
|
30
|
+
compare: boolean;
|
|
31
|
+
};
|
|
32
|
+
fillTranslateAnchor: string;
|
|
33
|
+
};
|
|
34
|
+
getShaders(this: Layer): {
|
|
35
|
+
modules?: undefined;
|
|
36
|
+
} | {
|
|
37
|
+
modules: {
|
|
38
|
+
readonly name: "fillTranslate";
|
|
39
|
+
readonly dependencies: readonly [{
|
|
40
|
+
readonly name: "project";
|
|
41
|
+
readonly dependencies: [{
|
|
42
|
+
name: string;
|
|
43
|
+
source: string;
|
|
44
|
+
vs: string;
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "geometry";
|
|
47
|
+
readonly source: "const SMOOTH_EDGE_RADIUS: f32 = 0.5;\n\nstruct VertexGeometry {\n position: vec4<f32>,\n worldPosition: vec3<f32>,\n worldPositionAlt: vec3<f32>,\n normal: vec3<f32>,\n uv: vec2<f32>,\n pickingColor: vec3<f32>,\n};\n\nvar<private> geometry_: VertexGeometry = VertexGeometry(\n vec4<f32>(0.0, 0.0, 1.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec2<f32>(0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0)\n);\n\nstruct FragmentGeometry {\n uv: vec2<f32>,\n};\n\nvar<private> fragmentGeometry: FragmentGeometry;\n\nfn smoothedge(edge: f32, x: f32) -> f32 {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n";
|
|
48
|
+
readonly vs: "#define SMOOTH_EDGE_RADIUS 0.5\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n";
|
|
49
|
+
readonly fs: "#define SMOOTH_EDGE_RADIUS 0.5\n\nstruct FragmentGeometry {\n vec2 uv;\n};\nFragmentGeometry geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n";
|
|
50
|
+
}];
|
|
51
|
+
readonly source: string;
|
|
52
|
+
readonly vs: string;
|
|
53
|
+
readonly getUniforms: (opts?: import("@deck.gl/core").ProjectProps | {}) => {};
|
|
54
|
+
readonly uniformTypes: {
|
|
55
|
+
readonly wrapLongitude: "f32";
|
|
56
|
+
readonly coordinateSystem: "i32";
|
|
57
|
+
readonly commonUnitsPerMeter: "vec3<f32>";
|
|
58
|
+
readonly projectionMode: "i32";
|
|
59
|
+
readonly scale: "f32";
|
|
60
|
+
readonly commonUnitsPerWorldUnit: "vec3<f32>";
|
|
61
|
+
readonly commonUnitsPerWorldUnit2: "vec3<f32>";
|
|
62
|
+
readonly center: "vec4<f32>";
|
|
63
|
+
readonly modelMatrix: "mat4x4<f32>";
|
|
64
|
+
readonly viewProjectionMatrix: "mat4x4<f32>";
|
|
65
|
+
readonly viewportSize: "vec2<f32>";
|
|
66
|
+
readonly devicePixelRatio: "f32";
|
|
67
|
+
readonly focalDistance: "f32";
|
|
68
|
+
readonly cameraPosition: "vec3<f32>";
|
|
69
|
+
readonly coordinateOrigin: "vec3<f32>";
|
|
70
|
+
readonly commonOrigin: "vec3<f32>";
|
|
71
|
+
readonly pseudoMeters: "f32";
|
|
72
|
+
};
|
|
73
|
+
}];
|
|
74
|
+
readonly vs: "layout(std140) uniform fillTranslateUniforms {\n vec2 offset;\n} fillTranslate;\n";
|
|
75
|
+
readonly uniformTypes: {
|
|
76
|
+
readonly offset: "vec2<f32>";
|
|
77
|
+
};
|
|
78
|
+
readonly inject: {
|
|
79
|
+
readonly 'vs:DECKGL_FILTER_GL_POSITION': {
|
|
80
|
+
readonly order: -1;
|
|
81
|
+
readonly injection: "\n if (fillTranslate.offset != vec2(0.0)) {\n vec2 fillTranslate_pixels = vec2(fillTranslate.offset.x, -fillTranslate.offset.y);\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n // The globe is centred at the origin with its axis along z.\n vec3 fillTranslate_up = normalize(geometry.position.xyz);\n vec3 fillTranslate_east = vec3(-fillTranslate_up.y, fillTranslate_up.x, 0.0);\n fillTranslate_east = length(fillTranslate_east) > 0.0\n ? normalize(fillTranslate_east)\n : vec3(1.0, 0.0, 0.0);\n vec3 fillTranslate_north = cross(fillTranslate_up, fillTranslate_east);\n geometry.position.xyz +=\n (fillTranslate_east * fillTranslate_pixels.x + fillTranslate_north * fillTranslate_pixels.y) /\n project.scale;\n } else {\n geometry.position.xy += fillTranslate_pixels / project.scale;\n }\n position = project_common_position_to_clipspace(geometry.position);\n }\n";
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
}[];
|
|
85
|
+
};
|
|
86
|
+
draw(this: Layer<FillTranslateExtensionProps>): void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* `FillStyleExtension` with image patterns, run only where its GLSL shader runs. On WebGPU it adds
|
|
90
|
+
* no shader code, and the fills it is added to draw nothing, as before patterns were supported:
|
|
91
|
+
* their fill color is only the pattern's opacity.
|
|
92
|
+
*/
|
|
93
|
+
export declare class FillPatternExtension extends FillStyleExtension {
|
|
94
|
+
static extensionName: string;
|
|
95
|
+
constructor();
|
|
96
|
+
getShaders(this: Layer, extension: this): any;
|
|
97
|
+
isEnabled(layer: Layer): boolean;
|
|
98
|
+
getSubLayerProps(this: CompositeLayer, extension: this): any;
|
|
99
|
+
}
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GeoJSONVTOptions } from '@maplibre/geojson-vt';
|
|
2
|
+
import type { BasemapSource } from "./style-resolver.js";
|
|
3
|
+
/** Whether a source is a GeoJSON source whose data has been resolved to a GeoJSON object. */
|
|
4
|
+
export declare function isGeoJsonSource(source: BasemapSource | undefined): boolean;
|
|
5
|
+
/** The deepest zoom a GeoJSON source is tiled at; deeper views overzoom its tiles. */
|
|
6
|
+
export declare function getGeoJsonMaxZoom(source: BasemapSource): number;
|
|
7
|
+
/**
|
|
8
|
+
* geojson-vt options for a GeoJSON source, as MapLibre GL JS 6 sets them: `buffer` and
|
|
9
|
+
* `tolerance` are given in pixels of a 512 pixel tile, and the source's `maxzoom` is the deepest
|
|
10
|
+
* zoom tiled. Clustering is supported without `clusterProperties`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getGeoJsonVtOptions(source: BasemapSource): GeoJSONVTOptions;
|
|
13
|
+
/**
|
|
14
|
+
* Whether tiles requested from now on are cut in a worker, where one can start (`true`, the
|
|
15
|
+
* default), or on the main thread. For tests.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setGeoJsonWorkerEnabled(enabled: boolean): void;
|
|
18
|
+
/**
|
|
19
|
+
* The features of one tile of a GeoJSON source, cut by geojson-vt as MapLibre GL JS cuts them, in
|
|
20
|
+
* the normalized tile-local coordinates of decoded vector tiles: the existing vector tile path
|
|
21
|
+
* then draws them as it draws vector tiles. The source is indexed, and its tiles cut, in a worker
|
|
22
|
+
* where one can start, and on the main thread otherwise. Rejects if the source's data is not
|
|
23
|
+
* valid GeoJSON.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getGeoJsonTileFeatures(source: BasemapSource, index: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
z: number;
|
|
29
|
+
}): Promise<Record<string, unknown>[]>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cutting GeoJSON into vector tiles with `@maplibre/geojson-vt`, and the transferable form a
|
|
3
|
+
* tile's features take between the worker that cuts them and the main thread that draws them.
|
|
4
|
+
* This module runs in both: it holds no state and imports nothing from the rest of the module.
|
|
5
|
+
*/
|
|
6
|
+
import { GeoJSONVT, type GeoJSONVTOptions } from '@maplibre/geojson-vt';
|
|
7
|
+
/** The extent of MapLibre GL JS's tiles, in tile units: GeoJSON is tiled at this precision. */
|
|
8
|
+
export declare const GEOJSON_TILE_EXTENT = 8192;
|
|
9
|
+
/** The geometry types of a tile's features, by how deep their coordinates nest. */
|
|
10
|
+
declare const GEOMETRY_DEPTHS: {
|
|
11
|
+
readonly Point: 0;
|
|
12
|
+
readonly MultiPoint: 1;
|
|
13
|
+
readonly LineString: 1;
|
|
14
|
+
readonly MultiLineString: 2;
|
|
15
|
+
readonly Polygon: 2;
|
|
16
|
+
readonly MultiPolygon: 3;
|
|
17
|
+
};
|
|
18
|
+
type GeometryType = keyof typeof GEOMETRY_DEPTHS;
|
|
19
|
+
/** One feature of an encoded tile: its coordinates are in the tile's typed arrays. */
|
|
20
|
+
type EncodedFeature = {
|
|
21
|
+
type: GeometryType;
|
|
22
|
+
properties: Record<string, unknown>;
|
|
23
|
+
id?: unknown;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A tile's features in a form whose bulk can be transferred between threads: each feature's
|
|
27
|
+
* coordinates, in tile units, follow one another in `positions` (x, y pairs), and `lengths` holds,
|
|
28
|
+
* depth first, the length of each array above a position (the polygons of a multipolygon, the
|
|
29
|
+
* rings of a polygon, the points of a ring). Tile units are integers: geojson-vt rounds them.
|
|
30
|
+
*/
|
|
31
|
+
export type EncodedTile = {
|
|
32
|
+
features: EncodedFeature[];
|
|
33
|
+
positions: Int32Array;
|
|
34
|
+
lengths: Uint32Array;
|
|
35
|
+
};
|
|
36
|
+
/** Builds the tile index of a GeoJSON source's data. Throws if the data is not valid GeoJSON. */
|
|
37
|
+
export declare function createTileIndex(data: unknown, options: GeoJSONVTOptions): GeoJSONVT;
|
|
38
|
+
/**
|
|
39
|
+
* Cuts one tile from a tile index, as MapLibre GL JS cuts it, and encodes its features. Its typed
|
|
40
|
+
* arrays' buffers can be transferred.
|
|
41
|
+
*/
|
|
42
|
+
export declare function cutTile(index: GeoJSONVT, z: number, x: number, y: number): EncodedTile;
|
|
43
|
+
/**
|
|
44
|
+
* The GeoJSON features of an encoded tile, in the normalized tile-local coordinates of decoded
|
|
45
|
+
* vector tiles: the vector tile path then draws them as it draws vector tiles.
|
|
46
|
+
*/
|
|
47
|
+
export declare function decodeTile(tile: EncodedTile): Record<string, unknown>[];
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The worker that indexes GeoJSON sources and cuts their tiles, as MapLibre GL JS's
|
|
3
|
+
* `GeoJSONWorkerSource` does, so that a large source does not hold the main thread. See
|
|
4
|
+
* `geojson-source.ts` for the other end of each message.
|
|
5
|
+
*/
|
|
6
|
+
import type { GeoJSONVTOptions } from '@maplibre/geojson-vt';
|
|
7
|
+
import { cutTile } from "./geojson-tiler.js";
|
|
8
|
+
/** A message from the main thread. Messages of one source arrive in the order they are sent. */
|
|
9
|
+
export type GeoJsonWorkerRequest =
|
|
10
|
+
/** Features of a FeatureCollection, sent in batches before its `index` message. */
|
|
11
|
+
{
|
|
12
|
+
type: 'features';
|
|
13
|
+
source: number;
|
|
14
|
+
features: unknown[];
|
|
15
|
+
}
|
|
16
|
+
/** Builds a source's index from `data`, or from the features sent before it. */
|
|
17
|
+
| {
|
|
18
|
+
type: 'index';
|
|
19
|
+
source: number;
|
|
20
|
+
data?: unknown;
|
|
21
|
+
options: GeoJSONVTOptions;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'tile';
|
|
24
|
+
source: number;
|
|
25
|
+
request: number;
|
|
26
|
+
z: number;
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'remove';
|
|
31
|
+
source: number;
|
|
32
|
+
};
|
|
33
|
+
/** The answer to a `tile` request: the encoded tile, or why the source cannot be tiled. */
|
|
34
|
+
export type GeoJsonWorkerResponse = {
|
|
35
|
+
request: number;
|
|
36
|
+
} & ({
|
|
37
|
+
tile: ReturnType<typeof cutTile>;
|
|
38
|
+
} | {
|
|
39
|
+
error: string;
|
|
40
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { LayerExtension } from '@deck.gl/core';
|
|
2
|
+
import type { Layer } from '@deck.gl/core';
|
|
3
|
+
/**
|
|
4
|
+
* Hides labels and icons whose anchor is on the far side of the globe in a `GlobeView`, in the
|
|
5
|
+
* screen pass and in the collision filter's pass. In other views the shader does nothing. WebGL
|
|
6
|
+
* only: on WebGPU the extension adds no shader code.
|
|
7
|
+
*
|
|
8
|
+
* Added to a composite layer such as `TextLayer`, it reaches the character and background
|
|
9
|
+
* sublayers.
|
|
10
|
+
*/
|
|
11
|
+
export declare class GlobeHorizonExtension extends LayerExtension {
|
|
12
|
+
static extensionName: string;
|
|
13
|
+
getShaders(this: Layer): {
|
|
14
|
+
modules?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
modules: {
|
|
17
|
+
readonly name: "globeHorizon";
|
|
18
|
+
readonly dependencies: readonly [{
|
|
19
|
+
readonly name: "project";
|
|
20
|
+
readonly dependencies: [{
|
|
21
|
+
name: string;
|
|
22
|
+
source: string;
|
|
23
|
+
vs: string;
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "geometry";
|
|
26
|
+
readonly source: "const SMOOTH_EDGE_RADIUS: f32 = 0.5;\n\nstruct VertexGeometry {\n position: vec4<f32>,\n worldPosition: vec3<f32>,\n worldPositionAlt: vec3<f32>,\n normal: vec3<f32>,\n uv: vec2<f32>,\n pickingColor: vec3<f32>,\n};\n\nvar<private> geometry_: VertexGeometry = VertexGeometry(\n vec4<f32>(0.0, 0.0, 1.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec2<f32>(0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0)\n);\n\nstruct FragmentGeometry {\n uv: vec2<f32>,\n};\n\nvar<private> fragmentGeometry: FragmentGeometry;\n\nfn smoothedge(edge: f32, x: f32) -> f32 {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n";
|
|
27
|
+
readonly vs: "#define SMOOTH_EDGE_RADIUS 0.5\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n";
|
|
28
|
+
readonly fs: "#define SMOOTH_EDGE_RADIUS 0.5\n\nstruct FragmentGeometry {\n vec2 uv;\n};\nFragmentGeometry geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n";
|
|
29
|
+
}];
|
|
30
|
+
readonly source: string;
|
|
31
|
+
readonly vs: string;
|
|
32
|
+
readonly getUniforms: (opts?: import("@deck.gl/core").ProjectProps | {}) => {};
|
|
33
|
+
readonly uniformTypes: {
|
|
34
|
+
readonly wrapLongitude: "f32";
|
|
35
|
+
readonly coordinateSystem: "i32";
|
|
36
|
+
readonly commonUnitsPerMeter: "vec3<f32>";
|
|
37
|
+
readonly projectionMode: "i32";
|
|
38
|
+
readonly scale: "f32";
|
|
39
|
+
readonly commonUnitsPerWorldUnit: "vec3<f32>";
|
|
40
|
+
readonly commonUnitsPerWorldUnit2: "vec3<f32>";
|
|
41
|
+
readonly center: "vec4<f32>";
|
|
42
|
+
readonly modelMatrix: "mat4x4<f32>";
|
|
43
|
+
readonly viewProjectionMatrix: "mat4x4<f32>";
|
|
44
|
+
readonly viewportSize: "vec2<f32>";
|
|
45
|
+
readonly devicePixelRatio: "f32";
|
|
46
|
+
readonly focalDistance: "f32";
|
|
47
|
+
readonly cameraPosition: "vec3<f32>";
|
|
48
|
+
readonly coordinateOrigin: "vec3<f32>";
|
|
49
|
+
readonly commonOrigin: "vec3<f32>";
|
|
50
|
+
readonly pseudoMeters: "f32";
|
|
51
|
+
};
|
|
52
|
+
}];
|
|
53
|
+
readonly inject: {
|
|
54
|
+
readonly 'vs:DECKGL_FILTER_GL_POSITION': {
|
|
55
|
+
readonly order: 1;
|
|
56
|
+
readonly injection: "\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n vec3 globeHorizon_normal = normalize(project_position(geometry.worldPosition));\n mat4 globeHorizon_m = project.viewProjectionMatrix;\n vec3 globeHorizon_wRow = vec3(globeHorizon_m[0][3], globeHorizon_m[1][3], globeHorizon_m[2][3]);\n bool globeHorizon_hidden = dot(globeHorizon_wRow, globeHorizon_wRow) == 0.0\n ? dot(globeHorizon_normal, vec3(globeHorizon_m[0][2], globeHorizon_m[1][2], globeHorizon_m[2][2])) > 0.0\n : dot(globeHorizon_normal, project.cameraPosition) < GLOBE_RADIUS;\n if (globeHorizon_hidden) {\n // Every vertex of the quad lands beyond the far plane, so it is clipped. In the collision\n // pass this keeps a hidden label out of the collision map.\n position = vec4(0.0, 0.0, 2.0, 1.0);\n }\n }\n";
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
}
|