mapbox-gl 1.13.2

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 (460) hide show
  1. package/.flowconfig +61 -0
  2. package/CHANGELOG.md +2485 -0
  3. package/LICENSE.txt +84 -0
  4. package/README.md +34 -0
  5. package/build/banner.js +4 -0
  6. package/build/check-bundle-size.js +140 -0
  7. package/build/diff-tarball.js +18 -0
  8. package/build/generate-access-token-script.js +11 -0
  9. package/build/generate-flow-typed-style-spec.js +188 -0
  10. package/build/generate-release-list.js +21 -0
  11. package/build/generate-struct-arrays.js +243 -0
  12. package/build/generate-style-code.js +159 -0
  13. package/build/mapbox-gl.js.flow +3 -0
  14. package/build/print-release-url.js +6 -0
  15. package/build/rollup_plugin_minify_style_spec.js +24 -0
  16. package/build/rollup_plugins.js +80 -0
  17. package/build/run-node +3 -0
  18. package/build/run-tap +8 -0
  19. package/build/test/build-tape.js +19 -0
  20. package/dist/mapbox-gl-csp-worker.js +2 -0
  21. package/dist/mapbox-gl-csp-worker.js.map +1 -0
  22. package/dist/mapbox-gl-csp.js +2 -0
  23. package/dist/mapbox-gl-csp.js.map +1 -0
  24. package/dist/mapbox-gl-dev.js +65889 -0
  25. package/dist/mapbox-gl-dev.js.flow +3 -0
  26. package/dist/mapbox-gl-unminified.js +42889 -0
  27. package/dist/mapbox-gl-unminified.js.map +1 -0
  28. package/dist/mapbox-gl.css +1 -0
  29. package/dist/mapbox-gl.js +42 -0
  30. package/dist/mapbox-gl.js.flow +3 -0
  31. package/dist/mapbox-gl.js.map +1 -0
  32. package/dist/style-spec/index.es.js +15032 -0
  33. package/dist/style-spec/index.es.js.map +1 -0
  34. package/dist/style-spec/index.js +15058 -0
  35. package/dist/style-spec/index.js.map +1 -0
  36. package/flow-typed/gl.js +5 -0
  37. package/flow-typed/jsdom.js +18 -0
  38. package/flow-typed/mapbox-gl-supported.js +9 -0
  39. package/flow-typed/mapbox-unitbezier.js +14 -0
  40. package/flow-typed/offscreen-canvas.js +9 -0
  41. package/flow-typed/pbf.js +25 -0
  42. package/flow-typed/point-geometry.js +44 -0
  43. package/flow-typed/potpack.js +12 -0
  44. package/flow-typed/sinon.js +28 -0
  45. package/flow-typed/vector-tile.js +41 -0
  46. package/package.json +173 -0
  47. package/src/css/mapbox-gl.css +812 -0
  48. package/src/css/svg/mapboxgl-ctrl-attrib.svg +3 -0
  49. package/src/css/svg/mapboxgl-ctrl-compass.svg +4 -0
  50. package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +3 -0
  51. package/src/css/svg/mapboxgl-ctrl-geolocate.svg +5 -0
  52. package/src/css/svg/mapboxgl-ctrl-logo.svg +20 -0
  53. package/src/css/svg/mapboxgl-ctrl-shrink.svg +3 -0
  54. package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +3 -0
  55. package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +3 -0
  56. package/src/data/array_types.js +1135 -0
  57. package/src/data/bucket/circle_attributes.js +9 -0
  58. package/src/data/bucket/circle_bucket.js +201 -0
  59. package/src/data/bucket/fill_attributes.js +9 -0
  60. package/src/data/bucket/fill_bucket.js +229 -0
  61. package/src/data/bucket/fill_extrusion_attributes.js +10 -0
  62. package/src/data/bucket/fill_extrusion_bucket.js +283 -0
  63. package/src/data/bucket/heatmap_bucket.js +17 -0
  64. package/src/data/bucket/line_attributes.js +10 -0
  65. package/src/data/bucket/line_attributes_ext.js +10 -0
  66. package/src/data/bucket/line_bucket.js +594 -0
  67. package/src/data/bucket/pattern_attributes.js +12 -0
  68. package/src/data/bucket/pattern_bucket_features.js +60 -0
  69. package/src/data/bucket/symbol_attributes.js +117 -0
  70. package/src/data/bucket/symbol_bucket.js +937 -0
  71. package/src/data/bucket.js +123 -0
  72. package/src/data/dem_data.js +125 -0
  73. package/src/data/evaluation_feature.js +25 -0
  74. package/src/data/extent.js +18 -0
  75. package/src/data/feature_index.js +322 -0
  76. package/src/data/feature_position_map.js +131 -0
  77. package/src/data/index_array_type.js +16 -0
  78. package/src/data/load_geometry.js +46 -0
  79. package/src/data/pos_attributes.js +6 -0
  80. package/src/data/program_configuration.js +708 -0
  81. package/src/data/raster_bounds_attributes.js +7 -0
  82. package/src/data/segment.js +76 -0
  83. package/src/geo/edge_insets.js +102 -0
  84. package/src/geo/lng_lat.js +168 -0
  85. package/src/geo/lng_lat_bounds.js +276 -0
  86. package/src/geo/mercator_coordinate.js +150 -0
  87. package/src/geo/transform.js +834 -0
  88. package/src/gl/color_mode.js +34 -0
  89. package/src/gl/context.js +302 -0
  90. package/src/gl/cull_face_mode.js +26 -0
  91. package/src/gl/depth_mode.js +29 -0
  92. package/src/gl/framebuffer.js +44 -0
  93. package/src/gl/index_buffer.js +55 -0
  94. package/src/gl/stencil_mode.js +30 -0
  95. package/src/gl/types.js +84 -0
  96. package/src/gl/value.js +520 -0
  97. package/src/gl/vertex_buffer.js +119 -0
  98. package/src/index.js +230 -0
  99. package/src/render/draw_background.js +57 -0
  100. package/src/render/draw_circle.js +113 -0
  101. package/src/render/draw_collision_debug.js +172 -0
  102. package/src/render/draw_custom.js +49 -0
  103. package/src/render/draw_debug.js +127 -0
  104. package/src/render/draw_fill.js +124 -0
  105. package/src/render/draw_fill_extrusion.js +95 -0
  106. package/src/render/draw_heatmap.js +133 -0
  107. package/src/render/draw_hillshade.js +107 -0
  108. package/src/render/draw_line.js +125 -0
  109. package/src/render/draw_raster.js +125 -0
  110. package/src/render/draw_symbol.js +392 -0
  111. package/src/render/glyph_atlas.js +71 -0
  112. package/src/render/glyph_manager.js +182 -0
  113. package/src/render/image_atlas.js +149 -0
  114. package/src/render/image_manager.js +306 -0
  115. package/src/render/line_atlas.js +210 -0
  116. package/src/render/painter.js +654 -0
  117. package/src/render/program/background_program.js +103 -0
  118. package/src/render/program/circle_program.js +69 -0
  119. package/src/render/program/clipping_mask_program.js +20 -0
  120. package/src/render/program/collision_program.js +76 -0
  121. package/src/render/program/debug_program.js +35 -0
  122. package/src/render/program/fill_extrusion_program.js +122 -0
  123. package/src/render/program/fill_program.js +126 -0
  124. package/src/render/program/heatmap_program.js +83 -0
  125. package/src/render/program/hillshade_program.js +119 -0
  126. package/src/render/program/line_program.js +211 -0
  127. package/src/render/program/pattern.js +102 -0
  128. package/src/render/program/program_uniforms.js +42 -0
  129. package/src/render/program/raster_program.js +92 -0
  130. package/src/render/program/symbol_program.js +224 -0
  131. package/src/render/program.js +188 -0
  132. package/src/render/texture.js +122 -0
  133. package/src/render/uniform_binding.js +147 -0
  134. package/src/render/vertex_array_object.js +163 -0
  135. package/src/shaders/README.md +42 -0
  136. package/src/shaders/_prelude.fragment.glsl +17 -0
  137. package/src/shaders/_prelude.vertex.glsl +73 -0
  138. package/src/shaders/background.fragment.glsl +10 -0
  139. package/src/shaders/background.vertex.glsl +7 -0
  140. package/src/shaders/background_pattern.fragment.glsl +28 -0
  141. package/src/shaders/background_pattern.vertex.glsl +20 -0
  142. package/src/shaders/circle.fragment.glsl +39 -0
  143. package/src/shaders/circle.vertex.glsl +64 -0
  144. package/src/shaders/clipping_mask.fragment.glsl +3 -0
  145. package/src/shaders/clipping_mask.vertex.glsl +7 -0
  146. package/src/shaders/collision_box.fragment.glsl +21 -0
  147. package/src/shaders/collision_box.vertex.glsl +27 -0
  148. package/src/shaders/collision_circle.fragment.glsl +17 -0
  149. package/src/shaders/collision_circle.vertex.glsl +59 -0
  150. package/src/shaders/debug.fragment.glsl +9 -0
  151. package/src/shaders/debug.vertex.glsl +12 -0
  152. package/src/shaders/encode_attribute.js +17 -0
  153. package/src/shaders/fill.fragment.glsl +13 -0
  154. package/src/shaders/fill.vertex.glsl +13 -0
  155. package/src/shaders/fill_extrusion.fragment.glsl +9 -0
  156. package/src/shaders/fill_extrusion.vertex.glsl +66 -0
  157. package/src/shaders/fill_extrusion_pattern.fragment.glsl +45 -0
  158. package/src/shaders/fill_extrusion_pattern.vertex.glsl +79 -0
  159. package/src/shaders/fill_outline.fragment.glsl +17 -0
  160. package/src/shaders/fill_outline.vertex.glsl +17 -0
  161. package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
  162. package/src/shaders/fill_outline_pattern.vertex.glsl +44 -0
  163. package/src/shaders/fill_pattern.fragment.glsl +36 -0
  164. package/src/shaders/fill_pattern.vertex.glsl +39 -0
  165. package/src/shaders/heatmap.fragment.glsl +22 -0
  166. package/src/shaders/heatmap.vertex.glsl +54 -0
  167. package/src/shaders/heatmap_texture.fragment.glsl +14 -0
  168. package/src/shaders/heatmap_texture.vertex.glsl +11 -0
  169. package/src/shaders/hillshade.fragment.glsl +52 -0
  170. package/src/shaders/hillshade.vertex.glsl +11 -0
  171. package/src/shaders/hillshade_prepare.fragment.glsl +75 -0
  172. package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
  173. package/src/shaders/index.js +20 -0
  174. package/src/shaders/line.fragment.glsl +30 -0
  175. package/src/shaders/line.vertex.glsl +85 -0
  176. package/src/shaders/line_gradient.fragment.glsl +34 -0
  177. package/src/shaders/line_gradient.vertex.glsl +88 -0
  178. package/src/shaders/line_pattern.fragment.glsl +74 -0
  179. package/src/shaders/line_pattern.vertex.glsl +99 -0
  180. package/src/shaders/line_sdf.fragment.glsl +45 -0
  181. package/src/shaders/line_sdf.vertex.glsl +98 -0
  182. package/src/shaders/raster.fragment.glsl +52 -0
  183. package/src/shaders/raster.vertex.glsl +21 -0
  184. package/src/shaders/shaders.js +185 -0
  185. package/src/shaders/symbol_icon.fragment.glsl +17 -0
  186. package/src/shaders/symbol_icon.vertex.glsl +94 -0
  187. package/src/shaders/symbol_sdf.fragment.glsl +52 -0
  188. package/src/shaders/symbol_sdf.vertex.glsl +115 -0
  189. package/src/shaders/symbol_text_and_icon.fragment.glsl +68 -0
  190. package/src/shaders/symbol_text_and_icon.vertex.glsl +116 -0
  191. package/src/source/canvas_source.js +238 -0
  192. package/src/source/geojson_source.js +370 -0
  193. package/src/source/geojson_worker_source.js +366 -0
  194. package/src/source/geojson_wrapper.js +94 -0
  195. package/src/source/image_source.js +307 -0
  196. package/src/source/load_tilejson.js +39 -0
  197. package/src/source/pixels_to_tile_units.js +21 -0
  198. package/src/source/query_features.js +208 -0
  199. package/src/source/raster_dem_tile_source.js +138 -0
  200. package/src/source/raster_dem_tile_worker_source.js +62 -0
  201. package/src/source/raster_tile_source.js +169 -0
  202. package/src/source/rtl_text_plugin.js +143 -0
  203. package/src/source/source.js +137 -0
  204. package/src/source/source_cache.js +953 -0
  205. package/src/source/source_state.js +159 -0
  206. package/src/source/tile.js +458 -0
  207. package/src/source/tile_bounds.js +38 -0
  208. package/src/source/tile_cache.js +212 -0
  209. package/src/source/tile_id.js +199 -0
  210. package/src/source/vector_tile_source.js +259 -0
  211. package/src/source/vector_tile_worker_source.js +216 -0
  212. package/src/source/video_source.js +203 -0
  213. package/src/source/worker.js +240 -0
  214. package/src/source/worker_source.js +107 -0
  215. package/src/source/worker_tile.js +224 -0
  216. package/src/style/create_style_layer.js +36 -0
  217. package/src/style/evaluation_parameters.js +62 -0
  218. package/src/style/format_section_override.js +56 -0
  219. package/src/style/light.js +130 -0
  220. package/src/style/load_glyph_range.js +38 -0
  221. package/src/style/load_sprite.js +67 -0
  222. package/src/style/parse_glyph_pbf.js +44 -0
  223. package/src/style/pauseable_placement.js +132 -0
  224. package/src/style/properties.js +753 -0
  225. package/src/style/query_utils.js +43 -0
  226. package/src/style/style.js +1374 -0
  227. package/src/style/style_glyph.js +17 -0
  228. package/src/style/style_image.js +137 -0
  229. package/src/style/style_layer/background_style_layer.js +21 -0
  230. package/src/style/style_layer/background_style_layer_properties.js +40 -0
  231. package/src/style/style_layer/circle_style_layer.js +98 -0
  232. package/src/style/style_layer/circle_style_layer_properties.js +63 -0
  233. package/src/style/style_layer/custom_style_layer.js +223 -0
  234. package/src/style/style_layer/fill_extrusion_style_layer.js +224 -0
  235. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +50 -0
  236. package/src/style/style_layer/fill_style_layer.js +67 -0
  237. package/src/style/style_layer/fill_style_layer_properties.js +55 -0
  238. package/src/style/style_layer/heatmap_style_layer.js +73 -0
  239. package/src/style/style_layer/heatmap_style_layer_properties.js +44 -0
  240. package/src/style/style_layer/hillshade_style_layer.js +25 -0
  241. package/src/style/style_layer/hillshade_style_layer_properties.js +46 -0
  242. package/src/style/style_layer/layer_properties.js.ejs +69 -0
  243. package/src/style/style_layer/line_style_layer.js +150 -0
  244. package/src/style/style_layer/line_style_layer_properties.js +71 -0
  245. package/src/style/style_layer/raster_style_layer.js +21 -0
  246. package/src/style/style_layer/raster_style_layer_properties.js +50 -0
  247. package/src/style/style_layer/symbol_style_layer.js +190 -0
  248. package/src/style/style_layer/symbol_style_layer_properties.js +153 -0
  249. package/src/style/style_layer/typed_style_layer.js +17 -0
  250. package/src/style/style_layer.js +283 -0
  251. package/src/style/style_layer_index.js +80 -0
  252. package/src/style/validate_style.js +42 -0
  253. package/src/style/zoom_history.js +44 -0
  254. package/src/style-spec/.eslintrc +5 -0
  255. package/src/style-spec/CHANGELOG.md +468 -0
  256. package/src/style-spec/README.md +59 -0
  257. package/src/style-spec/bin/gl-style-composite +9 -0
  258. package/src/style-spec/bin/gl-style-format +22 -0
  259. package/src/style-spec/bin/gl-style-migrate +9 -0
  260. package/src/style-spec/bin/gl-style-validate +50 -0
  261. package/src/style-spec/composite.js +50 -0
  262. package/src/style-spec/declass.js +42 -0
  263. package/src/style-spec/deref.js +52 -0
  264. package/src/style-spec/diff.js +393 -0
  265. package/src/style-spec/dist/.gitkeep +0 -0
  266. package/src/style-spec/dist/index.es.js +15032 -0
  267. package/src/style-spec/dist/index.es.js.map +1 -0
  268. package/src/style-spec/dist/index.js +15058 -0
  269. package/src/style-spec/dist/index.js.map +1 -0
  270. package/src/style-spec/empty.js +29 -0
  271. package/src/style-spec/error/parsing_error.js +16 -0
  272. package/src/style-spec/error/validation_error.js +18 -0
  273. package/src/style-spec/expression/compound_expression.js +162 -0
  274. package/src/style-spec/expression/definitions/assertion.js +130 -0
  275. package/src/style-spec/expression/definitions/at.js +70 -0
  276. package/src/style-spec/expression/definitions/case.js +85 -0
  277. package/src/style-spec/expression/definitions/coalesce.js +93 -0
  278. package/src/style-spec/expression/definitions/coercion.js +133 -0
  279. package/src/style-spec/expression/definitions/collator.js +78 -0
  280. package/src/style-spec/expression/definitions/comparison.js +184 -0
  281. package/src/style-spec/expression/definitions/format.js +144 -0
  282. package/src/style-spec/expression/definitions/image.js +52 -0
  283. package/src/style-spec/expression/definitions/in.js +72 -0
  284. package/src/style-spec/expression/definitions/index.js +565 -0
  285. package/src/style-spec/expression/definitions/index_of.js +89 -0
  286. package/src/style-spec/expression/definitions/interpolate.js +267 -0
  287. package/src/style-spec/expression/definitions/length.js +61 -0
  288. package/src/style-spec/expression/definitions/let.js +72 -0
  289. package/src/style-spec/expression/definitions/literal.js +77 -0
  290. package/src/style-spec/expression/definitions/match.js +158 -0
  291. package/src/style-spec/expression/definitions/number_format.js +142 -0
  292. package/src/style-spec/expression/definitions/slice.js +86 -0
  293. package/src/style-spec/expression/definitions/step.js +120 -0
  294. package/src/style-spec/expression/definitions/var.js +46 -0
  295. package/src/style-spec/expression/definitions/within.js +342 -0
  296. package/src/style-spec/expression/evaluation_context.js +59 -0
  297. package/src/style-spec/expression/expression.js +27 -0
  298. package/src/style-spec/expression/index.js +392 -0
  299. package/src/style-spec/expression/is_constant.js +59 -0
  300. package/src/style-spec/expression/parsing_context.js +233 -0
  301. package/src/style-spec/expression/parsing_error.js +13 -0
  302. package/src/style-spec/expression/runtime_error.js +17 -0
  303. package/src/style-spec/expression/scope.js +36 -0
  304. package/src/style-spec/expression/stops.js +39 -0
  305. package/src/style-spec/expression/types/collator.js +61 -0
  306. package/src/style-spec/expression/types/formatted.js +73 -0
  307. package/src/style-spec/expression/types/resolved_image.js +29 -0
  308. package/src/style-spec/expression/types.js +126 -0
  309. package/src/style-spec/expression/values.js +123 -0
  310. package/src/style-spec/feature_filter/README.md +55 -0
  311. package/src/style-spec/feature_filter/convert.js +208 -0
  312. package/src/style-spec/feature_filter/index.js +175 -0
  313. package/src/style-spec/format.js +51 -0
  314. package/src/style-spec/function/convert.js +270 -0
  315. package/src/style-spec/function/index.js +262 -0
  316. package/src/style-spec/group_by_layout.js +75 -0
  317. package/src/style-spec/migrate/expressions.js +39 -0
  318. package/src/style-spec/migrate/v8.js +203 -0
  319. package/src/style-spec/migrate/v9.js +26 -0
  320. package/src/style-spec/migrate.js +36 -0
  321. package/src/style-spec/package.json +41 -0
  322. package/src/style-spec/read_style.js +14 -0
  323. package/src/style-spec/reference/latest.js +3 -0
  324. package/src/style-spec/reference/v8.json +5914 -0
  325. package/src/style-spec/rollup.config.js +65 -0
  326. package/src/style-spec/style-spec.js +124 -0
  327. package/src/style-spec/types.js +432 -0
  328. package/src/style-spec/util/color.js +95 -0
  329. package/src/style-spec/util/color_spaces.js +139 -0
  330. package/src/style-spec/util/deep_equal.js +28 -0
  331. package/src/style-spec/util/extend.js +10 -0
  332. package/src/style-spec/util/get_type.js +17 -0
  333. package/src/style-spec/util/interpolate.js +22 -0
  334. package/src/style-spec/util/properties.js +15 -0
  335. package/src/style-spec/util/ref_properties.js +2 -0
  336. package/src/style-spec/util/result.js +19 -0
  337. package/src/style-spec/util/unbundle_jsonlint.js +24 -0
  338. package/src/style-spec/validate/latest.js +11 -0
  339. package/src/style-spec/validate/validate.js +75 -0
  340. package/src/style-spec/validate/validate_array.js +52 -0
  341. package/src/style-spec/validate/validate_boolean.js +15 -0
  342. package/src/style-spec/validate/validate_color.js +20 -0
  343. package/src/style-spec/validate/validate_constants.js +13 -0
  344. package/src/style-spec/validate/validate_enum.js +21 -0
  345. package/src/style-spec/validate/validate_expression.js +43 -0
  346. package/src/style-spec/validate/validate_filter.js +117 -0
  347. package/src/style-spec/validate/validate_formatted.js +11 -0
  348. package/src/style-spec/validate/validate_function.js +207 -0
  349. package/src/style-spec/validate/validate_glyphs_url.js +21 -0
  350. package/src/style-spec/validate/validate_image.js +11 -0
  351. package/src/style-spec/validate/validate_layer.js +134 -0
  352. package/src/style-spec/validate/validate_layout_property.js +6 -0
  353. package/src/style-spec/validate/validate_light.js +47 -0
  354. package/src/style-spec/validate/validate_number.js +29 -0
  355. package/src/style-spec/validate/validate_object.js +61 -0
  356. package/src/style-spec/validate/validate_paint_property.js +6 -0
  357. package/src/style-spec/validate/validate_property.js +64 -0
  358. package/src/style-spec/validate/validate_source.js +111 -0
  359. package/src/style-spec/validate/validate_string.js +15 -0
  360. package/src/style-spec/validate_mapbox_api_supported.js +171 -0
  361. package/src/style-spec/validate_style.js +39 -0
  362. package/src/style-spec/validate_style.min.js +78 -0
  363. package/src/style-spec/visit.js +77 -0
  364. package/src/symbol/anchor.js +26 -0
  365. package/src/symbol/check_max_angle.js +81 -0
  366. package/src/symbol/clip_line.js +71 -0
  367. package/src/symbol/collision_feature.js +109 -0
  368. package/src/symbol/collision_index.js +373 -0
  369. package/src/symbol/cross_tile_symbol_index.js +301 -0
  370. package/src/symbol/get_anchors.js +167 -0
  371. package/src/symbol/grid_index.js +335 -0
  372. package/src/symbol/mergelines.js +82 -0
  373. package/src/symbol/one_em.js +4 -0
  374. package/src/symbol/opacity_state.js +27 -0
  375. package/src/symbol/path_interpolator.js +61 -0
  376. package/src/symbol/placement.js +1124 -0
  377. package/src/symbol/projection.js +451 -0
  378. package/src/symbol/quads.js +334 -0
  379. package/src/symbol/shaping.js +816 -0
  380. package/src/symbol/symbol_layout.js +796 -0
  381. package/src/symbol/symbol_size.js +113 -0
  382. package/src/symbol/transform_text.js +29 -0
  383. package/src/types/callback.js +17 -0
  384. package/src/types/cancelable.js +3 -0
  385. package/src/types/tilejson.js +17 -0
  386. package/src/types/transferable.js +3 -0
  387. package/src/types/window.js +172 -0
  388. package/src/ui/anchor.js +32 -0
  389. package/src/ui/camera.js +1277 -0
  390. package/src/ui/control/attribution_control.js +212 -0
  391. package/src/ui/control/fullscreen_control.js +147 -0
  392. package/src/ui/control/geolocate_control.js +707 -0
  393. package/src/ui/control/logo_control.js +92 -0
  394. package/src/ui/control/navigation_control.js +257 -0
  395. package/src/ui/control/scale_control.js +142 -0
  396. package/src/ui/default_locale.js +22 -0
  397. package/src/ui/events.js +1301 -0
  398. package/src/ui/handler/box_zoom.js +170 -0
  399. package/src/ui/handler/click_zoom.js +52 -0
  400. package/src/ui/handler/handler_util.js +12 -0
  401. package/src/ui/handler/keyboard.js +208 -0
  402. package/src/ui/handler/map_event.js +156 -0
  403. package/src/ui/handler/mouse.js +171 -0
  404. package/src/ui/handler/scroll_zoom.js +350 -0
  405. package/src/ui/handler/shim/dblclick_zoom.js +62 -0
  406. package/src/ui/handler/shim/drag_pan.js +88 -0
  407. package/src/ui/handler/shim/drag_rotate.js +67 -0
  408. package/src/ui/handler/shim/touch_zoom_rotate.js +108 -0
  409. package/src/ui/handler/tap_drag_zoom.js +103 -0
  410. package/src/ui/handler/tap_recognizer.js +133 -0
  411. package/src/ui/handler/tap_zoom.js +93 -0
  412. package/src/ui/handler/touch_pan.js +101 -0
  413. package/src/ui/handler/touch_zoom_rotate.js +305 -0
  414. package/src/ui/handler_inertia.js +158 -0
  415. package/src/ui/handler_manager.js +531 -0
  416. package/src/ui/hash.js +148 -0
  417. package/src/ui/map.js +2874 -0
  418. package/src/ui/marker.js +672 -0
  419. package/src/ui/popup.js +640 -0
  420. package/src/util/actor.js +212 -0
  421. package/src/util/ajax.js +388 -0
  422. package/src/util/browser/web_worker.js +10 -0
  423. package/src/util/browser/window.js +6 -0
  424. package/src/util/browser.js +70 -0
  425. package/src/util/classify_rings.js +52 -0
  426. package/src/util/color_ramp.js +61 -0
  427. package/src/util/config.js +30 -0
  428. package/src/util/debug.js +28 -0
  429. package/src/util/dictionary_coder.js +30 -0
  430. package/src/util/dispatcher.js +70 -0
  431. package/src/util/dom.js +142 -0
  432. package/src/util/evented.js +174 -0
  433. package/src/util/find_pole_of_inaccessibility.js +129 -0
  434. package/src/util/global_worker_pool.js +35 -0
  435. package/src/util/image.js +142 -0
  436. package/src/util/intersection_tests.js +208 -0
  437. package/src/util/is_char_in_unicode_block.js +311 -0
  438. package/src/util/mapbox.js +491 -0
  439. package/src/util/offscreen_canvas_supported.js +14 -0
  440. package/src/util/performance.js +112 -0
  441. package/src/util/primitives.js +145 -0
  442. package/src/util/resolve_tokens.js +16 -0
  443. package/src/util/script_detection.js +328 -0
  444. package/src/util/sku_token.js +42 -0
  445. package/src/util/smart_wrap.js +55 -0
  446. package/src/util/struct_array.js +243 -0
  447. package/src/util/struct_array.js.ejs +112 -0
  448. package/src/util/struct_array_layout.js.ejs +98 -0
  449. package/src/util/task_queue.js +68 -0
  450. package/src/util/throttle.js +27 -0
  451. package/src/util/throttled_invoker.js +46 -0
  452. package/src/util/tile_request_cache.js +172 -0
  453. package/src/util/util.js +524 -0
  454. package/src/util/vectortile_to_geojson.js +50 -0
  455. package/src/util/verticalize_punctuation.js +114 -0
  456. package/src/util/web_worker.js +91 -0
  457. package/src/util/web_worker_transfer.js +266 -0
  458. package/src/util/webp_supported.js +69 -0
  459. package/src/util/window.js +102 -0
  460. package/src/util/worker_pool.js +57 -0
