@mapbox/mapbox-gl-style-spec 14.25.0 → 14.26.0

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 CHANGED
@@ -1300,6 +1300,24 @@
1300
1300
  doc: "Override the orientation of the model node in euler angles [x, y, z]."
1301
1301
  }
1302
1302
  };
1303
+ var modelLightOverrides = {
1304
+ "light-ambient-color": {
1305
+ type: "color",
1306
+ doc: "Override the color of ambient lights."
1307
+ },
1308
+ "light-ambient-intensity": {
1309
+ type: "number",
1310
+ doc: "Override the intensity of light-ambient-color (on a scale from 0 to 1)."
1311
+ },
1312
+ "light-directional-color": {
1313
+ type: "color",
1314
+ doc: "Override the color of directional lights."
1315
+ },
1316
+ "light-directional-intensity": {
1317
+ type: "number",
1318
+ doc: "Override the intensity of light-directional-color (on a scale from 0 to 1)."
1319
+ }
1320
+ };
1303
1321
  var modelNodeOverrides = {
1304
1322
  "*": {
1305
1323
  type: "modelNodeOverride",
@@ -1370,6 +1388,11 @@
1370
1388
  units: "degrees",
1371
1389
  doc: "Orientation of the model in euler angles [x, y, z]."
1372
1390
  },
1391
+ lightOverrides: {
1392
+ type: "modelLightOverrides",
1393
+ required: false,
1394
+ doc: "A collection of light overrides."
1395
+ },
1373
1396
  nodeOverrides: {
1374
1397
  type: "modelNodeOverrides",
1375
1398
  required: false,
@@ -6527,13 +6550,6 @@
6527
6550
  doc: "Projection where objects are of the same scale regardless of whether they are far away or near to the camera. Parallel lines remains parallel and there is no vanishing point."
6528
6551
  }
6529
6552
  },
6530
- transition: true,
6531
- expression: {
6532
- interpolated: true,
6533
- parameters: [
6534
- "zoom"
6535
- ]
6536
- },
6537
6553
  "sdk-support": {
6538
6554
  "basic functionality": {
6539
6555
  js: "3.0.0",
@@ -10942,6 +10958,7 @@
10942
10958
  source_video: source_video,
10943
10959
  source_image: source_image,
10944
10960
  modelNodeOverride: modelNodeOverride,
10961
+ modelLightOverrides: modelLightOverrides,
10945
10962
  modelNodeOverrides: modelNodeOverrides,
10946
10963
  modelMaterialOverride: modelMaterialOverride,
10947
10964
  modelMaterialOverrides: modelMaterialOverrides,
@@ -13986,7 +14003,7 @@
13986
14003
  overloadParams.push(params);
13987
14004
  overloadIndex++;
13988
14005
  if (signatureContext === null) {
13989
- signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, [], context._scope, context.options, context.iconImageUseTheme);
14006
+ signatureContext = context._forkForSignature();
13990
14007
  } else {
13991
14008
  signatureContext.errors.length = 0;
13992
14009
  }
@@ -14749,485 +14766,6 @@
14749
14766
  }
14750
14767
  }
14751
14768
 
