@mapbox/mapbox-gl-style-spec 14.12.0-beta.1 → 14.13.0-beta.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/composite.ts +2 -0
- package/deref.ts +5 -5
- package/diff.ts +21 -21
- package/dist/index.cjs +455 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +64 -30
- package/dist/index.es.js +455 -241
- package/dist/index.es.js.map +1 -1
- package/error/validation_error.ts +1 -3
- package/expression/definitions/assertion.ts +2 -1
- package/expression/definitions/at.ts +1 -1
- package/expression/definitions/at_interpolated.ts +1 -1
- package/expression/definitions/case.ts +3 -1
- package/expression/definitions/coalesce.ts +1 -0
- package/expression/definitions/coercion.ts +3 -1
- package/expression/definitions/collator.ts +2 -1
- package/expression/definitions/comparison.ts +15 -1
- package/expression/definitions/config.ts +33 -10
- package/expression/definitions/distance.ts +6 -4
- package/expression/definitions/format.ts +3 -2
- package/expression/definitions/index.ts +29 -3
- package/expression/definitions/index_of.ts +1 -0
- package/expression/definitions/interpolate.ts +5 -1
- package/expression/definitions/let.ts +1 -0
- package/expression/definitions/literal.ts +3 -3
- package/expression/definitions/match.ts +5 -3
- package/expression/definitions/number_format.ts +3 -4
- package/expression/definitions/slice.ts +1 -0
- package/expression/definitions/step.ts +1 -0
- package/expression/definitions/var.ts +1 -0
- package/expression/definitions/within.ts +6 -2
- package/expression/expression.ts +3 -0
- package/expression/index.ts +18 -3
- package/expression/is_constant.ts +4 -0
- package/expression/parsing_context.ts +1 -1
- package/expression/types/formatted.ts +1 -1
- package/expression/types/image_variant.ts +2 -2
- package/expression/types.ts +9 -0
- package/expression/values.ts +1 -3
- package/feature_filter/convert.ts +13 -6
- package/feature_filter/index.ts +16 -0
- package/format.ts +1 -0
- package/function/convert.ts +5 -1
- package/function/index.ts +28 -0
- package/group_by_layout.ts +17 -8
- package/migrate/expressions.ts +2 -2
- package/migrate/v8.ts +9 -0
- package/migrate/v9.ts +1 -0
- package/migrate.ts +1 -0
- package/package.json +1 -1
- package/read_style.ts +1 -0
- package/reference/latest.ts +1 -0
- package/reference/v8.json +209 -21
- package/types.ts +21 -2
- package/union-to-intersection.ts +1 -1
- package/util/color.ts +85 -69
- package/util/extend.ts +1 -0
- package/util/geometry_util.ts +7 -8
- package/util/interpolate.ts +0 -4
- package/validate/validate.ts +6 -0
- package/validate/validate_array.ts +2 -0
- package/validate/validate_enum.ts +1 -0
- package/validate/validate_expression.ts +4 -0
- package/validate/validate_filter.ts +4 -2
- package/validate/validate_fog.ts +3 -0
- package/validate/validate_function.ts +7 -2
- package/validate/validate_iconset.ts +1 -0
- package/validate/validate_layer.ts +1 -0
- package/validate/validate_light.ts +3 -0
- package/validate/validate_lights.ts +27 -21
- package/validate/validate_model.ts +4 -0
- package/validate/validate_object.ts +2 -2
- package/validate/validate_projection.ts +1 -0
- package/validate/validate_property.ts +4 -0
- package/validate/validate_rain.ts +3 -0
- package/validate/validate_snow.ts +3 -0
- package/validate/validate_source.ts +8 -6
- package/validate/validate_terrain.ts +4 -0
- package/validate_mapbox_api_supported.ts +30 -19
- package/validate_style.ts +1 -0
- package/visit.ts +3 -1
package/types.ts
CHANGED
|
@@ -59,6 +59,7 @@ export type CompositeFunctionSpecification<T> =
|
|
|
59
59
|
| { type: 'interval', stops: Array<[{zoom: number, value: number}, T]>, property: string, default?: T }
|
|
60
60
|
| { type: 'categorical', stops: Array<[{zoom: number, value: string | number | boolean}, T]>, property: string, default?: T };
|
|
61
61
|
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
63
|
export type ExpressionSpecification = [string, ...any[]];
|
|
63
64
|
|
|
64
65
|
export type PropertyValueSpecification<T> =
|
|
@@ -386,6 +387,10 @@ export type VectorSourceSpecification = {
|
|
|
386
387
|
"url"?: string,
|
|
387
388
|
"tiles"?: Array<string>,
|
|
388
389
|
"bounds"?: [number, number, number, number],
|
|
390
|
+
/**
|
|
391
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
392
|
+
*/
|
|
393
|
+
"extra_bounds"?: Array<[number, number, number, number]>,
|
|
389
394
|
"scheme"?: "xyz" | "tms",
|
|
390
395
|
"minzoom"?: number,
|
|
391
396
|
"maxzoom"?: number,
|
|
@@ -400,6 +405,10 @@ export type RasterSourceSpecification = {
|
|
|
400
405
|
"url"?: string,
|
|
401
406
|
"tiles"?: Array<string>,
|
|
402
407
|
"bounds"?: [number, number, number, number],
|
|
408
|
+
/**
|
|
409
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
410
|
+
*/
|
|
411
|
+
"extra_bounds"?: Array<[number, number, number, number]>,
|
|
403
412
|
"minzoom"?: number,
|
|
404
413
|
"maxzoom"?: number,
|
|
405
414
|
"tileSize"?: number,
|
|
@@ -414,6 +423,10 @@ export type RasterDEMSourceSpecification = {
|
|
|
414
423
|
"url"?: string,
|
|
415
424
|
"tiles"?: Array<string>,
|
|
416
425
|
"bounds"?: [number, number, number, number],
|
|
426
|
+
/**
|
|
427
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
428
|
+
*/
|
|
429
|
+
"extra_bounds"?: Array<[number, number, number, number]>,
|
|
417
430
|
"minzoom"?: number,
|
|
418
431
|
"maxzoom"?: number,
|
|
419
432
|
"tileSize"?: number,
|
|
@@ -431,6 +444,10 @@ export type RasterArraySourceSpecification = {
|
|
|
431
444
|
"url"?: string,
|
|
432
445
|
"tiles"?: Array<string>,
|
|
433
446
|
"bounds"?: [number, number, number, number],
|
|
447
|
+
/**
|
|
448
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
449
|
+
*/
|
|
450
|
+
"extra_bounds"?: Array<[number, number, number, number]>,
|
|
434
451
|
"minzoom"?: number,
|
|
435
452
|
"maxzoom"?: number,
|
|
436
453
|
"tileSize"?: number,
|
|
@@ -590,6 +607,7 @@ export type FillLayerSpecification = {
|
|
|
590
607
|
"fill-translate-transition"?: TransitionSpecification,
|
|
591
608
|
"fill-translate-anchor"?: PropertyValueSpecification<"map" | "viewport">,
|
|
592
609
|
"fill-pattern"?: DataDrivenPropertyValueSpecification<ResolvedImageSpecification>,
|
|
610
|
+
"fill-pattern-cross-fade"?: PropertyValueSpecification<number>,
|
|
593
611
|
"fill-emissive-strength"?: PropertyValueSpecification<number>,
|
|
594
612
|
"fill-emissive-strength-transition"?: TransitionSpecification,
|
|
595
613
|
/**
|
|
@@ -675,6 +693,7 @@ export type LineLayerSpecification = {
|
|
|
675
693
|
"line-blur-transition"?: TransitionSpecification,
|
|
676
694
|
"line-dasharray"?: DataDrivenPropertyValueSpecification<Array<number>>,
|
|
677
695
|
"line-pattern"?: DataDrivenPropertyValueSpecification<ResolvedImageSpecification>,
|
|
696
|
+
"line-pattern-cross-fade"?: PropertyValueSpecification<number>,
|
|
678
697
|
"line-gradient"?: ExpressionSpecification,
|
|
679
698
|
"line-gradient-use-theme"?: PropertyValueSpecification<string>,
|
|
680
699
|
"line-trim-offset"?: [number, number],
|
|
@@ -799,8 +818,7 @@ export type SymbolLayerSpecification = {
|
|
|
799
818
|
"icon-translate"?: PropertyValueSpecification<[number, number]>,
|
|
800
819
|
"icon-translate-transition"?: TransitionSpecification,
|
|
801
820
|
"icon-translate-anchor"?: PropertyValueSpecification<"map" | "viewport">,
|
|
802
|
-
"icon-image-cross-fade"?:
|
|
803
|
-
"icon-image-cross-fade-transition"?: TransitionSpecification,
|
|
821
|
+
"icon-image-cross-fade"?: PropertyValueSpecification<number>,
|
|
804
822
|
"text-opacity"?: DataDrivenPropertyValueSpecification<number>,
|
|
805
823
|
"text-opacity-transition"?: TransitionSpecification,
|
|
806
824
|
"text-occlusion-opacity"?: DataDrivenPropertyValueSpecification<number>,
|
|
@@ -958,6 +976,7 @@ export type FillExtrusionLayerSpecification = {
|
|
|
958
976
|
"fill-extrusion-translate-transition"?: TransitionSpecification,
|
|
959
977
|
"fill-extrusion-translate-anchor"?: PropertyValueSpecification<"map" | "viewport">,
|
|
960
978
|
"fill-extrusion-pattern"?: DataDrivenPropertyValueSpecification<ResolvedImageSpecification>,
|
|
979
|
+
"fill-extrusion-pattern-cross-fade"?: PropertyValueSpecification<number>,
|
|
961
980
|
"fill-extrusion-height"?: DataDrivenPropertyValueSpecification<number>,
|
|
962
981
|
"fill-extrusion-height-transition"?: TransitionSpecification,
|
|
963
982
|
"fill-extrusion-base"?: DataDrivenPropertyValueSpecification<number>,
|
package/union-to-intersection.ts
CHANGED
package/util/color.ts
CHANGED
|
@@ -56,9 +56,9 @@ class Color {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
return new Color(
|
|
59
|
-
rgba[0] / 255
|
|
60
|
-
rgba[1] / 255
|
|
61
|
-
rgba[2] / 255
|
|
59
|
+
rgba[0] / 255,
|
|
60
|
+
rgba[1] / 255,
|
|
61
|
+
rgba[2] / 255,
|
|
62
62
|
rgba[3]
|
|
63
63
|
);
|
|
64
64
|
}
|
|
@@ -73,16 +73,6 @@ class Color {
|
|
|
73
73
|
* var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');
|
|
74
74
|
* translucentGreen.toString(); // = "rgba(26,207,26,0.73)"
|
|
75
75
|
*/
|
|
76
|
-
toStringPremultipliedAlpha(): string {
|
|
77
|
-
const [r, g, b, a] = this.a === 0 ? [0, 0, 0, 0] : [
|
|
78
|
-
this.r * 255 / this.a,
|
|
79
|
-
this.g * 255 / this.a,
|
|
80
|
-
this.b * 255 / this.a,
|
|
81
|
-
this.a
|
|
82
|
-
];
|
|
83
|
-
return `rgba(${Math.round(r)},${Math.round(g)},${Math.round(b)},${a})`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
76
|
toString(): string {
|
|
87
77
|
const [r, g, b, a] = [
|
|
88
78
|
this.r,
|
|
@@ -93,9 +83,14 @@ class Color {
|
|
|
93
83
|
return `rgba(${Math.round(r * 255)},${Math.round(g * 255)},${Math.round(b * 255)},${a})`;
|
|
94
84
|
}
|
|
95
85
|
|
|
96
|
-
|
|
86
|
+
toNonPremultipliedRenderColor(lut: LUT | null): NonPremultipliedRenderColor {
|
|
87
|
+
const {r, g, b, a} = this;
|
|
88
|
+
return new NonPremultipliedRenderColor(lut, r, g, b, a);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
toPremultipliedRenderColor(lut: LUT | null): NonPremultipliedRenderColor {
|
|
97
92
|
const {r, g, b, a} = this;
|
|
98
|
-
return new
|
|
93
|
+
return new PremultipliedRenderColor(lut, r * a, g * a, b * a, a);
|
|
99
94
|
}
|
|
100
95
|
|
|
101
96
|
clone(): Color {
|
|
@@ -103,16 +98,16 @@ class Color {
|
|
|
103
98
|
}
|
|
104
99
|
}
|
|
105
100
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
export class RenderColor {
|
|
101
|
+
export abstract class RenderColor {
|
|
102
|
+
premultiplied: boolean = false;
|
|
103
|
+
|
|
110
104
|
r: number;
|
|
111
105
|
g: number;
|
|
112
106
|
b: number;
|
|
113
107
|
a: number;
|
|
114
108
|
|
|
115
|
-
constructor(lut: LUT | null, r: number, g: number, b: number, a: number) {
|
|
109
|
+
constructor(lut: LUT | null, r: number, g: number, b: number, a: number, premultiplied: boolean = false) {
|
|
110
|
+
this.premultiplied = premultiplied;
|
|
116
111
|
if (!lut) {
|
|
117
112
|
this.r = r;
|
|
118
113
|
this.g = g;
|
|
@@ -121,10 +116,18 @@ export class RenderColor {
|
|
|
121
116
|
} else {
|
|
122
117
|
const N = lut.image.height;
|
|
123
118
|
const N2 = N * N;
|
|
119
|
+
|
|
124
120
|
// Normalize to cube dimensions.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
|
|
122
|
+
if (this.premultiplied) {
|
|
123
|
+
r = a === 0 ? 0 : (r / a) * (N - 1);
|
|
124
|
+
g = a === 0 ? 0 : (g / a) * (N - 1);
|
|
125
|
+
b = a === 0 ? 0 : (b / a) * (N - 1);
|
|
126
|
+
} else {
|
|
127
|
+
r = r * (N - 1);
|
|
128
|
+
g = g * (N - 1);
|
|
129
|
+
b = b * (N - 1);
|
|
130
|
+
}
|
|
128
131
|
|
|
129
132
|
// Determine boundary values for the cube the color is in.
|
|
130
133
|
const r0 = Math.floor(r);
|
|
@@ -159,54 +162,59 @@ export class RenderColor {
|
|
|
159
162
|
lerp(data[i2], data[i3], bw), gw),
|
|
160
163
|
lerp(
|
|
161
164
|
lerp(data[i4], data[i5], bw),
|
|
162
|
-
lerp(data[i6], data[i7], bw), gw), rw) / 255 * a;
|
|
165
|
+
lerp(data[i6], data[i7], bw), gw), rw) / 255 * (this.premultiplied ? a : 1);
|
|
163
166
|
this.g = lerp(
|
|
164
167
|
lerp(
|
|
165
168
|
lerp(data[i0 + 1], data[i1 + 1], bw),
|
|
166
169
|
lerp(data[i2 + 1], data[i3 + 1], bw), gw),
|
|
167
170
|
lerp(
|
|
168
171
|
lerp(data[i4 + 1], data[i5 + 1], bw),
|
|
169
|
-
lerp(data[i6 + 1], data[i7 + 1], bw), gw), rw) / 255 * a;
|
|
172
|
+
lerp(data[i6 + 1], data[i7 + 1], bw), gw), rw) / 255 * (this.premultiplied ? a : 1);
|
|
170
173
|
this.b = lerp(
|
|
171
174
|
lerp(
|
|
172
175
|
lerp(data[i0 + 2], data[i1 + 2], bw),
|
|
173
176
|
lerp(data[i2 + 2], data[i3 + 2], bw), gw),
|
|
174
177
|
lerp(
|
|
175
178
|
lerp(data[i4 + 2], data[i5 + 2], bw),
|
|
176
|
-
lerp(data[i6 + 2], data[i7 + 2], bw), gw), rw) / 255 * a;
|
|
179
|
+
lerp(data[i6 + 2], data[i7 + 2], bw), gw), rw) / 255 * (this.premultiplied ? a : 1);
|
|
177
180
|
this.a = a;
|
|
178
181
|
}
|
|
179
182
|
}
|
|
180
183
|
|
|
181
184
|
/**
|
|
182
|
-
* Returns an RGBA array of values representing the color
|
|
183
|
-
*
|
|
185
|
+
* Returns an RGBA array of values representing the color.
|
|
184
186
|
* @returns An array of RGBA color values in the range [0, 255].
|
|
185
187
|
*/
|
|
186
188
|
toArray(): [number, number, number, number] {
|
|
187
189
|
const {r, g, b, a} = this;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
|
|
191
|
+
return [
|
|
192
|
+
r * 255,
|
|
193
|
+
g * 255,
|
|
194
|
+
b * 255,
|
|
192
195
|
a
|
|
193
196
|
];
|
|
197
|
+
|
|
194
198
|
}
|
|
195
199
|
|
|
196
200
|
/**
|
|
197
201
|
* Returns an HSLA array of values representing the color, unpremultiplied by A.
|
|
198
|
-
*
|
|
199
202
|
* @returns An array of HSLA color values.
|
|
200
203
|
*/
|
|
201
204
|
toHslaArray(): [number, number, number, number] {
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
let {r, g, b, a} = this;
|
|
206
|
+
|
|
207
|
+
if (this.premultiplied) {
|
|
208
|
+
if (a === 0) return [0, 0, 0, 0];
|
|
209
|
+
|
|
210
|
+
r /= a;
|
|
211
|
+
g /= a;
|
|
212
|
+
b /= a;
|
|
204
213
|
}
|
|
205
|
-
const {r, g, b, a} = this;
|
|
206
214
|
|
|
207
|
-
const red = Math.min(Math.max(r
|
|
208
|
-
const green = Math.min(Math.max(g
|
|
209
|
-
const blue = Math.min(Math.max(b
|
|
215
|
+
const red = Math.min(Math.max(r, 0.0), 1.0);
|
|
216
|
+
const green = Math.min(Math.max(g, 0.0), 1.0);
|
|
217
|
+
const blue = Math.min(Math.max(b, 0.0), 1.0);
|
|
210
218
|
|
|
211
219
|
const min = Math.min(red, green, blue);
|
|
212
220
|
const max = Math.max(red, green, blue);
|
|
@@ -241,16 +249,17 @@ export class RenderColor {
|
|
|
241
249
|
}
|
|
242
250
|
|
|
243
251
|
/**
|
|
244
|
-
* Returns a RGBA array of float values representing the color
|
|
252
|
+
* Returns a RGBA array of float values representing the color.
|
|
245
253
|
*
|
|
246
254
|
* @returns An array of RGBA color values in the range [0, 1].
|
|
247
255
|
*/
|
|
248
256
|
toArray01(): [number, number, number, number] {
|
|
249
257
|
const {r, g, b, a} = this;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
258
|
+
|
|
259
|
+
return [
|
|
260
|
+
r,
|
|
261
|
+
g,
|
|
262
|
+
b,
|
|
254
263
|
a
|
|
255
264
|
];
|
|
256
265
|
}
|
|
@@ -262,46 +271,53 @@ export class RenderColor {
|
|
|
262
271
|
* @returns An array of RGB color values in the range [0, 1].
|
|
263
272
|
*/
|
|
264
273
|
toArray01Scaled(scale: number): [number, number, number] {
|
|
265
|
-
const {r, g, b
|
|
266
|
-
return a === 0 ? [0, 0, 0] : [
|
|
267
|
-
(r / a) * scale,
|
|
268
|
-
(g / a) * scale,
|
|
269
|
-
(b / a) * scale
|
|
270
|
-
];
|
|
271
|
-
}
|
|
274
|
+
const {r, g, b} = this;
|
|
272
275
|
|
|
273
|
-
/**
|
|
274
|
-
* Returns an RGBA array of values representing the color, premultiplied by A.
|
|
275
|
-
*
|
|
276
|
-
* @returns An array of RGBA color values in the range [0, 1].
|
|
277
|
-
*/
|
|
278
|
-
toArray01PremultipliedAlpha(): [number, number, number, number] {
|
|
279
|
-
const {r, g, b, a} = this;
|
|
280
276
|
return [
|
|
281
|
-
r,
|
|
282
|
-
g,
|
|
283
|
-
b
|
|
284
|
-
a
|
|
277
|
+
r * scale,
|
|
278
|
+
g * scale,
|
|
279
|
+
b * scale
|
|
285
280
|
];
|
|
286
281
|
}
|
|
287
282
|
|
|
288
283
|
/**
|
|
289
|
-
* Returns an RGBA array of values representing the color
|
|
290
|
-
* The color is defined by sRGB primaries, but the sRGB transfer function
|
|
291
|
-
*
|
|
284
|
+
* Returns an RGBA array of values representing the color converted to linear color space.
|
|
285
|
+
* The color is defined by sRGB primaries, but the sRGB transfer function
|
|
286
|
+
* is reversed to obtain linear energy.
|
|
292
287
|
* @returns An array of RGBA color values in the range [0, 1].
|
|
293
288
|
*/
|
|
294
289
|
toArray01Linear(): [number, number, number, number] {
|
|
295
290
|
const {r, g, b, a} = this;
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
Math.pow(
|
|
299
|
-
Math.pow(
|
|
291
|
+
|
|
292
|
+
return [
|
|
293
|
+
Math.pow(r, 2.2),
|
|
294
|
+
Math.pow(g, 2.2),
|
|
295
|
+
Math.pow(b, 2.2),
|
|
300
296
|
a
|
|
301
297
|
];
|
|
302
298
|
}
|
|
303
299
|
}
|
|
304
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Renderable color created from a Color and an optional LUT value.
|
|
303
|
+
* Represent a color value with non-premultiplied alpha.
|
|
304
|
+
*/
|
|
305
|
+
export class NonPremultipliedRenderColor extends RenderColor {
|
|
306
|
+
constructor(lut: LUT | null, r: number, g: number, b: number, a: number) {
|
|
307
|
+
super(lut, r, g, b, a, false);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Renderable color created from a Color and an optional LUT value.
|
|
313
|
+
* Represent a color value with premultiplied alpha.
|
|
314
|
+
*/
|
|
315
|
+
export class PremultipliedRenderColor extends RenderColor {
|
|
316
|
+
constructor(lut: LUT | null, r: number, g: number, b: number, a: number) {
|
|
317
|
+
super(lut, r, g, b, a, true);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
305
321
|
Color.black = new Color(0, 0, 0, 1);
|
|
306
322
|
Color.white = new Color(1, 1, 1, 1);
|
|
307
323
|
Color.transparent = new Color(0, 0, 0, 0);
|
package/util/extend.ts
CHANGED
package/util/geometry_util.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import quickselect from 'quickselect';
|
|
2
2
|
import Point from '@mapbox/point-geometry';
|
|
3
3
|
|
|
4
|
+
type Ring = Point[] & {area?: number};
|
|
5
|
+
|
|
4
6
|
// minX, minY, maxX, maxY
|
|
5
7
|
export type BBox = [number, number, number, number];
|
|
6
8
|
|
|
@@ -9,7 +11,7 @@ export type BBox = [number, number, number, number];
|
|
|
9
11
|
* have a clockwise winding. Negative areas are interior rings and have a counter clockwise
|
|
10
12
|
* ordering.
|
|
11
13
|
*/
|
|
12
|
-
function calculateSignedArea(ring:
|
|
14
|
+
function calculateSignedArea(ring: Ring): number {
|
|
13
15
|
let sum = 0;
|
|
14
16
|
for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {
|
|
15
17
|
p1 = ring[i];
|
|
@@ -19,16 +21,12 @@ function calculateSignedArea(ring: Array<Point>): number {
|
|
|
19
21
|
return sum;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
function compareAreas(a: {
|
|
23
|
-
area: number;
|
|
24
|
-
}, b: {
|
|
25
|
-
area: number;
|
|
26
|
-
}) {
|
|
24
|
+
function compareAreas(a: Ring, b: Ring): number {
|
|
27
25
|
return b.area - a.area;
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
// classifies an array of rings into polygons with outer rings and holes
|
|
31
|
-
export function classifyRings(rings: Array<
|
|
29
|
+
export function classifyRings(rings: Array<Ring>, maxRings: number): Array<Array<Ring>> {
|
|
32
30
|
const len = rings.length;
|
|
33
31
|
|
|
34
32
|
if (len <= 1) return [rings];
|
|
@@ -41,7 +39,7 @@ export function classifyRings(rings: Array<Array<Point>>, maxRings: number): Arr
|
|
|
41
39
|
const area = calculateSignedArea(rings[i]);
|
|
42
40
|
if (area === 0) continue;
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
rings[i].area = Math.abs(area);
|
|
45
43
|
|
|
46
44
|
if (ccw === undefined) ccw = area < 0;
|
|
47
45
|
|
|
@@ -65,6 +63,7 @@ export function classifyRings(rings: Array<Array<Point>>, maxRings: number): Arr
|
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
65
|
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
68
67
|
return polygons;
|
|
69
68
|
}
|
|
70
69
|
|
package/util/interpolate.ts
CHANGED
package/validate/validate.ts
CHANGED
|
@@ -68,12 +68,16 @@ const VALIDATORS = {
|
|
|
68
68
|
// - styleSpec: current full spec being evaluated.
|
|
69
69
|
export type ValidationOptions = {
|
|
70
70
|
key: string;
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
72
|
value: any;
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
74
|
valueSpec?: any;
|
|
73
75
|
style: Partial<StyleSpecification>;
|
|
74
76
|
styleSpec: StyleReference;
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
78
|
object?: any;
|
|
76
79
|
objectKey?: string;
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
81
|
objectElementValidators?: Record<string, (...args: any[]) => Array<ValidationError>>;
|
|
78
82
|
};
|
|
79
83
|
|
|
@@ -83,6 +87,7 @@ export default function validate(options: ValidationOptions, arrayAsExpression:
|
|
|
83
87
|
const styleSpec = options.styleSpec;
|
|
84
88
|
|
|
85
89
|
if (valueSpec.expression && isFunction(unbundle(value))) {
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
86
91
|
return validateFunction(options);
|
|
87
92
|
} else if (valueSpec.expression && isExpression(deepUnbundle(value))) {
|
|
88
93
|
return validateExpression(options);
|
|
@@ -92,6 +97,7 @@ export default function validate(options: ValidationOptions, arrayAsExpression:
|
|
|
92
97
|
// Try to validate as an expression
|
|
93
98
|
return validateExpression(options);
|
|
94
99
|
} else {
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
95
101
|
return valid;
|
|
96
102
|
}
|
|
97
103
|
} else {
|
|
@@ -5,6 +5,7 @@ import ValidationError from '../error/validation_error';
|
|
|
5
5
|
import type {ValidationOptions} from './validate';
|
|
6
6
|
|
|
7
7
|
type Options = ValidationOptions & {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
9
|
arrayElementValidator: any;
|
|
9
10
|
};
|
|
10
11
|
|
|
@@ -56,5 +57,6 @@ export default function validateArray(options: Options): Array<ValidationError>
|
|
|
56
57
|
key: `${key}[${i}]`
|
|
57
58
|
}, true));
|
|
58
59
|
}
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
59
61
|
return errors;
|
|
60
62
|
}
|
|
@@ -18,5 +18,6 @@ export default function validateEnum(options: ValidationOptions): Array<Validati
|
|
|
18
18
|
errors.push(new ValidationError(key, value, `expected one of [${Object.keys(valueSpec.values).join(', ')}], ${JSON.stringify(value)} found`));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
21
22
|
return errors;
|
|
22
23
|
}
|
|
@@ -6,6 +6,7 @@ import CompoundExpression from '../expression/compound_expression';
|
|
|
6
6
|
|
|
7
7
|
import type {Expression} from '../expression/expression';
|
|
8
8
|
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
10
|
export default function validateExpression(options: any): Array<ValidationError> {
|
|
10
11
|
const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);
|
|
11
12
|
if (expression.result === 'error') {
|
|
@@ -14,6 +15,7 @@ export default function validateExpression(options: any): Array<ValidationError>
|
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
19
|
const expressionObj = (expression.value as any).expression || (expression.value as any)._styleExpression.expression;
|
|
18
20
|
|
|
19
21
|
if (options.expressionContext === 'property' && (options.propertyKey === 'text-font') &&
|
|
@@ -42,6 +44,7 @@ export default function validateExpression(options: any): Array<ValidationError>
|
|
|
42
44
|
return [];
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
48
|
export function disallowedFilterParameters(e: Expression, options: any): Array<ValidationError> {
|
|
46
49
|
const disallowedParameters = new Set([
|
|
47
50
|
'zoom',
|
|
@@ -70,5 +73,6 @@ export function disallowedFilterParameters(e: Expression, options: any): Array<V
|
|
|
70
73
|
errors.push(...disallowedFilterParameters(arg, options));
|
|
71
74
|
});
|
|
72
75
|
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
73
77
|
return errors;
|
|
74
78
|
}
|
|
@@ -26,6 +26,7 @@ export default function validateFilter(options: Options): Array<ValidationError>
|
|
|
26
26
|
valueSpec: options.styleSpec[`filter_${layerType}`]
|
|
27
27
|
}));
|
|
28
28
|
} else {
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
29
30
|
return validateNonExpressionFilter(options);
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -100,12 +101,12 @@ function validateNonExpressionFilter(options: Options) {
|
|
|
100
101
|
case 'all':
|
|
101
102
|
case 'none':
|
|
102
103
|
for (let i = 1; i < value.length; i++) {
|
|
103
|
-
errors = errors.concat(validateNonExpressionFilter(
|
|
104
|
+
errors = errors.concat(validateNonExpressionFilter({
|
|
104
105
|
key: `${key}[${i}]`,
|
|
105
106
|
value: value[i],
|
|
106
107
|
style: options.style,
|
|
107
108
|
styleSpec: options.styleSpec
|
|
108
|
-
}
|
|
109
|
+
}));
|
|
109
110
|
}
|
|
110
111
|
break;
|
|
111
112
|
|
|
@@ -119,5 +120,6 @@ function validateNonExpressionFilter(options: Options) {
|
|
|
119
120
|
}
|
|
120
121
|
break;
|
|
121
122
|
}
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
122
124
|
return errors;
|
|
123
125
|
}
|
package/validate/validate_fog.ts
CHANGED
|
@@ -13,9 +13,11 @@ export default function validateFog(options: ValidationOptions): Array<Validatio
|
|
|
13
13
|
|
|
14
14
|
const rootType = getType(fog);
|
|
15
15
|
if (fog === undefined) {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
16
17
|
return errors;
|
|
17
18
|
} else if (rootType !== 'object') {
|
|
18
19
|
errors = errors.concat([new ValidationError('fog', fog, `object expected, ${rootType} found`)]);
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
19
21
|
return errors;
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -52,5 +54,6 @@ export default function validateFog(options: ValidationOptions): Array<Validatio
|
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
55
58
|
return errors;
|
|
56
59
|
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
|
|
15
15
|
import type {ValidationOptions} from './validate';
|
|
16
16
|
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
18
|
export default function validateFunction(options: ValidationOptions): any {
|
|
18
19
|
const functionValueSpec = options.valueSpec;
|
|
19
20
|
const functionType = unbundle(options.value.type);
|
|
@@ -88,6 +89,7 @@ export default function validateFunction(options: ValidationOptions): any {
|
|
|
88
89
|
errors.push(new ValidationError(options.key, value, 'array must have at least one stop'));
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
91
93
|
return errors;
|
|
92
94
|
}
|
|
93
95
|
|
|
@@ -147,9 +149,11 @@ export default function validateFunction(options: ValidationOptions): any {
|
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
if (isExpression(deepUnbundle(value[1]))) {
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
150
153
|
return errors.concat([new ValidationError(`${key}[1]`, value[1], 'expressions are not allowed in function stops.')]);
|
|
151
154
|
}
|
|
152
155
|
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
153
157
|
return errors.concat(validate({
|
|
154
158
|
key: `${key}[1]`,
|
|
155
159
|
value: value[1],
|
|
@@ -159,6 +163,7 @@ export default function validateFunction(options: ValidationOptions): any {
|
|
|
159
163
|
}));
|
|
160
164
|
}
|
|
161
165
|
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
162
167
|
function validateStopDomainValue(options: ValidationOptions, stop: any) {
|
|
163
168
|
const type = getType(options.value);
|
|
164
169
|
const value = unbundle(options.value);
|
|
@@ -193,10 +198,10 @@ export default function validateFunction(options: ValidationOptions): any {
|
|
|
193
198
|
previousStopDomainValue = value;
|
|
194
199
|
}
|
|
195
200
|
|
|
196
|
-
if (functionType === 'categorical' && (value as
|
|
201
|
+
if (functionType === 'categorical' && (value as string) in stopDomainValues) {
|
|
197
202
|
return [new ValidationError(options.key, reportValue, 'stop domain values must be unique')];
|
|
198
203
|
} else {
|
|
199
|
-
stopDomainValues[(value as
|
|
204
|
+
stopDomainValues[(value as string)] = true;
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
return [];
|
|
@@ -14,9 +14,11 @@ export default function validateLight(options: ValidationOptions): Array<Validat
|
|
|
14
14
|
|
|
15
15
|
const rootType = getType(light);
|
|
16
16
|
if (light === undefined) {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
17
18
|
return errors;
|
|
18
19
|
} else if (rootType !== 'object') {
|
|
19
20
|
errors = errors.concat([new ValidationError('light', light, `object expected, ${rootType} found`)]);
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
20
22
|
return errors;
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -53,5 +55,6 @@ export default function validateLight(options: ValidationOptions): Array<Validat
|
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
56
59
|
return errors;
|
|
57
60
|
}
|