@mapwhit/tilerenderer 0.49.0 → 0.51.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.
Files changed (147) hide show
  1. package/build/min/package.json +1 -1
  2. package/build/min/src/shaders/.dir +0 -0
  3. package/build/min/src/shaders/_prelude.fragment.glsl.js +14 -0
  4. package/build/min/src/shaders/_prelude.vertex.glsl.js +14 -0
  5. package/build/min/src/shaders/background.fragment.glsl.js +5 -0
  6. package/build/min/src/shaders/background.vertex.glsl.js +1 -0
  7. package/build/min/src/shaders/background_pattern.fragment.glsl.js +5 -0
  8. package/build/min/src/shaders/background_pattern.vertex.glsl.js +1 -0
  9. package/build/min/src/shaders/circle.fragment.glsl.js +20 -0
  10. package/build/min/src/shaders/circle.vertex.glsl.js +17 -0
  11. package/build/min/src/shaders/clipping_mask.fragment.glsl.js +1 -0
  12. package/build/min/src/shaders/clipping_mask.vertex.glsl.js +1 -0
  13. package/build/min/src/shaders/collision_box.fragment.glsl.js +1 -0
  14. package/build/min/src/shaders/collision_box.vertex.glsl.js +1 -0
  15. package/build/min/src/shaders/collision_circle.fragment.glsl.js +1 -0
  16. package/build/min/src/shaders/collision_circle.vertex.glsl.js +1 -0
  17. package/build/min/src/shaders/debug.fragment.glsl.js +1 -0
  18. package/build/min/src/shaders/debug.vertex.glsl.js +1 -0
  19. package/build/min/src/shaders/fill.fragment.glsl.js +10 -0
  20. package/build/min/src/shaders/fill.vertex.glsl.js +7 -0
  21. package/build/min/src/shaders/fill_extrusion.fragment.glsl.js +5 -0
  22. package/build/min/src/shaders/fill_extrusion.fragment.glsl.txt +1 -9
  23. package/build/min/src/shaders/fill_extrusion.vertex.glsl.js +9 -0
  24. package/build/min/src/shaders/fill_extrusion.vertex.glsl.txt +4 -4
  25. package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.js +15 -0
  26. package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.js +11 -0
  27. package/build/min/src/shaders/fill_outline.fragment.glsl.js +10 -0
  28. package/build/min/src/shaders/fill_outline.vertex.glsl.js +7 -0
  29. package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.js +13 -0
  30. package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.js +9 -0
  31. package/build/min/src/shaders/fill_pattern.fragment.glsl.js +13 -0
  32. package/build/min/src/shaders/fill_pattern.vertex.glsl.js +9 -0
  33. package/build/min/src/shaders/heatmap.fragment.glsl.js +10 -0
  34. package/build/min/src/shaders/heatmap.vertex.glsl.js +8 -0
  35. package/build/min/src/shaders/heatmap_texture.fragment.glsl.js +5 -0
  36. package/build/min/src/shaders/heatmap_texture.vertex.glsl.js +1 -0
  37. package/build/min/src/shaders/hillshade.fragment.glsl.js +7 -0
  38. package/build/min/src/shaders/hillshade.vertex.glsl.js +1 -0
  39. package/build/min/src/shaders/hillshade_prepare.fragment.glsl.js +8 -0
  40. package/build/min/src/shaders/hillshade_prepare.vertex.glsl.js +1 -0
  41. package/build/min/src/shaders/line.fragment.glsl.js +12 -0
  42. package/build/min/src/shaders/line.vertex.glsl.js +17 -0
  43. package/build/min/src/shaders/line_gradient.fragment.glsl.js +10 -0
  44. package/build/min/src/shaders/line_gradient.vertex.glsl.js +16 -0
  45. package/build/min/src/shaders/line_pattern.fragment.glsl.js +15 -0
  46. package/build/min/src/shaders/line_pattern.vertex.glsl.js +20 -0
  47. package/build/min/src/shaders/line_sdf.fragment.glsl.js +17 -0
  48. package/build/min/src/shaders/line_sdf.vertex.glsl.js +20 -0
  49. package/build/min/src/shaders/raster.fragment.glsl.js +5 -0
  50. package/build/min/src/shaders/raster.vertex.glsl.js +1 -0
  51. package/build/min/src/shaders/symbol_icon.fragment.glsl.js +9 -0
  52. package/build/min/src/shaders/symbol_icon.vertex.glsl.js +5 -0
  53. package/build/min/src/shaders/symbol_sdf.fragment.glsl.js +19 -0
  54. package/build/min/src/shaders/symbol_sdf.vertex.glsl.js +13 -0
  55. package/package.json +7 -7
  56. package/src/data/bucket/fill_bucket.js +1 -1
  57. package/src/data/bucket/fill_extrusion_bucket.js +2 -2
  58. package/src/data/bucket/line_bucket.js +1 -1
  59. package/src/data/bucket/symbol_bucket.js +16 -15
  60. package/src/data/feature_index.js +1 -1
  61. package/src/data/program_configuration.js +1 -1
  62. package/src/gl/color_mode.js +1 -1
  63. package/src/gl/value.js +1 -1
  64. package/src/render/draw_debug.js +1 -1
  65. package/src/render/draw_fill.js +1 -1
  66. package/src/render/draw_heatmap.js +1 -1
  67. package/src/render/glyph_manager.js +6 -130
  68. package/src/render/painter.js +1 -1
  69. package/src/render/uniform_binding.js +1 -1
  70. package/src/shaders/fill_extrusion.fragment.glsl +0 -7
  71. package/src/shaders/fill_extrusion.vertex.glsl +4 -4
  72. package/src/shaders/index.js +50 -50
  73. package/src/source/geojson_worker_source.js +4 -4
  74. package/src/source/geojson_wrapper.js +34 -26
  75. package/src/source/resources/glyphs.js +73 -0
  76. package/src/source/resources/images.js +68 -0
  77. package/src/source/resources/index.js +22 -0
  78. package/src/source/vector_tile_worker_source.js +5 -5
  79. package/src/source/worker.js +6 -5
  80. package/src/source/worker_tile.js +4 -4
  81. package/src/style/properties.js +1 -2
  82. package/src/style/style.js +3 -3
  83. package/src/style/style_layer/symbol_style_layer.js +1 -1
  84. package/src/style/style_layer.js +1 -1
  85. package/src/style-spec/feature_filter/index.js +43 -34
  86. package/src/style-spec/group_by_layout.js +10 -32
  87. package/src/style-spec/reference/v8.json +1 -1
  88. package/src/symbol/mergelines.js +1 -3
  89. package/src/symbol/placement.js +21 -2
  90. package/src/symbol/shaping.js +9 -18
  91. package/src/symbol/symbol_layout.js +1 -2
  92. package/src/symbol/symbol_size.js +1 -1
  93. package/src/symbol/transform_text.js +4 -8
  94. package/src/ui/map.js +11 -39
  95. package/src/util/browser.js +3 -18
  96. package/src/util/classify_rings.js +1 -1
  97. package/src/util/dom.js +0 -88
  98. package/src/util/find_pole_of_inaccessibility.js +2 -2
  99. package/src/util/web_worker_transfer.js +4 -4
  100. package/src/style/load_glyph_range.js +0 -17
  101. package/src/style-spec/expression/compound_expression.js +0 -132
  102. package/src/style-spec/expression/definitions/assertion.js +0 -116
  103. package/src/style-spec/expression/definitions/at.js +0 -57
  104. package/src/style-spec/expression/definitions/case.js +0 -73
  105. package/src/style-spec/expression/definitions/coalesce.js +0 -68
  106. package/src/style-spec/expression/definitions/coercion.js +0 -109
  107. package/src/style-spec/expression/definitions/collator.js +0 -102
  108. package/src/style-spec/expression/definitions/comparison.js +0 -193
  109. package/src/style-spec/expression/definitions/formatted.js +0 -123
  110. package/src/style-spec/expression/definitions/index.js +0 -356
  111. package/src/style-spec/expression/definitions/interpolate.js +0 -245
  112. package/src/style-spec/expression/definitions/length.js +0 -54
  113. package/src/style-spec/expression/definitions/let.js +0 -60
  114. package/src/style-spec/expression/definitions/literal.js +0 -69
  115. package/src/style-spec/expression/definitions/match.js +0 -142
  116. package/src/style-spec/expression/definitions/step.js +0 -116
  117. package/src/style-spec/expression/definitions/var.js +0 -38
  118. package/src/style-spec/expression/evaluation_context.js +0 -35
  119. package/src/style-spec/expression/index.js +0 -329
  120. package/src/style-spec/expression/is_constant.js +0 -63
  121. package/src/style-spec/expression/parsing_context.js +0 -212
  122. package/src/style-spec/expression/parsing_error.js +0 -9
  123. package/src/style-spec/expression/runtime_error.js +0 -12
  124. package/src/style-spec/expression/scope.js +0 -34
  125. package/src/style-spec/expression/stops.js +0 -37
  126. package/src/style-spec/expression/types.js +0 -88
  127. package/src/style-spec/expression/values.js +0 -126
  128. package/src/style-spec/function/convert.js +0 -234
  129. package/src/style-spec/function/index.js +0 -299
  130. package/src/style-spec/util/color.js +0 -73
  131. package/src/style-spec/util/color_spaces.js +0 -128
  132. package/src/style-spec/util/get_type.js +0 -18
  133. package/src/style-spec/util/interpolate.js +0 -21
  134. package/src/style-spec/util/properties.js +0 -17
  135. package/src/style-spec/util/result.js +0 -19
  136. package/src/ui/anchor.js +0 -24
  137. package/src/ui/bind_handlers.js +0 -199
  138. package/src/ui/events.js +0 -210
  139. package/src/ui/handler/box_zoom.js +0 -151
  140. package/src/ui/handler/dblclick_zoom.js +0 -91
  141. package/src/ui/handler/drag_pan.js +0 -285
  142. package/src/ui/handler/drag_rotate.js +0 -290
  143. package/src/ui/handler/frame.js +0 -28
  144. package/src/ui/handler/inertia.js +0 -45
  145. package/src/ui/handler/keyboard.js +0 -148
  146. package/src/ui/handler/scroll_zoom.js +0 -284
  147. package/src/ui/handler/touch_zoom_rotate.js +0 -263