14752
- const factors = {
14753
- kilometers: 1,
14754
- miles: 1000 / 1609.344,
14755
- nauticalmiles: 1000 / 1852,
14756
- meters: 1000,
14757
- metres: 1000,
14758
- yards: 1000 / 0.9144,
14759
- feet: 1000 / 0.3048,
14760
- inches: 1000 / 0.0254
14761
- };
14762
-
14763
- // Values that define WGS84 ellipsoid model of the Earth
14764
- const RE = 6378.137; // equatorial radius
14765
- const FE = 1 / 298.257223563; // flattening
14766
-
14767
- const E2 = FE * (2 - FE);
14768
- const RAD = Math.PI / 180;
14769
-
14770
- /**
14771
- * A collection of very fast approximations to common geodesic measurements. Useful for performance-sensitive code that measures things on a city scale.
14772
- */
14773
- class CheapRuler {
14774
- /**
14775
- * Creates a ruler object from tile coordinates (y and z).
14776
- *
14777
- * @param {number} y
14778
- * @param {number} z
14779
- * @param {keyof typeof factors} [units='kilometers']
14780
- * @returns {CheapRuler}
14781
- * @example
14782
- * const ruler = cheapRuler.fromTile(1567, 12);
14783
- * //=ruler
14784
- */
14785
- static fromTile(y, z, units) {
14786
- const n = Math.PI * (1 - 2 * (y + 0.5) / Math.pow(2, z));
14787
- const lat = Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))) / RAD;
14788
- return new CheapRuler(lat, units);
14789
- }
14790
-
14791
- /**
14792
- * Multipliers for converting between units.
14793
- *
14794
- * @example
14795
- * // convert 50 meters to yards
14796
- * 50 * CheapRuler.units.yards / CheapRuler.units.meters;
14797
- */
14798
- static get units() {
14799
- return factors;
14800
- }
14801
-
14802
- /**
14803
- * Creates a ruler instance for very fast approximations to common geodesic measurements around a certain latitude.
14804
- *
14805
- * @param {number} lat latitude
14806
- * @param {keyof typeof factors} [units='kilometers']
14807
- * @example
14808
- * const ruler = cheapRuler(35.05, 'miles');
14809
- * //=ruler
14810
- */
14811
- constructor(lat, units) {
14812
- if (lat === undefined) throw new Error('No latitude given.');
14813
- if (units && !factors[units]) throw new Error(`Unknown unit ${ units }. Use one of: ${ Object.keys(factors).join(', ')}`);
14814
-
14815
- // Curvature formulas from https://en.wikipedia.org/wiki/Earth_radius#Meridional
14816
- const m = RAD * RE * (units ? factors[units] : 1);
14817
- const coslat = Math.cos(lat * RAD);
14818
- const w2 = 1 / (1 - E2 * (1 - coslat * coslat));
14819
- const w = Math.sqrt(w2);
14820
-
14821
- // multipliers for converting longitude and latitude degrees into distance
14822
- this.kx = m * w * coslat; // based on normal radius of curvature
14823
- this.ky = m * w * w2 * (1 - E2); // based on meridonal radius of curvature
14824
- }
14825
-
14826
- /**
14827
- * Given two points of the form [longitude, latitude], returns the distance.
14828
- *
14829
- * @param {[number, number]} a point [longitude, latitude]
14830
- * @param {[number, number]} b point [longitude, latitude]
14831
- * @returns {number} distance
14832
- * @example
14833
- * const distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);
14834
- * //=distance
14835
- */
14836
- distance(a, b) {
14837
- const dx = wrap(a[0] - b[0]) * this.kx;
14838
- const dy = (a[1] - b[1]) * this.ky;
14839
- return Math.sqrt(dx * dx + dy * dy);
14840
- }
14841
-
14842
- /**
14843
- * Returns the bearing between two points in angles.
14844
- *
14845
- * @param {[number, number]} a point [longitude, latitude]
14846
- * @param {[number, number]} b point [longitude, latitude]
14847
- * @returns {number} bearing
14848
- * @example
14849
- * const bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]);
14850
- * //=bearing
14851
- */
14852
- bearing(a, b) {
14853
- const dx = wrap(b[0] - a[0]) * this.kx;
14854
- const dy = (b[1] - a[1]) * this.ky;
14855
- return Math.atan2(dx, dy) / RAD;
14856
- }
14857
-
14858
- /**
14859
- * Returns a new point given distance and bearing from the starting point.
14860
- *
14861
- * @param {[number, number]} p point [longitude, latitude]
14862
- * @param {number} dist distance
14863
- * @param {number} bearing
14864
- * @returns {[number, number]} point [longitude, latitude]
14865
- * @example
14866
- * const point = ruler.destination([30.5, 50.5], 0.1, 90);
14867
- * //=point
14868
- */
14869
- destination(p, dist, bearing) {
14870
- const a = bearing * RAD;
14871
- return this.offset(p,
14872
- Math.sin(a) * dist,
14873
- Math.cos(a) * dist);
14874
- }
14875
-
14876
- /**
14877
- * Returns a new point given easting and northing offsets (in ruler units) from the starting point.
14878
- *
14879
- * @param {[number, number]} p point [longitude, latitude]
14880
- * @param {number} dx easting
14881
- * @param {number} dy northing
14882
- * @returns {[number, number]} point [longitude, latitude]
14883
- * @example
14884
- * const point = ruler.offset([30.5, 50.5], 10, 10);
14885
- * //=point
14886
- */
14887
- offset(p, dx, dy) {
14888
- return [
14889
- p[0] + dx / this.kx,
14890
- p[1] + dy / this.ky
14891
- ];
14892
- }
14893
-
14894
- /**
14895
- * Given a line (an array of points), returns the total line distance.
14896
- *
14897
- * @param {[number, number][]} points [longitude, latitude]
14898
- * @returns {number} total line distance
14899
- * @example
14900
- * const length = ruler.lineDistance([
14901
- * [-67.031, 50.458], [-67.031, 50.534],
14902
- * [-66.929, 50.534], [-66.929, 50.458]
14903
- * ]);
14904
- * //=length
14905
- */
14906
- lineDistance(points) {
14907
- let total = 0;
14908
- for (let i = 0; i < points.length - 1; i++) {
14909
- total += this.distance(points[i], points[i + 1]);
14910
- }
14911
- return total;
14912
- }
14913
-
14914
- /**
14915
- * Given a polygon (an array of rings, where each ring is an array of points), returns the area.
14916
- *
14917
- * @param {[number, number][][]} polygon
14918
- * @returns {number} area value in the specified units (square kilometers by default)
14919
- * @example
14920
- * const area = ruler.area([[
14921
- * [-67.031, 50.458], [-67.031, 50.534], [-66.929, 50.534],
14922
- * [-66.929, 50.458], [-67.031, 50.458]
14923
- * ]]);
14924
- * //=area
14925
- */
14926
- area(polygon) {
14927
- let sum = 0;
14928
-
14929
- for (let i = 0; i < polygon.length; i++) {
14930
- const ring = polygon[i];
14931
-
14932
- for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
14933
- sum += wrap(ring[j][0] - ring[k][0]) * (ring[j][1] + ring[k][1]) * (i ? -1 : 1);
14934
- }
14935
- }
14936
-
14937
- return (Math.abs(sum) / 2) * this.kx * this.ky;
14938
- }
14939
-
14940
- /**
14941
- * Returns the point at a specified distance along the line.
14942
- *
14943
- * @param {[number, number][]} line
14944
- * @param {number} dist distance
14945
- * @returns {[number, number]} point [longitude, latitude]
14946
- * @example
14947
- * const point = ruler.along(line, 2.5);
14948
- * //=point
14949
- */
14950
- along(line, dist) {
14951
- let sum = 0;
14952
-
14953
- if (dist <= 0) return line[0];
14954
-
14955
- for (let i = 0; i < line.length - 1; i++) {
14956
- const p0 = line[i];
14957
- const p1 = line[i + 1];
14958
- const d = this.distance(p0, p1);
14959
- sum += d;
14960
- if (sum > dist) return interpolate$1(p0, p1, (dist - (sum - d)) / d);
14961
- }
14962
-
14963
- return line[line.length - 1];
14964
- }
14965
-
14966
- /**
14967
- * Returns the distance from a point `p` to a line segment `a` to `b`.
14968
- *
14969
- * @pointToSegmentDistance
14970
- * @param {[number, number]} p point [longitude, latitude]
14971
- * @param {[number, number]} a segment point 1 [longitude, latitude]
14972
- * @param {[number, number]} b segment point 2 [longitude, latitude]
14973
- * @returns {number} distance
14974
- * @example
14975
- * const distance = ruler.pointToSegmentDistance([-67.04, 50.5], [-67.05, 50.57], [-67.03, 50.54]);
14976
- * //=distance
14977
- */
14978
- pointToSegmentDistance(p, a, b) {
14979
- let [x, y] = a;
14980
- let dx = wrap(b[0] - x) * this.kx;
14981
- let dy = (b[1] - y) * this.ky;
14982
-
14983
- if (dx !== 0 || dy !== 0) {
14984
- const t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
14985
-
14986
- if (t > 1) {
14987
- x = b[0];
14988
- y = b[1];
14989
-
14990
- } else if (t > 0) {
14991
- x += (dx / this.kx) * t;
14992
- y += (dy / this.ky) * t;
14993
- }
14994
- }
14995
-
14996
- dx = wrap(p[0] - x) * this.kx;
14997
- dy = (p[1] - y) * this.ky;
14998
-
14999
- return Math.sqrt(dx * dx + dy * dy);
15000
- }
15001
-
15002
- /**
15003
- * Returns an object of the form {point, index, t}, where point is closest point on the line
15004
- * from the given point, index is the start index of the segment with the closest point,
15005
- * and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
15006
- *
15007
- * @param {[number, number][]} line
15008
- * @param {[number, number]} p point [longitude, latitude]
15009
- * @returns {{point: [number, number], index: number, t: number}} {point, index, t}
15010
- * @example
15011
- * const point = ruler.pointOnLine(line, [-67.04, 50.5]).point;
15012
- * //=point
15013
- */
15014
- pointOnLine(line, p) {
15015
- let minDist = Infinity;
15016
- let minX = line[0][0];
15017
- let minY = line[0][1];
15018
- let minI = 0;
15019
- let minT = 0;
15020
-
15021
- for (let i = 0; i < line.length - 1; i++) {
15022
-
15023
- let x = line[i][0];
15024
- let y = line[i][1];
15025
- let dx = wrap(line[i + 1][0] - x) * this.kx;
15026
- let dy = (line[i + 1][1] - y) * this.ky;
15027
- let t = 0;
15028
-
15029
- if (dx !== 0 || dy !== 0) {
15030
- t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
15031
-
15032
- if (t > 1) {
15033
- x = line[i + 1][0];
15034
- y = line[i + 1][1];
15035
-
15036
- } else if (t > 0) {
15037
- x += (dx / this.kx) * t;
15038
- y += (dy / this.ky) * t;
15039
- }
15040
- }
15041
-
15042
- dx = wrap(p[0] - x) * this.kx;
15043
- dy = (p[1] - y) * this.ky;
15044
-
15045
- const sqDist = dx * dx + dy * dy;
15046
- if (sqDist < minDist) {
15047
- minDist = sqDist;
15048
- minX = x;
15049
- minY = y;
15050
- minI = i;
15051
- minT = t;
15052
- }
15053
- }
15054
-
15055
- return {
15056
- point: [minX, minY],
15057
- index: minI,
15058
- t: Math.max(0, Math.min(1, minT))
15059
- };
15060
- }
15061
-
15062
- /**
15063
- * Returns a part of the given line between the start and the stop points (or their closest points on the line).
15064
- *
15065
- * @param {[number, number]} start point [longitude, latitude]
15066
- * @param {[number, number]} stop point [longitude, latitude]
15067
- * @param {[number, number][]} line
15068
- * @returns {[number, number][]} line part of a line
15069
- * @example
15070
- * const line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1);
15071
- * //=line2
15072
- */
15073
- lineSlice(start, stop, line) {
15074
- let p1 = this.pointOnLine(line, start);
15075
- let p2 = this.pointOnLine(line, stop);
15076
-
15077
- if (p1.index > p2.index || (p1.index === p2.index && p1.t > p2.t)) {
15078
- const tmp = p1;
15079
- p1 = p2;
15080
- p2 = tmp;
15081
- }
15082
-
15083
- const slice = [p1.point];
15084
-
15085
- const l = p1.index + 1;
15086
- const r = p2.index;
15087
-
15088
- if (!equals(line[l], slice[0]) && l <= r)
15089
- slice.push(line[l]);
15090
-
15091
- for (let i = l + 1; i <= r; i++) {
15092
- slice.push(line[i]);
15093
- }
15094
-
15095
- if (!equals(line[r], p2.point))
15096
- slice.push(p2.point);
15097
-
15098
- return slice;
15099
- }
15100
-
15101
- /**
15102
- * Returns a part of the given line between the start and the stop points indicated by distance along the line.
15103
- *
15104
- * @param {number} start start distance
15105
- * @param {number} stop stop distance
15106
- * @param {[number, number][]} line
15107
- * @returns {[number, number][]} part of a line
15108
- * @example
15109
- * const line2 = ruler.lineSliceAlong(10, 20, line1);
15110
- * //=line2
15111
- */
15112
- lineSliceAlong(start, stop, line) {
15113
- let sum = 0;
15114
- const slice = [];
15115
-
15116
- for (let i = 0; i < line.length - 1; i++) {
15117
- const p0 = line[i];
15118
- const p1 = line[i + 1];
15119
- const d = this.distance(p0, p1);
15120
-
15121
- sum += d;
15122
-
15123
- if (sum > start && slice.length === 0) {
15124
- slice.push(interpolate$1(p0, p1, (start - (sum - d)) / d));
15125
- }
15126
-
15127
- if (sum >= stop) {
15128
- slice.push(interpolate$1(p0, p1, (stop - (sum - d)) / d));
15129
- return slice;
15130
- }
15131
-
15132
- if (sum > start) slice.push(p1);
15133
- }
15134
-
15135
- return slice;
15136
- }
15137
-
15138
- /**
15139
- * Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance.
15140
- *
15141
- * @param {[number, number]} p point [longitude, latitude]
15142
- * @param {number} buffer
15143
- * @returns {[number, number, number, number]} bbox ([w, s, e, n])
15144
- * @example
15145
- * const bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
15146
- * //=bbox
15147
- */
15148
- bufferPoint(p, buffer) {
15149
- const v = buffer / this.ky;
15150
- const h = buffer / this.kx;
15151
- return [
15152
- p[0] - h,
15153
- p[1] - v,
15154
- p[0] + h,
15155
- p[1] + v
15156
- ];
15157
- }
15158
-
15159
- /**
15160
- * Given a bounding box, returns the box buffered by a given distance.
15161
- *
15162
- * @param {[number, number, number, number]} bbox ([w, s, e, n])
15163
- * @param {number} buffer
15164
- * @returns {[number, number, number, number]} bbox ([w, s, e, n])
15165
- * @example
15166
- * const bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2);
15167
- * //=bbox
15168
- */
15169
- bufferBBox(bbox, buffer) {
15170
- const v = buffer / this.ky;
15171
- const h = buffer / this.kx;
15172
- return [
15173
- bbox[0] - h,
15174
- bbox[1] - v,
15175
- bbox[2] + h,
15176
- bbox[3] + v
15177
- ];
15178
- }
15179
-
15180
- /**
15181
- * Returns true if the given point is inside in the given bounding box, otherwise false.
15182
- *
15183
- * @param {[number, number]} p point [longitude, latitude]
15184
- * @param {[number, number, number, number]} bbox ([w, s, e, n])
15185
- * @returns {boolean}
15186
- * @example
15187
- * const inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
15188
- * //=inside
15189
- */
15190
- insideBBox(p, bbox) { // eslint-disable-line
15191
- return wrap(p[0] - bbox[0]) >= 0 &&
15192
- wrap(p[0] - bbox[2]) <= 0 &&
15193
- p[1] >= bbox[1] &&
15194
- p[1] <= bbox[3];
15195
- }
15196
- }
15197
-
15198
- /**
15199
- * @param {[number, number]} a
15200
- * @param {[number, number]} b
15201
- */
15202
- function equals(a, b) {
15203
- return a[0] === b[0] && a[1] === b[1];
15204
- }
15205
-
15206
- /**
15207
- * @param {[number, number]} a
15208
- * @param {[number, number]} b
15209
- * @param {number} t
15210
- * @returns {[number, number]}
15211
- */
15212
- function interpolate$1(a, b, t) {
15213
- const dx = wrap(b[0] - a[0]);
15214
- const dy = b[1] - a[1];
15215
- return [
15216
- a[0] + dx * t,
15217
- a[1] + dy * t
15218
- ];
15219
- }
15220
-
15221
- /**
15222
- * normalize a degree value into [-180..180] range
15223
- * @param {number} deg
15224
- */
15225
- function wrap(deg) {
15226
- while (deg < -180) deg += 360;
15227
- while (deg > 180) deg -= 360;
15228
- return deg;
15229
- }
15230
-
15231
14769
  class TinyQueue {
15232
14770
  constructor(data = [], compare = (a, b) => (a < b ? -1 : a > b ? 1 : 0)) {
15233
14771
  this.data = data;
@@ -15301,6 +14839,77 @@
15301
14839
 
15302
14840
  var EXTENT = 8192;
15303
14841
 
14842
+ const RE = 6378.137;
14843
+ const FE = 1 / 298.257223563;
14844
+ const E2 = FE * (2 - FE);
14845
+ const RAD = Math.PI / 180;
14846
+ function lngLatScale(lat) {
14847
+ const m = RAD * RE * 1e3;
14848
+ const coslat = Math.cos(lat * RAD);
14849
+ const w2 = 1 / (1 - E2 * (1 - coslat * coslat));
14850
+ const w = Math.sqrt(w2);
14851
+ return [m * w * coslat, m * w * w2 * (1 - E2)];
14852
+ }
14853
+ function wrapLng(deg) {
14854
+ while (deg < -180) deg += 360;
14855
+ while (deg > 180) deg -= 360;
14856
+ return deg;
14857
+ }
14858
+ function rulerDistance(a, b, kx, ky) {
14859
+ const dx = wrapLng(a[0] - b[0]) * kx;
14860
+ const dy = (a[1] - b[1]) * ky;
14861
+ return Math.sqrt(dx * dx + dy * dy);
14862
+ }
14863
+ function rulerPointToSegmentDistance(p, a, b, kx, ky) {
14864
+ let x = a[0];
14865
+ let y = a[1];
14866
+ let dx = wrapLng(b[0] - x) * kx;
14867
+ let dy = (b[1] - y) * ky;
14868
+ if (dx !== 0 || dy !== 0) {
14869
+ const t = (wrapLng(p[0] - x) * kx * dx + (p[1] - y) * ky * dy) / (dx * dx + dy * dy);
14870
+ if (t > 1) {
14871
+ x = b[0];
14872
+ y = b[1];
14873
+ } else if (t > 0) {
14874
+ x += dx / kx * t;
14875
+ y += dy / ky * t;
14876
+ }
14877
+ }
14878
+ dx = wrapLng(p[0] - x) * kx;
14879
+ dy = (p[1] - y) * ky;
14880
+ return Math.sqrt(dx * dx + dy * dy);
14881
+ }
14882
+ function rulerPointOnLine(line, p, kx, ky) {
14883
+ let minDist = Infinity;
14884
+ let minX = line[0][0];
14885
+ let minY = line[0][1];
14886
+ for (let i = 0; i < line.length - 1; i++) {
14887
+ let x = line[i][0];
14888
+ let y = line[i][1];
14889
+ let dx = wrapLng(line[i + 1][0] - x) * kx;
14890
+ let dy = (line[i + 1][1] - y) * ky;
14891
+ let t = 0;
14892
+ if (dx !== 0 || dy !== 0) {
14893
+ t = (wrapLng(p[0] - x) * kx * dx + (p[1] - y) * ky * dy) / (dx * dx + dy * dy);
14894
+ if (t > 1) {
14895
+ x = line[i + 1][0];
14896
+ y = line[i + 1][1];
14897
+ } else if (t > 0) {
14898
+ x += dx / kx * t;
14899
+ y += dy / ky * t;
14900
+ }
14901
+ }
14902
+ dx = wrapLng(p[0] - x) * kx;
14903
+ dy = (p[1] - y) * ky;
14904
+ const sqDist = dx * dx + dy * dy;
14905
+ if (sqDist < minDist) {
14906
+ minDist = sqDist;
14907
+ minX = x;
14908
+ minY = y;
14909
+ }
14910
+ }
14911
+ return [minX, minY];
14912
+ }
15304
14913
  function compareMax(a, b) {
15305
14914
  return b.dist - a.dist;
15306
14915
  }
@@ -15366,7 +14975,7 @@
15366
14975
  }
15367
14976
  return bbox;
15368
14977
  }
