@mapwhit/tilerenderer 1.0.0 → 1.1.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.
Files changed (236) hide show
  1. package/build/min/package.json +2 -1
  2. package/build/min/src/shaders/_prelude.fragment.glsl.js +1 -1
  3. package/build/min/src/shaders/_prelude.vertex.glsl.js +1 -1
  4. package/build/min/src/shaders/background.fragment.glsl.js +1 -1
  5. package/build/min/src/shaders/background.vertex.glsl.js +1 -1
  6. package/build/min/src/shaders/background_pattern.fragment.glsl.js +1 -1
  7. package/build/min/src/shaders/background_pattern.vertex.glsl.js +1 -1
  8. package/build/min/src/shaders/circle.fragment.glsl.js +1 -1
  9. package/build/min/src/shaders/circle.vertex.glsl.js +1 -1
  10. package/build/min/src/shaders/clipping_mask.fragment.glsl.js +1 -1
  11. package/build/min/src/shaders/clipping_mask.vertex.glsl.js +1 -1
  12. package/build/min/src/shaders/collision_box.fragment.glsl.js +1 -1
  13. package/build/min/src/shaders/collision_box.vertex.glsl.js +1 -1
  14. package/build/min/src/shaders/collision_circle.fragment.glsl.js +1 -1
  15. package/build/min/src/shaders/collision_circle.vertex.glsl.js +1 -1
  16. package/build/min/src/shaders/debug.fragment.glsl.js +1 -1
  17. package/build/min/src/shaders/debug.vertex.glsl.js +1 -1
  18. package/build/min/src/shaders/fill.fragment.glsl.js +1 -1
  19. package/build/min/src/shaders/fill.vertex.glsl.js +1 -1
  20. package/build/min/src/shaders/fill_extrusion.fragment.glsl.js +1 -1
  21. package/build/min/src/shaders/fill_extrusion.vertex.glsl.js +1 -1
  22. package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.js +1 -1
  23. package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.js +1 -1
  24. package/build/min/src/shaders/fill_outline.fragment.glsl.js +1 -1
  25. package/build/min/src/shaders/fill_outline.vertex.glsl.js +1 -1
  26. package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.js +1 -1
  27. package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.js +1 -1
  28. package/build/min/src/shaders/fill_pattern.fragment.glsl.js +1 -1
  29. package/build/min/src/shaders/fill_pattern.vertex.glsl.js +1 -1
  30. package/build/min/src/shaders/heatmap.fragment.glsl.js +1 -1
  31. package/build/min/src/shaders/heatmap.vertex.glsl.js +1 -1
  32. package/build/min/src/shaders/heatmap_texture.fragment.glsl.js +1 -1
  33. package/build/min/src/shaders/heatmap_texture.vertex.glsl.js +1 -1
  34. package/build/min/src/shaders/hillshade.fragment.glsl.js +1 -1
  35. package/build/min/src/shaders/hillshade.vertex.glsl.js +1 -1
  36. package/build/min/src/shaders/hillshade_prepare.fragment.glsl.js +1 -1
  37. package/build/min/src/shaders/hillshade_prepare.vertex.glsl.js +1 -1
  38. package/build/min/src/shaders/line.fragment.glsl.js +1 -1
  39. package/build/min/src/shaders/line.vertex.glsl.js +1 -1
  40. package/build/min/src/shaders/line_gradient.fragment.glsl.js +1 -1
  41. package/build/min/src/shaders/line_gradient.vertex.glsl.js +1 -1
  42. package/build/min/src/shaders/line_pattern.fragment.glsl.js +1 -1
  43. package/build/min/src/shaders/line_pattern.vertex.glsl.js +1 -1
  44. package/build/min/src/shaders/line_sdf.fragment.glsl.js +1 -1
  45. package/build/min/src/shaders/line_sdf.vertex.glsl.js +1 -1
  46. package/build/min/src/shaders/raster.fragment.glsl.js +1 -1
  47. package/build/min/src/shaders/raster.vertex.glsl.js +1 -1
  48. package/build/min/src/shaders/symbol_icon.fragment.glsl.js +1 -1
  49. package/build/min/src/shaders/symbol_icon.vertex.glsl.js +1 -1
  50. package/build/min/src/shaders/symbol_sdf.fragment.glsl.js +1 -1
  51. package/build/min/src/shaders/symbol_sdf.vertex.glsl.js +1 -1
  52. package/package.json +3 -2
  53. package/src/data/array_types.js +54 -81
  54. package/src/data/bucket/circle_attributes.js +2 -4
  55. package/src/data/bucket/circle_bucket.js +19 -13
  56. package/src/data/bucket/fill_attributes.js +2 -4
  57. package/src/data/bucket/fill_bucket.js +38 -24
  58. package/src/data/bucket/fill_extrusion_attributes.js +2 -4
  59. package/src/data/bucket/fill_extrusion_bucket.js +56 -34
  60. package/src/data/bucket/heatmap_bucket.js +2 -7
  61. package/src/data/bucket/line_attributes.js +2 -4
  62. package/src/data/bucket/line_bucket.js +207 -159
  63. package/src/data/bucket/pattern_attributes.js +2 -4
  64. package/src/data/bucket/pattern_bucket_features.js +5 -7
  65. package/src/data/bucket/symbol_attributes.js +12 -26
  66. package/src/data/bucket/symbol_bucket.js +111 -221
  67. package/src/data/bucket/symbol_buffers.js +62 -0
  68. package/src/data/bucket/symbol_collision_buffers.js +33 -0
  69. package/src/data/bucket.js +2 -6
  70. package/src/data/dem_data.js +11 -7
  71. package/src/data/extent.js +1 -1
  72. package/src/data/feature_index.js +35 -20
  73. package/src/data/index_array_type.js +1 -6
  74. package/src/data/load_geometry.js +6 -9
  75. package/src/data/pos_attributes.js +2 -3
  76. package/src/data/program_configuration.js +44 -26
  77. package/src/data/raster_bounds_attributes.js +2 -2
  78. package/src/data/segment.js +4 -3
  79. package/src/geo/coordinate.js +1 -1
  80. package/src/geo/lng_lat.js +3 -3
  81. package/src/geo/lng_lat_bounds.js +8 -4
  82. package/src/geo/transform.js +69 -30
  83. package/src/gl/color_mode.js +2 -2
  84. package/src/gl/context.js +28 -29
  85. package/src/gl/cull_face_mode.js +1 -1
  86. package/src/gl/depth_mode.js +1 -1
  87. package/src/gl/framebuffer.js +8 -4
  88. package/src/gl/index_buffer.js +2 -2
  89. package/src/gl/stencil_mode.js +1 -1
  90. package/src/gl/value.js +33 -68
  91. package/src/gl/vertex_buffer.js +2 -2
  92. package/src/index.js +49 -25
  93. package/src/render/draw_background.js +14 -9
  94. package/src/render/draw_circle.js +11 -8
  95. package/src/render/draw_collision_debug.js +11 -8
  96. package/src/render/draw_debug.js +16 -14
  97. package/src/render/draw_fill.js +19 -12
  98. package/src/render/draw_fill_extrusion.js +12 -9
  99. package/src/render/draw_heatmap.js +17 -12
  100. package/src/render/draw_hillshade.js +12 -9
  101. package/src/render/draw_line.js +30 -16
  102. package/src/render/draw_raster.js +17 -13
  103. package/src/render/draw_symbol.js +22 -17
  104. package/src/render/glyph_atlas.js +9 -5
  105. package/src/render/glyph_manager.js +1 -1
  106. package/src/render/image_atlas.js +4 -7
  107. package/src/render/image_manager.js +6 -9
  108. package/src/render/line_atlas.js +2 -2
  109. package/src/render/painter.js +65 -47
  110. package/src/render/program/background_program.js +6 -13
  111. package/src/render/program/circle_program.js +4 -6
  112. package/src/render/program/clipping_mask_program.js +3 -5
  113. package/src/render/program/collision_program.js +4 -6
  114. package/src/render/program/debug_program.js +3 -5
  115. package/src/render/program/fill_extrusion_program.js +8 -14
  116. package/src/render/program/fill_program.js +10 -21
  117. package/src/render/program/heatmap_program.js +8 -14
  118. package/src/render/program/hillshade_program.js +10 -16
  119. package/src/render/program/line_program.js +11 -22
  120. package/src/render/program/pattern.js +5 -7
  121. package/src/render/program/program_uniforms.js +13 -20
  122. package/src/render/program/raster_program.js +3 -5
  123. package/src/render/program/symbol_program.js +5 -7
  124. package/src/render/program.js +5 -6
  125. package/src/render/texture.js +1 -1
  126. package/src/render/tile_mask.js +6 -4
  127. package/src/render/uniform_binding.js +9 -20
  128. package/src/render/vertex_array_object.js +5 -3
  129. package/src/shaders/encode_attribute.js +2 -6
  130. package/src/shaders/index.js +103 -51
  131. package/src/source/geojson_source.js +11 -7
  132. package/src/source/geojson_worker_source.js +7 -7
  133. package/src/source/geojson_wrapper.js +4 -4
  134. package/src/source/image_source.js +11 -12
  135. package/src/source/load_tilejson.js +3 -3
  136. package/src/source/pixels_to_tile_units.js +3 -3
  137. package/src/source/query_features.js +13 -10
  138. package/src/source/raster_dem_tile_source.js +12 -10
  139. package/src/source/raster_tile_source.js +13 -9
  140. package/src/source/resources/glyphs.js +2 -3
  141. package/src/source/resources/index.js +2 -4
  142. package/src/source/rtl_text_plugin.js +8 -8
  143. package/src/source/source.js +9 -15
  144. package/src/source/source_cache.js +114 -49
  145. package/src/source/source_state.js +37 -14
  146. package/src/source/tile.js +38 -23
  147. package/src/source/tile_bounds.js +15 -8
  148. package/src/source/tile_cache.js +2 -2
  149. package/src/source/tile_id.js +30 -23
  150. package/src/source/vector_tile_source.js +10 -8
  151. package/src/source/vector_tile_worker_source.js +4 -4
  152. package/src/source/worker_tile.js +24 -22
  153. package/src/style/create_style_layer.js +11 -11
  154. package/src/style/evaluation_parameters.js +4 -6
  155. package/src/style/light.js +5 -5
  156. package/src/style/load_sprite.js +6 -6
  157. package/src/style/parse_glyph_pbf.js +21 -17
  158. package/src/style/pauseable_placement.js +3 -4
  159. package/src/style/properties.js +21 -44
  160. package/src/style/query_utils.js +4 -10
  161. package/src/style/style.js +64 -34
  162. package/src/style/style_layer/background_style_layer.js +3 -4
  163. package/src/style/style_layer/background_style_layer_properties.js +2 -2
  164. package/src/style/style_layer/circle_style_layer.js +12 -9
  165. package/src/style/style_layer/circle_style_layer_properties.js +2 -2
  166. package/src/style/style_layer/fill_extrusion_style_layer.js +16 -13
  167. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +2 -2
  168. package/src/style/style_layer/fill_style_layer.js +6 -7
  169. package/src/style/style_layer/fill_style_layer_properties.js +2 -2
  170. package/src/style/style_layer/heatmap_style_layer.js +5 -6
  171. package/src/style/style_layer/heatmap_style_layer_properties.js +2 -2
  172. package/src/style/style_layer/hillshade_style_layer.js +3 -4
  173. package/src/style/style_layer/hillshade_style_layer_properties.js +2 -2
  174. package/src/style/style_layer/line_style_layer.js +10 -11
  175. package/src/style/style_layer/line_style_layer_properties.js +5 -5
  176. package/src/style/style_layer/raster_style_layer.js +3 -4
  177. package/src/style/style_layer/raster_style_layer_properties.js +2 -2
  178. package/src/style/style_layer/symbol_style_layer.js +7 -8
  179. package/src/style/style_layer/symbol_style_layer_properties.js +2 -2
  180. package/src/style/style_layer.js +21 -20
  181. package/src/style/style_layer_index.js +2 -2
  182. package/src/style/zoom_history.js +1 -1
  183. package/src/style-spec/error/parsing_error.js +1 -1
  184. package/src/style-spec/error/validation_error.js +5 -3
  185. package/src/style-spec/feature_filter/convert.js +17 -9
  186. package/src/style-spec/feature_filter/index.js +13 -9
  187. package/src/style-spec/util/eval_support.js +2 -2
  188. package/src/style-spec/util/ref_properties.js +1 -1
  189. package/src/symbol/anchor.js +2 -2
  190. package/src/symbol/check_max_angle.js +13 -5
  191. package/src/symbol/clip_line.js +2 -3
  192. package/src/symbol/collision_feature.js +8 -4
  193. package/src/symbol/collision_index.js +5 -7
  194. package/src/symbol/cross_tile_symbol_index.js +5 -5
  195. package/src/symbol/get_anchors.js +15 -8
  196. package/src/symbol/grid_index.js +5 -3
  197. package/src/symbol/mergelines.js +2 -2
  198. package/src/symbol/opacity_state.js +1 -1
  199. package/src/symbol/placement.js +25 -20
  200. package/src/symbol/projection.js +29 -28
  201. package/src/symbol/quads.js +10 -12
  202. package/src/symbol/shaping.js +27 -19
  203. package/src/symbol/symbol_layout.js +17 -21
  204. package/src/symbol/symbol_size.js +13 -12
  205. package/src/symbol/transform_text.js +3 -3
  206. package/src/ui/camera.js +34 -18
  207. package/src/ui/map.js +54 -34
  208. package/src/util/async.js +11 -5
  209. package/src/util/browser.js +1 -1
  210. package/src/util/callback.js +3 -9
  211. package/src/util/classify_rings.js +13 -8
  212. package/src/util/color_ramp.js +3 -3
  213. package/src/util/config.js +4 -4
  214. package/src/util/dictionary_coder.js +2 -3
  215. package/src/util/dom.js +7 -3
  216. package/src/util/find_pole_of_inaccessibility.js +29 -14
  217. package/src/util/group_layers.js +1 -1
  218. package/src/util/image.js +3 -8
  219. package/src/util/interpolate.js +1 -1
  220. package/src/util/intersection_tests.js +80 -42
  221. package/src/util/is_char_in_unicode_block.js +1 -1
  222. package/src/util/key.js +7 -3
  223. package/src/util/loader/image.js +1 -1
  224. package/src/util/object.js +25 -23
  225. package/src/util/script_detection.js +212 -91
  226. package/src/util/struct_array.js +8 -40
  227. package/src/util/task_queue.js +11 -7
  228. package/src/util/throttle.js +2 -2
  229. package/src/util/tile_cover.js +8 -5
  230. package/src/util/token.js +1 -1
  231. package/src/util/unique_id.js +2 -2
  232. package/src/util/util.js +21 -29
  233. package/src/util/vectortile_to_geojson.js +4 -2
  234. package/src/util/verticalize_punctuation.js +3 -7
  235. package/src/util/warn.js +4 -4
  236. package/src/util/web_worker.js +3 -3
