@mapbox/mapbox-gl-style-spec 14.5.0-beta.1 → 14.5.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.d.ts CHANGED
@@ -80,6 +80,25 @@ type TransitionSpecification = {
80
80
  duration?: number;
81
81
  delay?: number;
82
82
  };
83
+ type PropertyFunctionStop<T> = [
84
+ number,
85
+ T
86
+ ];
87
+ type ZoomAndPropertyFunctionStop<T> = [
88
+ {
89
+ zoom: number;
90
+ value: string | number | boolean;
91
+ },
92
+ T
93
+ ];
94
+ type FunctionSpecification<T> = {
95
+ stops: Array<PropertyFunctionStop<T> | ZoomAndPropertyFunctionStop<T>>;
96
+ base?: number;
97
+ property?: string;
98
+ type?: "identity" | "exponential" | "interval" | "categorical";
99
+ colorSpace?: "rgb" | "lab" | "hcl";
100
+ default?: T;
101
+ };
83
102
  type CameraFunctionSpecification<T> = {
84
103
  type: "exponential";
85
104
  stops: Array<[
@@ -161,7 +180,7 @@ type ExpressionSpecification = [
161
180
  ...any[]
162
181
  ];
163
182
  type PropertyValueSpecification<T> = T | CameraFunctionSpecification<T> | ExpressionSpecification;
164
- type DataDrivenPropertyValueSpecification<T> = T | CameraFunctionSpecification<T> | SourceFunctionSpecification<T> | CompositeFunctionSpecification<T> | ExpressionSpecification;
183
+ type DataDrivenPropertyValueSpecification<T> = T | FunctionSpecification<T> | CameraFunctionSpecification<T> | SourceFunctionSpecification<T> | CompositeFunctionSpecification<T> | ExpressionSpecification;
165
184
  type StyleSpecification = {
166
185
  "version": 8;
167
186
  "fragment"?: boolean;
@@ -543,6 +562,15 @@ type LineLayerSpecification = {
543
562
  number,
544
563
  number
545
564
  ];
565
+ /**
566
+ * @experimental This property is experimental and subject to change in future versions.
567
+ */
568
+ "line-trim-fade-range"?: PropertyValueSpecification<[
569
+ number,
570
+ number
571
+ ]>;
572
+ "line-trim-color"?: PropertyValueSpecification<ColorSpecification>;
573
+ "line-trim-color-transition"?: TransitionSpecification;
546
574
  "line-emissive-strength"?: PropertyValueSpecification<number>;
547
575
  "line-emissive-strength-transition"?: TransitionSpecification;
548
576
  "line-border-width"?: DataDrivenPropertyValueSpecification<number>;
@@ -1325,7 +1353,7 @@ type FeatureFilter = {
1325
1353
  needGeometry: boolean;
1326
1354
  needFeature: boolean;
1327
1355
  };
1328
- declare function isExpressionFilter(filter: any): boolean;
1356
+ declare function isExpressionFilter(filter: unknown): boolean;
1329
1357
  /**
1330
1358
  * Given a filter expressed as nested arrays, return a new function
1331
1359
  * that evaluates whether a given feature (with a .properties or .tags property)
@@ -1336,7 +1364,7 @@ declare function isExpressionFilter(filter: any): boolean;
1336
1364
  * @param {string} layerType the type of the layer this filter will be applied to.
1337
1365
  * @returns {Function} filter-evaluating function
1338
1366
  */
1339
- declare function createFilter(filter: any, layerType?: string): FeatureFilter;
1367
+ declare function createFilter(filter?: FilterSpecification | ExpressionSpecification, layerType?: string): FeatureFilter;
1340
1368
  type SerializedExpression = Array<unknown> | Array<string> | string | number | boolean | null;
1341
1369
  interface Expression {
1342
1370
  readonly type: Type;
@@ -1559,22 +1587,7 @@ declare function createFunction(parameters: any, propertySpec: any): {
1559
1587
  interpolationFactor?: undefined;
1560
1588
  zoomStops?: undefined;
1561
1589
  };
1562
- type Stop = [
1563
- {
1564
- zoom: number;
1565
- value: string | number | boolean;
1566
- },
1567
- unknown
1568
- ];
1569
- type FunctionParameters = {
1570
- stops: Array<Stop>;
1571
- base: number;
1572
- property: string;
1573
- type: "identity" | "exponential" | "interval" | "categorical";
1574
- colorSpace: "rgb" | "lab" | "hcl";
1575
- default: unknown;
1576
- };
1577
- declare function convertFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification): ExpressionSpecification;
1590
+ declare function convertFunction<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification): ExpressionSpecification;
1578
1591
  declare function eachSource(style: StyleSpecification, callback: (_: SourceSpecification) => void): void;
1579
1592
  declare function eachLayer(style: StyleSpecification, callback: (_: LayerSpecification) => void): void;
1580
1593
  type PropertyCallback = (arg1: {
@@ -1638,6 +1651,7 @@ export type StylePropertySpecification = {
1638
1651
  expression?: ExpressionSpecification$1;
1639
1652
  transition?: boolean;
1640
1653
  default?: number;
1654
+ tokens: never;
1641
1655
  } | {
1642
1656
  type: "string";
1643
1657
  "property-type": ExpressionType;
@@ -1651,6 +1665,7 @@ export type StylePropertySpecification = {
1651
1665
  expression?: ExpressionSpecification$1;
1652
1666
  transition?: boolean;
1653
1667
  default?: boolean;
1668
+ tokens: never;
1654
1669
  } | {
1655
1670
  type: "enum";
1656
1671
  "property-type": ExpressionType;
@@ -1660,12 +1675,14 @@ export type StylePropertySpecification = {
1660
1675
  };
1661
1676
  transition?: boolean;
1662
1677
  default?: string;
1678
+ tokens: never;
1663
1679
  } | {
1664
1680
  type: "color";
1665
1681
  "property-type": ExpressionType;
1666
1682
  expression?: ExpressionSpecification$1;
1667
1683
  transition?: boolean;
1668
1684
  default?: string;
1685
+ tokens: never;
1669
1686
  overridable: boolean;
1670
1687
  } | {
1671
1688
  type: "array";
@@ -1675,6 +1692,7 @@ export type StylePropertySpecification = {
1675
1692
  length?: number;
1676
1693
  transition?: boolean;
1677
1694
  default?: Array<number>;
1695
+ tokens: never;
1678
1696
  } | {
1679
1697
  type: "array";
1680
1698
  value: "string";
@@ -1683,12 +1701,14 @@ export type StylePropertySpecification = {
1683
1701
  length?: number;
1684
1702
  transition?: boolean;
1685
1703
  default?: Array<string>;
1704
+ tokens: never;
1686
1705
  } | {
1687
1706
  type: "resolvedImage";
1688
1707
  "property-type": ExpressionType;
1689
1708
  expression?: ExpressionSpecification$1;
1690
1709
  transition?: boolean;
1691
1710
  default?: string;
1711
+ tokens: never;
1692
1712
  };
1693
1713
  export declare const expression: {
1694
1714
  StyleExpression: typeof StyleExpression;
package/dist/index.es.js CHANGED
@@ -4985,6 +4985,7 @@ var paint = [
4985
4985
  "paint_fill-extrusion",
4986
4986
  "paint_symbol",
4987
4987
  "paint_raster",
4988
+ "paint_raster-particle",
4988
4989
  "paint_hillshade",
4989
4990
  "paint_background",
4990
4991
  "paint_sky",
@@ -5567,7 +5568,7 @@ var paint_line = {
5567
5568
  "line-trim-offset": {
5568
5569
  type: "array",
5569
5570
  value: "number",
5570
- doc: "The line part between [trim-start, trim-end] will be marked as transparent to make a route vanishing effect. The line trim-off offset is based on the whole line range [0.0, 1.0].",
5571
+ doc: "The line part between [trim-start, trim-end] will be painted using `line-trim-color,` which is transparent by default to produce a route vanishing effect. The line trim-off offset is based on the whole line range [0.0, 1.0].",
5571
5572
  length: 2,
5572
5573
  "default": [
5573
5574
  0,
@@ -5599,6 +5600,81 @@ var paint_line = {
5599
5600
  },
5600
5601
  "property-type": "constant"
5601
5602
  },
5603
+ "line-trim-fade-range": {
5604
+ type: "array",
5605
+ value: "number",
5606
+ doc: "The fade range for the trim-start and trim-end points is defined by the `line-trim-offset` property. The first element of the array represents the fade range from the trim-start point toward the end of the line, while the second element defines the fade range from the trim-end point toward the beginning of the line. The fade result is achieved by interpolating between `line-trim-color` and the color specified by the `line-color` or the `line-gradient` property.",
5607
+ experimental: true,
5608
+ length: 2,
5609
+ "default": [
5610
+ 0,
5611
+ 0
5612
+ ],
5613
+ minimum: [
5614
+ 0,
5615
+ 0
5616
+ ],
5617
+ maximum: [
5618
+ 1,
5619
+ 1
5620
+ ],
5621
+ transition: false,
5622
+ requires: [
5623
+ "line-trim-offset",
5624
+ {
5625
+ source: "geojson",
5626
+ has: {
5627
+ lineMetrics: true
5628
+ }
5629
+ }
5630
+ ],
5631
+ expression: {
5632
+ interpolated: true,
5633
+ parameters: [
5634
+ "zoom",
5635
+ "measure-light"
5636
+ ]
5637
+ },
5638
+ "sdk-support": {
5639
+ "basic functionality": {
5640
+ js: "3.6.0",
5641
+ android: "11.6.0",
5642
+ ios: "11.6.0"
5643
+ }
5644
+ },
5645
+ "property-type": "data-constant"
5646
+ },
5647
+ "line-trim-color": {
5648
+ type: "color",
5649
+ doc: "The color to be used for rendering the trimmed line section that is defined by the `line-trim-offset` property.",
5650
+ experimental: true,
5651
+ "default": "transparent",
5652
+ transition: true,
5653
+ requires: [
5654
+ "line-trim-offset",
5655
+ {
5656
+ source: "geojson",
5657
+ has: {
5658
+ lineMetrics: true
5659
+ }
5660
+ }
5661
+ ],
5662
+ "sdk-support": {
5663
+ "basic functionality": {
5664
+ js: "3.6.0",
5665
+ android: "11.6.0",
5666
+ ios: "11.6.0"
5667
+ }
5668
+ },
5669
+ expression: {
5670
+ interpolated: true,
5671
+ parameters: [
5672
+ "zoom",
5673
+ "measure-light"
5674
+ ]
5675
+ },
5676
+ "property-type": "data-constant"
5677
+ },
5602
5678
  "line-emissive-strength": {
5603
5679
  type: "number",
5604
5680
  "default": 0,
@@ -12178,7 +12254,6 @@ class Within {
12178
12254
  }
12179
12255
  }
12180
12256
 
12181
- /* @flow */
12182
12257
  const factors = {
12183
12258
  kilometers: 1,
12184
12259
  miles: 1000 / 1609.344,
@@ -12198,13 +12273,6 @@ const E2 = FE * (2 - FE);
12198
12273
  const RAD = Math.PI / 180;
12199
12274
  /**
12200
12275
  * A collection of very fast approximations to common geodesic measurements. Useful for performance-sensitive code that measures things on a city scale.
12201
- *
12202
- * @param {number} lat latitude
12203
- * @param {string} [units='kilometers']
12204
- * @returns {CheapRuler}
12205
- * @example
12206
- * const ruler = cheapRuler(35.05, 'miles');
12207
- * //=ruler
12208
12276
  */
12209
12277
  class CheapRuler {
12210
12278
  /**
@@ -12212,7 +12280,7 @@ class CheapRuler {
12212
12280
  *
12213
12281
  * @param {number} y
12214
12282
  * @param {number} z
12215
- * @param {string} [units='kilometers']
12283
+ * @param {keyof typeof factors} [units='kilometers']
12216
12284
  * @returns {CheapRuler}
12217
12285
  * @example
12218
12286
  * const ruler = cheapRuler.fromTile(1567, 12);
@@ -12237,8 +12305,7 @@ class CheapRuler {
12237
12305
  * Creates a ruler instance for very fast approximations to common geodesic measurements around a certain latitude.
12238
12306
  *
12239
12307
  * @param {number} lat latitude
12240
- * @param {string} [units='kilometers']
12241
- * @returns {CheapRuler}
12308
+ * @param {keyof typeof factors} [units='kilometers']
12242
12309
  * @example
12243
12310
  * const ruler = cheapRuler(35.05, 'miles');
12244
12311
  * //=ruler
@@ -12261,8 +12328,8 @@ class CheapRuler {
12261
12328
  /**
12262
12329
  * Given two points of the form [longitude, latitude], returns the distance.
12263
12330
  *
12264
- * @param {Array<number>} a point [longitude, latitude]
12265
- * @param {Array<number>} b point [longitude, latitude]
12331
+ * @param {[number, number]} a point [longitude, latitude]
12332
+ * @param {[number, number]} b point [longitude, latitude]
12266
12333
  * @returns {number} distance
12267
12334
  * @example
12268
12335
  * const distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);
@@ -12276,8 +12343,8 @@ class CheapRuler {
12276
12343
  /**
12277
12344
  * Returns the bearing between two points in angles.
12278
12345
  *
12279
- * @param {Array<number>} a point [longitude, latitude]
12280
- * @param {Array<number>} b point [longitude, latitude]
12346
+ * @param {[number, number]} a point [longitude, latitude]
12347
+ * @param {[number, number]} b point [longitude, latitude]
12281
12348
  * @returns {number} bearing
12282
12349
  * @example
12283
12350
  * const bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]);
@@ -12291,10 +12358,10 @@ class CheapRuler {
12291
12358
  /**
12292
12359
  * Returns a new point given distance and bearing from the starting point.
12293
12360
  *
12294
- * @param {Array<number>} p point [longitude, latitude]
12361
+ * @param {[number, number]} p point [longitude, latitude]
12295
12362
  * @param {number} dist distance
12296
12363
  * @param {number} bearing
12297
- * @returns {Array<number>} point [longitude, latitude]
12364
+ * @returns {[number, number]} point [longitude, latitude]
12298
12365
  * @example
12299
12366
  * const point = ruler.destination([30.5, 50.5], 0.1, 90);
12300
12367
  * //=point
@@ -12306,10 +12373,10 @@ class CheapRuler {
12306
12373
  /**
12307
12374
  * Returns a new point given easting and northing offsets (in ruler units) from the starting point.
12308
12375
  *
12309
- * @param {Array<number>} p point [longitude, latitude]
12376
+ * @param {[number, number]} p point [longitude, latitude]
12310
12377
  * @param {number} dx easting
12311
12378
  * @param {number} dy northing
12312
- * @returns {Array<number>} point [longitude, latitude]
12379
+ * @returns {[number, number]} point [longitude, latitude]
12313
12380
  * @example
12314
12381
  * const point = ruler.offset([30.5, 50.5], 10, 10);
12315
12382
  * //=point
@@ -12323,7 +12390,7 @@ class CheapRuler {
12323
12390
  /**
12324
12391
  * Given a line (an array of points), returns the total line distance.
12325
12392
  *
12326
- * @param {Array<Array<number>>} points [longitude, latitude]
12393
+ * @param {[number, number][]} points [longitude, latitude]
12327
12394
  * @returns {number} total line distance
12328
12395
  * @example
12329
12396
  * const length = ruler.lineDistance([
@@ -12342,7 +12409,7 @@ class CheapRuler {
12342
12409
  /**
12343
12410
  * Given a polygon (an array of rings, where each ring is an array of points), returns the area.
12344
12411
  *
12345
- * @param {Array<Array<Array<number>>>} polygon
12412
+ * @param {[number, number][][]} polygon
12346
12413
  * @returns {number} area value in the specified units (square kilometers by default)
12347
12414
  * @example
12348
12415
  * const area = ruler.area([[
@@ -12364,9 +12431,9 @@ class CheapRuler {
12364
12431
  /**
12365
12432
  * Returns the point at a specified distance along the line.
12366
12433
  *
12367
- * @param {Array<Array<number>>} line
12434
+ * @param {[number, number][]} line
12368
12435
  * @param {number} dist distance
12369
- * @returns {Array<number>} point [longitude, latitude]
12436
+ * @returns {[number, number]} point [longitude, latitude]
12370
12437
  * @example
12371
12438
  * const point = ruler.along(line, 2.5);
12372
12439
  * //=point
@@ -12389,9 +12456,9 @@ class CheapRuler {
12389
12456
  * Returns the distance from a point `p` to a line segment `a` to `b`.
12390
12457
  *
12391
12458
  * @pointToSegmentDistance
12392
- * @param {Array<number>} p point [longitude, latitude]
12393
- * @param {Array<number>} p1 segment point 1 [longitude, latitude]
12394
- * @param {Array<number>} p2 segment point 2 [longitude, latitude]
12459
+ * @param {[number, number]} p point [longitude, latitude]
12460
+ * @param {[number, number]} a segment point 1 [longitude, latitude]
12461
+ * @param {[number, number]} b segment point 2 [longitude, latitude]
12395
12462
  * @returns {number} distance
12396
12463
  * @example
12397
12464
  * const distance = ruler.pointToSegmentDistance([-67.04, 50.5], [-67.05, 50.57], [-67.03, 50.54]);
@@ -12401,9 +12468,8 @@ class CheapRuler {
12401
12468
  let [x, y] = a;
12402
12469
  let dx = wrap(b[0] - x) * this.kx;
12403
12470
  let dy = (b[1] - y) * this.ky;
12404
- let t = 0;
12405
12471
  if (dx !== 0 || dy !== 0) {
12406
- t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
12472
+ const t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
12407
12473
  if (t > 1) {
12408
12474
  x = b[0];
12409
12475
  y = b[1];
@@ -12421,16 +12487,19 @@ class CheapRuler {
12421
12487
  * from the given point, index is the start index of the segment with the closest point,
12422
12488
  * and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
12423
12489
  *
12424
- * @param {Array<Array<number>>} line
12425
- * @param {Array<number>} p point [longitude, latitude]
12426
- * @returns {Object} {point, index, t}
12490
+ * @param {[number, number][]} line
12491
+ * @param {[number, number]} p point [longitude, latitude]
12492
+ * @returns {{point: [number, number], index: number, t: number}} {point, index, t}
12427
12493
  * @example
12428
12494
  * const point = ruler.pointOnLine(line, [-67.04, 50.5]).point;
12429
12495
  * //=point
12430
12496
  */
12431
12497
  pointOnLine(line, p) {
12432
12498
  let minDist = Infinity;
12433
- let minX, minY, minI, minT;
12499
+ let minX = line[0][0];
12500
+ let minY = line[0][1];
12501
+ let minI = 0;
12502
+ let minT = 0;
12434
12503
  for (let i = 0; i < line.length - 1; i++) {
12435
12504
  let x = line[i][0];
12436
12505
  let y = line[i][1];
@@ -12470,10 +12539,10 @@ class CheapRuler {
12470
12539
  /**
12471
12540
  * Returns a part of the given line between the start and the stop points (or their closest points on the line).
12472
12541
  *
12473
- * @param {Array<number>} start point [longitude, latitude]
12474
- * @param {Array<number>} stop point [longitude, latitude]
12475
- * @param {Array<Array<number>>} line
12476
- * @returns {Array<Array<number>>} line part of a line
12542
+ * @param {[number, number]} start point [longitude, latitude]
12543
+ * @param {[number, number]} stop point [longitude, latitude]
12544
+ * @param {[number, number][]} line
12545
+ * @returns {[number, number][]} line part of a line
12477
12546
  * @example
12478
12547
  * const line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1);
12479
12548
  * //=line2
@@ -12501,10 +12570,10 @@ class CheapRuler {
12501
12570
  /**
12502
12571
  * Returns a part of the given line between the start and the stop points indicated by distance along the line.
12503
12572
  *
12504
- * @param {number} start distance
12505
- * @param {number} stop distance
12506
- * @param {Array<Array<number>>} line
12507
- * @returns {Array<Array<number>>} line part of a line
12573
+ * @param {number} start start distance
12574
+ * @param {number} stop stop distance
12575
+ * @param {[number, number][]} line
12576
+ * @returns {[number, number][]} part of a line
12508
12577
  * @example
12509
12578
  * const line2 = ruler.lineSliceAlong(10, 20, line1);
12510
12579
  * //=line2
@@ -12532,9 +12601,9 @@ class CheapRuler {
12532
12601
  /**
12533
12602
  * Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance.
12534
12603
  *
12535
- * @param {Array<number>} p point [longitude, latitude]
12604
+ * @param {[number, number]} p point [longitude, latitude]
12536
12605
  * @param {number} buffer
12537
- * @returns {Array<number>} box object ([w, s, e, n])
12606
+ * @returns {[number, number, number, number]} bbox ([w, s, e, n])
12538
12607
  * @example
12539
12608
  * const bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
12540
12609
  * //=bbox
@@ -12552,9 +12621,9 @@ class CheapRuler {
12552
12621
  /**
12553
12622
  * Given a bounding box, returns the box buffered by a given distance.
12554
12623
  *
12555
- * @param {Array<number>} box object ([w, s, e, n])
12624
+ * @param {[number, number, number, number]} bbox ([w, s, e, n])
12556
12625
  * @param {number} buffer
12557
- * @returns {Array<number>} box object ([w, s, e, n])
12626
+ * @returns {[number, number, number, number]} bbox ([w, s, e, n])
12558
12627
  * @example
12559
12628
  * const bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2);
12560
12629
  * //=bbox
@@ -12572,20 +12641,31 @@ class CheapRuler {
12572
12641
  /**
12573
12642
  * Returns true if the given point is inside in the given bounding box, otherwise false.
12574
12643
  *
12575
- * @param {Array<number>} p point [longitude, latitude]
12576
- * @param {Array<number>} box object ([w, s, e, n])
12644
+ * @param {[number, number]} p point [longitude, latitude]
12645
+ * @param {[number, number, number, number]} bbox ([w, s, e, n])
12577
12646
  * @returns {boolean}
12578
12647
  * @example
12579
12648
  * const inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
12580
12649
  * //=inside
12581
12650
  */
12582
12651
  insideBBox(p, bbox) {
12652
+ // eslint-disable-line
12583
12653
  return wrap(p[0] - bbox[0]) >= 0 && wrap(p[0] - bbox[2]) <= 0 && p[1] >= bbox[1] && p[1] <= bbox[3];
12584
12654
  }
12585
12655
  }
12656
+ /**
12657
+ * @param {[number, number]} a
12658
+ * @param {[number, number]} b
12659
+ */
12586
12660
  function equals(a, b) {
12587
12661
  return a[0] === b[0] && a[1] === b[1];
12588
12662
  }
12663
+ /**
12664
+ * @param {[number, number]} a
12665
+ * @param {[number, number]} b
12666
+ * @param {number} t
12667
+ * @returns {[number, number]}
12668
+ */
12589
12669
  function interpolate(a, b, t) {
12590
12670
  const dx = wrap(b[0] - a[0]);
12591
12671
  const dy = b[1] - a[1];
@@ -12594,7 +12674,10 @@ function interpolate(a, b, t) {
12594
12674
  a[1] + dy * t
12595
12675
  ];
12596
12676
  }
12597
- // normalize a degree value into [-180..180] range
12677
+ /**
12678
+ * normalize a degree value into [-180..180] range
12679
+ * @param {number} deg
12680
+ */
12598
12681
  function wrap(deg) {
12599
12682
  while (deg < -180)
12600
12683
  deg += 360;