@@ -0,0 +1,937 @@
1
+ // @flow
2
+
3
+ import {symbolLayoutAttributes,
4
+ collisionVertexAttributes,
5
+ collisionBoxLayout,
6
+ dynamicLayoutAttributes
7
+ } from './symbol_attributes';
8
+
9
+ import {SymbolLayoutArray,
10
+ SymbolDynamicLayoutArray,
11
+ SymbolOpacityArray,
12
+ CollisionBoxLayoutArray,
13
+ CollisionVertexArray,
14
+ PlacedSymbolArray,
15
+ SymbolInstanceArray,
16
+ GlyphOffsetArray,
17
+ SymbolLineVertexArray
18
+ } from '../array_types';
19
+
20
+ import Point from '@mapbox/point-geometry';
21
+ import SegmentVector from '../segment';
22
+ import {ProgramConfigurationSet} from '../program_configuration';
23
+ import {TriangleIndexArray, LineIndexArray} from '../index_array_type';
24
+ import transformText from '../../symbol/transform_text';
25
+ import mergeLines from '../../symbol/mergelines';
26
+ import {allowsVerticalWritingMode, stringContainsRTLText} from '../../util/script_detection';
27
+ import {WritingMode} from '../../symbol/shaping';
28
+ import loadGeometry from '../load_geometry';
29
+ import toEvaluationFeature from '../evaluation_feature';
30
+ import mvt from '@mapbox/vector-tile';
31
+ const vectorTileFeatureTypes = mvt.VectorTileFeature.types;
32
+ import {verticalizedCharacterMap} from '../../util/verticalize_punctuation';
33
+ import Anchor from '../../symbol/anchor';
34
+ import {getSizeData} from '../../symbol/symbol_size';
35
+ import {MAX_PACKED_SIZE} from '../../symbol/symbol_layout';
36
+ import {register} from '../../util/web_worker_transfer';
37
+ import EvaluationParameters from '../../style/evaluation_parameters';
38
+ import Formatted from '../../style-spec/expression/types/formatted';
39
+ import ResolvedImage from '../../style-spec/expression/types/resolved_image';
40
+ import {plugin as globalRTLTextPlugin, getRTLTextPluginStatus} from '../../source/rtl_text_plugin';
41
+ import {mat4} from 'gl-matrix';
42
+
43
+ import type {CanonicalTileID} from '../../source/tile_id';
44
+ import type {
45
+ Bucket,
46
+ BucketParameters,
47
+ IndexedFeature,
48
+ PopulateParameters
49
+ } from '../bucket';
50
+ import type {CollisionBoxArray, CollisionBox, SymbolInstance} from '../array_types';
51
+ import type {StructArray, StructArrayMember} from '../../util/struct_array';
52
+ import SymbolStyleLayer from '../../style/style_layer/symbol_style_layer';
53
+ import type Context from '../../gl/context';
54
+ import type IndexBuffer from '../../gl/index_buffer';
55
+ import type VertexBuffer from '../../gl/vertex_buffer';
56
+ import type {SymbolQuad} from '../../symbol/quads';
57
+ import type {SizeData} from '../../symbol/symbol_size';
58
+ import type {FeatureStates} from '../../source/source_state';
59
+ import type {ImagePosition} from '../../render/image_atlas';
60
+
61
+ export type SingleCollisionBox = {
62
+ x1: number;
63
+ y1: number;
64
+ x2: number;
65
+ y2: number;
66
+ anchorPointX: number;
67
+ anchorPointY: number;
68
+ };
69
+
70
+ export type CollisionArrays = {
71
+ textBox?: SingleCollisionBox;
72
+ verticalTextBox?: SingleCollisionBox;
73
+ iconBox?: SingleCollisionBox;
74
+ verticalIconBox?: SingleCollisionBox;
75
+ textFeatureIndex?: number;
76
+ verticalTextFeatureIndex?: number;
77
+ iconFeatureIndex?: number;
78
+ verticalIconFeatureIndex?: number;
79
+ };
80
+
81
+ export type SymbolFeature = {|
82
+ sortKey: number | void,
83
+ text: Formatted | void,
84
+ icon: ?ResolvedImage,
85
+ index: number,
86
+ sourceLayerIndex: number,
87
+ geometry: Array<Array<Point>>,
88
+ properties: Object,
89
+ type: 'Point' | 'LineString' | 'Polygon',
90
+ id?: any
91
+ |};
92
+
93
+ export type SortKeyRange = {
94
+ sortKey: number,
95
+ symbolInstanceStart: number,
96
+ symbolInstanceEnd: number
97
+ };
98
+
99
+ // Opacity arrays are frequently updated but don't contain a lot of information, so we pack them
100
+ // tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph
101
+ // 7 bits are for the current opacity, and the lowest bit is the target opacity
102
+
103
+ // actually defined in symbol_attributes.js
104
+ // const placementOpacityAttributes = [
105
+ // { name: 'a_fade_opacity', components: 1, type: 'Uint32' }
106
+ // ];
107
+ const shaderOpacityAttributes = [
108
+ {name: 'a_fade_opacity', components: 1, type: 'Uint8', offset: 0}
109
+ ];
110
+
111
+ function addVertex(array, anchorX, anchorY, ox, oy, tx, ty, sizeVertex, isSDF: boolean, pixelOffsetX, pixelOffsetY, minFontScaleX, minFontScaleY) {
112
+ const aSizeX = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[0])) : 0;
113
+ const aSizeY = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[1])) : 0;
114
+ array.emplaceBack(
115
+ // a_pos_offset
116
+ anchorX,
117
+ anchorY,
118
+ Math.round(ox * 32),
119
+ Math.round(oy * 32),
120
+
121
+ // a_data
122
+ tx, // x coordinate of symbol on glyph atlas texture
123
+ ty, // y coordinate of symbol on glyph atlas texture
124
+ (aSizeX << 1) + (isSDF ? 1 : 0),
125
+ aSizeY,
126
+ pixelOffsetX * 16,
127
+ pixelOffsetY * 16,
128
+ minFontScaleX * 256,
129
+ minFontScaleY * 256
130
+ );
131
+ }
132
+
133
+ function addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, angle: number) {
134
+ dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
135
+ dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
136
+ dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
137
+ dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
138
+ }
139
+
140
+ function containsRTLText(formattedText: Formatted): boolean {
141
+ for (const section of formattedText.sections) {
142
+ if (stringContainsRTLText(section.text)) {
143
+ return true;
144
+ }
145
+ }
146
+ return false;
147
+ }
148
+
149
+ export class SymbolBuffers {
150
+ layoutVertexArray: SymbolLayoutArray;
151
+ layoutVertexBuffer: VertexBuffer;
152
+
153
+ indexArray: TriangleIndexArray;
154
+ indexBuffer: IndexBuffer;
155
+
156
+ programConfigurations: ProgramConfigurationSet<SymbolStyleLayer>;
157
+ segments: SegmentVector;
158
+
159
+ dynamicLayoutVertexArray: SymbolDynamicLayoutArray;
160
+ dynamicLayoutVertexBuffer: VertexBuffer;
161
+
162
+ opacityVertexArray: SymbolOpacityArray;
163
+ opacityVertexBuffer: VertexBuffer;
164
+
165
+ collisionVertexArray: CollisionVertexArray;
166
+ collisionVertexBuffer: VertexBuffer;
167
+
168
+ placedSymbolArray: PlacedSymbolArray;
169
+
170
+ constructor(programConfigurations: ProgramConfigurationSet<SymbolStyleLayer>) {
171
+ this.layoutVertexArray = new SymbolLayoutArray();
172
+ this.indexArray = new TriangleIndexArray();
173
+ this.programConfigurations = programConfigurations;
174
+ this.segments = new SegmentVector();
175
+ this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray();
176
+ this.opacityVertexArray = new SymbolOpacityArray();
177
+ this.placedSymbolArray = new PlacedSymbolArray();
178
+ }
179
+
180
+ isEmpty() {
181
+ return this.layoutVertexArray.length === 0 &&
182
+ this.indexArray.length === 0 &&
183
+ this.dynamicLayoutVertexArray.length === 0 &&
184
+ this.opacityVertexArray.length === 0;
185
+ }
186
+
187
+ upload(context: Context, dynamicIndexBuffer: boolean, upload?: boolean, update?: boolean) {
188
+ if (this.isEmpty()) {
189
+ return;
190
+ }
191
+
192
+ if (upload) {
193
+ this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members);
194
+ this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer);
195
+ this.dynamicLayoutVertexBuffer = context.createVertexBuffer(this.dynamicLayoutVertexArray, dynamicLayoutAttributes.members, true);
196
+ this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true);
197
+ // This is a performance hack so that we can write to opacityVertexArray with uint32s
198
+ // even though the shaders read uint8s
199
+ this.opacityVertexBuffer.itemSize = 1;
200
+ }
201
+ if (upload || update) {
202
+ this.programConfigurations.upload(context);
203
+ }
204
+ }
205
+
206
+ destroy() {
207
+ if (!this.layoutVertexBuffer) return;
208
+ this.layoutVertexBuffer.destroy();
209
+ this.indexBuffer.destroy();
210
+ this.programConfigurations.destroy();
211
+ this.segments.destroy();
212
+ this.dynamicLayoutVertexBuffer.destroy();
213
+ this.opacityVertexBuffer.destroy();
214
+ }
215
+ }
216
+
217
+ register('SymbolBuffers', SymbolBuffers);
218
+
219
+ class CollisionBuffers {
220
+ layoutVertexArray: StructArray;
221
+ layoutAttributes: Array<StructArrayMember>;
222
+ layoutVertexBuffer: VertexBuffer;
223
+
224
+ indexArray: TriangleIndexArray | LineIndexArray;
225
+ indexBuffer: IndexBuffer;
226
+
227
+ segments: SegmentVector;
228
+
229
+ collisionVertexArray: CollisionVertexArray;
230
+ collisionVertexBuffer: VertexBuffer;
231
+
232
+ constructor(LayoutArray: Class<StructArray>,
233
+ layoutAttributes: Array<StructArrayMember>,
234
+ IndexArray: Class<TriangleIndexArray | LineIndexArray>) {
235
+ this.layoutVertexArray = new LayoutArray();
236
+ this.layoutAttributes = layoutAttributes;
237
+ this.indexArray = new IndexArray();
238
+ this.segments = new SegmentVector();
239
+ this.collisionVertexArray = new CollisionVertexArray();
240
+ }
241
+
242
+ upload(context: Context) {
243
+ this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes);
244
+ this.indexBuffer = context.createIndexBuffer(this.indexArray);
245
+ this.collisionVertexBuffer = context.createVertexBuffer(this.collisionVertexArray, collisionVertexAttributes.members, true);
246
+ }
247
+
248
+ destroy() {
249
+ if (!this.layoutVertexBuffer) return;
250
+ this.layoutVertexBuffer.destroy();
251
+ this.indexBuffer.destroy();
252
+ this.segments.destroy();
253
+ this.collisionVertexBuffer.destroy();
254
+ }
255
+ }
256
+
257
+ register('CollisionBuffers', CollisionBuffers);
258
+
259
+ /**
260
+ * Unlike other buckets, which simply implement #addFeature with type-specific
261
+ * logic for (essentially) triangulating feature geometries, SymbolBucket
262
+ * requires specialized behavior:
263
+ *
264
+ * 1. WorkerTile#parse(), the logical owner of the bucket creation process,
265
+ * calls SymbolBucket#populate(), which resolves text and icon tokens on
266
+ * each feature, adds each glyphs and symbols needed to the passed-in
267
+ * collections options.glyphDependencies and options.iconDependencies, and
268
+ * stores the feature data for use in subsequent step (this.features).
269
+ *
270
+ * 2. WorkerTile asynchronously requests from the main thread all of the glyphs
271
+ * and icons needed (by this bucket and any others). When glyphs and icons
272
+ * have been received, the WorkerTile creates a CollisionIndex and invokes:
273
+ *
274
+ * 3. performSymbolLayout(bucket, stacks, icons) perform texts shaping and
275
+ * layout on a Symbol Bucket. This step populates:
276
+ * `this.symbolInstances`: metadata on generated symbols
277
+ * `this.collisionBoxArray`: collision data for use by foreground
278
+ * `this.text`: SymbolBuffers for text symbols
279
+ * `this.icons`: SymbolBuffers for icons
280
+ * `this.iconCollisionBox`: Debug SymbolBuffers for icon collision boxes
281
+ * `this.textCollisionBox`: Debug SymbolBuffers for text collision boxes
282
+ * The results are sent to the foreground for rendering
283
+ *
284
+ * 4. performSymbolPlacement(bucket, collisionIndex) is run on the foreground,
285
+ * and uses the CollisionIndex along with current camera settings to determine
286
+ * which symbols can actually show on the map. Collided symbols are hidden
287
+ * using a dynamic "OpacityVertexArray".
288
+ *
289
+ * @private
290
+ */
291
+ class SymbolBucket implements Bucket {
292
+ static MAX_GLYPHS: number;
293
+ static addDynamicAttributes: typeof addDynamicAttributes;
294
+
295
+ collisionBoxArray: CollisionBoxArray;
296
+ zoom: number;
297
+ overscaling: number;
298
+ layers: Array<SymbolStyleLayer>;
299
+ layerIds: Array<string>;
300
+ stateDependentLayers: Array<SymbolStyleLayer>;
301
+ stateDependentLayerIds: Array<string>;
302
+
303
+ index: number;
304
+ sdfIcons: boolean;
305
+ iconsInText: boolean;
306
+ iconsNeedLinear: boolean;
307
+ bucketInstanceId: number;
308
+ justReloaded: boolean;
309
+ hasPattern: boolean;
310
+
311
+ textSizeData: SizeData;
312
+ iconSizeData: SizeData;
313
+
314
+ glyphOffsetArray: GlyphOffsetArray;
315
+ lineVertexArray: SymbolLineVertexArray;
316
+ features: Array<SymbolFeature>;
317
+ symbolInstances: SymbolInstanceArray;
318
+ collisionArrays: Array<CollisionArrays>;
319
+ sortKeyRanges: Array<SortKeyRange>;
320
+ pixelRatio: number;
321
+ tilePixelRatio: number;
322
+ compareText: {[_: string]: Array<Point>};
323
+ fadeStartTime: number;
324
+ sortFeaturesByKey: boolean;
325
+ sortFeaturesByY: boolean;
326
+ canOverlap: boolean;
327
+ sortedAngle: number;
328
+ featureSortOrder: Array<number>;
329
+
330
+ collisionCircleArray: Array<number>;
331
+ placementInvProjMatrix: mat4;
332
+ placementViewportMatrix: mat4;
333
+
334
+ text: SymbolBuffers;
335
+ icon: SymbolBuffers;
336
+ textCollisionBox: CollisionBuffers;
337
+ iconCollisionBox: CollisionBuffers;
338
+ uploaded: boolean;
339
+ sourceLayerIndex: number;
340
+ sourceID: string;
341
+ symbolInstanceIndexes: Array<number>;
342
+ writingModes: Array<number>;
343
+ allowVerticalPlacement: boolean;
344
+ hasRTLText: boolean;
345
+
346
+ constructor(options: BucketParameters<SymbolStyleLayer>) {
347
+ this.collisionBoxArray = options.collisionBoxArray;
348
+ this.zoom = options.zoom;
349
+ this.overscaling = options.overscaling;
350
+ this.layers = options.layers;
351
+ this.layerIds = this.layers.map(layer => layer.id);
352
+ this.index = options.index;
353
+ this.pixelRatio = options.pixelRatio;
354
+ this.sourceLayerIndex = options.sourceLayerIndex;
355
+ this.hasPattern = false;
356
+ this.hasRTLText = false;
357
+ this.sortKeyRanges = [];
358
+
359
+ this.collisionCircleArray = [];
360
+ this.placementInvProjMatrix = mat4.identity([]);
361
+ this.placementViewportMatrix = mat4.identity([]);
362
+
363
+ const layer = this.layers[0];
364
+ const unevaluatedLayoutValues = layer._unevaluatedLayout._values;
365
+
366
+ this.textSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['text-size']);
367
+ this.iconSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['icon-size']);
368
+
369
+ const layout = this.layers[0].layout;
370
+ const sortKey = layout.get('symbol-sort-key');
371
+ const zOrder = layout.get('symbol-z-order');
372
+ this.canOverlap =
373
+ layout.get('text-allow-overlap') ||
374
+ layout.get('icon-allow-overlap') ||
375
+ layout.get('text-ignore-placement') ||
376
+ layout.get('icon-ignore-placement');
377
+ this.sortFeaturesByKey = zOrder !== 'viewport-y' && sortKey.constantOr(1) !== undefined;
378
+ const zOrderByViewportY = zOrder === 'viewport-y' || (zOrder === 'auto' && !this.sortFeaturesByKey);
379
+ this.sortFeaturesByY = zOrderByViewportY && this.canOverlap;
380
+
381
+ if (layout.get('symbol-placement') === 'point') {
382
+ this.writingModes = layout.get('text-writing-mode').map(wm => WritingMode[wm]);
383
+ }
384
+
385
+ this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);
386
+
387
+ this.sourceID = options.sourceID;
388
+ }
389
+
390
+ createArrays() {
391
+ this.text = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^text/.test(property)));
392
+ this.icon = new SymbolBuffers(new ProgramConfigurationSet(this.layers, this.zoom, property => /^icon/.test(property)));
393
+
394
+ this.glyphOffsetArray = new GlyphOffsetArray();
395
+ this.lineVertexArray = new SymbolLineVertexArray();
396
+ this.symbolInstances = new SymbolInstanceArray();
397
+ }
398
+
399
+ calculateGlyphDependencies(text: string, stack: {[_: number]: boolean}, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean) {
400
+ for (let i = 0; i < text.length; i++) {
401
+ stack[text.charCodeAt(i)] = true;
402
+ if ((textAlongLine || allowVerticalPlacement) && doesAllowVerticalWritingMode) {
403
+ const verticalChar = verticalizedCharacterMap[text.charAt(i)];
404
+ if (verticalChar) {
405
+ stack[verticalChar.charCodeAt(0)] = true;
406
+ }
407
+ }
408
+ }
409
+ }
410
+
411
+ populate(features: Array<IndexedFeature>, options: PopulateParameters, canonical: CanonicalTileID) {
412
+ const layer = this.layers[0];
413
+ const layout = layer.layout;
414
+
415
+ const textFont = layout.get('text-font');
416
+ const textField = layout.get('text-field');
417
+ const iconImage = layout.get('icon-image');
418
+ const hasText =
419
+ (textField.value.kind !== 'constant' ||
420
+ (textField.value.value instanceof Formatted && !textField.value.value.isEmpty()) ||
421
+ textField.value.value.toString().length > 0) &&
422
+ (textFont.value.kind !== 'constant' || textFont.value.value.length > 0);
423
+ // we should always resolve the icon-image value if the property was defined in the style
424
+ // this allows us to fire the styleimagemissing event if image evaluation returns null
425
+ // the only way to distinguish between null returned from a coalesce statement with no valid images
426
+ // and null returned because icon-image wasn't defined is to check whether or not iconImage.parameters is an empty object
427
+ const hasIcon = iconImage.value.kind !== 'constant' || !!iconImage.value.value || Object.keys(iconImage.parameters).length > 0;
428
+ const symbolSortKey = layout.get('symbol-sort-key');
429
+
430
+ this.features = [];
431
+
432
+ if (!hasText && !hasIcon) {
433
+ return;
434
+ }
435
+
436
+ const icons = options.iconDependencies;
437
+ const stacks = options.glyphDependencies;
438
+ const availableImages = options.availableImages;
439
+ const globalProperties = new EvaluationParameters(this.zoom);
440
+
441
+ for (const {feature, id, index, sourceLayerIndex} of features) {
442
+
443
+ const needGeometry = layer._featureFilter.needGeometry;
444
+ const evaluationFeature = toEvaluationFeature(feature, needGeometry);
445
+ if (!layer._featureFilter.filter(globalProperties, evaluationFeature, canonical)) {
446
+ continue;
447
+ }
448
+
449
+ if (!needGeometry) evaluationFeature.geometry = loadGeometry(feature);
450
+
451
+ let text: Formatted | void;
452
+ if (hasText) {
453
+ // Expression evaluation will automatically coerce to Formatted
454
+ // but plain string token evaluation skips that pathway so do the
455
+ // conversion here.
456
+ const resolvedTokens = layer.getValueAndResolveTokens('text-field', evaluationFeature, canonical, availableImages);
457
+ const formattedText = Formatted.factory(resolvedTokens);
458
+ if (containsRTLText(formattedText)) {
459
+ this.hasRTLText = true;
460
+ }
461
+ if (
462
+ !this.hasRTLText || // non-rtl text so can proceed safely
463
+ getRTLTextPluginStatus() === 'unavailable' || // We don't intend to lazy-load the rtl text plugin, so proceed with incorrect shaping
464
+ this.hasRTLText && globalRTLTextPlugin.isParsed() // Use the rtlText plugin to shape text
465
+ ) {
466
+ text = transformText(formattedText, layer, evaluationFeature);
467
+ }
468
+ }
469
+
470
+ let icon: ?ResolvedImage;
471
+ if (hasIcon) {
472
+ // Expression evaluation will automatically coerce to Image
473
+ // but plain string token evaluation skips that pathway so do the
474
+ // conversion here.
475
+ const resolvedTokens = layer.getValueAndResolveTokens('icon-image', evaluationFeature, canonical, availableImages);
476
+ if (resolvedTokens instanceof ResolvedImage) {
477
+ icon = resolvedTokens;
478
+ } else {
479
+ icon = ResolvedImage.fromString(resolvedTokens);
480
+ }
481
+ }
482
+
483
+ if (!text && !icon) {
484
+ continue;
485
+ }
486
+ const sortKey = this.sortFeaturesByKey ?
487
+ symbolSortKey.evaluate(evaluationFeature, {}, canonical) :
488
+ undefined;
489
+
490
+ const symbolFeature: SymbolFeature = {
491
+ id,
492
+ text,
493
+ icon,
494
+ index,
495
+ sourceLayerIndex,
496
+ geometry: evaluationFeature.geometry,
497
+ properties: feature.properties,
498
+ type: vectorTileFeatureTypes[feature.type],
499
+ sortKey
500
+ };
501
+ this.features.push(symbolFeature);
502
+
503
+ if (icon) {
504
+ icons[icon.name] = true;
505
+ }
506
+
507
+ if (text) {
508
+ const fontStack = textFont.evaluate(evaluationFeature, {}, canonical).join(',');
509
+ const textAlongLine = layout.get('text-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point';
510
+ this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(WritingMode.vertical) >= 0;
511
+ for (const section of text.sections) {
512
+ if (!section.image) {
513
+ const doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString());
514
+ const sectionFont = section.fontStack || fontStack;
515
+ const sectionStack = stacks[sectionFont] = stacks[sectionFont] || {};
516
+ this.calculateGlyphDependencies(section.text, sectionStack, textAlongLine, this.allowVerticalPlacement, doesAllowVerticalWritingMode);
517
+ } else {
518
+ // Add section image to the list of dependencies.
519
+ icons[section.image.name] = true;
520
+ }
521
+ }
522
+ }
523
+ }
524
+
525
+ if (layout.get('symbol-placement') === 'line') {
526
+ // Merge adjacent lines with the same text to improve labelling.
527
+ // It's better to place labels on one long line than on many short segments.
528
+ this.features = mergeLines(this.features);
529
+ }
530
+
531
+ if (this.sortFeaturesByKey) {
532
+ this.features.sort((a, b) => {
533
+ // a.sortKey is always a number when sortFeaturesByKey is true
534
+ return ((a.sortKey: any): number) - ((b.sortKey: any): number);
535
+ });
536
+ }
537
+ }
538
+
539
+ update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {
540
+ if (!this.stateDependentLayers.length) return;
541
+ this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);
542
+ this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);
543
+ }
544
+
545
+ isEmpty() {
546
+ // When the bucket encounters only rtl-text but the plugin isnt loaded, no symbol instances will be created.
547
+ // In order for the bucket to be serialized, and not discarded as an empty bucket both checks are necessary.
548
+ return this.symbolInstances.length === 0 && !this.hasRTLText;
549
+ }
550
+
551
+ uploadPending() {
552
+ return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload;
553
+ }
554
+
555
+ upload(context: Context) {
556
+ if (!this.uploaded && this.hasDebugData()) {
557
+ this.textCollisionBox.upload(context);
558
+ this.iconCollisionBox.upload(context);
559
+ }
560
+ this.text.upload(context, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload);
561
+ this.icon.upload(context, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload);
562
+ this.uploaded = true;
563
+ }
564
+
565
+ destroyDebugData() {
566
+ this.textCollisionBox.destroy();
567
+ this.iconCollisionBox.destroy();
568
+ }
569
+
570
+ destroy() {
571
+ this.text.destroy();
572
+ this.icon.destroy();
573
+
574
+ if (this.hasDebugData()) {
575
+ this.destroyDebugData();
576
+ }
577
+ }
578
+
579
+ addToLineVertexArray(anchor: Anchor, line: any) {
580
+ const lineStartIndex = this.lineVertexArray.length;
581
+ if (anchor.segment !== undefined) {
582
+ let sumForwardLength = anchor.dist(line[anchor.segment + 1]);
583
+ let sumBackwardLength = anchor.dist(line[anchor.segment]);
584
+ const vertices = {};
585
+ for (let i = anchor.segment + 1; i < line.length; i++) {
586
+ vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength};
587
+ if (i < line.length - 1) {
588
+ sumForwardLength += line[i + 1].dist(line[i]);
589
+ }
590
+ }
591
+ for (let i = anchor.segment || 0; i >= 0; i--) {
592
+ vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength};
593
+ if (i > 0) {
594
+ sumBackwardLength += line[i - 1].dist(line[i]);
595
+ }
596
+ }
597
+ for (let i = 0; i < line.length; i++) {
598
+ const vertex = vertices[i];
599
+ this.lineVertexArray.emplaceBack(vertex.x, vertex.y, vertex.tileUnitDistanceFromAnchor);
600
+ }
601
+ }
602
+ return {
603
+ lineStartIndex,
604
+ lineLength: this.lineVertexArray.length - lineStartIndex
605
+ };
606
+ }
607
+
608
+ addSymbols(arrays: SymbolBuffers,
609
+ quads: Array<SymbolQuad>,
610
+ sizeVertex: any,
611
+ lineOffset: [number, number],
612
+ alongLine: boolean,
613
+ feature: SymbolFeature,
614
+ writingMode: any,
615
+ labelAnchor: Anchor,
616
+ lineStartIndex: number,
617
+ lineLength: number,
618
+ associatedIconIndex: number,
619
+ canonical: CanonicalTileID) {
620
+ const indexArray = arrays.indexArray;
621
+ const layoutVertexArray = arrays.layoutVertexArray;
622
+
623
+ const segment = arrays.segments.prepareSegment(4 * quads.length, layoutVertexArray, indexArray, this.canOverlap ? feature.sortKey : undefined);
624
+ const glyphOffsetArrayStart = this.glyphOffsetArray.length;
625
+ const vertexStartIndex = segment.vertexLength;
626
+
627
+ const angle = (this.allowVerticalPlacement && writingMode === WritingMode.vertical) ? Math.PI / 2 : 0;
628
+
629
+ const sections = feature.text && feature.text.sections;
630
+
631
+ for (let i = 0; i < quads.length; i++) {
632
+ const {tl, tr, bl, br, tex, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, glyphOffset, isSDF, sectionIndex} = quads[i];
633
+ const index = segment.vertexLength;
634
+
635
+ const y = glyphOffset[1];
636
+ addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tl.x, y + tl.y, tex.x, tex.y, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);
637
+ addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tr.x, y + tr.y, tex.x + tex.w, tex.y, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);
638
+ addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, bl.x, y + bl.y, tex.x, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);
639
+ addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, br.x, y + br.y, tex.x + tex.w, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);
640
+
641
+ addDynamicAttributes(arrays.dynamicLayoutVertexArray, labelAnchor, angle);
642
+
643
+ indexArray.emplaceBack(index, index + 1, index + 2);
644
+ indexArray.emplaceBack(index + 1, index + 2, index + 3);
645
+
646
+ segment.vertexLength += 4;
647
+ segment.primitiveLength += 2;
648
+
649
+ this.glyphOffsetArray.emplaceBack(glyphOffset[0]);
650
+
651
+ if (i === quads.length - 1 || sectionIndex !== quads[i + 1].sectionIndex) {
652
+ arrays.programConfigurations.populatePaintArrays(layoutVertexArray.length, feature, feature.index, {}, canonical, sections && sections[sectionIndex]);
653
+ }
654
+ }
655
+
656
+ arrays.placedSymbolArray.emplaceBack(labelAnchor.x, labelAnchor.y,
657
+ glyphOffsetArrayStart, this.glyphOffsetArray.length - glyphOffsetArrayStart, vertexStartIndex,
658
+ lineStartIndex, lineLength, (labelAnchor.segment: any),
659
+ sizeVertex ? sizeVertex[0] : 0, sizeVertex ? sizeVertex[1] : 0,
660
+ lineOffset[0], lineOffset[1],
661
+ writingMode,
662
+ // placedOrientation is null initially; will be updated to horizontal(1)/vertical(2) if placed
663
+ 0,
664
+ (false: any),
665
+ // The crossTileID is only filled/used on the foreground for dynamic text anchors
666
+ 0,
667
+ associatedIconIndex
668
+ );
669
+ }
670
+
671
+ _addCollisionDebugVertex(layoutVertexArray: StructArray, collisionVertexArray: StructArray, point: Point, anchorX: number, anchorY: number, extrude: Point) {
672
+ collisionVertexArray.emplaceBack(0, 0);
673
+ return layoutVertexArray.emplaceBack(
674
+ // pos
675
+ point.x,
676
+ point.y,
677
+ // a_anchor_pos
678
+ anchorX,
679
+ anchorY,
680
+ // extrude
681
+ Math.round(extrude.x),
682
+ Math.round(extrude.y));
683
+ }
684
+
685
+ addCollisionDebugVertices(x1: number, y1: number, x2: number, y2: number, arrays: CollisionBuffers, boxAnchorPoint: Point, symbolInstance: SymbolInstance) {
686
+ const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray);
687
+ const index = segment.vertexLength;
688
+
689
+ const layoutVertexArray = arrays.layoutVertexArray;
690
+ const collisionVertexArray = arrays.collisionVertexArray;
691
+
692
+ const anchorX = symbolInstance.anchorX;
693
+ const anchorY = symbolInstance.anchorY;
694
+
695
+ this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y1));
696
+ this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y1));
697
+ this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y2));
698
+ this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y2));
699
+
700
+ segment.vertexLength += 4;
701
+
702
+ const indexArray: LineIndexArray = (arrays.indexArray: any);
703
+ indexArray.emplaceBack(index, index + 1);
704
+ indexArray.emplaceBack(index + 1, index + 2);
705
+ indexArray.emplaceBack(index + 2, index + 3);
706
+ indexArray.emplaceBack(index + 3, index);
707
+
708
+ segment.primitiveLength += 4;
709
+ }
710
+
711
+ addDebugCollisionBoxes(startIndex: number, endIndex: number, symbolInstance: SymbolInstance, isText: boolean) {
712
+ for (let b = startIndex; b < endIndex; b++) {
713
+ const box: CollisionBox = (this.collisionBoxArray.get(b): any);
714
+ const x1 = box.x1;
715
+ const y1 = box.y1;
716
+ const x2 = box.x2;
717
+ const y2 = box.y2;
718
+
719
+ this.addCollisionDebugVertices(x1, y1, x2, y2,
720
+ isText ? this.textCollisionBox : this.iconCollisionBox,
721
+ box.anchorPoint, symbolInstance);
722
+ }
723
+ }
724
+
725
+ generateCollisionDebugBuffers() {
726
+ if (this.hasDebugData()) {
727
+ this.destroyDebugData();
728
+ }
729
+
730
+ this.textCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);
731
+ this.iconCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);
732
+
733
+ for (let i = 0; i < this.symbolInstances.length; i++) {
734
+ const symbolInstance = this.symbolInstances.get(i);
735
+ this.addDebugCollisionBoxes(symbolInstance.textBoxStartIndex, symbolInstance.textBoxEndIndex, symbolInstance, true);
736
+ this.addDebugCollisionBoxes(symbolInstance.verticalTextBoxStartIndex, symbolInstance.verticalTextBoxEndIndex, symbolInstance, true);
737
+ this.addDebugCollisionBoxes(symbolInstance.iconBoxStartIndex, symbolInstance.iconBoxEndIndex, symbolInstance, false);
738
+ this.addDebugCollisionBoxes(symbolInstance.verticalIconBoxStartIndex, symbolInstance.verticalIconBoxEndIndex, symbolInstance, false);
739
+ }
740
+ }
741
+
742
+ // These flat arrays are meant to be quicker to iterate over than the source
743
+ // CollisionBoxArray
744
+ _deserializeCollisionBoxesForSymbol(collisionBoxArray: CollisionBoxArray,
745
+ textStartIndex: number, textEndIndex: number,
746
+ verticalTextStartIndex: number, verticalTextEndIndex: number,
747
+ iconStartIndex: number, iconEndIndex: number,
748
+ verticalIconStartIndex: number, verticalIconEndIndex: number): CollisionArrays {
749
+
750
+ const collisionArrays = {};
751
+ for (let k = textStartIndex; k < textEndIndex; k++) {
752
+ const box: CollisionBox = (collisionBoxArray.get(k): any);
753
+ collisionArrays.textBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
754
+ collisionArrays.textFeatureIndex = box.featureIndex;
755
+ break; // Only one box allowed per instance
756
+ }
757
+ for (let k = verticalTextStartIndex; k < verticalTextEndIndex; k++) {
758
+ const box: CollisionBox = (collisionBoxArray.get(k): any);
759
+ collisionArrays.verticalTextBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
760
+ collisionArrays.verticalTextFeatureIndex = box.featureIndex;
761
+ break; // Only one box allowed per instance
762
+ }
763
+ for (let k = iconStartIndex; k < iconEndIndex; k++) {
764
+ // An icon can only have one box now, so this indexing is a bit vestigial...
765
+ const box: CollisionBox = (collisionBoxArray.get(k): any);
766
+ collisionArrays.iconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
767
+ collisionArrays.iconFeatureIndex = box.featureIndex;
768
+ break; // Only one box allowed per instance
769
+ }
770
+ for (let k = verticalIconStartIndex; k < verticalIconEndIndex; k++) {
771
+ // An icon can only have one box now, so this indexing is a bit vestigial...
772
+ const box: CollisionBox = (collisionBoxArray.get(k): any);
773
+ collisionArrays.verticalIconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
774
+ collisionArrays.verticalIconFeatureIndex = box.featureIndex;
775
+ break; // Only one box allowed per instance
776
+ }
777
+ return collisionArrays;
778
+ }
779
+
780
+ deserializeCollisionBoxes(collisionBoxArray: CollisionBoxArray) {
781
+ this.collisionArrays = [];
782
+ for (let i = 0; i < this.symbolInstances.length; i++) {
783
+ const symbolInstance = this.symbolInstances.get(i);
784
+ this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(
785
+ collisionBoxArray,
786
+ symbolInstance.textBoxStartIndex,
787
+ symbolInstance.textBoxEndIndex,
788
+ symbolInstance.verticalTextBoxStartIndex,
789
+ symbolInstance.verticalTextBoxEndIndex,
790
+ symbolInstance.iconBoxStartIndex,
791
+ symbolInstance.iconBoxEndIndex,
792
+ symbolInstance.verticalIconBoxStartIndex,
793
+ symbolInstance.verticalIconBoxEndIndex
794
+ ));
795
+ }
796
+ }
797
+
798
+ hasTextData() {
799
+ return this.text.segments.get().length > 0;
800
+ }
801
+
802
+ hasIconData() {
803
+ return this.icon.segments.get().length > 0;
804
+ }
805
+
806
+ hasDebugData() {
807
+ return this.textCollisionBox && this.iconCollisionBox;
808
+ }
809
+
810
+ hasTextCollisionBoxData() {
811
+ return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0;
812
+ }
813
+
814
+ hasIconCollisionBoxData() {
815
+ return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0;
816
+ }
817
+
818
+ addIndicesForPlacedSymbol(iconOrText: SymbolBuffers, placedSymbolIndex: number) {
819
+ const placedSymbol = iconOrText.placedSymbolArray.get(placedSymbolIndex);
820
+
821
+ const endIndex = placedSymbol.vertexStartIndex + placedSymbol.numGlyphs * 4;
822
+ for (let vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) {
823
+ iconOrText.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2);
824
+ iconOrText.indexArray.emplaceBack(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3);
825
+ }
826
+ }
827
+
828
+ getSortedSymbolIndexes(angle: number) {
829
+ if (this.sortedAngle === angle && this.symbolInstanceIndexes !== undefined) {
830
+ return this.symbolInstanceIndexes;
831
+ }
832
+ const sin = Math.sin(angle);
833
+ const cos = Math.cos(angle);
834
+ const rotatedYs = [];
835
+ const featureIndexes = [];
836
+ const result = [];
837
+
838
+ for (let i = 0; i < this.symbolInstances.length; ++i) {
839
+ result.push(i);
840
+ const symbolInstance = this.symbolInstances.get(i);
841
+ rotatedYs.push(Math.round(sin * symbolInstance.anchorX + cos * symbolInstance.anchorY) | 0);
842
+ featureIndexes.push(symbolInstance.featureIndex);
843
+ }
844
+
845
+ result.sort((aIndex, bIndex) => {
846
+ return (rotatedYs[aIndex] - rotatedYs[bIndex]) ||
847
+ (featureIndexes[bIndex] - featureIndexes[aIndex]);
848
+ });
849
+
850
+ return result;
851
+ }
852
+
853
+ addToSortKeyRanges(symbolInstanceIndex: number, sortKey: number) {
854
+ const last = this.sortKeyRanges[this.sortKeyRanges.length - 1];
855
+ if (last && last.sortKey === sortKey) {
856
+ last.symbolInstanceEnd = symbolInstanceIndex + 1;
857
+ } else {
858
+ this.sortKeyRanges.push({
859
+ sortKey,
860
+ symbolInstanceStart: symbolInstanceIndex,
861
+ symbolInstanceEnd: symbolInstanceIndex + 1
862
+ });
863
+ }
864
+ }
865
+
866
+ sortFeatures(angle: number) {
867
+ if (!this.sortFeaturesByY) return;
868
+ if (this.sortedAngle === angle) return;
869
+
870
+ // The current approach to sorting doesn't sort across segments so don't try.
871
+ // Sorting within segments separately seemed not to be worth the complexity.
872
+ if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1) return;
873
+
874
+ // If the symbols are allowed to overlap sort them by their vertical screen position.
875
+ // The index array buffer is rewritten to reference the (unchanged) vertices in the
876
+ // sorted order.
877
+
878
+ // To avoid sorting the actual symbolInstance array we sort an array of indexes.
879
+ this.symbolInstanceIndexes = this.getSortedSymbolIndexes(angle);
880
+ this.sortedAngle = angle;
881
+
882
+ this.text.indexArray.clear();
883
+ this.icon.indexArray.clear();
884
+
885
+ this.featureSortOrder = [];
886
+
887
+ for (const i of this.symbolInstanceIndexes) {
888
+ const symbolInstance = this.symbolInstances.get(i);
889
+ this.featureSortOrder.push(symbolInstance.featureIndex);
890
+
891
+ [
892
+ symbolInstance.rightJustifiedTextSymbolIndex,
893
+ symbolInstance.centerJustifiedTextSymbolIndex,
894
+ symbolInstance.leftJustifiedTextSymbolIndex
895
+ ].forEach((index, i, array) => {
896
+ // Only add a given index the first time it shows up,
897
+ // to avoid duplicate opacity entries when multiple justifications
898
+ // share the same glyphs.
899
+ if (index >= 0 && array.indexOf(index) === i) {
900
+ this.addIndicesForPlacedSymbol(this.text, index);
901
+ }
902
+ });
903
+
904
+ if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) {
905
+ this.addIndicesForPlacedSymbol(this.text, symbolInstance.verticalPlacedTextSymbolIndex);
906
+ }
907
+
908
+ if (symbolInstance.placedIconSymbolIndex >= 0) {
909
+ this.addIndicesForPlacedSymbol(this.icon, symbolInstance.placedIconSymbolIndex);
910
+ }
911
+
912
+ if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) {
913
+ this.addIndicesForPlacedSymbol(this.icon, symbolInstance.verticalPlacedIconSymbolIndex);
914
+ }
915
+ }
916
+
917
+ if (this.text.indexBuffer) this.text.indexBuffer.updateData(this.text.indexArray);
918
+ if (this.icon.indexBuffer) this.icon.indexBuffer.updateData(this.icon.indexArray);
919
+ }
920
+ }
921
+
922
+ register('SymbolBucket', SymbolBucket, {
923
+ omit: ['layers', 'collisionBoxArray', 'features', 'compareText']
924
+ });
925
+
926
+ // this constant is based on the size of StructArray indexes used in a symbol
927
+ // bucket--namely, glyphOffsetArrayStart
928
+ // eg the max valid UInt16 is 65,535
929
+ // See https://github.com/mapbox/mapbox-gl-js/issues/2907 for motivation
930
+ // lineStartIndex and textBoxStartIndex could potentially be concerns
931
+ // but we expect there to be many fewer boxes/lines than glyphs
932
+ SymbolBucket.MAX_GLYPHS = 65535;
933
+
934
+ SymbolBucket.addDynamicAttributes = addDynamicAttributes;
935
+
936
+ export default SymbolBucket;
937
+ export {addDynamicAttributes};