@@ -1,13 +1,12 @@
1
- const { default: Point } = require('@mapbox/point-geometry');
2
-
3
- const StyleLayer = require('../style_layer');
4
- const LineBucket = require('../../data/bucket/line_bucket');
5
- const { polygonIntersectsBufferedMultiLine } = require('../../util/intersection_tests');
6
- const { getMaximumPaintValue, translateDistance, translate } = require('../query_utils');
7
- const properties = require('./line_style_layer_properties');
8
- const EvaluationParameters = require('../evaluation_parameters');
9
- const renderColorRamp = require('../../util/color_ramp');
10
- const { DataDrivenProperty } = require('../properties');
1
+ import Point from '@mapbox/point-geometry';
2
+ import LineBucket from '../../data/bucket/line_bucket.js';
3
+ import renderColorRamp from '../../util/color_ramp.js';
4
+ import { polygonIntersectsBufferedMultiLine } from '../../util/intersection_tests.js';
5
+ import EvaluationParameters from '../evaluation_parameters.js';
6
+ import { DataDrivenProperty } from '../properties.js';
7
+ import { getMaximumPaintValue, translate, translateDistance } from '../query_utils.js';
8
+ import StyleLayer from '../style_layer.js';
9
+ import properties from './line_style_layer_properties.js';
11
10
 
