@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,14 +1,13 @@
1
- const loadGeometry = require('./load_geometry');
2
- const EXTENT = require('./extent');
3
- const featureFilter = require('../style-spec/feature_filter');
4
- const Grid = require('grid-index');
5
- const dictionaryCoder = require('../util/dictionary_coder');
6
- const GeoJSONFeature = require('../util/vectortile_to_geojson');
7
- const { arraysIntersect } = require('../util/object');
8
- const EvaluationParameters = require('../style/evaluation_parameters');
9
- const { polygonIntersectsBox } = require('../util/intersection_tests');
10
-
11
- const { FeatureIndexArray } = require('./array_types');
1
+ import Grid from 'grid-index';
2
+ import EvaluationParameters from '../style/evaluation_parameters.js';
3
+ import featureFilter from '../style-spec/feature_filter/index.js';
4
+ import dictionaryCoder from '../util/dictionary_coder.js';
5
+ import { polygonIntersectsBox } from '../util/intersection_tests.js';
6
+ import { arraysIntersect } from '../util/object.js';
7
+ import GeoJSONFeature from '../util/vectortile_to_geojson.js';
8
+ import { FeatureIndexArray } from './array_types.js';
9
+ import EXTENT from './extent.js';
10
+ import loadGeometry from './load_geometry.js';
12
11
 
