@mapbox/mapbox-gl-style-spec 14.25.0 → 14.26.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1294,6 +1294,24 @@ var modelNodeOverride = {
1294
1294
  doc: "Override the orientation of the model node in euler angles [x, y, z]."
1295
1295
  }
1296
1296
  };
1297
+ var modelLightOverrides = {
1298
+ "light-ambient-color": {
1299
+ type: "color",
1300
+ doc: "Override the color of ambient lights."
1301
+ },
1302
+ "light-ambient-intensity": {
1303
+ type: "number",
1304
+ doc: "Override the intensity of light-ambient-color (on a scale from 0 to 1)."
1305
+ },
1306
+ "light-directional-color": {
1307
+ type: "color",
1308
+ doc: "Override the color of directional lights."
1309
+ },
1310
+ "light-directional-intensity": {
1311
+ type: "number",
1312
+ doc: "Override the intensity of light-directional-color (on a scale from 0 to 1)."
1313
+ }
1314
+ };
1297
1315
  var modelNodeOverrides = {
1298
1316
  "*": {
1299
1317
  type: "modelNodeOverride",
@@ -1364,6 +1382,11 @@ var modelSourceModel = {
1364
1382
  units: "degrees",
1365
1383
  doc: "Orientation of the model in euler angles [x, y, z]."
1366
1384
  },
1385
+ lightOverrides: {
1386
+ type: "modelLightOverrides",
1387
+ required: false,
1388
+ doc: "A collection of light overrides."
1389
+ },
1367
1390
  nodeOverrides: {
1368
1391
  type: "modelNodeOverrides",
1369
1392
  required: false,
@@ -6521,13 +6544,6 @@ var camera = {
6521
6544
  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."
6522
6545
  }
6523
6546
  },
6524
- transition: true,
6525
- expression: {
6526
- interpolated: true,
6527
- parameters: [
6528
- "zoom"
6529
- ]
6530
- },
6531
6547
  "sdk-support": {
6532
6548
  "basic functionality": {
6533
6549
  js: "3.0.0",
@@ -10936,6 +10952,7 @@ var v8 = {
10936
10952
  source_video: source_video,
10937
10953
  source_image: source_image,
10938
10954
  modelNodeOverride: modelNodeOverride,
10955
+ modelLightOverrides: modelLightOverrides,
10939
10956
  modelNodeOverrides: modelNodeOverrides,
10940
10957
  modelMaterialOverride: modelMaterialOverride,
10941
10958
  modelMaterialOverrides: modelMaterialOverrides,
@@ -13980,7 +13997,7 @@ class CompoundExpression {
13980
13997
  overloadParams.push(params);
13981
13998
  overloadIndex++;
13982
13999
  if (signatureContext === null) {
13983
- signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, [], context._scope, context.options, context.iconImageUseTheme);
14000
+ signatureContext = context._forkForSignature();
13984
14001
  } else {
13985
14002
  signatureContext.errors.length = 0;
13986
14003
  }
@@ -14743,485 +14760,6 @@ class Within {
14743
14760
  }
14744
14761
  }
14745
14762
 
14746
- const factors = {
14747
- kilometers: 1,
14748
- miles: 1000 / 1609.344,
14749
- nauticalmiles: 1000 / 1852,
14750
- meters: 1000,
14751
- metres: 1000,
14752
- yards: 1000 / 0.9144,
14753
- feet: 1000 / 0.3048,
14754
- inches: 1000 / 0.0254
14755
- };
14756
-
14757
- // Values that define WGS84 ellipsoid model of the Earth
14758
- const RE = 6378.137; // equatorial radius
14759
- const FE = 1 / 298.257223563; // flattening
14760
-
14761
- const E2 = FE * (2 - FE);
14762
- const RAD = Math.PI / 180;
14763
-
14764
- /**
14765
- * A collection of very fast approximations to common geodesic measurements. Useful for performance-sensitive code that measures things on a city scale.
14766
- */
14767
- class CheapRuler {
14768
- /**
14769
- * Creates a ruler object from tile coordinates (y and z).
14770
- *
14771
- * @param {number} y
14772
- * @param {number} z
14773
- * @param {keyof typeof factors} [units='kilometers']
14774
- * @returns {CheapRuler}
14775
- * @example
14776
- * const ruler = cheapRuler.fromTile(1567, 12);
14777
- * //=ruler
14778
- */
14779
- static fromTile(y, z, units) {
14780
- const n = Math.PI * (1 - 2 * (y + 0.5) / Math.pow(2, z));
14781
- const lat = Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))) / RAD;
14782
- return new CheapRuler(lat, units);
14783
- }
14784
-
14785
- /**
14786
- * Multipliers for converting between units.
14787
- *
14788
- * @example
14789
- * // convert 50 meters to yards
14790
- * 50 * CheapRuler.units.yards / CheapRuler.units.meters;
14791
- */
14792
- static get units() {
14793
- return factors;
14794
- }
14795
-
14796
- /**
14797
- * Creates a ruler instance for very fast approximations to common geodesic measurements around a certain latitude.
14798
- *
14799
- * @param {number} lat latitude
14800
- * @param {keyof typeof factors} [units='kilometers']
14801
- * @example
14802
- * const ruler = cheapRuler(35.05, 'miles');
14803
- * //=ruler
14804
- */
14805
- constructor(lat, units) {
14806
- if (lat === undefined) throw new Error('No latitude given.');
14807
- if (units && !factors[units]) throw new Error(`Unknown unit ${ units }. Use one of: ${ Object.keys(factors).join(', ')}`);
14808
-
14809
- // Curvature formulas from https://en.wikipedia.org/wiki/Earth_radius#Meridional
14810
- const m = RAD * RE * (units ? factors[units] : 1);
14811
- const coslat = Math.cos(lat * RAD);
14812
- const w2 = 1 / (1 - E2 * (1 - coslat * coslat));
14813
- const w = Math.sqrt(w2);
14814
-
14815
- // multipliers for converting longitude and latitude degrees into distance
14816
- this.kx = m * w * coslat; // based on normal radius of curvature
14817
- this.ky = m * w * w2 * (1 - E2); // based on meridonal radius of curvature
14818
- }
14819
-
14820
- /**
14821
- * Given two points of the form [longitude, latitude], returns the distance.
14822
- *
14823
- * @param {[number, number]} a point [longitude, latitude]
14824
- * @param {[number, number]} b point [longitude, latitude]
14825
- * @returns {number} distance
14826
- * @example
14827
- * const distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);
14828
- * //=distance
14829
- */
14830
- distance(a, b) {
14831
- const dx = wrap(a[0] - b[0]) * this.kx;
14832
- const dy = (a[1] - b[1]) * this.ky;
14833
- return Math.sqrt(dx * dx + dy * dy);
14834
- }
14835
-
14836
- /**
14837
- * Returns the bearing between two points in angles.
14838
- *
14839
- * @param {[number, number]} a point [longitude, latitude]
14840
- * @param {[number, number]} b point [longitude, latitude]
14841
- * @returns {number} bearing
14842
- * @example
14843
- * const bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]);
14844
- * //=bearing
14845
- */
14846
- bearing(a, b) {
14847
- const dx = wrap(b[0] - a[0]) * this.kx;
14848
- const dy = (b[1] - a[1]) * this.ky;
14849
- return Math.atan2(dx, dy) / RAD;
14850
- }
14851
-
14852
- /**
14853
- * Returns a new point given distance and bearing from the starting point.
14854
- *
14855
- * @param {[number, number]} p point [longitude, latitude]
14856
- * @param {number} dist distance
14857
- * @param {number} bearing
14858
- * @returns {[number, number]} point [longitude, latitude]
14859
- * @example
14860
- * const point = ruler.destination([30.5, 50.5], 0.1, 90);
14861
- * //=point
14862
- */
14863
- destination(p, dist, bearing) {
14864
- const a = bearing * RAD;
14865
- return this.offset(p,
14866
- Math.sin(a) * dist,
14867
- Math.cos(a) * dist);
14868
- }
14869
-
14870
- /**
14871
- * Returns a new point given easting and northing offsets (in ruler units) from the starting point.
14872
- *
14873
- * @param {[number, number]} p point [longitude, latitude]
14874
- * @param {number} dx easting
14875
- * @param {number} dy northing
14876
- * @returns {[number, number]} point [longitude, latitude]
14877
- * @example
14878
- * const point = ruler.offset([30.5, 50.5], 10, 10);
14879
- * //=point
14880
- */
14881
- offset(p, dx, dy) {
14882
- return [
14883
- p[0] + dx / this.kx,
14884
- p[1] + dy / this.ky
14885
- ];
14886
- }
14887
-
14888
- /**
14889
- * Given a line (an array of points), returns the total line distance.
14890
- *
14891
- * @param {[number, number][]} points [longitude, latitude]
14892
- * @returns {number} total line distance
14893
- * @example
14894
- * const length = ruler.lineDistance([
14895
- * [-67.031, 50.458], [-67.031, 50.534],
14896
- * [-66.929, 50.534], [-66.929, 50.458]
14897
- * ]);
14898
- * //=length
14899
- */
14900
- lineDistance(points) {
14901
- let total = 0;
14902
- for (let i = 0; i < points.length - 1; i++) {
14903
- total += this.distance(points[i], points[i + 1]);
14904
- }
14905
- return total;
14906
- }
14907
-
14908
- /**
14909
- * Given a polygon (an array of rings, where each ring is an array of points), returns the area.
14910
- *
14911
- * @param {[number, number][][]} polygon
14912
- * @returns {number} area value in the specified units (square kilometers by default)
14913
- * @example
14914
- * const area = ruler.area([[
14915
- * [-67.031, 50.458], [-67.031, 50.534], [-66.929, 50.534],
14916
- * [-66.929, 50.458], [-67.031, 50.458]
14917
- * ]]);
14918
- * //=area
14919
- */
14920
- area(polygon) {
14921
- let sum = 0;
14922
-
14923
- for (let i = 0; i < polygon.length; i++) {
14924
- const ring = polygon[i];
14925
-
14926
- for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
14927
- sum += wrap(ring[j][0] - ring[k][0]) * (ring[j][1] + ring[k][1]) * (i ? -1 : 1);
14928
- }
14929
- }
14930
-
14931
- return (Math.abs(sum) / 2) * this.kx * this.ky;
14932
- }
14933
-
14934
- /**
14935
- * Returns the point at a specified distance along the line.
14936
- *
14937
- * @param {[number, number][]} line
14938
- * @param {number} dist distance
14939
- * @returns {[number, number]} point [longitude, latitude]
14940
- * @example
14941
- * const point = ruler.along(line, 2.5);
14942
- * //=point
14943
- */
14944
- along(line, dist) {
14945
- let sum = 0;
14946
-
14947
- if (dist <= 0) return line[0];
14948
-
14949
- for (let i = 0; i < line.length - 1; i++) {
14950
- const p0 = line[i];
14951
- const p1 = line[i + 1];
14952
- const d = this.distance(p0, p1);
14953
- sum += d;
14954
- if (sum > dist) return interpolate$1(p0, p1, (dist - (sum - d)) / d);
14955
- }
14956
-
14957
- return line[line.length - 1];
14958
- }
14959
-
14960
- /**
14961
- * Returns the distance from a point `p` to a line segment `a` to `b`.
14962
- *
14963
- * @pointToSegmentDistance
14964
- * @param {[number, number]} p point [longitude, latitude]
14965
- * @param {[number, number]} a segment point 1 [longitude, latitude]
14966
- * @param {[number, number]} b segment point 2 [longitude, latitude]
14967
- * @returns {number} distance
14968
- * @example
14969
- * const distance = ruler.pointToSegmentDistance([-67.04, 50.5], [-67.05, 50.57], [-67.03, 50.54]);
14970
- * //=distance
14971
- */
14972
- pointToSegmentDistance(p, a, b) {
14973
- let [x, y] = a;
14974
- let dx = wrap(b[0] - x) * this.kx;
14975
- let dy = (b[1] - y) * this.ky;
14976
-
14977
- if (dx !== 0 || dy !== 0) {
14978
- const t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
14979
-
14980
- if (t > 1) {
14981
- x = b[0];
14982
- y = b[1];
14983
-
14984
- } else if (t > 0) {
14985
- x += (dx / this.kx) * t;
14986
- y += (dy / this.ky) * t;
14987
- }
14988
- }
14989
-
14990
- dx = wrap(p[0] - x) * this.kx;
14991
- dy = (p[1] - y) * this.ky;
14992
-
14993
- return Math.sqrt(dx * dx + dy * dy);
14994
- }
14995
-
14996
- /**
14997
- * Returns an object of the form {point, index, t}, where point is closest point on the line
14998
- * from the given point, index is the start index of the segment with the closest point,
14999
- * and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
15000
- *
15001
- * @param {[number, number][]} line
15002
- * @param {[number, number]} p point [longitude, latitude]
15003
- * @returns {{point: [number, number], index: number, t: number}} {point, index, t}
15004
- * @example
15005
- * const point = ruler.pointOnLine(line, [-67.04, 50.5]).point;
15006
- * //=point
15007
- */
15008
- pointOnLine(line, p) {
15009
- let minDist = Infinity;
15010
- let minX = line[0][0];
15011
- let minY = line[0][1];
15012
- let minI = 0;
15013
- let minT = 0;
15014
-
15015
- for (let i = 0; i < line.length - 1; i++) {
15016
-
15017
- let x = line[i][0];
15018
- let y = line[i][1];
15019
- let dx = wrap(line[i + 1][0] - x) * this.kx;
15020
- let dy = (line[i + 1][1] - y) * this.ky;
15021
- let t = 0;
15022
-
15023
- if (dx !== 0 || dy !== 0) {
15024
- t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
15025
-
15026
- if (t > 1) {
15027
- x = line[i + 1][0];
15028
- y = line[i + 1][1];
15029
-
15030
- } else if (t > 0) {
15031
- x += (dx / this.kx) * t;
15032
- y += (dy / this.ky) * t;
15033
- }
15034
- }
15035
-
15036
- dx = wrap(p[0] - x) * this.kx;
15037
- dy = (p[1] - y) * this.ky;
15038
-
15039
- const sqDist = dx * dx + dy * dy;
15040
- if (sqDist < minDist) {
15041
- minDist = sqDist;
15042
- minX = x;
15043
- minY = y;
15044
- minI = i;
15045
- minT = t;
15046
- }
15047
- }
15048
-
15049
- return {
15050
- point: [minX, minY],
15051
- index: minI,
15052
- t: Math.max(0, Math.min(1, minT))
15053
- };
15054
- }
15055
-
15056
- /**
15057
- * Returns a part of the given line between the start and the stop points (or their closest points on the line).
15058
- *
15059
- * @param {[number, number]} start point [longitude, latitude]
15060
- * @param {[number, number]} stop point [longitude, latitude]
15061
- * @param {[number, number][]} line
15062
- * @returns {[number, number][]} line part of a line
15063
- * @example
15064
- * const line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1);
15065
- * //=line2
15066
- */
15067
- lineSlice(start, stop, line) {
15068
- let p1 = this.pointOnLine(line, start);
15069
- let p2 = this.pointOnLine(line, stop);
15070
-
15071
- if (p1.index > p2.index || (p1.index === p2.index && p1.t > p2.t)) {
15072
- const tmp = p1;
15073
- p1 = p2;
15074
- p2 = tmp;
15075
- }
15076
-
15077
- const slice = [p1.point];
15078
-
15079
- const l = p1.index + 1;
15080
- const r = p2.index;
15081
-
15082
- if (!equals(line[l], slice[0]) && l <= r)
15083
- slice.push(line[l]);
15084
-
15085
- for (let i = l + 1; i <= r; i++) {
15086
- slice.push(line[i]);
15087
- }
15088
-
15089
- if (!equals(line[r], p2.point))
15090
- slice.push(p2.point);
15091
-
15092
- return slice;
15093
- }
15094
-
15095
- /**
15096
- * Returns a part of the given line between the start and the stop points indicated by distance along the line.
15097
- *
15098
- * @param {number} start start distance
15099
- * @param {number} stop stop distance
15100
- * @param {[number, number][]} line
15101
- * @returns {[number, number][]} part of a line
15102
- * @example
15103
- * const line2 = ruler.lineSliceAlong(10, 20, line1);
15104
- * //=line2
15105
- */
15106
- lineSliceAlong(start, stop, line) {
15107
- let sum = 0;
15108
- const slice = [];
15109
-
15110
- for (let i = 0; i < line.length - 1; i++) {
15111
- const p0 = line[i];
15112
- const p1 = line[i + 1];
15113
- const d = this.distance(p0, p1);
15114
-
15115
- sum += d;
15116
-
15117
- if (sum > start && slice.length === 0) {
15118
- slice.push(interpolate$1(p0, p1, (start - (sum - d)) / d));
15119
- }
15120
-
15121
- if (sum >= stop) {
15122
- slice.push(interpolate$1(p0, p1, (stop - (sum - d)) / d));
15123
- return slice;
15124
- }
15125
-
15126
- if (sum > start) slice.push(p1);
15127
- }
15128
-
15129
- return slice;
15130
- }
15131
-
15132
- /**
15133
- * Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance.
15134
- *
15135
- * @param {[number, number]} p point [longitude, latitude]
15136
- * @param {number} buffer
15137
- * @returns {[number, number, number, number]} bbox ([w, s, e, n])
15138
- * @example
15139
- * const bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
15140
- * //=bbox
15141
- */
15142
- bufferPoint(p, buffer) {
15143
- const v = buffer / this.ky;
15144
- const h = buffer / this.kx;
15145
- return [
15146
- p[0] - h,
15147
- p[1] - v,
15148
- p[0] + h,
15149
- p[1] + v
15150
- ];
15151
- }
15152
-
15153
- /**
15154
- * Given a bounding box, returns the box buffered by a given distance.
15155
- *
15156
- * @param {[number, number, number, number]} bbox ([w, s, e, n])
15157
- * @param {number} buffer
15158
- * @returns {[number, number, number, number]} bbox ([w, s, e, n])
15159
- * @example
15160
- * const bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2);
15161
- * //=bbox
15162
- */
15163
- bufferBBox(bbox, buffer) {
15164
- const v = buffer / this.ky;
15165
- const h = buffer / this.kx;
15166
- return [
15167
- bbox[0] - h,
15168
- bbox[1] - v,
15169
- bbox[2] + h,
15170
- bbox[3] + v
15171
- ];
15172
- }
15173
-
15174
- /**
15175
- * Returns true if the given point is inside in the given bounding box, otherwise false.
15176
- *
15177
- * @param {[number, number]} p point [longitude, latitude]
15178
- * @param {[number, number, number, number]} bbox ([w, s, e, n])
15179
- * @returns {boolean}
15180
- * @example
15181
- * const inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
15182
- * //=inside
15183
- */
15184
- insideBBox(p, bbox) { // eslint-disable-line
15185
- return wrap(p[0] - bbox[0]) >= 0 &&
15186
- wrap(p[0] - bbox[2]) <= 0 &&
15187
- p[1] >= bbox[1] &&
15188
- p[1] <= bbox[3];
15189
- }
15190
- }
15191
-
15192
- /**
15193
- * @param {[number, number]} a
15194
- * @param {[number, number]} b
15195
- */
15196
- function equals(a, b) {
15197
- return a[0] === b[0] && a[1] === b[1];
15198
- }
15199
-
15200
- /**
15201
- * @param {[number, number]} a
15202
- * @param {[number, number]} b
15203
- * @param {number} t
15204
- * @returns {[number, number]}
15205
- */
15206
- function interpolate$1(a, b, t) {
15207
- const dx = wrap(b[0] - a[0]);
15208
- const dy = b[1] - a[1];
15209
- return [
15210
- a[0] + dx * t,
15211
- a[1] + dy * t
15212
- ];
15213
- }
15214
-
15215
- /**
15216
- * normalize a degree value into [-180..180] range
15217
- * @param {number} deg
15218
- */
15219
- function wrap(deg) {
15220
- while (deg < -180) deg += 360;
15221
- while (deg > 180) deg -= 360;
15222
- return deg;
15223
- }
15224
-
15225
14763
  class TinyQueue {
15226
14764
  constructor(data = [], compare = (a, b) => (a < b ? -1 : a > b ? 1 : 0)) {
15227
14765
  this.data = data;
@@ -15295,6 +14833,77 @@ class TinyQueue {
15295
14833
 
15296
14834
  var EXTENT = 8192;
15297
14835
 
14836
+ const RE = 6378.137;
14837
+ const FE = 1 / 298.257223563;
14838
+ const E2 = FE * (2 - FE);
14839
+ const RAD = Math.PI / 180;
14840
+ function lngLatScale(lat) {
14841
+ const m = RAD * RE * 1e3;
14842
+ const coslat = Math.cos(lat * RAD);
14843
+ const w2 = 1 / (1 - E2 * (1 - coslat * coslat));
14844
+ const w = Math.sqrt(w2);
14845
+ return [m * w * coslat, m * w * w2 * (1 - E2)];
14846
+ }
14847
+ function wrapLng(deg) {
14848
+ while (deg < -180) deg += 360;
14849
+ while (deg > 180) deg -= 360;
14850
+ return deg;
14851
+ }
14852
+ function rulerDistance(a, b, kx, ky) {
14853
+ const dx = wrapLng(a[0] - b[0]) * kx;
14854
+ const dy = (a[1] - b[1]) * ky;
14855
+ return Math.sqrt(dx * dx + dy * dy);
14856
+ }
14857
+ function rulerPointToSegmentDistance(p, a, b, kx, ky) {
14858
+ let x = a[0];
14859
+ let y = a[1];
14860
+ let dx = wrapLng(b[0] - x) * kx;
14861
+ let dy = (b[1] - y) * ky;
14862
+ if (dx !== 0 || dy !== 0) {
14863
+ const t = (wrapLng(p[0] - x) * kx * dx + (p[1] - y) * ky * dy) / (dx * dx + dy * dy);
14864
+ if (t > 1) {
14865
+ x = b[0];
14866
+ y = b[1];
14867
+ } else if (t > 0) {
14868
+ x += dx / kx * t;
14869
+ y += dy / ky * t;
14870
+ }
14871
+ }
14872
+ dx = wrapLng(p[0] - x) * kx;
14873
+ dy = (p[1] - y) * ky;
14874
+ return Math.sqrt(dx * dx + dy * dy);
14875
+ }
14876
+ function rulerPointOnLine(line, p, kx, ky) {
14877
+ let minDist = Infinity;
14878
+ let minX = line[0][0];
14879
+ let minY = line[0][1];
14880
+ for (let i = 0; i < line.length - 1; i++) {
14881
+ let x = line[i][0];
14882
+ let y = line[i][1];
14883
+ let dx = wrapLng(line[i + 1][0] - x) * kx;
14884
+ let dy = (line[i + 1][1] - y) * ky;
14885
+ let t = 0;
14886
+ if (dx !== 0 || dy !== 0) {
14887
+ t = (wrapLng(p[0] - x) * kx * dx + (p[1] - y) * ky * dy) / (dx * dx + dy * dy);
14888
+ if (t > 1) {
14889
+ x = line[i + 1][0];
14890
+ y = line[i + 1][1];
14891
+ } else if (t > 0) {
14892
+ x += dx / kx * t;
14893
+ y += dy / ky * t;
14894
+ }
14895
+ }
14896
+ dx = wrapLng(p[0] - x) * kx;
14897
+ dy = (p[1] - y) * ky;
14898
+ const sqDist = dx * dx + dy * dy;
14899
+ if (sqDist < minDist) {
14900
+ minDist = sqDist;
14901
+ minX = x;
14902
+ minY = y;
14903
+ }
14904
+ }
14905
+ return [minX, minY];
14906
+ }
15298
14907
  function compareMax(a, b) {
15299
14908
  return b.dist - a.dist;
15300
14909
  }
@@ -15360,7 +14969,7 @@ function getPolygonBBox(polygon) {
15360
14969
  }
15361
14970
  return bbox;
15362
14971
  }
15363
- function bboxToBBoxDistance(bbox1, bbox2, ruler) {
14972
+ function bboxToBBoxDistance(bbox1, bbox2, kx, ky) {
15364
14973
  if (isDefaultBBOX(bbox1) || isDefaultBBOX(bbox2)) {
15365
14974
  return NaN;
15366
14975
  }
@@ -15378,7 +14987,7 @@ function bboxToBBoxDistance(bbox1, bbox2, ruler) {
15378
14987
  if (bbox1[3] < bbox2[1]) {
15379
14988
  dy = bbox2[1] - bbox1[3];
15380
14989
  }
15381
- return ruler.distance([0, 0], [dx, dy]);
14990
+ return rulerDistance([0, 0], [dx, dy], kx, ky);
15382
14991
  }
15383
14992
  function getLngLatPoint(coord, canonical, extent = EXTENT) {
15384
14993
  const tilesAtZoom = Math.pow(2, canonical.z);
@@ -15393,30 +15002,30 @@ function getLngLatPoints(coordinates, canonical) {
15393
15002
  }
15394
15003
  return coords;
15395
15004
  }
15396
- function pointToLineDistance(point, line, ruler) {
15397
- const nearestPoint = ruler.pointOnLine(line, point).point;
15398
- return ruler.distance(point, nearestPoint);
15005
+ function pointToLineDistance(point, line, kx, ky) {
15006
+ const nearestPoint = rulerPointOnLine(line, point, kx, ky);
15007
+ return rulerDistance(point, nearestPoint, kx, ky);
15399
15008
  }
15400
- function pointsToLineDistance(points, rangeA, line, rangeB, ruler) {
15009
+ function pointsToLineDistance(points, rangeA, line, rangeB, kx, ky) {
15401
15010
  const subLine = line.slice(rangeB[0], rangeB[1] + 1);
15402
15011
  let dist = Infinity;
15403
15012
  for (let i = rangeA[0]; i <= rangeA[1]; ++i) {
15404
- if ((dist = Math.min(dist, pointToLineDistance(points[i], subLine, ruler))) === 0) return 0;
15013
+ if ((dist = Math.min(dist, pointToLineDistance(points[i], subLine, kx, ky))) === 0) return 0;
15405
15014
  }
15406
15015
  return dist;
15407
15016
  }
15408
- function segmentToSegmentDistance(p1, p2, q1, q2, ruler) {
15017
+ function segmentToSegmentDistance(p1, p2, q1, q2, kx, ky) {
15409
15018
  const dist1 = Math.min(
15410
- ruler.pointToSegmentDistance(p1, q1, q2),
15411
- ruler.pointToSegmentDistance(p2, q1, q2)
15019
+ rulerPointToSegmentDistance(p1, q1, q2, kx, ky),
15020
+ rulerPointToSegmentDistance(p2, q1, q2, kx, ky)
15412
15021
  );
15413
15022
  const dist2 = Math.min(
15414
- ruler.pointToSegmentDistance(q1, p1, p2),
15415
- ruler.pointToSegmentDistance(q2, p1, p2)
15023
+ rulerPointToSegmentDistance(q1, p1, p2, kx, ky),
15024
+ rulerPointToSegmentDistance(q2, p1, p2, kx, ky)
15416
15025
  );
15417
15026
  return Math.min(dist1, dist2);
15418
15027
  }
15419
- function lineToLineDistance(line1, range1, line2, range2, ruler) {
15028
+ function lineToLineDistance(line1, range1, line2, range2, kx, ky) {
15420
15029
  if (!isRangeSafe(range1, line1.length) || !isRangeSafe(range2, line2.length)) {
15421
15030
  return NaN;
15422
15031
  }
@@ -15424,24 +15033,24 @@ function lineToLineDistance(line1, range1, line2, range2, ruler) {
15424
15033
  for (let i = range1[0]; i < range1[1]; ++i) {
15425
15034
  for (let j = range2[0]; j < range2[1]; ++j) {
15426
15035
  if (segmentIntersectSegment(line1[i], line1[i + 1], line2[j], line2[j + 1])) return 0;
15427
- dist = Math.min(dist, segmentToSegmentDistance(line1[i], line1[i + 1], line2[j], line2[j + 1], ruler));
15036
+ dist = Math.min(dist, segmentToSegmentDistance(line1[i], line1[i + 1], line2[j], line2[j + 1], kx, ky));
15428
15037
  }
15429
15038
  }
15430
15039
  return dist;
15431
15040
  }
15432
- function pointsToPointsDistance(pointSet1, range1, pointSet2, range2, ruler) {
15041
+ function pointsToPointsDistance(pointSet1, range1, pointSet2, range2, kx, ky) {
15433
15042
  if (!isRangeSafe(range1, pointSet1.length) || !isRangeSafe(range2, pointSet2.length)) {
15434
15043
  return NaN;
15435
15044
  }
15436
15045
  let dist = Infinity;
15437
15046
  for (let i = range1[0]; i <= range1[1]; ++i) {
15438
15047
  for (let j = range2[0]; j <= range2[1]; ++j) {
15439
- if ((dist = Math.min(dist, ruler.distance(pointSet1[i], pointSet2[j]))) === 0) return dist;
15048
+ if ((dist = Math.min(dist, rulerDistance(pointSet1[i], pointSet2[j], kx, ky))) === 0) return dist;
15440
15049
  }
15441
15050
  }
15442
15051
  return dist;
15443
15052
  }
15444
- function pointToPolygonDistance(point, polygon, ruler) {
15053
+ function pointToPolygonDistance(point, polygon, kx, ky) {
15445
15054
  if (pointWithinPolygon(
15446
15055
  point,
15447
15056
  polygon,
@@ -15456,13 +15065,13 @@ function pointToPolygonDistance(point, polygon, ruler) {
15456
15065
  return NaN;
15457
15066
  }
15458
15067
  if (ring[0] !== ring[ringLen - 1]) {
15459
- if ((dist = Math.min(dist, ruler.pointToSegmentDistance(point, ring[ringLen - 1], ring[0]))) === 0) return dist;
15068
+ if ((dist = Math.min(dist, rulerPointToSegmentDistance(point, ring[ringLen - 1], ring[0], kx, ky))) === 0) return dist;
15460
15069
  }
15461
- if ((dist = Math.min(dist, pointToLineDistance(point, ring, ruler))) === 0) return dist;
15070
+ if ((dist = Math.min(dist, pointToLineDistance(point, ring, kx, ky))) === 0) return dist;
15462
15071
  }
15463
15072
  return dist;
15464
15073
  }
15465
- function lineToPolygonDistance(line, range, polygon, ruler) {
15074
+ function lineToPolygonDistance(line, range, polygon, kx, ky) {
15466
15075
  if (!isRangeSafe(range, line.length)) {
15467
15076
  return NaN;
15468
15077
  }
@@ -15479,7 +15088,7 @@ function lineToPolygonDistance(line, range, polygon, ruler) {
15479
15088
  for (const ring of polygon) {
15480
15089
  for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
15481
15090
  if (segmentIntersectSegment(line[i], line[i + 1], ring[k], ring[j])) return 0;
15482
- dist = Math.min(dist, segmentToSegmentDistance(line[i], line[i + 1], ring[k], ring[j], ruler));
15091
+ dist = Math.min(dist, segmentToSegmentDistance(line[i], line[i + 1], ring[k], ring[j], kx, ky));
15483
15092
  }
15484
15093
  }
15485
15094
  }
@@ -15498,10 +15107,10 @@ function polygonIntersect(polygon1, polygon2) {
15498
15107
  }
15499
15108
  return false;
15500
15109
  }
15501
- function polygonToPolygonDistance(polygon1, polygon2, ruler, currentMiniDist = Infinity) {
15110
+ function polygonToPolygonDistance(polygon1, polygon2, kx, ky, currentMiniDist = Infinity) {
15502
15111
  const bbox1 = getPolygonBBox(polygon1);
15503
15112
  const bbox2 = getPolygonBBox(polygon2);
15504
- if (currentMiniDist !== Infinity && bboxToBBoxDistance(bbox1, bbox2, ruler) >= currentMiniDist) {
15113
+ if (currentMiniDist !== Infinity && bboxToBBoxDistance(bbox1, bbox2, kx, ky) >= currentMiniDist) {
15505
15114
  return currentMiniDist;
15506
15115
  }
15507
15116
  if (boxWithinBox(bbox1, bbox2)) {
@@ -15515,20 +15124,20 @@ function polygonToPolygonDistance(polygon1, polygon2, ruler, currentMiniDist = I
15515
15124
  for (const ring2 of polygon2) {
15516
15125
  for (let j = 0, len2 = ring2.length, k = len2 - 1; j < len2; k = j++) {
15517
15126
  if (segmentIntersectSegment(ring1[l], ring1[i], ring2[k], ring2[j])) return 0;
15518
- dist = Math.min(dist, segmentToSegmentDistance(ring1[l], ring1[i], ring2[k], ring2[j], ruler));
15127
+ dist = Math.min(dist, segmentToSegmentDistance(ring1[l], ring1[i], ring2[k], ring2[j], kx, ky));
15519
15128
  }
15520
15129
  }
15521
15130
  }
15522
15131
  }
15523
15132
  return dist;
15524
15133
  }
15525
- function updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, r1, r2) {
15134
+ function updateQueue(distQueue, miniDist, kx, ky, pointSet1, pointSet2, r1, r2) {
15526
15135
  if (r1 === null || r2 === null) return;
15527
- const tempDist = bboxToBBoxDistance(getBBox(pointSet1, r1), getBBox(pointSet2, r2), ruler);
15136
+ const tempDist = bboxToBBoxDistance(getBBox(pointSet1, r1), getBBox(pointSet2, r2), kx, ky);
15528
15137
  if (tempDist < miniDist) distQueue.push({ dist: tempDist, range1: r1, range2: r2 });
15529
15138
  }
15530
- function pointSetToPolygonDistance(pointSets, isLine, polygon, ruler, currentMiniDist = Infinity) {
15531
- let miniDist = Math.min(ruler.distance(pointSets[0], polygon[0][0]), currentMiniDist);
15139
+ function pointSetToPolygonDistance(pointSets, isLine, polygon, kx, ky, currentMiniDist = Infinity) {
15140
+ let miniDist = Math.min(rulerDistance(pointSets[0], polygon[0][0], kx, ky), currentMiniDist);
15532
15141
  if (miniDist === 0) return miniDist;
15533
15142
  const initialDistPair = {
15534
15143
  dist: 0,
@@ -15545,30 +15154,30 @@ function pointSetToPolygonDistance(pointSets, isLine, polygon, ruler, currentMin
15545
15154
  if (getRangeSize(range) <= setThreshold) {
15546
15155
  if (!isRangeSafe(range, pointSets.length)) return NaN;
15547
15156
  if (isLine) {
15548
- const tempDist = lineToPolygonDistance(pointSets, range, polygon, ruler);
15157
+ const tempDist = lineToPolygonDistance(pointSets, range, polygon, kx, ky);
15549
15158
  if ((miniDist = Math.min(miniDist, tempDist)) === 0) return miniDist;
15550
15159
  } else {
15551
15160
  for (let i = range[0]; i <= range[1]; ++i) {
15552
- const tempDist = pointToPolygonDistance(pointSets[i], polygon, ruler);
15161
+ const tempDist = pointToPolygonDistance(pointSets[i], polygon, kx, ky);
15553
15162
  if ((miniDist = Math.min(miniDist, tempDist)) === 0) return miniDist;
15554
15163
  }
15555
15164
  }
15556
15165
  } else {
15557
15166
  const newRanges = splitRange(range, isLine);
15558
15167
  if (newRanges[0] !== null) {
15559
- const tempDist = bboxToBBoxDistance(getBBox(pointSets, newRanges[0]), polyBBox, ruler);
15168
+ const tempDist = bboxToBBoxDistance(getBBox(pointSets, newRanges[0]), polyBBox, kx, ky);
15560
15169
  if (tempDist < miniDist) distQueue.push({ dist: tempDist, range1: newRanges[0], range2: [0, 0] });
15561
15170
  }
15562
15171
  if (newRanges[1] !== null) {
15563
- const tempDist = bboxToBBoxDistance(getBBox(pointSets, newRanges[1]), polyBBox, ruler);
15172
+ const tempDist = bboxToBBoxDistance(getBBox(pointSets, newRanges[1]), polyBBox, kx, ky);
15564
15173
  if (tempDist < miniDist) distQueue.push({ dist: tempDist, range1: newRanges[1], range2: [0, 0] });
15565
15174
  }
15566
15175
  }
15567
15176
  }
15568
15177
  return miniDist;
15569
15178
  }
15570
- function pointSetsDistance(pointSet1, isLine1, pointSet2, isLine2, ruler, currentMiniDist = Infinity) {
15571
- let miniDist = Math.min(currentMiniDist, ruler.distance(pointSet1[0], pointSet2[0]));
15179
+ function pointSetsDistance(pointSet1, isLine1, pointSet2, isLine2, kx, ky, currentMiniDist = Infinity) {
15180
+ let miniDist = Math.min(currentMiniDist, rulerDistance(pointSet1[0], pointSet2[0], kx, ky));
15572
15181
  if (miniDist === 0) return miniDist;
15573
15182
  const initialDistPair = {
15574
15183
  dist: 0,
@@ -15588,52 +15197,52 @@ function pointSetsDistance(pointSet1, isLine1, pointSet2, isLine2, ruler, curren
15588
15197
  return NaN;
15589
15198
  }
15590
15199
  if (isLine1 && isLine2) {
15591
- miniDist = Math.min(miniDist, lineToLineDistance(pointSet1, rangeA, pointSet2, rangeB, ruler));
15200
+ miniDist = Math.min(miniDist, lineToLineDistance(pointSet1, rangeA, pointSet2, rangeB, kx, ky));
15592
15201
  } else if (!isLine1 && !isLine2) {
15593
- miniDist = Math.min(miniDist, pointsToPointsDistance(pointSet1, rangeA, pointSet2, rangeB, ruler));
15202
+ miniDist = Math.min(miniDist, pointsToPointsDistance(pointSet1, rangeA, pointSet2, rangeB, kx, ky));
15594
15203
  } else if (isLine1 && !isLine2) {
15595
- miniDist = Math.min(miniDist, pointsToLineDistance(pointSet2, rangeB, pointSet1, rangeA, ruler));
15204
+ miniDist = Math.min(miniDist, pointsToLineDistance(pointSet2, rangeB, pointSet1, rangeA, kx, ky));
15596
15205
  } else if (!isLine1 && isLine2) {
15597
- miniDist = Math.min(miniDist, pointsToLineDistance(pointSet1, rangeA, pointSet2, rangeB, ruler));
15206
+ miniDist = Math.min(miniDist, pointsToLineDistance(pointSet1, rangeA, pointSet2, rangeB, kx, ky));
15598
15207
  }
15599
15208
  if (miniDist === 0) return miniDist;
15600
15209
  } else {
15601
15210
  const newRangesA = splitRange(rangeA, isLine1);
15602
15211
  const newRangesB = splitRange(rangeB, isLine2);
15603
- updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[0], newRangesB[0]);
15604
- updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[0], newRangesB[1]);
15605
- updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[1], newRangesB[0]);
15606
- updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[1], newRangesB[1]);
15212
+ updateQueue(distQueue, miniDist, kx, ky, pointSet1, pointSet2, newRangesA[0], newRangesB[0]);
15213
+ updateQueue(distQueue, miniDist, kx, ky, pointSet1, pointSet2, newRangesA[0], newRangesB[1]);
15214
+ updateQueue(distQueue, miniDist, kx, ky, pointSet1, pointSet2, newRangesA[1], newRangesB[0]);
15215
+ updateQueue(distQueue, miniDist, kx, ky, pointSet1, pointSet2, newRangesA[1], newRangesB[1]);
15607
15216
  }
15608
15217
  }
15609
15218
  return miniDist;
15610
15219
  }
15611
- function pointSetToLinesDistance(pointSet, isLine, lines, ruler, currentMiniDist = Infinity) {
15220
+ function pointSetToLinesDistance(pointSet, isLine, lines, kx, ky, currentMiniDist = Infinity) {
15612
15221
  let dist = currentMiniDist;
15613
15222
  const bbox1 = getBBox(pointSet, [0, pointSet.length - 1]);
15614
15223
  for (const line of lines) {
15615
- if (dist !== Infinity && bboxToBBoxDistance(bbox1, getBBox(line, [0, line.length - 1]), ruler) >= dist) continue;
15616
- dist = Math.min(dist, pointSetsDistance(pointSet, isLine, line, true, ruler, dist));
15224
+ if (dist !== Infinity && bboxToBBoxDistance(bbox1, getBBox(line, [0, line.length - 1]), kx, ky) >= dist) continue;
15225
+ dist = Math.min(dist, pointSetsDistance(pointSet, isLine, line, true, kx, ky, dist));
15617
15226
  if (dist === 0) return dist;
15618
15227
  }
15619
15228
  return dist;
15620
15229
  }
15621
- function pointSetToPolygonsDistance(points, isLine, polygons, ruler, currentMiniDist = Infinity) {
15230
+ function pointSetToPolygonsDistance(points, isLine, polygons, kx, ky, currentMiniDist = Infinity) {
15622
15231
  let dist = currentMiniDist;
15623
15232
  const bbox1 = getBBox(points, [0, points.length - 1]);
15624
15233
  for (const polygon of polygons) {
15625
- if (dist !== Infinity && bboxToBBoxDistance(bbox1, getPolygonBBox(polygon), ruler) >= dist) continue;
15626
- const tempDist = pointSetToPolygonDistance(points, isLine, polygon, ruler, dist);
15234
+ if (dist !== Infinity && bboxToBBoxDistance(bbox1, getPolygonBBox(polygon), kx, ky) >= dist) continue;
15235
+ const tempDist = pointSetToPolygonDistance(points, isLine, polygon, kx, ky, dist);
15627
15236
  if (isNaN(tempDist)) return tempDist;
15628
15237
  if ((dist = Math.min(dist, tempDist)) === 0) return dist;
15629
15238
  }
15630
15239
  return dist;
15631
15240
  }
15632
- function polygonsToPolygonsDistance(polygons1, polygons2, ruler) {
15241
+ function polygonsToPolygonsDistance(polygons1, polygons2, kx, ky) {
15633
15242
  let dist = Infinity;
15634
15243
  for (const polygon1 of polygons1) {
15635
15244
  for (const polygon2 of polygons2) {
15636
- const tempDist = polygonToPolygonDistance(polygon1, polygon2, ruler, dist);
15245
+ const tempDist = polygonToPolygonDistance(polygon1, polygon2, kx, ky, dist);
15637
15246
  if (isNaN(tempDist)) return tempDist;
15638
15247
  if ((dist = Math.min(dist, tempDist)) === 0) return dist;
15639
15248
  }
@@ -15647,25 +15256,27 @@ function pointsToGeometryDistance(originGeometry, canonical, geometry) {
15647
15256
  lngLatPoints.push(getLngLatPoint(point, canonical));
15648
15257
  }
15649
15258
  }
15650
- const ruler = new CheapRuler(lngLatPoints[0][1], "meters");
15259
+ const [kx, ky] = lngLatScale(lngLatPoints[0][1]);
15651
15260
  if (geometry.type === "Point" || geometry.type === "MultiPoint" || geometry.type === "LineString") {
15652
15261
  return pointSetsDistance(
15653
15262
  lngLatPoints,
15654
15263
  false,
15655
15264
  geometry.type === "Point" ? [geometry.coordinates] : geometry.coordinates,
15656
15265
  geometry.type === "LineString",
15657
- ruler
15266
+ kx,
15267
+ ky
15658
15268
  );
15659
15269
  }
15660
15270
  if (geometry.type === "MultiLineString") {
15661
- return pointSetToLinesDistance(lngLatPoints, false, geometry.coordinates, ruler);
15271
+ return pointSetToLinesDistance(lngLatPoints, false, geometry.coordinates, kx, ky);
15662
15272
  }
15663
15273
  if (geometry.type === "Polygon" || geometry.type === "MultiPolygon") {
15664
15274
  return pointSetToPolygonsDistance(
15665
15275
  lngLatPoints,
15666
15276
  false,
15667
15277
  geometry.type === "Polygon" ? [geometry.coordinates] : geometry.coordinates,
15668
- ruler
15278
+ kx,
15279
+ ky
15669
15280
  );
15670
15281
  }
15671
15282
  return null;
@@ -15679,19 +15290,20 @@ function linesToGeometryDistance(originGeometry, canonical, geometry) {
15679
15290
  }
15680
15291
  lngLatLines.push(lngLatLine);
15681
15292
  }
15682
- const ruler = new CheapRuler(lngLatLines[0][0][1], "meters");
15293
+ const [kx, ky] = lngLatScale(lngLatLines[0][0][1]);
15683
15294
  if (geometry.type === "Point" || geometry.type === "MultiPoint" || geometry.type === "LineString") {
15684
15295
  return pointSetToLinesDistance(
15685
15296
  geometry.type === "Point" ? [geometry.coordinates] : geometry.coordinates,
15686
15297
  geometry.type === "LineString",
15687
15298
  lngLatLines,
15688
- ruler
15299
+ kx,
15300
+ ky
15689
15301
  );
15690
15302
  }
15691
15303
  if (geometry.type === "MultiLineString") {
15692
15304
  let dist = Infinity;
15693
15305
  for (let i = 0; i < geometry.coordinates.length; i++) {
15694
- const tempDist = pointSetToLinesDistance(geometry.coordinates[i], true, lngLatLines, ruler, dist);
15306
+ const tempDist = pointSetToLinesDistance(geometry.coordinates[i], true, lngLatLines, kx, ky, dist);
15695
15307
  if (isNaN(tempDist)) return tempDist;
15696
15308
  if ((dist = Math.min(dist, tempDist)) === 0) return dist;
15697
15309
  }
@@ -15704,7 +15316,8 @@ function linesToGeometryDistance(originGeometry, canonical, geometry) {
15704
15316
  lngLatLines[i],
15705
15317
  true,
15706
15318
  geometry.type === "Polygon" ? [geometry.coordinates] : geometry.coordinates,
15707
- ruler,
15319
+ kx,
15320
+ ky,
15708
15321
  dist
15709
15322
  );
15710
15323
  if (isNaN(tempDist)) return tempDist;
@@ -15723,19 +15336,20 @@ function polygonsToGeometryDistance(originGeometry, canonical, geometry) {
15723
15336
  }
15724
15337
  lngLatPolygons.push(lngLatPolygon);
15725
15338
  }
15726
- const ruler = new CheapRuler(lngLatPolygons[0][0][0][1], "meters");
15339
+ const [kx, ky] = lngLatScale(lngLatPolygons[0][0][0][1]);
15727
15340
  if (geometry.type === "Point" || geometry.type === "MultiPoint" || geometry.type === "LineString") {
15728
15341
  return pointSetToPolygonsDistance(
15729
15342
  geometry.type === "Point" ? [geometry.coordinates] : geometry.coordinates,
15730
15343
  geometry.type === "LineString",
15731
15344
  lngLatPolygons,
15732
- ruler
15345
+ kx,
15346
+ ky
15733
15347
  );
15734
15348
  }
15735
15349
  if (geometry.type === "MultiLineString") {
15736
15350
  let dist = Infinity;
15737
15351
  for (let i = 0; i < geometry.coordinates.length; i++) {
15738
- const tempDist = pointSetToPolygonsDistance(geometry.coordinates[i], true, lngLatPolygons, ruler, dist);
15352
+ const tempDist = pointSetToPolygonsDistance(geometry.coordinates[i], true, lngLatPolygons, kx, ky, dist);
15739
15353
  if (isNaN(tempDist)) return tempDist;
15740
15354
  if ((dist = Math.min(dist, tempDist)) === 0) return dist;
15741
15355
  }
@@ -15745,7 +15359,8 @@ function polygonsToGeometryDistance(originGeometry, canonical, geometry) {
15745
15359
  return polygonsToPolygonsDistance(
15746
15360
  geometry.type === "Polygon" ? [geometry.coordinates] : geometry.coordinates,
15747
15361
  lngLatPolygons,
15748
- ruler
15362
+ kx,
15363
+ ky
15749
15364
  );
15750
15365
  }
15751
15366
  return null;
@@ -15857,18 +15472,21 @@ function isStateConstant(e) {
15857
15472
  });
15858
15473
  return result;
15859
15474
  }
15860
- function isGlobalPropertyConstant(e, properties) {
15861
- if (e instanceof CompoundExpression && properties.includes(e.name)) {
15475
+ function isGlobalPropertyConstantSet(e, properties) {
15476
+ if (e instanceof CompoundExpression && properties.has(e.name)) {
15862
15477
  return false;
15863
15478
  }
15864
15479
  let result = true;
15865
15480
  e.eachChild((arg) => {
15866
- if (result && !isGlobalPropertyConstant(arg, properties)) {
15481
+ if (result && !isGlobalPropertyConstantSet(arg, properties)) {
15867
15482
  result = false;
15868
15483
  }
15869
15484
  });
15870
15485
  return result;
15871
15486
  }
15487
+ function isGlobalPropertyConstant(e, properties) {
15488
+ return isGlobalPropertyConstantSet(e, new Set(properties));
15489
+ }
15872
15490
 
15873
15491
  const FQIDSeparator = "";
15874
15492
  function makeConfigFQID(id, ownScope, contextScope) {
@@ -16035,16 +15653,12 @@ class ParsingContext {
16035
15653
  this.iconImageUseTheme = iconImageUseTheme;
16036
15654
  }
16037
15655
  get key() {
16038
- if (this._key === void 0) {
16039
- const path = this.path;
16040
- let key = "";
16041
- for (let i = 0; i < path.length; i++) {
16042
- const part = path[i];
16043
- key += typeof part === "string" ? `['${part}']` : `[${part}]`;
16044
- }
16045
- this._key = key;
15656
+ let key = "";
15657
+ for (let i = 0; i < this.path.length; i++) {
15658
+ const part = this.path[i];
15659
+ key += typeof part === "string" ? `['${part}']` : `[${part}]`;
16046
15660
  }
16047
- return this._key;
15661
+ return key;
16048
15662
  }
16049
15663
  /**
16050
15664
  * @param expr the JSON expression to parse
@@ -16055,7 +15669,17 @@ class ParsingContext {
16055
15669
  */
16056
15670
  parse(expr, index, expectedType, bindings, options = {}) {
16057
15671
  if (index || expectedType) {
16058
- return this.concat(index, null, expectedType, bindings)._parse(expr, options);
15672
+ const prevExpectedType = this.expectedType;
15673
+ const prevScope = this.scope;
15674
+ if (bindings) this.scope = this.scope.concat(bindings);
15675
+ this.expectedType = expectedType || null;
15676
+ const pushed = typeof index === "number";
15677
+ if (pushed) this.path.push(index);
15678
+ const result = this._parse(expr, options);
15679
+ if (pushed) this.path.pop();
15680
+ this.expectedType = prevExpectedType;
15681
+ this.scope = prevScope;
15682
+ return result;
16059
15683
  }
16060
15684
  return this._parse(expr, options);
16061
15685
  }
@@ -16068,21 +15692,23 @@ class ParsingContext {
16068
15692
  * @private
16069
15693
  */
16070
15694
  parseObjectValue(expr, index, key, expectedType, bindings, options = {}) {
16071
- return this.concat(index, key, expectedType, bindings)._parse(expr, options);
15695
+ const prevExpectedType = this.expectedType;
15696
+ const prevScope = this.scope;
15697
+ if (bindings) this.scope = this.scope.concat(bindings);
15698
+ this.expectedType = expectedType || null;
15699
+ this.path.push(index);
15700
+ this.path.push(key);
15701
+ const result = this._parse(expr, options);
15702
+ this.path.pop();
15703
+ this.path.pop();
15704
+ this.expectedType = prevExpectedType;
15705
+ this.scope = prevScope;
15706
+ return result;
16072
15707
  }
16073
15708
  _parse(expr, options) {
16074
15709
  if (expr === null || typeof expr === "string" || typeof expr === "boolean" || typeof expr === "number") {
16075
15710
  expr = ["literal", expr];
16076
15711
  }
16077
- function annotate(parsed, type, typeAnnotation) {
16078
- if (typeAnnotation === "assert") {
16079
- return new Assertion(type, [parsed]);
16080
- } else if (typeAnnotation === "coerce") {
16081
- return new Coercion(type, [parsed]);
16082
- } else {
16083
- return parsed;
16084
- }
16085
- }
16086
15712
  if (Array.isArray(expr)) {
16087
15713
  if (expr.length === 0) {
16088
15714
  return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);
@@ -16131,9 +15757,10 @@ class ParsingContext {
16131
15757
  * @private
16132
15758
  */
16133
15759
  concat(index, key, expectedType, bindings) {
16134
- let path = typeof index === "number" ? this.path.concat(index) : this.path;
16135
- path = typeof key === "string" ? path.concat(key) : path;
16136
15760
  const scope = bindings ? this.scope.concat(bindings) : this.scope;
15761
+ const path = this.path.slice();
15762
+ if (typeof index === "number") path.push(index);
15763
+ if (typeof key === "string") path.push(key);
16137
15764
  return new ParsingContext(
16138
15765
  this.registry,
16139
15766
  path,
@@ -16145,6 +15772,24 @@ class ParsingContext {
16145
15772
  this.iconImageUseTheme
16146
15773
  );
16147
15774
  }
15775
+ /**
15776
+ * Returns a fresh context that shares the same path position as this one
15777
+ * but has an empty errors array. Used by CompoundExpression to probe
15778
+ * overload signatures without polluting the parent errors list.
15779
+ * @private
15780
+ */
15781
+ _forkForSignature() {
15782
+ return new ParsingContext(
15783
+ this.registry,
15784
+ this.path.slice(),
15785
+ null,
15786
+ this.scope,
15787
+ [],
15788
+ this._scope,
15789
+ this.options,
15790
+ this.iconImageUseTheme
15791
+ );
15792
+ }
16148
15793
  /**
16149
15794
  * Push a parsing (or type checking) error into the `this.errors`
16150
15795
  * @param error The message
@@ -16166,6 +15811,30 @@ class ParsingContext {
16166
15811
  return error;
16167
15812
  }
16168
15813
  }
15814
+ const CONSTANT_FOLD_EXCLUDED_GLOBALS = /* @__PURE__ */ new Set([
15815
+ "zoom",
15816
+ "heatmap-density",
15817
+ "worldview",
15818
+ "line-progress",
15819
+ "raster-value",
15820
+ "sky-radial-progress",
15821
+ "accumulated",
15822
+ "is-supported-script",
15823
+ "pitch",
15824
+ "distance-from-center",
15825
+ "measure-light",
15826
+ "raster-particle-speed",
15827
+ "is-active-floor"
15828
+ ]);
15829
+ function annotate(parsed, type, typeAnnotation) {
15830
+ if (typeAnnotation === "assert") {
15831
+ return new Assertion(type, [parsed]);
15832
+ } else if (typeAnnotation === "coerce") {
15833
+ return new Coercion(type, [parsed]);
15834
+ } else {
15835
+ return parsed;
15836
+ }
15837
+ }
16169
15838
  function isConstant(expression) {
16170
15839
  if (expression instanceof Var) {
16171
15840
  return isConstant(expression.boundExpression);
@@ -16192,7 +15861,7 @@ function isConstant(expression) {
16192
15861
  if (!childrenConstant) {
16193
15862
  return false;
16194
15863
  }
16195
- 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"]);
15864
+ return isFeatureConstant(expression) && isGlobalPropertyConstantSet(expression, CONSTANT_FOLD_EXCLUDED_GLOBALS);
16196
15865
  }
16197
15866
 
16198
15867
  function findStopLessThanOrEqualTo(stops, input) {
@@ -16957,24 +16626,23 @@ class Match {
16957
16626
  if (!Array.isArray(labels)) {
16958
16627
  labels = [labels];
16959
16628
  }
16960
- const labelContext = context.concat(i);
16961
16629
  if (labels.length === 0) {
16962
- return labelContext.error("Expected at least one branch label.");
16630
+ return context.error("Expected at least one branch label.", i);
16963
16631
  }
16964
16632
  for (const label of labels) {
16965
16633
  if (typeof label !== "number" && typeof label !== "string") {
16966
- return labelContext.error(`Branch labels must be numbers or strings.`);
16634
+ return context.error(`Branch labels must be numbers or strings.`, i);
16967
16635
  } else if (typeof label === "number" && Math.abs(label) > Number.MAX_SAFE_INTEGER) {
16968
- return labelContext.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);
16636
+ return context.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`, i);
16969
16637
  } else if (typeof label === "number" && Math.floor(label) !== label) {
16970
- return labelContext.error(`Numeric branch labels must be integer values.`);
16638
+ return context.error(`Numeric branch labels must be integer values.`, i);
16971
16639
  } else if (!inputType) {
16972
16640
  inputType = typeOf(label);
16973
- } else if (labelContext.checkSubtype(inputType, typeOf(label))) {
16641
+ } else if (context.checkSubtype(inputType, typeOf(label), i)) {
16974
16642
  return null;
16975
16643
  }
16976
16644
  if (typeof cases[String(label)] !== "undefined") {
16977
- return labelContext.error("Branch labels must be unique.");
16645
+ return context.error("Branch labels must be unique.", i);
16978
16646
  }
16979
16647
  cases[String(label)] = outputs.length;
16980
16648
  }
@@ -16987,7 +16655,7 @@ class Match {
16987
16655
  if (!input) return null;
16988
16656
  const otherwise = context.parse(args.at(-1), args.length - 1, outputType);
16989
16657
  if (!otherwise) return null;
16990
- if (input.type.kind !== "value" && context.concat(1).checkSubtype(inputType, input.type)) {
16658
+ if (input.type.kind !== "value" && context.checkSubtype(inputType, input.type, 1)) {
16991
16659
  return null;
16992
16660
  }
16993
16661
  return new Match(inputType, outputType, input, cases, outputs, otherwise);
@@ -17245,12 +16913,12 @@ function makeComparison(op, compareBasic, compareWithCollator) {
17245
16913
  let lhs = context.parse(args[1], 1, ValueType);
17246
16914
  if (!lhs) return null;
17247
16915
  if (!isComparableType(op2, lhs.type)) {
17248
- return context.concat(1).error(`"${op2}" comparisons are not supported for type '${toString$1(lhs.type)}'.`);
16916
+ return context.error(`"${op2}" comparisons are not supported for type '${toString$1(lhs.type)}'.`, 1);
17249
16917
  }
17250
16918
  let rhs = context.parse(args[2], 2, ValueType);
17251
16919
  if (!rhs) return null;
17252
16920
  if (!isComparableType(op2, rhs.type)) {
17253
- return context.concat(2).error(`"${op2}" comparisons are not supported for type '${toString$1(rhs.type)}'.`);
16921
+ return context.error(`"${op2}" comparisons are not supported for type '${toString$1(rhs.type)}'.`, 2);
17254
16922
  }
17255
16923
  if (lhs.type.kind !== rhs.type.kind && lhs.type.kind !== "value" && rhs.type.kind !== "value") {
17256
16924
  return context.error(`Cannot compare types '${toString$1(lhs.type)}' and '${toString$1(rhs.type)}'.`);
@@ -18205,7 +17873,7 @@ function createFunction(parameters, propertySpec) {
18205
17873
  const zoomDependent = zoomAndFeatureDependent || !featureDependent;
18206
17874
  const type = parameters.type || (supportsInterpolation(propertySpec) ? "exponential" : "interval");
18207
17875
  if (isColor) {
18208
- parameters = Object.assign({}, parameters);
17876
+ parameters = { ...parameters };
18209
17877
  if (parameters.stops) {
18210
17878
  parameters.stops = parameters.stops.map((stop) => {
18211
17879
  return [stop[0], Color.parse(stop[1])];
@@ -19864,11 +19532,12 @@ function validateImport(options) {
19864
19532
  value: value.__line__,
19865
19533
  enumerable: false
19866
19534
  });
19867
- let errors = validateObject(Object.assign({}, options, {
19535
+ let errors = validateObject({
19536
+ ...options,
19868
19537
  value: importSpec,
19869
19538
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
19870
19539
  valueSpec: styleSpec.import
19871
- }));
19540
+ });
19872
19541
  if (unbundle(importSpec.id) === "") {
19873
19542
  const key2 = `${options.key}.id`;
19874
19543
  errors.push(new ValidationError(key2, importSpec, `import id can't be an empty string`));
@@ -19889,7 +19558,8 @@ function validateOption(options) {
19889
19558
  const optionValue = options.value;
19890
19559
  const isArrayOption = isObject(optionValue) && unbundle(optionValue.array) === true;
19891
19560
  const declaredType = !isArrayOption && isObject(optionValue) ? unbundle(optionValue.type) : void 0;
19892
- return validateObject(Object.assign({}, options, {
19561
+ return validateObject({
19562
+ ...options,
19893
19563
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
19894
19564
  valueSpec: styleSpec.option,
19895
19565
  objectElementValidators: declaredType ? {
@@ -19897,11 +19567,9 @@ function validateOption(options) {
19897
19567
  // expression (array-form). Primitive defaults keep the previous
19898
19568
  // permissive validation, mirroring the runtime parser's narrowing
19899
19569
  // in style.ts/parser.cpp.
19900
- default: (elementOptions) => Array.isArray(elementOptions.value) ? validate(Object.assign({}, elementOptions, {
19901
- valueSpec: Object.assign({}, elementOptions.valueSpec, { type: declaredType })
19902
- })) : validate(elementOptions)
19570
+ default: (elementOptions) => Array.isArray(elementOptions.value) ? validate({ ...elementOptions, valueSpec: { ...elementOptions.valueSpec, type: declaredType } }) : validate(elementOptions)
19903
19571
  } : void 0
19904
- }));
19572
+ });
19905
19573
  }
19906
19574
 
19907
19575
  function validateArray(options) {
@@ -20290,11 +19958,12 @@ function validateEnum(options) {
20290
19958
  function validateFilter(options) {
20291
19959
  if (isExpressionFilter(deepUnbundle(options.value))) {
20292
19960
  const layerType = options.layerType || "fill";
20293
- return validateExpression(Object.assign({}, options, {
19961
+ return validateExpression({
19962
+ ...options,
20294
19963
  expressionContext: "filter",
20295
19964
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
20296
19965
  valueSpec: options.styleSpec[`filter_${layerType}`]
20297
- }));
19966
+ });
20298
19967
  } else {
20299
19968
  return validateNonExpressionFilter(options);
20300
19969
  }
@@ -20491,8 +20160,8 @@ function validateAppearance(options) {
20491
20160
  style: options.style,
20492
20161
  styleSpec: options.styleSpec,
20493
20162
  objectElementValidators: {
20494
- condition: (options2) => validateCondition(Object.assign({ layer, layerType }, options2)),
20495
- properties: (options2) => validateProperties(Object.assign({ layer, layerType }, options2))
20163
+ condition: (options2) => validateCondition({ ...options2 }),
20164
+ properties: (options2) => validateProperties({ layer, layerType, ...options2 })
20496
20165
  }
20497
20166
  });
20498
20167
  if (name !== "hidden" && condition === void 0) {
@@ -20512,15 +20181,15 @@ function validateProperties(options) {
20512
20181
  errors.push(new ValidationError(options.key, propertyKey, `unknown property "${propertyKey}" for layer type "${layerType}"`));
20513
20182
  continue;
20514
20183
  }
20515
- const propertyValidationOptions = Object.assign({}, options, {
20184
+ const propertyValidationOptions = {
20185
+ ...options,
20516
20186
  key: `${options.key}.${propertyKey}`,
20517
- object: properties,
20518
20187
  objectKey: propertyKey,
20519
20188
  layer,
20520
20189
  layerType,
20521
20190
  value: properties[propertyKey],
20522
20191
  valueSpec: propertyType === "paint" ? paintProperties[propertyKey] : layoutProperties[propertyKey]
20523
- });
20192
+ };
20524
20193
  errors.push(...validateProperty(propertyValidationOptions, propertyType));
20525
20194
  }
20526
20195
  return errors;
@@ -20642,7 +20311,7 @@ function validateLayer(options) {
20642
20311
  });
20643
20312
  },
20644
20313
  filter(options2) {
20645
- return validateFilter(Object.assign({ layerType: type }, options2));
20314
+ return validateFilter({ layerType: type, ...options2 });
20646
20315
  },
20647
20316
  layout(options2) {
20648
20317
  return validateObject({
@@ -20654,7 +20323,7 @@ function validateLayer(options) {
20654
20323
  styleSpec: options2.styleSpec,
20655
20324
  objectElementValidators: {
20656
20325
  "*"(options3) {
20657
- return validateLayoutProperty(Object.assign({ layerType: type }, options3));
20326
+ return validateLayoutProperty({ layerType: type, ...options3 });
20658
20327
  }
20659
20328
  }
20660
20329
  });
@@ -20669,7 +20338,7 @@ function validateLayer(options) {
20669
20338
  styleSpec: options2.styleSpec,
20670
20339
  objectElementValidators: {
20671
20340
  "*"(options3) {
20672
- return validatePaintProperty(Object.assign({ layerType: type, layer }, options3));
20341
+ return validatePaintProperty({ layerType: type, layer, ...options3 });
20673
20342
  }
20674
20343
  }
20675
20344
  });
@@ -20681,7 +20350,7 @@ function validateLayer(options) {
20681
20350
  valueSpec: options2.valueSpec,
20682
20351
  style: options2.style,
20683
20352
  styleSpec: options2.styleSpec,
20684
- arrayElementValidator: (options3) => validateAppearance(Object.assign({ layerType: type, layer }, options3))
20353
+ arrayElementValidator: (options3) => validateAppearance({ layerType: type, layer, ...options3 })
20685
20354
  });
20686
20355
  const appearances = Array.isArray(options2.value) ? options2.value : [];
20687
20356
  const dedupedNames = /* @__PURE__ */ new Set();
@@ -21243,10 +20912,11 @@ function validate(options, arrayAsExpression = false) {
21243
20912
  }
21244
20913
  return errors2;
21245
20914
  }
21246
- const errors = validateObject(Object.assign({}, options, {
20915
+ const errors = validateObject({
20916
+ ...options,
21247
20917
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
21248
20918
  valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec
21249
- }));
20919
+ });
21250
20920
  return errors;
21251
20921
  }
21252
20922
 
@@ -21322,12 +20992,11 @@ function validateStyle$2(style, styleSpec = v8, options = {}) {
21322
20992
  key: options.key || "",
21323
20993
  value: style,
21324
20994
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
21325
- valueSpec: Object.assign(
21326
- {},
21327
- styleSpec.$root,
20995
+ valueSpec: {
20996
+ ...styleSpec.$root,
21328
20997
  // Skip validation of the root properties that are not defined in the style spec (e.g. 'owner').
21329
- { "*": { type: "*" } }
21330
- ),
20998
+ "*": { type: "*" }
20999
+ },
21331
21000
  styleSpec,
21332
21001
  style,
21333
21002
  objectElementValidators: {