@mapbox/mapbox-gl-style-spec 14.27.0 → 14.28.0-alpha.fa7f708fbcc
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 +115 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +56 -48
- package/dist/index.es.js +115 -152
- package/dist/index.es.js.map +1 -1
- package/error/parsing_error.ts +1 -1
- package/expression/definitions/config.ts +1 -3
- package/expression/definitions/index.ts +56 -7
- package/expression/index.ts +3 -3
- package/expression/types/resolved_image.ts +5 -1
- package/package.json +1 -1
- package/read_style.ts +2 -2
- package/reference/v8.json +59 -5
- package/types.ts +10 -46
- package/util/color.ts +12 -15
- package/util/geometry_util.ts +30 -30
- package/util/interpolate.ts +1 -1
- package/validate_mapbox_api_supported.ts +1 -2
- package/expression/definitions/in.ts +0 -86
- package/expression/definitions/index_of.ts +0 -104
- package/expression/definitions/split.ts +0 -56
package/error/parsing_error.ts
CHANGED
|
@@ -11,6 +11,6 @@ export default class ParsingError {
|
|
|
11
11
|
this.error = error;
|
|
12
12
|
this.message = error.message;
|
|
13
13
|
const match = error.message.match(LINE_NUMBER_RE);
|
|
14
|
-
this.line = match ? parseInt(match[1], 10) : 0;
|
|
14
|
+
this.line = match && match[1] ? parseInt(match[1], 10) : 0;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -65,9 +65,7 @@ class Config implements Expression {
|
|
|
65
65
|
|
|
66
66
|
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Config | null | void {
|
|
67
67
|
let type = context.expectedType;
|
|
68
|
-
|
|
69
|
-
type = ValueType;
|
|
70
|
-
}
|
|
68
|
+
type ??= ValueType;
|
|
71
69
|
if (args.length < 2 || args.length > 3) {
|
|
72
70
|
return context.error(`Invalid number of arguments for 'config' expression.`);
|
|
73
71
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ErrorType,
|
|
9
9
|
CollatorType,
|
|
10
10
|
array,
|
|
11
|
+
isValidNativeType,
|
|
11
12
|
toString as typeToString,
|
|
12
13
|
} from '../types';
|
|
13
14
|
import {typeOf, Color, validateRGBA, validateHSLA, toString as valueToString} from '../values';
|
|
@@ -20,12 +21,9 @@ import Assertion from './assertion';
|
|
|
20
21
|
import Coercion from './coercion';
|
|
21
22
|
import At from './at';
|
|
22
23
|
import AtInterpolated from './at_interpolated';
|
|
23
|
-
import In from './in';
|
|
24
|
-
import IndexOf from './index_of';
|
|
25
24
|
import Match from './match';
|
|
26
25
|
import Case from './case';
|
|
27
26
|
import Slice from './slice';
|
|
28
|
-
import Split from './split';
|
|
29
27
|
import Step from './step';
|
|
30
28
|
import Interpolate from './interpolate';
|
|
31
29
|
import Coalesce from './coalesce';
|
|
@@ -70,8 +68,6 @@ const expressions: ExpressionRegistry = {
|
|
|
70
68
|
'collator': CollatorExpression,
|
|
71
69
|
'format': FormatExpression,
|
|
72
70
|
'image': ImageExpression,
|
|
73
|
-
'in': In,
|
|
74
|
-
'index-of': IndexOf,
|
|
75
71
|
'interpolate': Interpolate,
|
|
76
72
|
'interpolate-hcl': Interpolate,
|
|
77
73
|
'interpolate-lab': Interpolate,
|
|
@@ -92,8 +88,7 @@ const expressions: ExpressionRegistry = {
|
|
|
92
88
|
'var': Var,
|
|
93
89
|
'within': Within,
|
|
94
90
|
'distance': Distance,
|
|
95
|
-
'config': Config
|
|
96
|
-
'split': Split
|
|
91
|
+
'config': Config
|
|
97
92
|
};
|
|
98
93
|
|
|
99
94
|
function rgba(ctx: EvaluationContext, [r, g, b, a]: Expression[]) {
|
|
@@ -155,6 +150,17 @@ function varargs(type: Type): Varargs {
|
|
|
155
150
|
return {type};
|
|
156
151
|
}
|
|
157
152
|
|
|
153
|
+
// Shared runtime type validation for `in` and `index-of`, whose needle and
|
|
154
|
+
// haystack arguments are parsed as ValueType and checked at evaluation time.
|
|
155
|
+
function assertNeedleHaystack(needle: Value, haystack: Value) {
|
|
156
|
+
if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {
|
|
157
|
+
throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${typeToString(typeOf(needle))} instead.`);
|
|
158
|
+
}
|
|
159
|
+
if (!isValidNativeType(haystack, ['string', 'array'])) {
|
|
160
|
+
throw new RuntimeError(`Expected second argument to be of type array or string, but found ${typeToString(typeOf(haystack))} instead.`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
158
164
|
function hashString(str: string) {
|
|
159
165
|
let hash = 0;
|
|
160
166
|
if (str.length === 0) {
|
|
@@ -716,6 +722,49 @@ CompoundExpression.register(expressions, {
|
|
|
716
722
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
717
723
|
(ctx, args) => args.map(arg => valueToString(arg.evaluate(ctx))).join('')
|
|
718
724
|
],
|
|
725
|
+
'split': [
|
|
726
|
+
array(StringType),
|
|
727
|
+
[StringType, StringType],
|
|
728
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
|
729
|
+
(ctx, [str, delimiter]) => str.evaluate(ctx).split(delimiter.evaluate(ctx))
|
|
730
|
+
],
|
|
731
|
+
'in': [
|
|
732
|
+
BooleanType,
|
|
733
|
+
[ValueType, ValueType],
|
|
734
|
+
(ctx, [needleExpr, haystackExpr]) => {
|
|
735
|
+
const needle = needleExpr.evaluate(ctx) as Value;
|
|
736
|
+
const haystack = haystackExpr.evaluate(ctx) as Value;
|
|
737
|
+
if (haystack == null) return false;
|
|
738
|
+
assertNeedleHaystack(needle, haystack);
|
|
739
|
+
// Type assertions safe due to assertNeedleHaystack checks above
|
|
740
|
+
return (haystack as string | unknown[]).includes(needle as string);
|
|
741
|
+
}
|
|
742
|
+
],
|
|
743
|
+
'index-of': {
|
|
744
|
+
type: NumberType,
|
|
745
|
+
overloads: [
|
|
746
|
+
[
|
|
747
|
+
[ValueType, ValueType],
|
|
748
|
+
(ctx, [needleExpr, haystackExpr]) => {
|
|
749
|
+
const needle = needleExpr.evaluate(ctx) as Value;
|
|
750
|
+
const haystack = haystackExpr.evaluate(ctx) as Value;
|
|
751
|
+
assertNeedleHaystack(needle, haystack);
|
|
752
|
+
// Type assertions safe due to assertNeedleHaystack checks above
|
|
753
|
+
return (haystack as string | unknown[]).indexOf(needle as string);
|
|
754
|
+
}
|
|
755
|
+
], [
|
|
756
|
+
[ValueType, ValueType, NumberType],
|
|
757
|
+
(ctx, [needleExpr, haystackExpr, fromIndexExpr]) => {
|
|
758
|
+
const needle = needleExpr.evaluate(ctx) as Value;
|
|
759
|
+
const haystack = haystackExpr.evaluate(ctx) as Value;
|
|
760
|
+
const fromIndex = fromIndexExpr.evaluate(ctx) as number;
|
|
761
|
+
assertNeedleHaystack(needle, haystack);
|
|
762
|
+
// Type assertions safe due to assertNeedleHaystack checks above
|
|
763
|
+
return (haystack as string | unknown[]).indexOf(needle as string, fromIndex);
|
|
764
|
+
}
|
|
765
|
+
]
|
|
766
|
+
]
|
|
767
|
+
},
|
|
719
768
|
'resolved-locale': [
|
|
720
769
|
StringType,
|
|
721
770
|
[CollatorType],
|
package/expression/index.ts
CHANGED
|
@@ -446,9 +446,9 @@ export class StylePropertyFunction<T> {
|
|
|
446
446
|
_parameters: PropertyValueSpecification<T>;
|
|
447
447
|
_specification: StylePropertySpecification;
|
|
448
448
|
|
|
449
|
-
kind
|
|
450
|
-
evaluate
|
|
451
|
-
interpolationFactor
|
|
449
|
+
kind!: EvaluationKind;
|
|
450
|
+
evaluate!: <T = unknown>(globals: GlobalProperties, feature?: Feature) => T;
|
|
451
|
+
interpolationFactor!: (input: number, lower: number, upper: number) => number | null | undefined;
|
|
452
452
|
zoomStops: Array<number> | null | undefined;
|
|
453
453
|
|
|
454
454
|
constructor(parameters: PropertyValueSpecification<T>, specification: StylePropertySpecification) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import assert from '../../util/assert';
|
|
1
2
|
import {ImageId} from './image_id';
|
|
2
3
|
import {ImageVariant} from './image_variant';
|
|
3
4
|
|
|
@@ -56,7 +57,10 @@ export default class ResolvedImage {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
static from(image: string | ResolvedImage): ResolvedImage {
|
|
59
|
-
|
|
60
|
+
if (typeof image !== 'string') return image;
|
|
61
|
+
const resolved = ResolvedImage.build({name: image});
|
|
62
|
+
assert(resolved);
|
|
63
|
+
return resolved;
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
static build(
|
package/package.json
CHANGED
package/read_style.ts
CHANGED
|
@@ -87,7 +87,7 @@ function parseTokens(s: string, tokens: number[]) {
|
|
|
87
87
|
let lo = 0, hi = lineOffsets.length - 1;
|
|
88
88
|
while (lo < hi) {
|
|
89
89
|
const mid = (lo + hi + 1) >> 1;
|
|
90
|
-
if (lineOffsets[mid] <= pos) lo = mid;
|
|
90
|
+
if (lineOffsets[mid]! <= pos) lo = mid;
|
|
91
91
|
else hi = mid - 1;
|
|
92
92
|
}
|
|
93
93
|
return lo + 1;
|
|
@@ -104,7 +104,7 @@ function parseTokens(s: string, tokens: number[]) {
|
|
|
104
104
|
const end = tokens[i + 2];
|
|
105
105
|
i += 3;
|
|
106
106
|
|
|
107
|
-
const line = lineNum(start);
|
|
107
|
+
const line = lineNum(start!);
|
|
108
108
|
|
|
109
109
|
if (type === LBRACE) {
|
|
110
110
|
const obj = setLine({}, line);
|
package/reference/v8.json
CHANGED
|
@@ -1702,8 +1702,7 @@
|
|
|
1702
1702
|
"type": "array",
|
|
1703
1703
|
"value": "appearance",
|
|
1704
1704
|
"supported-layer-types": ["symbol"],
|
|
1705
|
-
"
|
|
1706
|
-
"doc": "Conditional styling applied to symbol layer features based on dynamic conditions. If multiple conditions are true, only the first matching appearance will be applied. Only properties marked with 'Works with appearances' are supported."
|
|
1705
|
+
"doc": "Conditional styling applied to symbol layer features based on dynamic conditions. If multiple conditions are true, only the first matching appearance will be applied. Only properties marked with 'Works with appearances' are supported. Known issue: at the moment having both `appearances` and `text-variable-anchor` in the same layer doesn't work correctly."
|
|
1707
1706
|
}
|
|
1708
1707
|
},
|
|
1709
1708
|
"appearance": {
|
|
@@ -3993,7 +3992,7 @@
|
|
|
3993
3992
|
]
|
|
3994
3993
|
}
|
|
3995
3994
|
],
|
|
3996
|
-
"doc": "To increase the chance of placing high-priority labels on the map, you can provide an array of `text-anchor` locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use `text-justify: auto` to choose justification based on anchor position. To apply an offset, use the `text-radial-offset` or the two-dimensional `text-offset`.",
|
|
3995
|
+
"doc": "To increase the chance of placing high-priority labels on the map, you can provide an array of `text-anchor` locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use `text-justify: auto` to choose justification based on anchor position. To apply an offset, use the `text-radial-offset` or the two-dimensional `text-offset`. Known issue: at the moment having both `appearances` and `text-variable-anchor` in the same layer doesn't work correctly.",
|
|
3997
3996
|
"sdk-support": {
|
|
3998
3997
|
"basic functionality": {
|
|
3999
3998
|
"js": "0.54.0",
|
|
@@ -8898,7 +8897,6 @@
|
|
|
8898
8897
|
},
|
|
8899
8898
|
"line-border-width": {
|
|
8900
8899
|
"type": "number",
|
|
8901
|
-
"private": true,
|
|
8902
8900
|
"doc": "The width of the line border. A value of zero means no border.",
|
|
8903
8901
|
"default": 0.0,
|
|
8904
8902
|
"minimum": 0.0,
|
|
@@ -8927,7 +8925,6 @@
|
|
|
8927
8925
|
},
|
|
8928
8926
|
"line-border-color": {
|
|
8929
8927
|
"type": "color",
|
|
8930
|
-
"private": true,
|
|
8931
8928
|
"doc": "The color of the line border. If line-border-width is greater than zero and the alpha value of this color is 0 (default), the color for the border will be selected automatically based on the line color.",
|
|
8932
8929
|
"default": "rgba(0, 0, 0, 0)",
|
|
8933
8930
|
"use-theme": true,
|
|
@@ -8954,6 +8951,48 @@
|
|
|
8954
8951
|
},
|
|
8955
8952
|
"property-type": "data-driven"
|
|
8956
8953
|
},
|
|
8954
|
+
"line-border-gradient": {
|
|
8955
|
+
"type": "color",
|
|
8956
|
+
"experimental": true,
|
|
8957
|
+
"doc": "A gradient used to color the border of a line feature at various distances along its length. Defined using a `step` or `interpolate` expression which outputs a color for each corresponding `line-progress` input value. `line-progress` is a percentage of the line feature's total length as measured on the webmercator projected coordinate plane (a `number` between `0` and `1`). Takes precedence over `line-border-color`. Has no effect unless `line-border-width` is greater than zero. Can only be used with GeoJSON sources that specify `\"lineMetrics\": true`.",
|
|
8958
|
+
"example": [
|
|
8959
|
+
"step",
|
|
8960
|
+
[
|
|
8961
|
+
"line-progress"
|
|
8962
|
+
],
|
|
8963
|
+
"blue",
|
|
8964
|
+
0.5,
|
|
8965
|
+
"gray"
|
|
8966
|
+
],
|
|
8967
|
+
"use-theme": true,
|
|
8968
|
+
"transition": false,
|
|
8969
|
+
"requires": [
|
|
8970
|
+
{
|
|
8971
|
+
"!": "line-pattern"
|
|
8972
|
+
},
|
|
8973
|
+
{
|
|
8974
|
+
"source": "geojson",
|
|
8975
|
+
"has": {
|
|
8976
|
+
"lineMetrics": true
|
|
8977
|
+
}
|
|
8978
|
+
}
|
|
8979
|
+
],
|
|
8980
|
+
"sdk-support": {
|
|
8981
|
+
"basic functionality": {
|
|
8982
|
+
"js": "3.28.0",
|
|
8983
|
+
"android": "11.28.0",
|
|
8984
|
+
"ios": "11.28.0"
|
|
8985
|
+
},
|
|
8986
|
+
"data-driven styling": {}
|
|
8987
|
+
},
|
|
8988
|
+
"expression": {
|
|
8989
|
+
"interpolated": true,
|
|
8990
|
+
"parameters": [
|
|
8991
|
+
"line-progress"
|
|
8992
|
+
]
|
|
8993
|
+
},
|
|
8994
|
+
"property-type": "color-ramp"
|
|
8995
|
+
},
|
|
8957
8996
|
"line-occlusion-opacity": {
|
|
8958
8997
|
"type": "number",
|
|
8959
8998
|
"default": 0,
|
|
@@ -10602,6 +10641,21 @@
|
|
|
10602
10641
|
"interpolated": false
|
|
10603
10642
|
},
|
|
10604
10643
|
"property-type": "data-constant"
|
|
10644
|
+
},
|
|
10645
|
+
"raster-allow-draping": {
|
|
10646
|
+
"type": "boolean",
|
|
10647
|
+
"default": true,
|
|
10648
|
+
"experimental": true,
|
|
10649
|
+
"doc": "Whether the raster layer is allowed to drape over terrain and globe. When disabled, the layer is rendered after all draped layers, which can change its position in the layer order. Disabling draping has a performance cost, since the terrain/globe geometry must be rendered again for each such layer.",
|
|
10650
|
+
"transition": false,
|
|
10651
|
+
"property-type": "data-constant",
|
|
10652
|
+
"sdk-support": {
|
|
10653
|
+
"basic functionality": {
|
|
10654
|
+
"js": "3.28.0",
|
|
10655
|
+
"android": "11.28.0",
|
|
10656
|
+
"ios": "11.28.0"
|
|
10657
|
+
}
|
|
10658
|
+
}
|
|
10605
10659
|
}
|
|
10606
10660
|
},
|
|
10607
10661
|
"paint_raster-particle": {
|
package/types.ts
CHANGED
|
@@ -674,9 +674,6 @@ export type FillLayerSpecification = {
|
|
|
674
674
|
"fill-tunnel-structure-color-transition"?: TransitionSpecification,
|
|
675
675
|
"fill-tunnel-structure-color-use-theme"?: PropertyValueSpecification<string>
|
|
676
676
|
},
|
|
677
|
-
/**
|
|
678
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
679
|
-
*/
|
|
680
677
|
"appearances"?: Array<AppearanceSpecification>
|
|
681
678
|
};
|
|
682
679
|
|
|
@@ -760,6 +757,11 @@ export type LineLayerSpecification = {
|
|
|
760
757
|
"line-border-color"?: DataDrivenPropertyValueSpecification<ColorSpecification>,
|
|
761
758
|
"line-border-color-transition"?: TransitionSpecification,
|
|
762
759
|
"line-border-color-use-theme"?: PropertyValueSpecification<string>,
|
|
760
|
+
/**
|
|
761
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
762
|
+
*/
|
|
763
|
+
"line-border-gradient"?: ColorSpecification | ExpressionSpecification,
|
|
764
|
+
"line-border-gradient-use-theme"?: PropertyValueSpecification<string>,
|
|
763
765
|
"line-occlusion-opacity"?: PropertyValueSpecification<number>,
|
|
764
766
|
"line-occlusion-opacity-transition"?: TransitionSpecification,
|
|
765
767
|
/**
|
|
@@ -771,9 +773,6 @@ export type LineLayerSpecification = {
|
|
|
771
773
|
*/
|
|
772
774
|
"line-blend-additive-clamp"?: PropertyValueSpecification<number>
|
|
773
775
|
},
|
|
774
|
-
/**
|
|
775
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
776
|
-
*/
|
|
777
776
|
"appearances"?: Array<AppearanceSpecification>
|
|
778
777
|
};
|
|
779
778
|
|
|
@@ -905,9 +904,6 @@ export type SymbolLayerSpecification = {
|
|
|
905
904
|
"symbol-z-offset"?: DataDrivenPropertyValueSpecification<number>,
|
|
906
905
|
"symbol-z-offset-transition"?: TransitionSpecification
|
|
907
906
|
},
|
|
908
|
-
/**
|
|
909
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
910
|
-
*/
|
|
911
907
|
"appearances"?: Array<AppearanceSpecification>
|
|
912
908
|
};
|
|
913
909
|
|
|
@@ -964,9 +960,6 @@ export type CircleLayerSpecification = {
|
|
|
964
960
|
"circle-emissive-strength"?: PropertyValueSpecification<number>,
|
|
965
961
|
"circle-emissive-strength-transition"?: TransitionSpecification
|
|
966
962
|
},
|
|
967
|
-
/**
|
|
968
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
969
|
-
*/
|
|
970
963
|
"appearances"?: Array<AppearanceSpecification>
|
|
971
964
|
};
|
|
972
965
|
|
|
@@ -1004,9 +997,6 @@ export type HeatmapLayerSpecification = {
|
|
|
1004
997
|
"heatmap-opacity"?: PropertyValueSpecification<number>,
|
|
1005
998
|
"heatmap-opacity-transition"?: TransitionSpecification
|
|
1006
999
|
},
|
|
1007
|
-
/**
|
|
1008
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1009
|
-
*/
|
|
1010
1000
|
"appearances"?: Array<AppearanceSpecification>
|
|
1011
1001
|
};
|
|
1012
1002
|
|
|
@@ -1133,9 +1123,6 @@ export type FillExtrusionLayerSpecification = {
|
|
|
1133
1123
|
"fill-extrusion-line-width-transition"?: TransitionSpecification,
|
|
1134
1124
|
"fill-extrusion-cast-shadows"?: boolean
|
|
1135
1125
|
},
|
|
1136
|
-
/**
|
|
1137
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1138
|
-
*/
|
|
1139
1126
|
"appearances"?: Array<AppearanceSpecification>
|
|
1140
1127
|
};
|
|
1141
1128
|
|
|
@@ -1208,9 +1195,6 @@ export type BuildingLayerSpecification = {
|
|
|
1208
1195
|
"building-flood-light-ground-attenuation"?: PropertyValueSpecification<number>,
|
|
1209
1196
|
"building-flood-light-ground-attenuation-transition"?: TransitionSpecification
|
|
1210
1197
|
},
|
|
1211
|
-
/**
|
|
1212
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1213
|
-
*/
|
|
1214
1198
|
"appearances"?: Array<AppearanceSpecification>
|
|
1215
1199
|
};
|
|
1216
1200
|
|
|
@@ -1272,11 +1256,12 @@ export type RasterLayerSpecification = {
|
|
|
1272
1256
|
/**
|
|
1273
1257
|
* @experimental This property is experimental and subject to change in future versions.
|
|
1274
1258
|
*/
|
|
1275
|
-
"raster-elevation-reference"?: "sea" | "ground" | ExpressionSpecification
|
|
1259
|
+
"raster-elevation-reference"?: "sea" | "ground" | ExpressionSpecification,
|
|
1260
|
+
/**
|
|
1261
|
+
* @experimental This property is experimental and subject to change in future versions.
|
|
1262
|
+
*/
|
|
1263
|
+
"raster-allow-draping"?: boolean
|
|
1276
1264
|
},
|
|
1277
|
-
/**
|
|
1278
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1279
|
-
*/
|
|
1280
1265
|
"appearances"?: Array<AppearanceSpecification>
|
|
1281
1266
|
};
|
|
1282
1267
|
|
|
@@ -1317,9 +1302,6 @@ export type RasterParticleLayerSpecification = {
|
|
|
1317
1302
|
"raster-particle-elevation"?: PropertyValueSpecification<number>,
|
|
1318
1303
|
"raster-particle-elevation-transition"?: TransitionSpecification
|
|
1319
1304
|
},
|
|
1320
|
-
/**
|
|
1321
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1322
|
-
*/
|
|
1323
1305
|
"appearances"?: Array<AppearanceSpecification>
|
|
1324
1306
|
};
|
|
1325
1307
|
|
|
@@ -1363,9 +1345,6 @@ export type HillshadeLayerSpecification = {
|
|
|
1363
1345
|
"hillshade-emissive-strength"?: PropertyValueSpecification<number>,
|
|
1364
1346
|
"hillshade-emissive-strength-transition"?: TransitionSpecification
|
|
1365
1347
|
},
|
|
1366
|
-
/**
|
|
1367
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1368
|
-
*/
|
|
1369
1348
|
"appearances"?: Array<AppearanceSpecification>
|
|
1370
1349
|
};
|
|
1371
1350
|
|
|
@@ -1430,9 +1409,6 @@ export type ModelLayerSpecification = {
|
|
|
1430
1409
|
*/
|
|
1431
1410
|
"model-line-cutout-mode"?: "enabled" | "disabled" | "enabled-above-cutout" | ExpressionSpecification
|
|
1432
1411
|
},
|
|
1433
|
-
/**
|
|
1434
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1435
|
-
*/
|
|
1436
1412
|
"appearances"?: Array<AppearanceSpecification>
|
|
1437
1413
|
};
|
|
1438
1414
|
|
|
@@ -1473,9 +1449,6 @@ export type BackgroundLayerSpecification = {
|
|
|
1473
1449
|
"background-emissive-strength"?: PropertyValueSpecification<number>,
|
|
1474
1450
|
"background-emissive-strength-transition"?: TransitionSpecification
|
|
1475
1451
|
},
|
|
1476
|
-
/**
|
|
1477
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1478
|
-
*/
|
|
1479
1452
|
"appearances"?: Array<AppearanceSpecification>
|
|
1480
1453
|
};
|
|
1481
1454
|
|
|
@@ -1517,9 +1490,6 @@ export type SkyLayerSpecification = {
|
|
|
1517
1490
|
"sky-opacity"?: PropertyValueSpecification<number>,
|
|
1518
1491
|
"sky-opacity-transition"?: TransitionSpecification
|
|
1519
1492
|
},
|
|
1520
|
-
/**
|
|
1521
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1522
|
-
*/
|
|
1523
1493
|
"appearances"?: Array<AppearanceSpecification>
|
|
1524
1494
|
};
|
|
1525
1495
|
|
|
@@ -1543,9 +1513,6 @@ export type SlotLayerSpecification = {
|
|
|
1543
1513
|
"minzoom"?: never,
|
|
1544
1514
|
"maxzoom"?: never,
|
|
1545
1515
|
"filter"?: never,
|
|
1546
|
-
/**
|
|
1547
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1548
|
-
*/
|
|
1549
1516
|
"appearances"?: Array<AppearanceSpecification>,
|
|
1550
1517
|
"layout"?: never,
|
|
1551
1518
|
"paint"?: never
|
|
@@ -1566,9 +1533,6 @@ export type ClipLayerSpecification = {
|
|
|
1566
1533
|
"clip-layer-scope"?: Array<string> | ExpressionSpecification,
|
|
1567
1534
|
"visibility"?: "visible" | "none" | ExpressionSpecification
|
|
1568
1535
|
},
|
|
1569
|
-
/**
|
|
1570
|
-
* @experimental This property is experimental and subject to change in future versions.
|
|
1571
|
-
*/
|
|
1572
1536
|
"appearances"?: Array<AppearanceSpecification>,
|
|
1573
1537
|
"paint"?: never
|
|
1574
1538
|
};
|
package/util/color.ts
CHANGED
|
@@ -164,31 +164,28 @@ export abstract class RenderColor {
|
|
|
164
164
|
const i7 = (r1 + g1 * N2 + b1 * N) * 4;
|
|
165
165
|
|
|
166
166
|
// r/g/b are clamped to [0, N-1] above, so every index below is within bounds.
|
|
167
|
-
// The `as number` casts only suppress the `number | undefined` that
|
|
168
|
-
// `noUncheckedIndexedAccess` infers for typed-array reads; they are erased at
|
|
169
|
-
// runtime, so unlike a helper closure they add no per-construction allocation.
|
|
170
167
|
// Trilinear interpolation.
|
|
171
168
|
this.r = lerp(
|
|
172
169
|
lerp(
|
|
173
|
-
lerp(data[i0]
|
|
174
|
-
lerp(data[i2]
|
|
170
|
+
lerp(data[i0]!, data[i1]!, bw),
|
|
171
|
+
lerp(data[i2]!, data[i3]!, bw), gw),
|
|
175
172
|
lerp(
|
|
176
|
-
lerp(data[i4]
|
|
177
|
-
lerp(data[i6]
|
|
173
|
+
lerp(data[i4]!, data[i5]!, bw),
|
|
174
|
+
lerp(data[i6]!, data[i7]!, bw), gw), rw) / 255 * (this.premultiplied ? a : 1);
|
|
178
175
|
this.g = lerp(
|
|
179
176
|
lerp(
|
|
180
|
-
lerp(data[i0 + 1]
|
|
181
|
-
lerp(data[i2 + 1]
|
|
177
|
+
lerp(data[i0 + 1]!, data[i1 + 1]!, bw),
|
|
178
|
+
lerp(data[i2 + 1]!, data[i3 + 1]!, bw), gw),
|
|
182
179
|
lerp(
|
|
183
|
-
lerp(data[i4 + 1]
|
|
184
|
-
lerp(data[i6 + 1]
|
|
180
|
+
lerp(data[i4 + 1]!, data[i5 + 1]!, bw),
|
|
181
|
+
lerp(data[i6 + 1]!, data[i7 + 1]!, bw), gw), rw) / 255 * (this.premultiplied ? a : 1);
|
|
185
182
|
this.b = lerp(
|
|
186
183
|
lerp(
|
|
187
|
-
lerp(data[i0 + 2]
|
|
188
|
-
lerp(data[i2 + 2]
|
|
184
|
+
lerp(data[i0 + 2]!, data[i1 + 2]!, bw),
|
|
185
|
+
lerp(data[i2 + 2]!, data[i3 + 2]!, bw), gw),
|
|
189
186
|
lerp(
|
|
190
|
-
lerp(data[i4 + 2]
|
|
191
|
-
lerp(data[i6 + 2]
|
|
187
|
+
lerp(data[i4 + 2]!, data[i5 + 2]!, bw),
|
|
188
|
+
lerp(data[i6 + 2]!, data[i7 + 2]!, bw), gw), rw) / 255 * (this.premultiplied ? a : 1);
|
|
192
189
|
this.a = a;
|
|
193
190
|
}
|
|
194
191
|
}
|
package/util/geometry_util.ts
CHANGED
|
@@ -14,15 +14,15 @@ export type BBox = [number, number, number, number];
|
|
|
14
14
|
export function calculateSignedArea(ring: Ring): number {
|
|
15
15
|
let sum = 0;
|
|
16
16
|
for (let i = 0, len = ring.length, j = len - 1, p1: Point, p2: Point; i < len; j = i++) {
|
|
17
|
-
p1 = ring[i]
|
|
18
|
-
p2 = ring[j]
|
|
17
|
+
p1 = ring[i]!;
|
|
18
|
+
p2 = ring[j]!;
|
|
19
19
|
sum += (p2.x - p1.x) * (p1.y + p2.y);
|
|
20
20
|
}
|
|
21
21
|
return sum;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function compareAreas(a: Ring, b: Ring): number {
|
|
25
|
-
return (b.area
|
|
25
|
+
return (b.area!) - (a.area!);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// classifies an array of rings into polygons with outer rings and holes
|
|
@@ -36,18 +36,18 @@ export function classifyRings(rings: Array<Ring>, maxRings: number): Array<Array
|
|
|
36
36
|
ccw: boolean | undefined;
|
|
37
37
|
|
|
38
38
|
for (let i = 0; i < len; i++) {
|
|
39
|
-
const area = calculateSignedArea(rings[i]
|
|
39
|
+
const area = calculateSignedArea(rings[i]!);
|
|
40
40
|
if (area === 0) continue;
|
|
41
41
|
|
|
42
|
-
(rings[i]
|
|
42
|
+
(rings[i]!).area = Math.abs(area);
|
|
43
43
|
|
|
44
44
|
if (ccw === undefined) ccw = area < 0;
|
|
45
45
|
|
|
46
46
|
if (ccw === area < 0) {
|
|
47
47
|
if (polygon) polygons.push(polygon);
|
|
48
|
-
polygon = [rings[i]
|
|
48
|
+
polygon = [rings[i]!];
|
|
49
49
|
} else {
|
|
50
|
-
(polygon
|
|
50
|
+
(polygon!).push(rings[i]!);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
if (polygon) polygons.push(polygon);
|
|
@@ -56,7 +56,7 @@ export function classifyRings(rings: Array<Ring>, maxRings: number): Array<Array
|
|
|
56
56
|
// reason, we limit strip out all but the `maxRings` largest rings.
|
|
57
57
|
if (maxRings > 1) {
|
|
58
58
|
for (let j = 0; j < polygons.length; j++) {
|
|
59
|
-
const currentPolygon = polygons[j]
|
|
59
|
+
const currentPolygon = polygons[j]!;
|
|
60
60
|
if (currentPolygon.length <= maxRings) continue;
|
|
61
61
|
quickselect(currentPolygon, maxRings, 1, currentPolygon.length - 1, compareAreas);
|
|
62
62
|
polygons[j] = currentPolygon.slice(0, maxRings);
|
|
@@ -67,10 +67,10 @@ export function classifyRings(rings: Array<Ring>, maxRings: number): Array<Array
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export function updateBBox(bbox: BBox, coord: GeoJSON.Position) {
|
|
70
|
-
bbox[0] = Math.min(bbox[0], coord[0]
|
|
71
|
-
bbox[1] = Math.min(bbox[1], coord[1]
|
|
72
|
-
bbox[2] = Math.max(bbox[2], coord[0]
|
|
73
|
-
bbox[3] = Math.max(bbox[3], coord[1]
|
|
70
|
+
bbox[0] = Math.min(bbox[0], coord[0]!);
|
|
71
|
+
bbox[1] = Math.min(bbox[1], coord[1]!);
|
|
72
|
+
bbox[2] = Math.max(bbox[2], coord[0]!);
|
|
73
|
+
bbox[3] = Math.max(bbox[3], coord[1]!);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export function boxWithinBox(bbox1: BBox, bbox2: BBox): boolean {
|
|
@@ -82,15 +82,15 @@ export function boxWithinBox(bbox1: BBox, bbox2: BBox): boolean {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function onBoundary(p: GeoJSON.Position, p1: GeoJSON.Position, p2: GeoJSON.Position) {
|
|
85
|
-
const x1 = (p[0]
|
|
86
|
-
const y1 = (p[1]
|
|
87
|
-
const x2 = (p[0]
|
|
88
|
-
const y2 = (p[1]
|
|
85
|
+
const x1 = (p[0]!) - (p1[0]!);
|
|
86
|
+
const y1 = (p[1]!) - (p1[1]!);
|
|
87
|
+
const x2 = (p[0]!) - (p2[0]!);
|
|
88
|
+
const y2 = (p[1]!) - (p2[1]!);
|
|
89
89
|
return (x1 * y2 - x2 * y1 === 0) && (x1 * x2 <= 0) && (y1 * y2 <= 0);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
function rayIntersect(p: GeoJSON.Position, p1: GeoJSON.Position, p2: GeoJSON.Position) {
|
|
93
|
-
return (((p1[1]
|
|
93
|
+
return (((p1[1]!) > (p[1]!)) !== ((p2[1]!) > (p[1]!))) && ((p[0]!) < ((p2[0]!) - (p1[0]!)) * ((p[1]!) - (p1[1]!)) / ((p2[1]!) - (p1[1]!)) + (p1[0]!));
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// ray casting algorithm for detecting if point is in polygon
|
|
@@ -101,10 +101,10 @@ export function pointWithinPolygon(
|
|
|
101
101
|
): boolean {
|
|
102
102
|
let inside = false;
|
|
103
103
|
for (let i = 0, len = rings.length; i < len; i++) {
|
|
104
|
-
const ring = rings[i]
|
|
104
|
+
const ring = rings[i]!;
|
|
105
105
|
for (let j = 0, len2 = ring.length, k = len2 - 1; j < len2; k = j++) {
|
|
106
|
-
const q1 = ring[k]
|
|
107
|
-
const q2 = ring[j]
|
|
106
|
+
const q1 = ring[k]!;
|
|
107
|
+
const q2 = ring[j]!;
|
|
108
108
|
if (onBoundary(point, q1, q2)) return trueOnBoundary;
|
|
109
109
|
if (rayIntersect(point, q1, q2)) inside = !inside;
|
|
110
110
|
}
|
|
@@ -113,18 +113,18 @@ export function pointWithinPolygon(
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function perp(v1: GeoJSON.Position, v2: GeoJSON.Position) {
|
|
116
|
-
return (v1[0]
|
|
116
|
+
return (v1[0]!) * (v2[1]!) - (v1[1]!) * (v2[0]!);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// check if p1 and p2 are in different sides of line segment q1->q2
|
|
120
120
|
function twoSided(p1: GeoJSON.Position, p2: GeoJSON.Position, q1: GeoJSON.Position, q2: GeoJSON.Position) {
|
|
121
121
|
// q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)
|
|
122
|
-
const x1 = (p1[0]
|
|
123
|
-
const y1 = (p1[1]
|
|
124
|
-
const x2 = (p2[0]
|
|
125
|
-
const y2 = (p2[1]
|
|
126
|
-
const x3 = (q2[0]
|
|
127
|
-
const y3 = (q2[1]
|
|
122
|
+
const x1 = (p1[0]!) - (q1[0]!);
|
|
123
|
+
const y1 = (p1[1]!) - (q1[1]!);
|
|
124
|
+
const x2 = (p2[0]!) - (q1[0]!);
|
|
125
|
+
const y2 = (p2[1]!) - (q1[1]!);
|
|
126
|
+
const x3 = (q2[0]!) - (q1[0]!);
|
|
127
|
+
const y3 = (q2[1]!) - (q1[1]!);
|
|
128
128
|
const det1 = x1 * y3 - x3 * y1;
|
|
129
129
|
const det2 = x2 * y3 - x3 * y2;
|
|
130
130
|
if ((det1 > 0 && det2 < 0) || (det1 < 0 && det2 > 0)) return true;
|
|
@@ -140,8 +140,8 @@ export function segmentIntersectSegment(
|
|
|
140
140
|
// check if two segments are parallel or not
|
|
141
141
|
// precondition is end point a, b is inside polygon, if line a->b is
|
|
142
142
|
// parallel to polygon edge c->d, then a->b won't intersect with c->d
|
|
143
|
-
const vectorP = [(b[0]
|
|
144
|
-
const vectorQ = [(d[0]
|
|
143
|
+
const vectorP = [(b[0]!) - (a[0]!), (b[1]!) - (a[1]!)];
|
|
144
|
+
const vectorQ = [(d[0]!) - (c[0]!), (d[1]!) - (c[1]!)];
|
|
145
145
|
if (perp(vectorQ, vectorP) === 0) return false;
|
|
146
146
|
|
|
147
147
|
// If lines are intersecting with each other, the relative location should be:
|
|
@@ -160,7 +160,7 @@ export function computeBounds(points: Point[][]): Bounds {
|
|
|
160
160
|
const min = new Point(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
161
161
|
const max = new Point(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);
|
|
162
162
|
|
|
163
|
-
for (const point of points[0]
|
|
163
|
+
for (const point of points[0]!) {
|
|
164
164
|
if (min.x > point.x) min.x = point.x;
|
|
165
165
|
if (min.y > point.y) min.y = point.y;
|
|
166
166
|
if (max.x < point.x) max.x = point.x;
|
package/util/interpolate.ts
CHANGED
|
@@ -14,6 +14,6 @@ export function color(from: Color, to: Color, t: number): Color {
|
|
|
14
14
|
|
|
15
15
|
export function array(from: Array<number>, to: Array<number>, t: number): Array<number> {
|
|
16
16
|
return from.map((d, i) => {
|
|
17
|
-
return number(d, to[i]
|
|
17
|
+
return number(d, to[i]!, t);
|
|
18
18
|
});
|
|
19
19
|
}
|