@mapwhit/tilerenderer 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +105 -47
  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 +58 -33
  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 +53 -33
  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
@@ -21,7 +21,9 @@ class SourceFeatureState {
21
21
  if (this.#deletedStates[sourceLayer] === null) {
22
22
  this.#deletedStates[sourceLayer] = {};
23
23
  for (const ft in this.#state[sourceLayer]) {
24
- if (ft !== feature) this.#deletedStates[sourceLayer][ft] = null;
24
+ if (ft !== feature) {
25
+ this.#deletedStates[sourceLayer][ft] = null;
26
+ }
25
27
  }
26
28
  } else {
27
29
  const featureDeletionQueued =
@@ -29,12 +31,16 @@ class SourceFeatureState {
29
31
  if (featureDeletionQueued) {
30
32
  this.#deletedStates[sourceLayer][feature] = {};
31
33
  for (const prop in this.state[sourceLayer][feature]) {
32
- if (!newState[prop]) this.#deletedStates[sourceLayer][feature][prop] = null;
34
+ if (!newState[prop]) {
35
+ this.#deletedStates[sourceLayer][feature][prop] = null;
36
+ }
33
37
  }
34
38
  } else {
35
39
  for (const key in newState) {
36
40
  const deletionInQueue = this.#deletedStates[sourceLayer]?.[feature]?.[key] === null;
37
- if (deletionInQueue) delete this.#deletedStates[sourceLayer][feature][key];
41
+ if (deletionInQueue) {
42
+ delete this.#deletedStates[sourceLayer][feature][key];
43
+ }
38
44
  }
39
45
  }
40
46
  }
@@ -42,7 +48,9 @@ class SourceFeatureState {
42
48
 
43
49
  removeFeatureState(sourceLayer, featureId, key) {
44
50
  const sourceLayerDeleted = this.#deletedStates[sourceLayer] === null;
45
- if (sourceLayerDeleted) return;
51
+ if (sourceLayerDeleted) {
52
+ return;
53
+ }
46
54
 
47
55
  const feature = String(featureId);
48
56
 
@@ -57,7 +65,9 @@ class SourceFeatureState {
57
65
  const updateInQueue = this.#stateChanges[sourceLayer]?.[feature];
58
66
  if (updateInQueue) {
59
67
  this.#deletedStates[sourceLayer][feature] = {};
60
- for (key in this.#stateChanges[sourceLayer][feature]) this.#deletedStates[sourceLayer][feature][key] = null;
68
+ for (key in this.#stateChanges[sourceLayer][feature]) {
69
+ this.#deletedStates[sourceLayer][feature][key] = null;
70
+ }
61
71
  } else {
62
72
  this.#deletedStates[sourceLayer][feature] = null;
63
73
  }
@@ -72,11 +82,17 @@ class SourceFeatureState {
72
82
  const reconciledState = Object.assign({}, base?.[feature], changes?.[feature]);
73
83
 
74
84
  //return empty object if the whole source layer is awaiting deletion
75
- if (this.#deletedStates[sourceLayer] === null) return {};
85
+ if (this.#deletedStates[sourceLayer] === null) {
86
+ return {};
87
+ }
76
88
  if (this.#deletedStates[sourceLayer]) {
77
89
  const featureDeletions = this.#deletedStates[sourceLayer][feature];
78
- if (featureDeletions === null) return {};
79
- for (const prop in featureDeletions) delete reconciledState[prop];
90
+ if (featureDeletions === null) {
91
+ return {};
92
+ }
93
+ for (const prop in featureDeletions) {
94
+ delete reconciledState[prop];
95
+ }
80
96
  }
81
97
  return reconciledState;
82
98
  }
@@ -92,7 +108,9 @@ class SourceFeatureState {
92
108
  this.#state[sourceLayer] ??= {};
93
109
  const layerStates = {};
94
110
  for (const feature in this.#stateChanges[sourceLayer]) {
95
- if (!this.#state[sourceLayer][feature]) this.#state[sourceLayer][feature] = {};
111
+ if (!this.#state[sourceLayer][feature]) {
112
+ this.#state[sourceLayer][feature] = {};
113
+ }
96
114
  Object.assign(this.#state[sourceLayer][feature], this.#stateChanges[sourceLayer][feature]);
97
115
  layerStates[feature] = this.#state[sourceLayer][feature];
98
116
  }
@@ -103,13 +121,16 @@ class SourceFeatureState {
103
121
  const layerStates = {};
104
122
 
105
123
  if (this.#deletedStates[sourceLayer] === null) {
106
- for (const ft in this.#state[sourceLayer]) layerStates[ft] = {};
124
+ for (const ft in this.#state[sourceLayer]) {
125
+ layerStates[ft] = {};
126
+ }
107
127
  this.#state[sourceLayer] = {};
108
128
  } else {
109
129
  for (const feature in this.#deletedStates[sourceLayer]) {
110
130
  const deleteWholeFeatureState = this.#deletedStates[sourceLayer][feature] === null;
111
- if (deleteWholeFeatureState) this.#state[sourceLayer][feature] = {};
112
- else {
131
+ if (deleteWholeFeatureState) {
132
+ this.#state[sourceLayer][feature] = {};
133
+ } else {
113
134
  for (const key of Object.keys(this.#deletedStates[sourceLayer][feature])) {
114
135
  delete this.#state[sourceLayer][feature][key];
115
136
  }
@@ -124,7 +145,9 @@ class SourceFeatureState {
124
145
  this.#stateChanges = {};
125
146
  this.#deletedStates = {};
126
147
 
127
- if (Object.keys(featuresChanged).length === 0) return;
148
+ if (Object.keys(featuresChanged).length === 0) {
149
+ return;
150
+ }
128
151
 
129
152
  for (const tile of tiles) {
130
153
  tile.setFeatureState(featuresChanged, painter);
@@ -132,4 +155,4 @@ class SourceFeatureState {
132
155
  }
133
156
  }
134
157
 
135
- module.exports = SourceFeatureState;
158
+ export default SourceFeatureState;
@@ -1,17 +1,16 @@
1
- const { deepEqual } = require('../util/object');
2
- const uniqueId = require('../util/unique_id');
3
- const { updateBuckets } = require('../data/bucket');
4
- const GeoJSONFeature = require('../util/vectortile_to_geojson');
5
- const featureFilter = require('../style-spec/feature_filter');
6
- const SymbolBucket = require('../data/bucket/symbol_bucket');
7
- const { RasterBoundsArray, CollisionBoxArray } = require('../data/array_types');
8
- const rasterBoundsAttributes = require('../data/raster_bounds_attributes');
9
- const EXTENT = require('../data/extent');
10
- const Texture = require('../render/texture');
11
- const SegmentVector = require('../data/segment');
12
- const { TriangleIndexArray } = require('../data/index_array_type');
13
- const browser = require('../util/browser');
14
- const EvaluationParameters = require('../style/evaluation_parameters');
1
+ import { CollisionBoxArray, RasterBoundsArray } from '../data/array_types.js';
2
+ import { updateBuckets } from '../data/bucket.js';
3
+ import EXTENT from '../data/extent.js';
4
+ import { TriangleIndexArray } from '../data/index_array_type.js';
5
+ import rasterBoundsAttributes from '../data/raster_bounds_attributes.js';
6
+ import SegmentVector from '../data/segment.js';
7
+ import Texture from '../render/texture.js';
8
+ import EvaluationParameters from '../style/evaluation_parameters.js';
9
+ import featureFilter from '../style-spec/feature_filter/index.js';
10
+ import browser from '../util/browser.js';
11
+ import { deepEqual } from '../util/object.js';
12
+ import uniqueId from '../util/unique_id.js';
13
+ import GeoJSONFeature from '../util/vectortile_to_geojson.js';
15
14
 
16
15
  /**
17
16
  * A tile object is the combination of a Coordinate, which defines
@@ -38,8 +37,12 @@ class Tile {
38
37
 
39
38
  registerFadeDuration(duration) {
40
39
  const fadeEndTime = duration + this.timeAdded;
41
- if (fadeEndTime < browser.now()) return;
42
- if (this.fadeEndTime && fadeEndTime < this.fadeEndTime) return;
40
+ if (fadeEndTime < browser.now()) {
41
+ return;
42
+ }
43
+ if (this.fadeEndTime && fadeEndTime < this.fadeEndTime) {
44
+ return;
45
+ }
43
46
 
44
47
  this.fadeEndTime = fadeEndTime;
45
48
  }
@@ -164,7 +167,9 @@ class Tile {
164
167
  maxPitchScaleFactor,
165
168
  pixelPosMatrix
166
169
  ) {
167
- if (!this.latestFeatureIndex?.vectorTile) return {};
170
+ if (!this.latestFeatureIndex?.vectorTile) {
171
+ return {};
172
+ }
168
173
 
169
174
  return this.latestFeatureIndex.query(
170
175
  {
@@ -183,14 +188,18 @@ class Tile {
183
188
  }
184
189
 
185
190
  querySourceFeatures(result, params) {
186
- if (!this.latestFeatureIndex?.vectorTile) return;
191
+ if (!this.latestFeatureIndex?.vectorTile) {
192
+ return;
193
+ }
187
194
 
188
195
  const vtLayers = this.latestFeatureIndex.loadVTLayers();
189
196
 
190
197
  const sourceLayer = params ? params.sourceLayer : '';
191
198
  const layer = vtLayers._geojsonTileLayer || vtLayers[sourceLayer];
192
199
 
193
- if (!layer) return;
200
+ if (!layer) {
201
+ return;
202
+ }
194
203
 
195
204
  const filter = featureFilter(params?.filter);
196
205
  const { z, x, y } = this.tileID.canonical;
@@ -223,14 +232,18 @@ class Tile {
223
232
 
224
233
  setMask(mask, context) {
225
234
  // don't redo buffer work if the mask is the same;
226
- if (deepEqual(this.mask, mask)) return;
235
+ if (deepEqual(this.mask, mask)) {
236
+ return;
237
+ }
227
238
 
228
239
  this.mask = mask;
229
240
  this.clearMask();
230
241
 
231
242
  // We want to render the full tile, and keeping the segments/vertices/indices empty means
232
243
  // using the global shared buffers for covering the entire tile.
233
- if (deepEqual(mask, { 0: true })) return;
244
+ if (deepEqual(mask, { 0: true })) {
245
+ return;
246
+ }
234
247
 
235
248
  const maskedBoundsArray = new RasterBoundsArray();
236
249
  const indexArray = new TriangleIndexArray();
@@ -290,7 +303,9 @@ class Tile {
290
303
  const sourceLayerId = bucket.layers[0]['sourceLayer'] || '_geojsonTileLayer';
291
304
  const sourceLayer = vtLayers[sourceLayerId];
292
305
  const sourceLayerStates = states[sourceLayerId];
293
- if (!sourceLayer || !sourceLayerStates || Object.keys(sourceLayerStates).length === 0) continue;
306
+ if (!sourceLayer || !sourceLayerStates || Object.keys(sourceLayerStates).length === 0) {
307
+ continue;
308
+ }
294
309
 
295
310
  bucket.update(sourceLayerStates, sourceLayer, this.imageAtlas?.patternPositions || {});
296
311
  if (painter?.style) {
@@ -316,4 +331,4 @@ class Tile {
316
331
  }
317
332
  }
318
333
 
319
- module.exports = Tile;
334
+ export default Tile;
@@ -1,6 +1,5 @@
1
- const LngLatBounds = require('../geo/lng_lat_bounds');
2
-
3
- const { clamp } = require('../util/util');
1
+ import LngLatBounds from '../geo/lng_lat_bounds.js';
2
+ import { clamp } from '../util/util.js';
4
3
 
5
4
  class TileBounds {
6
5
  constructor(bounds, minzoom = 0, maxzoom = 24) {
@@ -11,11 +10,17 @@ class TileBounds {
11
10
 
12
11
  contains({ x, y, z }) {
13
12
  const minX = Math.floor(lngX(this.bounds.getWest(), z));
14
- if (x < minX) return false;
13
+ if (x < minX) {
14
+ return false;
15
+ }
15
16
  const maxX = Math.ceil(lngX(this.bounds.getEast(), z));
16
- if (x >= maxX) return false;
17
+ if (x >= maxX) {
18
+ return false;
19
+ }
17
20
  const minY = Math.floor(latY(this.bounds.getNorth(), z));
18
- if (y < minY) return false;
21
+ if (y < minY) {
22
+ return false;
23
+ }
19
24
  const maxY = Math.ceil(latY(this.bounds.getSouth(), z));
20
25
  return y < maxY;
21
26
  }
@@ -23,7 +28,9 @@ class TileBounds {
23
28
 
24
29
  function validateBounds(bounds) {
25
30
  // make sure the bounds property contains valid longitude and latitudes
26
- if (!Array.isArray(bounds) || bounds.length !== 4) return [-180, -90, 180, 90];
31
+ if (!Array.isArray(bounds) || bounds.length !== 4) {
32
+ return [-180, -90, 180, 90];
33
+ }
27
34
  return [Math.max(-180, bounds[0]), Math.max(-90, bounds[1]), Math.min(180, bounds[2]), Math.min(90, bounds[3])];
28
35
  }
29
36
 
@@ -37,4 +44,4 @@ function latY(lat, zoom) {
37
44
  return 2 ** (zoom - 1) + 0.5 * Math.log((1 + f) / (1 - f)) * -scale;
38
45
  }
39
46
 
40
- module.exports = TileBounds;
47
+ export default TileBounds;
@@ -1,4 +1,4 @@
1
- const assert = require('assert');
1
+ import assert from 'assert';
2
2
 
3
3
  /**
4
4
  * A [fifo cache](http://en.wikipedia.org/wiki/Cache_algorithms)
@@ -119,4 +119,4 @@ class TileCache {
119
119
  }
120
120
  }
121
121
 
122
- module.exports = TileCache;
122
+ export default TileCache;
@@ -1,9 +1,7 @@
1
- const { getTileBBox } = require('@mapbox/whoots-js');
1
+ import assert from 'assert';
2
+ import Coordinate from '../geo/coordinate.js';
2
3
 
3
- const assert = require('assert');
4
- const Coordinate = require('../geo/coordinate');
5
-
6
- class CanonicalTileID {
4
+ export class CanonicalTileID {
7
5
  constructor(z, x, y) {
8
6
  assert(z >= 0 && z <= 25);
9
7
  assert(x >= 0 && x < 2 ** z);
@@ -23,7 +21,7 @@ class CanonicalTileID {
23
21
  }
24
22
  }
25
23
 
26
- class UnwrappedTileID {
24
+ export class UnwrappedTileID {
27
25
  constructor(wrap, canonical) {
28
26
  this.wrap = wrap;
29
27
  this.canonical = canonical;
@@ -31,7 +29,7 @@ class UnwrappedTileID {
31
29
  }
32
30
  }
33
31
 
34
- class OverscaledTileID {
32
+ export class OverscaledTileID {
35
33
  constructor(overscaledZ, wrap, z, x, y) {
36
34
  assert(overscaledZ >= z);
37
35
  this.overscaledZ = overscaledZ;
@@ -90,16 +88,30 @@ class OverscaledTileID {
90
88
  }
91
89
 
92
90
  isLessThan(rhs) {
93
- if (this.wrap < rhs.wrap) return true;
94
- if (this.wrap > rhs.wrap) return false;
91
+ if (this.wrap < rhs.wrap) {
92
+ return true;
93
+ }
94
+ if (this.wrap > rhs.wrap) {
95
+ return false;
96
+ }
95
97
 
96
- if (this.overscaledZ < rhs.overscaledZ) return true;
97
- if (this.overscaledZ > rhs.overscaledZ) return false;
98
+ if (this.overscaledZ < rhs.overscaledZ) {
99
+ return true;
100
+ }
101
+ if (this.overscaledZ > rhs.overscaledZ) {
102
+ return false;
103
+ }
98
104
 
99
- if (this.canonical.x < rhs.canonical.x) return true;
100
- if (this.canonical.x > rhs.canonical.x) return false;
105
+ if (this.canonical.x < rhs.canonical.x) {
106
+ return true;
107
+ }
108
+ if (this.canonical.x > rhs.canonical.x) {
109
+ return false;
110
+ }
101
111
 
102
- if (this.canonical.y < rhs.canonical.y) return true;
112
+ if (this.canonical.y < rhs.canonical.y) {
113
+ return true;
114
+ }
103
115
  return false;
104
116
  }
105
117
 
@@ -132,16 +144,11 @@ class OverscaledTileID {
132
144
  }
133
145
  }
134
146
 
135
- function calculateKey(wrap, z, x, y) {
147
+ export function calculateKey(wrap, z, x, y) {
136
148
  wrap *= 2;
137
- if (wrap < 0) wrap = wrap * -1 - 1;
149
+ if (wrap < 0) {
150
+ wrap = wrap * -1 - 1;
151
+ }
138
152
  const dim = 1 << z;
139
153
  return (dim * dim * wrap + dim * y + x) * 32 + z;
140
154
  }
141
-
142
- module.exports = {
143
- CanonicalTileID,
144
- UnwrappedTileID,
145
- OverscaledTileID,
146
- calculateKey
147
- };
@@ -1,9 +1,9 @@
1
- const { Event, ErrorEvent, Evented } = require('@mapwhit/events');
2
- const { pick } = require('../util/object');
3
- const loadTileJSON = require('./load_tilejson');
4
- const TileBounds = require('./tile_bounds');
5
- const browser = require('../util/browser');
6
- const VectorTileWorkerSource = require('./vector_tile_worker_source');
1
+ import { ErrorEvent, Event, Evented } from '@mapwhit/events';
2
+ import browser from '../util/browser.js';
3
+ import { pick } from '../util/object.js';
4
+ import loadTileJSON from './load_tilejson.js';
5
+ import TileBounds from './tile_bounds.js';
6
+ import VectorTileWorkerSource from './vector_tile_worker_source.js';
7
7
 
8
8
  class VectorTileSource extends Evented {
9
9
  #worker;
@@ -38,7 +38,9 @@ class VectorTileSource extends Evented {
38
38
  try {
39
39
  const tileJSON = await loadTileJSON(this._options);
40
40
  Object.assign(this, tileJSON);
41
- if (tileJSON.bounds) this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom);
41
+ if (tileJSON.bounds) {
42
+ this.tileBounds = new TileBounds(tileJSON.bounds, this.minzoom, this.maxzoom);
43
+ }
42
44
 
43
45
  // `content` is included here to prevent a race condition where `Style#_updateSources` is called
44
46
  // before the TileJSON arrives. this makes sure the tiles needed are loaded once TileJSON arrives
@@ -125,4 +127,4 @@ class VectorTileSource extends Evented {
125
127
  }
126
128
  }
127
129
 
128
- module.exports = VectorTileSource;
130
+ export default VectorTileSource;
@@ -1,6 +1,6 @@
1
- const { VectorTile } = require('@mapwhit/vector-tile');
2
- const Protobuf = require('@mapwhit/pbf');
3
- const makeWorkerTile = require('./worker_tile');
1
+ import Protobuf from '@mapwhit/pbf';
2
+ import { VectorTile } from '@mapwhit/vector-tile';
3
+ import makeWorkerTile from './worker_tile.js';
4
4
 
5
5
  /**
6
6
  * The {@link WorkerSource} implementation that supports {@link VectorTileSource}.
@@ -55,4 +55,4 @@ class VectorTileWorkerSource {
55
55
  }
56
56
  }
57
57
 
58
- module.exports = VectorTileWorkerSource;
58
+ export default VectorTileWorkerSource;
@@ -1,27 +1,23 @@
1
- const FeatureIndex = require('../data/feature_index');
2
-
3
- const { performSymbolLayout } = require('../symbol/symbol_layout');
4
- const { CollisionBoxArray } = require('../data/array_types');
5
- const dictionaryCoder = require('../util/dictionary_coder');
6
- const SymbolBucket = require('../data/bucket/symbol_bucket');
7
- const LineBucket = require('../data/bucket/line_bucket');
8
- const FillBucket = require('../data/bucket/fill_bucket');
9
- const FillExtrusionBucket = require('../data/bucket/fill_extrusion_bucket');
10
- const { mapObject } = require('../util/object');
11
- const warn = require('../util/warn');
12
- const assert = require('assert');
13
- const ImageAtlas = require('../render/image_atlas');
14
- const GlyphAtlas = require('../render/glyph_atlas');
15
- const EvaluationParameters = require('../style/evaluation_parameters');
16
- const { OverscaledTileID } = require('./tile_id');
17
-
18
- module.exports = makeWorkerTile;
1
+ import { CollisionBoxArray } from '../data/array_types.js';
2
+ import FillBucket from '../data/bucket/fill_bucket.js';
3
+ import FillExtrusionBucket from '../data/bucket/fill_extrusion_bucket.js';
4
+ import LineBucket from '../data/bucket/line_bucket.js';
5
+ import SymbolBucket from '../data/bucket/symbol_bucket.js';
6
+ import FeatureIndex from '../data/feature_index.js';
7
+ import GlyphAtlas from '../render/glyph_atlas.js';
8
+ import ImageAtlas from '../render/image_atlas.js';
9
+ import EvaluationParameters from '../style/evaluation_parameters.js';
10
+ import { performSymbolLayout } from '../symbol/symbol_layout.js';
11
+ import dictionaryCoder from '../util/dictionary_coder.js';
12
+ import { mapObject } from '../util/object.js';
13
+ import { OverscaledTileID } from './tile_id.js';
14
+ export default makeWorkerTile;
19
15
 
20
16
  async function makeWorkerTile(params, vectorTile, layerIndex, resources) {
21
17
  const tileID = createTileID(params);
22
18
 
23
19
  const overscaling = tileID.overscaleFactor();
24
- const { uid, zoom, pixelRatio, source, showCollisionBoxes, globalState, justReloaded, painter } = params;
20
+ const { zoom, pixelRatio, source, showCollisionBoxes, globalState, justReloaded, painter } = params;
25
21
 
26
22
  const collisionBoxArray = new CollisionBoxArray();
27
23
  const sourceLayerCoder = dictionaryCoder(Object.keys(vectorTile.layers));
@@ -54,9 +50,15 @@ async function makeWorkerTile(params, vectorTile, layerIndex, resources) {
54
50
  for (const layers of sourceLayerFamilies.values()) {
55
51
  const layer = layers[0];
56
52
 
57
- if (layer.minzoom && zoom < Math.floor(layer.minzoom)) continue;
58
- if (layer.maxzoom && zoom >= layer.maxzoom) continue;
59
- if (layer.visibility === 'none') continue;
53
+ if (layer.minzoom && zoom < Math.floor(layer.minzoom)) {
54
+ continue;
55
+ }
56
+ if (layer.maxzoom && zoom >= layer.maxzoom) {
57
+ continue;
58
+ }
59
+ if (layer.visibility === 'none') {
60
+ continue;
61
+ }
60
62
 
61
63
  recalculateLayers(layers, zoom, globalState);
62
64
 
@@ -1,12 +1,12 @@
1
- const circle = require('./style_layer/circle_style_layer');
2
- const heatmap = require('./style_layer/heatmap_style_layer');
3
- const hillshade = require('./style_layer/hillshade_style_layer');
4
- const fill = require('./style_layer/fill_style_layer');
5
- const { FillExtrusionStyleLayer: fillExtrusion } = require('./style_layer/fill_extrusion_style_layer');
6
- const line = require('./style_layer/line_style_layer');
7
- const symbol = require('./style_layer/symbol_style_layer');
8
- const background = require('./style_layer/background_style_layer');
9
- const raster = require('./style_layer/raster_style_layer');
1
+ import background from './style_layer/background_style_layer.js';
2
+ import circle from './style_layer/circle_style_layer.js';
3
+ import { FillExtrusionStyleLayer as fillExtrusion } from './style_layer/fill_extrusion_style_layer.js';
4
+ import fill from './style_layer/fill_style_layer.js';
5
+ import heatmap from './style_layer/heatmap_style_layer.js';
6
+ import hillshade from './style_layer/hillshade_style_layer.js';
7
+ import line from './style_layer/line_style_layer.js';
8
+ import raster from './style_layer/raster_style_layer.js';
9
+ import symbol from './style_layer/symbol_style_layer.js';
10
10
 
11
11
  const subclasses = {
12
12
  circle,
@@ -20,6 +20,6 @@ const subclasses = {
20
20
  raster
21
21
  };
22
22
 
23
- module.exports = function createStyleLayer(layer) {
23
+ export default function createStyleLayer(layer) {
24
24
  return new subclasses[layer.type](layer);
25
- };
25
+ }
@@ -1,8 +1,8 @@
1
- const ZoomHistory = require('./zoom_history');
2
- const { isStringInSupportedScript } = require('../util/script_detection');
3
- const { plugin: rtlTextPlugin } = require('../source/rtl_text_plugin');
1
+ import { plugin as rtlTextPlugin } from '../source/rtl_text_plugin.js';
2
+ import { isStringInSupportedScript } from '../util/script_detection.js';
3
+ import ZoomHistory from './zoom_history.js';
4
4
 
5
- class EvaluationParameters {
5
+ export default class EvaluationParameters {
6
6
  // "options" may also be another EvaluationParameters to copy, see CrossFadedProperty.possiblyEvaluate
7
7
  constructor(zoom, options) {
8
8
  this.zoom = zoom;
@@ -43,5 +43,3 @@ class EvaluationParameters {
43
43
  : { fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction };
44
44
  }
45
45
  }
46
-
47
- module.exports = EvaluationParameters;
@@ -1,6 +1,6 @@
1
- const { sphericalToCartesian } = require('../util/util');
2
- const { Evented } = require('@mapwhit/events');
3
- const interpolate = require('../util/interpolate');
1
+ import { Evented } from '@mapwhit/events';
2
+ import interpolate from '../util/interpolate.js';
3
+ import { sphericalToCartesian } from '../util/util.js';
4
4
 
5
5
  const lightSpec = {
6
6
  anchor: {
@@ -40,7 +40,7 @@ const lightSpec = {
40
40
  }
41
41
  };
42
42
 
43
- const { Properties, Transitionable, DataConstantProperty } = require('./properties');
43
+ import { DataConstantProperty, Properties, Transitionable } from './properties.js';
44
44
 
45
45
  class LightPositionProperty {
46
46
  constructor(specification) {
@@ -109,4 +109,4 @@ class Light extends Evented {
109
109
  }
110
110
  }
111
111
 
112
- module.exports = Light;
112
+ export default Light;
@@ -1,10 +1,10 @@
1
- const browser = require('../util/browser');
2
- const { RGBAImage } = require('../util/image');
3
- const loadImage = require('../util/loader/image');
1
+ import browser from '../util/browser.js';
2
+ import { RGBAImage } from '../util/image.js';
3
+ import loadImage from '../util/loader/image.js';
4
+ export default loadSprite;
4
5
 
5
- module.exports = loadSprite;
6
-
7
- async function loadSprite(sprite) {
6
+ async function loadSprite(loadingSprite) {
7
+ const sprite = await loadingSprite;
8
8
  const image = await loadImage(sprite.image);
9
9
  const { json } = sprite;
10
10
  if (json && image) {
@@ -1,7 +1,7 @@
1
- const { AlphaImage } = require('../util/image');
1
+ import Protobuf from '@mapwhit/pbf';
2
+ import { AlphaImage } from '../util/image.js';
2
3
 
3
- const Protobuf = require('@mapwhit/pbf');
4
- const border = 3;
4
+ export const GLYPH_PBF_BORDER = 3;
5
5
 
6
6
  function readFontstacks(tag, glyphs, pbf) {
7
7
  if (tag === 1) {
@@ -16,8 +16,8 @@ function readFontstack(tag, glyphs, pbf) {
16
16
  id,
17
17
  bitmap: new AlphaImage(
18
18
  {
19
- width: width + 2 * border,
20
- height: height + 2 * border
19
+ width: width + 2 * GLYPH_PBF_BORDER,
20
+ height: height + 2 * GLYPH_PBF_BORDER
21
21
  },
22
22
  bitmap
23
23
  ),
@@ -27,19 +27,23 @@ function readFontstack(tag, glyphs, pbf) {
27
27
  }
28
28
 
29
29
  function readGlyph(tag, glyph, pbf) {
30
- if (tag === 1) glyph.id = pbf.readVarint();
31
- else if (tag === 2) glyph.bitmap = pbf.readBytes();
32
- else if (tag === 3) glyph.width = pbf.readVarint();
33
- else if (tag === 4) glyph.height = pbf.readVarint();
34
- else if (tag === 5) glyph.left = pbf.readSVarint();
35
- else if (tag === 6) glyph.top = pbf.readSVarint();
36
- else if (tag === 7) glyph.advance = pbf.readVarint();
30
+ if (tag === 1) {
31
+ glyph.id = pbf.readVarint();
32
+ } else if (tag === 2) {
33
+ glyph.bitmap = pbf.readBytes();
34
+ } else if (tag === 3) {
35
+ glyph.width = pbf.readVarint();
36
+ } else if (tag === 4) {
37
+ glyph.height = pbf.readVarint();
38
+ } else if (tag === 5) {
39
+ glyph.left = pbf.readSVarint();
40
+ } else if (tag === 6) {
41
+ glyph.top = pbf.readSVarint();
42
+ } else if (tag === 7) {
43
+ glyph.advance = pbf.readVarint();
44
+ }
37
45
  }
38
46
 
39
- function parseGlyph(data) {
47
+ export default function parseGlyph(data) {
40
48
  return new Protobuf(data).readFields(readFontstacks, []);
41
49
  }
42
-
43
- parseGlyph.GLYPH_PBF_BORDER = border;
44
-
45
- module.exports = parseGlyph;