@mapgis/mapbox-gl 1.9.12 → 16.0.1

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