12
11
  class LineFloorwidthProperty extends DataDrivenProperty {
13
12
  possiblyEvaluate(value, parameters) {
@@ -95,7 +94,7 @@ class LineStyleLayer extends StyleLayer {
95
94
  }
96
95
  }
97
96
 
98
- module.exports = LineStyleLayer;
97
+ export default LineStyleLayer;
99
98
 
100
99
  function getLineWidth(lineWidth, lineGapWidth) {
101
100
  if (lineGapWidth > 0) {
@@ -1,13 +1,13 @@
1
1
  // This file is generated. Edit layer-properties.js.ejs, then run `make generate-style-code`.
2
2
 
3
- const {
4
- Properties,
3
+ import {
5
4
  ColorRampProperty,
6
5
  CrossFadedDataDrivenProperty,
7
6
  CrossFadedProperty,
8
7
  DataConstantProperty,
9
- DataDrivenProperty
10
- } = require('../properties');
8
+ DataDrivenProperty,
9
+ Properties
10
+ } from '../properties.js';
11
11
 
12
12
  const layout = new Properties({
13
13
  'line-cap': new DataConstantProperty({
@@ -101,4 +101,4 @@ const paint = new Properties({
101
101
  })
102
102
  });
103
103
 
104
- module.exports = { paint, layout };
104
+ export default { paint, layout };
@@ -1,6 +1,5 @@
1
- const StyleLayer = require('../style_layer');
2
-
3
- const properties = require('./raster_style_layer_properties');
1
+ import StyleLayer from '../style_layer.js';
2
+ import properties from './raster_style_layer_properties.js';
4
3
 
5
4
  class RasterStyleLayer extends StyleLayer {
6
5
  constructor(layer) {
@@ -8,4 +7,4 @@ class RasterStyleLayer extends StyleLayer {
8
7
  }
9
8
  }
10
9
 
11
- module.exports = RasterStyleLayer;
10
+ export default RasterStyleLayer;
@@ -1,6 +1,6 @@
1
1
  // This file is generated. Edit layer-properties.js.ejs, then run `make generate-style-code`.
2
2
 
3
- const { Properties, DataConstantProperty } = require('../properties');
3
+ import { DataConstantProperty, Properties } from '../properties.js';
4
4
 
5
5
  const paint = new Properties({
6
6
  'raster-opacity': new DataConstantProperty({
@@ -52,4 +52,4 @@ const paint = new Properties({
52
52
  })
53
53
  });
54
54
 
55
- module.exports = { paint };
55
+ export default { paint };
@@ -1,10 +1,9 @@
1
- const StyleLayer = require('../style_layer');
2
-
3
- const SymbolBucket = require('../../data/bucket/symbol_bucket');
4
- const resolveTokens = require('../../util/token');
5
- const { isExpression } = require('@mapwhit/style-expressions');
6
- const assert = require('assert');
7
- const properties = require('./symbol_style_layer_properties');
1
+ import { isExpression } from '@mapwhit/style-expressions';
2
+ import assert from 'assert';
3
+ import SymbolBucket from '../../data/bucket/symbol_bucket.js';
4
+ import resolveTokens from '../../util/token.js';
5
+ import StyleLayer from '../style_layer.js';
6
+ import properties from './symbol_style_layer_properties.js';
8
7
 
9
8
  class SymbolStyleLayer extends StyleLayer {
10
9
  constructor(layer) {
@@ -63,4 +62,4 @@ class SymbolStyleLayer extends StyleLayer {
63
62
  }
64
63
  }
65
64
 
66
- module.exports = SymbolStyleLayer;
65
+ export default SymbolStyleLayer;
@@ -1,6 +1,6 @@
1
1
  // This file is generated. Edit layer-properties.js.ejs, then run `make generate-style-code`.
2
2
 
3
- const { Properties, DataConstantProperty, DataDrivenProperty } = require('../properties');
3
+ import { DataConstantProperty, DataDrivenProperty, Properties } from '../properties.js';
4
4
 
5
5
  const layout = new Properties({
6
6
  'symbol-placement': new DataConstantProperty({
@@ -291,4 +291,4 @@ const paint = new Properties({
291
291
  })
292
292
  });
293
293
 
294
- module.exports = { paint, layout };
294
+ export default { paint, layout };
@@ -1,10 +1,8 @@
1
- const { filterObject } = require('../util/object');
2
-
3
- const { Evented } = require('@mapwhit/events');
4
- const { Layout, Transitionable, PossiblyEvaluatedPropertyValue } = require('./properties');
5
- const { supportsPropertyExpression } = require('@mapwhit/style-expressions');
6
- const featureFilter = require('../style-spec/feature_filter');
7
- const createKey = require('../util/key');
1
+ import { Evented } from '@mapwhit/events';
2
+ import { supportsPropertyExpression } from '@mapwhit/style-expressions';
3
+ import featureFilter from '../style-spec/feature_filter/index.js';
4
+ import createKey from '../util/key.js';
5
+ import { Layout, PossiblyEvaluatedPropertyValue, Transitionable } from './properties.js';
8
6
 
9
7
  const keyProperties = ['type', 'minzoom', 'maxzoom', 'filter', 'layout'];
10
8
  const TRANSITION_SUFFIX = '-transition';
@@ -160,21 +158,20 @@ class StyleLayer extends Evented {
160
158
  this._transitionablePaint.setTransition(name.slice(0, -TRANSITION_SUFFIX.length), value || undefined);
161
159
  return false;
162
160
  }
163
- // if a cross-faded value is changed, we need to make sure the new icons get added to each tile's iconAtlas
164
- // so a call to _updateLayer is necessary, and we return true from this function so it gets called in
165
- // Style#setPaintProperty
166
- const prop = this._transitionablePaint._values[name];
167
- const newCrossFadedValue =
168
- prop.property.specification['property-type'] === 'cross-faded-data-driven' && !prop.value.value && value;
169
- const wasDataDriven = this._transitionablePaint._values[name].value.isDataDriven();
161
+ const transitionable = this._transitionablePaint._values[name];
162
+ const isCrossFadedProperty = transitionable.property.specification['property-type'] === 'cross-faded-data-driven';
163
+ const wasDataDriven = transitionable.value.isDataDriven();
170
164
  this._transitionablePaint.setValue(name, value);
171
- const isDataDriven = this._transitionablePaint._values[name].value.isDataDriven();
172
165
  this._handleSpecialPaintPropertyUpdate(name);
173
- if (isDataDriven !== wasDataDriven || (wasDataDriven && isDataDriven)) {
166
+ const isDataDriven = this._transitionablePaint._values[name].value.isDataDriven();
167
+ if (isDataDriven !== wasDataDriven || (wasDataDriven && isDataDriven) || isCrossFadedProperty) {
174
168
  // reset transitioning in progress
175
169
  this._untransitioned(name);
176
170
  }
177
- return isDataDriven || wasDataDriven || newCrossFadedValue;
171
+ // if a cross-faded value is changed, we need to make sure the new icons get added to each tile's iconAtlas
172
+ // so a call to _updateLayer is necessary, and we return true from this function so it gets called in
173
+ // Style#setPaintProperty
174
+ return isDataDriven || wasDataDriven || isCrossFadedProperty;
178
175
  }
179
176
 
180
177
  _untransitioned(name) {
@@ -188,8 +185,12 @@ class StyleLayer extends Evented {
188
185
  }
189
186
 
190
187
  isHidden(zoom) {
191
- if (this.minzoom && zoom < this.minzoom) return true;
192
- if (this.maxzoom && zoom >= this.maxzoom) return true;
188
+ if (this.minzoom && zoom < this.minzoom) {
189
+ return true;
190
+ }
191
+ if (this.maxzoom && zoom >= this.maxzoom) {
192
+ return true;
193
+ }
193
194
  return this.visibility === 'none';
194
195
  }
195
196
 
@@ -253,4 +254,4 @@ class StyleLayer extends Evented {
253
254
  }
254
255
  }
255
256
 
256
- module.exports = StyleLayer;
257
+ export default StyleLayer;
@@ -1,4 +1,4 @@
1
- const groupBySource = require('../util/group_layers');
1
+ import groupBySource from '../util/group_layers.js';
2
2
 
3
3
  class StyleLayerIndex {
4
4
  #layers = new Map();
@@ -27,4 +27,4 @@ class StyleLayerIndex {
27
27
  }
28
28
  }
29
29
 
30
- module.exports = StyleLayerIndex;
30
+ export default StyleLayerIndex;
@@ -33,4 +33,4 @@ class ZoomHistory {
33
33
  }
34
34
  }
35
35
 
36
- module.exports = ZoomHistory;
36
+ export default ZoomHistory;
@@ -5,4 +5,4 @@ function ParsingError(error) {
5
5
  this.line = match ? Number.parseInt(match[1], 10) : 0;
6
6
  }
7
7
 
8
- module.exports = ParsingError;
8
+ export default ParsingError;
@@ -1,10 +1,12 @@
1
- module.exports = class ValidationError {
1
+ export default class ValidationError {
2
2
  constructor(key, value, message, identifier) {
3
3
  this.message = (key ? `${key}: ` : '') + message;
4
- if (identifier) this.identifier = identifier;
4
+ if (identifier) {
5
+ this.identifier = identifier;
6
+ }
5
7
 
6
8
  if (value?.__line__) {
7
9
  this.line = value.__line__;
8
10
  }
9
11
  }
10
- };
12
+ }
@@ -1,13 +1,11 @@
1
- const { isExpressionFilter } = require('./index');
2
-
3
- module.exports = convertFilter;
1
+ import { isExpressionFilter } from './index.js';
4
2
 
5
3
  /**
6
4
  * Convert the given legacy filter to (the JSON representation of) an
7
5
  * equivalent expression
8
6
  * @private
9
7
  */
10
- function convertFilter(filter) {
8
+ export default function convertFilter(filter) {
11
9
  return _convertFilter(filter, {});
12
10
  }
13
11
 
@@ -64,9 +62,13 @@ function _convertFilter(filter, expectedTypes) {
64
62
  return filter;
65
63
  }
66
64
 
67
- if (!filter) return true;
65
+ if (!filter) {
66
+ return true;
67
+ }
68
68
  const op = filter[0];
69
- if (filter.length <= 1) return op !== 'any';
69
+ if (filter.length <= 1) {
70
+ return op !== 'any';
71
+ }
70
72
 
71
73
  let converted;
72
74
 
@@ -115,8 +117,12 @@ function runtimeTypeChecks(expectedTypes) {
115
117
  const get = property === '$id' ? ['id'] : ['get', property];
116
118
  conditions.push(['==', ['typeof', get], expectedTypes[property]]);
117
119
  }
118
- if (conditions.length === 0) return true;
119
- if (conditions.length === 1) return conditions[0];
120
+ if (conditions.length === 0) {
121
+ return true;
122
+ }
123
+ if (conditions.length === 1) {
124
+ return conditions[0];
125
+ }
120
126
  return ['all'].concat(conditions);
121
127
  }
122
128
 
@@ -155,7 +161,9 @@ function convertComparisonOp(property, value, op, expectedTypes) {
155
161
  }
156
162
 
157
163
  function convertInOp(property, values, negate = false) {
158
- if (values.length === 0) return negate;
164
+ if (values.length === 0) {
165
+ return negate;
166
+ }
159
167
 
160
168
  let get;
161
169
  if (property === '$type') {
@@ -1,11 +1,9 @@
1
- const { createExpression, findGlobalStateRefs } = require('@mapwhit/style-expressions');
2
-
3
- module.exports = createFilter;
1
+ import { createExpression, findGlobalStateRefs } from '@mapwhit/style-expressions';
4
2
 
5
3
  createFilter.isExpressionFilter = isExpressionFilter;
6
4
  createFilter.addGlobalStateRefs = addGlobalStateRefs;
7
5
 
8
- function isExpressionFilter(filter) {
6
+ export function isExpressionFilter(filter) {
9
7
  if (filter === true || filter === false) {
10
8
  return true;
11
9
  }
@@ -65,7 +63,7 @@ const filterSpec = {
65
63
  * @param {Array} filter mapbox gl filter
66
64
  * @returns {Function} filter-evaluating function
67
65
  */
68
- function createFilter(filter) {
66
+ export default function createFilter(filter) {
69
67
  if (filter === null || filter === undefined) {
70
68
  return addGlobalStateRefs(() => true);
71
69
  }
@@ -84,7 +82,7 @@ function createFilter(filter) {
84
82
  );
85
83
  }
86
84
 
87
- function addGlobalStateRefs(filter, getGlobalStateRefs = () => new Set()) {
85
+ export function addGlobalStateRefs(filter, getGlobalStateRefs = () => new Set()) {
88
86
  filter.getGlobalStateRefs = getGlobalStateRefs;
89
87
  return filter;
90
88
  }
@@ -95,9 +93,13 @@ function compare(a, b) {
95
93
  }
96
94
 
97
95
  function convertFilter(filter) {
98
- if (!filter || filter.length === 0) return true;
96
+ if (!filter || filter.length === 0) {
97
+ return true;
98
+ }
99
99
  const [op, ...args] = filter;
100
- if (filter.length <= 1) return op !== 'any';
100
+ if (filter.length <= 1) {
101
+ return op !== 'any';
102
+ }
101
103
  switch (op) {
102
104
  case '!=':
103
105
  return convertNegation(convertComparisonOp('==', ...args));
@@ -158,7 +160,9 @@ function convertInOp([property, ...values]) {
158
160
  }
159
161
 
160
162
  function isUniformLarge(values) {
161
- if (values.length < 200) return false;
163
+ if (values.length < 200) {
164
+ return false;
165
+ }
162
166
  const type = typeof values[0];
163
167
  return values.every(v => typeof v === type);
164
168
  }
@@ -1,8 +1,8 @@
1
- module.exports = (function () {
1
+ export default (function () {
2
2
  try {
3
3
  new Function('');
4
4
  return true;
5
- } catch (e) {
5
+ } catch {
6
6
  return false;
7
7
  }
8
8
  })();
@@ -1 +1 @@
1
- module.exports = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];
1
+ export default ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];
@@ -1,4 +1,4 @@
1
- const { default: Point } = require('@mapbox/point-geometry');
1
+ import Point from '@mapbox/point-geometry';
2
2
 
3
3
  class Anchor extends Point {
4
4
  constructor(x, y, angle, segment) {
@@ -14,4 +14,4 @@ class Anchor extends Point {
14
14
  }
15
15
  }
16
16
 
17
- module.exports = Anchor;
17
+ export default Anchor;
@@ -1,4 +1,4 @@
1
- module.exports = checkMaxAngle;
1
+ export default checkMaxAngle;
2
2
 
3
3
  /**
4
4
  * Labels placed around really sharp angles aren't readable. Check if any
@@ -15,7 +15,9 @@ module.exports = checkMaxAngle;
15
15
  */
16
16
  function checkMaxAngle(line, anchor, labelLength, windowSize, maxAngle) {
17
17
  // horizontal labels always pass
18
- if (anchor.segment === undefined) return true;
18
+ if (anchor.segment === undefined) {
19
+ return true;
20
+ }
19
21
 
20
22
  let p = anchor;
21
23
  let index = anchor.segment + 1;
@@ -26,7 +28,9 @@ function checkMaxAngle(line, anchor, labelLength, windowSize, maxAngle) {
26
28
  index--;
27
29
 
28
30
  // there isn't enough room for the label after the beginning of the line
29
- if (index < 0) return false;
31
+ if (index < 0) {
32
+ return false;
33
+ }
30
34
 
31
35
  anchorDistance -= line[index].dist(p);
32
36
  p = line[index];
@@ -46,7 +50,9 @@ function checkMaxAngle(line, anchor, labelLength, windowSize, maxAngle) {
46
50
  const next = line[index + 1];
47
51
 
48
52
  // there isn't enough room for the label before the end of the line
49
- if (!next) return false;
53
+ if (!next) {
54
+ return false;
55
+ }
50
56
 
51
57
  let angleDelta = prev.angleTo(current) - current.angleTo(next);
52
58
  // restrict angle to -pi..pi range
@@ -64,7 +70,9 @@ function checkMaxAngle(line, anchor, labelLength, windowSize, maxAngle) {
64
70
  }
65
71
 
66
72
  // the sum of angles within the window area exceeds the maximum allowed value. check fails.
67
- if (recentAngleDelta > maxAngle) return false;
73
+ if (recentAngleDelta > maxAngle) {
74
+ return false;
75
+ }
68
76
 
69
77
  index++;
70
78
  anchorDistance += current.dist(next);
@@ -1,6 +1,5 @@
1
- const { default: Point } = require('@mapbox/point-geometry');
2
-
3
- module.exports = clipLine;
1
+ import Point from '@mapbox/point-geometry';
2
+ export default clipLine;
4
3
 
5
4
  /**
6
5
  * Returns the part of a multiline that intersects with the provided rectangular box.
@@ -1,4 +1,4 @@
1
- const { default: Point } = require('@mapbox/point-geometry');
1
+ import Point from '@mapbox/point-geometry';
2
2
 
3
3
  /**
4
4
  * A CollisionFeature represents the area of the tile covered by a single label.
@@ -174,8 +174,12 @@ class CollisionFeature {
174
174
  let boxDistanceToAnchor = labelStartDistance + boxOffset;
175
175
 
176
176
  // make the distance between pitch padding boxes bigger
177
- if (boxOffset < 0) boxDistanceToAnchor += boxOffset;
178
- if (boxOffset > labelLength) boxDistanceToAnchor += boxOffset - labelLength;
177
+ if (boxOffset < 0) {
178
+ boxDistanceToAnchor += boxOffset;
179
+ }
180
+ if (boxOffset > labelLength) {
181
+ boxDistanceToAnchor += boxOffset - labelLength;
182
+ }
179
183
 
180
184
  if (boxDistanceToAnchor < anchorDistance) {
181
185
  // The line doesn't extend far enough back for this box, skip it
@@ -227,4 +231,4 @@ class CollisionFeature {
227
231
  }
228
232
  }
229
233
 
230
- module.exports = CollisionFeature;
234
+ export default CollisionFeature;
@@ -1,9 +1,7 @@
1
- const { default: Point } = require('@mapbox/point-geometry');
2
-
3
- const intersectionTests = require('../util/intersection_tests');
4
- const Grid = require('./grid_index');
5
-
6
- const projection = require('../symbol/projection');
1
+ import Point from '@mapbox/point-geometry';
2
+ import * as projection from '../symbol/projection.js';
3
+ import * as intersectionTests from '../util/intersection_tests.js';
4
+ import Grid from './grid_index.js';
7
5
 
8
6
  // When a symbol crosses the edge that causes it to be included in
9
7
  // collision detection, it will cause changes in the symbols around
@@ -382,4 +380,4 @@ function markCollisionCircleUsed(collisionCircles, index, used) {
382
380
  collisionCircles[index + 4] = used ? 1 : 0;
383
381
  }
384
382
 
385
- module.exports = CollisionIndex;
383
+ export default CollisionIndex;
@@ -1,6 +1,4 @@
1
- const EXTENT = require('../data/extent');
2
-
3
- const { SymbolInstanceArray } = require('../data/array_types');
1
+ import EXTENT from '../data/extent.js';
4
2
 
5
3
  /*
6
4
  The CrossTileSymbolIndex generally works on the assumption that
@@ -240,7 +238,9 @@ class CrossTileSymbolIndex {
240
238
 
241
239
  for (const tile of tiles) {
242
240
  const symbolBucket = tile.getBucket(styleLayer);
243
- if (!symbolBucket || styleLayer.id !== symbolBucket.layerIds[0]) continue;
241
+ if (!symbolBucket || styleLayer.id !== symbolBucket.layers[0].id) {
242
+ continue;
243
+ }
244
244
 
245
245
  if (!symbolBucket.bucketInstanceId) {
246
246
  symbolBucket.bucketInstanceId = ++this.maxBucketInstanceId;
@@ -269,4 +269,4 @@ class CrossTileSymbolIndex {
269
269
  }
270
270
  }
271
271
 
272
- module.exports = CrossTileSymbolIndex;
272
+ export default CrossTileSymbolIndex;
@@ -1,9 +1,6 @@
1
- const interpolate = require('../util/interpolate');
2
-
3
- const Anchor = require('../symbol/anchor');
4
- const checkMaxAngle = require('./check_max_angle');
5
-
6
- module.exports = { getAnchors, getCenterAnchor };
1
+ import Anchor from '../symbol/anchor.js';
2
+ import interpolate from '../util/interpolate.js';
3
+ import checkMaxAngle from './check_max_angle.js';
7
4
 
8
5
  function getLineLength(line) {
9
6
  let lineLength = 0;
@@ -24,7 +21,7 @@ function getShapedLabelLength(shapedText, shapedIcon) {
24
21
  );
25
22
  }
26
23
 
27
- function getCenterAnchor(line, maxAngle, shapedText, shapedIcon, glyphSize, boxScale) {
24
+ export function getCenterAnchor(line, maxAngle, shapedText, shapedIcon, glyphSize, boxScale) {
28
25
  const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale);
29
26
  const labelLength = getShapedLabelLength(shapedText, shapedIcon) * boxScale;
30
27
 
@@ -55,7 +52,17 @@ function getCenterAnchor(line, maxAngle, shapedText, shapedIcon, glyphSize, boxS
55
52
  }
56
53
  }
57
54
 
58
- function getAnchors(line, spacing, maxAngle, shapedText, shapedIcon, glyphSize, boxScale, overscaling, tileExtent) {
55
+ export function getAnchors(
56
+ line,
57
+ spacing,
58
+ maxAngle,
59
+ shapedText,
60
+ shapedIcon,
61
+ glyphSize,
62
+ boxScale,
63
+ overscaling,
64
+ tileExtent
65
+ ) {
59
66
  // Resample a line to get anchor points for labels and check that each
60
67
  // potential label passes text-max-angle check and has enough froom to fit
61
68
  // on the line.
@@ -1,4 +1,4 @@
1
- const { clamp } = require('../util/util');
1
+ import { clamp } from '../util/util.js';
2
2
 
3
3
  /**
4
4
  * GridIndex is a data structure for testing the intersection of
@@ -266,7 +266,9 @@ class GridIndex {
266
266
  for (let x = cx1; x <= cx2; x++) {
267
267
  for (let y = cy1; y <= cy2; y++) {
268
268
  const cellIndex = xCellCount * y + x;
269
- if (fn.call(this, x1, y1, x2, y2, cellIndex, ...args)) return;
269
+ if (fn.call(this, x1, y1, x2, y2, cellIndex, ...args)) {
270
+ return;
271
+ }
270
272
  }
271
273
  }
272
274
 
@@ -280,7 +282,7 @@ class GridIndex {
280
282
  }
281
283
  }
282
284
 
283
- module.exports = GridIndex;
285
+ export default GridIndex;
284
286
 
285
287
  function circlesCollide(x1, y1, r1, x2, y2, r2) {
286
288
  const dx = x2 - x1;
@@ -1,4 +1,4 @@
1
- module.exports = function (features) {
1
+ export default function (features) {
2
2
  const leftIndex = new Map();
3
3
  const rightIndex = new Map();
4
4
  const mergedFeatures = [];
@@ -73,4 +73,4 @@ module.exports = function (features) {
73
73
  const { x, y } = geom.at(onRight ? -1 : 0);
74
74
  return `${text}:${x}:${y}`;
75
75
  }
76
- };
76
+ }
@@ -14,4 +14,4 @@ class OpacityState {
14
14
  }
15
15
  }
16
16
 
17
- module.exports = OpacityState;
17
+ export default OpacityState;