13
12
  class FeatureIndex {
14
13
  constructor(tileID, grid = new Grid(EXTENT, 16, 0), featureIndexArray = new FeatureIndexArray()) {
@@ -85,7 +84,9 @@ class FeatureIndex {
85
84
  const index = matching[k];
86
85
 
87
86
  // don't check the same feature more than once
88
- if (index === previousIndex) continue;
87
+ if (index === previousIndex) {
88
+ continue;
89
+ }
89
90
  previousIndex = index;
90
91
 
91
92
  const match = this.featureIndexArray.get(index);
@@ -136,13 +137,17 @@ class FeatureIndex {
136
137
  intersectionTest
137
138
  ) {
138
139
  const layerIDs = this.bucketLayerIDs[bucketIndex];
139
- if (filterLayerIDs && !arraysIntersect(filterLayerIDs, layerIDs)) return;
140
+ if (filterLayerIDs && !arraysIntersect(filterLayerIDs, layerIDs)) {
141
+ return;
142
+ }
140
143
 
141
144
  const sourceLayerName = this.sourceLayerCoder.decode(sourceLayerIndex);
142
145
  const sourceLayer = this.vtLayers[sourceLayerName];
143
146
  const feature = sourceLayer.feature(featureIndex);
144
147
 
145
- if (!filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) return;
148
+ if (!filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) {
149
+ return;
150
+ }
146
151
 
147
152
  const { x, y, z } = this.tileID.canonical;
148
153
  for (const layerID of layerIDs) {
@@ -151,7 +156,9 @@ class FeatureIndex {
151
156
  }
152
157
 
153
158
  const styleLayer = styleLayers.get(layerID);
154
- if (!styleLayer) continue;
159
+ if (!styleLayer) {
160
+ continue;
161
+ }
155
162
 
156
163
  const intersectionZ = !intersectionTest || intersectionTest(feature, styleLayer);
157
164
  if (!intersectionZ) {
@@ -189,7 +196,7 @@ class FeatureIndex {
189
196
  }
190
197
  }
191
198
 
192
- module.exports = FeatureIndex;
199
+ export default FeatureIndex;
193
200
 
194
201
  function getBounds(geometry) {
195
202
  let minX = Number.POSITIVE_INFINITY;
@@ -197,10 +204,18 @@ function getBounds(geometry) {
197
204
  let maxX = Number.NEGATIVE_INFINITY;
198
205
  let maxY = Number.NEGATIVE_INFINITY;
199
206
  for (const { x, y } of geometry) {
200
- if (x < minX) minX = x;
201
- if (x > maxX) maxX = x;
202
- if (y < minY) minY = y;
203
- if (y > maxY) maxY = y;
207
+ if (x < minX) {
208
+ minX = x;
209
+ }
210
+ if (x > maxX) {
211
+ maxX = x;
212
+ }
213
+ if (y < minY) {
214
+ minY = y;
215
+ }
216
+ if (y > maxY) {
217
+ maxY = y;
218
+ }
204
219
  }
205
220
  return { minX, minY, maxX, maxY };
206
221
  }
@@ -1,4 +1,4 @@
1
- const { LineIndexArray, TriangleIndexArray, LineStripIndexArray } = require('./array_types');
1
+ export { LineIndexArray, LineStripIndexArray, TriangleIndexArray } from './array_types.js';
2
2
 
3
3
  /**
4
4
  * An index array stores Uint16 indices of vertexes in a corresponding vertex array. We use
@@ -7,8 +7,3 @@ const { LineIndexArray, TriangleIndexArray, LineStripIndexArray } = require('./a
7
7
  * forming a line strip.
8
8
  * @private
9
9
  */
10
- module.exports = {
11
- LineIndexArray,
12
- TriangleIndexArray,
13
- LineStripIndexArray
14
- };
@@ -1,6 +1,5 @@
1
- const warn = require('../util/warn');
2
-
3
- const EXTENT = require('./extent');
1
+ import warn from '../util/warn.js';
2
+ import EXTENT from './extent.js';
4
3
 
5
4
  // These bounds define the minimum and maximum supported coordinate values.
6
5
  // While visible coordinates are within [0, EXTENT], tiles may theoretically
@@ -21,13 +20,11 @@ const bounds = createBounds(16);
21
20
  * @param {VectorTileFeature} feature
22
21
  * @private
23
22
  */
24
- module.exports = function loadGeometry(feature) {
23
+ export default function loadGeometry(feature) {
25
24
  const scale = EXTENT / feature.extent;
26
25
  const geometry = feature.loadGeometry();
27
- for (let r = 0; r < geometry.length; r++) {
28
- const ring = geometry[r];
29
- for (let p = 0; p < ring.length; p++) {
30
- const point = ring[p];
26
+ for (const ring of geometry) {
27
+ for (const point of ring) {
31
28
  // round here because mapbox-gl-native uses integers to represent
32
29
  // points and we need to do the same to avoid renering differences.
33
30
  point.x = Math.round(point.x * scale);
@@ -39,4 +36,4 @@ module.exports = function loadGeometry(feature) {
39
36
  }
40
37
  }
41
38
  return geometry;
42
- };
39
+ }
@@ -1,3 +1,2 @@
1
- const { createLayout } = require('../util/struct_array');
2
-
3
- module.exports = createLayout([{ name: 'a_pos', type: 'Int16', components: 2 }]);
1
+ import { createLayout } from '../util/struct_array.js';
2
+ export default createLayout([{ name: 'a_pos', type: 'Int16', components: 2 }]);
@@ -1,14 +1,14 @@
1
- const { packUint8ToFloat } = require('../shaders/encode_attribute');
2
- const { supportsPropertyExpression } = require('@mapwhit/style-expressions');
3
- const { PossiblyEvaluatedPropertyValue } = require('../style/properties');
4
- const {
1
+ import { supportsPropertyExpression } from '@mapwhit/style-expressions';
2
+ import { Uniform1f, Uniform4f, UniformColor } from '../render/uniform_binding.js';
3
+ import { packUint8ToFloat } from '../shaders/encode_attribute.js';
4
+ import EvaluationParameters from '../style/evaluation_parameters.js';
5
+ import { PossiblyEvaluatedPropertyValue } from '../style/properties.js';
6
+ import {
7
+ PatternLayoutArray,
5
8
  StructArrayLayout1f4,
6
9
  StructArrayLayout2f8,
7
- StructArrayLayout4f16,
8
- PatternLayoutArray
9
- } = require('./array_types');
10
- const EvaluationParameters = require('../style/evaluation_parameters');
11
- const { Uniform1f, UniformColor, Uniform4f } = require('../render/uniform_binding');
10
+ StructArrayLayout4f16
11
+ } from './array_types.js';
12
12
 
13
13
  function packColor(color) {
14
14
  return [packUint8ToFloat(255 * color.r, 255 * color.g), packUint8ToFloat(255 * color.b, 255 * color.a)];
@@ -96,8 +96,12 @@ class CrossFadedConstantBinder {
96
96
 
97
97
  setUniforms(context, uniform, globals, currentValue, uniformName) {
98
98
  const pos = this.patternPositions;
99
- if (uniformName === 'u_pattern_to' && pos.patternTo) uniform.set(pos.patternTo);
100
- if (uniformName === 'u_pattern_from' && pos.patternFrom) uniform.set(pos.patternFrom);
99
+ if (uniformName === 'u_pattern_to' && pos.patternTo) {
100
+ uniform.set(pos.patternTo);
101
+ }
102
+ if (uniformName === 'u_pattern_from' && pos.patternFrom) {
103
+ uniform.set(pos.patternFrom);
104
+ }
101
105
  }
102
106
 
103
107
  getBinding(context, location) {
@@ -350,7 +354,9 @@ class CrossFadedCompositeBinder {
350
354
  const imageMid = imagePositions[mid];
351
355
  const imageMax = imagePositions[max];
352
356
 
353
- if (!imageMin || !imageMid || !imageMax) return;
357
+ if (!imageMin || !imageMid || !imageMax) {
358
+ return;
359
+ }
354
360
 
355
361
  for (let i = start; i < length; i++) {
356
362
  zoomInArray.emplaceBack(
@@ -393,7 +399,9 @@ class CrossFadedCompositeBinder {
393
399
  const imageMid = imagePositions[mid];
394
400
  const imageMax = imagePositions[max];
395
401
 
396
- if (!imageMin || !imageMid || !imageMax) return;
402
+ if (!imageMin || !imageMid || !imageMax) {
403
+ return;
404
+ }
397
405
  for (let i = start; i < end; i++) {
398
406
  zoomInArray.emplace(
399
407
  i,
@@ -438,8 +446,12 @@ class CrossFadedCompositeBinder {
438
446
  }
439
447
 
440
448
  destroy() {
441
- if (this.zoomOutPaintVertexBuffer) this.zoomOutPaintVertexBuffer.destroy();
442
- if (this.zoomInPaintVertexBuffer) this.zoomInPaintVertexBuffer.destroy();
449
+ if (this.zoomOutPaintVertexBuffer) {
450
+ this.zoomOutPaintVertexBuffer.destroy();
451
+ }
452
+ if (this.zoomInPaintVertexBuffer) {
453
+ this.zoomInPaintVertexBuffer.destroy();
454
+ }
443
455
  }
444
456
 
445
457
  setUniforms(context, uniform) {
@@ -471,7 +483,7 @@ class CrossFadedCompositeBinder {
471
483
  *
472
484
  * @private
473
485
  */
474
- class ProgramConfiguration {
486
+ export default class ProgramConfiguration {
475
487
  constructor() {
476
488
  this.binders = {};
477
489
  this.cacheKey = '';
@@ -486,7 +498,9 @@ class ProgramConfiguration {
486
498
  const keys = [];
487
499
 
488
500
  for (const property in layer._paint._values) {
489
- if (!filterProperties(property)) continue;
501
+ if (!filterProperties(property)) {
502
+ continue;
503
+ }
490
504
  const value = layer._paint.get(property);
491
505
  if (
492
506
  !(value instanceof PossiblyEvaluatedPropertyValue) ||
@@ -574,7 +588,9 @@ class ProgramConfiguration {
574
588
  let dirty = false;
575
589
  for (const id in featureStates) {
576
590
  const posArray = this._idMap[id];
577
- if (!posArray) continue;
591
+ if (!posArray) {
592
+ continue;
593
+ }
578
594
 
579
595
  const featureState = featureStates[id];
580
596
  for (const pos of posArray) {
@@ -582,7 +598,9 @@ class ProgramConfiguration {
582
598
 
583
599
  for (const property in this.binders) {
584
600
  const binder = this.binders[property];
585
- if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) continue;
601
+ if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) {
602
+ continue;
603
+ }
586
604
  if (binder.expression.isStateDependent === true) {
587
605
  //AHM: Remove after https://github.com/mapbox/mapbox-gl-js/issues/6255
588
606
  const value = layer._paint.get(property);
@@ -639,7 +657,9 @@ class ProgramConfiguration {
639
657
  if (binder instanceof CrossFadedCompositeBinder) {
640
658
  const patternVertexBuffer =
641
659
  crossfade.fromScale === 2 ? binder.zoomInPaintVertexBuffer : binder.zoomOutPaintVertexBuffer;
642
- if (patternVertexBuffer) buffers.push(patternVertexBuffer);
660
+ if (patternVertexBuffer) {
661
+ buffers.push(patternVertexBuffer);
662
+ }
643
663
  } else if (
644
664
  (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) &&
645
665
  binder.paintVertexBuffer
@@ -676,7 +696,7 @@ class ProgramConfiguration {
676
696
  }
677
697
  }
678
698
 
679
- class ProgramConfigurationSet {
699
+ export class ProgramConfigurationSet {
680
700
  constructor(layoutAttributes, layers, zoom, filterProperties = () => true) {
681
701
  this.programConfigurations = {};
682
702
  for (const layer of layers) {
@@ -706,7 +726,9 @@ class ProgramConfigurationSet {
706
726
  }
707
727
 
708
728
  upload(context) {
709
- if (!this.needsUpload) return;
729
+ if (!this.needsUpload) {
730
+ return;
731
+ }
710
732
  for (const layerId in this.programConfigurations) {
711
733
  this.programConfigurations[layerId].upload(context);
712
734
  }
@@ -775,7 +797,3 @@ function layoutType(property, type, binderType) {
775
797
  const layoutException = getLayoutException(property);
776
798
  return layoutException?.[binderType] || defaultLayouts[type][binderType];
777
799
  }
778
-
779
- ProgramConfiguration.ProgramConfigurationSet = ProgramConfigurationSet;
780
-
781
- module.exports = ProgramConfiguration;
@@ -1,6 +1,6 @@
1
- const { createLayout } = require('../util/struct_array');
1
+ import { createLayout } from '../util/struct_array.js';
2
2
 
3
- module.exports = createLayout([
3
+ export default createLayout([
4
4
  { name: 'a_pos', type: 'Int16', components: 2 },
5
5
  { name: 'a_texture_pos', type: 'Int16', components: 2 }
6
6
  ]);
@@ -1,4 +1,4 @@
1
- const warn = require('../util/warn');
1
+ import warn from '../util/warn.js';
2
2
 
3
3
  class SegmentVector {
4
4
  constructor(segments = []) {
@@ -6,10 +6,11 @@ class SegmentVector {
6
6
  }
7
7
 
8
8
  prepareSegment(numVertices, layoutVertexArray, indexArray) {
9
- if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH)
9
+ if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {
10
10
  warn.once(
11
11
  `Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${numVertices}`
12
12
  );
13
+ }
13
14
  let segment = this.segments.at(-1);
14
15
  if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {
15
16
  segment = {
@@ -56,4 +57,4 @@ class SegmentVector {
56
57
  */
57
58
  SegmentVector.MAX_VERTEX_ARRAY_LENGTH = 2 ** 16 - 1;
58
59
 
59
- module.exports = SegmentVector;
60
+ export default SegmentVector;
@@ -75,4 +75,4 @@ class Coordinate {
75
75
  }
76
76
  }
77
77
 
78
- module.exports = Coordinate;
78
+ export default Coordinate;
@@ -1,4 +1,5 @@
1
- const { wrap } = require('../util/util');
1
+ import { wrap } from '../util/util.js';
2
+ import LngLatBounds from './lng_lat_bounds.js';
2
3
 
3
4
  /**
4
5
  * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.
@@ -80,7 +81,6 @@ class LngLat {
80
81
  const earthCircumferenceInMetersAtEquator = 40075017;
81
82
  const latAccuracy = (360 * radius) / earthCircumferenceInMetersAtEquator;
82
83
  const lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
83
- const LngLatBounds = require('./lng_lat_bounds');
84
84
 
85
85
  return new LngLatBounds(
86
86
  new LngLat(this.lng - lngAccuracy, this.lat - latAccuracy),
@@ -126,4 +126,4 @@ class LngLat {
126
126
  * var v2 = [-122.420679, 37.772537];
127
127
  */
128
128
 
129
- module.exports = LngLat;
129
+ export default LngLat;
@@ -1,4 +1,4 @@
1
- const LngLat = require('./lng_lat');
1
+ import LngLat from './lng_lat.js';
2
2
 
3
3
  /**
4
4
  * A `LngLatBounds` object represents a geographical bounding box,
@@ -73,7 +73,9 @@ class LngLatBounds {
73
73
  sw2 = obj._sw;
74
74
  ne2 = obj._ne;
75
75
 
76
- if (!sw2 || !ne2) return this;
76
+ if (!sw2 || !ne2) {
77
+ return this;
78
+ }
77
79
  } else {
78
80
  if (Array.isArray(obj)) {
79
81
  if (obj.every(Array.isArray)) {
@@ -231,7 +233,9 @@ class LngLatBounds {
231
233
  * llb; // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}
232
234
  */
233
235
  static convert(input) {
234
- if (!input || input instanceof LngLatBounds) return input;
236
+ if (!input || input instanceof LngLatBounds) {
237
+ return input;
238
+ }
235
239
  return new LngLatBounds(input);
236
240
  }
237
241
  }
@@ -250,4 +254,4 @@ class LngLatBounds {
250
254
  * var v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
251
255
  */
252
256
 
253
- module.exports = LngLatBounds;
257
+ export default LngLatBounds;
@@ -1,13 +1,14 @@
1
- const LngLat = require('./lng_lat');
2
-
3
- const { default: Point } = require('@mapbox/point-geometry');
4
- const Coordinate = require('./coordinate');
5
- const { wrap, clamp } = require('../util/util');
6
- const interpolate = require('../util/interpolate');
7
- const tileCover = require('../util/tile_cover');
8
- const { UnwrappedTileID } = require('../source/tile_id');
9
- const EXTENT = require('../data/extent');
10
- const { vec4, mat4, mat2 } = require('@mapbox/gl-matrix');
1
+ import glMatrix from '@mapbox/gl-matrix';
2
+ import Point from '@mapbox/point-geometry';
3
+ import EXTENT from '../data/extent.js';
4
+ import { UnwrappedTileID } from '../source/tile_id.js';
5
+ import interpolate from '../util/interpolate.js';
6
+ import tileCover from '../util/tile_cover.js';
7
+ import { clamp, wrap } from '../util/util.js';
8
+ import Coordinate from './coordinate.js';
9
+ import LngLat from './lng_lat.js';
10
+
11
+ const { mat2, mat4, vec4 } = glMatrix;
11
12
 
12
13
  /**
13
14
  * A single transform, generally used for a single tile to be
@@ -57,7 +58,9 @@ class Transform {
57
58
  return this._minZoom;
58
59
  }
59
60
  set minZoom(zoom) {
60
- if (this._minZoom === zoom) return;
61
+ if (this._minZoom === zoom) {
62
+ return;
63
+ }
61
64
  this._minZoom = zoom;
62
65
  this.zoom = Math.max(this.zoom, zoom);
63
66
  }
@@ -66,7 +69,9 @@ class Transform {
66
69
  return this._maxZoom;
67
70
  }
68
71
  set maxZoom(zoom) {
69
- if (this._maxZoom === zoom) return;
72
+ if (this._maxZoom === zoom) {
73
+ return;
74
+ }
70
75
  this._maxZoom = zoom;
71
76
  this.zoom = Math.min(this.zoom, zoom);
72
77
  }
@@ -101,7 +106,9 @@ class Transform {
101
106
  }
102
107
  set bearing(bearing) {
103
108
  const b = (-wrap(bearing, -180, 180) * Math.PI) / 180;
104
- if (this.angle === b) return;
109
+ if (this.angle === b) {
110
+ return;
111
+ }
105
112
  this._unmodified = false;
106
113
  this.angle = b;
107
114
  this._calcMatrices();
@@ -116,7 +123,9 @@ class Transform {
116
123
  }
117
124
  set pitch(pitch) {
118
125
  const p = (clamp(pitch, 0, 60) / 180) * Math.PI;
119
- if (this._pitch === p) return;
126
+ if (this._pitch === p) {
127
+ return;
128
+ }
120
129
  this._unmodified = false;
121
130
  this._pitch = p;
122
131
  this._calcMatrices();
@@ -127,7 +136,9 @@ class Transform {
127
136
  }
128
137
  set fov(fov) {
129
138
  fov = Math.max(0.01, Math.min(60, fov));
130
- if (this._fov === fov) return;
139
+ if (this._fov === fov) {
140
+ return;
141
+ }
131
142
  this._unmodified = false;
132
143
  this._fov = (fov / 180) * Math.PI;
133
144
  this._calcMatrices();
@@ -138,7 +149,9 @@ class Transform {
138
149
  }
139
150
  set zoom(zoom) {
140
151
  const z = Math.min(Math.max(zoom, this.minZoom), this.maxZoom);
141
- if (this._zoom === z) return;
152
+ if (this._zoom === z) {
153
+ return;
154
+ }
142
155
  this._unmodified = false;
143
156
  this._zoom = z;
144
157
  this.scale = this.zoomScale(z);
@@ -152,7 +165,9 @@ class Transform {
152
165
  return this._center;
153
166
  }
154
167
  set center(center) {
155
- if (center.lat === this._center.lat && center.lng === this._center.lng) return;
168
+ if (center.lat === this._center.lat && center.lng === this._center.lng) {
169
+ return;
170
+ }
156
171
  this._unmodified = false;
157
172
  this._center = center;
158
173
  this._constrain();
@@ -192,7 +207,9 @@ class Transform {
192
207
  const extraWorldCopy = 1;
193
208
 
194
209
  for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) {
195
- if (w === 0) continue;
210
+ if (w === 0) {
211
+ continue;
212
+ }
196
213
  result.push(new UnwrappedTileID(w, tileID));
197
214
  }
198
215
  }
@@ -215,8 +232,12 @@ class Transform {
215
232
  let z = this.coveringZoomLevel(options);
216
233
  const actualZ = z;
217
234
 
218
- if (options.minzoom !== undefined && z < options.minzoom) return [];
219
- if (options.maxzoom !== undefined && z > options.maxzoom) z = options.maxzoom;
235
+ if (options.minzoom !== undefined && z < options.minzoom) {
236
+ return [];
237
+ }
238
+ if (options.maxzoom !== undefined && z > options.maxzoom) {
239
+ z = options.maxzoom;
240
+ }
220
241
 
221
242
  const centerCoord = this.pointCoordinate(this.centerPoint, z);
222
243
  const centerPoint = new Point(centerCoord.column - 0.5, centerCoord.row - 0.5);
@@ -346,7 +367,9 @@ class Transform {
346
367
  }
347
368
 
348
369
  pointCoordinate(p, zoom) {
349
- if (zoom === undefined) zoom = this.tileZoom;
370
+ if (zoom === undefined) {
371
+ zoom = this.tileZoom;
372
+ }
350
373
 
351
374
  const targetZ = 0;
352
375
  // since we don't know the correct projected z value for the point,
@@ -414,7 +437,9 @@ class Transform {
414
437
  }
415
438
 
416
439
  _constrain() {
417
- if (!this.center || !this.width || !this.height || this._constraining) return;
440
+ if (!this.center || !this.width || !this.height || this._constraining) {
441
+ return;
442
+ }
418
443
 
419
444
  this._constraining = true;
420
445
 
@@ -458,16 +483,24 @@ class Transform {
458
483
  const y = this.y;
459
484
  const h2 = size.y / 2;
460
485
 
461
- if (y - h2 < minY) y2 = minY + h2;
462
- if (y + h2 > maxY) y2 = maxY - h2;
486
+ if (y - h2 < minY) {
487
+ y2 = minY + h2;
488
+ }
489
+ if (y + h2 > maxY) {
490
+ y2 = maxY - h2;
491
+ }
463
492
  }
464
493
 
465
494
  if (this.lngRange) {
466
495
  const x = this.x;
467
496
  const w2 = size.x / 2;
468
497
 
469
- if (x - w2 < minX) x2 = minX + w2;
470
- if (x + w2 > maxX) x2 = maxX - w2;
498
+ if (x - w2 < minX) {
499
+ x2 = minX + w2;
500
+ }
501
+ if (x + w2 > maxX) {
502
+ x2 = maxX - w2;
503
+ }
471
504
  }
472
505
 
473
506
  // pan the map if the screen goes off the range
@@ -480,7 +513,9 @@ class Transform {
480
513
  }
481
514
 
482
515
  _calcMatrices() {
483
- if (!this.height) return;
516
+ if (!this.height) {
517
+ return;
518
+ }
484
519
 
485
520
  this.cameraToCenterDistance = (0.5 / Math.tan(this._fov / 2)) * this.height;
486
521
 
@@ -542,7 +577,9 @@ class Transform {
542
577
 
543
578
  // inverse matrix for conversion from screen coordinaes to location
544
579
  m = mat4.invert(new Float64Array(16), this.pixelMatrix);
545
- if (!m) throw new Error('failed to invert matrix');
580
+ if (!m) {
581
+ throw new Error('failed to invert matrix');
582
+ }
546
583
  this.pixelMatrixInverse = m;
547
584
 
548
585
  this._posMatrixCache = {};
@@ -551,7 +588,9 @@ class Transform {
551
588
 
552
589
  maxPitchScaleFactor() {
553
590
  // calcMatrices hasn't run yet
554
- if (!this.pixelMatrixInverse) return 1;
591
+ if (!this.pixelMatrixInverse) {
592
+ return 1;
593
+ }
555
594
 
556
595
  const coord = this.pointCoordinate(new Point(0, 0)).zoomTo(this.zoom);
557
596
  const p = [coord.column * this.tileSize, coord.row * this.tileSize, 0, 1];
@@ -612,4 +651,4 @@ class Transform {
612
651
  }
613
652
  }
614
653
 
615
- module.exports = Transform;
654
+ export default Transform;
@@ -1,4 +1,4 @@
1
- const { Color } = require('@mapwhit/style-expressions');
1
+ import { Color } from '@mapwhit/style-expressions';
2
2
 
3
3
  const ZERO = 0x0000;
4
4
  const ONE = 0x0001;
@@ -18,4 +18,4 @@ class ColorMode {
18
18
  }
19
19
  }
20
20
 
21
- module.exports = ColorMode;
21
+ export default ColorMode;