@tangram.gl/basemap-layers 0.0.0-stage → 0.0.1
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,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Label anchors along lines, for `symbol-placement: line` and `line-center`. The placement follows
|
|
3
|
+
* MapLibre GL JS (`getAnchors`, `getCenterAnchor` and `checkMaxAngle` in its symbol code): labels
|
|
4
|
+
* repeat every `symbol-spacing` pixels where the line is long enough for them, and a placement is
|
|
5
|
+
* skipped where the line bends more than `text-max-angle` within the label.
|
|
6
|
+
*
|
|
7
|
+
* Lines are given in pixels, with y pointing down. An anchor is returned as the segment it lies
|
|
8
|
+
* on and its position along that segment, so the caller can interpolate the anchor in its own
|
|
9
|
+
* coordinates.
|
|
10
|
+
*/
|
|
11
|
+
/** An anchor on a line: `t` along the segment from `line[segment]` to `line[segment + 1]`. */
|
|
12
|
+
export type LineAnchor = {
|
|
13
|
+
segment: number;
|
|
14
|
+
t: number;
|
|
15
|
+
/** The direction of the segment, in degrees counter-clockwise from the +x axis on screen. */
|
|
16
|
+
angle: number;
|
|
17
|
+
};
|
|
18
|
+
export type LineAnchorOptions = {
|
|
19
|
+
/** `line` repeats labels along the line; `line-center` places one at its middle. */
|
|
20
|
+
placement: 'line' | 'line-center';
|
|
21
|
+
/** `symbol-spacing`: pixels between two labels of a line. */
|
|
22
|
+
spacing: number;
|
|
23
|
+
/** `text-max-angle`: the largest bend, in degrees, within any window of the label. */
|
|
24
|
+
maxAngle: number;
|
|
25
|
+
/** The label's length along the line, in pixels. */
|
|
26
|
+
labelLength: number;
|
|
27
|
+
/** `text-size` in pixels; the bend window is 3/5 of it, as in MapLibre. */
|
|
28
|
+
textSize: number;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the symbol has text. As in MapLibre, a symbol with only an icon has no bend window:
|
|
31
|
+
* the line may bend any amount under it. With `line` placement it must still fit on the line.
|
|
32
|
+
* Default: true.
|
|
33
|
+
*/
|
|
34
|
+
hasText?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the line continues in a neighbouring tile. MapLibre then starts the first label half
|
|
37
|
+
* a spacing in, so labels line up across tile edges, and does not fall back to the middle.
|
|
38
|
+
*/
|
|
39
|
+
isContinued: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Work the placement may spend, in steps along the line and vertices checked for bends. It is
|
|
42
|
+
* drawn down as the placement runs; once it is spent, no further anchors are placed. Tile
|
|
43
|
+
* geometry is untrusted, so callers share one budget across a tile.
|
|
44
|
+
*/
|
|
45
|
+
budget?: LineAnchorBudget;
|
|
46
|
+
};
|
|
47
|
+
/** Remaining placement work; see `LineAnchorOptions.budget`. */
|
|
48
|
+
export type LineAnchorBudget = {
|
|
49
|
+
steps: number;
|
|
50
|
+
};
|
|
51
|
+
/** Work one feature's line labels may spend, unless the tile's budget has less left. */
|
|
52
|
+
export declare const DEFAULT_LINE_ANCHOR_STEPS = 100000;
|
|
53
|
+
/**
|
|
54
|
+
* The least distance, in pixels, between two labels of a line beyond the label's own length. It
|
|
55
|
+
* only matters for a `symbol-spacing` far below any label's length: with a spacing of 1, a short
|
|
56
|
+
* or empty label would otherwise be placed at every pixel of the line.
|
|
57
|
+
*/
|
|
58
|
+
export declare const MIN_LABEL_GAP = 16;
|
|
59
|
+
/**
|
|
60
|
+
* Label anchors along a line in pixels. `line` repeats labels every `spacing` pixels, starting
|
|
61
|
+
* where MapLibre starts them; `line-center` places one at the middle of the line by length. Either
|
|
62
|
+
* skips a placement where the label does not fit on the line or where the line bends more than
|
|
63
|
+
* `maxAngle` within the label.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getLineAnchors(line: number[][], options: LineAnchorOptions): LineAnchor[];
|
|
66
|
+
/** A line to merge: its label text, or none, and its vertices. */
|
|
67
|
+
export type MergeableLine = {
|
|
68
|
+
text: string | null | undefined;
|
|
69
|
+
line: number[][];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Joins lines with the same label text whose ends meet exactly, as MapLibre GL JS's `mergeLines`
|
|
73
|
+
* does before it places labels along lines. Vector tiles split a street or river into many short
|
|
74
|
+
* features (one per block, bridge or name change), and a label longer than each piece fits on
|
|
75
|
+
* none of them; MapLibre places it on the joined line.
|
|
76
|
+
*
|
|
77
|
+
* Returns one entry per input line: the joined line at the line that started each chain (whose
|
|
78
|
+
* feature the labels belong to, as in MapLibre), `null` for a line merged into a chain started by
|
|
79
|
+
* another, and the line unchanged when nothing joins it. Lines without text or vertices are
|
|
80
|
+
* never merged. The work is linear in the number of vertices.
|
|
81
|
+
*/
|
|
82
|
+
export declare function mergeLines(lines: MergeableLine[]): (number[][] | null)[];
|
|
83
|
+
/**
|
|
84
|
+
* The angle at which a label along a line is drawn: the line's direction, turned by 180 degrees
|
|
85
|
+
* when `keepUpright` is set and the text would otherwise read upside down on a map rotated by
|
|
86
|
+
* `bearing` degrees.
|
|
87
|
+
*/
|
|
88
|
+
export declare function getUprightAngle(angle: number, bearing: number, keepUpright: boolean): number;
|
|
89
|
+
/**
|
|
90
|
+
* The parts of `line` inside `[minX, minY, maxX, maxY]`, clipped segment by segment
|
|
91
|
+
* (Liang-Barsky). A line that leaves the box and comes back gives one part per stay inside.
|
|
92
|
+
*/
|
|
93
|
+
export declare function clipLine(line: number[][], box: number[]): number[][][];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { LoaderContext, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
import type { BasemapLoadOptions, ResolvedBasemapStyle } from "./style-resolver.js";
|
|
3
|
+
/** Namespaced loaders.gl options for {@link MapStyleLoader}. */
|
|
4
|
+
export type MapStyleLoaderOptions = LoaderOptions & {
|
|
5
|
+
mapStyle?: NonNullable<BasemapLoadOptions>;
|
|
6
|
+
};
|
|
7
|
+
/** loaders.gl-compatible loader that resolves and validates map-style documents. */
|
|
8
|
+
export declare const MapStyleLoader: {
|
|
9
|
+
readonly dataType: ResolvedBasemapStyle;
|
|
10
|
+
readonly batchType: never;
|
|
11
|
+
readonly name: "Map Style";
|
|
12
|
+
readonly id: "map-style";
|
|
13
|
+
readonly module: "basemap-layers";
|
|
14
|
+
readonly version: string;
|
|
15
|
+
readonly worker: false;
|
|
16
|
+
readonly extensions: ["json"];
|
|
17
|
+
readonly mimeTypes: ["application/json", "application/vnd.mapbox.style+json"];
|
|
18
|
+
readonly text: true;
|
|
19
|
+
readonly options: {
|
|
20
|
+
readonly mapStyle: {};
|
|
21
|
+
};
|
|
22
|
+
readonly parse: (data: ArrayBuffer | string, options?: MapStyleLoaderOptions, context?: LoaderContext) => Promise<{
|
|
23
|
+
[x: string]: unknown;
|
|
24
|
+
sources: Record<string, {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
type?: string | undefined;
|
|
27
|
+
url?: string | undefined;
|
|
28
|
+
tiles?: string[] | undefined;
|
|
29
|
+
minzoom?: number | undefined;
|
|
30
|
+
maxzoom?: number | undefined;
|
|
31
|
+
tileSize?: number | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
layers: {
|
|
34
|
+
[x: string]: unknown;
|
|
35
|
+
id: string;
|
|
36
|
+
type: string;
|
|
37
|
+
source?: string | undefined;
|
|
38
|
+
'source-layer'?: string | undefined;
|
|
39
|
+
minzoom?: number | undefined;
|
|
40
|
+
maxzoom?: number | undefined;
|
|
41
|
+
filter?: unknown[] | undefined;
|
|
42
|
+
paint?: Record<string, unknown> | undefined;
|
|
43
|
+
layout?: Record<string, unknown> | undefined;
|
|
44
|
+
}[];
|
|
45
|
+
version?: number | undefined;
|
|
46
|
+
metadata?: Record<string, unknown> | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Zod schema for a basemap source entry. */
|
|
3
|
+
export declare const BasemapSourceSchema: z.ZodObject<{
|
|
4
|
+
type: z.ZodOptional<z.ZodString>;
|
|
5
|
+
url: z.ZodOptional<z.ZodString>;
|
|
6
|
+
tiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
|
+
minzoom: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
maxzoom: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
tileSize: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
11
|
+
/** Zod schema for a basemap style layer entry. */
|
|
12
|
+
export declare const BasemapStyleLayerSchema: z.ZodObject<{
|
|
13
|
+
id: z.ZodString;
|
|
14
|
+
type: z.ZodOptional<z.ZodString>;
|
|
15
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
16
|
+
source: z.ZodOptional<z.ZodString>;
|
|
17
|
+
'source-layer': z.ZodOptional<z.ZodString>;
|
|
18
|
+
minzoom: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
maxzoom: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
filter: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
21
|
+
paint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
22
|
+
layout: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
23
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
24
|
+
/** Zod schema for a MapLibre / Mapbox style document. */
|
|
25
|
+
export declare const BasemapStyleSchema: z.ZodObject<{
|
|
26
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
28
|
+
sources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
29
|
+
type: z.ZodOptional<z.ZodString>;
|
|
30
|
+
url: z.ZodOptional<z.ZodString>;
|
|
31
|
+
tiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
|
+
minzoom: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
maxzoom: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
tileSize: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
36
|
+
layers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
type: z.ZodOptional<z.ZodString>;
|
|
39
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
40
|
+
source: z.ZodOptional<z.ZodString>;
|
|
41
|
+
'source-layer': z.ZodOptional<z.ZodString>;
|
|
42
|
+
minzoom: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
maxzoom: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
filter: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
45
|
+
paint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
46
|
+
layout: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
47
|
+
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
48
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
49
|
+
/** Zod schema for a fully resolved basemap style document. */
|
|
50
|
+
export declare const ResolvedBasemapStyleSchema: z.ZodObject<{
|
|
51
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
53
|
+
sources: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
54
|
+
type: z.ZodOptional<z.ZodString>;
|
|
55
|
+
url: z.ZodOptional<z.ZodString>;
|
|
56
|
+
tiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
57
|
+
minzoom: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
maxzoom: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
tileSize: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
61
|
+
layers: z.ZodArray<z.ZodObject<{
|
|
62
|
+
id: z.ZodString;
|
|
63
|
+
type: z.ZodString;
|
|
64
|
+
source: z.ZodOptional<z.ZodString>;
|
|
65
|
+
'source-layer': z.ZodOptional<z.ZodString>;
|
|
66
|
+
minzoom: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
maxzoom: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
filter: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
69
|
+
paint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
70
|
+
layout: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
71
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
72
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Map-style helpers exported from `@deck.gl-community/basemap-layers/map-style`. */
|
|
2
|
+
export { filterFeatures, findFeaturesStyledByLayer, parseProperties } from "./mapbox-style.js";
|
|
3
|
+
export { BasemapSourceSchema, BasemapStyleLayerSchema, BasemapStyleSchema, ResolvedBasemapStyleSchema } from "./map-style-schema.js";
|
|
4
|
+
export { MapStyleLoader } from "./map-style-loader.js";
|
|
5
|
+
export type { MapStyleLoaderOptions } from "./map-style-loader.js";
|
|
6
|
+
export { resolveBasemapStyle, type BasemapLoadOptions, type BasemapSource, type BasemapStyle, type BasemapStyleLayer, type ResolvedBasemapStyleLayer, type ResolvedBasemapStyle } from "./style-resolver.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type GlobalProperties = {
|
|
2
|
+
zoom?: number;
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
};
|
|
5
|
+
type GeometryLike = {
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
type FeatureLike = {
|
|
9
|
+
type?: number | string;
|
|
10
|
+
geometry?: GeometryLike;
|
|
11
|
+
properties?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
type FilterFeaturesOptions = {
|
|
14
|
+
features: FeatureLike[];
|
|
15
|
+
filter: unknown[];
|
|
16
|
+
globalProperties?: GlobalProperties;
|
|
17
|
+
};
|
|
18
|
+
type FindFeaturesStyledByLayerOptions = {
|
|
19
|
+
features: Record<string, Record<string, FeatureLike[]>>;
|
|
20
|
+
layer: {
|
|
21
|
+
source?: string;
|
|
22
|
+
'source-layer'?: string;
|
|
23
|
+
filter?: unknown[];
|
|
24
|
+
};
|
|
25
|
+
globalProperties?: GlobalProperties;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Applies a Mapbox style-spec filter expression to a set of features.
|
|
29
|
+
*/
|
|
30
|
+
export declare function filterFeatures({ features, filter, globalProperties }: FilterFeaturesOptions): FeatureLike[];
|
|
31
|
+
/**
|
|
32
|
+
* Finds the source-layer features that participate in a particular style layer
|
|
33
|
+
* and applies the layer's filter expression when present.
|
|
34
|
+
*/
|
|
35
|
+
export declare function findFeaturesStyledByLayer({ features, layer, globalProperties }: FindFeaturesStyledByLayerOptions): FeatureLike[];
|
|
36
|
+
/**
|
|
37
|
+
* Evaluates paint properties for a style layer at the requested zoom.
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseProperties(layer: Record<string, any>, globalProperties: GlobalProperties): Array<Record<string, unknown>>;
|
|
40
|
+
export { colorToArray } from "./style-expression.js";
|