15369
- function bboxToBBoxDistance(bbox1, bbox2, ruler) {
14978
+ function bboxToBBoxDistance(bbox1, bbox2, kx, ky) {
15370
14979
  if (isDefaultBBOX(bbox1) || isDefaultBBOX(bbox2)) {
15371
14980
  return NaN;
15372
14981
  }
@@ -15384,7 +14993,7 @@
15384
14993
  if (bbox1[3] < bbox2[1]) {
15385
14994
  dy = bbox2[1] - bbox1[3];
15386
14995
  }
15387
- return ruler.distance([0, 0], [dx, dy]);
14996
+ return rulerDistance([0, 0], [dx, dy], kx, ky);
15388
14997
  }
15389
14998
  function getLngLatPoint(coord, canonical, extent = EXTENT) {
15390
14999
  const tilesAtZoom = Math.pow(2, canonical.z);
@@ -15399,30 +15008,30 @@
15399
15008
  }
15400
15009
  return coords;
15401
15010
  }
15402
- function pointToLineDistance(point, line, ruler) {
15403
- const nearestPoint = ruler.pointOnLine(line, point).point;
15404
- return ruler.distance(point, nearestPoint);
15011
+ function pointToLineDistance(point, line, kx, ky) {
15012
+ const nearestPoint = rulerPointOnLine(line, point, kx, ky);
15013
+ return rulerDistance(point, nearestPoint, kx, ky);
15405
15014
  }
15406
- function pointsToLineDistance(points, rangeA, line, rangeB, ruler) {
15015
+ function pointsToLineDistance(points, rangeA, line, rangeB, kx, ky) {
15407
15016
  const subLine = line.slice(rangeB[0], rangeB[1] + 1);
15408
15017
  let dist = Infinity;
15409
15018
  for (let i = rangeA[0]; i <= rangeA[1]; ++i) {
15410
- if ((dist = Math.min(dist, pointToLineDistance(points[i], subLine, ruler))) === 0) return 0;
15019
+ if ((dist = Math.min(dist, pointToLineDistance(points[i], subLine, kx, ky))) === 0) return 0;
15411
15020
  }
15412
15021
  return dist;
15413
15022
  }
15414
- function segmentToSegmentDistance(p1, p2, q1, q2, ruler) {
15023
+ function segmentToSegmentDistance(p1, p2, q1, q2, kx, ky) {
15415
15024
  const dist1 = Math.min(
15416
- ruler.pointToSegmentDistance(p1, q1, q2),
15417
- ruler.pointToSegmentDistance(p2, q1, q2)
15025
+ rulerPointToSegmentDistance(p1, q1, q2, kx, ky),
15026
+ rulerPointToSegmentDistance(p2, q1, q2, kx, ky)
15418
15027
  );
15419
15028
  const dist2 = Math.min(
15420
- ruler.pointToSegmentDistance(q1, p1, p2),
15421
- ruler.pointToSegmentDistance(q2, p1, p2)
15029
+ rulerPointToSegmentDistance(q1, p1, p2, kx, ky),
15030
+ rulerPointToSegmentDistance(q2, p1, p2, kx, ky)
15422
15031
  );
15423
15032
  return Math.min(dist1, dist2);
15424
15033
  }
15425
- function lineToLineDistance(line1, range1, line2, range2, ruler) {
15034
+ function lineToLineDistance(line1, range1, line2, range2, kx, ky) {
15426
15035
  if (!isRangeSafe(range1, line1.length) || !isRangeSafe(range2, line2.length)) {
15427
15036
  return NaN;
15428
15037
  }
@@ -15430,24 +15039,24 @@
15430
15039
  for (let i = range1[0]; i < range1[1]; ++i) {
15431
15040
  for (let j = range2[0]; j < range2[1]; ++j) {
15432
15041
  if (segmentIntersectSegment(line1[i], line1[i + 1], line2[j], line2[j + 1])) return 0;
15433
- dist = Math.min(dist, segmentToSegmentDistance(line1[i], line1[i + 1], line2[j], line2[j + 1], ruler));
15042
+ dist = Math.min(dist, segmentToSegmentDistance(line1[i], line1[i + 1], line2[j], line2[j + 1], kx, ky));
15434
15043
  }
15435
15044
  }
15436
15045
  return dist;
15437
15046
  }
15438
- function pointsToPointsDistance(pointSet1, range1, pointSet2, range2, ruler) {
15047
+ function pointsToPointsDistance(pointSet1, range1, pointSet2, range2, kx, ky) {
15439
15048
  if (!isRangeSafe(range1, pointSet1.length) || !isRangeSafe(range2, pointSet2.length)) {
15440
15049
  return NaN;
15441
15050
  }
15442
15051
  let dist = Infinity;
15443
15052
  for (let i = range1[0]; i <= range1[1]; ++i) {
15444
15053
  for (let j = range2[0]; j <= range2[1]; ++j) {
15445
- if ((dist = Math.min(dist, ruler.distance(pointSet1[i], pointSet2[j]))) === 0) return dist;
15054
+ if ((dist = Math.min(dist, rulerDistance(pointSet1[i], pointSet2[j], kx, ky))) === 0) return dist;
15446
15055
  }
15447
15056
  }
15448
15057
  return dist;
15449
15058
  }
15450
- function pointToPolygonDistance(point, polygon, ruler) {
15059
+ function pointToPolygonDistance(point, polygon, kx, ky) {
15451
15060
  if (pointWithinPolygon(
15452
15061
  point,
15453
15062
  polygon,
@@ -15462,13 +15071,13 @@
15462
15071
  return NaN;
15463
15072
  }
15464
15073
  if (ring[0] !== ring[ringLen - 1]) {
15465
- if ((dist = Math.min(dist, ruler.pointToSegmentDistance(point, ring[ringLen - 1], ring[0]))) === 0) return dist;
15074
+ if ((dist = Math.min(dist, rulerPointToSegmentDistance(point, ring[ringLen - 1], ring[0], kx, ky))) === 0) return dist;
15466
15075
  }
15467
- if ((dist = Math.min(dist, pointToLineDistance(point, ring, ruler))) === 0) return dist;
15076
+ if ((dist = Math.min(dist, pointToLineDistance(point, ring, kx, ky))) === 0) return dist;
15468
15077
  }
15469
15078
  return dist;
15470
15079
  }
15471
- function lineToPolygonDistance(line, range, polygon, ruler) {
15080
+ function lineToPolygonDistance(line, range, polygon, kx, ky) {
15472
15081
  if (!isRangeSafe(range, line.length)) {
15473
15082
  return NaN;
15474
15083
  }
@@ -15485,7 +15094,7 @@
15485
15094
  for (const ring of polygon) {
15486
15095
  for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
15487
15096
  if (segmentIntersectSegment(line[i], line[i + 1], ring[k], ring[j])) return 0;
15488
- dist = Math.min(dist, segmentToSegmentDistance(line[i], line[i + 1], ring[k], ring[j], ruler));
15097
+ dist = Math.min(dist, segmentToSegmentDistance(line[i], line[i + 1], ring[k], ring[j], kx, ky));
15489
15098
  }
15490
15099
  }
15491
15100
  }
@@ -15504,10 +15113,10 @@
15504
15113
  }
15505
15114
  return false;
15506
15115
  }
15507
- function polygonToPolygonDistance(polygon1, polygon2, ruler, currentMiniDist = Infinity) {
15116
+ function polygonToPolygonDistance(polygon1, polygon2, kx, ky, currentMiniDist = Infinity) {
15508
15117
  const bbox1 = getPolygonBBox(polygon1);
15509
15118
  const bbox2 = getPolygonBBox(polygon2);
15510
- if (currentMiniDist !== Infinity && bboxToBBoxDistance(bbox1, bbox2, ruler) >= currentMiniDist) {
15119
+ if (currentMiniDist !== Infinity && bboxToBBoxDistance(bbox1, bbox2, kx, ky) >= currentMiniDist) {
15511
15120
  return currentMiniDist;
15512
15121
  }
15513
15122
  if (boxWithinBox(bbox1, bbox2)) {
@@ -15521,20 +15130,20 @@
15521
15130
  for (const ring2 of polygon2) {
15522
15131
  for (let j = 0, len2 = ring2.length, k = len2 - 1; j < len2; k = j++) {
15523
15132
  if (segmentIntersectSegment(ring1[l], ring1[i], ring2[k], ring2[j])) return 0;
15524
- dist = Math.min(dist, segmentToSegmentDistance(ring1[l], ring1[i], ring2[k], ring2[j], ruler));
15133
+ dist = Math.min(dist, segmentToSegmentDistance(ring1[l], ring1[i], ring2[k], ring2[j], kx, ky));
15525
15134
  }
15526
15135
  }
15527
15136
  }
15528
15137
  }
15529
15138
  return dist;
15530
15139
  }
15531
- function updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, r1, r2) {
15140
+ function updateQueue(distQueue, miniDist, kx, ky, pointSet1, pointSet2, r1, r2) {
15532
15141
  if (r1 === null || r2 === null) return;
15533
- const tempDist = bboxToBBoxDistance(getBBox(pointSet1, r1), getBBox(pointSet2, r2), ruler);
15142
+ const tempDist = bboxToBBoxDistance(getBBox(pointSet1, r1), getBBox(pointSet2, r2), kx, ky);
15534
15143
  if (tempDist < miniDist) distQueue.push({ dist: tempDist, range1: r1, range2: r2 });
15535
15144
  }
15536
- function pointSetToPolygonDistance(pointSets, isLine, polygon, ruler, currentMiniDist = Infinity) {
15537
- let miniDist = Math.min(ruler.distance(pointSets[0], polygon[0][0]), currentMiniDist);
15145
+ function pointSetToPolygonDistance(pointSets, isLine, polygon, kx, ky, currentMiniDist = Infinity) {
15146
+ let miniDist = Math.min(rulerDistance(pointSets[0], polygon[0][0], kx, ky), currentMiniDist);
15538
15147
  if (miniDist === 0) return miniDist;
15539
15148
  const initialDistPair = {
15540
15149
  dist: 0,
@@ -15551,30 +15160,30 @@
15551
15160
  if (getRangeSize(range) <= setThreshold) {
15552
15161
  if (!isRangeSafe(range, pointSets.length)) return NaN;
15553
15162
  if (isLine) {
15554
- const tempDist = lineToPolygonDistance(pointSets, range, polygon, ruler);
15163
+ const tempDist = lineToPolygonDistance(pointSets, range, polygon, kx, ky);
15555
15164
  if ((miniDist = Math.min(miniDist, tempDist)) === 0) return miniDist;
15556
15165
  } else {
15557
15166
  for (let i = range[0]; i <= range[1]; ++i) {
15558
- const tempDist = pointToPolygonDistance(pointSets[i], polygon, ruler);
15167
+ const tempDist = pointToPolygonDistance(pointSets[i], polygon, kx, ky);
15559
15168
  if ((miniDist = Math.min(miniDist, tempDist)) === 0) return miniDist;
15560
15169
  }
15561
15170
  }
15562
15171
  } else {
15563
15172
  const newRanges = splitRange(range, isLine);
15564
15173
  if (newRanges[0] !== null) {
15565
- const tempDist = bboxToBBoxDistance(getBBox(pointSets, newRanges[0]), polyBBox, ruler);
15174
+ const tempDist = bboxToBBoxDistance(getBBox(pointSets, newRanges[0]), polyBBox, kx, ky);
15566
15175
  if (tempDist < miniDist) distQueue.push({ dist: tempDist, range1: newRanges[0], range2: [0, 0] });
15567
15176
  }
15568
15177
  if (newRanges[1] !== null) {
15569
- const tempDist = bboxToBBoxDistance(getBBox(pointSets, newRanges[1]), polyBBox, ruler);
15178
+ const tempDist = bboxToBBoxDistance(getBBox(pointSets, newRanges[1]), polyBBox, kx, ky);
15570
15179
  if (tempDist < miniDist) distQueue.push({ dist: tempDist, range1: newRanges[1], range2: [0, 0] });
15571
15180
  }
15572
15181
  }
15573
15182
  }
15574
15183
  return miniDist;
15575
15184
  }
15576
- function pointSetsDistance(pointSet1, isLine1, pointSet2, isLine2, ruler, currentMiniDist = Infinity) {
15577
- let miniDist = Math.min(currentMiniDist, ruler.distance(pointSet1[0], pointSet2[0]));
15185
+ function pointSetsDistance(pointSet1, isLine1, pointSet2, isLine2, kx, ky, currentMiniDist = Infinity) {
15186
+ let miniDist = Math.min(currentMiniDist, rulerDistance(pointSet1[0], pointSet2[0], kx, ky));
15578
15187
  if (miniDist === 0) return miniDist;
15579
15188
  const initialDistPair = {
15580
15189
  dist: 0,
@@ -15594,52 +15203,52 @@
15594
15203
  return NaN;
15595
15204
  }
15596
15205
  if (isLine1 && isLine2) {
15597
- miniDist = Math.min(miniDist, lineToLineDistance(pointSet1, rangeA, pointSet2, rangeB, ruler));
15206
+ miniDist = Math.min(miniDist, lineToLineDistance(pointSet1, rangeA, pointSet2, rangeB, kx, ky));
15598
15207
  } else if (!isLine1 && !isLine2) {
15599
- miniDist = Math.min(miniDist, pointsToPointsDistance(pointSet1, rangeA, pointSet2, rangeB, ruler));
15208
+ miniDist = Math.min(miniDist, pointsToPointsDistance(pointSet1, rangeA, pointSet2, rangeB, kx, ky));
15600
15209
  } else if (isLine1 && !isLine2) {
15601
- miniDist = Math.min(miniDist, pointsToLineDistance(pointSet2, rangeB, pointSet1, rangeA, ruler));
15210
+ miniDist = Math.min(miniDist, pointsToLineDistance(pointSet2, rangeB, pointSet1, rangeA, kx, ky));
15602
15211
  } else if (!isLine1 && isLine2) {
15603
- miniDist = Math.min(miniDist, pointsToLineDistance(pointSet1, rangeA, pointSet2, rangeB, ruler));
15212
+ miniDist = Math.min(miniDist, pointsToLineDistance(pointSet1, rangeA, pointSet2, rangeB, kx, ky));
15604
15213
  }
15605
15214
  if (miniDist === 0) return miniDist;
15606
15215
  } else {
15607
15216
  const newRangesA = splitRange(rangeA, isLine1);
15608
15217
  const newRangesB = splitRange(rangeB, isLine2);
15609
- updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[0], newRangesB[0]);
15610
- updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[0], newRangesB[1]);
15611
- updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[1], newRangesB[0]);
15612
- updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[1], newRangesB[1]);
15218
+ updateQueue(distQueue, miniDist, kx, ky, pointSet1, pointSet2, newRangesA[0], newRangesB[0]);
15219
+ updateQueue(distQueue, miniDist, kx, ky, pointSet1, pointSet2, newRangesA[0], newRangesB[1]);
15220
+ updateQueue(distQueue, miniDist, kx, ky, pointSet1, pointSet2, newRangesA[1], newRangesB[0]);
15221
+ updateQueue(distQueue, miniDist, kx, ky, pointSet1, pointSet2, newRangesA[1], newRangesB[1]);
15613
15222
  }
15614
15223
  }
15615
15224
  return miniDist;
15616
15225
  }
15617
- function pointSetToLinesDistance(pointSet, isLine, lines, ruler, currentMiniDist = Infinity) {
15226
+ function pointSetToLinesDistance(pointSet, isLine, lines, kx, ky, currentMiniDist = Infinity) {
15618
15227
  let dist = currentMiniDist;
15619
15228
  const bbox1 = getBBox(pointSet, [0, pointSet.length - 1]);
15620
15229
  for (const line of lines) {
15621
- if (dist !== Infinity && bboxToBBoxDistance(bbox1, getBBox(line, [0, line.length - 1]), ruler) >= dist) continue;
15622
- dist = Math.min(dist, pointSetsDistance(pointSet, isLine, line, true, ruler, dist));
15230
+ if (dist !== Infinity && bboxToBBoxDistance(bbox1, getBBox(line, [0, line.length - 1]), kx, ky) >= dist) continue;
15231
+ dist = Math.min(dist, pointSetsDistance(pointSet, isLine, line, true, kx, ky, dist));
15623
15232
  if (dist === 0) return dist;
15624
15233
  }
15625
15234
  return dist;
15626
15235
  }
15627
- function pointSetToPolygonsDistance(points, isLine, polygons, ruler, currentMiniDist = Infinity) {
15236
+ function pointSetToPolygonsDistance(points, isLine, polygons, kx, ky, currentMiniDist = Infinity) {
15628
15237
  let dist = currentMiniDist;
15629
15238
  const bbox1 = getBBox(points, [0, points.length - 1]);
15630
15239
  for (const polygon of polygons) {
15631
- if (dist !== Infinity && bboxToBBoxDistance(bbox1, getPolygonBBox(polygon), ruler) >= dist) continue;
15632
- const tempDist = pointSetToPolygonDistance(points, isLine, polygon, ruler, dist);
15240
+ if (dist !== Infinity && bboxToBBoxDistance(bbox1, getPolygonBBox(polygon), kx, ky) >= dist) continue;
15241
+ const tempDist = pointSetToPolygonDistance(points, isLine, polygon, kx, ky, dist);
15633
15242
  if (isNaN(tempDist)) return tempDist;
15634
15243
  if ((dist = Math.min(dist, tempDist)) === 0) return dist;
15635
15244
  }
15636
15245
  return dist;
15637
15246
  }
15638
- function polygonsToPolygonsDistance(polygons1, polygons2, ruler) {
15247
+ function polygonsToPolygonsDistance(polygons1, polygons2, kx, ky) {
15639
15248
  let dist = Infinity;
15640
15249
  for (const polygon1 of polygons1) {
15641
15250
  for (const polygon2 of polygons2) {
15642
- const tempDist = polygonToPolygonDistance(polygon1, polygon2, ruler, dist);
15251
+ const tempDist = polygonToPolygonDistance(polygon1, polygon2, kx, ky, dist);
15643
15252
  if (isNaN(tempDist)) return tempDist;
15644
15253
  if ((dist = Math.min(dist, tempDist)) === 0) return dist;
15645
15254
  }
@@ -15653,25 +15262,27 @@
15653
15262
  lngLatPoints.push(getLngLatPoint(point, canonical));
15654
15263
  }
15655
15264
  }
15656
- const ruler = new CheapRuler(lngLatPoints[0][1], "meters");
15265
+ const [kx, ky] = lngLatScale(lngLatPoints[0][1]);
15657
15266
  if (geometry.type === "Point" || geometry.type === "MultiPoint" || geometry.type === "LineString") {
15658
15267
  return pointSetsDistance(
15659
15268
  lngLatPoints,
15660
15269
  false,
15661
15270
  geometry.type === "Point" ? [geometry.coordinates] : geometry.coordinates,
15662
15271
  geometry.type === "LineString",
15663
- ruler
15272
+ kx,
15273
+ ky
15664
15274
  );
15665
15275
  }
15666
15276
  if (geometry.type === "MultiLineString") {
15667
- return pointSetToLinesDistance(lngLatPoints, false, geometry.coordinates, ruler);
15277
+ return pointSetToLinesDistance(lngLatPoints, false, geometry.coordinates, kx, ky);
15668
15278
  }
15669
15279
  if (geometry.type === "Polygon" || geometry.type === "MultiPolygon") {
15670
15280
  return pointSetToPolygonsDistance(
15671
15281
  lngLatPoints,
15672
15282
  false,
15673
15283
  geometry.type === "Polygon" ? [geometry.coordinates] : geometry.coordinates,
15674
- ruler
15284
+ kx,
15285
+ ky
15675
15286
  );
15676
15287
  }
15677
15288
  return null;
@@ -15685,19 +15296,20 @@
15685
15296
  }
15686
15297
  lngLatLines.push(lngLatLine);
15687
15298
  }
15688
- const ruler = new CheapRuler(lngLatLines[0][0][1], "meters");
15299
+ const [kx, ky] = lngLatScale(lngLatLines[0][0][1]);
15689
15300
  if (geometry.type === "Point" || geometry.type === "MultiPoint" || geometry.type === "LineString") {
15690
15301
  return pointSetToLinesDistance(
15691
15302
  geometry.type === "Point" ? [geometry.coordinates] : geometry.coordinates,
15692
15303
  geometry.type === "LineString",
15693
15304
  lngLatLines,
15694
- ruler
15305
+ kx,
15306
+ ky
15695
15307
  );
15696
15308
  }
15697
15309
  if (geometry.type === "MultiLineString") {
15698
15310
  let dist = Infinity;
15699
15311
  for (let i = 0; i < geometry.coordinates.length; i++) {
15700
- const tempDist = pointSetToLinesDistance(geometry.coordinates[i], true, lngLatLines, ruler, dist);
15312
+ const tempDist = pointSetToLinesDistance(geometry.coordinates[i], true, lngLatLines, kx, ky, dist);
15701
15313
  if (isNaN(tempDist)) return tempDist;
15702
15314
  if ((dist = Math.min(dist, tempDist)) === 0) return dist;
15703
15315
  }
@@ -15710,7 +15322,8 @@
15710
15322
  lngLatLines[i],
15711
15323
  true,
15712
15324
  geometry.type === "Polygon" ? [geometry.coordinates] : geometry.coordinates,
15713
- ruler,
15325
+ kx,
15326
+ ky,
15714
15327
  dist
15715
15328
  );
15716
15329
  if (isNaN(tempDist)) return tempDist;
@@ -15729,19 +15342,20 @@
15729
15342
  }
15730
15343
  lngLatPolygons.push(lngLatPolygon);
15731
15344
  }
