@mapbox/mapbox-gl-style-spec 14.13.0 → 14.14.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +471 -307
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +22 -2
- package/dist/index.es.js +471 -307
- package/dist/index.es.js.map +1 -1
- package/expression/definitions/index.ts +3 -1
- package/expression/definitions/split.ts +56 -0
- package/package.json +2 -2
- package/reference/v8.json +121 -8
- package/types.ts +20 -3
package/dist/index.cjs
CHANGED
|
@@ -1945,11 +1945,84 @@
|
|
|
1945
1945
|
},
|
|
1946
1946
|
"property-type": "constant"
|
|
1947
1947
|
},
|
|
1948
|
+
"building-facade": {
|
|
1949
|
+
type: "boolean",
|
|
1950
|
+
"default": false,
|
|
1951
|
+
doc: "Whether to render facade details on the buildings.",
|
|
1952
|
+
experimental: true,
|
|
1953
|
+
"private": true,
|
|
1954
|
+
"sdk-support": {
|
|
1955
|
+
"basic functionality": {
|
|
1956
|
+
},
|
|
1957
|
+
"data-driven styling": {
|
|
1958
|
+
}
|
|
1959
|
+
},
|
|
1960
|
+
expression: {
|
|
1961
|
+
interpolated: false,
|
|
1962
|
+
parameters: [
|
|
1963
|
+
"feature"
|
|
1964
|
+
]
|
|
1965
|
+
},
|
|
1966
|
+
"property-type": "data-driven"
|
|
1967
|
+
},
|
|
1968
|
+
"building-facade-floors": {
|
|
1969
|
+
type: "number",
|
|
1970
|
+
minimum: 1,
|
|
1971
|
+
maximum: 200,
|
|
1972
|
+
"default": 3,
|
|
1973
|
+
doc: "Number of floors created when building-facade is enabled.",
|
|
1974
|
+
experimental: true,
|
|
1975
|
+
"property-type": "data-driven",
|
|
1976
|
+
"sdk-support": {
|
|
1977
|
+
"basic functionality": {
|
|
1978
|
+
},
|
|
1979
|
+
"data-driven styling": {
|
|
1980
|
+
}
|
|
1981
|
+
},
|
|
1982
|
+
expression: {
|
|
1983
|
+
interpolated: false,
|
|
1984
|
+
parameters: [
|
|
1985
|
+
"feature"
|
|
1986
|
+
]
|
|
1987
|
+
},
|
|
1988
|
+
requires: [
|
|
1989
|
+
"building-facade"
|
|
1990
|
+
]
|
|
1991
|
+
},
|
|
1992
|
+
"building-facade-window": {
|
|
1993
|
+
type: "array",
|
|
1994
|
+
length: 2,
|
|
1995
|
+
value: "number",
|
|
1996
|
+
minimum: 0.1,
|
|
1997
|
+
maximum: 1,
|
|
1998
|
+
"default": [
|
|
1999
|
+
0.9,
|
|
2000
|
+
0.9
|
|
2001
|
+
],
|
|
2002
|
+
doc: "Given as fractions, specifies the percentage of floor area covered by windows when building-facade is enabled",
|
|
2003
|
+
experimental: true,
|
|
2004
|
+
"property-type": "data-driven",
|
|
2005
|
+
"sdk-support": {
|
|
2006
|
+
"basic functionality": {
|
|
2007
|
+
},
|
|
2008
|
+
"data-driven styling": {
|
|
2009
|
+
}
|
|
2010
|
+
},
|
|
2011
|
+
expression: {
|
|
2012
|
+
interpolated: false,
|
|
2013
|
+
parameters: [
|
|
2014
|
+
"feature"
|
|
2015
|
+
]
|
|
2016
|
+
},
|
|
2017
|
+
requires: [
|
|
2018
|
+
"building-facade"
|
|
2019
|
+
]
|
|
2020
|
+
},
|
|
1948
2021
|
"building-roof-shape": {
|
|
1949
2022
|
type: "enum",
|
|
1950
2023
|
values: {
|
|
1951
2024
|
flat: {
|
|
1952
|
-
doc: "Use
|
|
2025
|
+
doc: "Use flat roof for the procedurally generated buildings."
|
|
1953
2026
|
},
|
|
1954
2027
|
hipped: {
|
|
1955
2028
|
doc: "Use hipped roof for the procedurally generated buildings."
|
|
@@ -4192,6 +4265,17 @@
|
|
|
4192
4265
|
}
|
|
4193
4266
|
}
|
|
4194
4267
|
},
|
|
4268
|
+
split: {
|
|
4269
|
+
doc: "Returns an array of substrings from a string, split by a delimiter parameter.",
|
|
4270
|
+
group: "Lookup",
|
|
4271
|
+
"sdk-support": {
|
|
4272
|
+
"basic functionality": {
|
|
4273
|
+
js: "3.14.0",
|
|
4274
|
+
android: "11.14.0",
|
|
4275
|
+
ios: "11.14.0"
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4278
|
+
},
|
|
4195
4279
|
"case": {
|
|
4196
4280
|
doc: "Selects the first output whose corresponding test condition evaluates to true, or the fallback value otherwise.",
|
|
4197
4281
|
group: "Decision",
|
|
@@ -6680,7 +6764,7 @@
|
|
|
6680
6764
|
},
|
|
6681
6765
|
"property-type": "data-constant"
|
|
6682
6766
|
},
|
|
6683
|
-
"building-ambient-occlusion-
|
|
6767
|
+
"building-ambient-occlusion-intensity": {
|
|
6684
6768
|
"property-type": "data-constant",
|
|
6685
6769
|
type: "number",
|
|
6686
6770
|
"default": 0,
|
|
@@ -6689,13 +6773,12 @@
|
|
|
6689
6773
|
experimental: true,
|
|
6690
6774
|
"private": true,
|
|
6691
6775
|
expression: {
|
|
6692
|
-
interpolated:
|
|
6776
|
+
interpolated: false,
|
|
6693
6777
|
parameters: [
|
|
6694
|
-
"zoom"
|
|
6695
6778
|
]
|
|
6696
6779
|
},
|
|
6697
6780
|
transition: true,
|
|
6698
|
-
doc: "Controls the intensity of shading concave angles between walls and
|
|
6781
|
+
doc: "Controls the intensity of ambient occlusion when shading concave angles between walls and roof crevices and windows.",
|
|
6699
6782
|
"sdk-support": {
|
|
6700
6783
|
"basic functionality": {
|
|
6701
6784
|
}
|
|
@@ -6799,7 +6882,7 @@
|
|
|
6799
6882
|
"building-color": {
|
|
6800
6883
|
type: "color",
|
|
6801
6884
|
"default": "rgba(193, 154, 127, 1)",
|
|
6802
|
-
doc: "Color buildings. This can be styled using different building parts (e.g.
|
|
6885
|
+
doc: "Color buildings. This can be styled using different building parts (e.g. window, wall, roof).",
|
|
6803
6886
|
experimental: true,
|
|
6804
6887
|
"private": true,
|
|
6805
6888
|
"use-theme": true,
|
|
@@ -6814,7 +6897,8 @@
|
|
|
6814
6897
|
interpolated: true,
|
|
6815
6898
|
parameters: [
|
|
6816
6899
|
"feature",
|
|
6817
|
-
"feature-state"
|
|
6900
|
+
"feature-state",
|
|
6901
|
+
"measure-light"
|
|
6818
6902
|
]
|
|
6819
6903
|
},
|
|
6820
6904
|
"property-type": "data-driven"
|
|
@@ -6823,7 +6907,9 @@
|
|
|
6823
6907
|
type: "number",
|
|
6824
6908
|
"default": 0,
|
|
6825
6909
|
minimum: 0,
|
|
6826
|
-
|
|
6910
|
+
maximum: 5,
|
|
6911
|
+
units: "intensity",
|
|
6912
|
+
doc: "Controls the intensity of light emitted on the source features. There is no emission for value 0. For value 1.0, only emissive component (no shading) is displayed and values above 1.0 produce light contribution to surrounding area, for some of the parts (e.g. doors).",
|
|
6827
6913
|
experimental: true,
|
|
6828
6914
|
"private": true,
|
|
6829
6915
|
"sdk-support": {
|
|
@@ -6841,6 +6927,42 @@
|
|
|
6841
6927
|
]
|
|
6842
6928
|
},
|
|
6843
6929
|
"property-type": "data-driven"
|
|
6930
|
+
},
|
|
6931
|
+
"building-facade-emissive-chance": {
|
|
6932
|
+
type: "number",
|
|
6933
|
+
"default": 0.35,
|
|
6934
|
+
minimum: 0,
|
|
6935
|
+
maximum: 1,
|
|
6936
|
+
doc: "Given as a fraction specifies the likelihood for the facades to be emissive when building-facade is enabled. A value of 0.0 means the window will never be emissive, while a value of 1.0 means the window will always be emissive. This can be used to create variations on a building where some windows are lit and some are not.",
|
|
6937
|
+
experimental: true,
|
|
6938
|
+
"property-type": "data-constant",
|
|
6939
|
+
"sdk-support": {
|
|
6940
|
+
"basic functionality": {
|
|
6941
|
+
}
|
|
6942
|
+
},
|
|
6943
|
+
expression: {
|
|
6944
|
+
interpolated: true,
|
|
6945
|
+
parameters: [
|
|
6946
|
+
"measure-light",
|
|
6947
|
+
"zoom"
|
|
6948
|
+
]
|
|
6949
|
+
}
|
|
6950
|
+
},
|
|
6951
|
+
"building-cutoff-fade-range": {
|
|
6952
|
+
type: "number",
|
|
6953
|
+
"default": 0,
|
|
6954
|
+
minimum: 0,
|
|
6955
|
+
maximum: 1,
|
|
6956
|
+
doc: "This parameter defines the range for the fade-out effect before an automatic content cutoff on pitched map views. Fade out is implemented by scaling down and removing buildings in the fade range in a staggered fashion. Opacity is not changed. The fade range is expressed in relation to the height of the map view. A value of 1.0 indicates that the content is faded to the same extent as the map's height in pixels, while a value close to zero represents a sharp cutoff. When the value is set to 0.0, the cutoff is completely disabled. Note: The property has no effect on the map if terrain is enabled.",
|
|
6957
|
+
transition: false,
|
|
6958
|
+
expression: {
|
|
6959
|
+
interpolated: false
|
|
6960
|
+
},
|
|
6961
|
+
"sdk-support": {
|
|
6962
|
+
"basic functionality": {
|
|
6963
|
+
}
|
|
6964
|
+
},
|
|
6965
|
+
"property-type": "data-constant"
|
|
6844
6966
|
}
|
|
6845
6967
|
};
|
|
6846
6968
|
var paint_line = {
|
|
@@ -14111,305 +14233,309 @@
|
|
|
14111
14233
|
}
|
|
14112
14234
|
}
|
|
14113
14235
|
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
* @param {Number} y the y-coordinate. this could be latitude or screen
|
|
14129
|
-
* pixels, or any other sort of unit.
|
|
14130
|
-
* @example
|
|
14131
|
-
* var point = new Point(-77, 38);
|
|
14132
|
-
*/
|
|
14133
|
-
function Point(x, y) {
|
|
14134
|
-
this.x = x;
|
|
14135
|
-
this.y = y;
|
|
14136
|
-
}
|
|
14137
|
-
Point.prototype = {
|
|
14138
|
-
/**
|
|
14139
|
-
* Clone this point, returning a new point that can be modified
|
|
14140
|
-
* without affecting the old one.
|
|
14141
|
-
* @return {Point} the clone
|
|
14142
|
-
*/
|
|
14143
|
-
clone: function () {
|
|
14144
|
-
return new Point(this.x, this.y);
|
|
14145
|
-
},
|
|
14146
|
-
/**
|
|
14147
|
-
* Add this point's x & y coordinates to another point,
|
|
14148
|
-
* yielding a new point.
|
|
14149
|
-
* @param {Point} p the other point
|
|
14150
|
-
* @return {Point} output point
|
|
14151
|
-
*/
|
|
14152
|
-
add: function (p) {
|
|
14153
|
-
return this.clone()._add(p);
|
|
14154
|
-
},
|
|
14155
|
-
/**
|
|
14156
|
-
* Subtract this point's x & y coordinates to from point,
|
|
14157
|
-
* yielding a new point.
|
|
14158
|
-
* @param {Point} p the other point
|
|
14159
|
-
* @return {Point} output point
|
|
14160
|
-
*/
|
|
14161
|
-
sub: function (p) {
|
|
14162
|
-
return this.clone()._sub(p);
|
|
14163
|
-
},
|
|
14164
|
-
/**
|
|
14165
|
-
* Multiply this point's x & y coordinates by point,
|
|
14166
|
-
* yielding a new point.
|
|
14167
|
-
* @param {Point} p the other point
|
|
14168
|
-
* @return {Point} output point
|
|
14169
|
-
*/
|
|
14170
|
-
multByPoint: function (p) {
|
|
14171
|
-
return this.clone()._multByPoint(p);
|
|
14172
|
-
},
|
|
14173
|
-
/**
|
|
14174
|
-
* Divide this point's x & y coordinates by point,
|
|
14175
|
-
* yielding a new point.
|
|
14176
|
-
* @param {Point} p the other point
|
|
14177
|
-
* @return {Point} output point
|
|
14178
|
-
*/
|
|
14179
|
-
divByPoint: function (p) {
|
|
14180
|
-
return this.clone()._divByPoint(p);
|
|
14181
|
-
},
|
|
14182
|
-
/**
|
|
14183
|
-
* Multiply this point's x & y coordinates by a factor,
|
|
14184
|
-
* yielding a new point.
|
|
14185
|
-
* @param {Point} k factor
|
|
14186
|
-
* @return {Point} output point
|
|
14187
|
-
*/
|
|
14188
|
-
mult: function (k) {
|
|
14189
|
-
return this.clone()._mult(k);
|
|
14190
|
-
},
|
|
14191
|
-
/**
|
|
14192
|
-
* Divide this point's x & y coordinates by a factor,
|
|
14193
|
-
* yielding a new point.
|
|
14194
|
-
* @param {Point} k factor
|
|
14195
|
-
* @return {Point} output point
|
|
14196
|
-
*/
|
|
14197
|
-
div: function (k) {
|
|
14198
|
-
return this.clone()._div(k);
|
|
14199
|
-
},
|
|
14200
|
-
/**
|
|
14201
|
-
* Rotate this point around the 0, 0 origin by an angle a,
|
|
14202
|
-
* given in radians
|
|
14203
|
-
* @param {Number} a angle to rotate around, in radians
|
|
14204
|
-
* @return {Point} output point
|
|
14205
|
-
*/
|
|
14206
|
-
rotate: function (a) {
|
|
14207
|
-
return this.clone()._rotate(a);
|
|
14208
|
-
},
|
|
14209
|
-
/**
|
|
14210
|
-
* Rotate this point around p point by an angle a,
|
|
14211
|
-
* given in radians
|
|
14212
|
-
* @param {Number} a angle to rotate around, in radians
|
|
14213
|
-
* @param {Point} p Point to rotate around
|
|
14214
|
-
* @return {Point} output point
|
|
14215
|
-
*/
|
|
14216
|
-
rotateAround: function (a, p) {
|
|
14217
|
-
return this.clone()._rotateAround(a, p);
|
|
14218
|
-
},
|
|
14219
|
-
/**
|
|
14220
|
-
* Multiply this point by a 4x1 transformation matrix
|
|
14221
|
-
* @param {Array<Number>} m transformation matrix
|
|
14222
|
-
* @return {Point} output point
|
|
14223
|
-
*/
|
|
14224
|
-
matMult: function (m) {
|
|
14225
|
-
return this.clone()._matMult(m);
|
|
14226
|
-
},
|
|
14227
|
-
/**
|
|
14228
|
-
* Calculate this point but as a unit vector from 0, 0, meaning
|
|
14229
|
-
* that the distance from the resulting point to the 0, 0
|
|
14230
|
-
* coordinate will be equal to 1 and the angle from the resulting
|
|
14231
|
-
* point to the 0, 0 coordinate will be the same as before.
|
|
14232
|
-
* @return {Point} unit vector point
|
|
14233
|
-
*/
|
|
14234
|
-
unit: function () {
|
|
14235
|
-
return this.clone()._unit();
|
|
14236
|
-
},
|
|
14237
|
-
/**
|
|
14238
|
-
* Compute a perpendicular point, where the new y coordinate
|
|
14239
|
-
* is the old x coordinate and the new x coordinate is the old y
|
|
14240
|
-
* coordinate multiplied by -1
|
|
14241
|
-
* @return {Point} perpendicular point
|
|
14242
|
-
*/
|
|
14243
|
-
perp: function () {
|
|
14244
|
-
return this.clone()._perp();
|
|
14245
|
-
},
|
|
14246
|
-
/**
|
|
14247
|
-
* Return a version of this point with the x & y coordinates
|
|
14248
|
-
* rounded to integers.
|
|
14249
|
-
* @return {Point} rounded point
|
|
14250
|
-
*/
|
|
14251
|
-
round: function () {
|
|
14252
|
-
return this.clone()._round();
|
|
14253
|
-
},
|
|
14254
|
-
/**
|
|
14255
|
-
* Return the magitude of this point: this is the Euclidean
|
|
14256
|
-
* distance from the 0, 0 coordinate to this point's x and y
|
|
14257
|
-
* coordinates.
|
|
14258
|
-
* @return {Number} magnitude
|
|
14259
|
-
*/
|
|
14260
|
-
mag: function () {
|
|
14261
|
-
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
14262
|
-
},
|
|
14263
|
-
/**
|
|
14264
|
-
* Judge whether this point is equal to another point, returning
|
|
14265
|
-
* true or false.
|
|
14266
|
-
* @param {Point} other the other point
|
|
14267
|
-
* @return {boolean} whether the points are equal
|
|
14268
|
-
*/
|
|
14269
|
-
equals: function (other) {
|
|
14270
|
-
return this.x === other.x && this.y === other.y;
|
|
14271
|
-
},
|
|
14272
|
-
/**
|
|
14273
|
-
* Calculate the distance from this point to another point
|
|
14274
|
-
* @param {Point} p the other point
|
|
14275
|
-
* @return {Number} distance
|
|
14276
|
-
*/
|
|
14277
|
-
dist: function (p) {
|
|
14278
|
-
return Math.sqrt(this.distSqr(p));
|
|
14279
|
-
},
|
|
14280
|
-
/**
|
|
14281
|
-
* Calculate the distance from this point to another point,
|
|
14282
|
-
* without the square root step. Useful if you're comparing
|
|
14283
|
-
* relative distances.
|
|
14284
|
-
* @param {Point} p the other point
|
|
14285
|
-
* @return {Number} distance
|
|
14286
|
-
*/
|
|
14287
|
-
distSqr: function (p) {
|
|
14288
|
-
var dx = p.x - this.x, dy = p.y - this.y;
|
|
14289
|
-
return dx * dx + dy * dy;
|
|
14290
|
-
},
|
|
14291
|
-
/**
|
|
14292
|
-
* Get the angle from the 0, 0 coordinate to this point, in radians
|
|
14293
|
-
* coordinates.
|
|
14294
|
-
* @return {Number} angle
|
|
14295
|
-
*/
|
|
14296
|
-
angle: function () {
|
|
14297
|
-
return Math.atan2(this.y, this.x);
|
|
14298
|
-
},
|
|
14299
|
-
/**
|
|
14300
|
-
* Get the angle from this point to another point, in radians
|
|
14301
|
-
* @param {Point} b the other point
|
|
14302
|
-
* @return {Number} angle
|
|
14303
|
-
*/
|
|
14304
|
-
angleTo: function (b) {
|
|
14305
|
-
return Math.atan2(this.y - b.y, this.x - b.x);
|
|
14306
|
-
},
|
|
14307
|
-
/**
|
|
14308
|
-
* Get the angle between this point and another point, in radians
|
|
14309
|
-
* @param {Point} b the other point
|
|
14310
|
-
* @return {Number} angle
|
|
14311
|
-
*/
|
|
14312
|
-
angleWith: function (b) {
|
|
14313
|
-
return this.angleWithSep(b.x, b.y);
|
|
14314
|
-
},
|
|
14315
|
-
/*
|
|
14316
|
-
* Find the angle of the two vectors, solving the formula for
|
|
14317
|
-
* the cross product a x b = |a||b|sin(θ) for θ.
|
|
14318
|
-
* @param {Number} x the x-coordinate
|
|
14319
|
-
* @param {Number} y the y-coordinate
|
|
14320
|
-
* @return {Number} the angle in radians
|
|
14321
|
-
*/
|
|
14322
|
-
angleWithSep: function (x, y) {
|
|
14323
|
-
return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
|
|
14324
|
-
},
|
|
14325
|
-
_matMult: function (m) {
|
|
14326
|
-
var x = m[0] * this.x + m[1] * this.y, y = m[2] * this.x + m[3] * this.y;
|
|
14327
|
-
this.x = x;
|
|
14328
|
-
this.y = y;
|
|
14329
|
-
return this;
|
|
14330
|
-
},
|
|
14331
|
-
_add: function (p) {
|
|
14332
|
-
this.x += p.x;
|
|
14333
|
-
this.y += p.y;
|
|
14334
|
-
return this;
|
|
14335
|
-
},
|
|
14336
|
-
_sub: function (p) {
|
|
14337
|
-
this.x -= p.x;
|
|
14338
|
-
this.y -= p.y;
|
|
14339
|
-
return this;
|
|
14340
|
-
},
|
|
14341
|
-
_mult: function (k) {
|
|
14342
|
-
this.x *= k;
|
|
14343
|
-
this.y *= k;
|
|
14344
|
-
return this;
|
|
14345
|
-
},
|
|
14346
|
-
_div: function (k) {
|
|
14347
|
-
this.x /= k;
|
|
14348
|
-
this.y /= k;
|
|
14349
|
-
return this;
|
|
14350
|
-
},
|
|
14351
|
-
_multByPoint: function (p) {
|
|
14352
|
-
this.x *= p.x;
|
|
14353
|
-
this.y *= p.y;
|
|
14354
|
-
return this;
|
|
14355
|
-
},
|
|
14356
|
-
_divByPoint: function (p) {
|
|
14357
|
-
this.x /= p.x;
|
|
14358
|
-
this.y /= p.y;
|
|
14359
|
-
return this;
|
|
14360
|
-
},
|
|
14361
|
-
_unit: function () {
|
|
14362
|
-
this._div(this.mag());
|
|
14363
|
-
return this;
|
|
14364
|
-
},
|
|
14365
|
-
_perp: function () {
|
|
14366
|
-
var y = this.y;
|
|
14367
|
-
this.y = this.x;
|
|
14368
|
-
this.x = -y;
|
|
14369
|
-
return this;
|
|
14370
|
-
},
|
|
14371
|
-
_rotate: function (angle) {
|
|
14372
|
-
var cos = Math.cos(angle), sin = Math.sin(angle), x = cos * this.x - sin * this.y, y = sin * this.x + cos * this.y;
|
|
14373
|
-
this.x = x;
|
|
14374
|
-
this.y = y;
|
|
14375
|
-
return this;
|
|
14376
|
-
},
|
|
14377
|
-
_rotateAround: function (angle, p) {
|
|
14378
|
-
var cos = Math.cos(angle), sin = Math.sin(angle), x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y), y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
|
|
14379
|
-
this.x = x;
|
|
14380
|
-
this.y = y;
|
|
14381
|
-
return this;
|
|
14382
|
-
},
|
|
14383
|
-
_round: function () {
|
|
14384
|
-
this.x = Math.round(this.x);
|
|
14385
|
-
this.y = Math.round(this.y);
|
|
14386
|
-
return this;
|
|
14387
|
-
}
|
|
14388
|
-
};
|
|
14389
|
-
/**
|
|
14390
|
-
* Construct a point from an array if necessary, otherwise if the input
|
|
14391
|
-
* is already a Point, or an unknown type, return it unchanged
|
|
14392
|
-
* @param {Array<Number>|Point|*} a any kind of input value
|
|
14393
|
-
* @return {Point} constructed point, or passed-through value.
|
|
14394
|
-
* @example
|
|
14395
|
-
* // this
|
|
14396
|
-
* var point = Point.convert([0, 1]);
|
|
14397
|
-
* // is equivalent to
|
|
14398
|
-
* var point = new Point(0, 1);
|
|
14399
|
-
*/
|
|
14400
|
-
Point.convert = function (a) {
|
|
14401
|
-
if (a instanceof Point) {
|
|
14402
|
-
return a;
|
|
14403
|
-
}
|
|
14404
|
-
if (Array.isArray(a)) {
|
|
14405
|
-
return new Point(a[0], a[1]);
|
|
14406
|
-
}
|
|
14407
|
-
return a;
|
|
14408
|
-
};
|
|
14409
|
-
return pointGeometry;
|
|
14236
|
+
/**
|
|
14237
|
+
* A standalone point geometry with useful accessor, comparison, and
|
|
14238
|
+
* modification methods.
|
|
14239
|
+
*
|
|
14240
|
+
* @class
|
|
14241
|
+
* @param {number} x the x-coordinate. This could be longitude or screen pixels, or any other sort of unit.
|
|
14242
|
+
* @param {number} y the y-coordinate. This could be latitude or screen pixels, or any other sort of unit.
|
|
14243
|
+
*
|
|
14244
|
+
* @example
|
|
14245
|
+
* const point = new Point(-77, 38);
|
|
14246
|
+
*/
|
|
14247
|
+
function Point(x, y) {
|
|
14248
|
+
this.x = x;
|
|
14249
|
+
this.y = y;
|
|
14410
14250
|
}
|
|
14411
|
-
|
|
14412
|
-
|
|
14251
|
+
Point.prototype = {
|
|
14252
|
+
/**
|
|
14253
|
+
* Clone this point, returning a new point that can be modified
|
|
14254
|
+
* without affecting the old one.
|
|
14255
|
+
* @return {Point} the clone
|
|
14256
|
+
*/
|
|
14257
|
+
clone() {
|
|
14258
|
+
return new Point(this.x, this.y);
|
|
14259
|
+
},
|
|
14260
|
+
/**
|
|
14261
|
+
* Add this point's x & y coordinates to another point,
|
|
14262
|
+
* yielding a new point.
|
|
14263
|
+
* @param {Point} p the other point
|
|
14264
|
+
* @return {Point} output point
|
|
14265
|
+
*/
|
|
14266
|
+
add(p) {
|
|
14267
|
+
return this.clone()._add(p);
|
|
14268
|
+
},
|
|
14269
|
+
/**
|
|
14270
|
+
* Subtract this point's x & y coordinates to from point,
|
|
14271
|
+
* yielding a new point.
|
|
14272
|
+
* @param {Point} p the other point
|
|
14273
|
+
* @return {Point} output point
|
|
14274
|
+
*/
|
|
14275
|
+
sub(p) {
|
|
14276
|
+
return this.clone()._sub(p);
|
|
14277
|
+
},
|
|
14278
|
+
/**
|
|
14279
|
+
* Multiply this point's x & y coordinates by point,
|
|
14280
|
+
* yielding a new point.
|
|
14281
|
+
* @param {Point} p the other point
|
|
14282
|
+
* @return {Point} output point
|
|
14283
|
+
*/
|
|
14284
|
+
multByPoint(p) {
|
|
14285
|
+
return this.clone()._multByPoint(p);
|
|
14286
|
+
},
|
|
14287
|
+
/**
|
|
14288
|
+
* Divide this point's x & y coordinates by point,
|
|
14289
|
+
* yielding a new point.
|
|
14290
|
+
* @param {Point} p the other point
|
|
14291
|
+
* @return {Point} output point
|
|
14292
|
+
*/
|
|
14293
|
+
divByPoint(p) {
|
|
14294
|
+
return this.clone()._divByPoint(p);
|
|
14295
|
+
},
|
|
14296
|
+
/**
|
|
14297
|
+
* Multiply this point's x & y coordinates by a factor,
|
|
14298
|
+
* yielding a new point.
|
|
14299
|
+
* @param {number} k factor
|
|
14300
|
+
* @return {Point} output point
|
|
14301
|
+
*/
|
|
14302
|
+
mult(k) {
|
|
14303
|
+
return this.clone()._mult(k);
|
|
14304
|
+
},
|
|
14305
|
+
/**
|
|
14306
|
+
* Divide this point's x & y coordinates by a factor,
|
|
14307
|
+
* yielding a new point.
|
|
14308
|
+
* @param {number} k factor
|
|
14309
|
+
* @return {Point} output point
|
|
14310
|
+
*/
|
|
14311
|
+
div(k) {
|
|
14312
|
+
return this.clone()._div(k);
|
|
14313
|
+
},
|
|
14314
|
+
/**
|
|
14315
|
+
* Rotate this point around the 0, 0 origin by an angle a,
|
|
14316
|
+
* given in radians
|
|
14317
|
+
* @param {number} a angle to rotate around, in radians
|
|
14318
|
+
* @return {Point} output point
|
|
14319
|
+
*/
|
|
14320
|
+
rotate(a) {
|
|
14321
|
+
return this.clone()._rotate(a);
|
|
14322
|
+
},
|
|
14323
|
+
/**
|
|
14324
|
+
* Rotate this point around p point by an angle a,
|
|
14325
|
+
* given in radians
|
|
14326
|
+
* @param {number} a angle to rotate around, in radians
|
|
14327
|
+
* @param {Point} p Point to rotate around
|
|
14328
|
+
* @return {Point} output point
|
|
14329
|
+
*/
|
|
14330
|
+
rotateAround(a, p) {
|
|
14331
|
+
return this.clone()._rotateAround(a, p);
|
|
14332
|
+
},
|
|
14333
|
+
/**
|
|
14334
|
+
* Multiply this point by a 4x1 transformation matrix
|
|
14335
|
+
* @param {[number, number, number, number]} m transformation matrix
|
|
14336
|
+
* @return {Point} output point
|
|
14337
|
+
*/
|
|
14338
|
+
matMult(m) {
|
|
14339
|
+
return this.clone()._matMult(m);
|
|
14340
|
+
},
|
|
14341
|
+
/**
|
|
14342
|
+
* Calculate this point but as a unit vector from 0, 0, meaning
|
|
14343
|
+
* that the distance from the resulting point to the 0, 0
|
|
14344
|
+
* coordinate will be equal to 1 and the angle from the resulting
|
|
14345
|
+
* point to the 0, 0 coordinate will be the same as before.
|
|
14346
|
+
* @return {Point} unit vector point
|
|
14347
|
+
*/
|
|
14348
|
+
unit() {
|
|
14349
|
+
return this.clone()._unit();
|
|
14350
|
+
},
|
|
14351
|
+
/**
|
|
14352
|
+
* Compute a perpendicular point, where the new y coordinate
|
|
14353
|
+
* is the old x coordinate and the new x coordinate is the old y
|
|
14354
|
+
* coordinate multiplied by -1
|
|
14355
|
+
* @return {Point} perpendicular point
|
|
14356
|
+
*/
|
|
14357
|
+
perp() {
|
|
14358
|
+
return this.clone()._perp();
|
|
14359
|
+
},
|
|
14360
|
+
/**
|
|
14361
|
+
* Return a version of this point with the x & y coordinates
|
|
14362
|
+
* rounded to integers.
|
|
14363
|
+
* @return {Point} rounded point
|
|
14364
|
+
*/
|
|
14365
|
+
round() {
|
|
14366
|
+
return this.clone()._round();
|
|
14367
|
+
},
|
|
14368
|
+
/**
|
|
14369
|
+
* Return the magnitude of this point: this is the Euclidean
|
|
14370
|
+
* distance from the 0, 0 coordinate to this point's x and y
|
|
14371
|
+
* coordinates.
|
|
14372
|
+
* @return {number} magnitude
|
|
14373
|
+
*/
|
|
14374
|
+
mag() {
|
|
14375
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
14376
|
+
},
|
|
14377
|
+
/**
|
|
14378
|
+
* Judge whether this point is equal to another point, returning
|
|
14379
|
+
* true or false.
|
|
14380
|
+
* @param {Point} other the other point
|
|
14381
|
+
* @return {boolean} whether the points are equal
|
|
14382
|
+
*/
|
|
14383
|
+
equals(other) {
|
|
14384
|
+
return this.x === other.x && this.y === other.y;
|
|
14385
|
+
},
|
|
14386
|
+
/**
|
|
14387
|
+
* Calculate the distance from this point to another point
|
|
14388
|
+
* @param {Point} p the other point
|
|
14389
|
+
* @return {number} distance
|
|
14390
|
+
*/
|
|
14391
|
+
dist(p) {
|
|
14392
|
+
return Math.sqrt(this.distSqr(p));
|
|
14393
|
+
},
|
|
14394
|
+
/**
|
|
14395
|
+
* Calculate the distance from this point to another point,
|
|
14396
|
+
* without the square root step. Useful if you're comparing
|
|
14397
|
+
* relative distances.
|
|
14398
|
+
* @param {Point} p the other point
|
|
14399
|
+
* @return {number} distance
|
|
14400
|
+
*/
|
|
14401
|
+
distSqr(p) {
|
|
14402
|
+
const dx = p.x - this.x, dy = p.y - this.y;
|
|
14403
|
+
return dx * dx + dy * dy;
|
|
14404
|
+
},
|
|
14405
|
+
/**
|
|
14406
|
+
* Get the angle from the 0, 0 coordinate to this point, in radians
|
|
14407
|
+
* coordinates.
|
|
14408
|
+
* @return {number} angle
|
|
14409
|
+
*/
|
|
14410
|
+
angle() {
|
|
14411
|
+
return Math.atan2(this.y, this.x);
|
|
14412
|
+
},
|
|
14413
|
+
/**
|
|
14414
|
+
* Get the angle from this point to another point, in radians
|
|
14415
|
+
* @param {Point} b the other point
|
|
14416
|
+
* @return {number} angle
|
|
14417
|
+
*/
|
|
14418
|
+
angleTo(b) {
|
|
14419
|
+
return Math.atan2(this.y - b.y, this.x - b.x);
|
|
14420
|
+
},
|
|
14421
|
+
/**
|
|
14422
|
+
* Get the angle between this point and another point, in radians
|
|
14423
|
+
* @param {Point} b the other point
|
|
14424
|
+
* @return {number} angle
|
|
14425
|
+
*/
|
|
14426
|
+
angleWith(b) {
|
|
14427
|
+
return this.angleWithSep(b.x, b.y);
|
|
14428
|
+
},
|
|
14429
|
+
/**
|
|
14430
|
+
* Find the angle of the two vectors, solving the formula for
|
|
14431
|
+
* the cross product a x b = |a||b|sin(θ) for θ.
|
|
14432
|
+
* @param {number} x the x-coordinate
|
|
14433
|
+
* @param {number} y the y-coordinate
|
|
14434
|
+
* @return {number} the angle in radians
|
|
14435
|
+
*/
|
|
14436
|
+
angleWithSep(x, y) {
|
|
14437
|
+
return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
|
|
14438
|
+
},
|
|
14439
|
+
/** @param {[number, number, number, number]} m */
|
|
14440
|
+
_matMult(m) {
|
|
14441
|
+
const x = m[0] * this.x + m[1] * this.y, y = m[2] * this.x + m[3] * this.y;
|
|
14442
|
+
this.x = x;
|
|
14443
|
+
this.y = y;
|
|
14444
|
+
return this;
|
|
14445
|
+
},
|
|
14446
|
+
/** @param {Point} p */
|
|
14447
|
+
_add(p) {
|
|
14448
|
+
this.x += p.x;
|
|
14449
|
+
this.y += p.y;
|
|
14450
|
+
return this;
|
|
14451
|
+
},
|
|
14452
|
+
/** @param {Point} p */
|
|
14453
|
+
_sub(p) {
|
|
14454
|
+
this.x -= p.x;
|
|
14455
|
+
this.y -= p.y;
|
|
14456
|
+
return this;
|
|
14457
|
+
},
|
|
14458
|
+
/** @param {number} k */
|
|
14459
|
+
_mult(k) {
|
|
14460
|
+
this.x *= k;
|
|
14461
|
+
this.y *= k;
|
|
14462
|
+
return this;
|
|
14463
|
+
},
|
|
14464
|
+
/** @param {number} k */
|
|
14465
|
+
_div(k) {
|
|
14466
|
+
this.x /= k;
|
|
14467
|
+
this.y /= k;
|
|
14468
|
+
return this;
|
|
14469
|
+
},
|
|
14470
|
+
/** @param {Point} p */
|
|
14471
|
+
_multByPoint(p) {
|
|
14472
|
+
this.x *= p.x;
|
|
14473
|
+
this.y *= p.y;
|
|
14474
|
+
return this;
|
|
14475
|
+
},
|
|
14476
|
+
/** @param {Point} p */
|
|
14477
|
+
_divByPoint(p) {
|
|
14478
|
+
this.x /= p.x;
|
|
14479
|
+
this.y /= p.y;
|
|
14480
|
+
return this;
|
|
14481
|
+
},
|
|
14482
|
+
_unit() {
|
|
14483
|
+
this._div(this.mag());
|
|
14484
|
+
return this;
|
|
14485
|
+
},
|
|
14486
|
+
_perp() {
|
|
14487
|
+
const y = this.y;
|
|
14488
|
+
this.y = this.x;
|
|
14489
|
+
this.x = -y;
|
|
14490
|
+
return this;
|
|
14491
|
+
},
|
|
14492
|
+
/** @param {number} angle */
|
|
14493
|
+
_rotate(angle) {
|
|
14494
|
+
const cos = Math.cos(angle), sin = Math.sin(angle), x = cos * this.x - sin * this.y, y = sin * this.x + cos * this.y;
|
|
14495
|
+
this.x = x;
|
|
14496
|
+
this.y = y;
|
|
14497
|
+
return this;
|
|
14498
|
+
},
|
|
14499
|
+
/**
|
|
14500
|
+
* @param {number} angle
|
|
14501
|
+
* @param {Point} p
|
|
14502
|
+
*/
|
|
14503
|
+
_rotateAround(angle, p) {
|
|
14504
|
+
const cos = Math.cos(angle), sin = Math.sin(angle), x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y), y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
|
|
14505
|
+
this.x = x;
|
|
14506
|
+
this.y = y;
|
|
14507
|
+
return this;
|
|
14508
|
+
},
|
|
14509
|
+
_round() {
|
|
14510
|
+
this.x = Math.round(this.x);
|
|
14511
|
+
this.y = Math.round(this.y);
|
|
14512
|
+
return this;
|
|
14513
|
+
},
|
|
14514
|
+
constructor: Point
|
|
14515
|
+
};
|
|
14516
|
+
/**
|
|
14517
|
+
* Construct a point from an array if necessary, otherwise if the input
|
|
14518
|
+
* is already a Point, return it unchanged.
|
|
14519
|
+
* @param {Point | [number, number] | {x: number, y: number}} p input value
|
|
14520
|
+
* @return {Point} constructed point.
|
|
14521
|
+
* @example
|
|
14522
|
+
* // this
|
|
14523
|
+
* var point = Point.convert([0, 1]);
|
|
14524
|
+
* // is equivalent to
|
|
14525
|
+
* var point = new Point(0, 1);
|
|
14526
|
+
*/
|
|
14527
|
+
Point.convert = function (p) {
|
|
14528
|
+
if (p instanceof Point) {
|
|
14529
|
+
return p;
|
|
14530
|
+
}
|
|
14531
|
+
if (Array.isArray(p)) {
|
|
14532
|
+
return new Point(+p[0], +p[1]);
|
|
14533
|
+
}
|
|
14534
|
+
if (p.x !== undefined && p.y !== undefined) {
|
|
14535
|
+
return new Point(+p.x, +p.y);
|
|
14536
|
+
}
|
|
14537
|
+
throw new Error('Expected [x, y] or {x, y} point format');
|
|
14538
|
+
};
|
|
14413
14539
|
|
|
14414
14540
|
function calculateSignedArea(ring) {
|
|
14415
14541
|
let sum = 0;
|
|
@@ -17365,6 +17491,43 @@
|
|
|
17365
17491
|
}
|
|
17366
17492
|
}
|
|
17367
17493
|
|
|
17494
|
+
class Split {
|
|
17495
|
+
constructor(str, delimiter) {
|
|
17496
|
+
this.type = array$1(StringType);
|
|
17497
|
+
this.str = str;
|
|
17498
|
+
this.delimiter = delimiter;
|
|
17499
|
+
}
|
|
17500
|
+
static parse(args, context) {
|
|
17501
|
+
if (args.length !== 3) {
|
|
17502
|
+
return context.error(`Expected 2 arguments, but found ${ args.length - 1 } instead.`);
|
|
17503
|
+
}
|
|
17504
|
+
const str = context.parse(args[1], 1, StringType);
|
|
17505
|
+
const delimiter = context.parse(args[2], 2, StringType);
|
|
17506
|
+
if (!str || !delimiter)
|
|
17507
|
+
return;
|
|
17508
|
+
return new Split(str, delimiter);
|
|
17509
|
+
}
|
|
17510
|
+
evaluate(ctx) {
|
|
17511
|
+
const str = this.str.evaluate(ctx);
|
|
17512
|
+
const delimiter = this.delimiter.evaluate(ctx);
|
|
17513
|
+
return str.split(delimiter);
|
|
17514
|
+
}
|
|
17515
|
+
eachChild(fn) {
|
|
17516
|
+
fn(this.str);
|
|
17517
|
+
fn(this.delimiter);
|
|
17518
|
+
}
|
|
17519
|
+
outputDefined() {
|
|
17520
|
+
return false;
|
|
17521
|
+
}
|
|
17522
|
+
serialize() {
|
|
17523
|
+
return [
|
|
17524
|
+
'split',
|
|
17525
|
+
this.str.serialize(),
|
|
17526
|
+
this.delimiter.serialize()
|
|
17527
|
+
];
|
|
17528
|
+
}
|
|
17529
|
+
}
|
|
17530
|
+
|
|
17368
17531
|
function isComparableType(op, type) {
|
|
17369
17532
|
if (op === '==' || op === '!=') {
|
|
17370
17533
|
return type.kind === 'boolean' || type.kind === 'string' || type.kind === 'number' || type.kind === 'null' || type.kind === 'value';
|
|
@@ -17696,7 +17859,8 @@
|
|
|
17696
17859
|
'var': Var,
|
|
17697
17860
|
'within': Within,
|
|
17698
17861
|
'distance': Distance,
|
|
17699
|
-
'config': Config
|
|
17862
|
+
'config': Config,
|
|
17863
|
+
'split': Split
|
|
17700
17864
|
};
|
|
17701
17865
|
function rgba(ctx, [r, g, b, a]) {
|
|
17702
17866
|
r = r.evaluate(ctx);
|