@mapbox/mapbox-gl-style-spec 14.11.0-beta.2 → 14.12.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/diff.ts +47 -11
- package/dist/index.cjs +687 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +186 -13
- package/dist/index.es.js +687 -30
- package/dist/index.es.js.map +1 -1
- package/expression/compound_expression.ts +1 -1
- package/expression/definitions/coalesce.ts +2 -2
- package/expression/definitions/config.ts +1 -1
- package/expression/definitions/image.ts +1 -11
- package/expression/definitions/index.ts +3 -2
- package/expression/definitions/interpolate.ts +3 -3
- package/expression/definitions/match.ts +1 -1
- package/expression/definitions/step.ts +1 -1
- package/expression/evaluation_context.ts +3 -5
- package/expression/index.ts +4 -8
- package/expression/parsing_context.ts +1 -1
- package/expression/types/image_id.ts +6 -8
- package/expression/types.ts +1 -1
- package/expression/values.ts +1 -3
- package/feature_filter/index.ts +1 -1
- package/function/index.ts +3 -3
- package/migrate/expressions.ts +1 -1
- package/migrate/v8.ts +1 -1
- package/migrate/v9.ts +1 -1
- package/migrate.ts +1 -1
- package/package.json +1 -1
- package/read_style.ts +4 -6
- package/reference/v8.json +313 -0
- package/test.js +2 -5
- package/types.ts +195 -0
- package/util/extend.ts +1 -1
- package/util/geometry_util.ts +19 -2
- package/util/interpolate.ts +4 -0
- package/validate/validate_fog.ts +1 -1
- package/validate/validate_glyphs_url.ts +1 -1
- package/validate/validate_layer.ts +2 -2
- package/validate/validate_light.ts +1 -1
- package/validate/validate_lights.ts +1 -1
- package/validate/validate_property.ts +1 -1
- package/validate/validate_source.ts +2 -4
- package/validate/validate_style.ts +2 -1
- package/validate/validate_terrain.ts +1 -1
- package/validate_mapbox_api_supported.ts +1 -1
- package/validate_style.min.ts +17 -15
- package/validate_style.ts +3 -3
- package/visit.ts +1 -1
package/types.ts
CHANGED
|
@@ -171,49 +171,106 @@ export type FogSpecification = {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
export type SnowSpecification = {
|
|
174
|
+
/**
|
|
175
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
176
|
+
*/
|
|
174
177
|
"density"?: PropertyValueSpecification<number>,
|
|
175
178
|
"density-transition"?: TransitionSpecification,
|
|
179
|
+
/**
|
|
180
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
181
|
+
*/
|
|
176
182
|
"intensity"?: PropertyValueSpecification<number>,
|
|
177
183
|
"intensity-transition"?: TransitionSpecification,
|
|
184
|
+
/**
|
|
185
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
186
|
+
*/
|
|
178
187
|
"color"?: PropertyValueSpecification<ColorSpecification>,
|
|
179
188
|
"color-transition"?: TransitionSpecification,
|
|
180
189
|
"color-use-theme"?: PropertyValueSpecification<string>,
|
|
190
|
+
/**
|
|
191
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
192
|
+
*/
|
|
181
193
|
"opacity"?: PropertyValueSpecification<number>,
|
|
182
194
|
"opacity-transition"?: TransitionSpecification,
|
|
195
|
+
/**
|
|
196
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
197
|
+
*/
|
|
183
198
|
"vignette"?: PropertyValueSpecification<number>,
|
|
184
199
|
"vignette-transition"?: TransitionSpecification,
|
|
200
|
+
/**
|
|
201
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
202
|
+
*/
|
|
185
203
|
"vignette-color"?: PropertyValueSpecification<ColorSpecification>,
|
|
186
204
|
"vignette-color-transition"?: TransitionSpecification,
|
|
187
205
|
"vignette-color-use-theme"?: PropertyValueSpecification<string>,
|
|
206
|
+
/**
|
|
207
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
208
|
+
*/
|
|
188
209
|
"center-thinning"?: PropertyValueSpecification<number>,
|
|
189
210
|
"center-thinning-transition"?: TransitionSpecification,
|
|
211
|
+
/**
|
|
212
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
213
|
+
*/
|
|
190
214
|
"direction"?: PropertyValueSpecification<[number, number]>,
|
|
191
215
|
"direction-transition"?: TransitionSpecification,
|
|
216
|
+
/**
|
|
217
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
218
|
+
*/
|
|
192
219
|
"flake-size"?: PropertyValueSpecification<number>,
|
|
193
220
|
"flake-size-transition"?: TransitionSpecification
|
|
194
221
|
}
|
|
195
222
|
|
|
196
223
|
export type RainSpecification = {
|
|
224
|
+
/**
|
|
225
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
226
|
+
*/
|
|
197
227
|
"density"?: PropertyValueSpecification<number>,
|
|
198
228
|
"density-transition"?: TransitionSpecification,
|
|
229
|
+
/**
|
|
230
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
231
|
+
*/
|
|
199
232
|
"intensity"?: PropertyValueSpecification<number>,
|
|
200
233
|
"intensity-transition"?: TransitionSpecification,
|
|
234
|
+
/**
|
|
235
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
236
|
+
*/
|
|
201
237
|
"color"?: PropertyValueSpecification<ColorSpecification>,
|
|
202
238
|
"color-transition"?: TransitionSpecification,
|
|
203
239
|
"color-use-theme"?: PropertyValueSpecification<string>,
|
|
240
|
+
/**
|
|
241
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
242
|
+
*/
|
|
204
243
|
"opacity"?: PropertyValueSpecification<number>,
|
|
205
244
|
"opacity-transition"?: TransitionSpecification,
|
|
245
|
+
/**
|
|
246
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
247
|
+
*/
|
|
206
248
|
"vignette"?: PropertyValueSpecification<number>,
|
|
207
249
|
"vignette-transition"?: TransitionSpecification,
|
|
250
|
+
/**
|
|
251
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
252
|
+
*/
|
|
208
253
|
"vignette-color"?: PropertyValueSpecification<ColorSpecification>,
|
|
209
254
|
"vignette-color-transition"?: TransitionSpecification,
|
|
210
255
|
"vignette-color-use-theme"?: PropertyValueSpecification<string>,
|
|
256
|
+
/**
|
|
257
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
258
|
+
*/
|
|
211
259
|
"center-thinning"?: PropertyValueSpecification<number>,
|
|
212
260
|
"center-thinning-transition"?: TransitionSpecification,
|
|
261
|
+
/**
|
|
262
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
263
|
+
*/
|
|
213
264
|
"direction"?: PropertyValueSpecification<[number, number]>,
|
|
214
265
|
"direction-transition"?: TransitionSpecification,
|
|
266
|
+
/**
|
|
267
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
268
|
+
*/
|
|
215
269
|
"droplet-size"?: PropertyValueSpecification<[number, number]>,
|
|
216
270
|
"droplet-size-transition"?: TransitionSpecification,
|
|
271
|
+
/**
|
|
272
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
273
|
+
*/
|
|
217
274
|
"distortion-strength"?: PropertyValueSpecification<number>,
|
|
218
275
|
"distortion-strength-transition"?: TransitionSpecification
|
|
219
276
|
}
|
|
@@ -535,11 +592,20 @@ export type FillLayerSpecification = {
|
|
|
535
592
|
"fill-pattern"?: DataDrivenPropertyValueSpecification<ResolvedImageSpecification>,
|
|
536
593
|
"fill-emissive-strength"?: PropertyValueSpecification<number>,
|
|
537
594
|
"fill-emissive-strength-transition"?: TransitionSpecification,
|
|
595
|
+
/**
|
|
596
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
597
|
+
*/
|
|
538
598
|
"fill-z-offset"?: DataDrivenPropertyValueSpecification<number>,
|
|
539
599
|
"fill-z-offset-transition"?: TransitionSpecification,
|
|
600
|
+
/**
|
|
601
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
602
|
+
*/
|
|
540
603
|
"fill-bridge-guard-rail-color"?: DataDrivenPropertyValueSpecification<ColorSpecification>,
|
|
541
604
|
"fill-bridge-guard-rail-color-transition"?: TransitionSpecification,
|
|
542
605
|
"fill-bridge-guard-rail-color-use-theme"?: PropertyValueSpecification<string>,
|
|
606
|
+
/**
|
|
607
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
608
|
+
*/
|
|
543
609
|
"fill-tunnel-structure-color"?: DataDrivenPropertyValueSpecification<ColorSpecification>,
|
|
544
610
|
"fill-tunnel-structure-color-transition"?: TransitionSpecification,
|
|
545
611
|
"fill-tunnel-structure-color-use-theme"?: PropertyValueSpecification<string>
|
|
@@ -616,6 +682,9 @@ export type LineLayerSpecification = {
|
|
|
616
682
|
* @experimental This property is experimental and subject to change in future versions.
|
|
617
683
|
*/
|
|
618
684
|
"line-trim-fade-range"?: PropertyValueSpecification<[number, number]>,
|
|
685
|
+
/**
|
|
686
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
687
|
+
*/
|
|
619
688
|
"line-trim-color"?: PropertyValueSpecification<ColorSpecification>,
|
|
620
689
|
"line-trim-color-transition"?: TransitionSpecification,
|
|
621
690
|
"line-trim-color-use-theme"?: PropertyValueSpecification<string>,
|
|
@@ -753,6 +822,9 @@ export type SymbolLayerSpecification = {
|
|
|
753
822
|
"icon-color-contrast"?: ExpressionSpecification,
|
|
754
823
|
"icon-color-brightness-min"?: ExpressionSpecification,
|
|
755
824
|
"icon-color-brightness-max"?: ExpressionSpecification,
|
|
825
|
+
/**
|
|
826
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
827
|
+
*/
|
|
756
828
|
"symbol-z-offset"?: DataDrivenPropertyValueSpecification<number>,
|
|
757
829
|
"symbol-z-offset-transition"?: TransitionSpecification
|
|
758
830
|
}
|
|
@@ -903,23 +975,50 @@ export type FillExtrusionLayerSpecification = {
|
|
|
903
975
|
"fill-extrusion-ambient-occlusion-intensity-transition"?: TransitionSpecification,
|
|
904
976
|
"fill-extrusion-ambient-occlusion-radius"?: PropertyValueSpecification<number>,
|
|
905
977
|
"fill-extrusion-ambient-occlusion-radius-transition"?: TransitionSpecification,
|
|
978
|
+
/**
|
|
979
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
980
|
+
*/
|
|
906
981
|
"fill-extrusion-ambient-occlusion-wall-radius"?: PropertyValueSpecification<number>,
|
|
907
982
|
"fill-extrusion-ambient-occlusion-wall-radius-transition"?: TransitionSpecification,
|
|
983
|
+
/**
|
|
984
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
985
|
+
*/
|
|
908
986
|
"fill-extrusion-ambient-occlusion-ground-radius"?: PropertyValueSpecification<number>,
|
|
909
987
|
"fill-extrusion-ambient-occlusion-ground-radius-transition"?: TransitionSpecification,
|
|
988
|
+
/**
|
|
989
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
990
|
+
*/
|
|
910
991
|
"fill-extrusion-ambient-occlusion-ground-attenuation"?: PropertyValueSpecification<number>,
|
|
911
992
|
"fill-extrusion-ambient-occlusion-ground-attenuation-transition"?: TransitionSpecification,
|
|
993
|
+
/**
|
|
994
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
995
|
+
*/
|
|
912
996
|
"fill-extrusion-flood-light-color"?: PropertyValueSpecification<ColorSpecification>,
|
|
913
997
|
"fill-extrusion-flood-light-color-transition"?: TransitionSpecification,
|
|
914
998
|
"fill-extrusion-flood-light-color-use-theme"?: PropertyValueSpecification<string>,
|
|
999
|
+
/**
|
|
1000
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1001
|
+
*/
|
|
915
1002
|
"fill-extrusion-flood-light-intensity"?: PropertyValueSpecification<number>,
|
|
916
1003
|
"fill-extrusion-flood-light-intensity-transition"?: TransitionSpecification,
|
|
1004
|
+
/**
|
|
1005
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1006
|
+
*/
|
|
917
1007
|
"fill-extrusion-flood-light-wall-radius"?: DataDrivenPropertyValueSpecification<number>,
|
|
918
1008
|
"fill-extrusion-flood-light-wall-radius-transition"?: TransitionSpecification,
|
|
1009
|
+
/**
|
|
1010
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1011
|
+
*/
|
|
919
1012
|
"fill-extrusion-flood-light-ground-radius"?: DataDrivenPropertyValueSpecification<number>,
|
|
920
1013
|
"fill-extrusion-flood-light-ground-radius-transition"?: TransitionSpecification,
|
|
1014
|
+
/**
|
|
1015
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1016
|
+
*/
|
|
921
1017
|
"fill-extrusion-flood-light-ground-attenuation"?: PropertyValueSpecification<number>,
|
|
922
1018
|
"fill-extrusion-flood-light-ground-attenuation-transition"?: TransitionSpecification,
|
|
1019
|
+
/**
|
|
1020
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1021
|
+
*/
|
|
923
1022
|
"fill-extrusion-vertical-scale"?: PropertyValueSpecification<number>,
|
|
924
1023
|
"fill-extrusion-vertical-scale-transition"?: TransitionSpecification,
|
|
925
1024
|
/**
|
|
@@ -929,6 +1028,9 @@ export type FillExtrusionLayerSpecification = {
|
|
|
929
1028
|
"fill-extrusion-cutoff-fade-range"?: ExpressionSpecification,
|
|
930
1029
|
"fill-extrusion-emissive-strength"?: DataDrivenPropertyValueSpecification<number>,
|
|
931
1030
|
"fill-extrusion-emissive-strength-transition"?: TransitionSpecification,
|
|
1031
|
+
/**
|
|
1032
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1033
|
+
*/
|
|
932
1034
|
"fill-extrusion-line-width"?: DataDrivenPropertyValueSpecification<number>,
|
|
933
1035
|
"fill-extrusion-line-width-transition"?: TransitionSpecification,
|
|
934
1036
|
"fill-extrusion-cast-shadows"?: boolean
|
|
@@ -945,6 +1047,90 @@ export type FillExtrusionLayout = FillExtrusionLayerSpecification['layout'];
|
|
|
945
1047
|
*/
|
|
946
1048
|
export type FillExtrusionPaint = FillExtrusionLayerSpecification['paint'];
|
|
947
1049
|
|
|
1050
|
+
export type BuildingLayerSpecification = {
|
|
1051
|
+
"id": string,
|
|
1052
|
+
"type": "building",
|
|
1053
|
+
"metadata"?: unknown,
|
|
1054
|
+
"source": string,
|
|
1055
|
+
"source-layer"?: string,
|
|
1056
|
+
"slot"?: string,
|
|
1057
|
+
"minzoom"?: number,
|
|
1058
|
+
"maxzoom"?: number,
|
|
1059
|
+
"filter"?: FilterSpecification,
|
|
1060
|
+
"layout"?: {
|
|
1061
|
+
"visibility"?: "visible" | "none" | ExpressionSpecification,
|
|
1062
|
+
/**
|
|
1063
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1064
|
+
*/
|
|
1065
|
+
"building-roof-shape"?: DataDrivenPropertyValueSpecification<"flat" | "hipped" | "gabled" | "parapet" | "mansard" | "skillion" | "pyramidal">,
|
|
1066
|
+
/**
|
|
1067
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1068
|
+
*/
|
|
1069
|
+
"building-height"?: DataDrivenPropertyValueSpecification<number>,
|
|
1070
|
+
"building-height-transition"?: TransitionSpecification,
|
|
1071
|
+
/**
|
|
1072
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1073
|
+
*/
|
|
1074
|
+
"building-base"?: DataDrivenPropertyValueSpecification<number>,
|
|
1075
|
+
"building-base-transition"?: TransitionSpecification
|
|
1076
|
+
},
|
|
1077
|
+
"paint"?: {
|
|
1078
|
+
/**
|
|
1079
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1080
|
+
*/
|
|
1081
|
+
"building-opacity"?: PropertyValueSpecification<number>,
|
|
1082
|
+
"building-opacity-transition"?: TransitionSpecification,
|
|
1083
|
+
/**
|
|
1084
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1085
|
+
*/
|
|
1086
|
+
"building-ambient-occlusion-wall-intensity"?: PropertyValueSpecification<number>,
|
|
1087
|
+
"building-ambient-occlusion-wall-intensity-transition"?: TransitionSpecification,
|
|
1088
|
+
/**
|
|
1089
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1090
|
+
*/
|
|
1091
|
+
"building-ambient-occlusion-ground-intensity"?: PropertyValueSpecification<number>,
|
|
1092
|
+
"building-ambient-occlusion-ground-intensity-transition"?: TransitionSpecification,
|
|
1093
|
+
/**
|
|
1094
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1095
|
+
*/
|
|
1096
|
+
"building-ambient-occlusion-ground-radius"?: PropertyValueSpecification<number>,
|
|
1097
|
+
"building-ambient-occlusion-ground-radius-transition"?: TransitionSpecification,
|
|
1098
|
+
/**
|
|
1099
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1100
|
+
*/
|
|
1101
|
+
"building-ambient-occlusion-ground-attenuation"?: PropertyValueSpecification<number>,
|
|
1102
|
+
"building-ambient-occlusion-ground-attenuation-transition"?: TransitionSpecification,
|
|
1103
|
+
/**
|
|
1104
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1105
|
+
*/
|
|
1106
|
+
"building-vertical-scale"?: PropertyValueSpecification<number>,
|
|
1107
|
+
"building-vertical-scale-transition"?: TransitionSpecification,
|
|
1108
|
+
/**
|
|
1109
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1110
|
+
*/
|
|
1111
|
+
"building-cast-shadows"?: boolean,
|
|
1112
|
+
/**
|
|
1113
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1114
|
+
*/
|
|
1115
|
+
"building-color"?: DataDrivenPropertyValueSpecification<ColorSpecification>,
|
|
1116
|
+
"building-color-use-theme"?: PropertyValueSpecification<string>,
|
|
1117
|
+
/**
|
|
1118
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1119
|
+
*/
|
|
1120
|
+
"building-emissive-strength"?: DataDrivenPropertyValueSpecification<number>
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* @deprecated Use `BuildingLayerSpecification['layout']` instead.
|
|
1126
|
+
*/
|
|
1127
|
+
export type BuildingLayout = BuildingLayerSpecification['layout'];
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* @deprecated Use `BuildingLayerSpecification['paint']` instead.
|
|
1131
|
+
*/
|
|
1132
|
+
export type BuildingPaint = BuildingLayerSpecification['paint'];
|
|
1133
|
+
|
|
948
1134
|
export type RasterLayerSpecification = {
|
|
949
1135
|
"id": string,
|
|
950
1136
|
"type": "raster",
|
|
@@ -985,6 +1171,9 @@ export type RasterLayerSpecification = {
|
|
|
985
1171
|
* @experimental This property is experimental and subject to change in future versions.
|
|
986
1172
|
*/
|
|
987
1173
|
"raster-array-band"?: string,
|
|
1174
|
+
/**
|
|
1175
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1176
|
+
*/
|
|
988
1177
|
"raster-elevation"?: PropertyValueSpecification<number>,
|
|
989
1178
|
"raster-elevation-transition"?: TransitionSpecification
|
|
990
1179
|
}
|
|
@@ -1257,6 +1446,7 @@ export type LayerSpecification =
|
|
|
1257
1446
|
| CircleLayerSpecification
|
|
1258
1447
|
| HeatmapLayerSpecification
|
|
1259
1448
|
| FillExtrusionLayerSpecification
|
|
1449
|
+
| BuildingLayerSpecification
|
|
1260
1450
|
| RasterLayerSpecification
|
|
1261
1451
|
| RasterParticleLayerSpecification
|
|
1262
1452
|
| HillshadeLayerSpecification
|
|
@@ -1327,6 +1517,11 @@ export type HeatmapLayer = HeatmapLayerSpecification;
|
|
|
1327
1517
|
*/
|
|
1328
1518
|
export type FillExtrusionLayer = FillExtrusionLayerSpecification;
|
|
1329
1519
|
|
|
1520
|
+
/**
|
|
1521
|
+
* @deprecated Use `BuildingLayerSpecification` instead.
|
|
1522
|
+
*/
|
|
1523
|
+
export type BuildingLayer = BuildingLayerSpecification;
|
|
1524
|
+
|
|
1330
1525
|
/**
|
|
1331
1526
|
* @deprecated Use `RasterLayerSpecification` instead.
|
|
1332
1527
|
*/
|
package/util/extend.ts
CHANGED
package/util/geometry_util.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import quickselect from 'quickselect';
|
|
2
|
-
|
|
3
|
-
import type Point from '@mapbox/point-geometry';
|
|
2
|
+
import Point from '@mapbox/point-geometry';
|
|
4
3
|
|
|
5
4
|
// minX, minY, maxX, maxY
|
|
6
5
|
export type BBox = [number, number, number, number];
|
|
@@ -154,3 +153,21 @@ export function segmentIntersectSegment(
|
|
|
154
153
|
return false;
|
|
155
154
|
}
|
|
156
155
|
|
|
156
|
+
export interface Bounds {
|
|
157
|
+
min: Point;
|
|
158
|
+
max: Point;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function computeBounds(points: Point[][]): Bounds {
|
|
162
|
+
const min = new Point(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
163
|
+
const max = new Point(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);
|
|
164
|
+
|
|
165
|
+
for (const point of points[0]) {
|
|
166
|
+
if (min.x > point.x) min.x = point.x;
|
|
167
|
+
if (min.y > point.y) min.y = point.y;
|
|
168
|
+
if (max.x < point.x) max.x = point.x;
|
|
169
|
+
if (max.y < point.y) max.y = point.y;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return {min, max};
|
|
173
|
+
}
|
package/util/interpolate.ts
CHANGED
package/validate/validate_fog.ts
CHANGED
|
@@ -3,7 +3,7 @@ import validateString from './validate_string';
|
|
|
3
3
|
|
|
4
4
|
import type {ValidationOptions} from './validate';
|
|
5
5
|
|
|
6
|
-
export default function(options: ValidationOptions): Array<ValidationError> {
|
|
6
|
+
export default function (options: ValidationOptions): Array<ValidationError> {
|
|
7
7
|
const value = options.value;
|
|
8
8
|
const key = options.key;
|
|
9
9
|
|
|
@@ -79,8 +79,8 @@ export default function validateLayer(options: Options): Array<ValidationError>
|
|
|
79
79
|
} else if (sourceType === 'raster-array' && !['raster', 'raster-particle'].includes(type)) {
|
|
80
80
|
errors.push(new ValidationError(key, layer.source, `raster-array source can only be used with layer type \'raster\'.`));
|
|
81
81
|
} else if (type === 'line' && layer.paint && (layer.paint['line-gradient'] || layer.paint['line-trim-offset']) &&
|
|
82
|
-
(sourceType
|
|
83
|
-
errors.push(new ValidationError(key, layer, `layer "${layer.id}" specifies a line-gradient, which requires
|
|
82
|
+
(sourceType === 'geojson' && !(source as GeoJSONSourceSpecification).lineMetrics)) {
|
|
83
|
+
errors.push(new ValidationError(key, layer, `layer "${layer.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`));
|
|
84
84
|
} else if (type === 'raster-particle' && sourceType !== 'raster-array') {
|
|
85
85
|
errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a \'raster-array\' source.`));
|
|
86
86
|
}
|
|
@@ -25,10 +25,9 @@ export default function validateSource(options: ValidationOptions): Array<Valida
|
|
|
25
25
|
return [new ValidationError(key, value, '"type" is required')];
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const type = unbundle(value.type);
|
|
28
|
+
const type = unbundle(value.type) as string;
|
|
29
29
|
let errors = [];
|
|
30
30
|
|
|
31
|
-
// @ts-expect-error - TS2345 - Argument of type 'unknown' is not assignable to parameter of type 'string'.
|
|
32
31
|
if (['vector', 'raster', 'raster-dem', 'raster-array'].includes(type)) {
|
|
33
32
|
if (!value.url && !value.tiles) {
|
|
34
33
|
errors.push(new ValidationWarning(key, value, 'Either "url" or "tiles" is required.'));
|
|
@@ -111,8 +110,7 @@ export default function validateSource(options: ValidationOptions): Array<Valida
|
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
function getSourceTypeValues(styleSpec: StyleReference) {
|
|
114
|
-
|
|
115
|
-
return styleSpec.source.reduce<Array<any>>((memo, source) => {
|
|
113
|
+
return styleSpec.source.reduce((memo, source) => {
|
|
116
114
|
const sourceType = styleSpec[source];
|
|
117
115
|
if (sourceType.type.type === 'enum') {
|
|
118
116
|
memo = memo.concat(Object.keys(sourceType.type.values));
|
|
@@ -3,6 +3,7 @@ import latestStyleSpec from '../reference/latest';
|
|
|
3
3
|
import validateGlyphsURL from './validate_glyphs_url';
|
|
4
4
|
|
|
5
5
|
import type ValidationError from '../error/validation_error';
|
|
6
|
+
import type {StyleReference} from '../reference/latest';
|
|
6
7
|
import type {ValidationOptions} from './validate';
|
|
7
8
|
import type {StyleSpecification} from '../types';
|
|
8
9
|
|
|
@@ -12,7 +13,7 @@ type StyleValidationOptions = {
|
|
|
12
13
|
|
|
13
14
|
export default function validateStyle(
|
|
14
15
|
style: StyleSpecification,
|
|
15
|
-
styleSpec:
|
|
16
|
+
styleSpec: StyleReference = latestStyleSpec,
|
|
16
17
|
options: StyleValidationOptions = {},
|
|
17
18
|
): ValidationError[] {
|
|
18
19
|
const errors = validate({
|
package/validate_style.min.ts
CHANGED
|
@@ -13,6 +13,7 @@ import _validatePaintProperty from './validate/validate_paint_property';
|
|
|
13
13
|
import _validateLayoutProperty from './validate/validate_layout_property';
|
|
14
14
|
import _validateModel from './validate/validate_model';
|
|
15
15
|
|
|
16
|
+
import type {StyleReference} from './reference/latest';
|
|
16
17
|
import type {StyleSpecification} from './types';
|
|
17
18
|
|
|
18
19
|
export type ValidationError = {
|
|
@@ -20,8 +21,9 @@ export type ValidationError = {
|
|
|
20
21
|
identifier?: string | null | undefined;
|
|
21
22
|
line?: number | null | undefined;
|
|
22
23
|
};
|
|
24
|
+
|
|
23
25
|
export type ValidationErrors = ReadonlyArray<ValidationError>;
|
|
24
|
-
export type Validator = (
|
|
26
|
+
export type Validator<T extends (...args: unknown[]) => unknown = (...args: unknown[]) => unknown> = (...args: Parameters<T>) => ValidationErrors;
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Validate a Mapbox GL style against the style specification. This entrypoint,
|
|
@@ -38,24 +40,24 @@ export type Validator = (arg1: any) => ValidationErrors;
|
|
|
38
40
|
* var validate = require('mapbox-gl-style-spec/lib/validate_style.min');
|
|
39
41
|
* var errors = validate(style);
|
|
40
42
|
*/
|
|
41
|
-
export function validateStyle(style: StyleSpecification, styleSpec:
|
|
43
|
+
export function validateStyle(style: StyleSpecification, styleSpec: StyleReference = latestStyleSpec): ValidationErrors {
|
|
42
44
|
const errors = _validateStyle(style, styleSpec);
|
|
43
45
|
return sortErrors(errors);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
export const validateSource: Validator = opts => sortErrors(_validateSource(opts));
|
|
47
|
-
export const validateLight: Validator = opts => sortErrors(_validateLight(opts));
|
|
48
|
-
export const validateLights: Validator = opts => sortErrors(_validateLights(opts));
|
|
49
|
-
export const validateTerrain: Validator = opts => sortErrors(_validateTerrain(opts));
|
|
50
|
-
export const validateFog: Validator = opts => sortErrors(_validateFog(opts));
|
|
51
|
-
export const validateSnow: Validator = opts => sortErrors(_validateSnow(opts));
|
|
52
|
-
export const validateRain: Validator = opts => sortErrors(_validateRain(opts));
|
|
53
|
-
export const validateLayer: Validator = opts => sortErrors(_validateLayer(opts));
|
|
54
|
-
export const validateFilter: Validator = opts => sortErrors(_validateFilter(opts));
|
|
55
|
-
export const validatePaintProperty: Validator = opts => sortErrors(_validatePaintProperty(opts));
|
|
56
|
-
export const validateLayoutProperty: Validator = opts => sortErrors(_validateLayoutProperty(opts));
|
|
57
|
-
export const validateModel: Validator = opts => sortErrors(_validateModel(opts));
|
|
48
|
+
export const validateSource: Validator<typeof _validateSource> = opts => sortErrors(_validateSource(opts));
|
|
49
|
+
export const validateLight: Validator<typeof _validateLight> = opts => sortErrors(_validateLight(opts));
|
|
50
|
+
export const validateLights: Validator<typeof _validateLights> = opts => sortErrors(_validateLights(opts));
|
|
51
|
+
export const validateTerrain: Validator<typeof _validateTerrain> = opts => sortErrors(_validateTerrain(opts));
|
|
52
|
+
export const validateFog: Validator<typeof _validateFog> = opts => sortErrors(_validateFog(opts));
|
|
53
|
+
export const validateSnow: Validator<typeof _validateSnow> = opts => sortErrors(_validateSnow(opts));
|
|
54
|
+
export const validateRain: Validator<typeof _validateRain> = opts => sortErrors(_validateRain(opts));
|
|
55
|
+
export const validateLayer: Validator<typeof _validateLayer> = opts => sortErrors(_validateLayer(opts));
|
|
56
|
+
export const validateFilter: Validator<typeof _validateFilter> = opts => sortErrors(_validateFilter(opts));
|
|
57
|
+
export const validatePaintProperty: Validator<typeof _validatePaintProperty> = opts => sortErrors(_validatePaintProperty(opts));
|
|
58
|
+
export const validateLayoutProperty: Validator<typeof _validateLayoutProperty> = opts => sortErrors(_validateLayoutProperty(opts));
|
|
59
|
+
export const validateModel: Validator<typeof _validateModel> = opts => sortErrors(_validateModel(opts));
|
|
58
60
|
|
|
59
|
-
function sortErrors(errors: ValidationErrors) {
|
|
61
|
+
function sortErrors(errors: ValidationErrors): ValidationErrors {
|
|
60
62
|
return errors.slice().sort((a, b) => a.line && b.line ? a.line - b.line : 0);
|
|
61
63
|
}
|
package/validate_style.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {validateStyle as validateStyleMin} from './validate_style.min';
|
|
|
2
2
|
import {v8} from './style-spec';
|
|
3
3
|
import readStyle from './read_style';
|
|
4
4
|
|
|
5
|
+
import type {StyleReference} from './reference/latest';
|
|
5
6
|
import type {ValidationErrors} from './validate_style.min';
|
|
6
7
|
import type {StyleSpecification} from './types';
|
|
7
8
|
|
|
@@ -21,16 +22,15 @@ import type {StyleSpecification} from './types';
|
|
|
21
22
|
* var errors = validate(style);
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
|
-
export default function validateStyle(style: StyleSpecification | string | Buffer, styleSpec:
|
|
25
|
+
export default function validateStyle(style: StyleSpecification | string | Buffer, styleSpec: StyleReference = v8): ValidationErrors {
|
|
25
26
|
let s = style;
|
|
26
27
|
|
|
27
28
|
try {
|
|
28
29
|
s = readStyle(s);
|
|
29
|
-
} catch (e
|
|
30
|
+
} catch (e) {
|
|
30
31
|
return [e];
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
// @ts-expect-error - TS2345 - Argument of type 'string | StyleSpecification | Buffer' is not assignable to parameter of type 'StyleSpecification'.
|
|
34
34
|
return validateStyleMin(s, styleSpec);
|
|
35
35
|
}
|
|
36
36
|
|
package/visit.ts
CHANGED