@@ -1,123 +0,0 @@
1
- const { NumberType, ValueType, FormattedType, array, StringType } = require('../types');
2
-
3
- class FormattedSection {
4
- constructor(text, scale, fontStack) {
5
- this.text = text;
6
- this.scale = scale;
7
- this.fontStack = fontStack;
8
- }
9
- }
10
-
11
- class Formatted {
12
- constructor(sections) {
13
- this.sections = sections;
14
- }
15
-
16
- toString() {
17
- return this.sections.map(section => section.text).join('');
18
- }
19
-
20
- serialize() {
21
- const serialized = ['format'];
22
- for (const section of this.sections) {
23
- serialized.push(section.text);
24
- const fontStack = section.fontStack ? ['literal', section.fontStack.split(',')] : null;
25
- serialized.push({ 'text-font': fontStack, 'font-scale': section.scale });
26
- }
27
- return serialized;
28
- }
29
- }
30
-
31
- class FormatExpression {
32
- constructor(sections) {
33
- this.type = FormattedType;
34
- this.sections = sections;
35
- }
36
-
37
- static parse(args, context) {
38
- if (args.length < 3) {
39
- return context.error('Expected at least two arguments.');
40
- }
41
-
42
- if ((args.length - 1) % 2 !== 0) {
43
- return context.error('Expected an even number of arguments.');
44
- }
45
-
46
- const sections = [];
47
- for (let i = 1; i < args.length - 1; i += 2) {
48
- const text = context.parse(args[i], 1, ValueType);
49
- if (!text) return null;
50
- const kind = text.type.kind;
51
- if (kind !== 'string' && kind !== 'value' && kind !== 'null')
52
- return context.error("Formatted text type must be 'string', 'value', or 'null'.");
53
-
54
- const options = args[i + 1];
55
- if (typeof options !== 'object' || Array.isArray(options))
56
- return context.error('Format options argument must be an object.');
57
-
58
- let scale = null;
59
- if (options['font-scale']) {
60
- scale = context.parse(options['font-scale'], 1, NumberType);
61
- if (!scale) return null;
62
- }
63
-
64
- let font = null;
65
- if (options['text-font']) {
66
- font = context.parse(options['text-font'], 1, array(StringType));
67
- if (!font) return null;
68
- }
69
- sections.push({ text, scale, font });
70
- }
71
-
72
- return new FormatExpression(sections);
73
- }
74
-
75
- evaluate(ctx) {
76
- return new Formatted(
77
- this.sections.map(
78
- section =>
79
- new FormattedSection(
80
- section.text.evaluate(ctx) || '',
81
- section.scale ? section.scale.evaluate(ctx) : null,
82
- section.font ? section.font.evaluate(ctx).join(',') : null
83
- )
84
- )
85
- );
86
- }
87
-
88
- eachChild(fn) {
89
- for (const section of this.sections) {
90
- fn(section.text);
91
- if (section.scale) {
92
- fn(section.scale);
93
- }
94
- if (section.font) {
95
- fn(section.font);
96
- }
97
- }
98
- }
99
-
100
- possibleOutputs() {
101
- // Technically the combinatoric set of all children
102
- // Usually, this.text will be undefined anyway
103
- return [undefined];
104
- }
105
-
106
- serialize() {
107
- const serialized = ['format'];
108
- for (const section of this.sections) {
109
- serialized.push(section.text.serialize());
110
- const options = {};
111
- if (section.scale) {
112
- options['font-scale'] = section.scale.serialize();
113
- }
114
- if (section.font) {
115
- options['text-font'] = section.font.serialize();
116
- }
117
- serialized.push(options);
118
- }
119
- return serialized;
120
- }
121
- }
122
-
123
- module.exports = { Formatted, FormatExpression };
@@ -1,356 +0,0 @@
1
- const {
2
- NumberType,
3
- StringType,
4
- BooleanType,
5
- ColorType,
6
- ObjectType,
7
- ValueType,
8
- ErrorType,
9
- CollatorType,
10
- array,
11
- toString
12
- } = require('../types');
13
-
14
- const { typeOf, Color, validateRGBA } = require('../values');
15
- const CompoundExpression = require('../compound_expression');
16
- const RuntimeError = require('../runtime_error');
17
- const Let = require('./let');
18
- const Var = require('./var');
19
- const Literal = require('./literal');
20
- const Assertion = require('./assertion');
21
- const Coercion = require('./coercion');
22
- const At = require('./at');
23
- const Match = require('./match');
24
- const Case = require('./case');
25
- const Step = require('./step');
26
- const Interpolate = require('./interpolate');
27
- const Coalesce = require('./coalesce');
28
- const { Equals, NotEquals, LessThan, GreaterThan, LessThanOrEqual, GreaterThanOrEqual } = require('./comparison');
29
- const { CollatorExpression } = require('./collator');
30
- const { Formatted, FormatExpression } = require('./formatted');
31
- const Length = require('./length');
32
-
33
- const expressions = {
34
- // special forms
35
- '==': Equals,
36
- '!=': NotEquals,
37
- '>': GreaterThan,
38
- '<': LessThan,
39
- '>=': GreaterThanOrEqual,
40
- '<=': LessThanOrEqual,
41
- array: Assertion,
42
- at: At,
43
- boolean: Assertion,
44
- case: Case,
45
- coalesce: Coalesce,
46
- collator: CollatorExpression,
47
- format: FormatExpression,
48
- interpolate: Interpolate,
49
- 'interpolate-hcl': Interpolate,
50
- 'interpolate-lab': Interpolate,
51
- length: Length,
52
- let: Let,
53
- literal: Literal,
54
- match: Match,
55
- number: Assertion,
56
- object: Assertion,
57
- step: Step,
58
- string: Assertion,
59
- 'to-color': Coercion,
60
- 'to-number': Coercion,
61
- var: Var
62
- };
63
-
64
- function rgba(ctx, [r, g, b, a]) {
65
- r = r.evaluate(ctx);
66
- g = g.evaluate(ctx);
67
- b = b.evaluate(ctx);
68
- const alpha = a ? a.evaluate(ctx) : 1;
69
- const error = validateRGBA(r, g, b, alpha);
70
- if (error) throw new RuntimeError(error);
71
- return new Color((r / 255) * alpha, (g / 255) * alpha, (b / 255) * alpha, alpha);
72
- }
73
-
74
- function has(key, obj) {
75
- return key in obj;
76
- }
77
-
78
- function get(key, obj) {
79
- const v = obj[key];
80
- return typeof v === 'undefined' ? null : v;
81
- }
82
-
83
- function binarySearch(v, a, i, j) {
84
- while (i <= j) {
85
- const m = (i + j) >> 1;
86
- if (a[m] === v) return true;
87
- if (a[m] > v) j = m - 1;
88
- else i = m + 1;
89
- }
90
- return false;
91
- }
92
-
93
- function varargs(type) {
94
- return { type };
95
- }
96
-
97
- CompoundExpression.register(expressions, {
98
- error: [
99
- ErrorType,
100
- [StringType],
101
- (ctx, [v]) => {
102
- throw new RuntimeError(v.evaluate(ctx));
103
- }
104
- ],
105
- typeof: [StringType, [ValueType], (ctx, [v]) => toString(typeOf(v.evaluate(ctx)))],
106
- 'to-string': [
107
- StringType,
108
- [ValueType],
109
- (ctx, [v]) => {
110
- v = v.evaluate(ctx);
111
- const type = typeof v;
112
- if (v === null) {
113
- return '';
114
- }
115
- if (type === 'string' || type === 'number' || type === 'boolean') {
116
- return String(v);
117
- }
118
- if (v instanceof Color || v instanceof Formatted) {
119
- return v.toString();
120
- }
121
- return JSON.stringify(v);
122
- }
123
- ],
124
- 'to-boolean': [BooleanType, [ValueType], (ctx, [v]) => Boolean(v.evaluate(ctx))],
125
- 'to-rgba': [
126
- array(NumberType, 4),
127
- [ColorType],
128
- (ctx, [v]) => {
129
- return v.evaluate(ctx).toArray();
130
- }
131
- ],
132
- rgb: [ColorType, [NumberType, NumberType, NumberType], rgba],
133
- rgba: [ColorType, [NumberType, NumberType, NumberType, NumberType], rgba],
134
- has: {
135
- type: BooleanType,
136
- overloads: [
137
- [[StringType], (ctx, [key]) => has(key.evaluate(ctx), ctx.properties())],
138
- [[StringType, ObjectType], (ctx, [key, obj]) => has(key.evaluate(ctx), obj.evaluate(ctx))]
139
- ]
140
- },
141
- get: {
142
- type: ValueType,
143
- overloads: [
144
- [[StringType], (ctx, [key]) => get(key.evaluate(ctx), ctx.properties())],
145
- [[StringType, ObjectType], (ctx, [key, obj]) => get(key.evaluate(ctx), obj.evaluate(ctx))]
146
- ]
147
- },
148
- 'feature-state': [ValueType, [StringType], (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})],
149
- properties: [ObjectType, [], ctx => ctx.properties()],
150
- 'geometry-type': [StringType, [], ctx => ctx.geometryType()],
151
- id: [ValueType, [], ctx => ctx.id()],
152
- zoom: [NumberType, [], ctx => ctx.globals.zoom],
153
- 'heatmap-density': [NumberType, [], ctx => ctx.globals.heatmapDensity || 0],
154
- 'line-progress': [NumberType, [], ctx => ctx.globals.lineProgress || 0],
155
- '+': [
156
- NumberType,
157
- varargs(NumberType),
158
- (ctx, args) => {
159
- let result = 0;
160
- for (const arg of args) {
161
- result += arg.evaluate(ctx);
162
- }
163
- return result;
164
- }
165
- ],
166
- '*': [
167
- NumberType,
168
- varargs(NumberType),
169
- (ctx, args) => {
170
- let result = 1;
171
- for (const arg of args) {
172
- result *= arg.evaluate(ctx);
173
- }
174
- return result;
175
- }
176
- ],
177
- '-': {
178
- type: NumberType,
179
- overloads: [
180
- [[NumberType, NumberType], (ctx, [a, b]) => a.evaluate(ctx) - b.evaluate(ctx)],
181
- [[NumberType], (ctx, [a]) => -a.evaluate(ctx)]
182
- ]
183
- },
184
- '/': [NumberType, [NumberType, NumberType], (ctx, [a, b]) => a.evaluate(ctx) / b.evaluate(ctx)],
185
- '%': [NumberType, [NumberType, NumberType], (ctx, [a, b]) => a.evaluate(ctx) % b.evaluate(ctx)],
186
- ln2: [NumberType, [], () => Math.LN2],
187
- pi: [NumberType, [], () => Math.PI],
188
- e: [NumberType, [], () => Math.E],
189
- '^': [NumberType, [NumberType, NumberType], (ctx, [b, e]) => b.evaluate(ctx) ** e.evaluate(ctx)],
190
- sqrt: [NumberType, [NumberType], (ctx, [x]) => Math.sqrt(x.evaluate(ctx))],
191
- log10: [NumberType, [NumberType], (ctx, [n]) => Math.log10(n.evaluate(ctx))],
192
- ln: [NumberType, [NumberType], (ctx, [n]) => Math.log(n.evaluate(ctx))],
193
- log2: [NumberType, [NumberType], (ctx, [n]) => Math.log2(n.evaluate(ctx))],
194
- sin: [NumberType, [NumberType], (ctx, [n]) => Math.sin(n.evaluate(ctx))],
195
- cos: [NumberType, [NumberType], (ctx, [n]) => Math.cos(n.evaluate(ctx))],
196
- tan: [NumberType, [NumberType], (ctx, [n]) => Math.tan(n.evaluate(ctx))],
197
- asin: [NumberType, [NumberType], (ctx, [n]) => Math.asin(n.evaluate(ctx))],
198
- acos: [NumberType, [NumberType], (ctx, [n]) => Math.acos(n.evaluate(ctx))],
199
- atan: [NumberType, [NumberType], (ctx, [n]) => Math.atan(n.evaluate(ctx))],
200
- min: [NumberType, varargs(NumberType), (ctx, args) => Math.min(...args.map(arg => arg.evaluate(ctx)))],
201
- max: [NumberType, varargs(NumberType), (ctx, args) => Math.max(...args.map(arg => arg.evaluate(ctx)))],
202
- abs: [NumberType, [NumberType], (ctx, [n]) => Math.abs(n.evaluate(ctx))],
203
- round: [
204
- NumberType,
205
- [NumberType],
206
- (ctx, [n]) => {
207
- const v = n.evaluate(ctx);
208
- // Javascript's Math.round() rounds towards +Infinity for halfway
209
- // values, even when they're negative. It's more common to round
210
- // away from 0 (e.g., this is what python and C++ do)
211
- return v < 0 ? -Math.round(-v) : Math.round(v);
212
- }
213
- ],
214
- floor: [NumberType, [NumberType], (ctx, [n]) => Math.floor(n.evaluate(ctx))],
215
- ceil: [NumberType, [NumberType], (ctx, [n]) => Math.ceil(n.evaluate(ctx))],
216
- 'filter-==': [BooleanType, [StringType, ValueType], (ctx, [k, v]) => ctx.properties()[k.value] === v.value],
217
- 'filter-id-==': [BooleanType, [ValueType], (ctx, [v]) => ctx.id() === v.value],
218
- 'filter-type-==': [BooleanType, [StringType], (ctx, [v]) => ctx.geometryType() === v.value],
219
- 'filter-<': [
220
- BooleanType,
221
- [StringType, ValueType],
222
- (ctx, [k, v]) => {
223
- const a = ctx.properties()[k.value];
224
- const b = v.value;
225
- return typeof a === typeof b && a < b;
226
- }
227
- ],
228
- 'filter-id-<': [
229
- BooleanType,
230
- [ValueType],
231
- (ctx, [v]) => {
232
- const a = ctx.id();
233
- const b = v.value;
234
- return typeof a === typeof b && a < b;
235
- }
236
- ],
237
- 'filter->': [
238
- BooleanType,
239
- [StringType, ValueType],
240
- (ctx, [k, v]) => {
241
- const a = ctx.properties()[k.value];
242
- const b = v.value;
243
- return typeof a === typeof b && a > b;
244
- }
245
- ],
246
- 'filter-id->': [
247
- BooleanType,
248
- [ValueType],
249
- (ctx, [v]) => {
250
- const a = ctx.id();
251
- const b = v.value;
252
- return typeof a === typeof b && a > b;
253
- }
254
- ],
255
- 'filter-<=': [
256
- BooleanType,
257
- [StringType, ValueType],
258
- (ctx, [k, v]) => {
259
- const a = ctx.properties()[k.value];
260
- const b = v.value;
261
- return typeof a === typeof b && a <= b;
262
- }
263
- ],
264
- 'filter-id-<=': [
265
- BooleanType,
266
- [ValueType],
267
- (ctx, [v]) => {
268
- const a = ctx.id();
269
- const b = v.value;
270
- return typeof a === typeof b && a <= b;
271
- }
272
- ],
273
- 'filter->=': [
274
- BooleanType,
275
- [StringType, ValueType],
276
- (ctx, [k, v]) => {
277
- const a = ctx.properties()[k.value];
278
- const b = v.value;
279
- return typeof a === typeof b && a >= b;
280
- }
281
- ],
282
- 'filter-id->=': [
283
- BooleanType,
284
- [ValueType],
285
- (ctx, [v]) => {
286
- const a = ctx.id();
287
- const b = v.value;
288
- return typeof a === typeof b && a >= b;
289
- }
290
- ],
291
- 'filter-has': [BooleanType, [ValueType], (ctx, [k]) => k.value in ctx.properties()],
292
- 'filter-has-id': [BooleanType, [], ctx => ctx.id() !== null],
293
- 'filter-type-in': [BooleanType, [array(StringType)], (ctx, [v]) => v.value.indexOf(ctx.geometryType()) >= 0],
294
- 'filter-id-in': [BooleanType, [array(ValueType)], (ctx, [v]) => v.value.indexOf(ctx.id()) >= 0],
295
- 'filter-in-small': [
296
- BooleanType,
297
- [StringType, array(ValueType)],
298
- // assumes v is an array literal
299
- (ctx, [k, v]) => v.value.indexOf(ctx.properties()[k.value]) >= 0
300
- ],
301
- 'filter-in-large': [
302
- BooleanType,
303
- [StringType, array(ValueType)],
304
- // assumes v is a array literal with values sorted in ascending order and of a single type
305
- (ctx, [k, v]) => binarySearch(ctx.properties()[k.value], v.value, 0, v.value.length - 1)
306
- ],
307
- all: {
308
- type: BooleanType,
309
- overloads: [
310
- [[BooleanType, BooleanType], (ctx, [a, b]) => a.evaluate(ctx) && b.evaluate(ctx)],
311
- [
312
- varargs(BooleanType),
313
- (ctx, args) => {
314
- for (const arg of args) {
315
- if (!arg.evaluate(ctx)) return false;
316
- }
317
- return true;
318
- }
319
- ]
320
- ]
321
- },
322
- any: {
323
- type: BooleanType,
324
- overloads: [
325
- [[BooleanType, BooleanType], (ctx, [a, b]) => a.evaluate(ctx) || b.evaluate(ctx)],
326
- [
327
- varargs(BooleanType),
328
- (ctx, args) => {
329
- for (const arg of args) {
330
- if (arg.evaluate(ctx)) return true;
331
- }
332
- return false;
333
- }
334
- ]
335
- ]
336
- },
337
- '!': [BooleanType, [BooleanType], (ctx, [b]) => !b.evaluate(ctx)],
338
- 'is-supported-script': [
339
- BooleanType,
340
- [StringType],
341
- // At parse time this will always return true, so we need to exclude this expression with isGlobalPropertyConstant
342
- (ctx, [s]) => {
343
- const isSupportedScript = ctx.globals?.isSupportedScript;
344
- if (isSupportedScript) {
345
- return isSupportedScript(s.evaluate(ctx));
346
- }
347
- return true;
348
- }
349
- ],
350
- upcase: [StringType, [StringType], (ctx, [s]) => s.evaluate(ctx).toUpperCase()],
351
- downcase: [StringType, [StringType], (ctx, [s]) => s.evaluate(ctx).toLowerCase()],
352
- concat: [StringType, varargs(StringType), (ctx, args) => args.map(arg => arg.evaluate(ctx)).join('')],
353
- 'resolved-locale': [StringType, [CollatorType], (ctx, [collator]) => collator.evaluate(ctx).resolvedLocale()]
354
- });
355
-
356
- module.exports = expressions;