@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,12 +1,12 @@
1
- const CollisionIndex = require('./collision_index');
1
+ import assert from 'assert';
2
+ import EXTENT from '../data/extent.js';
3
+ import pixelsToTileUnits from '../source/pixels_to_tile_units.js';
4
+ import properties from '../style/style_layer/symbol_style_layer_properties.js';
5
+ import CollisionIndex from './collision_index.js';
6
+ import * as projection from './projection.js';
7
+ import * as symbolSize from './symbol_size.js';
2
8
 
3
- const EXTENT = require('../data/extent');
4
- const symbolSize = require('./symbol_size');
5
- const projection = require('./projection');
6
- const properties = require('../style/style_layer/symbol_style_layer_properties');
7
9
  const symbolLayoutProperties = properties.layout;
8
- const assert = require('assert');
9
- const pixelsToTileUnits = require('../source/pixels_to_tile_units');
10
10
 
11
11
  class OpacityState {
12
12
  constructor(prevState, increment, placed, skipFade) {
@@ -44,7 +44,7 @@ class JointPlacement {
44
44
  }
45
45
  }
46
46
 
47
- class RetainedQueryData {
47
+ export class RetainedQueryData {
48
48
  constructor(bucketInstanceId, featureIndex, sourceLayerIndex, bucketIndex, tileID) {
49
49
  this.bucketInstanceId = bucketInstanceId;
50
50
  this.featureIndex = featureIndex;
@@ -81,7 +81,7 @@ class CollisionGroups {
81
81
  }
82
82
  }
83
83
 
84
- class Placement {
84
+ export class Placement {
85
85
  constructor(transform, fadeDuration, crossSourceCollisions) {
86
86
  this.transform = transform.clone();
87
87
  this.collisionIndex = new CollisionIndex(this.transform);
@@ -96,7 +96,9 @@ class Placement {
96
96
  placeLayerTile(styleLayer, tile, showCollisionBoxes, seenCrossTileIDs) {
97
97
  const symbolBucket = tile.getBucket(styleLayer);
98
98
  const bucketFeatureIndex = tile.latestFeatureIndex;
99
- if (!symbolBucket || !bucketFeatureIndex || styleLayer.id !== symbolBucket.layerIds[0]) return;
99
+ if (!symbolBucket || !bucketFeatureIndex || styleLayer.id !== symbolBucket.layers[0].id) {
100
+ return;
101
+ }
100
102
 
101
103
  const collisionBoxArray = tile.collisionBoxArray;
102
104
 
@@ -399,17 +401,25 @@ class Placement {
399
401
 
400
402
  for (const tile of tiles) {
401
403
  const symbolBucket = tile.getBucket(styleLayer);
402
- if (symbolBucket && tile.latestFeatureIndex && styleLayer.id === symbolBucket.layerIds[0]) {
404
+ if (symbolBucket && tile.latestFeatureIndex && styleLayer.id === symbolBucket.layers[0].id) {
403
405
  this.updateBucketOpacities(symbolBucket, seenCrossTileIDs, tile.collisionBoxArray);
404
406
  }
405
407
  }
406
408
  }
407
409
 
408
410
  updateBucketOpacities(bucket, seenCrossTileIDs, collisionBoxArray) {
409
- if (bucket.hasTextData()) bucket.text.opacityVertexArray.clear();
410
- if (bucket.hasIconData()) bucket.icon.opacityVertexArray.clear();
411
- if (bucket.hasCollisionBoxData()) bucket.collisionBox.collisionVertexArray.clear();
412
- if (bucket.hasCollisionCircleData()) bucket.collisionCircle.collisionVertexArray.clear();
411
+ if (bucket.hasTextData()) {
412
+ bucket.text.opacityVertexArray.clear();
413
+ }
414
+ if (bucket.hasIconData()) {
415
+ bucket.icon.opacityVertexArray.clear();
416
+ }
417
+ if (bucket.hasCollisionBoxData()) {
418
+ bucket.collisionBox.collisionVertexArray.clear();
419
+ }
420
+ if (bucket.hasCollisionCircleData()) {
421
+ bucket.collisionCircle.collisionVertexArray.clear();
422
+ }
413
423
 
414
424
  const layout = bucket.layers[0]._layout;
415
425
  const duplicateOpacityState = new JointOpacityState(null, 0, false, false, true);
@@ -579,8 +589,3 @@ function packOpacity(opacityState) {
579
589
  targetBit
580
590
  );
581
591
  }
582
-
583
- module.exports = {
584
- RetainedQueryData,
585
- Placement
586
- };
@@ -1,22 +1,13 @@
1
- const { default: Point } = require('@mapbox/point-geometry');
2
-
3
- const { mat4, vec4 } = require('@mapbox/gl-matrix');
4
- const symbolSize = require('./symbol_size');
5
- const { addDynamicAttributes } = require('../data/bucket/symbol_bucket');
6
- const properties = require('../style/style_layer/symbol_style_layer_properties');
1
+ import glMatrix from '@mapbox/gl-matrix';
2
+ import Point from '@mapbox/point-geometry';
3
+ import { addDynamicAttributes } from '../data/bucket/symbol_bucket.js';
4
+ import properties from '../style/style_layer/symbol_style_layer_properties.js';
5
+ import { WritingMode } from '../symbol/shaping.js';
6
+ import * as symbolSize from './symbol_size.js';
7
+
8
+ const { mat4, vec4 } = glMatrix;
7
9
  const symbolLayoutProperties = properties.layout;
8
10
 
9
- const { WritingMode } = require('../symbol/shaping');
10
-
11
- module.exports = {
12
- updateLineLabels,
13
- getLabelPlaneMatrix,
14
- getGlCoordMatrix,
15
- project,
16
- placeFirstAndLastGlyph,
17
- xyTransformMat4
18
- };
19
-
20
11
  /*
21
12
  * # Overview of coordinate spaces
22
13
  *
@@ -65,7 +56,7 @@ module.exports = {
65
56
  /*
66
57
  * Returns a matrix for converting from tile units to the correct label coordinate space.
67
58
  */
68
- function getLabelPlaneMatrix(posMatrix, pitchWithMap, rotateWithMap, transform, pixelsToTileUnits) {
59
+ export function getLabelPlaneMatrix(posMatrix, pitchWithMap, rotateWithMap, transform, pixelsToTileUnits) {
69
60
  const m = mat4.identity(new Float32Array(16));
70
61
  if (pitchWithMap) {
71
62
  mat4.identity(m);
@@ -84,7 +75,7 @@ function getLabelPlaneMatrix(posMatrix, pitchWithMap, rotateWithMap, transform,
84
75
  /*
85
76
  * Returns a matrix for converting from the correct label coordinate space to gl coords.
86
77
  */
87
- function getGlCoordMatrix(posMatrix, pitchWithMap, rotateWithMap, transform, pixelsToTileUnits) {
78
+ export function getGlCoordMatrix(posMatrix, pitchWithMap, rotateWithMap, transform, pixelsToTileUnits) {
88
79
  const m = mat4.identity(new Float32Array(16));
89
80
  if (pitchWithMap) {
90
81
  mat4.multiply(m, m, posMatrix);
@@ -100,7 +91,7 @@ function getGlCoordMatrix(posMatrix, pitchWithMap, rotateWithMap, transform, pix
100
91
  return m;
101
92
  }
102
93
 
103
- function project(point, matrix) {
94
+ export function project(point, matrix) {
104
95
  const pos = [point.x, point.y, 0, 1];
105
96
  xyTransformMat4(pos, pos, matrix);
106
97
  const w = pos[3];
@@ -122,7 +113,7 @@ function isVisible(anchorPos, clippingBuffer) {
122
113
  * Update the `dynamicLayoutVertexBuffer` for the buffer with the correct glyph positions for the current map view.
123
114
  * This is only run on labels that are aligned with lines. Horizontal labels are handled entirely in the shader.
124
115
  */
125
- function updateLineLabels(
116
+ export function updateLineLabels(
126
117
  bucket,
127
118
  posMatrix,
128
119
  painter,
@@ -233,7 +224,7 @@ function updateLineLabels(
233
224
  }
234
225
  }
235
226
 
236
- function placeFirstAndLastGlyph(
227
+ export function placeFirstAndLastGlyph(
237
228
  fontScale,
238
229
  glyphOffsetArray,
239
230
  lineOffsetX,
@@ -269,7 +260,9 @@ function placeFirstAndLastGlyph(
269
260
  projectionCache,
270
261
  returnTileDistance
271
262
  );
272
- if (!firstPlacedGlyph) return null;
263
+ if (!firstPlacedGlyph) {
264
+ return null;
265
+ }
273
266
 
274
267
  const lastPlacedGlyph = placeGlyphAlongLine(
275
268
  fontScale * lastGlyphOffset,
@@ -286,7 +279,9 @@ function placeFirstAndLastGlyph(
286
279
  projectionCache,
287
280
  returnTileDistance
288
281
  );
289
- if (!lastPlacedGlyph) return null;
282
+ if (!lastPlacedGlyph) {
283
+ return null;
284
+ }
290
285
 
291
286
  return { first: firstPlacedGlyph, last: lastPlacedGlyph };
292
287
  }
@@ -428,7 +423,9 @@ function placeGlyphsAlongLine(
428
423
  projectionCache,
429
424
  false
430
425
  );
431
- if (!singleGlyph) return { notEnoughRoom: true };
426
+ if (!singleGlyph) {
427
+ return { notEnoughRoom: true };
428
+ }
432
429
 
433
430
  placedGlyphs = [singleGlyph];
434
431
  }
@@ -486,7 +483,9 @@ function placeGlyphAlongLine(
486
483
  angle = Math.PI;
487
484
  }
488
485
 
489
- if (dir < 0) angle += Math.PI;
486
+ if (dir < 0) {
487
+ angle += Math.PI;
488
+ }
490
489
 
491
490
  let currentIndex = dir > 0 ? lineStartIndex + anchorSegment : lineStartIndex + anchorSegment + 1;
492
491
 
@@ -501,7 +500,9 @@ function placeGlyphAlongLine(
501
500
  currentIndex += dir;
502
501
 
503
502
  // offset does not fit on the projected line
504
- if (currentIndex < lineStartIndex || currentIndex >= lineEndIndex) return null;
503
+ if (currentIndex < lineStartIndex || currentIndex >= lineEndIndex) {
504
+ return null;
505
+ }
505
506
 
506
507
  prev = current;
507
508
 
@@ -591,7 +592,7 @@ function hideGlyphs(num, dynamicLayoutVertexArray) {
591
592
 
592
593
  // For line label layout, we're not using z output and our w input is always 1
593
594
  // This custom matrix transformation ignores those components to make projection faster
594
- function xyTransformMat4(out, a, m) {
595
+ export function xyTransformMat4(out, a, m) {
595
596
  const x = a[0];
596
597
  const y = a[1];
597
598
  out[0] = m[0] * x + m[4] * y + m[12];
@@ -1,6 +1,5 @@
1
- const { default: Point } = require('@mapbox/point-geometry');
2
-
3
- const { GLYPH_PBF_BORDER } = require('../style/parse_glyph_pbf');
1
+ import Point from '@mapbox/point-geometry';
2
+ import { GLYPH_PBF_BORDER } from '../style/parse_glyph_pbf.js';
4
3
 
5
4
  /**
6
5
  * A textured quad for rendering a single icon or glyph.
@@ -20,7 +19,7 @@ const { GLYPH_PBF_BORDER } = require('../style/parse_glyph_pbf');
20
19
  * Create the quads used for rendering an icon.
21
20
  * @private
22
21
  */
23
- function getIconQuads(anchor, shapedIcon, layer, alongLine, shapedText, feature) {
22
+ export function getIconQuads(anchor, shapedIcon, layer, alongLine, shapedText, feature) {
24
23
  const image = shapedIcon.image;
25
24
  const layout = layer._layout;
26
25
 
@@ -92,7 +91,7 @@ function getIconQuads(anchor, shapedIcon, layer, alongLine, shapedText, feature)
92
91
  * Create the quads used for rendering a text label.
93
92
  * @private
94
93
  */
95
- function getGlyphQuads(anchor, shaping, layer, alongLine, feature, positions) {
94
+ export function getGlyphQuads(anchor, shaping, layer, alongLine, feature, positions) {
96
95
  const oneEm = 24;
97
96
  const textRotate = (layer._layout.get('text-rotate').evaluate(feature, {}) * Math.PI) / 180;
98
97
  const textOffset = layer._layout
@@ -107,10 +106,14 @@ function getGlyphQuads(anchor, shaping, layer, alongLine, feature, positions) {
107
106
  const positionedGlyph = positionedGlyphs[k];
108
107
  const glyphPositions = positions[positionedGlyph.fontStack];
109
108
  const glyph = glyphPositions?.[positionedGlyph.glyph];
110
- if (!glyph) continue;
109
+ if (!glyph) {
110
+ continue;
111
+ }
111
112
 
112
113
  const rect = glyph.rect;
113
- if (!rect) continue;
114
+ if (!rect) {
115
+ continue;
116
+ }
114
117
 
115
118
  // The rects have an addditional buffer that is not included in their size.
116
119
  const glyphPadding = 1.0;
@@ -167,8 +170,3 @@ function getGlyphQuads(anchor, shaping, layer, alongLine, feature, positions) {
167
170
 
168
171
  return quads;
169
172
  }
170
-
171
- module.exports = {
172
- getIconQuads,
173
- getGlyphQuads
174
- };
@@ -1,19 +1,13 @@
1
- const { charHasUprightVerticalOrientation, charAllowsIdeographicBreaking } = require('../util/script_detection');
2
- const verticalizePunctuation = require('../util/verticalize_punctuation');
3
- const { plugin: rtlTextPlugin } = require('../source/rtl_text_plugin');
1
+ import { plugin as rtlTextPlugin } from '../source/rtl_text_plugin.js';
2
+ import { charAllowsIdeographicBreaking, charHasUprightVerticalOrientation } from '../util/script_detection.js';
3
+ import verticalizePunctuation from '../util/verticalize_punctuation.js';
4
4
 
5
- const WritingMode = {
5
+ export const WritingMode = {
6
6
  horizontal: 1,
7
7
  vertical: 2,
8
8
  horizontalOnly: 3
9
9
  };
10
10
 
11
- module.exports = {
12
- shapeText,
13
- shapeIcon,
14
- WritingMode
15
- };
16
-
17
11
  class TaggedString {
18
12
  constructor() {
19
13
  this.text = '';
@@ -98,7 +92,7 @@ function breakLines(input, lineBreakPoints) {
98
92
  return lines;
99
93
  }
100
94
 
101
- function shapeText(
95
+ export function shapeText(
102
96
  text,
103
97
  glyphs,
104
98
  defaultFontStack,
@@ -168,7 +162,9 @@ function shapeText(
168
162
 
169
163
  shapeLines(shaping, glyphs, lines, lineHeight, textAnchor, textJustify, writingMode, spacing, verticalHeight);
170
164
 
171
- if (!positionedGlyphs.length) return false;
165
+ if (!positionedGlyphs.length) {
166
+ return false;
167
+ }
172
168
 
173
169
  shaping.text = shaping.text.toString();
174
170
  return shaping;
@@ -210,7 +206,9 @@ function determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap) {
210
206
  const section = logicalInput.getSection(index);
211
207
  const positions = glyphMap[section.fontStack];
212
208
  const glyph = positions?.[logicalInput.getCharCode(index)];
213
- if (!glyph) continue;
209
+ if (!glyph) {
210
+ continue;
211
+ }
214
212
  totalWidth += glyph.metrics.advance * section.scale + spacing;
215
213
  }
216
214
 
@@ -283,9 +281,13 @@ function leastBadBreaks(lastLineBreak) {
283
281
  }
284
282
 
285
283
  function determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap) {
286
- if (!maxWidth) return [];
284
+ if (!maxWidth) {
285
+ return [];
286
+ }
287
287
 
288
- if (!logicalInput) return [];
288
+ if (!logicalInput) {
289
+ return [];
290
+ }
289
291
 
290
292
  const potentialLineBreaks = [];
291
293
  const targetWidth = determineAverageLineWidth(logicalInput, spacing, maxWidth, glyphMap);
@@ -298,7 +300,9 @@ function determineLineBreaks(logicalInput, spacing, maxWidth, glyphMap) {
298
300
  const positions = glyphMap[section.fontStack];
299
301
  const glyph = positions?.[codePoint];
300
302
 
301
- if (glyph && !whitespace[codePoint]) currentX += glyph.metrics.advance * section.scale + spacing;
303
+ if (glyph && !whitespace[codePoint]) {
304
+ currentX += glyph.metrics.advance * section.scale + spacing;
305
+ }
302
306
 
303
307
  // Ideographic characters, spaces, and word-breaking punctuation that often appear without
304
308
  // surrounding spaces.
@@ -395,7 +399,9 @@ function shapeLines(
395
399
  const positions = glyphMap[section.fontStack];
396
400
  const glyph = positions?.[codePoint];
397
401
 
398
- if (!glyph) continue;
402
+ if (!glyph) {
403
+ continue;
404
+ }
399
405
 
400
406
  if (!charHasUprightVerticalOrientation(codePoint) || writingMode === WritingMode.horizontal) {
401
407
  positionedGlyphs.push({
@@ -446,7 +452,9 @@ function shapeLines(
446
452
 
447
453
  // justify right = 1, left = 0, center = 0.5
448
454
  function justifyLine(positionedGlyphs, glyphMap, start, end, justify) {
449
- if (!justify) return;
455
+ if (!justify) {
456
+ return;
457
+ }
450
458
 
451
459
  const lastPositionedGlyph = positionedGlyphs[end];
452
460
  const positions = glyphMap[lastPositionedGlyph.fontStack];
@@ -471,7 +479,7 @@ function align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLin
471
479
  }
472
480
  }
473
481
 
474
- function shapeIcon(image, iconOffset, iconAnchor) {
482
+ export function shapeIcon(image, iconOffset, iconAnchor) {
475
483
  const { horizontalAlign, verticalAlign } = getAnchorAlignment(iconAnchor);
476
484
  const dx = iconOffset[0];
477
485
  const dy = iconOffset[1];
@@ -1,18 +1,17 @@
1
- const Anchor = require('./anchor');
2
-
3
- const { getAnchors, getCenterAnchor } = require('./get_anchors');
4
- const clipLine = require('./clip_line');
5
- const { shapeText, shapeIcon, WritingMode } = require('./shaping');
6
- const { getGlyphQuads, getIconQuads } = require('./quads');
7
- const CollisionFeature = require('./collision_feature');
8
- const warn = require('../util/warn');
9
- const { allowsVerticalWritingMode, allowsLetterSpacing } = require('../util/script_detection');
10
- const findPoleOfInaccessibility = require('../util/find_pole_of_inaccessibility');
11
- const classifyRings = require('../util/classify_rings');
12
- const EXTENT = require('../data/extent');
13
- const SymbolBucket = require('../data/bucket/symbol_bucket');
14
- const EvaluationParameters = require('../style/evaluation_parameters');
15
- const murmur3 = require('murmurhash-js');
1
+ import murmur3 from 'murmurhash-js';
2
+ import SymbolBucket from '../data/bucket/symbol_bucket.js';
3
+ import EXTENT from '../data/extent.js';
4
+ import EvaluationParameters from '../style/evaluation_parameters.js';
5
+ import classifyRings from '../util/classify_rings.js';
6
+ import findPoleOfInaccessibility from '../util/find_pole_of_inaccessibility.js';
7
+ import { allowsLetterSpacing, allowsVerticalWritingMode } from '../util/script_detection.js';
8
+ import warn from '../util/warn.js';
9
+ import Anchor from './anchor.js';
10
+ import clipLine from './clip_line.js';
11
+ import CollisionFeature from './collision_feature.js';
12
+ import { getAnchors, getCenterAnchor } from './get_anchors.js';
13
+ import { getGlyphQuads, getIconQuads } from './quads.js';
14
+ import { shapeIcon, shapeText, WritingMode } from './shaping.js';
16
15
 
17
16
  // The symbol layout process needs `text-size` evaluated at up to five different zoom levels, and
18
17
  // `icon-size` at up to three:
@@ -29,7 +28,7 @@ const murmur3 = require('murmurhash-js');
29
28
  // (1) and (2) are stored in `bucket.layers[0]._layout`. The remainder are below.
30
29
  //
31
30
 
32
- function performSymbolLayout(bucket, glyphMap, glyphPositions, imageMap, imagePositions, showCollisionBoxes) {
31
+ export function performSymbolLayout(bucket, glyphMap, glyphPositions, imageMap, imagePositions, showCollisionBoxes) {
33
32
  bucket.createArrays();
34
33
 
35
34
  const tileSize = 512 * bucket.overscaling;
@@ -477,8 +476,9 @@ function addSymbol(
477
476
  const iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;
478
477
  const iconBoxEndIndex = iconCollisionFeature ? iconCollisionFeature.boxEndIndex : bucket.collisionBoxArray.length;
479
478
 
480
- if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS)
479
+ if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS) {
481
480
  warn.once('Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907');
481
+ }
482
482
 
483
483
  bucket.symbolInstances.emplaceBack(
484
484
  anchor.x,
@@ -515,7 +515,3 @@ function anchorIsTooClose(bucket, text, repeatDistance, anchor) {
515
515
  compareText[text].push(anchor);
516
516
  return false;
517
517
  }
518
-
519
- module.exports = {
520
- performSymbolLayout
521
- };
@@ -1,14 +1,11 @@
1
- const { normalizePropertyExpression } = require('@mapwhit/style-expressions');
2
-
3
- const interpolate = require('../util/interpolate');
4
- const { clamp } = require('../util/util');
5
- const EvaluationParameters = require('../style/evaluation_parameters');
6
-
7
- module.exports = { getSizeData, evaluateSizeForFeature, evaluateSizeForZoom };
1
+ import { normalizePropertyExpression } from '@mapwhit/style-expressions';
2
+ import EvaluationParameters from '../style/evaluation_parameters.js';
3
+ import interpolate from '../util/interpolate.js';
4
+ import { clamp } from '../util/util.js';
8
5
 
9
6
  // For {text,icon}-size, get the bucket-level data that will be needed by
10
7
  // the painter to set symbol-size-related uniforms
11
- function getSizeData(tileZoom, value) {
8
+ export function getSizeData(tileZoom, value) {
12
9
  const { expression } = value;
13
10
  if (expression.kind === 'constant') {
14
11
  return {
@@ -25,10 +22,14 @@ function getSizeData(tileZoom, value) {
25
22
  const levels = expression.zoomStops;
26
23
 
27
24
  let lower = 0;
28
- while (lower < levels.length && levels[lower] <= tileZoom) lower++;
25
+ while (lower < levels.length && levels[lower] <= tileZoom) {
26
+ lower++;
27
+ }
29
28
  lower = Math.max(0, lower - 1);
30
29
  let upper = lower;
31
- while (upper < levels.length && levels[upper] < tileZoom + 1) upper++;
30
+ while (upper < levels.length && levels[upper] < tileZoom + 1) {
31
+ upper++;
32
+ }
32
33
  upper = Math.min(levels.length - 1, upper);
33
34
 
34
35
  const zoomRange = {
@@ -60,7 +61,7 @@ function getSizeData(tileZoom, value) {
60
61
  };
61
62
  }
62
63
 
63
- function evaluateSizeForFeature(sizeData, partiallyEvaluatedSize, symbol) {
64
+ export function evaluateSizeForFeature(sizeData, partiallyEvaluatedSize, symbol) {
64
65
  const part = partiallyEvaluatedSize;
65
66
  if (sizeData.functionType === 'source') {
66
67
  return symbol.lowerSize / 10;
@@ -71,7 +72,7 @@ function evaluateSizeForFeature(sizeData, partiallyEvaluatedSize, symbol) {
71
72
  return part.uSize;
72
73
  }
73
74
 
74
- function evaluateSizeForZoom(sizeData, currentZoom, property) {
75
+ export function evaluateSizeForZoom(sizeData, currentZoom, property) {
75
76
  if (sizeData.functionType === 'constant') {
76
77
  return {
77
78
  uSizeT: 0,
@@ -1,4 +1,4 @@
1
- const { plugin: rtlTextPlugin } = require('../source/rtl_text_plugin');
1
+ import { plugin as rtlTextPlugin } from '../source/rtl_text_plugin.js';
2
2
 
3
3
  function transformText(text, layer, feature) {
4
4
  const transform = layer._layout.get('text-transform').evaluate(feature, {});
@@ -15,9 +15,9 @@ function transformText(text, layer, feature) {
15
15
  return text;
16
16
  }
17
17
 
18
- module.exports = function (text, layer, feature) {
18
+ export default function (text, layer, feature) {
19
19
  text.sections.forEach(section => {
20
20
  section.text = transformText(section.text, layer, feature);
21
21
  });
22
22
  return text;
23
- };
23
+ }
package/src/ui/camera.js CHANGED
@@ -1,12 +1,12 @@
1
- const { deepEqual } = require('../util/object');
2
- const { clamp, wrap, ease: defaultEasing } = require('../util/util');
3
- const warn = require('../util/warn');
4
- const interpolate = require('../util/interpolate');
5
- const browser = require('../util/browser');
6
- const LngLat = require('../geo/lng_lat');
7
- const LngLatBounds = require('../geo/lng_lat_bounds');
8
- const { default: Point } = require('@mapbox/point-geometry');
9
- const { Event, Evented } = require('@mapwhit/events');
1
+ import Point from '@mapbox/point-geometry';
2
+ import { Event, Evented } from '@mapwhit/events';
3
+ import LngLat from '../geo/lng_lat.js';
4
+ import LngLatBounds from '../geo/lng_lat_bounds.js';
5
+ import browser from '../util/browser.js';
6
+ import interpolate from '../util/interpolate.js';
7
+ import { deepEqual } from '../util/object.js';
8
+ import { clamp, ease as defaultEasing, wrap } from '../util/util.js';
9
+ import warn from '../util/warn.js';
10
10
 
11
11
  /**
12
12
  * Options common to {@link Map#jumpTo}, {@link Map#easeTo}, and {@link Map#flyTo}, controlling the desired location,
@@ -354,8 +354,12 @@ class Camera extends Evented {
354
354
  if (
355
355
  !deepEqual(
356
356
  Object.keys(options.padding).sort((a, b) => {
357
- if (a < b) return -1;
358
- if (a > b) return 1;
357
+ if (a < b) {
358
+ return -1;
359
+ }
360
+ if (a > b) {
361
+ return 1;
362
+ }
359
363
  return 0;
360
364
  }),
361
365
  ['bottom', 'left', 'right', 'top']
@@ -429,7 +433,9 @@ class Camera extends Evented {
429
433
  const calculatedOptions = this.cameraForBounds(bounds, options);
430
434
 
431
435
  // cameraForBounds warns + returns undefined if unable to fit:
432
- if (!calculatedOptions) return this;
436
+ if (!calculatedOptions) {
437
+ return this;
438
+ }
433
439
 
434
440
  options = Object.assign(calculatedOptions, options);
435
441
 
@@ -542,7 +548,9 @@ class Camera extends Evented {
542
548
  ...options
543
549
  };
544
550
 
545
- if (options.animate === false) options.duration = 0;
551
+ if (options.animate === false) {
552
+ options.duration = 0;
553
+ }
546
554
 
547
555
  const tr = this.transform;
548
556
  const startZoom = this.getZoom();
@@ -820,7 +828,9 @@ class Camera extends Evented {
820
828
  // When u₀ = u₁, the optimal path doesn’t require both ascent and descent.
821
829
  if (Math.abs(u1) < 0.000001 || !Number.isFinite(S)) {
822
830
  // Perform a more or less instantaneous transition if the path is too short.
823
- if (Math.abs(w0 - w1) < 0.000001) return this.easeTo(options, eventData);
831
+ if (Math.abs(w0 - w1) < 0.000001) {
832
+ return this.easeTo(options, eventData);
833
+ }
824
834
 
825
835
  const k = w1 < w0 ? -1 : 1;
826
836
  S = Math.abs(Math.log(w1 / w0)) / rho;
@@ -932,8 +942,12 @@ class Camera extends Evented {
932
942
  _normalizeBearing(bearing, currentBearing) {
933
943
  bearing = wrap(bearing, -180, 180);
934
944
  const diff = Math.abs(bearing - currentBearing);
935
- if (Math.abs(bearing - 360 - currentBearing) < diff) bearing -= 360;
936
- if (Math.abs(bearing + 360 - currentBearing) < diff) bearing += 360;
945
+ if (Math.abs(bearing - 360 - currentBearing) < diff) {
946
+ bearing -= 360;
947
+ }
948
+ if (Math.abs(bearing + 360 - currentBearing) < diff) {
949
+ bearing += 360;
950
+ }
937
951
  return bearing;
938
952
  }
939
953
 
@@ -941,11 +955,13 @@ class Camera extends Evented {
941
955
  // interpolating between the two endpoints will cross it.
942
956
  _normalizeCenter(center) {
943
957
  const tr = this.transform;
944
- if (!tr.renderWorldCopies || tr.lngRange) return;
958
+ if (!tr.renderWorldCopies || tr.lngRange) {
959
+ return;
960
+ }
945
961
 
946
962
  const delta = center.lng - tr.center.lng;
947
963
  center.lng += delta > 180 ? -360 : delta < -180 ? 360 : 0;
948
964
  }
949
965
  }
950
966
 
951
- module.exports = Camera;
967
+ export default Camera;