@mapbox/mapbox-gl-style-spec 14.33.0 → 14.34.1-alpha.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/dist/index.cjs +82 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +67 -12
- package/dist/index.es.js +82 -9
- package/dist/index.es.js.map +1 -1
- package/expression/definitions/config.ts +1 -1
- package/expression/expression_dependencies.ts +5 -2
- package/expression/index.ts +3 -0
- package/package.json +1 -1
- package/reference/v8.json +59 -7
- package/types.ts +15 -9
- package/validate/validate_layer.ts +21 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import CompoundExpression from "./compound_expression";
|
|
2
2
|
import Config from "./definitions/config";
|
|
3
|
+
import ImageExpression from "./definitions/image";
|
|
3
4
|
|
|
4
5
|
import type {Expression} from "./expression";
|
|
5
6
|
|
|
6
7
|
export type ExpressionDependencies = {
|
|
7
8
|
configDependencies: Set<string>;
|
|
8
9
|
isIndoorDependent: boolean;
|
|
10
|
+
isImageDependent: boolean;
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
// Shared by every expression without config dependencies, which is the vast majority; read-only.
|
|
@@ -18,13 +20,14 @@ function collect(e: Expression, deps: ExpressionDependencies) {
|
|
|
18
20
|
return; // `Config.eachChild` is a no-op
|
|
19
21
|
}
|
|
20
22
|
if (e instanceof CompoundExpression && e.name === 'is-active-floor') deps.isIndoorDependent = true;
|
|
23
|
+
if (e instanceof ImageExpression) deps.isImageDependent = true;
|
|
21
24
|
e.eachChild(arg => { collect(arg, deps); });
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
// One traversal for
|
|
27
|
+
// One traversal for all dependency kinds, and no per-node allocation: this runs for every
|
|
25
28
|
// expression of every property of every layer at style load, so the walk dominates what it finds.
|
|
26
29
|
export function getExpressionDependencies(e: Expression): ExpressionDependencies {
|
|
27
|
-
const deps = {configDependencies: NO_CONFIG_DEPENDENCIES, isIndoorDependent: false};
|
|
30
|
+
const deps = {configDependencies: NO_CONFIG_DEPENDENCIES, isIndoorDependent: false, isImageDependent: false};
|
|
28
31
|
collect(e, deps);
|
|
29
32
|
return deps;
|
|
30
33
|
}
|
package/expression/index.ts
CHANGED
|
@@ -75,6 +75,8 @@ export class StyleExpression {
|
|
|
75
75
|
_enumValues?: {[_: string]: unknown} | null;
|
|
76
76
|
configDependencies: Set<string>;
|
|
77
77
|
isIndoorDependent: boolean;
|
|
78
|
+
// Whether the result depends on the available images passed to `evaluate`
|
|
79
|
+
isImageDependent: boolean;
|
|
78
80
|
|
|
79
81
|
constructor(expression: Expression, propertySpec?: StylePropertySpecification | null, scope?: string | null, options?: ConfigOptions | null, iconImageUseTheme?: string | null) {
|
|
80
82
|
this.expression = expression;
|
|
@@ -88,6 +90,7 @@ export class StyleExpression {
|
|
|
88
90
|
const dependencies = expressionDependencies.getExpressionDependencies(expression);
|
|
89
91
|
this.configDependencies = dependencies.configDependencies;
|
|
90
92
|
this.isIndoorDependent = dependencies.isIndoorDependent;
|
|
93
|
+
this.isImageDependent = dependencies.isImageDependent;
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
evaluateWithoutErrorHandling(
|
package/package.json
CHANGED
package/reference/v8.json
CHANGED
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
},
|
|
197
197
|
"projection": {
|
|
198
198
|
"type": "projection",
|
|
199
|
-
"doc": "The projection the map should be rendered in. Supported projections are Mercator, Globe, Albers, Equal Earth, Equirectangular (WGS84), Lambert conformal conic, Natural Earth, and Winkel Tripel. Terrain, sky and fog are supported by only Mercator and globe. CustomLayerInterface is
|
|
199
|
+
"doc": "The projection the map should be rendered in. Supported projections are Mercator, Globe, Albers, Equal Earth, Equirectangular (WGS84), Lambert conformal conic, Natural Earth, and Winkel Tripel. Terrain, sky and fog are supported by only Mercator and globe. CustomLayerInterface is supported by only Mercator and globe.",
|
|
200
200
|
"example": {
|
|
201
201
|
"name": "albers",
|
|
202
202
|
"center": [-154, 50],
|
|
@@ -2486,7 +2486,6 @@
|
|
|
2486
2486
|
"minimum": 0,
|
|
2487
2487
|
"units": "meters",
|
|
2488
2488
|
"doc": "The height of the procedural buildings.",
|
|
2489
|
-
"transition": true,
|
|
2490
2489
|
"private": true,
|
|
2491
2490
|
"sdk-support": {
|
|
2492
2491
|
"basic functionality": {
|
|
@@ -2511,7 +2510,6 @@
|
|
|
2511
2510
|
"minimum": 0,
|
|
2512
2511
|
"units": "meters",
|
|
2513
2512
|
"doc": "The height with which to extrude the base of this layer. Must be less than or equal to `building-height`.",
|
|
2514
|
-
"transition": true,
|
|
2515
2513
|
"requires": [
|
|
2516
2514
|
"building-height"
|
|
2517
2515
|
],
|
|
@@ -2544,7 +2542,6 @@
|
|
|
2544
2542
|
"requires": [
|
|
2545
2543
|
"lights"
|
|
2546
2544
|
],
|
|
2547
|
-
"transition": true,
|
|
2548
2545
|
"expression": {
|
|
2549
2546
|
"interpolated": true,
|
|
2550
2547
|
"parameters": [
|
|
@@ -2575,7 +2572,6 @@
|
|
|
2575
2572
|
"requires": [
|
|
2576
2573
|
"lights"
|
|
2577
2574
|
],
|
|
2578
|
-
"transition": true,
|
|
2579
2575
|
"expression": {
|
|
2580
2576
|
"interpolated": true,
|
|
2581
2577
|
"parameters": [
|
|
@@ -2602,7 +2598,6 @@
|
|
|
2602
2598
|
"private": true,
|
|
2603
2599
|
"default": false,
|
|
2604
2600
|
"doc": "Flips the orientation of the roofs for the buildings. This only affects simple geometries. Namely buildings whose footprints form a quadrilateral. By default (false), the roof ridge takes the direction of the longer edge of the quadrilateral.",
|
|
2605
|
-
"transition": true,
|
|
2606
2601
|
"requires": [
|
|
2607
2602
|
"building-roof-shape"
|
|
2608
2603
|
],
|
|
@@ -2946,7 +2941,6 @@
|
|
|
2946
2941
|
"requires": [
|
|
2947
2942
|
"line-z-offset"
|
|
2948
2943
|
],
|
|
2949
|
-
"transition": true,
|
|
2950
2944
|
"property-type": "data-driven"
|
|
2951
2945
|
}
|
|
2952
2946
|
},
|
|
@@ -10798,6 +10792,64 @@
|
|
|
10798
10792
|
"interpolated": false
|
|
10799
10793
|
},
|
|
10800
10794
|
"property-type": "data-constant"
|
|
10795
|
+
},
|
|
10796
|
+
"raster-mask": {
|
|
10797
|
+
"type": "string",
|
|
10798
|
+
"required": false,
|
|
10799
|
+
"experimental": true,
|
|
10800
|
+
"private": true,
|
|
10801
|
+
"doc": "The id of a `fill` layer in the same style whose polygons should clip this layer. Only the geometry is used: set `fill-opacity` to 0 to keep the layer invisible, but don't hide it with `visibility`, `minzoom` or `maxzoom`. To use a featureset from another import, see `raster-mask-import`. Elevated `fill` layers and `raster-elevation` are not supported. This layer is only drawn where the mask's data has loaded, and not at all if the mask can't be used.",
|
|
10802
|
+
"example": "water",
|
|
10803
|
+
"transition": false,
|
|
10804
|
+
"sdk-support": {
|
|
10805
|
+
"basic functionality": {
|
|
10806
|
+
"js": "3.34.0"
|
|
10807
|
+
}
|
|
10808
|
+
},
|
|
10809
|
+
"property-type": "data-constant"
|
|
10810
|
+
},
|
|
10811
|
+
"raster-mask-import": {
|
|
10812
|
+
"type": "string",
|
|
10813
|
+
"required": false,
|
|
10814
|
+
"experimental": true,
|
|
10815
|
+
"private": true,
|
|
10816
|
+
"doc": "The id of an import of this style. When set, `raster-mask` is the id of a featureset of that import instead of a layer id, and the mask is made of the `fill` layers the featureset selects. If the featureset can't be found, or selects no `fill` layers, this layer is not drawn.",
|
|
10817
|
+
"example": "basemap",
|
|
10818
|
+
"transition": false,
|
|
10819
|
+
"requires": [
|
|
10820
|
+
"raster-mask"
|
|
10821
|
+
],
|
|
10822
|
+
"sdk-support": {
|
|
10823
|
+
"basic functionality": {
|
|
10824
|
+
"js": "3.34.0"
|
|
10825
|
+
}
|
|
10826
|
+
},
|
|
10827
|
+
"property-type": "data-constant"
|
|
10828
|
+
},
|
|
10829
|
+
"raster-mask-mode": {
|
|
10830
|
+
"type": "enum",
|
|
10831
|
+
"doc": "Whether this layer is drawn inside or outside the mask.",
|
|
10832
|
+
"values": {
|
|
10833
|
+
"clip-path-intersect": {
|
|
10834
|
+
"doc": "Draw only where the mask layer's geometry covers the map."
|
|
10835
|
+
},
|
|
10836
|
+
"clip-path-exclude": {
|
|
10837
|
+
"doc": "Draw only where the mask layer's geometry does not cover the map."
|
|
10838
|
+
}
|
|
10839
|
+
},
|
|
10840
|
+
"default": "clip-path-intersect",
|
|
10841
|
+
"experimental": true,
|
|
10842
|
+
"private": true,
|
|
10843
|
+
"transition": false,
|
|
10844
|
+
"requires": [
|
|
10845
|
+
"raster-mask"
|
|
10846
|
+
],
|
|
10847
|
+
"sdk-support": {
|
|
10848
|
+
"basic functionality": {
|
|
10849
|
+
"js": "3.34.0"
|
|
10850
|
+
}
|
|
10851
|
+
},
|
|
10852
|
+
"property-type": "data-constant"
|
|
10801
10853
|
}
|
|
10802
10854
|
},
|
|
10803
10855
|
"paint_raster-particle": {
|
package/types.ts
CHANGED
|
@@ -716,8 +716,7 @@ export type LineLayerSpecification = {
|
|
|
716
716
|
* @experimental This property is experimental and subject to change in future versions.
|
|
717
717
|
*/
|
|
718
718
|
"line-width-unit"?: PropertyValueSpecification<"pixels" | "meters">,
|
|
719
|
-
"line-elevation-ground-scale"?: DataDrivenPropertyValueSpecification<number
|
|
720
|
-
"line-elevation-ground-scale-transition"?: TransitionSpecification
|
|
719
|
+
"line-elevation-ground-scale"?: DataDrivenPropertyValueSpecification<number>
|
|
721
720
|
},
|
|
722
721
|
"paint"?: {
|
|
723
722
|
"line-opacity"?: DataDrivenPropertyValueSpecification<number>,
|
|
@@ -1166,15 +1165,10 @@ export type BuildingLayerSpecification = {
|
|
|
1166
1165
|
"building-facade-window"?: DataDrivenPropertyValueSpecification<[number, number]>,
|
|
1167
1166
|
"building-roof-shape"?: DataDrivenPropertyValueSpecification<"flat" | "hipped" | "gabled" | "parapet" | "mansard" | "skillion" | "pyramidal">,
|
|
1168
1167
|
"building-height"?: DataDrivenPropertyValueSpecification<number>,
|
|
1169
|
-
"building-height-transition"?: TransitionSpecification,
|
|
1170
1168
|
"building-base"?: DataDrivenPropertyValueSpecification<number>,
|
|
1171
|
-
"building-base-transition"?: TransitionSpecification,
|
|
1172
1169
|
"building-flood-light-wall-radius"?: DataDrivenPropertyValueSpecification<number>,
|
|
1173
|
-
"building-flood-light-wall-radius-transition"?: TransitionSpecification,
|
|
1174
1170
|
"building-flood-light-ground-radius"?: DataDrivenPropertyValueSpecification<number>,
|
|
1175
|
-
"building-
|
|
1176
|
-
"building-flip-roof-orientation"?: DataDrivenPropertyValueSpecification<boolean>,
|
|
1177
|
-
"building-flip-roof-orientation-transition"?: TransitionSpecification
|
|
1171
|
+
"building-flip-roof-orientation"?: DataDrivenPropertyValueSpecification<boolean>
|
|
1178
1172
|
},
|
|
1179
1173
|
"paint"?: {
|
|
1180
1174
|
"building-opacity"?: PropertyValueSpecification<number>,
|
|
@@ -1272,7 +1266,19 @@ export type RasterLayerSpecification = {
|
|
|
1272
1266
|
/**
|
|
1273
1267
|
* @experimental This property is experimental and subject to change in future versions.
|
|
1274
1268
|
*/
|
|
1275
|
-
"raster-elevation-reference"?: "sea" | "ground" | ExpressionSpecification
|
|
1269
|
+
"raster-elevation-reference"?: "sea" | "ground" | ExpressionSpecification,
|
|
1270
|
+
/**
|
|
1271
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1272
|
+
*/
|
|
1273
|
+
"raster-mask"?: string,
|
|
1274
|
+
/**
|
|
1275
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1276
|
+
*/
|
|
1277
|
+
"raster-mask-import"?: string,
|
|
1278
|
+
/**
|
|
1279
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1280
|
+
*/
|
|
1281
|
+
"raster-mask-mode"?: "clip-path-intersect" | "clip-path-exclude"
|
|
1276
1282
|
},
|
|
1277
1283
|
"appearances"?: Array<AppearanceSpecification>
|
|
1278
1284
|
};
|
|
@@ -107,6 +107,27 @@ export default function validateLayer(options: LayerValidatorOptions): Validatio
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
if (type === 'raster' && isObject(layer.paint)) {
|
|
111
|
+
const paint = layer.paint as Record<string, unknown>;
|
|
112
|
+
const maskId = unbundle(paint['raster-mask']);
|
|
113
|
+
const importId = unbundle(paint['raster-mask-import']);
|
|
114
|
+
if (isString(maskId) && maskId) {
|
|
115
|
+
if (isString(importId) && importId) {
|
|
116
|
+
// The featureset itself can only be checked once the import has loaded.
|
|
117
|
+
if (!(style.imports || []).some((i) => unbundle(i.id) === importId)) {
|
|
118
|
+
errors.push(new ValidationError(`${key}.paint.raster-mask-import`, paint['raster-mask-import'], `import "${importId}" not found`));
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
const maskLayer = (style.layers || []).find((l) => unbundle(l.id) === maskId);
|
|
122
|
+
if (!maskLayer) {
|
|
123
|
+
errors.push(new ValidationError(`${key}.paint.raster-mask`, paint['raster-mask'], `layer "${maskId}" not found`));
|
|
124
|
+
} else if (unbundle(maskLayer.type) !== 'fill') {
|
|
125
|
+
errors.push(new ValidationError(`${key}.paint.raster-mask`, paint['raster-mask'], `layer "${maskId}" must be a "fill" layer`));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
110
131
|
errors = errors.concat(validateObject({
|
|
111
132
|
key,
|
|
112
133
|
value: layer,
|