15732
- const ruler = new CheapRuler(lngLatPolygons[0][0][0][1], "meters");
15345
+ const [kx, ky] = lngLatScale(lngLatPolygons[0][0][0][1]);
15733
15346
  if (geometry.type === "Point" || geometry.type === "MultiPoint" || geometry.type === "LineString") {
15734
15347
  return pointSetToPolygonsDistance(
15735
15348
  geometry.type === "Point" ? [geometry.coordinates] : geometry.coordinates,
15736
15349
  geometry.type === "LineString",
15737
15350
  lngLatPolygons,
15738
- ruler
15351
+ kx,
15352
+ ky
15739
15353
  );
15740
15354
  }
15741
15355
  if (geometry.type === "MultiLineString") {
15742
15356
  let dist = Infinity;
15743
15357
  for (let i = 0; i < geometry.coordinates.length; i++) {
15744
- const tempDist = pointSetToPolygonsDistance(geometry.coordinates[i], true, lngLatPolygons, ruler, dist);
15358
+ const tempDist = pointSetToPolygonsDistance(geometry.coordinates[i], true, lngLatPolygons, kx, ky, dist);
15745
15359
  if (isNaN(tempDist)) return tempDist;
15746
15360
  if ((dist = Math.min(dist, tempDist)) === 0) return dist;
15747
15361
  }
@@ -15751,7 +15365,8 @@
15751
15365
  return polygonsToPolygonsDistance(
15752
15366
  geometry.type === "Polygon" ? [geometry.coordinates] : geometry.coordinates,
15753
15367
  lngLatPolygons,
15754
- ruler
15368
+ kx,
15369
+ ky
15755
15370
  );
15756
15371
  }
15757
15372
  return null;
@@ -15863,18 +15478,21 @@
15863
15478
  });
15864
15479
  return result;
15865
15480
  }
15866
- function isGlobalPropertyConstant(e, properties) {
15867
- if (e instanceof CompoundExpression && properties.includes(e.name)) {
15481
+ function isGlobalPropertyConstantSet(e, properties) {
15482
+ if (e instanceof CompoundExpression && properties.has(e.name)) {
15868
15483
  return false;
15869
15484
  }
15870
15485
  let result = true;
15871
15486
  e.eachChild((arg) => {
15872
- if (result && !isGlobalPropertyConstant(arg, properties)) {
15487
+ if (result && !isGlobalPropertyConstantSet(arg, properties)) {
15873
15488
  result = false;
15874
15489
  }
15875
15490
  });
15876
15491
  return result;
15877
15492
  }
15493
+ function isGlobalPropertyConstant(e, properties) {
15494
+ return isGlobalPropertyConstantSet(e, new Set(properties));
15495
+ }
15878
15496
 
15879
15497
  const FQIDSeparator = "";
15880
15498
  function makeConfigFQID(id, ownScope, contextScope) {
@@ -16041,16 +15659,12 @@
16041
15659
  this.iconImageUseTheme = iconImageUseTheme;
16042
15660
  }
16043
15661
  get key() {
16044
- if (this._key === void 0) {
16045
- const path = this.path;
16046
- let key = "";
16047
- for (let i = 0; i < path.length; i++) {
16048
- const part = path[i];
16049
- key += typeof part === "string" ? `['${part}']` : `[${part}]`;
16050
- }
16051
- this._key = key;
15662
+ let key = "";
15663
+ for (let i = 0; i < this.path.length; i++) {
15664
+ const part = this.path[i];
15665
+ key += typeof part === "string" ? `['${part}']` : `[${part}]`;
16052
15666
  }
16053
- return this._key;
15667
+ return key;
16054
15668
  }
16055
15669
  /**
16056
15670
  * @param expr the JSON expression to parse
@@ -16061,7 +15675,17 @@
16061
15675
  */
16062
15676
  parse(expr, index, expectedType, bindings, options = {}) {
16063
15677
  if (index || expectedType) {
16064
- return this.concat(index, null, expectedType, bindings)._parse(expr, options);
15678
+ const prevExpectedType = this.expectedType;
15679
+ const prevScope = this.scope;
15680
+ if (bindings) this.scope = this.scope.concat(bindings);
15681
+ this.expectedType = expectedType || null;
15682
+ const pushed = typeof index === "number";
15683
+ if (pushed) this.path.push(index);
15684
+ const result = this._parse(expr, options);
15685
+ if (pushed) this.path.pop();
15686
+ this.expectedType = prevExpectedType;
15687
+ this.scope = prevScope;
15688
+ return result;
16065
15689
  }
16066
15690
  return this._parse(expr, options);
16067
15691
  }
@@ -16074,21 +15698,23 @@
16074
15698
  * @private
16075
15699
  */
16076
15700
  parseObjectValue(expr, index, key, expectedType, bindings, options = {}) {
16077
- return this.concat(index, key, expectedType, bindings)._parse(expr, options);
15701
+ const prevExpectedType = this.expectedType;
15702
+ const prevScope = this.scope;
15703
+ if (bindings) this.scope = this.scope.concat(bindings);
15704
+ this.expectedType = expectedType || null;
15705
+ this.path.push(index);
15706
+ this.path.push(key);
15707
+ const result = this._parse(expr, options);
15708
+ this.path.pop();
15709
+ this.path.pop();
15710
+ this.expectedType = prevExpectedType;
15711
+ this.scope = prevScope;
15712
+ return result;
16078
15713
  }
16079
15714
  _parse(expr, options) {
16080
15715
  if (expr === null || typeof expr === "string" || typeof expr === "boolean" || typeof expr === "number") {
16081
15716
  expr = ["literal", expr];
16082
15717
  }
16083
- function annotate(parsed, type, typeAnnotation) {
16084
- if (typeAnnotation === "assert") {
16085
- return new Assertion(type, [parsed]);
16086
- } else if (typeAnnotation === "coerce") {
16087
- return new Coercion(type, [parsed]);
16088
- } else {
16089
- return parsed;
16090
- }
16091
- }
16092
15718
  if (Array.isArray(expr)) {
16093
15719
  if (expr.length === 0) {
16094
15720
  return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);
@@ -16137,9 +15763,10 @@
16137
15763
  * @private
16138
15764
  */
16139
15765
  concat(index, key, expectedType, bindings) {
16140
- let path = typeof index === "number" ? this.path.concat(index) : this.path;
16141
- path = typeof key === "string" ? path.concat(key) : path;
16142
15766
  const scope = bindings ? this.scope.concat(bindings) : this.scope;
15767
+ const path = this.path.slice();
15768
+ if (typeof index === "number") path.push(index);
15769
+ if (typeof key === "string") path.push(key);
16143
15770
  return new ParsingContext(
16144
15771
  this.registry,
16145
15772
  path,
@@ -16151,6 +15778,24 @@
16151
15778
  this.iconImageUseTheme
16152
15779
  );
16153
15780
  }
15781
+ /**
15782
+ * Returns a fresh context that shares the same path position as this one
15783
+ * but has an empty errors array. Used by CompoundExpression to probe
15784
+ * overload signatures without polluting the parent errors list.
15785
+ * @private
15786
+ */
15787
+ _forkForSignature() {
15788
+ return new ParsingContext(
15789
+ this.registry,
15790
+ this.path.slice(),
15791
+ null,
15792
+ this.scope,
15793
+ [],
15794
+ this._scope,
15795
+ this.options,
15796
+ this.iconImageUseTheme
15797
+ );
15798
+ }
16154
15799
  /**
16155
15800
  * Push a parsing (or type checking) error into the `this.errors`
16156
15801
  * @param error The message
@@ -16172,6 +15817,30 @@
16172
15817
  return error;
16173
15818
  }
16174
15819
  }
15820
+ const CONSTANT_FOLD_EXCLUDED_GLOBALS = /* @__PURE__ */ new Set([
15821
+ "zoom",
15822
+ "heatmap-density",
15823
+ "worldview",
15824
+ "line-progress",
15825
+ "raster-value",
15826
+ "sky-radial-progress",
15827
+ "accumulated",
15828
+ "is-supported-script",
15829
+ "pitch",
15830
+ "distance-from-center",
15831
+ "measure-light",
15832
+ "raster-particle-speed",
15833
+ "is-active-floor"
15834
+ ]);
15835
+ function annotate(parsed, type, typeAnnotation) {
15836
+ if (typeAnnotation === "assert") {
15837
+ return new Assertion(type, [parsed]);
15838
+ } else if (typeAnnotation === "coerce") {
15839
+ return new Coercion(type, [parsed]);
15840
+ } else {
15841
+ return parsed;
15842
+ }
15843
+ }
16175
15844
  function isConstant(expression) {
16176
15845
  if (expression instanceof Var) {
16177
15846
  return isConstant(expression.boundExpression);
@@ -16198,7 +15867,7 @@
16198
15867
  if (!childrenConstant) {
16199
15868
  return false;
16200
15869
  }
16201
- return isFeatureConstant(expression) && isGlobalPropertyConstant(expression, ["zoom", "heatmap-density", "worldview", "line-progress", "raster-value", "sky-radial-progress", "accumulated", "is-supported-script", "pitch", "distance-from-center", "measure-light", "raster-particle-speed", "is-active-floor"]);
15870
+ return isFeatureConstant(expression) && isGlobalPropertyConstantSet(expression, CONSTANT_FOLD_EXCLUDED_GLOBALS);
16202
15871
  }
16203
15872
 
16204
15873
  function findStopLessThanOrEqualTo(stops, input) {
@@ -16963,24 +16632,23 @@
16963
16632
  if (!Array.isArray(labels)) {
16964
16633
  labels = [labels];
16965
16634
  }
16966
- const labelContext = context.concat(i);
16967
16635
  if (labels.length === 0) {
16968
- return labelContext.error("Expected at least one branch label.");
16636
+ return context.error("Expected at least one branch label.", i);
16969
16637
  }
16970
16638
  for (const label of labels) {
16971
16639
  if (typeof label !== "number" && typeof label !== "string") {
16972
- return labelContext.error(`Branch labels must be numbers or strings.`);
16640
+ return context.error(`Branch labels must be numbers or strings.`, i);
16973
16641
  } else if (typeof label === "number" && Math.abs(label) > Number.MAX_SAFE_INTEGER) {
16974
- return labelContext.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);
16642
+ return context.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`, i);
16975
16643
  } else if (typeof label === "number" && Math.floor(label) !== label) {
16976
- return labelContext.error(`Numeric branch labels must be integer values.`);
16644
+ return context.error(`Numeric branch labels must be integer values.`, i);
16977
16645
  } else if (!inputType) {
16978
16646
  inputType = typeOf(label);
16979
- } else if (labelContext.checkSubtype(inputType, typeOf(label))) {
16647
+ } else if (context.checkSubtype(inputType, typeOf(label), i)) {
16980
16648
  return null;
16981
16649
  }
16982
16650
  if (typeof cases[String(label)] !== "undefined") {
16983
- return labelContext.error("Branch labels must be unique.");
16651
+ return context.error("Branch labels must be unique.", i);
16984
16652
  }
16985
16653
  cases[String(label)] = outputs.length;
16986
16654
  }
@@ -16993,7 +16661,7 @@
16993
16661
  if (!input) return null;
16994
16662
  const otherwise = context.parse(args.at(-1), args.length - 1, outputType);
16995
16663
  if (!otherwise) return null;
16996
- if (input.type.kind !== "value" && context.concat(1).checkSubtype(inputType, input.type)) {
16664
+ if (input.type.kind !== "value" && context.checkSubtype(inputType, input.type, 1)) {
16997
16665
  return null;
16998
16666
  }
16999
16667
  return new Match(inputType, outputType, input, cases, outputs, otherwise);
@@ -17251,12 +16919,12 @@
17251
16919
  let lhs = context.parse(args[1], 1, ValueType);
17252
16920
  if (!lhs) return null;
17253
16921
  if (!isComparableType(op2, lhs.type)) {
17254
- return context.concat(1).error(`"${op2}" comparisons are not supported for type '${toString$1(lhs.type)}'.`);
16922
+ return context.error(`"${op2}" comparisons are not supported for type '${toString$1(lhs.type)}'.`, 1);
17255
16923
  }
17256
16924
  let rhs = context.parse(args[2], 2, ValueType);
17257
16925
  if (!rhs) return null;
17258
16926
  if (!isComparableType(op2, rhs.type)) {
17259
- return context.concat(2).error(`"${op2}" comparisons are not supported for type '${toString$1(rhs.type)}'.`);
16927
+ return context.error(`"${op2}" comparisons are not supported for type '${toString$1(rhs.type)}'.`, 2);
17260
16928
  }
17261
16929
  if (lhs.type.kind !== rhs.type.kind && lhs.type.kind !== "value" && rhs.type.kind !== "value") {
17262
16930
  return context.error(`Cannot compare types '${toString$1(lhs.type)}' and '${toString$1(rhs.type)}'.`);
@@ -18211,7 +17879,7 @@
18211
17879
  const zoomDependent = zoomAndFeatureDependent || !featureDependent;
18212
17880
  const type = parameters.type || (supportsInterpolation(propertySpec) ? "exponential" : "interval");
18213
17881
  if (isColor) {
18214
- parameters = Object.assign({}, parameters);
17882
+ parameters = { ...parameters };
18215
17883
  if (parameters.stops) {
18216
17884
  parameters.stops = parameters.stops.map((stop) => {
18217
17885
  return [stop[0], Color.parse(stop[1])];
@@ -19870,11 +19538,12 @@ ${JSON.stringify(filterExp, null, 2)}
19870
19538
  value: value.__line__,
19871
19539
  enumerable: false
19872
19540
  });
19873
- let errors = validateObject(Object.assign({}, options, {
19541
+ let errors = validateObject({
19542
+ ...options,
19874
19543
  value: importSpec,
19875
19544
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
19876
19545
  valueSpec: styleSpec.import
19877
- }));
19546
+ });
19878
19547
  if (unbundle(importSpec.id) === "") {
19879
19548
  const key2 = `${options.key}.id`;
19880
19549
  errors.push(new ValidationError(key2, importSpec, `import id can't be an empty string`));
@@ -19895,7 +19564,8 @@ ${JSON.stringify(filterExp, null, 2)}
19895
19564
  const optionValue = options.value;
19896
19565
  const isArrayOption = isObject(optionValue) && unbundle(optionValue.array) === true;
19897
19566
  const declaredType = !isArrayOption && isObject(optionValue) ? unbundle(optionValue.type) : void 0;
19898
- return validateObject(Object.assign({}, options, {
19567
+ return validateObject({
19568
+ ...options,
19899
19569
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
19900
19570
  valueSpec: styleSpec.option,
19901
19571
  objectElementValidators: declaredType ? {
@@ -19903,11 +19573,9 @@ ${JSON.stringify(filterExp, null, 2)}
19903
19573
  // expression (array-form). Primitive defaults keep the previous
19904
19574
  // permissive validation, mirroring the runtime parser's narrowing
19905
19575
  // in style.ts/parser.cpp.
19906
- default: (elementOptions) => Array.isArray(elementOptions.value) ? validate(Object.assign({}, elementOptions, {
19907
- valueSpec: Object.assign({}, elementOptions.valueSpec, { type: declaredType })
19908
- })) : validate(elementOptions)
19576
+ default: (elementOptions) => Array.isArray(elementOptions.value) ? validate({ ...elementOptions, valueSpec: { ...elementOptions.valueSpec, type: declaredType } }) : validate(elementOptions)
19909
19577
  } : void 0
19910
- }));
19578
+ });
19911
19579
  }
19912
19580
 
19913
19581
  function validateArray(options) {
@@ -20296,11 +19964,12 @@ ${JSON.stringify(filterExp, null, 2)}
20296
19964
  function validateFilter(options) {
20297
19965
  if (isExpressionFilter(deepUnbundle(options.value))) {
20298
19966
  const layerType = options.layerType || "fill";
20299
- return validateExpression(Object.assign({}, options, {
19967
+ return validateExpression({
19968
+ ...options,
20300
19969
  expressionContext: "filter",
20301
19970
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
20302
19971
  valueSpec: options.styleSpec[`filter_${layerType}`]
20303
- }));
19972
+ });
20304
19973
  } else {
20305
19974
  return validateNonExpressionFilter(options);
20306
19975
  }
@@ -20497,8 +20166,8 @@ Use an identity property function instead: ${example}.`
20497
20166
  style: options.style,
20498
20167
  styleSpec: options.styleSpec,
20499
20168
  objectElementValidators: {
20500
- condition: (options2) => validateCondition(Object.assign({ layer, layerType }, options2)),
20501
- properties: (options2) => validateProperties(Object.assign({ layer, layerType }, options2))
20169
+ condition: (options2) => validateCondition({ ...options2 }),
20170
+ properties: (options2) => validateProperties({ layer, layerType, ...options2 })
20502
20171
  }
20503
20172
  });
20504
20173
  if (name !== "hidden" && condition === void 0) {
@@ -20518,15 +20187,15 @@ Use an identity property function instead: ${example}.`
20518
20187
  errors.push(new ValidationError(options.key, propertyKey, `unknown property "${propertyKey}" for layer type "${layerType}"`));
20519
20188
  continue;
20520
20189
  }
20521
- const propertyValidationOptions = Object.assign({}, options, {
20190
+ const propertyValidationOptions = {
20191
+ ...options,
20522
20192
  key: `${options.key}.${propertyKey}`,
20523
- object: properties,
20524
20193
  objectKey: propertyKey,
20525
20194
  layer,
20526
20195
  layerType,
20527
20196
  value: properties[propertyKey],
20528
20197
  valueSpec: propertyType === "paint" ? paintProperties[propertyKey] : layoutProperties[propertyKey]
20529
- });
20198
+ };
20530
20199
  errors.push(...validateProperty(propertyValidationOptions, propertyType));
20531
20200
  }
20532
20201
  return errors;
@@ -20648,7 +20317,7 @@ Use an identity property function instead: ${example}.`
20648
20317
  });
20649
20318
  },
20650
20319
  filter(options2) {
20651
- return validateFilter(Object.assign({ layerType: type }, options2));
20320
+ return validateFilter({ layerType: type, ...options2 });
20652
20321
  },
20653
20322
  layout(options2) {
20654
20323
  return validateObject({
@@ -20660,7 +20329,7 @@ Use an identity property function instead: ${example}.`
20660
20329
  styleSpec: options2.styleSpec,
20661
20330
  objectElementValidators: {
20662
20331
  "*"(options3) {
20663
- return validateLayoutProperty(Object.assign({ layerType: type }, options3));
20332
+ return validateLayoutProperty({ layerType: type, ...options3 });
20664
20333
  }
20665
20334
  }
20666
20335
  });
@@ -20675,7 +20344,7 @@ Use an identity property function instead: ${example}.`
20675
20344
  styleSpec: options2.styleSpec,
20676
20345
  objectElementValidators: {
20677
20346
  "*"(options3) {
20678
- return validatePaintProperty(Object.assign({ layerType: type, layer }, options3));
20347
+ return validatePaintProperty({ layerType: type, layer, ...options3 });
20679
20348
  }
20680
20349
  }
20681
20350
  });
@@ -20687,7 +20356,7 @@ Use an identity property function instead: ${example}.`
20687
20356
  valueSpec: options2.valueSpec,
20688
20357
  style: options2.style,
20689
20358
  styleSpec: options2.styleSpec,
20690
- arrayElementValidator: (options3) => validateAppearance(Object.assign({ layerType: type, layer }, options3))
20359
+ arrayElementValidator: (options3) => validateAppearance({ layerType: type, layer, ...options3 })
20691
20360
  });
20692
20361
  const appearances = Array.isArray(options2.value) ? options2.value : [];
20693
20362
  const dedupedNames = /* @__PURE__ */ new Set();
@@ -21249,10 +20918,11 @@ Use an identity property function instead: ${example}.`
21249
20918
  }
21250
20919
  return errors2;
21251
20920
  }
21252
- const errors = validateObject(Object.assign({}, options, {
20921
+ const errors = validateObject({
20922
+ ...options,
21253
20923
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
21254
20924
  valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec
21255
- }));
20925
+ });
21256
20926
  return errors;
21257
20927
  }
21258
20928
 
@@ -21328,12 +20998,11 @@ Use an identity property function instead: ${example}.`
21328
20998
  key: options.key || "",
21329
20999
  value: style,
21330
21000
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
21331
- valueSpec: Object.assign(
21332
- {},
21333
- styleSpec.$root,
21001
+ valueSpec: {
21002
+ ...styleSpec.$root,
21334
21003
  // Skip validation of the root properties that are not defined in the style spec (e.g. 'owner').
21335
- { "*": { type: "*" } }
21336
- ),
21004
+ "*": { type: "*" }
21005
+ },
21337
21006
  styleSpec,
21338
21007
  style,
21339
21008
  objectElementValidators: {